diff options
author | Bot <bot@myigel.name> | 2017-08-30 00:07:01 +0200 |
---|---|---|
committer | Igor Scheller <igor.scheller@igorshp.de> | 2017-08-30 00:22:02 +0200 |
commit | a473a56f1dbf568dc66cd6fcffe6b638308c542e (patch) | |
tree | c3f11e5fd08e0180d743a2ee0d2142f376662d8e /includes | |
parent | 341c076d98209b19f8360486ca41ac62e506db7b (diff) |
Formatting
Diffstat (limited to 'includes')
-rw-r--r-- | includes/model/Shifts_model.php | 3 | ||||
-rw-r--r-- | includes/model/User_model.php | 2 | ||||
-rw-r--r-- | includes/pages/admin_import.php | 2 | ||||
-rw-r--r-- | includes/view/Rooms_view.php | 1 | ||||
-rw-r--r-- | includes/view/ShiftCalendarRenderer.php | 76 |
5 files changed, 39 insertions, 45 deletions
diff --git a/includes/model/Shifts_model.php b/includes/model/Shifts_model.php index 88b28998..1589939d 100644 --- a/includes/model/Shifts_model.php +++ b/includes/model/Shifts_model.php @@ -45,7 +45,7 @@ function Shifts_by_ShiftsFilter(ShiftsFilter $shiftsFilter) AND NOT `Shifts`.`PSID` IS NULL) AS tmp_shifts ORDER BY `start`'; - + return DB::select( $sql, [ @@ -444,6 +444,7 @@ function Shift_update($shift) * * @param array $shift * @return bool|null + * @throws Exception */ function Shift_update_by_psid($shift) { diff --git a/includes/model/User_model.php b/includes/model/User_model.php index 4757ed3c..0ed602e0 100644 --- a/includes/model/User_model.php +++ b/includes/model/User_model.php @@ -241,7 +241,7 @@ function Users_by_angeltype($angeltype) `UserAngelTypes`.`id` AS `user_angeltype_id`, `UserAngelTypes`.`confirm_user_id`, `UserAngelTypes`.`supporter`, - (`UserDriverLicenses`.`user_id` IS NOT NULL) as `wants_to_drive`, + (`UserDriverLicenses`.`user_id` IS NOT NULL) AS `wants_to_drive`, `UserDriverLicenses`.* FROM `User` JOIN `UserAngelTypes` ON `User`.`UID`=`UserAngelTypes`.`user_id` diff --git a/includes/pages/admin_import.php b/includes/pages/admin_import.php index bda5ba93..bf8c498c 100644 --- a/includes/pages/admin_import.php +++ b/includes/pages/admin_import.php @@ -248,7 +248,7 @@ function admin_import() list($rooms_new, $rooms_deleted) = prepare_rooms($import_file); foreach ($rooms_new as $room) { $result = Room_create($room, true, true); - + $rooms_import[trim($room)] = $result; } foreach ($rooms_deleted as $room) { diff --git a/includes/view/Rooms_view.php b/includes/view/Rooms_view.php index 802b4c8e..76ce33a5 100644 --- a/includes/view/Rooms_view.php +++ b/includes/view/Rooms_view.php @@ -1,4 +1,5 @@ <?php + use Engelsystem\ShiftCalendarRenderer; use Engelsystem\ShiftsFilterRenderer; diff --git a/includes/view/ShiftCalendarRenderer.php b/includes/view/ShiftCalendarRenderer.php index 3269f338..d2becb58 100644 --- a/includes/view/ShiftCalendarRenderer.php +++ b/includes/view/ShiftCalendarRenderer.php @@ -1,11 +1,9 @@ <?php -namespace Engelsystem; -use Exception; +namespace Engelsystem; class ShiftCalendarRenderer { - /** * 15m * 60s/m = 900s */ @@ -51,10 +49,10 @@ class ShiftCalendarRenderer /** * ShiftCalendarRenderer constructor. * - * @param array[] $shifts - * @param array[] $needed_angeltypes - * @param array[] $shift_entries - * @param ShiftsFilter $shiftsFilter + * @param array[] $shifts + * @param array[] $needed_angeltypes + * @param array[] $shift_entries + * @param ShiftsFilter $shiftsFilter */ public function __construct($shifts, $needed_angeltypes, $shift_entries, ShiftsFilter $shiftsFilter) { @@ -69,23 +67,21 @@ class ShiftCalendarRenderer /** * Assigns the shifts to different lanes per room if they collide * - * @param array[] $shifts - * The shifts to assign - * + * @param array[] $shifts The shifts to assign * @return array Returns an array that assigns a room_id to an array of ShiftCalendarLane containing the shifts */ private function assignShiftsToLanes($shifts) { // array that assigns a room id to a list of lanes (per room) $lanes = []; - + foreach ($shifts as $shift) { $room_id = $shift['RID']; $header = Room_name_render([ - 'RID' => $room_id, + 'RID' => $room_id, 'Name' => $shift['room_name'] ]); - if (! isset($lanes[$room_id])) { + if (!isset($lanes[$room_id])) { // initialize room with one lane $lanes[$room_id] = [ new ShiftCalendarLane($header, $this->getFirstBlockStartTime(), $this->getBlocksPerSlot()) @@ -95,7 +91,7 @@ class ShiftCalendarRenderer $shift_added = false; foreach ($lanes[$room_id] as $lane) { /** @var ShiftCalendarLane $lane */ - if($lane->shiftFits($shift)) { + if ($lane->shiftFits($shift)) { $lane->addShift($shift); $shift_added = true; break; @@ -108,12 +104,11 @@ class ShiftCalendarRenderer $lanes[$room_id][] = $newLane; } } - + return $lanes; } /** - * * @return int */ public function getFirstBlockStartTime() @@ -122,7 +117,6 @@ class ShiftCalendarRenderer } /** - * * @return int */ public function getLastBlockEndTime() @@ -131,7 +125,6 @@ class ShiftCalendarRenderer } /** - * * @return float */ public function getBlocksPerSlot() @@ -153,9 +146,9 @@ class ShiftCalendarRenderer return ''; } return div('shift-calendar', [ - $this->renderTimeLane(), - $this->renderShiftLanes() - ]) . $this->renderLegend(); + $this->renderTimeLane(), + $this->renderShiftLanes() + ]) . $this->renderLegend(); } /** @@ -171,41 +164,45 @@ class ShiftCalendarRenderer $html .= $this->renderLane($lane); } } - + return $html; } /** * Renders a single lane * - * @param ShiftCalendarLane $lane - * The lane to render + * @param ShiftCalendarLane $lane The lane to render * @return string */ private function renderLane(ShiftCalendarLane $lane) { global $user; - + $shift_renderer = new ShiftCalendarShiftRenderer(); $html = ''; $rendered_until = $this->getFirstBlockStartTime(); - + foreach ($lane->getShifts() as $shift) { while ($rendered_until + ShiftCalendarRenderer::SECONDS_PER_ROW <= $shift['start']) { $html .= $this->renderTick($rendered_until); $rendered_until += ShiftCalendarRenderer::SECONDS_PER_ROW; } - - list ($shift_height, $shift_html) = $shift_renderer->render($shift, $this->needed_angeltypes[$shift['SID']], $this->shift_entries[$shift['SID']], $user); + + list ($shift_height, $shift_html) = $shift_renderer->render( + $shift, + $this->needed_angeltypes[$shift['SID']], + $this->shift_entries[$shift['SID']], + $user + ); $html .= $shift_html; $rendered_until += $shift_height * ShiftCalendarRenderer::SECONDS_PER_ROW; } - + while ($rendered_until < $this->getLastBlockEndTime()) { $html .= $this->renderTick($rendered_until); $rendered_until += ShiftCalendarRenderer::SECONDS_PER_ROW; } - + return div('lane', [ div('header', $lane->getHeader()), $html @@ -215,23 +212,21 @@ class ShiftCalendarRenderer /** * Renders a tick/block for given time * - * @param int $time - * unix timestamp - * @param boolean $label - * Should time labels be generated? + * @param int $time unix timestamp + * @param boolean $label Should time labels be generated? * @return string rendered tick html */ private function renderTick($time, $label = false) { if ($time % (24 * 60 * 60) == 23 * 60 * 60) { - if (! $label) { + if (!$label) { return div('tick day'); } return div('tick day', [ date('m-d<b\r />H:i', $time) ]); } elseif ($time % (60 * 60) == 0) { - if (! $label) { + if (!$label) { return div('tick hour'); } return div('tick hour', [ @@ -253,7 +248,7 @@ class ShiftCalendarRenderer _('Time') ]) ]; - for ($block = 0; $block < $this->getBlocksPerSlot(); $block ++) { + for ($block = 0; $block < $this->getBlocksPerSlot(); $block++) { $thistime = $this->getFirstBlockStartTime() + ($block * ShiftCalendarRenderer::SECONDS_PER_ROW); $time_slot[] = $this->renderTick($thistime, true); } @@ -261,8 +256,7 @@ class ShiftCalendarRenderer } /** - * - * @param array[] $shifts + * @param array[] $shifts * @return int */ private function calcFirstBlockStartTime($shifts) @@ -277,8 +271,7 @@ class ShiftCalendarRenderer } /** - * - * @param array[] $shifts + * @param array[] $shifts * @return int */ private function calcLastBlockEndTime($shifts) @@ -293,7 +286,6 @@ class ShiftCalendarRenderer } /** - * * @return int */ private function calcBlocksPerSlot() |