Subversion Repositories public

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4 andreas 1
<?
2
require_once('version.inc');
3
require_once('settings.inc');
4
require_once('dbaccess.inc');
5
require_once('language.inc');
6
require_once('header.inc');
7
 
8
function calendar($date, $target) {
9
	//If no parameter is passed use the current date.
10
	if($date == null)
11
	   $date = getDate();
12
 
13
	$day = $date["mday"];
14
	$month = $date["mon"];
15
	$month_name = $date["month"];
16
	$year = $date["year"];
17
 
18
	$this_month = getDate(mktime(0, 0, 0, $month, 1, $year));
19
	$next_month = getDate(mktime(0, 0, 0, $month + 1, 1, $year));
20
 
21
	//Find out when this month starts and ends.
22
	$first_week_day = $this_month["wday"];
23
	$days_in_this_month = daysinmonth($this_month["mon"], $this_month["mday"]);
24
	$calendar_html = "<table class=\"cal\">\n";
25
 
26
	$calendar_html .= "<tr><td class=\"cal_center\" colspan=\"7\">" .
27
			$month_name . " " . $year . "</td></tr>\n";
28
 
29
	$calendar_html .= "<tr><td>So</td><td>Mo</td><td>Di</td>";
30
	$calendar_html .= "<td>Mi</td><td>Do</td><td>Fr</td>";
31
	$calendar_html .= "<td>Sa</td></tr>\n";
32
	$calendar_html .= "<tr>";
33
 
34
	//Fill the first week of the month with the appropriate number of blanks.
35
	for($week_day = 0; $week_day < $first_week_day; $week_day++) {
36
	   $calendar_html .= "<td class=\"cal\"> </td>\n";
37
	}
38
 
39
	$week_day = $first_week_day;
40
 
41
	for($day_counter = 1; $day_counter <= $days_in_this_month; $day_counter++) {
42
	   $week_day %= 7;
43
 
44
	   if($week_day == 0)
45
	      $calendar_html .= "</tr>\n<tr>";
46
 
47
	   //Do something different for the current day.
48
	   $dstr = $day_counter . "." . $month . "." . $year;
49
 
50
	   if($day == $day_counter) {
51
	      $calendar_html .= "<td align=\"center\"><a href=\"javascript:SetValue('";
52
	      $calendar_html .= $target . "','" . $dstr . "')\"><b>" . $day_counter . "</b></a></td>\n";
53
	   } else {
54
	      $calendar_html .= "<td class=\"cal_center\">&nbsp;";
55
	      $calendar_html .= "<a href=\"javascript:SetValue('" . $target . "','" . $dstr . "')\">";
56
	      $calendar_html .= $day_counter . "</td>\n";
57
	   }
58
 
59
	   $week_day++;
60
	}
61
 
62
	$calendar_html .= "</tr>\n";
63
	$calendar_html .= "</table>\n";
64
 
65
	return($calendar_html);
66
}
67
 
68
/*
69
 * Steuerung des Kalenders
70
 */
71
$target = $_REQUEST['target'];
72
$month = $_REQUEST['month'];
73
$year = $_REQUEST['year'];
74
$mback = $_REQUEST['mback'];
75
$mforw = $_REQUEST['mforw'];
76
$yback = $_REQUEST['yback'];
77
$yforw = $_REQUEST['yforw'];
78
$edit = $_REQUEST['edit'];
79
 
80
if (isset($edit)) {
81
   $datum = getDate($edit);
82
}
83
 
84
if (isset($month) && isset($year)) {
85
   $datum = getDate(mktime(0, 0, 0, $month, 1, $year));
86
} else if (!isset($datum)) {
87
   $datum = getDate();
88
}
89
 
90
if (isset($mback)) {
91
   $month = $datum["mon"];
92
   $year = $datum["year"];
93
 
94
   $month--;
95
 
96
   if ($month < 1) {
97
      $month = 12;
98
      $year--;
99
   }
100
 
101
   $datum = getDate(mktime(0, 0, 0, $month, 1, $year));
102
}
103
 
104
if (isset($yback)) {
105
   $month = $datum["mon"];
106
   $year = $datum["year"];
107
   $year--;
108
   $datum = getDate(mktime(0, 0, 0, $month, 1, $year));
109
}
110
 
111
if (isset($mforw)) {
112
   $month = $datum["mon"];
113
   $year = $datum["year"];
114
 
115
   $month++;
116
 
117
   if ($month > 12) {
118
      $month = 1;
119
      $year++;
120
   }
121
 
122
   $datum = getDate(mktime(0, 0, 0, $month, 1, $year));
123
}
124
 
125
if (isset($yforw)) {
126
   $month = $datum["mon"];
127
   $year = $datum["year"];
128
   $year++;
129
   $datum = getDate(mktime(0, 0, 0, $month, 1, $year));
130
}
131
 
132
$month = $datum["mon"];
133
$year = $datum["year"];
134
 
135
//echo "<form name=\"cal\" action=\"calendar.php\" method=\"post\">\n";
136
echo "<form name=\"calendar\">\n";
137
echo "<input type=\"hidden\" name=\"header\" value=\"1\">\n";
138
echo "<input type=\"hidden\" name=\"target\" value=\"$target\">\n";
139
echo "<input type=\"hidden\" name=\"month\" value=\"$month\">\n";
140
echo "<input type=\"hidden\" name=\"year\" value=\"$year\">\n";
141
echo "<table class=\"input\"><tr><td>";
142
echo "<table border=0 cellspacing=0 cellpadding=0><tr>";
143
echo "<td><input type=\"submit\" name=\"yback\" value=\"<<<\"></td>\n";
144
//echo "<td>";
145
//Button("<<<", "cal", "yback", "1");
146
//echo "</td>";
147
echo "<td><input type=\"submit\" name=\"mback\" value=\"<--\"></td>\n";
148
//echo "<td>";
149
//Button("<--", "cal", "mback", "1");
150
//echo "</td>";
151
echo "</tr></table>\n";
152
echo "</td><td valign=\"right\">";
153
echo "<table border=0 cellspacing=0 cellpadding=0><tr>";
154
echo "<td><input type=\"submit\" name=\"mforw\" value=\"-->\"></td>\n";
155
//echo "<td>";
156
//Button("-->", "cal", "mforw", "1");
157
//echo "</td>";
158
echo "<td><input type=\"submit\" name=\"yforw\" value=\">>>\"></td>\n";
159
//echo "<td>";
160
//Button(">>>", "cal", "yforw", "1");
161
//echo "</td>";
162
echo "</tr></table>\n";
163
echo "</td></tr></table>\n";
164
echo calendar($datum, $target);
165
echo "<table class=\"indent\"><tr><td>";
166
ButtonProg("Schliessen", "self.close()");
167
echo "</td></tr></table>";
168
//echo "<input type=\"button\" name=\"close\" value=\"Schliessen\" onClick=\"javascript:self.close()\">\n";
169
echo "</form>\n";
170
 
171
require('footer.inc');
172
?>