diff --git a/src/application/models/Services_model.php b/src/application/models/Services_model.php index 9f582599..9f130a88 100644 --- a/src/application/models/Services_model.php +++ b/src/application/models/Services_model.php @@ -142,6 +142,12 @@ class Services_Model extends CI_Model { . ' or ' . AVAILABILITIES_TYPE_FIXED . ' (given ' . $service['availabilities_type'] . ')'); } + if ($service['attendants_number'] !== NULL && (!is_numeric($service['attendants_number']) + || $service['attendants_number'] < 1)) { + throw new Exception('Service attendants number must be numeric and greater or equal to one: ' + . $service['attendants_number']); + } + return TRUE; } diff --git a/src/application/views/backend/services.php b/src/application/views/backend/services.php index d408f538..0ff9c315 100644 --- a/src/application/views/backend/services.php +++ b/src/application/views/backend/services.php @@ -131,6 +131,11 @@ +
+ + +
+
diff --git a/src/assets/js/backend_services.js b/src/assets/js/backend_services.js index 9203873f..3da3efaa 100644 --- a/src/assets/js/backend_services.js +++ b/src/assets/js/backend_services.js @@ -47,8 +47,8 @@ window.BackendServices = window.BackendServices || {}; }); $('#service-category').append(new Option('- ' + EALang['no_category'] + ' -', null)).val('null'); - $('#service-duration').spinner({ - min: 0, + $('#service-duration, #service-attendants-number').spinner({ + min: 1, disabled: true // default }); diff --git a/src/assets/js/backend_services_helper.js b/src/assets/js/backend_services_helper.js index af0ea076..86dface5 100644 --- a/src/assets/js/backend_services_helper.js +++ b/src/assets/js/backend_services_helper.js @@ -84,7 +84,7 @@ $('#services .save-cancel-group').show(); $('#services .record-details').find('input, textarea').prop('readonly', false); $('#services .record-details').find('select').prop('disabled', false); - $('#service-duration').spinner('enable'); + $('#service-duration, #service-attendants-number').spinner('enable'); $('#filter-services button').prop('disabled', true); $('#filter-services .results').css('color', '#AAA'); @@ -113,7 +113,8 @@ price: $('#service-price').val(), currency: $('#service-currency').val(), description: $('#service-description').val(), - availabilities_type: $('#service-availabilities-type').val() + availabilities_type: $('#service-availabilities-type').val(), + attendants_number: $('#service-attendants-number').val() }; if ($('#service-category').val() !== 'null') { @@ -141,7 +142,7 @@ $('#services .save-cancel-group').show(); $('#services .record-details').find('input, textarea').prop('readonly', false); $('#services .record-details select').prop('disabled', false); - $('#service-duration').spinner('enable'); + $('#service-duration, #service-attendants-number').spinner('enable'); $('#filter-services button').prop('disabled', true); $('#filter-services .results').css('color', '#AAA'); @@ -259,7 +260,7 @@ $('#edit-service, #delete-service').prop('disabled', true); $('#services .record-details').find('input, textarea').prop('readonly', true); $('#service-category').prop('disabled', true); - $('#service-duration').spinner('disable'); + $('#service-duration, #service-attendants-number').spinner('disable'); $('#filter-services .selected').removeClass('selected'); $('#filter-services button').prop('disabled', false); @@ -279,6 +280,7 @@ $('#service-currency').val(service.currency); $('#service-description').val(service.description); $('#service-availabilities-type').val(service.availabilities_type); + $('#service-attendants-number').val(service.attendants_number); var categoryId = (service.id_service_categories !== null) ? service.id_service_categories : 'null'; $('#service-category').val(categoryId);