diff --git a/src/application/controllers/backend.php b/src/application/controllers/backend.php index d1ae4d63..db64ea46 100644 --- a/src/application/controllers/backend.php +++ b/src/application/controllers/backend.php @@ -72,7 +72,6 @@ class Backend extends CI_Controller { $view['secretary_providers'] = array(); } - $results = $this->appointments_model->get_batch(array('hash' => $appointment_hash)); if ($appointment_hash != '' && count($results) > 0) { $appointment = $results[0]; @@ -232,6 +231,7 @@ class Backend extends CI_Controller { * @param bool $redirect (OPTIONAL - TRUE) If the user has not the required privileges * (either not logged in or insufficient role privileges) then the user will be redirected * to another page. Set this argument to FALSE when using ajax. + * * @return bool Returns whether the user has the required privileges to view the page or * not. If the user is not logged in then he will be prompted to log in. If he hasn't the * required privileges then an info message will be displayed. diff --git a/src/application/controllers/backend_api.php b/src/application/controllers/backend_api.php index 0ece9d4c..cd7b6c77 100644 --- a/src/application/controllers/backend_api.php +++ b/src/application/controllers/backend_api.php @@ -48,10 +48,10 @@ class Backend_api extends CI_Controller { * This method returns the database appointments and unavailable periods for the * user selected date period and record type (provider or service). * - * @param {numeric} $_POST['record_id'] Selected record id. - * @param {string} $_POST['filter_type'] Could be either FILTER_TYPE_PROVIDER or FILTER_TYPE_SERVICE. - * @param {string} $_POST['start_date'] The user selected start date. - * @param {string} $_POST['end_date'] The user selected end date. + * @param numeric $_POST['record_id'] Selected record id. + * @param string $_POST['filter_type'] Could be either FILTER_TYPE_PROVIDER or FILTER_TYPE_SERVICE. + * @param string $_POST['start_date'] The user selected start date. + * @param string $_POST['end_date'] The user selected end date. */ public function ajax_get_calendar_appointments() { try { @@ -113,13 +113,10 @@ class Backend_api extends CI_Controller { } /** - * [AJAX] Save appointment changes that are made from the backend calendar - * page. + * [AJAX] Save appointment changes that are made from the backend calendar page. * - * @param array $_POST['appointment_data'] (OPTIONAL) Array with the - * appointment data. - * @param array $_POST['customer_data'] (OPTIONAL) Array with the customer - * data. + * @param array $_POST['appointment_data'] (OPTIONAL) Array with the appointment data. + * @param array $_POST['customer_data'] (OPTIONAL) Array with the customer data. */ public function ajax_save_appointment() { try { @@ -374,7 +371,6 @@ class Backend_api extends CI_Controller { if (!isset($_POST['provider_id'])) throw new Exception('Provider id not specified.'); - if ($this->privileges[PRIV_USERS]['edit'] == FALSE && $this->session->userdata('user_id') != $_POST['provider_id']) { throw new Exception('You do not have the required privileges for this task.'); @@ -398,7 +394,8 @@ class Backend_api extends CI_Controller { /** * [AJAX] Filter the customer records with the given key string. * - * @param string $_POST['key'] The filter key string + * @param string $_POST['key'] The filter key string. + * * @return array Returns the search results. */ public function ajax_filter_customers() { @@ -666,6 +663,7 @@ class Backend_api extends CI_Controller { * [AJAX] Filter service records by given key string. * * @param string $_POST['key'] Key string used to filter the records. + * * @return array Returns a json encoded array back to client. */ public function ajax_filter_services() { @@ -744,6 +742,7 @@ class Backend_api extends CI_Controller { * [AJAX] Filter services categories with key string. * * @param string $_POST['key'] The key string used to filter the records. + * * @return array Returns a json encoded array back to client with the category records. */ public function ajax_filter_service_categories() { @@ -768,6 +767,7 @@ class Backend_api extends CI_Controller { * [AJAX] Filter admin records with string key. * * @param string $_POST['key'] The key string used to filter the records. + * * @return array Returns a json encoded array back to client with the admin records. */ public function ajax_filter_admins() { @@ -798,6 +798,7 @@ class Backend_api extends CI_Controller { * * @param array $_POST['admin'] A json encoded array that contains the admin data. If an 'id' * value is provided then the record is going to be updated. + * * @return array Returns an array with the operation status and the record id that was * saved into the database. */ @@ -832,6 +833,7 @@ class Backend_api extends CI_Controller { * [AJAX] Delete an admin record from the database. * * @param numeric $_POST['admin_id'] The id of the record to be deleted. + * * @return string Returns the operation result constant (AJAX_SUCESS or AJAX_FAILURE). */ public function ajax_delete_admin() { @@ -854,6 +856,7 @@ class Backend_api extends CI_Controller { * [AJAX] Filter provider records with string key. * * @param string $_POST['key'] The key string used to filter the records. + * * @return array Returns a json encoded array back to client with the provider records. */ public function ajax_filter_providers() { @@ -884,6 +887,7 @@ class Backend_api extends CI_Controller { * * @param array $_POST['provider'] A json encoded array that contains the provider data. If an 'id' * value is provided then the record is going to be updated. + * * @return string Returns the success contant 'AJAX_SUCCESS' so javascript knows that * everything completed successfully. */ @@ -923,6 +927,7 @@ class Backend_api extends CI_Controller { * [AJAX] Delete a provider record from the database. * * @param numeric $_POST['provider_id'] The id of the record to be deleted. + * * @return string Returns the operation result constant (AJAX_SUCESS or AJAX_FAILURE). */ public function ajax_delete_provider() { @@ -945,6 +950,7 @@ class Backend_api extends CI_Controller { * [AJAX] Filter secretary records with string key. * * @param string $_POST['key'] The key string used to filter the records. + * * @return array Returns a json encoded array back to client with the secretary records. */ public function ajax_filter_secretaries() { @@ -975,6 +981,7 @@ class Backend_api extends CI_Controller { * * @param array $_POST['secretary'] A json encoded array that contains the secretary data. * If an 'id' value is provided then the record is going to be updated. + * * @return string Returns the success contant 'AJAX_SUCCESS' so javascript knows that * everything completed successfully. */ @@ -1007,6 +1014,7 @@ class Backend_api extends CI_Controller { * [AJAX] Delete a secretary record from the database. * * @param numeric $_POST['secretary_id'] The id of the record to be deleted. + * * @return string Returns the operation result constant (AJAX_SUCESS or AJAX_FAILURE). */ public function ajax_delete_secretary() { diff --git a/src/application/controllers/errors.php b/src/application/controllers/errors.php index 0454978c..529f1730 100644 --- a/src/application/controllers/errors.php +++ b/src/application/controllers/errors.php @@ -1,44 +1,47 @@ - - * @copyright Copyright (c) 2013 - 2015, Alex Tselegidis - * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 - * @link http://easyappointments.org - * @since v1.0.0 - * ---------------------------------------------------------------------------- */ - -/** - * Errors Controller - * - * @package Controllers - */ -class Errors extends CI_Controller { - public function __construct() { - parent::__construct(); - $this->load->library('session'); - // Set user's selected language. - if ($this->session->userdata('language')) { - $this->config->set_item('language', $this->session->userdata('language')); - $this->lang->load('translations', $this->session->userdata('language')); - } else { - $this->lang->load('translations', $this->config->item('language')); // default - } - } - - public function index() { - $this->e404(); - } - - public function error404() { - $this->load->model('settings_model'); - $view['company_name'] = $this->settings_model->get_setting('company_name'); - $this->load->view('general/error404', $view); - } -} - -/* End of file errors.php */ -/* Location: ./application/controllers/errors.php */ \ No newline at end of file + + * @copyright Copyright (c) 2013 - 2015, Alex Tselegidis + * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 + * @link http://easyappointments.org + * @since v1.0.0 + * ---------------------------------------------------------------------------- */ + +/** + * Errors Controller + * + * @package Controllers + */ +class Errors extends CI_Controller { + /** + * Class Constructor + */ + public function __construct() { + parent::__construct(); + $this->load->library('session'); + // Set user's selected language. + if ($this->session->userdata('language')) { + $this->config->set_item('language', $this->session->userdata('language')); + $this->lang->load('translations', $this->session->userdata('language')); + } else { + $this->lang->load('translations', $this->config->item('language')); // default + } + } + + public function index() { + $this->e404(); + } + + public function error404() { + $this->load->model('settings_model'); + $view['company_name'] = $this->settings_model->get_setting('company_name'); + $this->load->view('general/error404', $view); + } +} + +/* End of file errors.php */ +/* Location: ./application/controllers/errors.php */ diff --git a/src/application/controllers/google.php b/src/application/controllers/google.php index 0d45d98e..787b3fae 100644 --- a/src/application/controllers/google.php +++ b/src/application/controllers/google.php @@ -14,9 +14,14 @@ /** * Google Controller * + * This controller handles the Google Calendar synchronization operations. + * * @package Controllers */ class Google extends CI_Controller { + /** + * Class Constructor + */ public function __construct() { parent::__construct(); } diff --git a/src/application/controllers/installation.php b/src/application/controllers/installation.php index efe4f1e6..9ab2c5eb 100644 --- a/src/application/controllers/installation.php +++ b/src/application/controllers/installation.php @@ -19,7 +19,6 @@ * @package Controllers */ class Installation extends CI_Controller { - /** * Class Constructor */ @@ -37,7 +36,6 @@ class Installation extends CI_Controller { } } - /** * Display the installation page. */ diff --git a/src/application/controllers/test.php b/src/application/controllers/test.php index 0955690b..725ef67a 100644 --- a/src/application/controllers/test.php +++ b/src/application/controllers/test.php @@ -1,71 +1,75 @@ - - * @copyright Copyright (c) 2013 - 2015, Alex Tselegidis - * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 - * @link http://easyappointments.org - * @since v1.0.0 - * ---------------------------------------------------------------------------- */ - -/** - * Test Controller - * - * @package Controllers - */ -class Test extends CI_Controller { - /** - * Class Constructor - */ - public function __construct() { - parent::__construct(); - $this->load->driver('Unit_tests'); - } - - /** - * Run all available unit tests. - * - * We only test models at the moment. In the future the unit test will be - * improved. - */ - public function index() { - // User must be logged in as an admin in order to run the tests. - $this->load->library('session'); - $this->session->set_userdata('dest_url', $this->config->item('base_url') . '/index.php/test'); - if ($this->session->userdata('role_slug') != DB_SLUG_ADMIN) { - header('Location: ' . $this->config->item('base_url') . '/index.php/user/login'); - return; - } - - if (ENVIRONMENT !== 'development') { - $this->output->set_output('Tests are available only at development environment. ' - . 'Please check your "index.php" file settings.'); - return; - } - - $this->load->view('general/test'); - $this->unit_tests->run_all_tests(); - } - - /** - * Test only the app models. - */ - public function models() { - //$this->load->view('general/test'); - //$this->unit_tests->run_model_tests(); - } - - /** - * Test only the app libraries. - */ - public function libraries() { - //$this->load->view('general/test'); - //$this->unit_tests->run_library_tests(); - } -} - -/* End of file test.php */ -/* Location: ./application/controllers/test.php */ \ No newline at end of file + + * @copyright Copyright (c) 2013 - 2015, Alex Tselegidis + * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 + * @link http://easyappointments.org + * @since v1.0.0 + * ---------------------------------------------------------------------------- */ + +/** + * Test Controller + * + * NOTICE: This controller is outdated and must not be used. + * + * @deprecated v1.1.0 + * + * @package Controllers + */ +class Test extends CI_Controller { + /** + * Class Constructor + */ + public function __construct() { + parent::__construct(); + $this->load->driver('Unit_tests'); + } + + /** + * Run all available unit tests. + * + * We only test models at the moment. In the future the unit test will be + * improved. + */ + public function index() { + // User must be logged in as an admin in order to run the tests. + $this->load->library('session'); + $this->session->set_userdata('dest_url', $this->config->item('base_url') . '/index.php/test'); + if ($this->session->userdata('role_slug') != DB_SLUG_ADMIN) { + header('Location: ' . $this->config->item('base_url') . '/index.php/user/login'); + return; + } + + if (ENVIRONMENT !== 'development') { + $this->output->set_output('Tests are available only at development environment. ' + . 'Please check your "index.php" file settings.'); + return; + } + + $this->load->view('general/test'); + $this->unit_tests->run_all_tests(); + } + + /** + * Test only the app models. + */ + public function models() { + //$this->load->view('general/test'); + //$this->unit_tests->run_model_tests(); + } + + /** + * Test only the app libraries. + */ + public function libraries() { + //$this->load->view('general/test'); + //$this->unit_tests->run_library_tests(); + } +} + +/* End of file test.php */ +/* Location: ./application/controllers/test.php */ diff --git a/src/application/controllers/user.php b/src/application/controllers/user.php index 371a26c1..c299803d 100644 --- a/src/application/controllers/user.php +++ b/src/application/controllers/user.php @@ -1,150 +1,167 @@ - - * @copyright Copyright (c) 2013 - 2015, Alex Tselegidis - * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 - * @link http://easyappointments.org - * @since v1.0.0 - * ---------------------------------------------------------------------------- */ - -/** - * User Controller - * - * @package Controllers - */ -class User extends CI_Controller { - public function __construct() { - parent::__construct(); - $this->load->library('session'); - - // Set user's selected language. - if ($this->session->userdata('language')) { - $this->config->set_item('language', $this->session->userdata('language')); - $this->lang->load('translations', $this->session->userdata('language')); - } else { - $this->lang->load('translations', $this->config->item('language')); // default - } - } - - public function index() { - header('Location: ' . $this->config->item('base_url') . '/index.php/user/login'); - } - - public function login() { - $this->load->model('settings_model'); - - $view['base_url'] = $this->config->item('base_url'); - $view['dest_url'] = $this->session->userdata('dest_url'); - - if (!$view['dest_url']) { - $view['dest_url'] = $view['base_url'] . '/index.php/backend'; - } - - $view['company_name'] = $this->settings_model->get_setting('company_name'); - $this->load->view('user/login', $view); - } - - public function logout() { - $this->load->model('settings_model'); - - $this->session->unset_userdata('user_id'); - $this->session->unset_userdata('user_email'); - $this->session->unset_userdata('role_slug'); - $this->session->unset_userdata('username'); - $this->session->unset_userdata('dest_url'); - - $view['base_url'] = $this->config->item('base_url'); - $view['company_name'] = $this->settings_model->get_setting('company_name'); - $this->load->view('user/logout', $view); - } - - public function forgot_password() { - $this->load->model('settings_model'); - $view['base_url'] = $this->config->item('base_url'); - $view['company_name'] = $this->settings_model->get_setting('company_name'); - $this->load->view('user/forgot_password', $view); - } - - public function no_privileges() { - $this->load->model('settings_model'); - $view['base_url'] = $this->config->item('base_url'); - $view['company_name'] = $this->settings_model->get_setting('company_name'); - $this->load->view('user/no_privileges', $view); - } - - /** - * [AJAX] Check whether the user has entered the correct login credentials. - * - * The session data of a logged in user are the following: - * 'user_id' - * 'user_email' - * 'role_slug' - * 'dest_url' - */ - public function ajax_check_login() { - try { - if (!isset($_POST['username']) || !isset($_POST['password'])) { - throw new Exception('Invalid credentials given!'); - } - - $this->load->model('user_model'); - $user_data = $this->user_model->check_login($_POST['username'], $_POST['password']); - - if ($user_data) { - $this->session->set_userdata($user_data); // Save data on user's session. - echo json_encode(AJAX_SUCCESS); - } else { - echo json_encode(AJAX_FAILURE); - } - - } catch(Exception $exc) { - echo json_encode(array( - 'exceptions' => array(exceptionToJavaScript($exc)) - )); - } - } - - /** - * Regenerate a new password for the current user, only if the username and - * email address given corresond to an existing user in db. - * - * @param string $_POST['username'] - * @param string $_POST['email'] - */ - public function ajax_forgot_password() { - try { - if (!isset($_POST['username']) || !isset($_POST['email'])) { - throw new Exception('You must enter a valid username and email address in ' - . 'order to get a new password!'); - } - - $this->load->model('user_model'); - $this->load->model('settings_model'); - - $new_password = $this->user_model->regenerate_password($_POST['username'], $_POST['email']); - - if ($new_password != FALSE) { - $this->load->library('notifications'); - $company_settings = array( - 'company_name' => $this->settings_model->get_setting('company_name'), - 'company_link' => $this->settings_model->get_setting('company_link'), - 'company_email' => $this->settings_model->get_setting('company_email') - ); - $this->notifications->send_password($new_password, $_POST['email'], $company_settings); - } - - echo ($new_password != FALSE) ? json_encode(AJAX_SUCCESS) : json_encode(AJAX_FAILURE); - } catch(Exception $exc) { - echo json_encode(array( - 'exceptions' => array(exceptionToJavaScript($exc)) - )); - } - } -} - -/* End of file user.php */ -/* Location: ./application/controllers/user.php */ \ No newline at end of file + + * @copyright Copyright (c) 2013 - 2015, Alex Tselegidis + * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 + * @link http://easyappointments.org + * @since v1.0.0 + * ---------------------------------------------------------------------------- */ + +/** + * User Controller + * + * @package Controllers + */ +class User extends CI_Controller { + /** + * Class Constructor + */ + public function __construct() { + parent::__construct(); + $this->load->library('session'); + + // Set user's selected language. + if ($this->session->userdata('language')) { + $this->config->set_item('language', $this->session->userdata('language')); + $this->lang->load('translations', $this->session->userdata('language')); + } else { + $this->lang->load('translations', $this->config->item('language')); // default + } + } + + /** + * Default Method + * + * The default method will redirect the browser to the user/login URL. + */ + public function index() { + header('Location: ' . $this->config->item('base_url') . '/index.php/user/login'); + } + + /** + * Display the login page. + */ + public function login() { + $this->load->model('settings_model'); + + $view['base_url'] = $this->config->item('base_url'); + $view['dest_url'] = $this->session->userdata('dest_url'); + + if (!$view['dest_url']) { + $view['dest_url'] = $view['base_url'] . '/index.php/backend'; + } + + $view['company_name'] = $this->settings_model->get_setting('company_name'); + $this->load->view('user/login', $view); + } + + /** + * Display the logout page. + */ + public function logout() { + $this->load->model('settings_model'); + + $this->session->unset_userdata('user_id'); + $this->session->unset_userdata('user_email'); + $this->session->unset_userdata('role_slug'); + $this->session->unset_userdata('username'); + $this->session->unset_userdata('dest_url'); + + $view['base_url'] = $this->config->item('base_url'); + $view['company_name'] = $this->settings_model->get_setting('company_name'); + $this->load->view('user/logout', $view); + } + + /** + * Display the forgot password page. + */ + public function forgot_password() { + $this->load->model('settings_model'); + $view['base_url'] = $this->config->item('base_url'); + $view['company_name'] = $this->settings_model->get_setting('company_name'); + $this->load->view('user/forgot_password', $view); + } + + public function no_privileges() { + $this->load->model('settings_model'); + $view['base_url'] = $this->config->item('base_url'); + $view['company_name'] = $this->settings_model->get_setting('company_name'); + $this->load->view('user/no_privileges', $view); + } + + /** + * [AJAX] Check whether the user has entered the correct login credentials. + * + * The session data of a logged in user are the following: + * - 'user_id' + * - 'user_email' + * - 'role_slug' + * - 'dest_url' + */ + public function ajax_check_login() { + try { + if (!isset($_POST['username']) || !isset($_POST['password'])) { + throw new Exception('Invalid credentials given!'); + } + + $this->load->model('user_model'); + $user_data = $this->user_model->check_login($_POST['username'], $_POST['password']); + + if ($user_data) { + $this->session->set_userdata($user_data); // Save data on user's session. + echo json_encode(AJAX_SUCCESS); + } else { + echo json_encode(AJAX_FAILURE); + } + + } catch(Exception $exc) { + echo json_encode(array( + 'exceptions' => array(exceptionToJavaScript($exc)) + )); + } + } + + /** + * Regenerate a new password for the current user, only if the username and + * email address given corresond to an existing user in db. + * + * @param string $_POST['username'] + * @param string $_POST['email'] + */ + public function ajax_forgot_password() { + try { + if (!isset($_POST['username']) || !isset($_POST['email'])) { + throw new Exception('You must enter a valid username and email address in ' + . 'order to get a new password!'); + } + + $this->load->model('user_model'); + $this->load->model('settings_model'); + + $new_password = $this->user_model->regenerate_password($_POST['username'], $_POST['email']); + + if ($new_password != FALSE) { + $this->load->library('notifications'); + $company_settings = array( + 'company_name' => $this->settings_model->get_setting('company_name'), + 'company_link' => $this->settings_model->get_setting('company_link'), + 'company_email' => $this->settings_model->get_setting('company_email') + ); + $this->notifications->send_password($new_password, $_POST['email'], $company_settings); + } + + echo ($new_password != FALSE) ? json_encode(AJAX_SUCCESS) : json_encode(AJAX_FAILURE); + } catch(Exception $exc) { + echo json_encode(array( + 'exceptions' => array(exceptionToJavaScript($exc)) + )); + } + } +} + +/* End of file user.php */ +/* Location: ./application/controllers/user.php */ diff --git a/src/assets/css/frontend.css b/src/assets/css/frontend.css index 090338a6..87cbccb8 100644 --- a/src/assets/css/frontend.css +++ b/src/assets/css/frontend.css @@ -13,7 +13,6 @@ root { display: block; } - html, body { height: 100%; @@ -241,6 +240,7 @@ body { margin-bottom: 0; } + /* MOBILE DEVICES ------------------------------------------------------------------------- */ @media(max-width:768px) {