/
cal.php
102 lines (100 loc) · 2.31 KB
/
cal.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
<?php
#
# Please initialize $menu before including this file.
#
/**
*
*/
function weeks($menu, $items) {
$index_dow = array(
"Monday" => 0,
"Tuesday" => 1,
"Wednesday" => 2,
"Thursday" => 3,
"Friday" => 4
);
$weeks = array();
$week = array();
foreach ($items as $i) {
$dow = date('l', $menu->timestamp_for_day($i->day));
$index = $index_dow[$dow];
if ($index == 0) {
if (count($week) == 0) {
$week[0] = $i;
} else {
array_push($weeks, $week);
$week = array();
$week[0] = $i;
}
} else {
$week[$index] = $i;
}
}
if (count($week)) array_push($weeks, $week);
return $weeks;
}
$weeks = weeks($menu, $menu->items());
?>
<div id="calendar-section" class="top-section">
<h1><?= strftime('%B %Y Lunch Menu', $menu->timestamp_for_day(2)) ?></h1>
<table id="calendar" width="100%">
<thead>
<tr>
<th>Monday</th><th>Tuesday</th><th>Wednesday</th><th>Thursday</th><th>Friday</th>
</tr>
</thead>
<tbody>
<?php
foreach ($weeks as $week) {
?>
<tr>
<?php
for ($i = 0; $i < 5; $i++) {
$item = false;
$extra = array();
if (array_key_exists($i, $week)) {
$item = $week[$i];
}
if ($item) { $extra = explode('|', $item->body); }
if (!$item) {
?>
<td class="none">
</td>
<?php
} elseif ($item->t == 'food') {
?>
<td class="<?= $item->t ?>">
<h4><?= $item->day ?></h4>
<h5><?= htmlentities($item->title) ?></h5>
<ul>
<li><?= htmlentities($extra[0]) ?></li>
<li><?= htmlentities($extra[1]) ?></li>
<li><?= htmlentities($extra[2]) ?></li>
</ul>
</td>
<?php
} elseif ($item->t == 'dismissal') {
?>
<td class="<?= $item->t ?>">
<h4><?= $item->day ?></h4>
<h5>Dismissal</h5>
</td>
<?php
} elseif ($item->t == 'holiday') {
?>
<td class="<?= $item->t ?>">
<h4><?= $item->day ?></h4>
<h5><?= $item->title ?></h5>
</td>
<?php
}
}
?>
</tr>
<?php
}
?>
</tbody>
</table>
</div>