* Completed main flow of installation use case.
This commit is contained in:
parent
a5ef8fb491
commit
dcecfd896d
7 changed files with 206 additions and 89 deletions
|
@ -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 */
|
||||
|
|
|
@ -148,7 +148,7 @@
|
|||
'<p>' +
|
||||
'Your appointment has successfully been added to ' +
|
||||
'your Google Calendar account. <br>' +
|
||||
'<a href="' + response.htmlLink + '">' +
|
||||
'<a href="' + response.htmlLink + '" target="_blank">' +
|
||||
'Click here to view your appointment on Google ' +
|
||||
'Calendar.' +
|
||||
'</a>' +
|
||||
|
|
|
@ -62,21 +62,21 @@
|
|||
</legend>
|
||||
|
||||
<label for="company-name">Company Name *</label>
|
||||
<input type="text" id="company-name" data-field="company_name" class="required">
|
||||
<input type="text" id="company-name" data-field="company_name" class="required span4">
|
||||
<span class="help-block">Company name will be displayed everywhere on the system
|
||||
(required).</span>
|
||||
|
||||
<br>
|
||||
|
||||
<label for="company-email">Company Email *</label>
|
||||
<input type="text" id="company-email" data-field="company_email" class="required">
|
||||
<input type="text" id="company-email" data-field="company_email" class="required span4">
|
||||
<span class="help-block">This will be the company email address. It will be used
|
||||
as the sender and the reply address of the system emails (required).</span>
|
||||
|
||||
<br>
|
||||
|
||||
<label for="company-link">Company Link *</label>
|
||||
<input type="text" id="company-link" data-field="company_link" class="required">
|
||||
<input type="text" id="company-link" data-field="company_link" class="required span4">
|
||||
<span class="help-block">Company link should point to the official website of
|
||||
the company (optional).</span>
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
<link
|
||||
rel="icon"
|
||||
type="image/x-icon"
|
||||
href="<?php echo $base_url(); ?>assets/images/favicon.ico">
|
||||
href="<?php echo $base_url; ?>assets/images/favicon.ico">
|
||||
|
||||
<?php // INCLUDE SCRIPTS ?>
|
||||
<script
|
||||
|
@ -41,21 +41,38 @@
|
|||
'baseUrl': <?php echo '"' . $base_url . '"'; ?>
|
||||
};
|
||||
|
||||
var MIN_PASSWORD_LENGTH = 7;
|
||||
var AJAX_SUCCESS = 'SUCCESS';
|
||||
var AJAX_FAILURE = 'FAILURE';
|
||||
|
||||
/**
|
||||
* Event: Install System "Click"
|
||||
* Event: Install Easy!Appointments Button "Click"
|
||||
*/
|
||||
$('#install').click(function() {
|
||||
if (!validate()) return;
|
||||
|
||||
var postUrl = GlobalVariables.baseUrl + 'ajax_install';
|
||||
var postUrl = GlobalVariables.baseUrl + 'appointments/ajax_install';
|
||||
var postData = {
|
||||
'admin': getAdminData(),
|
||||
'company': getCompanyDate()
|
||||
'admin': JSON.stringify(getAdminData()),
|
||||
'company': JSON.stringify(getCompanyData())
|
||||
};
|
||||
|
||||
$.post(postUrl, postData, function(response) {
|
||||
|
||||
});
|
||||
//////////////////////////////////////////////////////
|
||||
console.log('Ajax Install E!A Response:', response);
|
||||
//////////////////////////////////////////////////////
|
||||
|
||||
if (!GeneralFunctions.handleAjaxExceptions(response)) return;
|
||||
|
||||
if (response == AJAX_SUCCESS) {
|
||||
$('.alert').text('Easy!Appointments has been success fully installed!');
|
||||
$('.alert').addClass('alert-success');
|
||||
$('.alert').show();
|
||||
setTimeout(function() {
|
||||
window.location.href = GlobalVariables.baseUrl + 'backend';
|
||||
}, 1000);
|
||||
}
|
||||
}, 'json');
|
||||
});
|
||||
|
||||
/**
|
||||
|
@ -65,12 +82,12 @@
|
|||
*/
|
||||
function validate() {
|
||||
try {
|
||||
$('.alert').fadeOut();
|
||||
$('input[type="text"]').css('border', '');
|
||||
$('.alert').hide();
|
||||
$('input').css('border', '');
|
||||
|
||||
// Check for empty fields.
|
||||
var missingRequired = false;
|
||||
$('input[type="text"]').each(function() {
|
||||
$('input').each(function() {
|
||||
if ($(this).val() == '') {
|
||||
$(this).css('border', '2px solid red');
|
||||
missingRequired = true;
|
||||
|
@ -87,16 +104,27 @@
|
|||
throw 'Passwords do not match!';
|
||||
}
|
||||
|
||||
if ($('#password').val().length < MIN_PASSWORD_LENGTH) {
|
||||
$('#password').css('border', '2px solid red');
|
||||
$('#retype-password').css('border', '2px solid red');
|
||||
throw 'The password must be at least ' + MIN_PASSWORD_LENGTH + ' characters long.';
|
||||
}
|
||||
|
||||
// Validate Email
|
||||
if (!GeneralFunctions.validateEmail($('#email').val())) {
|
||||
$('#email').css('border', '2px solid red');
|
||||
throw 'The email addres is invalid!';
|
||||
throw 'The email address is invalid!';
|
||||
}
|
||||
|
||||
if (!GeneralFunctions.validateEmail($('#company-email').val())) {
|
||||
$('#company-email').css('border', '2px solid red');
|
||||
throw 'The email address is invalid!';
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch(exc) {
|
||||
$('.alert').txt(exc);
|
||||
$('.alert').fadeIn();
|
||||
$('.alert').text(exc);
|
||||
$('.alert').show();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -125,10 +153,39 @@
|
|||
* @returns {object}
|
||||
*/
|
||||
function getCompanyData() {
|
||||
var company = {
|
||||
'company_name': $('#company-name').val(),
|
||||
'company_email': $('#company-email').val(),
|
||||
'company_link': $('#company-link').val()
|
||||
};
|
||||
|
||||
return company;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style>
|
||||
header {
|
||||
background: #DAFFEB;
|
||||
margin-bottom: 25px;
|
||||
}
|
||||
|
||||
.content {
|
||||
margin: 32px;
|
||||
max-width: 980px;
|
||||
}
|
||||
|
||||
.alert {
|
||||
margin: 25px 0 10px 0;
|
||||
}
|
||||
|
||||
footer {
|
||||
padding: 10px 35px;
|
||||
background-color: #FAFAFA;
|
||||
margin-top: 20px;
|
||||
border-top: 1px solid #EEE;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
|
@ -136,76 +193,81 @@
|
|||
<img src="<?php echo $base_url; ?>assets/images/installation-banner.png" alt="Easy!Appointents Installation Banner">
|
||||
</a>
|
||||
</header>
|
||||
|
||||
<div class="content">
|
||||
<div class="welcome">
|
||||
<h2>Welcome To The Easy!Appointments Installation Page</h2>
|
||||
<h2>Welcome to the Easy!Appointments installation page.</h2>
|
||||
<p>
|
||||
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 <span class="label label-info"><?php echo $base_url; ?>
|
||||
backend</span> url to connect to the backend section of Easy!Appointments.
|
||||
|
||||
system. Remember to use the <span class="text-error"><?php echo $base_url; ?>backend</span>
|
||||
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 <a href="https://code.google.com/p/easy-appointments/w/list">Wiki Pages</a>
|
||||
and the <a href="http://groups.google.com/group/easy-appointments">Support Group</a>
|
||||
for getting help. You may also submit new issues on the
|
||||
<a href="https://code.google.com/p/easy-appointments/issues/list">Google Code Issues</a>
|
||||
page, in order to help our development process.
|
||||
and <a href="http://groups.google.com/group/easy-appointments">Support Group</a>
|
||||
for getting help. You may also submit new issues on
|
||||
<a href="https://code.google.com/p/easy-appointments/issues/list">Google Code</a>
|
||||
in order to help our development process.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<div class="alert" style="display: none"></div>
|
||||
|
||||
<div class="admin-settings">
|
||||
<h2>Administrator Settings</h2>
|
||||
<label for="first-name">First Name</label>
|
||||
<input type="text" id="first-name" />
|
||||
|
||||
<label for="last-name">Last Name</label>
|
||||
<input type="text" id="last-name" />
|
||||
|
||||
<label for="email">Email</label>
|
||||
<input type="text" id="email" />
|
||||
|
||||
<label for="phone-number">Phone Number</label>
|
||||
<input type="text" id="phone-number" />
|
||||
|
||||
<label for="username">Username</label>
|
||||
<input type="text" id="username" />
|
||||
|
||||
<label for="password">Password</label>
|
||||
<input type="password" id="password" />
|
||||
|
||||
<label for="retype-password">Retype Password</label>
|
||||
<input type="password" id="retype-password" />
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<div class="company-settings">
|
||||
<h2>Company Settings</h2>
|
||||
<label for="company-name">Company Name</label>
|
||||
<input type="text" id="company-name">
|
||||
|
||||
<label for="company-email">Company Email</label>
|
||||
<input type="text" id="company-email">
|
||||
|
||||
<label for="company-link">Company Link</label>
|
||||
<input type="text" id="company-link">
|
||||
|
||||
<div class="alert alert-info">
|
||||
You will be able to set your business logic in the backend settings page after
|
||||
the installation is complete.
|
||||
<div class="alert" style="display:none"></div>
|
||||
|
||||
<div class="row-fluid">
|
||||
<div class="admin-settings span5">
|
||||
<h3>Administrator</h3>
|
||||
<label for="first-name">First Name</label>
|
||||
<input type="text" id="first-name" class="span10" />
|
||||
|
||||
<label for="last-name">Last Name</label>
|
||||
<input type="text" id="last-name" class="span10" />
|
||||
|
||||
<label for="email">Email</label>
|
||||
<input type="text" id="email" class="span10" />
|
||||
|
||||
<label for="phone-number">Phone Number</label>
|
||||
<input type="text" id="phone-number" class="span10" />
|
||||
|
||||
<label for="username">Username</label>
|
||||
<input type="text" id="username" class="span10" />
|
||||
|
||||
<label for="password">Password</label>
|
||||
<input type="password" id="password" class="span10" />
|
||||
|
||||
<label for="retype-password">Retype Password</label>
|
||||
<input type="password" id="retype-password" class="span10" />
|
||||
</div>
|
||||
|
||||
<div class="company-settings span5">
|
||||
<h3>Company</h3>
|
||||
<label for="company-name">Company Name</label>
|
||||
<input type="text" id="company-name" class="span10" />
|
||||
|
||||
<label for="company-email">Company Email</label>
|
||||
<input type="text" id="company-email" class="span10" />
|
||||
|
||||
<label for="company-link">Company Link</label>
|
||||
<input type="text" id="company-link" class="span10" />
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<center>
|
||||
<button type="button" id="install" class="btn btn-success btn-large">
|
||||
<i class="icon-white icon-ok"></i>
|
||||
Install</button>
|
||||
</center>
|
||||
<br>
|
||||
|
||||
<p>
|
||||
You will be able to set your business logic in the backend settings page
|
||||
after the installation is complete.
|
||||
<br>
|
||||
Press the following button to complete the installation process.
|
||||
</p>
|
||||
|
||||
<br>
|
||||
|
||||
<button type="button" id="install" class="btn btn-success btn-large">
|
||||
<i class="icon-white icon-ok"></i>
|
||||
Install Easy!Appointments</button>
|
||||
</div>
|
||||
|
||||
<footer>
|
||||
|
|
|
@ -29,7 +29,7 @@ body {
|
|||
#book-appointment-wizard #company-name {
|
||||
font-weight: bold;
|
||||
color: #FFF;
|
||||
font-size: 27px;
|
||||
font-size: 22px;
|
||||
margin: 27px 10px 0 14px;
|
||||
display: inline-block;
|
||||
text-shadow: 0px 1px 1px #8F8888;
|
||||
|
|
|
@ -225,3 +225,13 @@ ALTER TABLE `ea_user_settings`
|
|||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||
|
||||
INSERT INTO `ea_roles` (`id`, `name`, `slug`, `is_admin`, `appointments`, `customers`, `services`, `users`, `system_settings`, `user_settings`) VALUES
|
||||
(1, 'Administrator', 'admin', 1, 15, 15, 15, 15, 15, 15),
|
||||
(2, 'Provider', 'provider', 0, 15, 15, 0, 0, 0, 15),
|
||||
(3, 'Customer', 'customer', 0, 0, 0, 0, 0, 0, 0),
|
||||
(4, 'Secretary', 'secretary', 0, 15, 15, 0, 0, 15, 15);
|
||||
|
||||
INSERT INTO `ea_settings` (`name`, `value`) VALUES
|
||||
('company_working_plan', '{"monday":{"start":"09:00","end":"18:00","breaks":[{"start":"11:20","end":"11:30"},{"start":"14:30","end":"15:00"}]},"tuesday":{"start":"09:00","end":"18:00","breaks":[{"start":"11:20","end":"11:30"},{"start":"14:30","end":"15:00"}]},"wednesday":{"start":"09:00","end":"18:00","breaks":[{"start":"11:20","end":"11:30"},{"start":"14:30","end":"15:00"}]},"thursday":{"start":"09:00","end":"18:00","breaks":[{"start":"11:20","end":"11:30"},{"start":"14:30","end":"15:00"}]},"friday":{"start":"09:00","end":"18:00","breaks":[{"start":"11:20","end":"11:30"},{"start":"14:30","end":"15:00"}]},"saturday":{"start":"09:00","end":"18:00","breaks":[{"start":"11:20","end":"11:30"},{"start":"14:30","end":"15:00"}]},"sunday":{"start":"09:00","end":"18:00","breaks":[{"start":"11:20","end":"11:30"},{"start":"14:30","end":"15:00"}]}}'),
|
||||
('book_advance_timeout', '30');
|
|
@ -5,7 +5,7 @@ class SystemConfiguration {
|
|||
|
||||
// Database Settings
|
||||
public static $db_host = 'localhost';
|
||||
public static $db_name = 'easy_appointments';
|
||||
public static $db_name = 'new_ea'; //'easy_appointments';
|
||||
public static $db_username = 'root';
|
||||
public static $db_password = '';
|
||||
|
||||
|
|
Loading…
Reference in a new issue