user_shifts fixed error with empty shifts table

This commit is contained in:
Philip Häusler 2011-09-14 22:45:15 +02:00
parent a5c6ad4393
commit 8e35c721d7
1 changed files with 51 additions and 48 deletions

View File

@ -103,6 +103,8 @@ function user_shifts() {
} else { } else {
$shifts = sql_select("SELECT * FROM `Shifts` ORDER BY `start`"); $shifts = sql_select("SELECT * FROM `Shifts` ORDER BY `start`");
$days = array (); $days = array ();
$rooms = array ();
if (count($shifts) > 0) {
foreach ($shifts as $shift) foreach ($shifts as $shift)
$days[] = date("Y-m-d", $shift['start']); $days[] = date("Y-m-d", $shift['start']);
$days = array_unique($days); $days = array_unique($days);
@ -159,6 +161,7 @@ function user_shifts() {
if ($id != 0 || ($show_shift && $row_count++ < 15)) if ($id != 0 || ($show_shift && $row_count++ < 15))
$shifts_table .= $shift_row . '</td></tr>'; $shifts_table .= $shift_row . '</td></tr>';
} }
}
return template_render('../templates/user_shifts.html', array ( return template_render('../templates/user_shifts.html', array (
'room_select' => make_room_select($rooms, $id, $day), 'room_select' => make_room_select($rooms, $id, $day),