mirror of
https://github.com/alextselegidis/easyappointments.git
synced 2024-12-27 09:03:09 +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,18 +525,23 @@ 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),
|
||||
);
|
||||
}
|
||||
|
||||
$start = date('H:i', strtotime($working_plan_exception['start']));
|
||||
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']));
|
||||
$end = date('H:i', strtotime($working_plan_exception['end']));
|
||||
|
||||
if ($start > $end) {
|
||||
throw new InvalidArgumentException('Working plan exception start date must be before the end date.');
|
||||
if ($start > $end) {
|
||||
throw new InvalidArgumentException('Working plan exception start date must be before the end date.');
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure the provider record exists.
|
||||
|
|
Loading…
Reference in a new issue