Skip to content

Commit

Permalink
Schedule Entry - Initial Occurrence Scope
Browse files Browse the repository at this point in the history
Commit 3a41b0 partially addressed initial occurrence issue from Starts On
perspective but failed to consider if the occurrence is already in the past
or out of scope.

This commit addresses the issue for realz.
  • Loading branch information
protich committed Dec 18, 2019
1 parent 920d3f2 commit 3da5bd7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
6 changes: 6 additions & 0 deletions include/class.businesshours.php
Expand Up @@ -116,7 +116,13 @@ public function addWorkingHours(Datetime $date, $hours, &$auditlog=array()) {
// partial / remaining hours
if (!$e->isBeforeHours($date))
$partial = true;

} elseif (strtotime("$d ".$e->getEndsTime()) <
$date->getTimestamp()) {
// Entry is out of scope
continue;
}

// Handle holidays - if within scope of current work day
$leadtime =0;
if (($holiday=$this->holidays[$d])) {
Expand Down
3 changes: 2 additions & 1 deletion include/class.schedule.php
Expand Up @@ -797,6 +797,7 @@ function getCurrent($from=null) {
$stop = $this->getStopsDatetime();
if ($stop && $stop->getTimestamp() < $from->getTimestamp())
return null;

// Figure out start time for the entry.
$from->modify($this->getIntervalSpec($from));
$this->_current = clone $from;
Expand Down Expand Up @@ -1421,7 +1422,7 @@ function buildFields() {
'gmt' => false,
'future' => false,
'max' => time(),
'showtimezone' => false,
'showtimezone' => true,
),
)),
'hours' => new TextboxField(array(
Expand Down
4 changes: 4 additions & 0 deletions include/staff/templates/schedule-diagnostic.tmpl.php
Expand Up @@ -15,6 +15,10 @@
if ($form->isValid()) {
$timeline = array();
$data = $form->getClean();
// Add timezone if it's not ISO compliant date (GET request)
if (strlen($data['date']) <= 16)
$data['date'] .= ' '.$schedule->getTimezone();

$schedule->addWorkingHours(Format::parseDateTime($data['date']), $data['hours'], $timeline);
?>
<div id="diagnostic-results"
Expand Down

0 comments on commit 3da5bd7

Please sign in to comment.