The javascript code must use moment instead of datejs
This commit is contained in:
parent
5906ae2aef
commit
b8cdf1c3ff
12 changed files with 194 additions and 208 deletions
|
@ -113,13 +113,8 @@ window.Backend = window.Backend || {};
|
|||
'html': [
|
||||
$('<button/>', {
|
||||
'type': 'button',
|
||||
'class': 'close',
|
||||
'data-dismiss': 'alert',
|
||||
'html': [
|
||||
$('<span/>', {
|
||||
'html': '×'
|
||||
})
|
||||
]
|
||||
'class': 'btn-close',
|
||||
'data-dismiss': 'alert'
|
||||
}),
|
||||
$('<strong/>', {
|
||||
'html': message
|
||||
|
|
|
@ -51,11 +51,12 @@ window.BackendCalendarAppointmentsModal = window.BackendCalendarAppointmentsModa
|
|||
// ID must exist on the object in order for the model to update the record and not to perform
|
||||
// an insert operation.
|
||||
|
||||
var startDatetime = $dialog
|
||||
.find('#start-datetime')
|
||||
.datetimepicker('getDate')
|
||||
.toString('yyyy-MM-dd HH:mm:ss');
|
||||
var endDatetime = $dialog.find('#end-datetime').datetimepicker('getDate').toString('yyyy-MM-dd HH:mm:ss');
|
||||
var startDatetime = moment($dialog.find('#start-datetime').datetimepicker('getDate')).format(
|
||||
'YYYY-MM-DD HH:mm:ss'
|
||||
);
|
||||
var endDatetime = moment($dialog.find('#end-datetime').datetimepicker('getDate')).format(
|
||||
'YYYY-MM-DD HH:mm:ss'
|
||||
);
|
||||
|
||||
var appointment = {
|
||||
id_services: $dialog.find('#select-service').val(),
|
||||
|
@ -151,26 +152,37 @@ window.BackendCalendarAppointmentsModal = window.BackendCalendarAppointmentsModa
|
|||
|
||||
var duration = service ? service.duration : 60;
|
||||
|
||||
var start = new Date();
|
||||
var currentMin = parseInt(start.toString('mm'));
|
||||
var startMoment = moment();
|
||||
|
||||
var currentMin = parseInt(startMoment.format('mm'));
|
||||
|
||||
if (currentMin > 0 && currentMin < 15) {
|
||||
start.set({'minute': 15});
|
||||
startMoment.set({minutes: 15});
|
||||
} else if (currentMin > 15 && currentMin < 30) {
|
||||
start.set({'minute': 30});
|
||||
startMoment.set({minutes: 30});
|
||||
} else if (currentMin > 30 && currentMin < 45) {
|
||||
start.set({'minute': 45});
|
||||
startMoment.set({minutes: 45});
|
||||
} else {
|
||||
start.addHours(1).set({'minute': 0});
|
||||
startMoment.add(1, 'hour').set({minutes: 0});
|
||||
}
|
||||
|
||||
$dialog.find('#start-datetime').val(GeneralFunctions.formatDate(start, GlobalVariables.dateFormat, true));
|
||||
$dialog
|
||||
.find('#start-datetime')
|
||||
.val(GeneralFunctions.formatDate(startMoment.toDate(), GlobalVariables.dateFormat, true));
|
||||
|
||||
$dialog
|
||||
.find('#end-datetime')
|
||||
.val(GeneralFunctions.formatDate(start.addMinutes(duration), GlobalVariables.dateFormat, true));
|
||||
.val(
|
||||
GeneralFunctions.formatDate(
|
||||
startMoment.add(duration, 'minutes').toDate(),
|
||||
GlobalVariables.dateFormat,
|
||||
true
|
||||
)
|
||||
);
|
||||
|
||||
// Display modal form.
|
||||
$dialog.find('.modal-header h3').text(EALang.new_appointment_title);
|
||||
|
||||
$dialog.modal('show');
|
||||
});
|
||||
|
||||
|
@ -420,7 +432,7 @@ window.BackendCalendarAppointmentsModal = window.BackendCalendarAppointmentsModa
|
|||
var duration = service ? service.duration : 0;
|
||||
|
||||
var startDatetime = new Date();
|
||||
var endDatetime = new Date().addMinutes(duration);
|
||||
var endDatetime = moment().add(duration, 'minutes').toDate();
|
||||
var dateFormat;
|
||||
|
||||
switch (GlobalVariables.dateFormat) {
|
||||
|
@ -442,7 +454,7 @@ window.BackendCalendarAppointmentsModal = window.BackendCalendarAppointmentsModa
|
|||
|
||||
$dialog.find('#start-datetime').datetimepicker({
|
||||
dateFormat: dateFormat,
|
||||
timeFormat: GlobalVariables.timeFormat === 'regular' ? 'h:mm TT' : 'HH:mm',
|
||||
timeFormat: GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm',
|
||||
|
||||
// Translation
|
||||
dayNames: [
|
||||
|
@ -511,7 +523,7 @@ window.BackendCalendarAppointmentsModal = window.BackendCalendarAppointmentsModa
|
|||
|
||||
$dialog.find('#end-datetime').datetimepicker({
|
||||
dateFormat: dateFormat,
|
||||
timeFormat: GlobalVariables.timeFormat === 'regular' ? 'h:mm TT' : 'HH:mm',
|
||||
timeFormat: GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm',
|
||||
|
||||
// Translation
|
||||
dayNames: [
|
||||
|
|
|
@ -69,8 +69,8 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
|
|||
$(this).parents('.popover').popover('dispose');
|
||||
|
||||
var $dialog;
|
||||
var startDatetime;
|
||||
var endDatetime;
|
||||
var startMoment;
|
||||
var endMoment;
|
||||
|
||||
if (lastFocusedEventData.data.workingPlanException) {
|
||||
var date = lastFocusedEventData.data.date;
|
||||
|
@ -106,7 +106,7 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
|
|||
null
|
||||
);
|
||||
});
|
||||
} else if (lastFocusedEventData.data.is_unavailable === '0') {
|
||||
} else if (!lastFocusedEventData.data.is_unavailable) {
|
||||
var appointment = lastFocusedEventData.data;
|
||||
$dialog = $('#manage-appointment');
|
||||
|
||||
|
@ -119,11 +119,11 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
|
|||
$dialog.find('#select-provider').val(appointment.id_users_provider);
|
||||
|
||||
// Set the start and end datetime of the appointment.
|
||||
startDatetime = Date.parseExact(appointment.start_datetime, 'yyyy-MM-dd HH:mm:ss');
|
||||
$dialog.find('#start-datetime').datetimepicker('setDate', startDatetime);
|
||||
startMoment = moment(appointment.start_datetime);
|
||||
$dialog.find('#start-datetime').datetimepicker('setDate', startMoment.toDate());
|
||||
|
||||
endDatetime = Date.parseExact(appointment.end_datetime, 'yyyy-MM-dd HH:mm:ss');
|
||||
$dialog.find('#end-datetime').datetimepicker('setDate', endDatetime);
|
||||
endMoment = moment(appointment.end_datetime);
|
||||
$dialog.find('#end-datetime').datetimepicker('setDate', endMoment.toDate());
|
||||
|
||||
var customer = appointment.customer;
|
||||
$dialog.find('#customer-id').val(appointment.id_users_customer);
|
||||
|
@ -143,19 +143,19 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
|
|||
|
||||
// Replace string date values with actual date objects.
|
||||
unavailable.start_datetime = lastFocusedEventData.start.format('YYYY-MM-DD HH:mm:ss');
|
||||
startDatetime = Date.parseExact(unavailable.start_datetime, 'yyyy-MM-dd HH:mm:ss');
|
||||
startMoment = moment(unavailable.start_datetime);
|
||||
unavailable.end_datetime = lastFocusedEventData.end.format('YYYY-MM-DD HH:mm:ss');
|
||||
endDatetime = Date.parseExact(unavailable.end_datetime, 'yyyy-MM-dd HH:mm:ss');
|
||||
endMoment = moment(unavailable.end_datetime);
|
||||
|
||||
$dialog = $('#manage-unavailable');
|
||||
BackendCalendarUnavailabilityEventsModal.resetUnavailableDialog();
|
||||
|
||||
// Apply unavailable data to dialog.
|
||||
$dialog.find('.modal-header h3').text('Edit Unavailable Period');
|
||||
$dialog.find('#unavailable-start').datetimepicker('setDate', startDatetime);
|
||||
$dialog.find('#unavailable-start').datetimepicker('setDate', startMoment.toDate());
|
||||
$dialog.find('#unavailable-id').val(unavailable.id);
|
||||
$dialog.find('#unavailable-provider').val(unavailable.id_users_provider);
|
||||
$dialog.find('#unavailable-end').datetimepicker('setDate', endDatetime);
|
||||
$dialog.find('#unavailable-end').datetimepicker('setDate', endMoment.toDate());
|
||||
$dialog.find('#unavailable-notes').val(unavailable.notes);
|
||||
$dialog.modal('show');
|
||||
}
|
||||
|
@ -205,7 +205,7 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
|
|||
var date = lastFocusedEventData.start.format('YYYY-MM-DD');
|
||||
|
||||
BackendCalendarApi.deleteWorkingPlanException(date, providerId, successCallback);
|
||||
} else if (lastFocusedEventData.data.is_unavailable === '0') {
|
||||
} else if (!lastFocusedEventData.data.is_unavailable) {
|
||||
var buttons = [
|
||||
{
|
||||
text: EALang.cancel,
|
||||
|
@ -737,11 +737,11 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
|
|||
$('#notification').hide('bind');
|
||||
}
|
||||
|
||||
if (Boolean(Number(event.data.is_unavailable)) === false) {
|
||||
if (!event.data.is_unavailable) {
|
||||
// Prepare appointment data.
|
||||
event.data.end_datetime = Date.parseExact(event.data.end_datetime, 'yyyy-MM-dd HH:mm:ss')
|
||||
event.data.end_datetime = moment(event.data.end_datetime)
|
||||
.add({days: delta.days(), hours: delta.hours(), minutes: delta.minutes()})
|
||||
.toString('yyyy-MM-dd HH:mm:ss');
|
||||
.format('YYYY-MM-DD HH:mm:ss');
|
||||
|
||||
var appointment = GeneralFunctions.clone(event.data);
|
||||
|
||||
|
@ -754,12 +754,9 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
|
|||
successCallback = function () {
|
||||
// Display success notification to user.
|
||||
var undoFunction = function () {
|
||||
appointment.end_datetime = event.data.end_datetime = Date.parseExact(
|
||||
appointment.end_datetime,
|
||||
'yyyy-MM-dd HH:mm:ss'
|
||||
)
|
||||
appointment.end_datetime = event.data.end_datetime = moment(appointment.end_datetime)
|
||||
.add({days: -delta.days(), hours: -delta.hours(), minutes: -delta.minutes()})
|
||||
.toString('yyyy-MM-dd HH:mm:ss');
|
||||
.format('YYYY-MM-DD HH:mm:ss');
|
||||
|
||||
var url = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_save_appointment';
|
||||
|
||||
|
@ -804,12 +801,9 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
|
|||
successCallback = function () {
|
||||
// Display success notification to user.
|
||||
var undoFunction = function () {
|
||||
unavailable.end_datetime = event.data.end_datetime = Date.parseExact(
|
||||
unavailable.end_datetime,
|
||||
'yyyy-MM-dd HH:mm:ss'
|
||||
)
|
||||
unavailable.end_datetime = event.data.end_datetime = moment(unavailable.end_datetime)
|
||||
.add({minutes: -delta.minutes()})
|
||||
.toString('yyyy-MM-dd HH:mm:ss');
|
||||
.format('YYYY-MM-DD HH:mm:ss');
|
||||
|
||||
var url = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_save_unavailable';
|
||||
|
||||
|
@ -892,7 +886,7 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
|
|||
|
||||
var successCallback;
|
||||
|
||||
if (event.data.is_unavailable === '0') {
|
||||
if (!event.data.is_unavailable) {
|
||||
// Prepare appointment data.
|
||||
var appointment = GeneralFunctions.clone(event.data);
|
||||
|
||||
|
@ -901,13 +895,13 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
|
|||
delete appointment.provider;
|
||||
delete appointment.service;
|
||||
|
||||
appointment.start_datetime = Date.parseExact(appointment.start_datetime, 'yyyy-MM-dd HH:mm:ss')
|
||||
appointment.start_datetime = moment(appointment.start_datetime)
|
||||
.add({days: delta.days(), hours: delta.hours(), minutes: delta.minutes()})
|
||||
.toString('yyyy-MM-dd HH:mm:ss');
|
||||
.format('YYYY-MM-DD HH:mm:ss');
|
||||
|
||||
appointment.end_datetime = Date.parseExact(appointment.end_datetime, 'yyyy-MM-dd HH:mm:ss')
|
||||
appointment.end_datetime = moment(appointment.end_datetime)
|
||||
.add({days: delta.days(), hours: delta.hours(), minutes: delta.minutes()})
|
||||
.toString('yyyy-MM-dd HH:mm:ss');
|
||||
.format('YYYY-MM-DD HH:mm:ss');
|
||||
|
||||
event.data.start_datetime = appointment.start_datetime;
|
||||
event.data.end_datetime = appointment.end_datetime;
|
||||
|
@ -916,13 +910,13 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
|
|||
successCallback = function () {
|
||||
// Define the undo function, if the user needs to reset the last change.
|
||||
var undoFunction = function () {
|
||||
appointment.start_datetime = Date.parseExact(appointment.start_datetime, 'yyyy-MM-dd HH:mm:ss')
|
||||
appointment.start_datetime = moment(appointment.start_datetime)
|
||||
.add({days: -delta.days(), hours: -delta.hours(), minutes: -delta.minutes()})
|
||||
.toString('yyyy-MM-dd HH:mm:ss');
|
||||
.format('YYYY-MM-DD HH:mm:ss');
|
||||
|
||||
appointment.end_datetime = Date.parseExact(appointment.end_datetime, 'yyyy-MM-dd HH:mm:ss')
|
||||
appointment.end_datetime = moment(appointment.end_datetime)
|
||||
.add({days: -delta.days(), hours: -delta.hours(), minutes: -delta.minutes()})
|
||||
.toString('yyyy-MM-dd HH:mm:ss');
|
||||
.format('YYYY-MM-DD HH:mm:ss');
|
||||
|
||||
event.data.start_datetime = appointment.start_datetime;
|
||||
event.data.end_datetime = appointment.end_datetime;
|
||||
|
@ -964,13 +958,13 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
|
|||
|
||||
successCallback = function () {
|
||||
var undoFunction = function () {
|
||||
unavailable.start_datetime = Date.parseExact(unavailable.start_datetime, 'yyyy-MM-dd HH:mm:ss')
|
||||
unavailable.start_datetime = moment(unavailable.start_datetime)
|
||||
.add({days: -delta.days(), minutes: -delta.minutes()})
|
||||
.toString('yyyy-MM-dd HH:mm:ss');
|
||||
.format('YYYY-MM-DD HH:mm:ss');
|
||||
|
||||
unavailable.end_datetime = Date.parseExact(unavailable.end_datetime, 'yyyy-MM-dd HH:mm:ss')
|
||||
unavailable.end_datetime = moment(unavailable.end_datetime)
|
||||
.add({days: -delta.days(), minutes: -delta.minutes()})
|
||||
.toString('yyyy-MM-dd HH:mm:ss');
|
||||
.format('YYYY-MM-DD HH:mm:ss');
|
||||
|
||||
event.data.start_datetime = unavailable.start_datetime;
|
||||
event.data.end_datetime = unavailable.end_datetime;
|
||||
|
@ -1686,10 +1680,10 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
|
|||
$dialog.find('#select-provider').val(appointment.id_users_provider);
|
||||
|
||||
// Set the start and end datetime of the appointment.
|
||||
var startDatetime = Date.parseExact(appointment.start_datetime, 'yyyy-MM-dd HH:mm:ss');
|
||||
var startDatetime = moment(appointment.start_datetime);
|
||||
$dialog.find('#start-datetime').datetimepicker('setDate', startDatetime);
|
||||
|
||||
var endDatetime = Date.parseExact(appointment.end_datetime, 'yyyy-MM-dd HH:mm:ss');
|
||||
var endDatetime = moment(appointment.end_datetime);
|
||||
$dialog.find('#end-datetime').datetimepicker('setDate', endDatetime);
|
||||
|
||||
var customer = appointment.customer;
|
||||
|
|
|
@ -146,6 +146,8 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {};
|
|||
$(this).parents('.popover').popover('dispose');
|
||||
|
||||
var $dialog;
|
||||
var startMoment;
|
||||
var endMoment;
|
||||
|
||||
if (lastFocusedEventData.data.workingPlanException) {
|
||||
var date = lastFocusedEventData.data.date;
|
||||
|
@ -194,11 +196,11 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {};
|
|||
$dialog.find('#select-provider').val(appointment.id_users_provider);
|
||||
|
||||
// Set the start and end datetime of the appointment.
|
||||
var startDatetime = Date.parseExact(appointment.start_datetime, 'yyyy-MM-dd HH:mm:ss');
|
||||
$dialog.find('#start-datetime').datetimepicker('setDate', startDatetime);
|
||||
startMoment = moment(appointment.start_datetime);
|
||||
$dialog.find('#start-datetime').datetimepicker('setDate', startMoment);
|
||||
|
||||
var endDatetime = Date.parseExact(appointment.end_datetime, 'yyyy-MM-dd HH:mm:ss');
|
||||
$dialog.find('#end-datetime').datetimepicker('setDate', endDatetime);
|
||||
endMoment = moment(appointment.end_datetime);
|
||||
$dialog.find('#end-datetime').datetimepicker('setDate', endMoment);
|
||||
|
||||
var customer = appointment.customer;
|
||||
$dialog.find('#customer-id').val(appointment.id_users_customer);
|
||||
|
@ -219,19 +221,19 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {};
|
|||
|
||||
// Replace string date values with actual date objects.
|
||||
unavailable.start_datetime = lastFocusedEventData.start.format('YYYY-MM-DD HH:mm:ss');
|
||||
var startDatetime = Date.parseExact(unavailable.start_datetime, 'yyyy-MM-dd HH:mm:ss');
|
||||
startMoment = moment(unavailable.start_datetime);
|
||||
unavailable.end_datetime = lastFocusedEventData.end.format('YYYY-MM-DD HH:mm:ss');
|
||||
var endDatetime = Date.parseExact(unavailable.end_datetime, 'yyyy-MM-dd HH:mm:ss');
|
||||
endMoment = moment(unavailable.end_datetime);
|
||||
|
||||
$dialog = $('#manage-unavailable');
|
||||
BackendCalendarUnavailabilityEventsModal.resetUnavailableDialog();
|
||||
|
||||
// Apply unavailable data to dialog.
|
||||
$dialog.find('.modal-header h3').text('Edit Unavailable Period');
|
||||
$dialog.find('#unavailable-start').datetimepicker('setDate', startDatetime);
|
||||
$dialog.find('#unavailable-start').datetimepicker('setDate', startMoment);
|
||||
$dialog.find('#unavailable-id').val(unavailable.id);
|
||||
$dialog.find('#unavailable-provider').val(unavailable.id_users_provider);
|
||||
$dialog.find('#unavailable-end').datetimepicker('setDate', endDatetime);
|
||||
$dialog.find('#unavailable-end').datetimepicker('setDate', endMoment);
|
||||
$dialog.find('#unavailable-notes').val(unavailable.notes);
|
||||
|
||||
$dialog.modal('show');
|
||||
|
@ -1505,9 +1507,9 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {};
|
|||
|
||||
if (event.data.is_unavailable === '0') {
|
||||
// Prepare appointment data.
|
||||
event.data.end_datetime = Date.parseExact(event.data.end_datetime, 'yyyy-MM-dd HH:mm:ss')
|
||||
event.data.end_datetime = moment(event.data.end_datetime)
|
||||
.add({days: delta.days(), hours: delta.hours(), minutes: delta.minutes()})
|
||||
.toString('yyyy-MM-dd HH:mm:ss');
|
||||
.format('YYYY-MM-DD HH:mm:ss');
|
||||
|
||||
var appointment = GeneralFunctions.clone(event.data);
|
||||
|
||||
|
@ -1520,12 +1522,9 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {};
|
|||
successCallback = function () {
|
||||
// Display success notification to user.
|
||||
var undoFunction = function () {
|
||||
appointment.end_datetime = event.data.end_datetime = Date.parseExact(
|
||||
appointment.end_datetime,
|
||||
'yyyy-MM-dd HH:mm:ss'
|
||||
)
|
||||
appointment.end_datetime = event.data.end_datetime = moment(appointment.end_datetime)
|
||||
.add({days: -delta.days(), hours: -delta.hours(), minutes: -delta.minutes()})
|
||||
.toString('yyyy-MM-dd HH:mm:ss');
|
||||
.format('YYYY-MM-DD HH:mm:ss');
|
||||
|
||||
var url = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_save_appointment';
|
||||
|
||||
|
@ -1570,12 +1569,9 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {};
|
|||
successCallback = function () {
|
||||
// Display success notification to user.
|
||||
var undoFunction = function () {
|
||||
unavailable.end_datetime = event.data.end_datetime = Date.parseExact(
|
||||
unavailable.end_datetime,
|
||||
'yyyy-MM-dd HH:mm:ss'
|
||||
)
|
||||
unavailable.end_datetime = event.data.end_datetime = moment(unavailable.end_datetime)
|
||||
.add({minutes: -delta.minutes()})
|
||||
.toString('yyyy-MM-dd HH:mm:ss');
|
||||
.format('YYYY-MM-DD HH:mm:ss');
|
||||
|
||||
var url = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_save_unavailable';
|
||||
|
||||
|
@ -1636,13 +1632,13 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {};
|
|||
delete appointment.provider;
|
||||
delete appointment.service;
|
||||
|
||||
appointment.start_datetime = Date.parseExact(appointment.start_datetime, 'yyyy-MM-dd HH:mm:ss')
|
||||
appointment.start_datetime = moment(appointment.start_datetime)
|
||||
.add({days: delta.days(), hours: delta.hours(), minutes: delta.minutes()})
|
||||
.toString('yyyy-MM-dd HH:mm:ss');
|
||||
.format('YYYY-MM-DD HH:mm:ss');
|
||||
|
||||
appointment.end_datetime = Date.parseExact(appointment.end_datetime, 'yyyy-MM-dd HH:mm:ss')
|
||||
appointment.end_datetime = moment(appointment.end_datetime)
|
||||
.add({days: delta.days(), hours: delta.hours(), minutes: delta.minutes()})
|
||||
.toString('yyyy-MM-dd HH:mm:ss');
|
||||
.format('YYYY-MM-DD HH:mm:ss');
|
||||
|
||||
event.data.start_datetime = appointment.start_datetime;
|
||||
event.data.end_datetime = appointment.end_datetime;
|
||||
|
@ -1651,13 +1647,13 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {};
|
|||
successCallback = function () {
|
||||
// Define the undo function, if the user needs to reset the last change.
|
||||
var undoFunction = function () {
|
||||
appointment.start_datetime = Date.parseExact(appointment.start_datetime, 'yyyy-MM-dd HH:mm:ss')
|
||||
appointment.start_datetime = moment(appointment.start_datetime)
|
||||
.add({days: -delta.days(), hours: -delta.hours(), minutes: -delta.minutes()})
|
||||
.toString('yyyy-MM-dd HH:mm:ss');
|
||||
.format('YYYY-MM-DD HH:mm:ss');
|
||||
|
||||
appointment.end_datetime = Date.parseExact(appointment.end_datetime, 'yyyy-MM-dd HH:mm:ss')
|
||||
appointment.end_datetime = moment(appointment.end_datetime)
|
||||
.add({days: -delta.days(), hours: -delta.hours(), minutes: -delta.minutes()})
|
||||
.toString('yyyy-MM-dd HH:mm:ss');
|
||||
.format('YYYY-MM-DD HH:mm:ss');
|
||||
|
||||
event.data.start_datetime = appointment.start_datetime;
|
||||
event.data.end_datetime = appointment.end_datetime;
|
||||
|
@ -1699,13 +1695,13 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {};
|
|||
|
||||
successCallback = function () {
|
||||
var undoFunction = function () {
|
||||
unavailable.start_datetime = Date.parseExact(unavailable.start_datetime, 'yyyy-MM-dd HH:mm:ss')
|
||||
unavailable.start_datetime = moment(unavailable.start_datetime)
|
||||
.add({days: -delta.days(), minutes: -delta.minutes()})
|
||||
.toString('yyyy-MM-dd HH:mm:ss');
|
||||
.format('YYYY-MM-DD HH:mm:ss');
|
||||
|
||||
unavailable.end_datetime = Date.parseExact(unavailable.end_datetime, 'yyyy-MM-dd HH:mm:ss')
|
||||
unavailable.end_datetime = moment(unavailable.end_datetime)
|
||||
.add({days: -delta.days(), minutes: -delta.minutes()})
|
||||
.toString('yyyy-MM-dd HH:mm:ss');
|
||||
.format('YYYY-MM-DD HH:mm:ss');
|
||||
|
||||
event.data.start_datetime = unavailable.start_datetime;
|
||||
event.data.end_datetime = unavailable.end_datetime;
|
||||
|
|
|
@ -39,7 +39,7 @@ window.BackendCalendarUnavailabilityEventsModal = window.BackendCalendarUnavaila
|
|||
return;
|
||||
}
|
||||
|
||||
var end = Date.parse($dialog.find('#unavailable-end').datetimepicker('getDate'));
|
||||
var end = moment($dialog.find('#unavailable-end').datetimepicker('getDate')).toDate();
|
||||
|
||||
if (!end) {
|
||||
$dialog.find('#unavailable-end').addClass('is-invalid');
|
||||
|
@ -95,17 +95,18 @@ window.BackendCalendarUnavailabilityEventsModal = window.BackendCalendarUnavaila
|
|||
var $dialog = $('#manage-unavailable');
|
||||
|
||||
// Set the default datetime values.
|
||||
var start = new Date();
|
||||
var currentMin = parseInt(start.toString('mm'));
|
||||
var startMoment = new Date();
|
||||
|
||||
var currentMin = parseInt(startMoment.toString('mm'));
|
||||
|
||||
if (currentMin > 0 && currentMin < 15) {
|
||||
start.set({'minute': 15});
|
||||
startMoment.set({minutes: 15});
|
||||
} else if (currentMin > 15 && currentMin < 30) {
|
||||
start.set({'minute': 30});
|
||||
startMoment.set({minutes: 30});
|
||||
} else if (currentMin > 30 && currentMin < 45) {
|
||||
start.set({'minute': 45});
|
||||
startMoment.set({minutes: 45});
|
||||
} else {
|
||||
start.addHours(1).set({'minute': 0});
|
||||
startMoment.add(1, 'hour').set({minutes: 0});
|
||||
}
|
||||
|
||||
if ($('.calendar-view').length === 0) {
|
||||
|
@ -114,10 +115,12 @@ window.BackendCalendarUnavailabilityEventsModal = window.BackendCalendarUnavaila
|
|||
|
||||
$dialog
|
||||
.find('#unavailable-start')
|
||||
.val(GeneralFunctions.formatDate(start, GlobalVariables.dateFormat, true));
|
||||
.val(GeneralFunctions.formatDate(startMoment.toDate(), GlobalVariables.dateFormat, true));
|
||||
$dialog
|
||||
.find('#unavailable-end')
|
||||
.val(GeneralFunctions.formatDate(start.addHours(1), GlobalVariables.dateFormat, true));
|
||||
.val(
|
||||
GeneralFunctions.formatDate(startMoment.add(1, 'hour').toDate(), GlobalVariables.dateFormat, true)
|
||||
);
|
||||
$dialog.find('.modal-header h3').text(EALang.new_unavailable_title);
|
||||
$dialog.modal('show');
|
||||
});
|
||||
|
@ -135,8 +138,10 @@ window.BackendCalendarUnavailabilityEventsModal = window.BackendCalendarUnavaila
|
|||
$dialog.find('#unavailable-id').val('');
|
||||
|
||||
// Set default time values
|
||||
var start = GeneralFunctions.formatDate(new Date(), GlobalVariables.dateFormat, true);
|
||||
var end = GeneralFunctions.formatDate(new Date().addHours(1), GlobalVariables.dateFormat, true);
|
||||
var start = GeneralFunctions.formatDate(moment().toDate(), GlobalVariables.dateFormat, true);
|
||||
|
||||
var end = GeneralFunctions.formatDate(moment().add(1, 'hour').toDate(), GlobalVariables.dateFormat, true);
|
||||
|
||||
var dateFormat;
|
||||
|
||||
switch (GlobalVariables.dateFormat) {
|
||||
|
@ -156,7 +161,7 @@ window.BackendCalendarUnavailabilityEventsModal = window.BackendCalendarUnavaila
|
|||
|
||||
$dialog.find('#unavailable-start').datetimepicker({
|
||||
dateFormat: dateFormat,
|
||||
timeFormat: GlobalVariables.timeFormat === 'regular' ? 'h:mm TT' : 'HH:mm',
|
||||
timeFormat: GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm',
|
||||
|
||||
// Translation
|
||||
dayNames: [
|
||||
|
@ -214,7 +219,7 @@ window.BackendCalendarUnavailabilityEventsModal = window.BackendCalendarUnavaila
|
|||
|
||||
$dialog.find('#unavailable-end').datetimepicker({
|
||||
dateFormat: dateFormat,
|
||||
timeFormat: GlobalVariables.timeFormat === 'regular' ? 'h:mm TT' : 'HH:mm',
|
||||
timeFormat: GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm',
|
||||
|
||||
// Translation
|
||||
dayNames: [
|
||||
|
|
|
@ -46,7 +46,7 @@ window.BackendCalendarWorkingPlanExceptionsModal = window.BackendCalendarWorking
|
|||
return;
|
||||
}
|
||||
|
||||
var end = Date.parse($('#working-plan-exception-end').datetimepicker('getDate'));
|
||||
var end = moment($('#working-plan-exception-end').datetimepicker('getDate')).toDate();
|
||||
|
||||
if (!end) {
|
||||
$('#working-plan-exception-end').addClass('is-invalid');
|
||||
|
|
|
@ -306,12 +306,12 @@
|
|||
}
|
||||
|
||||
var start = GeneralFunctions.formatDate(
|
||||
Date.parse(appointment.start_datetime),
|
||||
moment(appointment.start_datetime).toDate(),
|
||||
GlobalVariables.dateFormat,
|
||||
true
|
||||
);
|
||||
var end = GeneralFunctions.formatDate(
|
||||
Date.parse(appointment.end_datetime),
|
||||
moment(appointment.end_datetime).toDate(),
|
||||
GlobalVariables.dateFormat,
|
||||
true
|
||||
);
|
||||
|
|
|
@ -96,7 +96,7 @@ window.FrontendBook = window.FrontendBook || {};
|
|||
dateFormat: 'dd-mm-yy',
|
||||
firstDay: weekDayId,
|
||||
minDate: 0,
|
||||
defaultDate: Date.today(),
|
||||
defaultDate: moment().toDate(),
|
||||
|
||||
dayNames: [
|
||||
EALang.sunday,
|
||||
|
@ -669,9 +669,9 @@ window.FrontendBook = window.FrontendBook || {};
|
|||
|
||||
data.appointment = {
|
||||
start_datetime:
|
||||
$('#select-date').datepicker('getDate').toString('yyyy-MM-dd') +
|
||||
moment($('#select-date').datepicker('getDate')).format('YYYY-MM-DD') +
|
||||
' ' +
|
||||
Date.parse($('.selected-hour').data('value') || '').toString('HH:mm') +
|
||||
moment($('.selected-hour').data('value') || '').format('HH:mm') +
|
||||
':00',
|
||||
end_datetime: calculateEndDatetime(),
|
||||
notes: $('#notes').val(),
|
||||
|
@ -705,20 +705,21 @@ window.FrontendBook = window.FrontendBook || {};
|
|||
});
|
||||
|
||||
// Add the duration to the start datetime.
|
||||
var startDatetime =
|
||||
$('#select-date').datepicker('getDate').toString('dd-MM-yyyy') +
|
||||
' ' +
|
||||
Date.parse($('.selected-hour').data('value') || '').toString('HH:mm');
|
||||
startDatetime = Date.parseExact(startDatetime, 'dd-MM-yyyy HH:mm');
|
||||
var endDatetime;
|
||||
var selectedDate = moment($('#select-date').datepicker('getDate')).format('YYYY-MM-DD');
|
||||
|
||||
if (service.duration && startDatetime) {
|
||||
endDatetime = startDatetime.add({'minutes': parseInt(service.duration)});
|
||||
var selectedHour = $('.selected-hour').data('value'); // HH:mm
|
||||
|
||||
var startMoment = moment(selectedDate + ' ' + selectedHour);
|
||||
|
||||
var endMoment;
|
||||
|
||||
if (service.duration && startMoment) {
|
||||
endMoment = startMoment.clone().add({'minutes': parseInt(service.duration)});
|
||||
} else {
|
||||
endDatetime = new Date();
|
||||
endMoment = moment();
|
||||
}
|
||||
|
||||
return endDatetime.toString('yyyy-MM-dd HH:mm:ss');
|
||||
return endMoment.format('YYYY-MM-DD HH:mm:ss');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -738,8 +739,9 @@ window.FrontendBook = window.FrontendBook || {};
|
|||
$('#select-provider').val(appointment.id_users_provider);
|
||||
|
||||
// Set Appointment Date
|
||||
$('#select-date').datepicker('setDate', Date.parseExact(appointment.start_datetime, 'yyyy-MM-dd HH:mm:ss'));
|
||||
FrontendBookApi.getAvailableHours(moment(appointment.start_datetime).format('YYYY-MM-DD'));
|
||||
var startMoment = moment(appointment.start_datetime);
|
||||
$('#select-date').datepicker('setDate', startMoment.toDate());
|
||||
FrontendBookApi.getAvailableHours(startMoment.format('YYYY-MM-DD'));
|
||||
|
||||
// Apply Customer's Data
|
||||
$('#last-name').val(customer.last_name);
|
||||
|
|
|
@ -120,10 +120,7 @@ window.FrontendBookApi = window.FrontendBookApi || {};
|
|||
.filter(function () {
|
||||
return (
|
||||
$(this).text() ===
|
||||
Date.parseExact(
|
||||
GlobalVariables.appointmentData.start_datetime,
|
||||
'yyyy-MM-dd HH:mm:ss'
|
||||
).toString(timeFormat)
|
||||
moment(GlobalVariables.appointmentData.start_datetime).format(timeFormat)
|
||||
);
|
||||
})
|
||||
.addClass('selected-hour');
|
||||
|
@ -275,8 +272,8 @@ window.FrontendBookApi = window.FrontendBookApi || {};
|
|||
processingUnavailabilities = true;
|
||||
|
||||
// Select first enabled date.
|
||||
var selectedDate = Date.parse(selectedDateString);
|
||||
var numberOfDays = moment(selectedDate).daysInMonth();
|
||||
var selectedDate = moment(selectedDateString).toDate();
|
||||
var numberOfDays = moment(selectedDateString).daysInMonth();
|
||||
|
||||
if (setDate && !GlobalVariables.manageMode) {
|
||||
for (var i = 1; i <= numberOfDays; i++) {
|
||||
|
|
|
@ -362,24 +362,24 @@ window.GeneralFunctions = window.GeneralFunctions || {};
|
|||
* @return {String} Returns the formatted date string.
|
||||
*/
|
||||
exports.formatDate = function (date, dateFormatSetting, addHours) {
|
||||
var timeFormat = GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm';
|
||||
var timeFormat = GlobalVariables.timeFormat === 'regular' ? 'h:mm a' : 'HH:mm';
|
||||
var hours = addHours ? ' ' + timeFormat : '';
|
||||
var result;
|
||||
var parsedDate = Date.parse(date);
|
||||
var parsedDateMoment = moment(date);
|
||||
|
||||
if (!parsedDate) {
|
||||
if (!parsedDateMoment.isValid()) {
|
||||
return date;
|
||||
}
|
||||
|
||||
switch (dateFormatSetting) {
|
||||
case 'DMY':
|
||||
result = parsedDate.toString('dd/MM/yyyy' + hours);
|
||||
result = parsedDateMoment.format('DD/MM/YYYY' + hours);
|
||||
break;
|
||||
case 'MDY':
|
||||
result = parsedDate.toString('MM/dd/yyyy' + hours);
|
||||
result = parsedDateMoment.format('MM/DD/YYYY' + hours);
|
||||
break;
|
||||
case 'YMD':
|
||||
result = parsedDate.toString('yyyy/MM/dd' + hours);
|
||||
result = parsedDateMoment.format('YYYY/MM/DD' + hours);
|
||||
break;
|
||||
default:
|
||||
throw new Error('Invalid date format setting provided!', dateFormatSetting);
|
||||
|
@ -598,35 +598,4 @@ window.GeneralFunctions = window.GeneralFunctions || {};
|
|||
]
|
||||
}).html();
|
||||
};
|
||||
|
||||
/**
|
||||
* Format a given date according to ISO 8601 date format string yyyy-mm-dd
|
||||
*
|
||||
* @param {String} date The date to be formatted.
|
||||
* @param {String} dateFormatSetting The setting provided by PHP must be one of the "DMY", "MDY" or "YMD".
|
||||
*
|
||||
* @return {String} Returns the formatted date string.
|
||||
*/
|
||||
exports.ISO8601DateString = function (date, dateFormatSetting) {
|
||||
var dayArray;
|
||||
|
||||
// It's necessary to manually parse the date because Date.parse() not support some formats tha instead are
|
||||
// supported by Easy!Appointments. The unsupported format is dd/MM/yyyy.
|
||||
switch (dateFormatSetting) {
|
||||
case 'DMY':
|
||||
dayArray = date.split('/');
|
||||
date = dayArray[2] + '-' + dayArray[1] + '-' + dayArray[0];
|
||||
break;
|
||||
case 'MDY':
|
||||
dayArray = date.split('/');
|
||||
date = dayArray[2] + '-' + dayArray[0] + '-' + dayArray[1];
|
||||
break;
|
||||
case 'YMD':
|
||||
date = date.replace('/', '-');
|
||||
break;
|
||||
default:
|
||||
throw new Error('Invalid date format setting provided:' + dateFormatSetting);
|
||||
}
|
||||
return date;
|
||||
};
|
||||
})(window.GeneralFunctions);
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
$('.breaks tbody').empty();
|
||||
|
||||
// Build working plan day list starting with the first weekday as set in the General settings
|
||||
var timeFormat = GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm';
|
||||
var timeFormat = GlobalVariables.timeFormat === 'regular' ? 'h:mm a' : 'HH:mm';
|
||||
|
||||
$.each(
|
||||
workingPlanSorted,
|
||||
|
@ -102,8 +102,8 @@
|
|||
|
||||
if (workingDay) {
|
||||
$('#' + index).prop('checked', true);
|
||||
$('#' + index + '-start').val(Date.parse(workingDay.start).toString(timeFormat).toLowerCase());
|
||||
$('#' + index + '-end').val(Date.parse(workingDay.end).toString(timeFormat).toLowerCase());
|
||||
$('#' + index + '-start').val(moment(workingDay.start, 'HH:mm').format(timeFormat).toLowerCase());
|
||||
$('#' + index + '-end').val(moment(workingDay.end, 'HH:mm').format(timeFormat).toLowerCase());
|
||||
|
||||
// Sort day's breaks according to the starting hour
|
||||
workingDay.breaks.sort(function (break1, break2) {
|
||||
|
@ -120,11 +120,11 @@
|
|||
}),
|
||||
$('<td/>', {
|
||||
'class': 'break-start editable',
|
||||
'text': Date.parse(workingDayBreak.start).toString(timeFormat).toLowerCase()
|
||||
'text': moment(workingDayBreak.start, 'HH:mm').format(timeFormat).toLowerCase()
|
||||
}),
|
||||
$('<td/>', {
|
||||
'class': 'break-end editable',
|
||||
'text': Date.parse(workingDayBreak.end).toString(timeFormat).toLowerCase()
|
||||
'text': moment(workingDayBreak.end, 'HH:mm').format(timeFormat).toLowerCase()
|
||||
}),
|
||||
$('<td/>', {
|
||||
'html': [
|
||||
|
@ -292,7 +292,7 @@
|
|||
* @param {Object} workingPlanException Contains exception information.
|
||||
*/
|
||||
WorkingPlan.prototype.renderWorkingPlanExceptionRow = function (date, workingPlanException) {
|
||||
var timeFormat = GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm';
|
||||
var timeFormat = GlobalVariables.timeFormat === 'regular' ? 'h:mm a' : 'HH:mm';
|
||||
|
||||
return $('<tr/>', {
|
||||
'data': {
|
||||
|
@ -306,11 +306,11 @@
|
|||
}),
|
||||
$('<td/>', {
|
||||
'class': 'working-plan-exception--start',
|
||||
'text': Date.parse(workingPlanException.start).toString(timeFormat).toLowerCase()
|
||||
'text': moment(workingPlanException.start, 'HH:mm').format(timeFormat).toLowerCase()
|
||||
}),
|
||||
$('<td/>', {
|
||||
'class': 'working-plan-exception--end',
|
||||
'text': Date.parse(workingPlanException.end).toString(timeFormat).toLowerCase()
|
||||
'text': moment(workingPlanException.end, 'HH:mm').format(timeFormat).toLowerCase()
|
||||
}),
|
||||
$('<td/>', {
|
||||
'html': [
|
||||
|
@ -378,7 +378,7 @@
|
|||
$('.add-break').on(
|
||||
'click',
|
||||
function () {
|
||||
var timeFormat = GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm';
|
||||
var timeFormat = GlobalVariables.timeFormat === 'regular' ? 'h:mm a' : 'HH:mm';
|
||||
|
||||
var $newBreak = $('<tr/>', {
|
||||
'html': [
|
||||
|
@ -388,11 +388,11 @@
|
|||
}),
|
||||
$('<td/>', {
|
||||
'class': 'break-start editable',
|
||||
'text': Date.parse('12:00:00').toString(timeFormat).toLowerCase()
|
||||
'text': moment('12:00', 'HH:mm').format(timeFormat).toLowerCase()
|
||||
}),
|
||||
$('<td/>', {
|
||||
'class': 'break-end editable',
|
||||
'text': Date.parse('14:00:00').toString(timeFormat).toLowerCase()
|
||||
'text': moment('14:00', 'HH:mm').format(timeFormat).toLowerCase()
|
||||
}),
|
||||
$('<td/>', {
|
||||
'html': [
|
||||
|
@ -523,7 +523,7 @@
|
|||
*
|
||||
* Save the editable values and restore the table to its initial state.
|
||||
*
|
||||
* @param {jQuery.Event} e
|
||||
* @param {jQuery.Event} event
|
||||
*/
|
||||
$(document).on(
|
||||
'click',
|
||||
|
@ -531,15 +531,18 @@
|
|||
function (event) {
|
||||
// Break's start time must always be prior to break's end.
|
||||
var element = event.target;
|
||||
var $modifiedRow = $(element).closest('tr');
|
||||
var start = Date.parse($modifiedRow.find('.break-start input').val());
|
||||
var end = Date.parse($modifiedRow.find('.break-end input').val());
|
||||
|
||||
if (start > end) {
|
||||
var $modifiedRow = $(element).closest('tr');
|
||||
|
||||
var startMoment = moment($modifiedRow.find('.break-start input').val(), 'HH:mm');
|
||||
|
||||
var endMoment = moment($modifiedRow.find('.break-end input').val(), 'HH:mm');
|
||||
|
||||
if (startMoment.isAfter(endMoment)) {
|
||||
$modifiedRow.find('.break-end input').val(
|
||||
start
|
||||
.addHours(1)
|
||||
.toString(GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm')
|
||||
startMoment
|
||||
.add(1, 'hour')
|
||||
.format(GlobalVariables.timeFormat === 'regular' ? 'h:mm a' : 'HH:mm')
|
||||
.toLowerCase()
|
||||
);
|
||||
}
|
||||
|
@ -631,8 +634,8 @@
|
|||
var id = $(checkbox).attr('id');
|
||||
if ($(checkbox).prop('checked') === true) {
|
||||
workingPlan[id] = {
|
||||
start: Date.parse($('#' + id + '-start').val()).toString('HH:mm'),
|
||||
end: Date.parse($('#' + id + '-end').val()).toString('HH:mm'),
|
||||
start: moment($('#' + id + '-start').val(), 'HH:mm').format('HH:mm'),
|
||||
end: moment($('#' + id + '-end').val(), 'HH:mm').format('HH:mm'),
|
||||
breaks: []
|
||||
};
|
||||
|
||||
|
@ -645,8 +648,14 @@
|
|||
var end = $(tr).find('.break-end').text();
|
||||
|
||||
workingPlan[id].breaks.push({
|
||||
start: Date.parse(start).toString('HH:mm'),
|
||||
end: Date.parse(end).toString('HH:mm')
|
||||
start: moment(
|
||||
start,
|
||||
GlobalVariables.timeFormat === 'regular' ? 'h:mm a' : 'HH:mm'
|
||||
).format('HH:mm'),
|
||||
end: moment(
|
||||
end,
|
||||
GlobalVariables.timeFormat === 'regular' ? 'h:mm a' : 'HH:mm'
|
||||
).format('HH:mm')
|
||||
});
|
||||
}
|
||||
}.bind(this)
|
||||
|
@ -704,18 +713,19 @@
|
|||
|
||||
onSelect: function (datetime, inst) {
|
||||
// Start time must be earlier than end time.
|
||||
var start = Date.parse($(this).parent().parent().find('.work-start').val()),
|
||||
end = Date.parse($(this).parent().parent().find('.work-end').val());
|
||||
var startMoment = moment($(this).parent().parent().find('.work-start').val(), 'HH:mm');
|
||||
|
||||
if (start > end) {
|
||||
var endMoment = moment($(this).parent().parent().find('.work-end').val(), 'HH:mm');
|
||||
|
||||
if (startMoment > endMoment) {
|
||||
$(this)
|
||||
.parent()
|
||||
.parent()
|
||||
.find('.work-end')
|
||||
.val(
|
||||
start
|
||||
.addHours(1)
|
||||
.toString(GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm')
|
||||
startMoment
|
||||
.add(1, 'hour')
|
||||
.format(GlobalVariables.timeFormat === 'regular' ? 'h:mm a' : 'HH:mm')
|
||||
.toLowerCase()
|
||||
);
|
||||
}
|
||||
|
|
|
@ -60,8 +60,8 @@ $(function () {
|
|||
var end = $tr.find('.working-plan-exceptions-break-end').text();
|
||||
|
||||
breaks.push({
|
||||
start: Date.parse(start).toString('HH:mm'),
|
||||
end: Date.parse(end).toString('HH:mm')
|
||||
start: moment(start, GlobalVariables.timeFormat === 'regular' ? 'h:mm a' : 'HH:mm').format('HH:mm'),
|
||||
end: moment(end, GlobalVariables.timeFormat === 'regular' ? 'h:mm a' : 'HH:mm').format('HH:mm')
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -164,17 +164,17 @@ $(function () {
|
|||
}
|
||||
|
||||
function renderBreakRow(breakPeriod) {
|
||||
var timeFormat = GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm';
|
||||
var timeFormat = GlobalVariables.timeFormat === 'regular' ? 'h:mm a' : 'HH:mm';
|
||||
|
||||
return $('<tr/>', {
|
||||
'html': [
|
||||
$('<td/>', {
|
||||
'class': 'working-plan-exceptions-break-start editable',
|
||||
'text': Date.parse(breakPeriod.start).toString(timeFormat)
|
||||
'text': moment(breakPeriod.start, 'HH:mm').toString(timeFormat)
|
||||
}),
|
||||
$('<td/>', {
|
||||
'class': 'working-plan-exceptions-break-end editable',
|
||||
'text': Date.parse(breakPeriod.end).toString(timeFormat)
|
||||
'text': moment(breakPeriod.end, 'HH:mm').toString(timeFormat)
|
||||
}),
|
||||
$('<td/>', {
|
||||
'html': [
|
||||
|
@ -270,12 +270,18 @@ $(function () {
|
|||
function onSaveBreakClick() {
|
||||
// Break's start time must always be prior to break's end.
|
||||
var $tr = $(this).closest('tr');
|
||||
var start = Date.parse($tr.find('.working-plan-exceptions-break-start input').val());
|
||||
var end = Date.parse($tr.find('.working-plan-exceptions-break-end input').val());
|
||||
var start = moment(
|
||||
$tr.find('.working-plan-exceptions-break-start input').val(),
|
||||
GlobalVariables.timeFormat === 'regular' ? 'h:mm a' : 'HH:mm'
|
||||
);
|
||||
var end = moment(
|
||||
$tr.find('.working-plan-exceptions-break-end input').val(),
|
||||
GlobalVariables.timeFormat === 'regular' ? 'h:mm a' : 'HH:mm'
|
||||
);
|
||||
|
||||
if (start > end) {
|
||||
$tr.find('.working-plan-exceptions-break-end input').val(
|
||||
start.addHours(1).toString(GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm')
|
||||
start.add(1, 'hour').format(GlobalVariables.timeFormat === 'regular' ? 'h:mm a' : 'HH:mm')
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -327,7 +333,7 @@ $(function () {
|
|||
dateFormat: dateFormat,
|
||||
firstDay: GeneralFunctions.getWeekDayId(GlobalVariables.firstWeekday),
|
||||
minDate: 0,
|
||||
defaultDate: Date.today(),
|
||||
defaultDate: moment().toDate(),
|
||||
dayNames: [
|
||||
EALang.sunday,
|
||||
EALang.monday,
|
||||
|
@ -378,7 +384,7 @@ $(function () {
|
|||
|
||||
function initializeTimepicker($target) {
|
||||
$target.timepicker({
|
||||
timeFormat: GlobalVariables.timeFormat === 'regular' ? 'h:mm TT' : 'HH:mm',
|
||||
timeFormat: GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm',
|
||||
currentText: EALang.now,
|
||||
closeText: EALang.close,
|
||||
timeOnlyTitle: EALang.select_time,
|
||||
|
|
Loading…
Reference in a new issue