diff options
author | Bot <bot@myigel.name> | 2017-01-02 03:57:23 +0100 |
---|---|---|
committer | Igor Scheller <igor.scheller@igorshp.de> | 2017-01-02 03:57:23 +0100 |
commit | 7313e15ce8236e19331fb6639a3a5b97c8f06ecd (patch) | |
tree | 399e5eaa403d6dd5993ca8fb6f2162319d2ed2e1 /includes/controller/rooms_controller.php | |
parent | b839e401062b294292fdcbd7e30b79bc149fab6f (diff) |
PSR-2 formatting
Diffstat (limited to 'includes/controller/rooms_controller.php')
-rw-r--r-- | includes/controller/rooms_controller.php | 101 |
1 files changed, 52 insertions, 49 deletions
diff --git a/includes/controller/rooms_controller.php b/includes/controller/rooms_controller.php index a79034fb..2e45dead 100644 --- a/includes/controller/rooms_controller.php +++ b/includes/controller/rooms_controller.php @@ -10,56 +10,58 @@ use Engelsystem\ShiftCalendarRenderer; /** * View a room with its shifts. */ -function room_controller() { - global $privileges; +function room_controller() +{ + global $privileges; - if (! in_array('view_rooms', $privileges)) { - redirect(page_link_to()); - } + if (! in_array('view_rooms', $privileges)) { + redirect(page_link_to()); + } - $room = load_room(); - $all_shifts = Shifts_by_room($room); - $days = []; - foreach ($all_shifts as $shift) { - $day = date("Y-m-d", $shift['start']); - if (! in_array($day, $days)) { - $days[] = $day; + $room = load_room(); + $all_shifts = Shifts_by_room($room); + $days = []; + foreach ($all_shifts as $shift) { + $day = date("Y-m-d", $shift['start']); + if (! in_array($day, $days)) { + $days[] = $day; + } } - } - $shiftsFilter = new ShiftsFilter(true, [ - $room['RID'] + $shiftsFilter = new ShiftsFilter(true, [ + $room['RID'] ], AngelType_ids()); - $selected_day = date("Y-m-d"); - if (! empty($days)) { - $selected_day = $days[0]; - } - if (isset($_REQUEST['shifts_filter_day'])) { - $selected_day = $_REQUEST['shifts_filter_day']; - } - $shiftsFilter->setStartTime(parse_date("Y-m-d H:i", $selected_day . ' 00:00')); - $shiftsFilter->setEndTime(parse_date("Y-m-d H:i", $selected_day . ' 23:59')); + $selected_day = date("Y-m-d"); + if (! empty($days)) { + $selected_day = $days[0]; + } + if (isset($_REQUEST['shifts_filter_day'])) { + $selected_day = $_REQUEST['shifts_filter_day']; + } + $shiftsFilter->setStartTime(parse_date("Y-m-d H:i", $selected_day . ' 00:00')); + $shiftsFilter->setEndTime(parse_date("Y-m-d H:i", $selected_day . ' 23:59')); - $shiftsFilterRenderer = new ShiftsFilterRenderer($shiftsFilter); - $shiftsFilterRenderer->enableDaySelection($days); + $shiftsFilterRenderer = new ShiftsFilterRenderer($shiftsFilter); + $shiftsFilterRenderer->enableDaySelection($days); - $shiftCalendarRenderer = shiftCalendarRendererByShiftFilter($shiftsFilter); + $shiftCalendarRenderer = shiftCalendarRendererByShiftFilter($shiftsFilter); - return [ + return [ $room['Name'], - Room_view($room, $shiftsFilterRenderer, $shiftCalendarRenderer) + Room_view($room, $shiftsFilterRenderer, $shiftCalendarRenderer) ]; } /** * Dispatch different room actions. */ -function rooms_controller() { - if (! isset($_REQUEST['action'])) { - $_REQUEST['action'] = 'list'; - } +function rooms_controller() +{ + if (! isset($_REQUEST['action'])) { + $_REQUEST['action'] = 'list'; + } - switch ($_REQUEST['action']) { + switch ($_REQUEST['action']) { default: case 'list': redirect(page_link_to('admin_rooms')); @@ -68,28 +70,29 @@ function rooms_controller() { } } -function room_link($room) { - return page_link_to('rooms') . '&action=view&room_id=' . $room['RID']; +function room_link($room) +{ + return page_link_to('rooms') . '&action=view&room_id=' . $room['RID']; } -function room_edit_link($room) { - return page_link_to('admin_rooms') . '&show=edit&id=' . $room['RID']; +function room_edit_link($room) +{ + return page_link_to('admin_rooms') . '&show=edit&id=' . $room['RID']; } /** * Loads room by request param room_id */ -function load_room() { - if (! test_request_int('room_id')) { - redirect(page_link_to()); - } +function load_room() +{ + if (! test_request_int('room_id')) { + redirect(page_link_to()); + } - $room = Room($_REQUEST['room_id']); - if ($room == null) { - redirect(page_link_to()); - } + $room = Room($_REQUEST['room_id']); + if ($room == null) { + redirect(page_link_to()); + } - return $room; + return $room; } - -?>
\ No newline at end of file |