From 6050bf75c321bb0e4a9f8e0ff51b8e309ff051ea Mon Sep 17 00:00:00 2001 From: "alextselegidis@gmail.com" Date: Fri, 28 Jun 2013 21:54:12 +0000 Subject: [PATCH] Finish insert appointment from backend. --- src/application/controllers/backend.php | 58 ++-- src/application/views/appointments/book.php | 2 +- src/application/views/backend/calendar.php | 16 +- src/application/views/backend/header.php | 3 +- src/assets/css/backend.css | 2 + .../jquery/images/ui-icons_ffffff_256x240.png | Bin 0 -> 6299 bytes src/assets/js/backend_calendar.js | 259 +++++++++++++----- src/assets/js/frontend_book.js | 43 ++- src/assets/js/general_functions.js | 12 + 9 files changed, 281 insertions(+), 114 deletions(-) create mode 100644 src/assets/css/libs/jquery/images/ui-icons_ffffff_256x240.png diff --git a/src/application/controllers/backend.php b/src/application/controllers/backend.php index 961a8f59..84e2a192 100644 --- a/src/application/controllers/backend.php +++ b/src/application/controllers/backend.php @@ -17,10 +17,11 @@ class Backend extends CI_Controller { $this->load->model('Settings_Model'); // Display the main backend page. - $view_data['base_url'] = $this->config->item('base_url'); + $view_data['base_url'] = $this->config->item('base_url'); + $view_data['book_advance_timeout'] = $this->Settings_Model->get_setting('book_advance_timeout'); $view_data['company_name'] = $this->Settings_Model->get_setting('company_name'); $view_data['available_providers'] = $this->Providers_Model->get_available_providers(); - $view_data['available_services'] = $this->Services_Model->get_available_services(); + $view_data['available_services'] = $this->Services_Model->get_available_services(); $this->load->view('backend/header', $view_data); $this->load->view('backend/calendar', $view_data); @@ -96,7 +97,7 @@ class Backend extends CI_Controller { * @param array $_POST['customer_data'] (OPTIONAL) Array with the customer * data. */ - public function ajax_save_appointment_changes() { + public function ajax_save_appointment() { try { $this->load->model('Appointments_Model'); $this->load->model('Providers_Model'); @@ -104,16 +105,23 @@ class Backend extends CI_Controller { $this->load->model('Customers_Model'); $this->load->model('Settings_Model'); - // :: SAVE APPOINTMENT CHANGES TO DATABASE - if (isset($_POST['appointment_data'])) { - $appointment_data = json_decode(stripcslashes($_POST['appointment_data']), true); - $this->Appointments_Model->add($appointment_data); - } - // :: SAVE CUSTOMER CHANGES TO DATABASE if (isset($_POST['customer_data'])) { $customer_data = json_decode(stripcslashes($_POST['customer_data']), true); - $this->Customers_Model->add($customer_data); + $customer_data['id'] = $this->Customers_Model->add($customer_data); + } + + // :: SAVE APPOINTMENT CHANGES TO DATABASE + if (isset($_POST['appointment_data'])) { + $appointment_data = json_decode(stripcslashes($_POST['appointment_data']), true); + + // If the appointment does not contain the customer record id, then it + // means that is is going to be inserted. Get the customer's record id. + if (!isset($appointment_data['id_users_customer'])) { + $appointment_data['id_users_customer'] = $customer_data['id']; + } + + $appointment_data['id'] = $this->Appointments_Model->add($appointment_data); } $appointment_data = $this->Appointments_Model->get_row($appointment_data['id']); @@ -128,20 +136,24 @@ class Backend extends CI_Controller { ); // :: SYNC APPOINTMENT CHANGES WITH GOOGLE CALENDAR - if ($appointment_data['id_google_calendar'] != NULL) { - $google_sync = $this->Providers_Model - ->get_setting('google_sync', $appointment_data['id_users_provider']); + $google_sync = $this->Providers_Model + ->get_setting('google_sync', $appointment_data['id_users_provider']); + + if ($google_sync == TRUE) { + $google_token = json_decode($this->Providers_Model + ->get_setting('google_token', $appointment_data['id_users_provider'])); + + $this->load->library('Google_Sync'); + + $this->google_sync->refresh_token($google_token->refresh_token); - if ($google_sync == TRUE) { - $google_token = json_decode($this->Providers_Model - ->get_setting('google_token', $appointment_data['id_users_provider'])); - - $this->load->library('Google_Sync'); - - $this->google_sync->refresh_token($google_token->refresh_token); - $this->google_sync->update_appointment($appointment_data, $provider_data, - $service_data, $customer_data, $company_settings); - } + if ($appointment_data['id_google_calendar'] == NULL) { + $this->google_sync->add_appointment($appointment_data, $provider_data, + $service_data, $customer_data, $company_settings); + } else { + $this->google_sync->update_appointment($appointment_data, $provider_data, + $service_data, $customer_data, $company_settings); + } } // :: SEND EMAIL NOTIFICATIONS TO PROVIDER AND CUSTOMER diff --git a/src/application/views/appointments/book.php b/src/application/views/appointments/book.php index 91448ab4..f9fdc0eb 100644 --- a/src/application/views/appointments/book.php +++ b/src/application/views/appointments/book.php @@ -225,7 +225,7 @@

- Fields with * are mandatory. + Fields with * are required!
diff --git a/src/application/views/backend/calendar.php b/src/application/views/backend/calendar.php index 03b51d7a..be214393 100644 --- a/src/application/views/backend/calendar.php +++ b/src/application/views/backend/calendar.php @@ -14,7 +14,8 @@ var GlobalVariables = { 'availableProviders' : , 'availableServices' : , - 'baseUrl' : + 'baseUrl' : , + 'bookAdvanceTimeout' : }; $(document).ready(function() { @@ -73,6 +74,7 @@

Edit Appointment

+
- +
- +
- +
- +
- +
- +
diff --git a/src/application/views/backend/header.php b/src/application/views/backend/header.php index af58fe26..e9183613 100644 --- a/src/application/views/backend/header.php +++ b/src/application/views/backend/header.php @@ -1,8 +1,9 @@ - Easy!Appointments Admin + Easy!Appointments Backend + diff --git a/src/assets/css/backend.css b/src/assets/css/backend.css index 57ef77b7..fb31aebb 100644 --- a/src/assets/css/backend.css +++ b/src/assets/css/backend.css @@ -35,6 +35,8 @@ root { background: rgba(255, 255, 255, 0.75);} #loading img { margin: auto; display: block; } +#modal-message { margin: 10px 0px; } + /* BACKEND CALENDAR PAGE -------------------------------------------------------------------- */ #calendar-page #calendar-toolbar { margin: 15px 10px 20px 10px; padding-bottom: 10px; diff --git a/src/assets/css/libs/jquery/images/ui-icons_ffffff_256x240.png b/src/assets/css/libs/jquery/images/ui-icons_ffffff_256x240.png new file mode 100644 index 0000000000000000000000000000000000000000..4f624bb2b193750f1a5b36c8c307168c6681a861 GIT binary patch literal 6299 zcmZ`-cRXBOw>~q<7|})-qC`T7E_%u6y(b|`hD3`#dL6w769geLq6a~ummm_IAZic< z!$cQ#m~g%C_ucRJ-ut`vk8{@9=j`>{d#%0Cv!C_E8|rINl3yhU0Dw|UQ`Hy%K$nle zE*bIVUG23e{L+9Q>u9I~7qKaW?Uya6hvq}CORM?!rQYYP2mnltTB=I-{AaeTtm1C= z_?!oRthaygsH6uRE$8x~{Nb~uJQ49`qWA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