navigation  interaction  search

 other resources

root/tags/phpbms-0.51/calendar.php

Revision 1 (checked in by mipalmer, 2 years ago)

--

Line 
1 <?php require "include/session.php"?><!--
2 Title: Tigra Calendar
3 URL: http://www.softcomplex.com/products/tigra_calendar/
4 Version: 3.2
5 Date: 10/14/2002 (mm/dd/yyyy)
6 Feedback: feedback@softcomplex.com (specify product title in the subject)
7 Note: Permission given to use this script in ANY kind of applications if
8    header lines are left unchanged.
9 Note: Script consists of two files: calendar?.js and calendar.html
10 About us: Our company provides offshore IT consulting services.
11     Contact us at sales@softcomplex.com if you have any programming task you
12     want to be handled by professionals. Our typical hourly rate is $20.
13 -->
14 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" >
15 <html>
16 <head>
17 <title>Select Date</title>
18 <link href="common/stylesheet/<?php echo $_SESSION["stylesheet"] ?>/base.css" rel="stylesheet" type="text/css">
19 <script language="JavaScript">
20
21 // months as they appear in the calendar's title
22 var ARR_MONTHS = ["January", "February", "March", "April", "May", "June",
23         "July", "August", "September", "October", "November", "December"];
24 // week day titles as they appear on the calendar
25 var ARR_WEEKDAYS = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
26 // day week starts from (normally 0-Su or 1-Mo)
27 var NUM_WEEKSTART = 0;
28 // path to the directory where calendar images are stored. trailing slash req.
29 var STR_ICONPATH = '../common/image/cal/';
30
31 var re_url = new RegExp('datetime=(\\-?\\d+)');
32 var dt_current = (re_url.exec(String(window.location))
33     ? new Date(new Number(RegExp.$1)) : new Date());
34 var re_id = new RegExp('id=(\\d+)');
35 var num_id = (re_id.exec(String(window.location))
36     ? new Number(RegExp.$1) : 0);
37 var obj_caller = (window.opener ? window.opener.calendars[num_id] : null);
38
39 if (obj_caller && obj_caller.year_scroll) {
40     // get same date in the previous year
41     var dt_prev_year = new Date(dt_current);
42     dt_prev_year.setFullYear(dt_prev_year.getFullYear() - 1);
43     if (dt_prev_year.getDate() != dt_current.getDate())
44         dt_prev_year.setDate(0);
45    
46     // get same date in the next year
47     var dt_next_year = new Date(dt_current);
48     dt_next_year.setFullYear(dt_next_year.getFullYear() + 1);
49     if (dt_next_year.getDate() != dt_current.getDate())
50         dt_next_year.setDate(0);
51 }
52
53 // get same date in the previous month
54 var dt_prev_month = new Date(dt_current);
55 dt_prev_month.setMonth(dt_prev_month.getMonth() - 1);
56 if (dt_prev_month.getDate() != dt_current.getDate())
57     dt_prev_month.setDate(0);
58
59 // get same date in the next month
60 var dt_next_month = new Date(dt_current);
61 dt_next_month.setMonth(dt_next_month.getMonth() + 1);
62 if (dt_next_month.getDate() != dt_current.getDate())
63     dt_next_month.setDate(0);
64
65 // get first day to display in the grid for current month
66 var dt_firstday = new Date(dt_current);
67 dt_firstday.setDate(1);
68 dt_firstday.setDate(1 - (7 + dt_firstday.getDay() - NUM_WEEKSTART) % 7);
69
70 // function passing selected date to calling window
71 function set_datetime(n_datetime, b_close) {
72     if (!obj_caller) return;
73
74     var dt_datetime = obj_caller.prs_time(
75         (document.cal ? document.cal.time.value : ''),
76         new Date(n_datetime)
77     );
78
79     if (!dt_datetime) return;
80     if (b_close) {
81         window.close();
82         obj_caller.target.value = (document.cal
83             ? obj_caller.gen_tsmp(dt_datetime)
84             : obj_caller.gen_date(dt_datetime)
85         );
86     }
87     else obj_caller.popup(dt_datetime.valueOf());
88 }
89
90 </script>
91 </head>
92 <body>
93 <div class="bodyline" style="padding:2px;">
94 <div>
95 <table cellspacing="0" cellpadding="0" border="0">
96 <tr>
97 <script language="JavaScript">
98 document.write(
99 '<td nowrap>'+(obj_caller&&obj_caller.year_scroll?'<input type="button" onClick="javascript:set_datetime('+dt_prev_year.valueOf()+')" value="&lt;&lt;" class="smallButtons">':'')+'<input type="button" onClick="javascript:set_datetime('+dt_prev_month.valueOf()+')" value="&lt;" class="smallButtons"></td>'+
100 '<td align="center" width="100%" ><h2 style="margin:0px;padding:0px;">'+ARR_MONTHS[dt_current.getMonth()]+' '+dt_current.getFullYear() + '</H2></td>'+
101 '<td nowrap><input type="button" onClick="javascript:set_datetime('+dt_next_month.valueOf()+')" value="&gt;" class="smallButtons">'+(obj_caller && obj_caller.year_scroll?'<input type="button" onClick="javascript:set_datetime('+dt_next_year.valueOf()+')" value="&gt;&gt;" class="smallButtons">':'')+'</td>'
102 );
103 </script>
104 </tr>
105 </table>
106 </div>
107
108 <div><table cellspacing="0" cellpadding="0" border="0" width="100%" class="calendartable">
109 <tr>
110 <script language="JavaScript">
111
112 // print weekdays titles
113 for (var n=0; n<7; n++)
114     document.write('<td class="dayofweek" align="center">'+ARR_WEEKDAYS[(NUM_WEEKSTART+n)%7]+'</td>');
115 document.write('</tr>');
116
117 // print calendar table
118 var dt_current_day = new Date(dt_firstday);
119 while (dt_current_day.getMonth() == dt_current.getMonth() ||
120     dt_current_day.getMonth() == dt_firstday.getMonth()) {
121     // print row heder
122     document.write('<tr>');
123     for (var n_current_wday=0; n_current_wday<7; n_current_wday++) {
124         if (dt_current_day.getDate() == dt_current.getDate() &&
125             dt_current_day.getMonth() == dt_current.getMonth())
126             // print current date
127             document.write('<td class="today" align="center" width="14%">');
128         else if (dt_current_day.getDay() == 0 || dt_current_day.getDay() == 6)
129             // weekend days
130             document.write('<td class="weekend" align="center" width="14%">');
131         else
132             // print working days of current month
133             document.write('<td class="regulardays" align="center" width="14%">');
134
135         document.write('<a href="javascript:set_datetime('+dt_current_day.valueOf() +', true);"');
136
137         if (dt_current_day.getMonth() == this.dt_current.getMonth())
138             // print days of current month
139             document.write('>');
140         else
141             // print days of other months
142             document.write(' class="othermonths">');
143            
144         document.write(dt_current_day.getDate()+'</a></td>');
145         dt_current_day.setDate(dt_current_day.getDate()+1);
146     }
147     // print row footer
148     document.write('</tr>');
149 }
150 </script>
151 </table></div>
152 <script>
153 if (obj_caller && obj_caller.time_comp)
154     document.write('<form onsubmit="javascript:set_datetime('+dt_current.valueOf()+', true)" name="cal"><div>time<br><input type="text" name="time" value="'+obj_caller.gen_time(this.dt_current)+'" size="8" maxlength="8"><div></form>');
155 </script>
156 </div>
157 </body>
158 </html>
Note: See TracBrowser for help on using the browser.
Copyright © 2006-2007 Kreotek, LLC. All Rights reserved.