From a762a37d7b8fb6d28e66d6cd88bdd80ad600735d Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Tue, 18 Jan 2022 15:50:38 +0100 Subject: [PATCH] Fix working plan save and delete methods. --- application/models/Providers_model.php | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/application/models/Providers_model.php b/application/models/Providers_model.php index 9b67f238..6b1a80f0 100755 --- a/application/models/Providers_model.php +++ b/application/models/Providers_model.php @@ -563,8 +563,10 @@ class Providers_model extends EA_Model { throw new InvalidArgumentException('Provider ID was not found in the database: ' . $provider_id); } + $provider = $this->find($provider_id); + // Store the working plan exception. - $working_plan_exceptions = json_decode($this->get_setting('working_plan_exceptions', $provider_id), TRUE); + $working_plan_exceptions = json_decode($provider['settings']['working_plan_exceptions'], TRUE); if ( ! isset($working_plan_exception['breaks'])) { @@ -573,11 +575,9 @@ class Providers_model extends EA_Model { $working_plan_exceptions[$date] = $working_plan_exception; - $this->set_setting( - 'working_plan_exceptions', - json_encode($working_plan_exceptions), - $provider_id - ); + $provider['settings']['working_plan_exceptions'] = json_encode($working_plan_exceptions); + + $this->update($provider); } /** @@ -601,11 +601,9 @@ class Providers_model extends EA_Model { unset($working_plan_exceptions[$date]); - $this->set_setting( - 'working_plan_exceptions', - json_encode(empty($working_plan_exceptions) ? new stdClass() : $working_plan_exceptions), - $provider_id - ); + $provider['settings']['working_plan_exceptions'] = empty($working_plan_exceptions) ? new stdClass() : $working_plan_exceptions; + + $this->update($provider); } /**