From 80bff6bab6e4de9da33d46dc8816f14d1f9dee4a Mon Sep 17 00:00:00 2001 From: Philip Häusler Date: Thu, 14 Jul 2011 19:53:26 +0200 Subject: angel shift signup --- includes/pages/user_shifts.php | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) (limited to 'includes') diff --git a/includes/pages/user_shifts.php b/includes/pages/user_shifts.php index 72824c6f..cb1a8641 100644 --- a/includes/pages/user_shifts.php +++ b/includes/pages/user_shifts.php @@ -1,12 +1,14 @@ View my shifts »'; + } + return template_render('../templates/user_shifts_add.html', array ( 'date' => date("Y-m-d H:i", $shift['start']) . ', ' . date("H:i", $shift['end'] - $shift['start']) . 'h', - 'title' => $shift['name'] + 'title' => $shift['name'], + 'location' => $shift['Name'], + 'angel' => $user['Nick'], + 'type' => $type['Name'] )); } else { $shifts = sql_select("SELECT * FROM `Shifts` ORDER BY `start`"); @@ -38,21 +54,26 @@ function user_shifts() { $id = $rooms[0]['RID']; if (isset ($_REQUEST['room_id']) && preg_match("/^[0-9]*$/", $_REQUEST['room_id'])) $id = $_REQUEST['room_id']; - - $day_timestamp = DateTime :: createFromFormat("Y-m-d", $day)->getTimestamp(); + $day_timestamp = DateTime :: createFromFormat("Y-m-d-Hi", $day . "-0000")->getTimestamp(); $shifts = sql_select("SELECT * FROM `Shifts` WHERE `RID`=" . sql_escape($id) . " AND `start` >= " . sql_escape($day_timestamp) . " AND `start` < " . sql_escape($day_timestamp +24 * 60 * 60) . " ORDER BY `start`"); $shifts_table = ""; foreach ($shifts as $shift) { $shifts_table .= '' . date("H:i", $shift['start']) . ' - ' . date("H:i", $shift['end']) . '' . $shift['name'] . '
'; $angeltypes = sql_select("SELECT * FROM `RoomAngelTypes` JOIN `AngelTypes` ON (`RoomAngelTypes`.`angel_type_id` = `AngelTypes`.`TID`) WHERE `room_id`=" . sql_escape($id) . " AND `count` > 0 ORDER BY `AngelTypes`.`Name`"); - if (count($angeltypes)) { + if (count($angeltypes) > 0) { + $my_shift = sql_num_query("SELECT * FROM `ShiftEntry` WHERE `SID`=" . sql_escape($shift['SID']) . " AND `UID`=" . sql_escape($user['UID']) . " LIMIT 1") > 0; foreach ($angeltypes as $angeltype) { $shifts_table .= '' . $angeltype['Name'] . ': '; $entries = sql_select("SELECT * FROM `ShiftEntry` JOIN `User` ON (`ShiftEntry`.`UID` = `User`.`UID`) WHERE `SID`=" . sql_escape($shift['SID']) . " AND `TID`=" . sql_escape($angeltype['TID']) . " ORDER BY `Nick`"); $entry_list = array (); + foreach ($entries as $entry) + $entry_list[] = $entry['Nick']; if ($angeltype['count'] - count($entries) > 0) - $entry_list[] = '' . ($angeltype['count'] - count($entries)) . ' missing »'; + if (!$my_shift || in_array('user_shift_admin', $privileges)) + $entry_list[] = '' . ($angeltype['count'] - count($entries)) . ' angel missing »'; + else + $entry_list[] = ($angeltype['count'] - count($entries)) . ' angel missing'; $shifts_table .= join(", ", $entry_list); $shifts_table .= '
'; } -- cgit v1.2.3-54-g00ecf