mirror of
https://github.com/alextselegidis/easyappointments.git
synced 2024-12-26 16:42:27 +03:00
Date handling fixes for JS files
This commit is contained in:
parent
f2bb4519a5
commit
0c5c1347aa
5 changed files with 41 additions and 34 deletions
|
@ -105,7 +105,7 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {};
|
|||
|
||||
// Add the provider breaks to the column.
|
||||
var workingPlan = JSON.parse(provider.settings.working_plan);
|
||||
var day = date.toString('dddd').toLowerCase();
|
||||
var day = moment(date).format('dddd').toLowerCase();
|
||||
if (workingPlan[day]) {
|
||||
var breaks = workingPlan[day].breaks;
|
||||
createBreaks($providerColumn, breaks);
|
||||
|
@ -505,8 +505,8 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {};
|
|||
}).appendTo('#calendar');
|
||||
|
||||
$calendarView.data({
|
||||
startDate: startDate.toString('yyyy-MM-dd'),
|
||||
endDate: endDate.toString('yyyy-MM-dd')
|
||||
startDate: moment(startDate).format('YYYY-MM-DD'),
|
||||
endDate: moment(endDate).format('YYYY-MM-DD')
|
||||
});
|
||||
|
||||
var $wrapper = $('<div/>').appendTo($calendarView);
|
||||
|
@ -846,7 +846,7 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {};
|
|||
var view = $calendar.fullCalendar('getView');
|
||||
var start = view.start.clone();
|
||||
var end = view.end.clone();
|
||||
var selDayName = start.toDate().toString('dddd').toLowerCase();
|
||||
var selDayName = start.format('dddd').toLowerCase();
|
||||
var selDayDate = start.format('YYYY-MM-DD');
|
||||
var calendarEventSource = [];
|
||||
|
||||
|
@ -892,7 +892,7 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {};
|
|||
return;
|
||||
}
|
||||
|
||||
var workDateStart = moment(start.toDate().toString('yyyy-MM-dd') + ' ' + workingPlan[selDayName].start);
|
||||
var workDateStart = moment(start.format('YYYY-MM-DD') + ' ' + workingPlan[selDayName].start);
|
||||
|
||||
if (start < workDateStart) {
|
||||
unavailablePeriod = {
|
||||
|
@ -909,7 +909,7 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {};
|
|||
}
|
||||
|
||||
// Add unavailable period after work ends.
|
||||
var workDateEnd = moment(start.toDate().toString('yyyy-MM-dd') + ' ' + workingPlan[selDayName].end);
|
||||
var workDateEnd = moment(start.format('YYYY-MM-DD') + ' ' + workingPlan[selDayName].end);
|
||||
|
||||
if (end > workDateEnd) {
|
||||
var unavailablePeriod = {
|
||||
|
@ -930,8 +930,8 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {};
|
|||
var breakEnd;
|
||||
|
||||
workingPlan[selDayName].breaks.forEach(function (currentBreak) {
|
||||
breakStart = moment(start.toDate().toString('yyyy-MM-dd') + ' ' + currentBreak.start);
|
||||
breakEnd = moment(start.toDate().toString('yyyy-MM-dd') + ' ' + currentBreak.end);
|
||||
breakStart = moment(start.format('YYYY-MM-DD') + ' ' + currentBreak.start);
|
||||
breakEnd = moment(start.format('YYYY-MM-DD') + ' ' + currentBreak.end);
|
||||
|
||||
var unavailablePeriod = {
|
||||
title: EALang.break,
|
||||
|
@ -1072,7 +1072,12 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {};
|
|||
});
|
||||
|
||||
$event.html(
|
||||
EALang.break + ' <span class="hour">' + eventDate.toString('HH:mm') + '</span> (' + eventDuration + "')"
|
||||
EALang.break +
|
||||
' <span class="hour">' +
|
||||
moment(eventDate).format('HH:mm') +
|
||||
'</span> (' +
|
||||
eventDuration +
|
||||
"')"
|
||||
);
|
||||
|
||||
$event.data(entry);
|
||||
|
@ -1087,7 +1092,7 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {};
|
|||
|
||||
if (eventDate < cellDate) {
|
||||
// Remove the hour from the event if it is the same as the row.
|
||||
if (eventDate.toString('HH:mm') === $(tr).prev().find('td').eq(0).text()) {
|
||||
if (moment(eventDate).format('HH:mm') === $(tr).prev().find('td').eq(0).text()) {
|
||||
$event.find('.hour').remove();
|
||||
}
|
||||
|
||||
|
@ -1784,8 +1789,8 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {};
|
|||
|
||||
var data = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
startDate: startDate.toString('yyyy-MM-dd'),
|
||||
endDate: endDate.toString('yyyy-MM-dd')
|
||||
startDate: moment(startDate).format('YYYY-MM-DD'),
|
||||
endDate: moment(endDate).format('YYYY-MM-DD')
|
||||
};
|
||||
|
||||
return $.ajax({
|
||||
|
|
|
@ -66,8 +66,8 @@ window.BackendCalendarWorkingPlanExceptionsModal = window.BackendCalendarWorking
|
|||
}
|
||||
|
||||
var workingPlanException = {
|
||||
start: start.toString('HH:mm'),
|
||||
end: end.toString('HH:mm'),
|
||||
start: moment(start).format('HH:mm'),
|
||||
end: moment(end).format('HH:mm'),
|
||||
breaks: []
|
||||
};
|
||||
|
||||
|
@ -88,12 +88,12 @@ window.BackendCalendarWorkingPlanExceptionsModal = window.BackendCalendarWorking
|
|||
throw new Error('Provider could not be found: ' + providerId);
|
||||
}
|
||||
|
||||
var selectedDate = date.toString('yyyy-MM-dd');
|
||||
var selectedDate = moment(date).format('yyyy-MM-dd');
|
||||
var workingPlanExceptions = JSON.parse(provider.settings.working_plan_exceptions);
|
||||
|
||||
workingPlanExceptions[selectedDate] = {
|
||||
start: start.toString('HH:mm'),
|
||||
end: end.toString('HH:mm'),
|
||||
start: moment(start).format('HH:mm'),
|
||||
end: moment(end).format('HH:mm'),
|
||||
breaks: []
|
||||
};
|
||||
|
||||
|
|
|
@ -145,16 +145,17 @@ window.FrontendBook = window.FrontendBook || {};
|
|||
closeText: EALang.close,
|
||||
|
||||
onSelect: function (dateText, instance) {
|
||||
FrontendBookApi.getAvailableHours($(this).datepicker('getDate').toString('yyyy-MM-dd'));
|
||||
FrontendBookApi.getAvailableHours(moment($(this).datepicker('getDate')).format('YYYY-MM-DD'));
|
||||
FrontendBook.updateConfirmFrame();
|
||||
},
|
||||
|
||||
onChangeMonthYear: function (year, month, instance) {
|
||||
var currentDate = new Date(year, month - 1, 1);
|
||||
|
||||
FrontendBookApi.getUnavailableDates(
|
||||
$('#select-provider').val(),
|
||||
$('#select-service').val(),
|
||||
currentDate.toString('yyyy-MM-dd')
|
||||
moment(currentDate).format('YYYY-MM-DD')
|
||||
);
|
||||
}
|
||||
});
|
||||
|
@ -220,7 +221,7 @@ window.FrontendBook = window.FrontendBook || {};
|
|||
return;
|
||||
}
|
||||
|
||||
FrontendBookApi.getAvailableHours(date.toString('yyyy-MM-dd'));
|
||||
FrontendBookApi.getAvailableHours(moment(date).format('YYYY-MM-DD'));
|
||||
|
||||
FrontendBook.updateConfirmFrame();
|
||||
});
|
||||
|
@ -234,7 +235,7 @@ window.FrontendBook = window.FrontendBook || {};
|
|||
FrontendBookApi.getUnavailableDates(
|
||||
$(this).val(),
|
||||
$('#select-service').val(),
|
||||
$('#select-date').datepicker('getDate').toString('yyyy-MM-dd')
|
||||
moment($('#select-date').datepicker('getDate')).format('YYYY-MM-DD')
|
||||
);
|
||||
FrontendBook.updateConfirmFrame();
|
||||
});
|
||||
|
@ -274,7 +275,7 @@ window.FrontendBook = window.FrontendBook || {};
|
|||
FrontendBookApi.getUnavailableDates(
|
||||
$('#select-provider').val(),
|
||||
$(this).val(),
|
||||
$('#select-date').datepicker('getDate').toString('yyyy-MM-dd')
|
||||
moment($('#select-date').datepicker('getDate')).format('YYYY-MM-DD')
|
||||
);
|
||||
FrontendBook.updateConfirmFrame();
|
||||
updateServiceDescription(serviceId);
|
||||
|
@ -671,7 +672,7 @@ window.FrontendBook = window.FrontendBook || {};
|
|||
start_datetime:
|
||||
moment($('#select-date').datepicker('getDate')).format('YYYY-MM-DD') +
|
||||
' ' +
|
||||
moment($('.selected-hour').data('value') || '').format('HH:mm') +
|
||||
moment($('.selected-hour').data('value'), 'HH:mm').format('HH:mm') +
|
||||
':00',
|
||||
end_datetime: calculateEndDatetime(),
|
||||
notes: $('#notes').val(),
|
||||
|
|
|
@ -272,15 +272,16 @@ window.FrontendBookApi = window.FrontendBookApi || {};
|
|||
processingUnavailabilities = true;
|
||||
|
||||
// Select first enabled date.
|
||||
var selectedDate = moment(selectedDateString).toDate();
|
||||
var numberOfDays = moment(selectedDateString).daysInMonth();
|
||||
var selectedDateMoment = moment(selectedDateString);
|
||||
var selectedDate = selectedDateMoment.toDate();
|
||||
var numberOfDays = selectedDateMoment.daysInMonth();
|
||||
|
||||
if (setDate && !GlobalVariables.manageMode) {
|
||||
for (var i = 1; i <= numberOfDays; i++) {
|
||||
var currentDate = new Date(selectedDate.getFullYear(), selectedDate.getMonth(), i);
|
||||
if (unavailableDates.indexOf(currentDate.toString('yyyy-MM-dd')) === -1) {
|
||||
if (unavailableDates.indexOf(moment(currentDate).format('YYYY-MM-DD')) === -1) {
|
||||
$('#select-date').datepicker('setDate', currentDate);
|
||||
FrontendBookApi.getAvailableHours(currentDate.toString('yyyy-MM-dd'));
|
||||
FrontendBookApi.getAvailableHours(moment(currentDate).format('YYYY-MM-DD'));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -293,8 +294,8 @@ window.FrontendBookApi = window.FrontendBookApi || {};
|
|||
|
||||
// Grey out unavailable dates.
|
||||
$('#select-date .ui-datepicker-calendar td:not(.ui-datepicker-other-month)').each(function (index, td) {
|
||||
selectedDate.set({day: index + 1});
|
||||
if (unavailableDates.indexOf(selectedDate.toString('yyyy-MM-dd')) !== -1) {
|
||||
selectedDateMoment.set({day: index + 1});
|
||||
if (unavailableDates.indexOf(selectedDateMoment.format('YYYY-MM-DD')) !== -1) {
|
||||
$(td).addClass('ui-datepicker-unselectable ui-state-disabled');
|
||||
}
|
||||
});
|
||||
|
|
|
@ -83,11 +83,11 @@ $(function () {
|
|||
return;
|
||||
}
|
||||
|
||||
var date = $date.datepicker('getDate').toString('yyyy-MM-dd');
|
||||
var date = moment($date.datepicker('getDate')).format('YYYY-MM-DD');
|
||||
|
||||
var workingPlanException = {
|
||||
start: $start.datetimepicker('getDate').toString('HH:mm'),
|
||||
end: $end.datetimepicker('getDate').toString('HH:mm'),
|
||||
start: moment($start.datetimepicker('getDate')).format('HH:mm'),
|
||||
end: moment($end.datetimepicker('getDate')).format('HH:mm'),
|
||||
breaks: getBreaks()
|
||||
};
|
||||
|
||||
|
@ -170,11 +170,11 @@ $(function () {
|
|||
'html': [
|
||||
$('<td/>', {
|
||||
'class': 'working-plan-exceptions-break-start editable',
|
||||
'text': moment(breakPeriod.start, 'HH:mm').toString(timeFormat)
|
||||
'text': moment(breakPeriod.start, 'HH:mm').format(timeFormat)
|
||||
}),
|
||||
$('<td/>', {
|
||||
'class': 'working-plan-exceptions-break-end editable',
|
||||
'text': moment(breakPeriod.end, 'HH:mm').toString(timeFormat)
|
||||
'text': moment(breakPeriod.end, 'HH:mm').format(timeFormat)
|
||||
}),
|
||||
$('<td/>', {
|
||||
'html': [
|
||||
|
|
Loading…
Reference in a new issue