summaryrefslogtreecommitdiff
path: root/includes/view/ShiftCalendarRenderer.php
diff options
context:
space:
mode:
authormsquare <msquare@notrademark.de>2016-11-14 17:40:24 +0100
committermsquare <msquare@notrademark.de>2016-11-14 17:40:24 +0100
commit0ab9f4f9886ca61fe0711ba1ee551394ceda877a (patch)
treebc49135f57cbc1307e0e7594e2ec957e021a342d /includes/view/ShiftCalendarRenderer.php
parent1a3b4e2a334c57cc403be1d8e21fd8e162d9df5c (diff)
fix shift ended recognition and displayed time range end
Diffstat (limited to 'includes/view/ShiftCalendarRenderer.php')
-rw-r--r--includes/view/ShiftCalendarRenderer.php21
1 files changed, 19 insertions, 2 deletions
diff --git a/includes/view/ShiftCalendarRenderer.php b/includes/view/ShiftCalendarRenderer.php
index 3f0d81f7..989bd890 100644
--- a/includes/view/ShiftCalendarRenderer.php
+++ b/includes/view/ShiftCalendarRenderer.php
@@ -25,12 +25,15 @@ class ShiftCalendarRenderer {
private $shiftsFilter;
private $firstBlockStartTime = null;
+
+ private $lastBlockEndTime = null;
private $blocksPerSlot = null;
public function __construct($shifts, ShiftsFilter $shiftsFilter) {
$this->shiftsFilter = $shiftsFilter;
$this->firstBlockStartTime = $this->calcFirstBlockStartTime($shifts);
+ $this->lastBlockEndTime = $this->calcLastBlockEndTime($shifts);
$this->lanes = $this->assignShiftsToLanes($shifts);
}
@@ -82,6 +85,10 @@ class ShiftCalendarRenderer {
public function getFirstBlockStartTime() {
return $this->firstBlockStartTime;
}
+
+ public function getLastBlockEndTime() {
+ return $this->lastBlockEndTime;
+ }
public function getBlocksPerSlot() {
if ($this->blocksPerSlot == null) {
@@ -137,7 +144,7 @@ class ShiftCalendarRenderer {
$html .= $shift_html;
$rendered_until += $shift_height * ShiftCalendarRenderer::SECONDS_PER_ROW;
}
- while ($rendered_until <= $this->shiftsFilter->getEndTime()) {
+ while ($rendered_until < $this->getLastBlockEndTime()) {
$html .= $this->renderTick($rendered_until);
$rendered_until += ShiftCalendarRenderer::SECONDS_PER_ROW;
}
@@ -202,8 +209,18 @@ class ShiftCalendarRenderer {
return ShiftCalendarRenderer::SECONDS_PER_ROW * floor(($start_time - 60 * 60) / ShiftCalendarRenderer::SECONDS_PER_ROW);
}
+ private function calcLastBlockEndTime($shifts) {
+ $end_time = $this->shiftsFilter->getStartTime();
+ foreach ($shifts as $shift) {
+ if ($shift['end'] > $end_time) {
+ $end_time = $shift['end'];
+ }
+ }
+ return ShiftCalendarRenderer::SECONDS_PER_ROW * ceil(($end_time + 60 * 60) / ShiftCalendarRenderer::SECONDS_PER_ROW);
+ }
+
private function calcBlocksPerSlot() {
- return ceil(($this->shiftsFilter->getEndTime() - $this->getFirstBlockStartTime()) / ShiftCalendarRenderer::SECONDS_PER_ROW);
+ return ceil(($this->getLastBlockEndTime() - $this->getFirstBlockStartTime()) / ShiftCalendarRenderer::SECONDS_PER_ROW);
}
}