@@ -1896,6 +1896,63 @@ App.Utils.CalendarTableView = (function () {
18961896
18971897 // Hide Google Calendar Sync buttons because they can not be used within this view.
18981898 $ ( '#enable-sync, #google-sync' ) . hide ( ) ;
1899+
1900+ // Load the modified appointment in the appointments modal
1901+ if ( vars ( 'edit_appointment' ) ) {
1902+ const appointment = vars ( 'edit_appointment' ) ;
1903+
1904+ const startDateTimeObject = moment ( appointment . start_datetime )
1905+ . set ( { hour : 0 , minutes : 0 , seconds : 0 } )
1906+ . toDate ( ) ;
1907+ const endDateTimeObject = moment ( appointment . end_datetime )
1908+ . set ( { hour : 23 , minutes : 59 , seconds : 59 } )
1909+ . toDate ( ) ;
1910+
1911+ App . Utils . UI . setDateTimePickerValue ( $selectDate , startDateTimeObject ) ;
1912+ createView ( startDateTimeObject , endDateTimeObject ) ;
1913+
1914+ App . Components . AppointmentsModal . resetModal ( ) ;
1915+
1916+ $appointmentsModal . find ( '.modal-header h3' ) . text ( lang ( 'edit_appointment_title' ) ) ;
1917+ $appointmentsModal . find ( '#appointment-id' ) . val ( appointment . id ) ;
1918+ $appointmentsModal . find ( '#select-service' ) . val ( appointment . id_services ) . trigger ( 'change' ) ;
1919+ $appointmentsModal . find ( '#select-provider' ) . val ( appointment . id_users_provider ) ;
1920+
1921+ // Set the start and end datetime of the appointment.
1922+ const startDatetimeMoment = moment ( appointment . start_datetime ) ;
1923+ App . Utils . UI . setDateTimePickerValue (
1924+ $appointmentsModal . find ( '#start-datetime' ) ,
1925+ startDatetimeMoment . toDate ( ) ,
1926+ ) ;
1927+
1928+ const endDatetimeMoment = moment ( appointment . end_datetime ) ;
1929+ App . Utils . UI . setDateTimePickerValue ( $appointmentsModal . find ( '#end-datetime' ) , endDatetimeMoment . toDate ( ) ) ;
1930+
1931+ const customer = appointment . customer ;
1932+ $appointmentsModal . find ( '#customer-id' ) . val ( appointment . id_users_customer ) ;
1933+ $appointmentsModal . find ( '#first-name' ) . val ( customer . first_name ) ;
1934+ $appointmentsModal . find ( '#last-name' ) . val ( customer . last_name ) ;
1935+ $appointmentsModal . find ( '#email' ) . val ( customer . email ) ;
1936+ $appointmentsModal . find ( '#phone-number' ) . val ( customer . phone_number ) ;
1937+ $appointmentsModal . find ( '#address' ) . val ( customer . address ) ;
1938+ $appointmentsModal . find ( '#city' ) . val ( customer . city ) ;
1939+ $appointmentsModal . find ( '#zip-code' ) . val ( customer . zip_code ) ;
1940+ $appointmentsModal . find ( '#language' ) . val ( customer . language ) ;
1941+ $appointmentsModal . find ( '#timezone' ) . val ( customer . timezone ) ;
1942+ $appointmentsModal . find ( '#appointment-location' ) . val ( appointment . location ) ;
1943+ $appointmentsModal . find ( '#appointment-status' ) . val ( appointment . status ) ;
1944+ $appointmentsModal . find ( '#appointment-notes' ) . val ( appointment . notes ) ;
1945+ $appointmentsModal . find ( '#customer-notes' ) . val ( customer . notes ) ;
1946+ $appointmentsModal . find ( '#custom-field-1' ) . val ( customer . custom_field_1 ) ;
1947+ $appointmentsModal . find ( '#custom-field-2' ) . val ( customer . custom_field_2 ) ;
1948+ $appointmentsModal . find ( '#custom-field-3' ) . val ( customer . custom_field_3 ) ;
1949+ $appointmentsModal . find ( '#custom-field-4' ) . val ( customer . custom_field_4 ) ;
1950+ $appointmentsModal . find ( '#custom-field-5' ) . val ( customer . custom_field_5 ) ;
1951+
1952+ App . Components . ColorSelection . setColor ( $appointmentsModal . find ( '#appointment-color' ) , appointment . color ) ;
1953+
1954+ $appointmentsModal . modal ( 'show' ) ;
1955+ }
18991956 }
19001957
19011958 return {
0 commit comments