navigation  interaction  search

 other resources

root/tags/phpbms-0.7/datepicker.php

Revision 205 (checked in by brieb, 2 years ago)

Updated XHTML compliance

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