From 29a694e5de9980080ec8581526a351036d795dff Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Wed, 20 Jul 2016 21:19:52 +0200 Subject: [PATCH] Integrated availabilities type in backend section (#185). --- src/application/config/constants.php | 3 +++ src/application/models/Services_model.php | 7 +++++++ src/application/views/backend/services.php | 12 ++++++++++++ src/assets/js/backend_services_helper.js | 4 +++- 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/application/config/constants.php b/src/application/config/constants.php index d9265a83..cd2f8507 100644 --- a/src/application/config/constants.php +++ b/src/application/config/constants.php @@ -81,5 +81,8 @@ define('ANY_PROVIDER', 'any-provider'); define('CALENDAR_VIEW_DEFAULT', 'default'); define('CALENDAR_VIEW_TABLE', 'table'); +define('AVAILABILITIES_TYPE_FLEXIBLE', 'flexible'); +define('AVAILABILITIES_TYPE_FIXED', 'fixed'); + /* End of file constants.php */ /* Location: ./application/config/constants.php */ diff --git a/src/application/models/Services_model.php b/src/application/models/Services_model.php index c3c840ab..9f582599 100644 --- a/src/application/models/Services_model.php +++ b/src/application/models/Services_model.php @@ -135,6 +135,13 @@ class Services_Model extends CI_Model { } } + // Availabilities type must have the correct value. + if ($service['availabilities_type'] !== NULL && $service['availabilities_type'] !== AVAILABILITIES_TYPE_FLEXIBLE + && $service['availabilities_type'] !== AVAILABILITIES_TYPE_FIXED) { + throw new Exception('Service availabilities type must be either ' . AVAILABILITIES_TYPE_FLEXIBLE + . ' or ' . AVAILABILITIES_TYPE_FIXED . ' (given ' . $service['availabilities_type'] . ')'); + } + return TRUE; } diff --git a/src/application/views/backend/services.php b/src/application/views/backend/services.php index 2258700c..d408f538 100644 --- a/src/application/views/backend/services.php +++ b/src/application/views/backend/services.php @@ -119,6 +119,18 @@ +
+ + +
+
diff --git a/src/assets/js/backend_services_helper.js b/src/assets/js/backend_services_helper.js index 1c6d83f1..af0ea076 100644 --- a/src/assets/js/backend_services_helper.js +++ b/src/assets/js/backend_services_helper.js @@ -112,7 +112,8 @@ duration: $('#service-duration').val(), price: $('#service-price').val(), currency: $('#service-currency').val(), - description: $('#service-description').val() + description: $('#service-description').val(), + availabilities_type: $('#service-availabilities-type').val() }; if ($('#service-category').val() !== 'null') { @@ -277,6 +278,7 @@ $('#service-price').val(service.price); $('#service-currency').val(service.currency); $('#service-description').val(service.description); + $('#service-availabilities-type').val(service.availabilities_type); var categoryId = (service.id_service_categories !== null) ? service.id_service_categories : 'null'; $('#service-category').val(categoryId);