-
+
diff --git a/src/assets/js/backend_settings_system.js b/src/assets/js/backend_settings_system.js
index e2c4fe4b..6a96e881 100644
--- a/src/assets/js/backend_settings_system.js
+++ b/src/assets/js/backend_settings_system.js
@@ -46,9 +46,12 @@
// Update the logo title on the header.
$('#header-logo span').text($('#company-name').val());
+ // Update variables also used in other setting tabs
+ GlobalVariables.timeFormat = $('#time-format').val();
+ GlobalVariables.firstWeekday = $('#first-weekday').val();
+
// We need to refresh the working plan.
var workingPlan = BackendSettings.wp.get();
- $('.breaks tbody').empty();
BackendSettings.wp.setup(workingPlan);
BackendSettings.wp.timepickers(false);
}, 'json').fail(GeneralFunctions.ajaxFailureHandler);
diff --git a/src/assets/js/backend_users_providers.js b/src/assets/js/backend_users_providers.js
index f0a6785c..4f0b0e82 100644
--- a/src/assets/js/backend_users_providers.js
+++ b/src/assets/js/backend_users_providers.js
@@ -94,7 +94,6 @@
$('#provider-notifications').prop('disabled', false);
$('#providers').find('.add-break, .edit-break, .delete-break, #reset-working-plan').prop('disabled', false);
$('#provider-services input:checkbox').prop('disabled', false);
- $('#providers input:checkbox').prop('disabled', false);
// Apply default working plan
BackendUsers.wp.setup(GlobalVariables.workingPlan);
@@ -232,8 +231,6 @@
* Event: Reset Working Plan Button "Click".
*/
$('#providers').on('click', '#reset-working-plan', function () {
- $('.breaks tbody').empty();
- $('.work-start, .work-end').val('');
BackendUsers.wp.setup(GlobalVariables.workingPlan);
BackendUsers.wp.timepickers(false);
});
@@ -358,16 +355,12 @@
$('#provider-notifications').prop('disabled', true);
$('#provider-services input:checkbox').prop('disabled', true);
$('#providers .add-break, #reset-working-plan').prop('disabled', true);
- BackendUsers.wp.timepickers(true);
- $('#providers .working-plan input:text').timepicker('destroy');
- $('#providers .working-plan input:checkbox').prop('disabled', true);
- $('.breaks').find('.edit-break, .delete-break').prop('disabled', true);
$('#edit-provider, #delete-provider').prop('disabled', true);
$('#providers .record-details').find('input, textarea').val('');
- $('#providers input:checkbox').prop('checked', false);
$('#provider-services input:checkbox').prop('checked', false);
$('#provider-services a').remove();
+ $('#providers .working-plan tbody').empty();
$('#providers .breaks tbody').empty();
};
@@ -422,10 +415,10 @@
});
// Display working plan
- $('#providers .breaks tbody').empty();
var workingPlan = $.parseJSON(provider.settings.working_plan);
BackendUsers.wp.setup(workingPlan);
$('.breaks').find('.edit-break, .delete-break').prop('disabled', true);
+ $('#providers .working-plan input:checkbox').prop('disabled', true);
};
/**
diff --git a/src/assets/js/working_plan.js b/src/assets/js/working_plan.js
index 725e391b..a130d283 100755
--- a/src/assets/js/working_plan.js
+++ b/src/assets/js/working_plan.js
@@ -45,22 +45,48 @@
* @param {Object} workingPlan Contains the working hours and breaks for each day of the week.
*/
WorkingPlan.prototype.setup = function (workingPlan) {
- // Always displaying breaks with Sunday as the first day to be consistent with what is done in the the working plan view.
- var workingPlanSorted = GeneralFunctions.sortWeekDict(workingPlan,0); // 0 is the ID for Sunday
+ var fDaynum = GeneralFunctions.getWeekDayId(GlobalVariables.firstWeekday);
+ var workingPlanSorted = GeneralFunctions.sortWeekDict(workingPlan,fDaynum);
+
+ $('.working-plan tbody').empty();
+ $('.breaks tbody').empty();
+ // Build working plan day list starting with the first weekday as set in the General settings
$.each(workingPlanSorted, function (index, workingDay) {
+
+ var day = this.convertValueToDay(index);
+ var dayTranslatedname = GeneralFunctions.ucaseFirstLetter(day)
+
+ var tr =
+ '
' +
+ '
' +
+ '
' +
+ '' +
+ '
' +
+ '
' +
+ '
' +
+ '
' +
+ '
';
+
+ $('.working-plan tbody').append(tr);
+
if (workingDay != null) {
$('#' + index).prop('checked', true);
$('#' + index + '-start').val(Date.parse(workingDay.start).toString(GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm').toUpperCase());
$('#' + index + '-end').val(Date.parse(workingDay.end).toString(GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm').toUpperCase());
+ // Sort day's breaks according to the starting hour
+ workingDay.breaks.sort(function (break1, break2) {
+ // We can do a direct string comparison since we have time based on 24 hours clock.
+ return (break1.start).localeCompare(break2.start);
+ });
+
// Add the day's breaks on the breaks table.
$.each(workingDay.breaks, function (i, brk) {
- var day = this.convertValueToDay(index);
- var tr =
+ tr =
'
' +
@@ -171,7 +197,7 @@
*
* Enable or disable the time selection for each day.
*/
- $('.working-plan input:checkbox').click(function () {
+ $('.working-plan tbody').on( "click", "input:checkbox", function (event) {
var id = $(this).attr('id');
if ($(this).prop('checked') == true) {
@@ -308,6 +334,12 @@
$modifiedRow.find('.save-break, .cancel-break').addClass('hidden');
$(element).closest('table').find('.edit-break, .delete-break').removeClass('hidden');
$('.add-break').prop('disabled', false);
+
+ // Refresh working plan to have the new break sorted in the break list.
+ var workingPlan = this.get();
+ this.setup(workingPlan);
+ this.timepickers(false);
+
}.bind(this));
};
@@ -342,7 +374,7 @@
workingPlan[id].breaks.sort(function (break1, break2) {
// We can do a direct string comparison since we have time based on 24 hours clock.
- return break1.start - break2.start;
+ return (break1.start).localeCompare(break2.start);
});
}.bind(this));
} else {