From 79ca2f177203b9514c8f351eff4e24b6b4996af5 Mon Sep 17 00:00:00 2001 From: msquare Date: Tue, 15 Nov 2016 21:33:54 +0100 Subject: add fixed shift calendar headers and timelane --- includes/view/ShiftCalendarRenderer.php | 13 +++++++++---- includes/view/Shifts_view.php | 2 +- includes/view/User_view.php | 28 ++++++++++++++-------------- 3 files changed, 24 insertions(+), 19 deletions(-) (limited to 'includes') diff --git a/includes/view/ShiftCalendarRenderer.php b/includes/view/ShiftCalendarRenderer.php index 89c1be4c..151a39e0 100644 --- a/includes/view/ShiftCalendarRenderer.php +++ b/includes/view/ShiftCalendarRenderer.php @@ -19,6 +19,11 @@ class ShiftCalendarRenderer { * Distance between two shifts in pixels */ const MARGIN = 5; + + /** + * Seconds added to the start and end time + */ + const TIME_MARGIN = 1800; private $lanes; @@ -71,7 +76,7 @@ class ShiftCalendarRenderer { } // If all lanes for this room are busy, create a new lane and add shift to it if ($shift_added == false) { - $newLane = new ShiftCalendarLane("", $this->getFirstBlockStartTime(), $this->getBlocksPerSlot()); + $newLane = new ShiftCalendarLane($header, $this->getFirstBlockStartTime(), $this->getBlocksPerSlot()); if (! $newLane->addShift($shift)) { engelsystem_error("Unable to add shift to new lane."); } @@ -170,7 +175,7 @@ class ShiftCalendarRenderer { return div('tick day'); } return div('tick day', [ - date('Y-m-dH:i', $time) + date('m-dH:i', $time) ]); } elseif ($time % (60 * 60) == 0) { if (! $label) { @@ -206,7 +211,7 @@ class ShiftCalendarRenderer { $start_time = $shift['start']; } } - return ShiftCalendarRenderer::SECONDS_PER_ROW * floor(($start_time - 60 * 60) / ShiftCalendarRenderer::SECONDS_PER_ROW); + return ShiftCalendarRenderer::SECONDS_PER_ROW * floor(($start_time - ShiftCalendarRenderer::TIME_MARGIN) / ShiftCalendarRenderer::SECONDS_PER_ROW); } private function calcLastBlockEndTime($shifts) { @@ -216,7 +221,7 @@ class ShiftCalendarRenderer { $end_time = $shift['end']; } } - return ShiftCalendarRenderer::SECONDS_PER_ROW * ceil(($end_time + 60 * 60) / ShiftCalendarRenderer::SECONDS_PER_ROW); + return ShiftCalendarRenderer::SECONDS_PER_ROW * ceil(($end_time + ShiftCalendarRenderer::TIME_MARGIN) / ShiftCalendarRenderer::SECONDS_PER_ROW); } private function calcBlocksPerSlot() { diff --git a/includes/view/Shifts_view.php b/includes/view/Shifts_view.php index 7ad580f4..629f6b2a 100644 --- a/includes/view/Shifts_view.php +++ b/includes/view/Shifts_view.php @@ -50,7 +50,7 @@ function Shift_view($shift, $shifttype, $room, $angeltypes_source, $user_shifts, return page_with_title($shift['name'] . ' %c', [ msg(), - Shift_collides($shift, $user_shifts) ? info(_('This shift collides with one of your shifts.'), true) : '', + $shift_signup_state->getState() == ShiftSignupState::COLLIDES ? info(_('This shift collides with one of your shifts.'), true) : '', $shift_signup_state->getState() == ShiftSignupState::SIGNED_UP ? info(_('You are signed up for this shift.'), true) : '', ($shift_admin || $admin_shifttypes || $admin_rooms) ? buttons([ $shift_admin ? button(shift_edit_link($shift), glyph('pencil') . _('edit')) : '', diff --git a/includes/view/User_view.php b/includes/view/User_view.php index 6cd48899..09509c3d 100644 --- a/includes/view/User_view.php +++ b/includes/view/User_view.php @@ -297,6 +297,20 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_angel return page_with_title(' ' . htmlspecialchars($user_source['Nick']) . ' ' . $user_name . '', [ msg(), + div('row space-top', [ + div('col-md-12', [ + buttons([ + $admin_user_privilege ? button(page_link_to('admin_user') . '&id=' . $user_source['UID'], glyph("edit") . _("edit")) : '', + $admin_user_privilege ? button(user_driver_license_edit_link($user_source), glyph("road") . _("driving license")) : '', + ($admin_user_privilege && ! $user_source['Gekommen']) ? button(page_link_to('admin_arrive') . '&arrived=' . $user_source['UID'], _("arrived")) : '', + $admin_user_privilege ? button(page_link_to('users') . '&action=edit_vouchers&user_id=' . $user_source['UID'], glyph('cutlery') . _('Edit vouchers')) : '', + $its_me ? button(page_link_to('user_settings'), glyph('list-alt') . _("Settings")) : '', + $its_me ? button(page_link_to('ical') . '&key=' . $user_source['api_key'], glyph('calendar') . _("iCal Export")) : '', + $its_me ? button(page_link_to('shifts_json_export') . '&key=' . $user_source['api_key'], glyph('export') . _("JSON Export")) : '', + $its_me ? button(page_link_to('user_myshifts') . '&reset', glyph('repeat') . _('Reset API key')) : '' + ]) + ]) + ]), div('row', [ div('col-md-3', [ '

', @@ -322,20 +336,6 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_angel User_groups_render($user_groups) ]) ]), - div('row space-top', [ - div('col-md-12', [ - buttons([ - $admin_user_privilege ? button(page_link_to('admin_user') . '&id=' . $user_source['UID'], glyph("edit") . _("edit")) : '', - $admin_user_privilege ? button(user_driver_license_edit_link($user_source), glyph("road") . _("driving license")) : '', - ($admin_user_privilege && ! $user_source['Gekommen']) ? button(page_link_to('admin_arrive') . '&arrived=' . $user_source['UID'], _("arrived")) : '', - $admin_user_privilege ? button(page_link_to('users') . '&action=edit_vouchers&user_id=' . $user_source['UID'], glyph('cutlery') . _('Edit vouchers')) : '', - $its_me ? button(page_link_to('user_settings'), glyph('list-alt') . _("Settings")) : '', - $its_me ? button(page_link_to('ical') . '&key=' . $user_source['api_key'], glyph('calendar') . _("iCal Export")) : '', - $its_me ? button(page_link_to('shifts_json_export') . '&key=' . $user_source['api_key'], glyph('export') . _("JSON Export")) : '', - $its_me ? button(page_link_to('user_myshifts') . '&reset', glyph('repeat') . _('Reset API key')) : '' - ]) - ]) - ]), ($its_me || $admin_user_privilege) ? '

' . _("Shifts") . '

' : '', ($its_me || $admin_user_privilege) ? table([ 'date' => _("Day"), -- cgit v1.2.3-54-g00ecf