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