easyappointments/assets/js/http/calendar_http_client.min.js

1 line
2.7 KiB
JavaScript
Executable File

"use strict";App.Http.Calendar=function(){return{saveAppointment:function(appointment,customer,successCallback,errorCallback){var url=App.Utils.Url.siteUrl("calendar/save_appointment"),data={csrf_token:vars("csrf_token"),appointment_data:appointment};return customer&&(data.customer_data=customer),$.post(url,data).done(function(response){successCallback&&successCallback(response)}).fail(function(){errorCallback&&errorCallback()})},deleteAppointment:function(appointmentId,cancellationReason){var url=App.Utils.Url.siteUrl("calendar/delete_appointment"),data={csrf_token:vars("csrf_token"),appointment_id:appointmentId,cancellation_reason:cancellationReason};return $.post(url,data)},saveUnavailability:function(unavailability,successCallback,errorCallback){var url=App.Utils.Url.siteUrl("calendar/save_unavailability"),data={csrf_token:vars("csrf_token"),unavailability:unavailability};return $.post(url,data).done(function(response){successCallback&&successCallback(response)}).fail(function(){errorCallback&&errorCallback()})},deleteUnavailability:function(unavailabilityId){var url=App.Utils.Url.siteUrl("calendar/delete_unavailability"),data={csrf_token:vars("csrf_token"),unavailability_id:unavailabilityId};return $.post(url,data)},saveWorkingPlanException:function(date,workingPlanException,providerId,successCallback,errorCallback,originalDate){var url=App.Utils.Url.siteUrl("calendar/save_working_plan_exception"),data={csrf_token:vars("csrf_token"),date:date,working_plan_exception:workingPlanException,provider_id:providerId,original_date:originalDate};return $.post(url,data).done(function(response){successCallback&&successCallback(response)}).fail(function(){errorCallback&&errorCallback()})},deleteWorkingPlanException:function(date,providerId,successCallback,errorCallback){var url=App.Utils.Url.siteUrl("calendar/delete_working_plan_exception"),data={csrf_token:vars("csrf_token"),date:date,provider_id:providerId};return $.post(url,data).done(function(response){successCallback&&successCallback(response)}).fail(function(){errorCallback&&errorCallback()})},getCalendarAppointments:function(recordId,startDate,endDate,filterType){var url=App.Utils.Url.siteUrl("calendar/get_calendar_appointments"),data={csrf_token:vars("csrf_token"),record_id:recordId,start_date:moment(startDate).format("YYYY-MM-DD"),end_date:moment(endDate).format("YYYY-MM-DD"),filter_type:filterType};return $.post(url,data)},getCalendarAppointmentsForTableView:function(startDate,endDate){var url=App.Utils.Url.siteUrl("calendar/get_calendar_appointments_for_table_view"),data={csrf_token:vars("csrf_token"),start_date:moment(startDate).format("YYYY-MM-DD"),end_date:moment(endDate).format("YYYY-MM-DD")};return $.post(url,data)}}}();