Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Fix rendering errors when scheduling window is 24 hours.
Browse files Browse the repository at this point in the history
Signed-off-by: Max Fierke <[email protected]>
  • Loading branch information
maxfierke committed Jun 21, 2014
1 parent c47981a commit 5a46dd6
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ public function viewAction(Request $request, $uid, $spid)
$startIndex = $dtUtils->getIndexFromTime($appSettings->getStartHour());
$endIndex = $dtUtils->getIndexFromTime($appSettings->getEndHour())-1;

if ($endIndex === -1) { // Midnight end hour
$endIndex = 95;
}

$hoursAvailable = 0;
for ($day = 0; $day < 7; $day++) {
$timeRec = $entity->getDay($day);
Expand Down Expand Up @@ -223,6 +227,10 @@ public function newAction(Request $request, $spid)
$startIndex = $dtUtils->getIndexFromTime($appSettings->getStartHour());
$endIndex = $dtUtils->getIndexFromTime($appSettings->getEndHour())-1;

if ($endIndex === -1) { // Midnight end hour
$endIndex = 95;
}

return $this->render('OpenSkedgeBundle:AvailabilitySchedule:new.html.twig', array(
'avail' => $entity,
'htime' => $dtUtils->timeStrToDateTime($appSettings->getStartHour()),
Expand Down Expand Up @@ -298,6 +306,10 @@ public function editAction(Request $request, $spid)
$startIndex = $dtUtils->getIndexFromTime($appSettings->getStartHour());
$endIndex = $dtUtils->getIndexFromTime($appSettings->getEndHour())-1;

if ($endIndex === -1) { // Midnight end hour
$endIndex = 95;
}

$hoursAvailable = 0;
for ($day = 0; $day < 7; $day++) {
$timeRec = $entity->getDay($day);
Expand Down
4 changes: 4 additions & 0 deletions src/OpenSkedge/AppBundle/Controller/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ public function indexAction(Request $request)
$startIndex = $dtUtils->getIndexFromTime($appSettings->getStartHour());
$endIndex = $dtUtils->getIndexFromTime($appSettings->getEndHour())-1;

if ($endIndex === -1) { // Midnight end hour
$endIndex = 95;
}

return $this->render('OpenSkedgeBundle:Dashboard:index.html.twig', array(
'htime' => $dtUtils->timeStrToDateTime($appSettings->getStartHour()),
'resolution' => $resolution,
Expand Down
8 changes: 8 additions & 0 deletions src/OpenSkedge/AppBundle/Controller/ScheduleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ public function viewAction(Request $request, $pid, $spid)
$startIndex = $dtUtils->getIndexFromTime($appSettings->getStartHour());
$endIndex = $dtUtils->getIndexFromTime($appSettings->getEndHour())-1;

if ($endIndex === -1) { // Midnight end hour
$endIndex = 95;
}

return $this->render('OpenSkedgeBundle:Schedule:view.html.twig', array(
'htime' => $dtUtils->timeStrToDateTime($appSettings->getStartHour()),
'resolution' => $resolution,
Expand Down Expand Up @@ -271,6 +275,10 @@ public function editAction(Request $request, $pid, $spid)
$startIndex = $dtUtils->getIndexFromTime($appSettings->getStartHour());
$endIndex = $dtUtils->getIndexFromTime($appSettings->getEndHour())-1;

if ($endIndex === -1) { // Midnight end hour
$endIndex = 95;
}

return $this->render('OpenSkedgeBundle:Schedule:edit.html.twig', array(
'htime' => $dtUtils->timeStrToDateTime($appSettings->getStartHour()),
'resolution' => $resolution,
Expand Down
4 changes: 4 additions & 0 deletions src/OpenSkedge/AppBundle/Services/StatsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ public function weekClockReport($uid, $week)
foreach ($shifts as $shift) {
$startIndex = $this->dtUtils->getIndexFromTime($shift->getStartTime());
$endIndex = $this->dtUtils->getIndexFromTime($shift->getEndTime());

if ($endIndex === -1) { // Midnight end hour
$endIndex = 96;
}
// Update the schedule composite to mark shifts they had picked up.
if ($shift->getStartTime()->format('w') === $shift->getEndTime()->format('w')) {
$day = $shift->getStartTime()->format('w');
Expand Down

0 comments on commit 5a46dd6

Please sign in to comment.