diff --git a/src/application/controllers/appointments.php b/src/application/controllers/appointments.php index 139522f4..aee276f1 100755 --- a/src/application/controllers/appointments.php +++ b/src/application/controllers/appointments.php @@ -33,6 +33,9 @@ class Appointments extends CI_Controller { } else { $this->lang->load('translations', $this->config->item('language')); // default } + + // Common helpers + $this->load->helper('google_analytics'); } /** @@ -75,7 +78,7 @@ class Appointments extends CI_Controller { // If an appointment hash is provided then it means that the customer // is trying to edit a registered appointment record. - if ($appointment_hash !== ''){ + if ($appointment_hash !== '') { // Load the appointments data and enable the manage mode of the page. $manage_mode = TRUE; @@ -107,8 +110,6 @@ class Appointments extends CI_Controller { $customer = array(); } - $google_analytics_code = $this->settings_model->get_setting('google_analytics_code'); - // Load the book appointment view. $view = array ( 'available_services' => $available_services, @@ -118,8 +119,7 @@ class Appointments extends CI_Controller { 'date_format' => $date_format, 'appointment_data' => $appointment, 'provider_data' => $provider, - 'customer_data' => $customer, - 'google_analytics_code' => $google_analytics_code + 'customer_data' => $customer ); } catch(Exception $exc) { $view['exceptions'][] = $exc; diff --git a/src/application/controllers/errors.php b/src/application/controllers/errors.php index 2aac3bb1..8b3fc7c1 100644 --- a/src/application/controllers/errors.php +++ b/src/application/controllers/errors.php @@ -37,6 +37,7 @@ class Errors extends CI_Controller { } public function error404() { + $this->load->helper('google_analytics'); $this->load->model('settings_model'); $view['company_name'] = $this->settings_model->get_setting('company_name'); $this->load->view('general/error404', $view); diff --git a/src/application/helpers/google_analytics_helper.php b/src/application/helpers/google_analytics_helper.php new file mode 100644 index 00000000..fc4a046d --- /dev/null +++ b/src/application/helpers/google_analytics_helper.php @@ -0,0 +1,43 @@ + + * @copyright Copyright (c) 2013 - 2016, Alex Tselegidis + * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 + * @link http://easyappointments.org + * @since v1.1.0 + * ---------------------------------------------------------------------------- */ + +/** + * Print Google Analytics script. + * + * This helper function should be used in view files in order to output the Google Analytics + * script. It will check whether the code is set in the database and print it, otherwise nothing + * will be outputted. This eliminates the need for extra checking before outputting. + */ +function google_analytics_script() { + $ci =& get_instance(); + + $ci->load->model('settings_model'); + + $google_analytics_code = $ci->settings_model->get_setting('google_analytics_code'); + + if ($google_analytics_code !== '') { + echo ' + + '; + } +} + +/* End of file google_analytics.php */ +/* Location: ./application/helpers/google_analytics.php */ diff --git a/src/application/views/appointments/book.php b/src/application/views/appointments/book.php index 6862f80f..a694be30 100644 --- a/src/application/views/appointments/book.php +++ b/src/application/views/appointments/book.php @@ -11,6 +11,7 @@ // ------------------------------------------------------------ // INCLUDE CSS FILES // ------------------------------------------------------------ ?> + + @@ -59,6 +61,7 @@ // ------------------------------------------------------------ // WEBPAGE FAVICON // ------------------------------------------------------------ ?> + @@ -69,6 +72,7 @@ // ------------------------------------------------------------ // VIEW FILE JAVASCRIPT CODE // ------------------------------------------------------------ ?> + - - - + diff --git a/src/application/views/appointments/book_success.php b/src/application/views/appointments/book_success.php index db0ba229..e5dad818 100755 --- a/src/application/views/appointments/book_success.php +++ b/src/application/views/appointments/book_success.php @@ -7,21 +7,21 @@ <?php echo $this->lang->line('appointment_registered') . ' - ' . $company_name; ?> - + - + @@ -74,11 +74,11 @@ - + @@ -96,6 +96,7 @@ // ------------------------------------------------------------ // CUSTOM PAGE JS // ------------------------------------------------------------ ?> + + + diff --git a/src/application/views/appointments/message.php b/src/application/views/appointments/message.php index fdbe13a4..ed07b833 100644 --- a/src/application/views/appointments/message.php +++ b/src/application/views/appointments/message.php @@ -11,6 +11,7 @@ // ------------------------------------------------------------ // INCLUDE CSS FILES // ------------------------------------------------------------ ?> + + @@ -30,6 +32,7 @@ // ------------------------------------------------------------ // CUSTOM PAGE JS // ------------------------------------------------------------ ?> + @@ -38,6 +41,7 @@ // ------------------------------------------------------------ // INCLUDE JS FILES // ------------------------------------------------------------ ?> + @@ -68,7 +72,6 @@
' . $message_title . ''; echo '

' . $message_text . '

'; @@ -87,5 +90,7 @@
+ + diff --git a/src/application/views/general/error404.php b/src/application/views/general/error404.php index d4252577..94203ffa 100644 --- a/src/application/views/general/error404.php +++ b/src/application/views/general/error404.php @@ -11,6 +11,7 @@ // ------------------------------------------------------------ // INCLUDE CSS FILES // ------------------------------------------------------------ ?> + + + @@ -37,6 +40,7 @@ // ------------------------------------------------------------ // INCLUDE JS FILES // ------------------------------------------------------------ ?> + @@ -54,6 +58,7 @@ // ------------------------------------------------------------ // CUSTOM PAGE CSS // ------------------------------------------------------------ ?> +