navigation  interaction  search

 other resources

root/tags/phpbms-0.61/datepicker.php

Revision 51 (checked in by brieb, 3 years ago)

- Added license to the top of every page with code.

Line 
1 <?php
2 /*
3  +-------------------------------------------------------------------------+
4  | Copyright (c) 2005, Kreotek LLC                                         |
5  | All rights reserved.                                                    |
6  +-------------------------------------------------------------------------+
7  |                                                                         |
8  | Redistribution and use in source and binary forms, with or without      |
9  | modification, are permitted provided that the following conditions are  |
10  | met:                                                                    |
11  |                                                                         |
12  | - Redistributions of source code must retain the above copyright        |
13  |   notice, this list of conditions and the following disclaimer.         |
14  |                                                                         |
15  | - Redistributions in binary form must reproduce the above copyright     |
16  |   notice, this list of conditions and the following disclaimer in the   |
17  |   documentation and/or other materials provided with the distribution.  |
18  |                                                                         |
19  | - Neither the name of Kreotek LLC nor the names of its contributore may |
20  |   be used to endorse or promote products derived from this software     |
21  |   without specific prior written permission.                            |
22  |                                                                         |
23  | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS     |
24  | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT       |
25  | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
26  | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT      |
27  | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,   |
28  | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT        |
29  | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,   |
30  | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY   |
31  | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT     |
32  | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE   |
33  | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.    |
34  |                                                                         |
35  +-------------------------------------------------------------------------+
36 */
37     require_once("include/session.php");
38     require_once("include/common_functions.php");
39             
40     function displayBox($month,$year,$selectedDate){
41         global $dblink;
42         
43         $thedate=mktime(0,0,0,$month,1,$year);
44         $today=mktime(0,0,0);
45         $todayArray=getdate($today);
46         if($selectedDate!="0000-00-00"){
47             $selDate=dateFromSQLDate($selectedDate);
48             $tempDate=getdate($selDate);
49             $displayLongDate=$tempDate["month"]." ".$tempDate["mday"].", ".$tempDate["year"];
50         }
51         else {
52             $selDate=NULL;
53             $displayLongDate="Click a Date";
54         }       
55 ?><script language="javascript">displayLongDate="<?php echo $displayLongDate ?>";</script>
56     <?php
57     ?><table class="dp" cellspacing="0" cellpadding="0" border=0>
58     <tr>
59         <td colspan=6 class="dpHead"><?php echo date("F, Y",$thedate)?></td>
60         <td class="dpHead"><button type="buttton" class="invisibleButtons" id="DPCancel" onClick="closeDPBox();"><img src="<?php echo $_SESSION["app_path"] ?>common/stylesheet/<?php echo $_SESSION["stylesheet"] ?>/button-x.png" align="absmiddle" alt="x" width="16" height="16" border="0" /></button></td>
61     </tr>
62     <tr>
63         <td class="dpButtons" onClick="loadMonth('<?php echo $_SESSION["app_path"]?>','<?php echo $month?>','<?php echo $year-1?>'<?php if($selDate) echo ",'".date("m/d/Y",$selDate)."'"?>)">&lt;&lt;</td>
64         <td class="dpButtons" onClick="loadMonth('<?php echo $_SESSION["app_path"]?>','<?php if($month==1) echo "12"; else echo $month-1?>','<?php if($month==1) echo $year-1; else echo $year?>'<?php if($selDate) echo ",'".date("m/d/Y",$selDate)."'"?>)">&lt;</td>
65         <td colspan=3 class="dpButtons" onClick="loadMonth('<?php echo $_SESSION["app_path"]?>','<?php echo date('m',$today)?>','<?php echo $todayArray["year"]?>'<?php if($selDate) echo ",'".date("m/d/Y",$selDate)."'"?>)">Today</td>
66         <td class="dpButtons" onClick="loadMonth('<?php echo $_SESSION["app_path"]?>','<?php if($month==12) echo "1"; else echo $month+1?>','<?php if($month==12) echo $year+1; else echo $year;?>'<?php if($selDate) echo ",'".date("m/d/Y",$selDate)."'"?>)">&gt;</td>
67         <td class="dpButtons" onClick="loadMonth('<?php echo $_SESSION["app_path"]?>','<?php echo $month?>','<?php echo $year+1?>'<?php if($selDate) echo ",'".date("m/d/Y",$selDate)."'"?>)">&gt;&gt;</td>
68     </tr>
69     <tr  class="dpDayNames">
70         <td width="14.286%">S</td>
71         <td width="14.286%">M</td>
72         <td width="14.286%">T</td>
73         <td width="14.286%">W</td>
74         <td width="14.286%">R</td>
75         <td width="14.286%">F</td>
76         <td width="14.286%">S</td>
77     </tr>
78     <?php
79         $firstdate=getdate($thedate);
80         $mydate=$firstdate;
81         while($firstdate["month"]==$mydate["month"]){
82             if($mydate["wday"]==0) echo "<TR class=\"dpWeek\">";
83             if($firstdate==$mydate){
84                 // firstdate, so we may have to put in blanks
85                 echo "<TR class=\"dpWeek\">";
86                 for($i=0;$i<$mydate["wday"];$i++)
87                     echo "<TD>&nbsp;</TD>";
88             }
89             
90             $dayclass="dpReg";
91             if($thedate==$selDate) $dayclass="dpSelected";
92             elseif($thedate==$today) $dayclass="dpToday";
93             
94             echo "<TD class=\"".$dayclass."\" onMouseOut=\"dpUnhighlightDay();\" onMouseOver=\"dpHighlightDay(".$mydate["year"].",".date("n",$thedate).",".$mydate["mday"].")\" onClick=\"dpClickDay(".$mydate["year"].",".date("n",$thedate).",".$mydate["mday"].")\">".$mydate["mday"]."</TD>";
95             
96             if($mydate["wday"]==6) echo "</tr>";
97             $thedate=strtotime("tomorrow",$thedate);
98             $mydate=getdate($thedate);
99         }
100         
101         if($mydate["wday"]!=0){
102             for($i=6;$i>=$mydate["wday"];$i--)
103                 echo "<TD>&nbsp;</TD>";
104             echo "</TR";
105         }
106     ?>
107     <tr><td id="dpExp" class="dpExplanation" colspan="7"><?php echo $displayLongDate ?></td></tr>   
108 </table>
109 <?php    }//end function
110
111     if(!isset($_GET["cm"]))
112         $_GET["cm"]="shw";
113     
114     if(!isset($_GET["sd"]))
115         $_GET["sd"]="0000-00-00";
116
117     switch($_GET["cm"]){
118         case "shw":
119             displayBox($_GET["m"],$_GET["y"],$_GET["sd"]);
120         break;
121     }
122     
123 ?>
Note: See TracBrowser for help on using the browser.
Copyright © 2006-2007 Kreotek, LLC. All Rights reserved.