Skip to content

Commit

Permalink
Multiple attendant number generation must take into consideration the…
Browse files Browse the repository at this point in the history
… working plan exceptions
  • Loading branch information
alextselegidis committed Nov 21, 2020
1 parent 9e71255 commit 8c836bf
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions application/libraries/Availability.php
Original file line number Diff line number Diff line change
Expand Up @@ -342,22 +342,29 @@ protected function consider_multiple_attendants(
]);

$working_plan = json_decode($provider['settings']['working_plan'], TRUE);
$working_plan_exceptions = json_decode($provider['settings']['working_plan_exceptions'], TRUE);
$working_day = strtolower(date('l', strtotime($date)));
$working_hours = $working_plan[$working_day];
$date_working_plan = $working_plan[$working_day];

// Search if the $date is an custom availability period added outside the normal working plan.
if (isset($working_plan_exceptions[$date]))
{
$date_working_plan = $working_plan_exceptions[$date];
}

if ( ! $working_hours)
if ( ! $date_working_plan)
{
return [];
}

$periods = [
[
'start' => new DateTime($date . ' ' . $working_hours['start']),
'end' => new DateTime($date . ' ' . $working_hours['end'])
'start' => new DateTime($date . ' ' . $date_working_plan['start']),
'end' => new DateTime($date . ' ' . $date_working_plan['end'])
]
];

$periods = $this->remove_breaks($date, $periods, $working_hours['breaks']);
$periods = $this->remove_breaks($date, $periods, $date_working_plan['breaks']);
$periods = $this->remove_unavailability_events($periods, $unavailability_events);

$hours = [];
Expand Down

0 comments on commit 8c836bf

Please sign in to comment.