forked from craigk5n/webcalendar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatesel.php
119 lines (103 loc) · 3.5 KB
/
datesel.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
<?php // $Id: datesel.php,v 1.57 2009/11/22 16:47:44 bbannon Exp $
include_once 'includes/init.php';
$fday = getGetValue ( 'fday' );
$fmonth = getGetValue ( 'fmonth' );
$fyear = getGetValue ( 'fyear' );
$form = getGetValue ( 'form' );
$date = getGetValue ( 'date' );
if ( strlen ( $date ) > 0 ) {
$thisyear = substr ( $date, 0, 4 );
$thismonth = substr ( $date, 4, 2 );
} else {
$thisyear = date ( 'Y' );
$thismonth = date ( 'm' );
}
$href = 'href="datesel.php?form=' . $form . '&fday=' . $fday
. '&fmonth=' . $fmonth . '&fyear=' . $fyear . '&date=';
$nextdate = $href . date ( 'Ym01"', mktime ( 0, 0, 0, $thismonth + 1, 1, $thisyear ) );
$nextStr = translate ( 'Next' );
$prevdate = $href . date ( 'Ym01"', mktime ( 0, 0, 0, $thismonth - 1, 1, $thisyear ));
$previousStr = translate ( 'Previous' );
$monthStr = month_name ( $thismonth - 1 );
$wkstart = get_weekday_before ( $thisyear, $thismonth );
$monthstartYmd = date ( 'Ymd', mktime ( 0, 0, 0, $thismonth, 1, $thisyear ) );
$monthendYmd = date ( 'Ymd', mktime ( 23, 59, 59, $thismonth + 1, 0, $thisyear ) );
print_header ( '','', '', true, false, true, true, true );
//build weekday names
$wkdys = '';
for ( $i = 0; $i < 7; $i++ ) {
$wkdys .= '<td>' . weekday_name ( ( $i + $WEEK_START ) % 7, 'D' ) . '</td>';
}
//build month grid
$todayYmd = date ( 'Ymd' );
$mdays = '';
for ( $i = $wkstart; date ( 'Ymd', $i ) <= $monthendYmd; $i += 604800 ) {
$mdays .= '
<tr>';
for ( $j = 0; $j < 7; $j++ ) {
$date = $i + ( $j * 86400 ) + 43200;
$dateYmd = date ( 'Ymd', $date );
$class=' class="field "';
if ( $dateYmd == $todayYmd )
$class .= ' id="today" ';
$mdays .= '
<td'
. ( ( $dateYmd >= $monthstartYmd && $dateYmd <= $monthendYmd ) ||
$DISPLAY_ALL_DAYS_IN_MONTH == 'Y'
? $class . '><a href="javascript:sendDate(\''
. $dateYmd . '\')">' . date ( 'j', $date ) . '</a>'
: '>' ) . '</td>';
}
$mdays .= '
</tr>';
}
$mdays .= '
</table>
</td>
</tr>
</table>
</div>
';
echo <<<EOT
<div class="aligncenter">
<table class="aligncenter">
<tr>
<td class="aligncenter aligntop">
<table class="aligncenter" cellpadding="3" cellspacing="2">
<tr>
<td><a title="{$previousStr}" class="prev" {$prevdate}>
<img src="images/leftarrowsmall.gif"
alt="{$previousStr}" /></a></td>
<th colspan="5"> {$monthStr} {$thisyear} </th>
<td><a title="{$nextStr}"class="next" {$nextdate}>
<img src="images/rightarrowsmall.gif"
alt="{$nextStr}" /></a></td>
</tr>
<tr class="day">
{$wkdys}
</tr>
{$mdays}
<!--We'll leave this javascript here to speed things up. -->
<script>
<!-- <![CDATA[
function sendDate ( date ) {
year = date.substring ( 0, 4 );
month = date.substring ( 4, 6 );
day = date.substring ( 6, 8 );
sday = window.opener.document.{$form}.{$fday};
smonth = window.opener.document.{$form}.{$fmonth};
syear = window.opener.document.{$form}.{$fyear};
sday.selectedIndex = day - 1;
smonth.selectedIndex = month - 1;
for ( i = 0; i < syear.length; i++ ) {
if ( syear.options[i].value == year ) {
syear.selectedIndex = i;
}
}
window.close();
}
//]]> -->
</script>
EOT;
echo print_trailer ( false, true, true );
?>