From dcecfd896def965d7f4ade022486db5a7c954183 Mon Sep 17 00:00:00 2001 From: "alextselegidis@gmail.com" Date: Wed, 16 Oct 2013 15:53:26 +0000 Subject: [PATCH] * Completed main flow of installation use case. --- src/application/controllers/appointments.php | 71 ++++-- .../views/appointments/book_success.php | 2 +- src/application/views/backend/settings.php | 6 +- .../views/general/installation.php | 202 ++++++++++++------ src/assets/css/frontend.css | 2 +- src/assets/sql/structure.sql | 10 + src/configuration.php | 2 +- 7 files changed, 206 insertions(+), 89 deletions(-) diff --git a/src/application/controllers/appointments.php b/src/application/controllers/appointments.php index ea7cbaab..5b17f8de 100644 --- a/src/application/controllers/appointments.php +++ b/src/application/controllers/appointments.php @@ -617,28 +617,73 @@ class Appointments extends CI_Controller { try { if (!$this->db->table_exists('ea_users')) { // This is the first time the website is launched an the user needs to set - // the basic settings. - - // We will use mysqli to create the database structure from the "structure.sql" file. - require_once dirname(dirname(dirname(__FILE__))) . '/configuration.php'; - $mysqli = new mysqli(SystemConfiguration::$db_host, SystemConfiguration::$db_username, - SystemConfiguration::$db_password, SystemConfiguration::$db_name); - $structure = file_get_contents($this->config->item('base_url') . 'assets/sql/structure.sql'); - $mysqli->multi_query($structure); - $mysqli->close(); - - // Display the installation view page. + // the basic settings. Display the installation view page. $view['base_url'] = $this->config->item('base_url'); $this->load->view('general/installation', $view); - return FALSE; // Do not display the book appointment view file. } else { - return TRUE; + return TRUE; // Application installed, continue ... } } catch(Exception $exc) { echo $exc->getTrace(); } } + + /** + * Installs Easy!Appointments on server. + * + * @param array $_POST['admin'] Contains the initial admin user data. System needs at least + * one admin user to work. + * @param array $_POST['company'] Contains the basic company data. + */ + public function ajax_install() { + try { + // 2nd method using the ci database class. + $file_contents = file_get_contents($this->config->item('base_url') . 'assets/sql/structure.sql'); + $sql_queries = explode(';', $file_contents); + array_pop($sql_queries); + foreach($sql_queries as $query) { + $this->db->query($query); + } + + //$this->db->reconnect(); + + $admin = json_decode($_POST['admin'], true); + $admin_role_id = $this->db->get_where('ea_roles', array('slug' => DB_SLUG_ADMIN))->row()->id; + $admin = json_decode($_POST['admin'], true); + $this->db->query('INSERT INTO `ea_users` (`first_name`, `last_name`, `email`, `phone_number`, `id_roles`) VALUES ' + . '("' . $admin['first_name'] . '", "' . $admin['last_name'] . '", "' . $admin['email'] . '", "' . $admin['phone_number'] . '", "' . $admin_role_id . '");'); + $this->db->query('INSERT INTO `ea_user_settings` (`id_users`, `username`, `password`) VALUES ' + . '("' . $this->db->insert_id() . '", "' . $admin['username'] . '", "' . $admin['password'] . '");'); + +// // Insert admin +// $this->load->model('admins_model'); +// $admin = json_decode($_POST['admin'], true); +// $admin['settings']['username'] = $admin['username']; +// $admin['settings']['password'] = $admin['password']; +// unset($admin['username'], $admin['password']); +// $this->admins_model->add($admin); + + // Save company settings + $company = json_decode($_POST['company'], true); + $this->db->query('INSERT INTO `ea_settings` (`name`, `value`) VALUES ' + . '("company_name", "' . $company['company_name'] . '"),' + . '("company_email", "' . $company['company_email'] . '"),' + . '("company_link", "' . $company['company_link'] . '");'); +// $this->load->model('settings_model'); +// $company = json_decode($_POST['company'], true); +// $this->settings_model->set_setting('company_name', $company['company_name']); +// $this->settings_model->set_setting('company_email', $company['company_email']); +// $this->settings_model->set_setting('company_link', $company['company_link']); + + echo json_encode(AJAX_SUCCESS); + + } catch (Exception $exc) { + echo json_encode(array( + 'exceptions' => array(exceptionToJavaScript($exc)) + )); + } + } } /* End of file appointments.php */ diff --git a/src/application/views/appointments/book_success.php b/src/application/views/appointments/book_success.php index 3ce128bb..5d66318f 100644 --- a/src/application/views/appointments/book_success.php +++ b/src/application/views/appointments/book_success.php @@ -148,7 +148,7 @@ '

' + 'Your appointment has successfully been added to ' + 'your Google Calendar account.
' + - '' + + '' + 'Click here to view your appointment on Google ' + 'Calendar.' + '' + diff --git a/src/application/views/backend/settings.php b/src/application/views/backend/settings.php index c94c90f6..420ab8dc 100644 --- a/src/application/views/backend/settings.php +++ b/src/application/views/backend/settings.php @@ -62,21 +62,21 @@ - + Company name will be displayed everywhere on the system (required).
- + This will be the company email address. It will be used as the sender and the reply address of the system emails (required).
- + Company link should point to the official website of the company (optional). diff --git a/src/application/views/general/installation.php b/src/application/views/general/installation.php index 4131423a..1f1da990 100644 --- a/src/application/views/general/installation.php +++ b/src/application/views/general/installation.php @@ -19,7 +19,7 @@ + href="assets/images/favicon.ico"> + +

@@ -136,76 +193,81 @@ Easy!Appointents Installation Banner
+
-

Welcome To The Easy!Appointments Installation Page

+

Welcome to the Easy!Appointments installation page.

This page will help you set the main settings of your Easy!Appointments installation. You will be able to edit these settings and many more in the backend session of your - system. Remember to use the - backend url to connect to the backend section of Easy!Appointments. - + system. Remember to use the backend + url to connect to the backend section of Easy!Appointments. + If you face any problems during the usage of Easy!Appointments you can always check the official Wiki Pages - and the Support Group - for getting help. You may also submit new issues on the - Google Code Issues - page, in order to help our development process. + and Support Group + for getting help. You may also submit new issues on + Google Code + in order to help our development process.

-
- - - -
-

Administrator Settings

- - - - - - - - - - - - - - - - - - - - -
- -
- -
-

Company Settings

- - - - - - - - - -
- You will be able to set your business logic in the backend settings page after - the installation is complete. + + +
+
+

Administrator

+ + + + + + + + + + + + + + + + + + + + +
+ +
+

Company

+ + + + + + + + + +
-
- -
+
+ +

+ You will be able to set your business logic in the backend settings page + after the installation is complete. +
+ Press the following button to complete the installation process. +

+ +
+ +