mirror of
https://github.com/alextselegidis/easyappointments.git
synced 2024-11-22 07:52:29 +03:00
Multiple attendant number generation must take into consideration the working plan exceptions
This commit is contained in:
parent
9e71255cae
commit
8c836bf10c
1 changed files with 12 additions and 5 deletions
|
@ -342,22 +342,29 @@ class Availability {
|
|||
]);
|
||||
|
||||
$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];
|
||||
|
||||
if ( ! $working_hours)
|
||||
// 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 ( ! $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 = [];
|
||||
|
|
Loading…
Reference in a new issue