diff --git a/src/application/config/config.php b/src/application/config/config.php
index cf4496bc..e02350c7 100644
--- a/src/application/config/config.php
+++ b/src/application/config/config.php
@@ -19,6 +19,7 @@ include dirname(dirname(dirname(__FILE__))) . '/configuration.php';
*/
require_once dirname(dirname(dirname(__FILE__))) . '/configuration.php';
$config['base_url'] = SystemConfiguration::$base_url;
+$config['ea_version'] = '0.6'; // This must be changed manually.
/*
|--------------------------------------------------------------------------
diff --git a/src/application/controllers/appointments.php b/src/application/controllers/appointments.php
index 5b17f8de..879faca6 100644
--- a/src/application/controllers/appointments.php
+++ b/src/application/controllers/appointments.php
@@ -646,35 +646,31 @@ class Appointments extends CI_Controller {
$this->db->query($query);
}
- //$this->db->reconnect();
-
+ // Insert admin
+ $this->load->model('admins_model');
$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);
+ $admin['settings']['username'] = $admin['username'];
+ $admin['settings']['password'] = $admin['password'];
+ unset($admin['username'], $admin['password']);
+ $this->admins_model->add($admin);
// Save company settings
+ $this->load->model('settings_model');
$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']);
+ $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']);
+
+ // Try to send a notification email for the new installation.
+ // IMPORTANT: THIS WILL ONLY BE USED TO TRACK THE INSTALLATION NUMBER AND
+ // NO PERSONAL DATA WILL BE USED FOR OTHER CAUSE.
+ try {
+ $this->load->library('notifications');
+ $this->notifications->send_new_installation($company['company_name'],
+ $company['company_email'], $company['company_link']);
+ } catch(Exception $exc) {
+ // Well, I guess we'll never know ...
+ }
echo json_encode(AJAX_SUCCESS);
diff --git a/src/application/libraries/notifications.php b/src/application/libraries/notifications.php
index 26dfed65..38d30124 100644
--- a/src/application/libraries/notifications.php
+++ b/src/application/libraries/notifications.php
@@ -188,13 +188,13 @@ class Notifications {
// :: SETUP EMAIL OBJECT AND SEND NOTIFICATION
$mail = new PHPMailer();
- $mail->From = $company_settings['company_email'];
- $mail->FromName = $company_settings['company_name'];
+ $mail->From = $company_settings['company_email'];
+ $mail->FromName = $company_settings['company_name'];
$mail->AddAddress($email); // "Name" argument crushes the phpmailer class.
$mail->IsHTML(true);
- $mail->CharSet = 'UTF-8';
- $mail->Subject = 'New Account Password';
- $mail->Body = $email_html;
+ $mail->CharSet = 'UTF-8';
+ $mail->Subject = 'New Account Password';
+ $mail->Body = $email_html;
if (!$mail->Send()) {
throw new Exception('Email could not been sent. '
@@ -203,6 +203,30 @@ class Notifications {
return TRUE;
}
+
+ /**
+ * Sends a simple email to notify for a new installation.
+ *
+ * This method will be only used for tracking the number of installations. No personal
+ * data will be retrieved for any other cause.
+ *
+ * @returns bool Returns the "send()" method result.
+ */
+ public function send_new_installation($company_name, $company_email, $company_link) {
+ $mail = new PHPMailer();
+ $mail->From = $company_email;
+ $mail->FromName = 'New Installation: ' . $company_name ;
+ $mail->AddAddress('info@easyappointments.org');
+ $mail->IsHTML(true);
+ $mail->CharSet = 'UTF-8';
+ $mail->Subject = 'New Easy!Appointments Installation';
+ $mail->Body = 'Base URL: ' . $this->CI->config->item('base_url') . '
'
+ . 'E!A Version: ' . $this->CI->config->item('ea_version') . '
'
+ . 'Company Name: ' . $company_name . '
'
+ . 'Company Email: ' . $company_email . '
'
+ . 'Company Link: ' . $company_link . '
';
+ return $mail->Send();
+ }
}
/* End of file notifications.php */
diff --git a/src/application/views/appointments/book.php b/src/application/views/appointments/book.php
index 81a1b769..b8c6c9b9 100644
--- a/src/application/views/appointments/book.php
+++ b/src/application/views/appointments/book.php
@@ -1,7 +1,7 @@