aboutsummaryrefslogtreecommitdiffstats
path: root/week.php
blob: 0d3e0c771e212d8c23ba81b74f51e5288ecabeef (plain) (blame)
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
<?php

$current_view = "week";
define('BASE', './');
include(BASE.'functions/ical_parser.php');
if ($minical_view == "current") $minical_view = "week";

$starttime 			= "0500";
$weekstart 			= 1;
$unix_time 			= strtotime($getdate);
$thisday2 			= localizeDate($dateFormat_week_list, $unix_time);
$today_today 		= date('Ymd', strtotime("now + $second_offset seconds")); 
$next_week 			= date("Ymd", strtotime("+1 week",  $unix_time));
$prev_week 			= date("Ymd", strtotime("-1 week",  $unix_time));
$tomorrows_date 	= date( "Ymd", strtotime("+1 day",  $unix_time));
$yesterdays_date 	= date( "Ymd", strtotime("-1 day",  $unix_time));
$start_week_time 	= strtotime(dateOfWeek($getdate, $week_start_day));
$end_week_time 		= $start_week_time + (6 * 25 * 60 * 60);
$start_week 		= localizeDate($dateFormat_week, $start_week_time);
$end_week 			= localizeDate($dateFormat_week, $end_week_time);
$display_date 		= "$start_week - $end_week";

// For the side months
ereg ("([0-9]{4})([0-9]{2})([0-9]{2})", $getdate, $day_array2);
$this_day = $day_array2[3]; 
$this_month = $day_array2[2];
$this_year = $day_array2[1];

$dayborder = 0;
$thisdate = $start_week_time;
for ($i=0;$i<7;$i++) {
	$thisday = date("Ymd", $thisdate);
	$nbrGridCols[$thisday] = 1;
	if (isset($master_array[$thisday])) {
		foreach($master_array[($thisday)] as $ovlKey => $ovlValue) {
			if ($ovlKey != "-1") {
				foreach($ovlValue as $ovl2Value) {
					$nbrGridCols[($thisday)] = kgv($nbrGridCols[($thisday)], ($ovl2Value["event_overlap"] + 1));
				}
			}
		} 
	}
	$thisdate = ($thisdate + (25 * 60 * 60));
}
include (BASE.'includes/header.inc.php'); 

?>

