mirror of
https://github.com/alextselegidis/easyappointments.git
synced 2024-11-25 01:12:21 +03:00
Fixed save working plan exception handling for calendar page and non working days (#1548)
This commit is contained in:
parent
3bc2e69651
commit
2d41f181a1
2 changed files with 11 additions and 6 deletions
|
@ -480,7 +480,7 @@ class Calendar extends EA_Controller
|
|||
|
||||
$this->providers_model->save_working_plan_exception($provider_id, $date, $working_plan_exception);
|
||||
|
||||
if ($date !== $original_date) {
|
||||
if ($original_date && $date !== $original_date) {
|
||||
$this->providers_model->delete_working_plan_exception($provider_id, $original_date);
|
||||
}
|
||||
|
||||
|
|
|
@ -525,12 +525,16 @@ class Providers_model extends EA_Model
|
|||
): void {
|
||||
// Validate the working plan exception data.
|
||||
|
||||
if (empty($working_plan_exception['start']) || empty($working_plan_exception['end'])) {
|
||||
if (
|
||||
!empty($working_plan_exception) &&
|
||||
(empty($working_plan_exception['start']) || empty($working_plan_exception['end']))
|
||||
) {
|
||||
throw new InvalidArgumentException(
|
||||
'Empty start and/or end time provided: ' . json_encode($working_plan_exception),
|
||||
);
|
||||
}
|
||||
|
||||
if (!empty($working_plan_exception['start']) && !empty($working_plan_exception['end'])) {
|
||||
$start = date('H:i', strtotime($working_plan_exception['start']));
|
||||
|
||||
$end = date('H:i', strtotime($working_plan_exception['end']));
|
||||
|
@ -538,6 +542,7 @@ class Providers_model extends EA_Model
|
|||
if ($start > $end) {
|
||||
throw new InvalidArgumentException('Working plan exception start date must be before the end date.');
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure the provider record exists.
|
||||
$where = [
|
||||
|
|
Loading…
Reference in a new issue