|
|
|
@ -1,11 +1,9 @@
|
|
|
|
|
<?php
|
|
|
|
|
namespace Engelsystem;
|
|
|
|
|
|
|
|
|
|
use Exception;
|
|
|
|
|
namespace Engelsystem;
|
|
|
|
|
|
|
|
|
|
class ShiftCalendarRenderer
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 15m * 60s/m = 900s
|
|
|
|
|
*/
|
|
|
|
@ -69,9 +67,7 @@ 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)
|
|
|
|
@ -85,7 +81,7 @@ class ShiftCalendarRenderer
|
|
|
|
|
'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;
|
|
|
|
@ -113,7 +109,6 @@ class ShiftCalendarRenderer
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @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()
|
|
|
|
@ -178,8 +171,7 @@ class ShiftCalendarRenderer
|
|
|
|
|
/**
|
|
|
|
|
* 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)
|
|
|
|
@ -196,7 +188,12 @@ class ShiftCalendarRenderer
|
|
|
|
|
$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;
|
|
|
|
|
}
|
|
|
|
@ -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,7 +256,6 @@ class ShiftCalendarRenderer
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @param array[] $shifts
|
|
|
|
|
* @return int
|
|
|
|
|
*/
|
|
|
|
@ -277,7 +271,6 @@ class ShiftCalendarRenderer
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @param array[] $shifts
|
|
|
|
|
* @return int
|
|
|
|
|
*/
|
|
|
|
@ -293,7 +286,6 @@ class ShiftCalendarRenderer
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @return int
|
|
|
|
|
*/
|
|
|
|
|
private function calcBlocksPerSlot()
|
|
|
|
|