phpBMS

root/trunk/phpbms/datepicker.php

Revision 702, 6.0 kB (checked in by brieb, 7 months ago)

Updated copyrights to 2010

  • Property svn:keywords set to LastChangedBy LastChangedDate LastChangedRevision
Line 
1<?php
2/*
3 $Rev$ | $LastChangedBy$
4 $LastChangedDate$
5 +-------------------------------------------------------------------------+
6 | Copyright (c) 2004 - 2010, 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                       
41        function displayBox($month,$year,$selectedDate,$db){
42                $thedate=mktime(0,0,0,$month,1,$year);
43                $today=mktime(0,0,0);
44                $todayArray=getdate($today);
45                if($selectedDate!="0000-00-00"){
46                        $selDate=stringToDate($selectedDate,"SQL");
47                        $tempDate=getdate($selDate);
48                        $displayLongDate=$tempDate["month"]." ".$tempDate["mday"].", ".$tempDate["year"];
49                }
50                else {
51                        $selDate=NULL;
52                        $displayLongDate="Click a Date";
53                }               
54?><script language="JavaScript" type="text/javascript">displayLongDate="<?php echo $displayLongDate ?>";</script>
55        <?php 
56        ?><table class="dp" cellspacing="0" cellpadding="0" border="0">
57        <tr>
58                <td colspan=6 class="dpHead"><?php echo date("F, Y",$thedate)?></td>
59                <td class="dpHead"><button type="button" class="graphicButtons buttonX" id="DPCancel" onclick="closeDPBox();"><span>x</span></button></td>
60        </tr>
61        <tr>
62                <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)."'"?>)">&lt;&lt;</td>
63                <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)."'"?>)">&lt;</td>
64                <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>
65                <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)."'"?>)">&gt;</td>
66                <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)."'"?>)">&gt;&gt;</td>
67        </tr>
68        <tr  class="dpDayNames">
69                <td width="14.286%">S</td>
70                <td width="14.286%">M</td>
71                <td width="14.286%">T</td>
72                <td width="14.286%">W</td>
73                <td width="14.286%">R</td>
74                <td width="14.286%">F</td>
75                <td width="14.286%">S</td>
76        </tr>
77        <?php 
78                $firstdate=getdate($thedate);
79                $mydate=$firstdate;
80                while($firstdate["month"]==$mydate["month"]){
81                        if($mydate["wday"]==0) echo "<TR class=\"dpWeek\">";
82                        if($firstdate==$mydate){
83                                // firstdate, so we may have to put in blanks
84                                echo "<TR class=\"dpWeek\">";
85                                for($i=0;$i<$mydate["wday"];$i++)
86                                        echo "<TD>&nbsp;</TD>";
87                        }
88                       
89                        $dayclass="dpReg";
90                        if($thedate==$selDate) $dayclass="dpSelected";
91                        elseif($thedate==$today) $dayclass="dpToday";
92                       
93                        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>";
94                       
95                        if($mydate["wday"]==6) echo "</tr>";
96                        $thedate=strtotime("tomorrow",$thedate);
97                        $mydate=getdate($thedate);
98                }
99               
100                if($mydate["wday"]!=0){
101                        for($i=6;$i>=$mydate["wday"];$i--)
102                                echo "<TD>&nbsp;</TD>";
103                        echo "</TR";
104                }
105        ?>
106        <tr><td id="dpExp" class="dpExplanation" colspan="7"><?php echo $displayLongDate ?></td></tr>   
107</table>
108<?php   }//end function
109
110        if(!isset($_GET["cm"])) 
111                $_GET["cm"]="shw";
112       
113        if(!isset($_GET["sd"]))
114                $_GET["sd"]="0000-00-00";
115
116        switch($_GET["cm"]){
117                case "shw":
118                        displayBox($_GET["m"],$_GET["y"],$_GET["sd"],$db);
119                break;
120        }
121       
122?>
Note: See TracBrowser for help on using the browser.
Copyright © 2010 Kreotek, LLC. All Rights reserved.