<center>
<table border="0" width="720" cellspacing="0" cellpadding="0">
	<tr>
		<td width="540" valign="top">
			<table width="540" border="0" cellspacing="0" cellpadding="0" class="calborder">
				<tr>
					<td align="center" valign="middle">
						<table width="100%" border="0" cellspacing="0" cellpadding="0">
							<tr>
								<td align="left" width="120" class="navback">&nbsp;</td>
								<td class="navback">
									<table width="100%" border="0" cellspacing="0" cellpadding="0">
										<tr>
											<td align="right" width="40%" class="navback"><?php echo "<a class=\"psf\" href=\"week.php?cal=$cal&amp;getdate=$prev_week\"><img src=\"styles/$style_sheet/left_day.gif\" alt=\"[$last_week_lang]\" border=\"0\" align=\"right\"></a>"; ?></td>
											<td align="center" width="20%" class="navback" nowrap valign="middle"><font class="H20"><?php echo $display_date; ?></font></td>
											<td align="left" width="40%" class="navback"><?php echo "<a class=\"psf\" href=\"week.php?cal=$cal&amp;getdate=$next_week\"><img src=\"styles/$style_sheet/right_day.gif\" alt=\"[$next_week_lang]\" border=\"0\" align=\"left\"></a>"; ?></td>
										</tr>
									</table>
								</td>
								<td align="right" width="120" class="navback">	
									<table width="120" border="0" cellpadding="0" cellspacing="0">
										<tr>
											<td><?php echo '<a class="psf" href="day.php?cal='.$cal.'&amp;getdate='.$getdate.'"><img src="styles/'.$style_sheet.'/day_on.gif" alt="'.$day_view_lang.'" border="0"></a></td>'; ?>
											<td><?php echo '<a class="psf" href="week.php?cal='.$cal.'&amp;getdate='.$getdate.'"><img src="styles/'.$style_sheet.'/week_on.gif" alt="'.$week_view_lang.'" border="0"></a></td>'; ?>
											<td><?php echo '<a class="psf" href="month.php?cal='.$cal.'&amp;getdate='.$getdate.'"><img src="styles/'.$style_sheet.'/month_on.gif" alt="'.$month_view_lang.'" border="0"></a></td>'; ?>
											<td><?php echo '<a class="psf" href="year.php?cal='.$cal.'&amp;getdate='.$getdate.'"><img src="styles/'.$style_sheet.'/year_on.gif" alt="'.$year_view_lang.'" border="0"></a></td>'; ?>
										</tr>
									</table>
								</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<td>
						<table width="100%" border="0" cellspacing="0" cellpadding="0" class="G10B">      			
							<tr>
								<td align="center" valign="top">
									<table width="100%" border="0" cellspacing="0" cellpadding="0">
										<tr>
											<td width="60"><img src="images/spacer.gif" width="60" height="1" alt=" "></td>
											<td width="1"></td>
											<?php
											$thisdate = $start_week_time;
											$i = 0;
											do {
												$thisday = date("Ymd", $thisdate);
												$colWidth = round(70 / $nbrGridCols[$thisday]);
												for ($j=0;$j < $nbrGridCols[$thisday];$j++) {
													echo "<td width=\"" . $colWidth . "\"><img src=\"images/spacer.gif\" width=\"" . $colWidth . "\" height=\"1\" alt=\" \"></td>\n";
												}
												$thisdate = ($thisdate + (25 * 60 * 60));
												$i++;
											} while ($i < 7);
											?>
										</tr>
										<?php
										
										// print out the day names here
										echo "<tr>";
										$thisdate = $start_week_time;
										$i = 0;
										echo "<td class=\"dateback\" width=\"60\"><img src=\"images/spacer.gif\" width=\"1\" height=\"12\" alt=\" \"></td>";
										echo "<td class=\"dateback\" width=\"1\"></td>";
										do {
											$thisday = date("Ymd", $thisdate);
											$thisday3 = localizeDate($dateFormat_week_list, $thisdate);
											echo "<td width=\"70\" colspan=\"" . $nbrGridCols[$thisday] . "\" valign=\"top\" align=\"center\" class=\"dateback\">\n";
											echo "<font class=\"V9\"><a class=\"psf\" href=\"day.php?cal=$cal&amp;getdate=$thisday\">$thisday3</a></font>\n";
											echo "</td>\n";
											$thisdate = ($thisdate + (25 * 60 * 60));
											$i++;
										} while ($i < 7);
										echo "</tr>";
										?>
										<tr>
											<td width="60"><img src="images/spacer.gif" width="60" height="1" alt=" "></td>
											<td width="1"></td>
											<?php
											$thisdate = $start_week_time;
											$i = 0;
											do {
												$thisday = date("Ymd", $thisdate);
												$colWidth = round(70 / $nbrGridCols[$thisday]);
												for ($j=0;$j < $nbrGridCols[$thisday];$j++) {
													echo "<td width=\"" . $colWidth . "\"><img src=\"images/spacer.gif\" width=\"" . $colWidth . "\" height=\"1\" alt=\" \"></td>\n";
												}
												$thisdate = ($thisdate + (25 * 60 * 60));
												$i++;
											} while ($i < 7);
											?>
										</tr>
										<?php
										// The all day events returned here.
										$allday_events_this_week = false;
										$thisdate = $start_week_time;
										for ($i=0;$i<7;$i++) {
											$thisday = date("Ymd", $thisdate);
											if (isset($master_array[($thisday)]["-1"])) {
												$allday_events_this_week = true;
												break;
											}
											$thisdate = ($thisdate + (25 * 60 * 60));
										}
										if ($allday_events_this_week) {
											$thisdate = $start_week_time;
											$i = 0;
											echo "<tr>\n";
											echo "<td class=\"dateback\" colspan=\"2\"></td>";
											do {
												$thisday = date("Ymd", $thisdate);
												echo "<td class=\"dateback\" height=\"20\" colspan=\"" . $nbrGridCols[$thisday] . "\" valign=\"bottom\">\n";
												if (isset($master_array[($thisday)]["-1"])) {
													echo "<table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"4\" class=\"V9\">\n";
												  	foreach($master_array[($thisday)]["-1"] as $allday) {
														echo "<tr>\n";
														$event_calno  = $allday['calnumber'];
						 								if ($event_calno < 1) $event_calno=1;
														if ($event_calno > 7) $event_calno=7;
						 								echo '<td valign="top" align="center" class="eventbg_'.$event_calno.'">';
														openevent("$calendar_name",
														"",
													  	"",
													  	$allday,
													  	$allday_week_lines,
													  	12,
													  	'<font color="#ffffff">',
													  	"</font>",
													  	"psf");
														echo "</td></tr>\n";
												  	}
												  echo "</table>\n";
												}
												echo "</td>\n";
												$thisdate = ($thisdate + (25 * 60 * 60));
												$i++;
											  } while ($i < 7);
											echo "</tr>\n";
										}
											// $master_array[($getdate)]["$day_time"]
											
											$thisdate = $start_week_time;
											for ($i=0;$i<7;$i++) {
												$thisday = date("Ymd", $thisdate);
												$event_length[$thisday] = array ();
												$thisdate = ($thisdate + (25 * 60 * 60));
											}
											foreach ($day_array as $key) {
												$cal_time = $key;	
												ereg('([0-9]{2})([0-9]{2})', $key, $regs_tmp);
												$key = mktime($regs_tmp[1],$regs_tmp[2],0,$this_month,$this_day,$this_year);
												$key = date ($timeFormat, $key);
																					
			
												if (ereg("([0-9]{1,2}):00", $key)) {
													echo "<tr>\n";
													echo "<td rowspan=\"" . (60 / $gridLength) . "\" align=\"center\" valign=\"top\" width=\"60\" class=\"timeborder\">$key</td>\n";
													echo "<td width=\"1\" height=\"" . $gridLength . "\"></td>\n";
												} elseif("$cal_time" == "$day_start") {
													$size_tmp = 60 - (int)substr($cal_time,2,2);
													echo "<tr>\n";
													echo "<td rowspan=\"" . ($size_tmp / $gridLength) . "\" align=\"center\" valign=\"top\" width=\"60\" class=\"timeborder\">$key</td>\n";
													echo "<td width=\"1\" height=\"" . $gridLength . "\"></td>\n";
												} else {
			
													echo "<tr>\n";
													echo "<td width=\"1\" height=\"" . $gridLength . "\"></td>\n";
												}
												
												// initialize $thisdate again
												$thisdate = $start_week_time;
												
												// loop this part 7 times, one for each day
												
												for ($week_loop=0; $week_loop<7; $week_loop++) {
													$thisday = date("Ymd", $thisdate);
													$dayborder = 0;
													unset($this_time_arr);
													if (isset($master_array[$thisday][$cal_time]) && sizeof($master_array[$thisday][$cal_time]) > 0) {
														$this_time_arr = $master_array[$thisday][$cal_time];
													}
														
													if ("$day_start" == "$cal_time" && isset($master_array[$thisday]) && is_array($master_array[$thisday])) {
														foreach($master_array[$thisday] as $time_key => $time_arr) {
															if ((int)$time_key < (int)$cal_time && is_array($time_arr) && $time_key != '-1') {
																foreach($time_arr as $event_tmp) {
																	if ((int)$event_tmp['event_end'] > (int)$cal_time) {
																		$this_time_arr[] = $event_tmp;
																	}
																}
															} else {
																break;
															}
														}
													}
													
													
													// check for eventstart 
													if (isset($this_time_arr) && sizeof($this_time_arr) > 0) {
														foreach ($this_time_arr as $eventKey => $loopevent) {
															$drawEvent = drawEventTimes ($cal_time, $loopevent["event_end"]);
															$j = 0;
															while (isset($event_length[$thisday][$j])) {
																if ($event_length[$thisday][$j]["state"] == "ended") {
																	$event_length[$thisday][$j] = array ("length" => ($drawEvent["draw_length"] / $gridLength), "key" => $eventKey, "overlap" => $loopevent["event_overlap"],"state" => "begin");
																	break;
																}
																$j++;
															}
															if ($j == sizeof($event_length[$thisday])) {
																array_push ($event_length[$thisday], array ("length" => ($drawEvent["draw_length"] / $gridLength), "key" => $eventKey, "overlap" => $loopevent["event_overlap"],"state" => "begin"));
															}
														}
													}
			
													if (sizeof($event_length[$thisday]) == 0) {
														if ($dayborder == 0) {
															$class = " class=\"weekborder\"";
															$dayborder++;
														} else {
															$class = "";
															$dayborder = 0;
														}
														
														echo "<td bgcolor=\"#ffffff\" colspan=\"" . $nbrGridCols[$thisday] . "\" $class>&nbsp;</td>\n";
														
													} else {
														$emptyWidth = $nbrGridCols[$thisday];
														for ($i=0;$i<sizeof($event_length[$thisday]);$i++) {
														
														//echo $this_time_arr[($event_length[$thisday][$i]["key"])]["event_text"] . " ind: " . $i . " / anz: " . $event_length[$thisday][$i]["overlap"] . " = " . eventWidth($i,$event_length[$thisday][$i]["overlap"]) . "<br />";
															$drawWidth = $nbrGridCols[$thisday] / ($event_length[$thisday][$i]["overlap"] + 1);
															$emptyWidth = $emptyWidth - $drawWidth;
															switch ($event_length[$thisday][$i]["state"]) {
																case "begin":
																	$event_length[$thisday][$i]["state"] = "started";
																	$event_start 	= $this_time_arr[($event_length[$thisday][$i]["key"])]["start_unixtime"];
																	$event_start 	= date ($timeFormat, $event_start);
																	$event_calno  = $this_time_arr[($event_length[$thisday][$i]['key'])]['calnumber'];
																	$event_status	= strtolower($this_time_arr[($event_length[$thisday][$i]['key'])]['status']);
												  					if ($event_calno < 1) $event_calno = 1;
												  					if ($event_calno > 7) $event_calno = 7;
																	echo '<td rowspan="' . $event_length[$thisday][$i]['length'] . '" colspan="' . $drawWidth . '" align="left" valign="top" class="eventbg2week_'.$event_calno.'">'."\n";
																	echo "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n";
																	echo "<tr>\n";
																	echo "<td class=\"eventborder\"><font class=\"V10WB\"><b>$event_start</b></font></td>\n";
																	if ($event_status != '') {
																		echo '<td class="eventborder" width="9" align="right" valign="center"><font class="eventfont">';
																		echo '<img src="images/'.$event_status.'.gif" width="9" height="9" alt="" border="0" hspace="0" vspace="0">';
																		echo "</font></td>\n";
																	}
																	echo "</tr>\n";
																	echo "<tr>\n";
																	echo "<td colspan=\"2\">\n";
																	echo "<table width=\"100%\" border=\"0\" cellpadding=\"1\" cellspacing=\"0\">\n";
																	echo "<tr>\n";
																	echo '<td class="eventbg_'.$event_calno.'">';
																	$event_end	= $this_time_arr[($event_length[$thisday][$i]["key"])]["end_unixtime"];
																	$event_end 		= date ($timeFormat, $event_end);
																	// Todo: keep track of where the event comes from, and indicate that to openevent instead of $ALL_CALENDARS_COMBINED
																	if ($cal == $ALL_CALENDARS_COMBINED) $calendar_name2=$cal; else $calendar_name2=$calendar_name;
																	openevent("$calendar_name2",
																		  "$event_start",
																		  "$event_end",
																		  $this_time_arr[($event_length[$thisday][$i]["key"])],
																		  $week_events_lines,
																		  25,
																		  "<font class=\"V10W\">",
																		  "</font>",
																		  "psf");
																	echo "</td></tr>\n";
																	echo "</table>\n";
																	echo "</td>\n";           
																	echo "</tr>\n";
																	echo "</table>\n";
																	echo "</td>\n";
																	break;
																case "started":
																	break;
																case "ended":
																	echo "<td bgcolor=\"#ffffff\" colspan=\"" . $drawWidth . "\" $class>&nbsp;</td>\n";
																	break;
															}
															$event_length[$thisday][$i]["length"]--;
															if ($event_length[$thisday][$i]["length"] == 0) {
																$event_length[$thisday][$i]["state"] = "ended";
															}
														}
														//fill emtpy space on the right
														if ($emptyWidth > 0) {
															echo "<td bgcolor=\"#ffffff\" colspan=\"" . $emptyWidth . "\" $class>&nbsp;</td>\n";
														}
														while (isset($event_length[$thisday][(sizeof($event_length[$thisday]) - 1)]["state"]) && $event_length[$thisday][(sizeof($event_length[$thisday]) - 1)]["state"] == "ended") {
															array_pop($event_length[$thisday]);
														}
													}
													$thisdate = ($thisdate + (25 * 60 * 60));
												}
												echo "</tr>\n";
											}
			
										?>
								</table>
							</td>
						</tr>
						</table>
					</td>
				</tr>
			</table>
		</td>
		<td width="10"><img src="images/spacer.gif" width="10" height="1" alt=" "></td>
		<td width="170" valign="top">
			<?php include (BASE.'includes/sidebar.php'); ?>
		</td>
	</tr>
</table>
</center>
<?php include (BASE.'includes/footer.inc.php'); ?>

© 2014-2024 Faster IT GmbH | imprint | privacy policy