Days sorted also in the Users and Setting pages in the backend.
This commit is contained in:
parent
06630e0d2d
commit
beaa309054
6 changed files with 50 additions and 189 deletions
|
@ -250,6 +250,7 @@ class Backend extends CI_Controller {
|
||||||
$view['active_menu'] = PRIV_SYSTEM_SETTINGS;
|
$view['active_menu'] = PRIV_SYSTEM_SETTINGS;
|
||||||
$view['company_name'] = $this->settings_model->get_setting('company_name');
|
$view['company_name'] = $this->settings_model->get_setting('company_name');
|
||||||
$view['date_format'] = $this->settings_model->get_setting('date_format');
|
$view['date_format'] = $this->settings_model->get_setting('date_format');
|
||||||
|
$view['first_weekday'] = $this->settings_model->get_setting('first_weekday');
|
||||||
$view['time_format'] = $this->settings_model->get_setting('time_format');
|
$view['time_format'] = $this->settings_model->get_setting('time_format');
|
||||||
$view['role_slug'] = $this->session->userdata('role_slug');
|
$view['role_slug'] = $this->session->userdata('role_slug');
|
||||||
$view['system_settings'] = $this->settings_model->get_settings();
|
$view['system_settings'] = $this->settings_model->get_settings();
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
'csrfToken' : <?= json_encode($this->security->get_csrf_hash()) ?>,
|
'csrfToken' : <?= json_encode($this->security->get_csrf_hash()) ?>,
|
||||||
'baseUrl' : <?= json_encode($base_url) ?>,
|
'baseUrl' : <?= json_encode($base_url) ?>,
|
||||||
'dateFormat' : <?= json_encode($date_format) ?>,
|
'dateFormat' : <?= json_encode($date_format) ?>,
|
||||||
|
'firstWeekday' : <?= json_encode($first_weekday); ?>,
|
||||||
'timeFormat' : <?= json_encode($time_format) ?>,
|
'timeFormat' : <?= json_encode($time_format) ?>,
|
||||||
'userSlug' : <?= json_encode($role_slug) ?>,
|
'userSlug' : <?= json_encode($role_slug) ?>,
|
||||||
'settings' : {
|
'settings' : {
|
||||||
|
@ -214,92 +215,7 @@
|
||||||
<th><?= lang('end') ?></th>
|
<th><?= lang('end') ?></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody><!-- Dynamic Content --></tbody>
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<div class="checkbox">
|
|
||||||
<label>
|
|
||||||
<input type="checkbox" id="sunday">
|
|
||||||
<?= lang('sunday') ?>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td><input id="sunday-start" class="work-start form-control input-sm"></td>
|
|
||||||
<td><input id="sunday-end" class="work-end form-control input-sm"></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<div class="checkbox">
|
|
||||||
<label>
|
|
||||||
<input type="checkbox" id="monday">
|
|
||||||
<?= lang('monday') ?>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td><input id="monday-start" class="work-start form-control input-sm"></td>
|
|
||||||
<td><input id="monday-end" class="work-end form-control input-sm"></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<div class="checkbox">
|
|
||||||
<label>
|
|
||||||
<input type="checkbox" id="tuesday">
|
|
||||||
<?= lang('tuesday') ?>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td><input id="tuesday-start" class="work-start form-control input-sm"></td>
|
|
||||||
<td><input id="tuesday-end" class="work-end form-control input-sm"></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<div class="checkbox">
|
|
||||||
<label>
|
|
||||||
<input type="checkbox" id="wednesday">
|
|
||||||
<?= lang('wednesday') ?>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td><input id="wednesday-start" class="work-start form-control input-sm"></td>
|
|
||||||
<td><input id="wednesday-end" class="work-end form-control input-sm"></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<div class="checkbox">
|
|
||||||
<label>
|
|
||||||
<input type="checkbox" id="thursday">
|
|
||||||
<?= lang('thursday') ?>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td><input id="thursday-start" class="work-start form-control input-sm"></td>
|
|
||||||
<td><input id="thursday-end" class="work-end form-control input-sm"></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<div class="checkbox">
|
|
||||||
<label>
|
|
||||||
<input type="checkbox" id="friday">
|
|
||||||
<?= lang('friday') ?>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td><input id="friday-start" class="work-start form-control input-sm"></td>
|
|
||||||
<td><input id="friday-end" class="work-end form-control input-sm"></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<div class="checkbox">
|
|
||||||
<label>
|
|
||||||
<input type="checkbox" id="saturday">
|
|
||||||
<?= lang('saturday') ?>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td><input id="saturday-start" class="work-start form-control input-sm"></td>
|
|
||||||
<td><input id="saturday-end" class="work-end form-control input-sm"></td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
csrfToken : <?= json_encode($this->security->get_csrf_hash()) ?>,
|
csrfToken : <?= json_encode($this->security->get_csrf_hash()) ?>,
|
||||||
baseUrl : <?= json_encode($base_url) ?>,
|
baseUrl : <?= json_encode($base_url) ?>,
|
||||||
dateFormat : <?= json_encode($date_format) ?>,
|
dateFormat : <?= json_encode($date_format) ?>,
|
||||||
|
firstWeekday : <?= json_encode($first_weekday); ?>,
|
||||||
timeFormat : <?= json_encode($time_format) ?>,
|
timeFormat : <?= json_encode($time_format) ?>,
|
||||||
admins : <?= json_encode($admins) ?>,
|
admins : <?= json_encode($admins) ?>,
|
||||||
providers : <?= json_encode($providers) ?>,
|
providers : <?= json_encode($providers) ?>,
|
||||||
|
@ -216,92 +217,7 @@
|
||||||
<th><?= lang('end') ?></th>
|
<th><?= lang('end') ?></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody><!-- Dynamic Content --></tbody>
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<div class="checkbox">
|
|
||||||
<label>
|
|
||||||
<input type="checkbox" id="sunday">
|
|
||||||
<?= lang('sunday') ?>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td><input id="sunday-start" class="work-start form-control input-sm"></td>
|
|
||||||
<td><input id="sunday-end" class="work-end form-control input-sm"></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<div class="checkbox">
|
|
||||||
<label>
|
|
||||||
<input type="checkbox" id="monday">
|
|
||||||
<?= lang('monday') ?>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td><input id="monday-start" class="work-start form-control input-sm"></td>
|
|
||||||
<td><input id="monday-end" class="work-end form-control input-sm"></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<div class="checkbox">
|
|
||||||
<label>
|
|
||||||
<input type="checkbox" id="tuesday">
|
|
||||||
<?= lang('tuesday') ?>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td><input id="tuesday-start" class="work-start form-control input-sm"></td>
|
|
||||||
<td><input id="tuesday-end" class="work-end form-control input-sm"></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<div class="checkbox">
|
|
||||||
<label>
|
|
||||||
<input type="checkbox" id="wednesday">
|
|
||||||
<?= lang('wednesday') ?>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td><input id="wednesday-start" class="work-start form-control input-sm"></td>
|
|
||||||
<td><input id="wednesday-end" class="work-end form-control input-sm"></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<div class="checkbox">
|
|
||||||
<label>
|
|
||||||
<input type="checkbox" id="thursday">
|
|
||||||
<?= lang('thursday') ?>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td><input id="thursday-start" class="work-start form-control input-sm"></td>
|
|
||||||
<td><input id="thursday-end" class="work-end form-control input-sm"></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<div class="checkbox">
|
|
||||||
<label>
|
|
||||||
<input type="checkbox" id="friday">
|
|
||||||
<?= lang('friday') ?>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td><input id="friday-start" class="work-start form-control input-sm"></td>
|
|
||||||
<td><input id="friday-end" class="work-end form-control input-sm"></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<div class="checkbox">
|
|
||||||
<label>
|
|
||||||
<input type="checkbox" id="saturday">
|
|
||||||
<?= lang('saturday') ?>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td><input id="saturday-start" class="work-start form-control input-sm"></td>
|
|
||||||
<td><input id="saturday-end" class="work-end form-control input-sm"></td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
|
@ -46,9 +46,12 @@
|
||||||
// Update the logo title on the header.
|
// Update the logo title on the header.
|
||||||
$('#header-logo span').text($('#company-name').val());
|
$('#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.
|
// We need to refresh the working plan.
|
||||||
var workingPlan = BackendSettings.wp.get();
|
var workingPlan = BackendSettings.wp.get();
|
||||||
$('.breaks tbody').empty();
|
|
||||||
BackendSettings.wp.setup(workingPlan);
|
BackendSettings.wp.setup(workingPlan);
|
||||||
BackendSettings.wp.timepickers(false);
|
BackendSettings.wp.timepickers(false);
|
||||||
}, 'json').fail(GeneralFunctions.ajaxFailureHandler);
|
}, 'json').fail(GeneralFunctions.ajaxFailureHandler);
|
||||||
|
|
|
@ -94,7 +94,6 @@
|
||||||
$('#provider-notifications').prop('disabled', false);
|
$('#provider-notifications').prop('disabled', false);
|
||||||
$('#providers').find('.add-break, .edit-break, .delete-break, #reset-working-plan').prop('disabled', false);
|
$('#providers').find('.add-break, .edit-break, .delete-break, #reset-working-plan').prop('disabled', false);
|
||||||
$('#provider-services input:checkbox').prop('disabled', false);
|
$('#provider-services input:checkbox').prop('disabled', false);
|
||||||
$('#providers input:checkbox').prop('disabled', false);
|
|
||||||
|
|
||||||
// Apply default working plan
|
// Apply default working plan
|
||||||
BackendUsers.wp.setup(GlobalVariables.workingPlan);
|
BackendUsers.wp.setup(GlobalVariables.workingPlan);
|
||||||
|
@ -232,8 +231,6 @@
|
||||||
* Event: Reset Working Plan Button "Click".
|
* Event: Reset Working Plan Button "Click".
|
||||||
*/
|
*/
|
||||||
$('#providers').on('click', '#reset-working-plan', function () {
|
$('#providers').on('click', '#reset-working-plan', function () {
|
||||||
$('.breaks tbody').empty();
|
|
||||||
$('.work-start, .work-end').val('');
|
|
||||||
BackendUsers.wp.setup(GlobalVariables.workingPlan);
|
BackendUsers.wp.setup(GlobalVariables.workingPlan);
|
||||||
BackendUsers.wp.timepickers(false);
|
BackendUsers.wp.timepickers(false);
|
||||||
});
|
});
|
||||||
|
@ -358,16 +355,12 @@
|
||||||
$('#provider-notifications').prop('disabled', true);
|
$('#provider-notifications').prop('disabled', true);
|
||||||
$('#provider-services input:checkbox').prop('disabled', true);
|
$('#provider-services input:checkbox').prop('disabled', true);
|
||||||
$('#providers .add-break, #reset-working-plan').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);
|
$('#edit-provider, #delete-provider').prop('disabled', true);
|
||||||
$('#providers .record-details').find('input, textarea').val('');
|
$('#providers .record-details').find('input, textarea').val('');
|
||||||
$('#providers input:checkbox').prop('checked', false);
|
|
||||||
$('#provider-services input:checkbox').prop('checked', false);
|
$('#provider-services input:checkbox').prop('checked', false);
|
||||||
$('#provider-services a').remove();
|
$('#provider-services a').remove();
|
||||||
|
$('#providers .working-plan tbody').empty();
|
||||||
$('#providers .breaks tbody').empty();
|
$('#providers .breaks tbody').empty();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -422,10 +415,10 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
// Display working plan
|
// Display working plan
|
||||||
$('#providers .breaks tbody').empty();
|
|
||||||
var workingPlan = $.parseJSON(provider.settings.working_plan);
|
var workingPlan = $.parseJSON(provider.settings.working_plan);
|
||||||
BackendUsers.wp.setup(workingPlan);
|
BackendUsers.wp.setup(workingPlan);
|
||||||
$('.breaks').find('.edit-break, .delete-break').prop('disabled', true);
|
$('.breaks').find('.edit-break, .delete-break').prop('disabled', true);
|
||||||
|
$('#providers .working-plan input:checkbox').prop('disabled', true);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -45,22 +45,48 @@
|
||||||
* @param {Object} workingPlan Contains the working hours and breaks for each day of the week.
|
* @param {Object} workingPlan Contains the working hours and breaks for each day of the week.
|
||||||
*/
|
*/
|
||||||
WorkingPlan.prototype.setup = function (workingPlan) {
|
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 fDaynum = GeneralFunctions.getWeekDayId(GlobalVariables.firstWeekday);
|
||||||
var workingPlanSorted = GeneralFunctions.sortWeekDict(workingPlan,0); // 0 is the ID for Sunday
|
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) {
|
$.each(workingPlanSorted, function (index, workingDay) {
|
||||||
|
|
||||||
|
var day = this.convertValueToDay(index);
|
||||||
|
var dayTranslatedname = GeneralFunctions.ucaseFirstLetter(day)
|
||||||
|
|
||||||
|
var tr =
|
||||||
|
'<tr>' +
|
||||||
|
'<td>' +
|
||||||
|
'<div class="checkbox">' +
|
||||||
|
'<label> <input type="checkbox" id="' + index + '">' + dayTranslatedname + '</label>' +
|
||||||
|
'</div>' +
|
||||||
|
'</td>' +
|
||||||
|
'<td><input id="'+index+'-start" class="work-start form-control input-sm"></td>' +
|
||||||
|
'<td><input id="'+index+'-end" class="work-end form-control input-sm"></td>' +
|
||||||
|
'</tr>';
|
||||||
|
|
||||||
|
$('.working-plan tbody').append(tr);
|
||||||
|
|
||||||
if (workingDay != null) {
|
if (workingDay != null) {
|
||||||
$('#' + index).prop('checked', true);
|
$('#' + index).prop('checked', true);
|
||||||
$('#' + index + '-start').val(Date.parse(workingDay.start).toString(GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm').toUpperCase());
|
$('#' + 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());
|
$('#' + 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.
|
// Add the day's breaks on the breaks table.
|
||||||
$.each(workingDay.breaks, function (i, brk) {
|
$.each(workingDay.breaks, function (i, brk) {
|
||||||
var day = this.convertValueToDay(index);
|
|
||||||
|
|
||||||
var tr =
|
tr =
|
||||||
'<tr>' +
|
'<tr>' +
|
||||||
'<td class="break-day editable">' + GeneralFunctions.ucaseFirstLetter(day) + '</td>' +
|
'<td class="break-day editable">' + dayTranslatedname + '</td>' +
|
||||||
'<td class="break-start editable">' + Date.parse(brk.start).toString(GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm').toUpperCase() + '</td>' +
|
'<td class="break-start editable">' + Date.parse(brk.start).toString(GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm').toUpperCase() + '</td>' +
|
||||||
'<td class="break-end editable">' + Date.parse(brk.end).toString(GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm').toUpperCase() + '</td>' +
|
'<td class="break-end editable">' + Date.parse(brk.end).toString(GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm').toUpperCase() + '</td>' +
|
||||||
'<td>' +
|
'<td>' +
|
||||||
|
@ -171,7 +197,7 @@
|
||||||
*
|
*
|
||||||
* Enable or disable the time selection for each day.
|
* 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');
|
var id = $(this).attr('id');
|
||||||
|
|
||||||
if ($(this).prop('checked') == true) {
|
if ($(this).prop('checked') == true) {
|
||||||
|
@ -308,6 +334,12 @@
|
||||||
$modifiedRow.find('.save-break, .cancel-break').addClass('hidden');
|
$modifiedRow.find('.save-break, .cancel-break').addClass('hidden');
|
||||||
$(element).closest('table').find('.edit-break, .delete-break').removeClass('hidden');
|
$(element).closest('table').find('.edit-break, .delete-break').removeClass('hidden');
|
||||||
$('.add-break').prop('disabled', false);
|
$('.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));
|
}.bind(this));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -342,7 +374,7 @@
|
||||||
|
|
||||||
workingPlan[id].breaks.sort(function (break1, break2) {
|
workingPlan[id].breaks.sort(function (break1, break2) {
|
||||||
// We can do a direct string comparison since we have time based on 24 hours clock.
|
// 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));
|
}.bind(this));
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue