diff --git a/assets/js/backend_calendar_table_view.js b/assets/js/backend_calendar_table_view.js index 6bd0204e..0f89f1ac 100755 --- a/assets/js/backend_calendar_table_view.js +++ b/assets/js/backend_calendar_table_view.js @@ -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 = $('
').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 + ' ' + eventDate.toString('HH:mm') + ' (' + eventDuration + "')" + EALang.break + + ' ' + + moment(eventDate).format('HH:mm') + + ' (' + + 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({ diff --git a/assets/js/backend_calendar_working_plan_exceptions_modal.js b/assets/js/backend_calendar_working_plan_exceptions_modal.js index fccebf2c..722df779 100644 --- a/assets/js/backend_calendar_working_plan_exceptions_modal.js +++ b/assets/js/backend_calendar_working_plan_exceptions_modal.js @@ -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: [] }; diff --git a/assets/js/frontend_book.js b/assets/js/frontend_book.js index 7ff09a50..e0a18b9f 100644 --- a/assets/js/frontend_book.js +++ b/assets/js/frontend_book.js @@ -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(), diff --git a/assets/js/frontend_book_api.js b/assets/js/frontend_book_api.js index 4fbd7aeb..2c1cf044 100755 --- a/assets/js/frontend_book_api.js +++ b/assets/js/frontend_book_api.js @@ -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'); } }); diff --git a/assets/js/working_plan_exceptions_modal.js b/assets/js/working_plan_exceptions_modal.js index e40c34dc..8c55f083 100644 --- a/assets/js/working_plan_exceptions_modal.js +++ b/assets/js/working_plan_exceptions_modal.js @@ -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': [ $('