Added the dateFormat value to the GlobalVariables of every backend page.

This commit is contained in:
Alex Tselegidis 2015-12-01 23:39:31 +01:00
parent 284abdfd54
commit c60a0feeaf
7 changed files with 362 additions and 331 deletions

View file

@ -1,302 +1,307 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/* ---------------------------------------------------------------------------- /* ----------------------------------------------------------------------------
* Easy!Appointments - Open Source Web Scheduler * Easy!Appointments - Open Source Web Scheduler
* *
* @package EasyAppointments * @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com> * @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) 2013 - 2015, Alex Tselegidis * @copyright Copyright (c) 2013 - 2015, Alex Tselegidis
* @license http://opensource.org/licenses/GPL-3.0 - GPLv3 * @license http://opensource.org/licenses/GPL-3.0 - GPLv3
* @link http://easyappointments.org * @link http://easyappointments.org
* @since v1.0.0 * @since v1.0.0
* ---------------------------------------------------------------------------- */ * ---------------------------------------------------------------------------- */
/** /**
* Backend Controller * Backend Controller
* *
* @package Controllers * @package Controllers
*/ */
class Backend extends CI_Controller { class Backend extends CI_Controller {
public function __construct() { public function __construct() {
parent::__construct(); parent::__construct();
$this->load->library('session'); $this->load->library('session');
// Set user's selected language. // Set user's selected language.
if ($this->session->userdata('language')) { if ($this->session->userdata('language')) {
$this->config->set_item('language', $this->session->userdata('language')); $this->config->set_item('language', $this->session->userdata('language'));
$this->lang->load('translations', $this->session->userdata('language')); $this->lang->load('translations', $this->session->userdata('language'));
} else { } else {
$this->lang->load('translations', $this->config->item('language')); // default $this->lang->load('translations', $this->config->item('language')); // default
} }
} }
/** /**
* Display the main backend page. * Display the main backend page.
* *
* This method displays the main backend page. All users login permission can * This method displays the main backend page. All users login permission can
* view this page which displays a calendar with the events of the selected * view this page which displays a calendar with the events of the selected
* provider or service. If a user has more priviledges he will see more menus * provider or service. If a user has more priviledges he will see more menus
* at the top of the page. * at the top of the page.
* *
* @param string $appointment_hash If given, the appointment edit dialog will * @param string $appointment_hash If given, the appointment edit dialog will
* appear when the page loads. * appear when the page loads.
*/ */
public function index($appointment_hash = '') { public function index($appointment_hash = '') {
$this->session->set_userdata('dest_url', $this->config->item('base_url') . '/index.php/backend'); $this->session->set_userdata('dest_url', $this->config->item('base_url') . '/index.php/backend');
if (!$this->has_privileges(PRIV_APPOINTMENTS)) return; if (!$this->has_privileges(PRIV_APPOINTMENTS)) return;
$this->load->model('appointments_model'); $this->load->model('appointments_model');
$this->load->model('providers_model'); $this->load->model('providers_model');
$this->load->model('services_model'); $this->load->model('services_model');
$this->load->model('customers_model'); $this->load->model('customers_model');
$this->load->model('settings_model'); $this->load->model('settings_model');
$this->load->model('roles_model'); $this->load->model('roles_model');
$this->load->model('user_model'); $this->load->model('user_model');
$this->load->model('secretaries_model'); $this->load->model('secretaries_model');
$view['base_url'] = $this->config->item('base_url'); $view['base_url'] = $this->config->item('base_url');
$view['user_display_name'] = $this->user_model->get_user_display_name($this->session->userdata('user_id')); $view['user_display_name'] = $this->user_model->get_user_display_name($this->session->userdata('user_id'));
$view['active_menu'] = PRIV_APPOINTMENTS; $view['active_menu'] = PRIV_APPOINTMENTS;
$view['book_advance_timeout'] = $this->settings_model->get_setting('book_advance_timeout'); $view['book_advance_timeout'] = $this->settings_model->get_setting('book_advance_timeout');
$view['company_name'] = $this->settings_model->get_setting('company_name'); $view['date_format'] = $this->settings_model->get_setting('date_format');
$view['available_providers'] = $this->providers_model->get_available_providers(); $view['company_name'] = $this->settings_model->get_setting('company_name');
$view['available_services'] = $this->services_model->get_available_services(); $view['available_providers'] = $this->providers_model->get_available_providers();
$view['customers'] = $this->customers_model->get_batch(); $view['available_services'] = $this->services_model->get_available_services();
$this->set_user_data($view); $view['customers'] = $this->customers_model->get_batch();
$this->set_user_data($view);
if ($this->session->userdata('role_slug') == DB_SLUG_SECRETARY) {
$secretary = $this->secretaries_model->get_row($this->session->userdata('user_id')); if ($this->session->userdata('role_slug') == DB_SLUG_SECRETARY) {
$view['secretary_providers'] = $secretary['providers']; $secretary = $this->secretaries_model->get_row($this->session->userdata('user_id'));
} else { $view['secretary_providers'] = $secretary['providers'];
$view['secretary_providers'] = array(); } else {
} $view['secretary_providers'] = array();
}
$results = $this->appointments_model->get_batch(array('hash' => $appointment_hash));
if ($appointment_hash != '' && count($results) > 0) { $results = $this->appointments_model->get_batch(array('hash' => $appointment_hash));
$appointment = $results[0]; if ($appointment_hash != '' && count($results) > 0) {
$appointment['customer'] = $this->customers_model->get_row($appointment['id_users_customer']); $appointment = $results[0];
$view['edit_appointment'] = $appointment; // This will display the appointment edit dialog on page load. $appointment['customer'] = $this->customers_model->get_row($appointment['id_users_customer']);
} else { $view['edit_appointment'] = $appointment; // This will display the appointment edit dialog on page load.
$view['edit_appointment'] = NULL; } else {
} $view['edit_appointment'] = NULL;
}
$this->load->view('backend/header', $view);
$this->load->view('backend/calendar', $view); $this->load->view('backend/header', $view);
$this->load->view('backend/footer', $view); $this->load->view('backend/calendar', $view);
} $this->load->view('backend/footer', $view);
}
/**
* Display the backend customers page. /**
* * Display the backend customers page.
* In this page the user can manage all the customer records of the system. *
*/ * In this page the user can manage all the customer records of the system.
public function customers() { */
$this->session->set_userdata('dest_url', $this->config->item('base_url') . '/index.php/backend/customers'); public function customers() {
if (!$this->has_privileges(PRIV_CUSTOMERS)) return; $this->session->set_userdata('dest_url', $this->config->item('base_url') . '/index.php/backend/customers');
if (!$this->has_privileges(PRIV_CUSTOMERS)) return;
$this->load->model('providers_model');
$this->load->model('customers_model'); $this->load->model('providers_model');
$this->load->model('services_model'); $this->load->model('customers_model');
$this->load->model('settings_model'); $this->load->model('services_model');
$this->load->model('user_model'); $this->load->model('settings_model');
$this->load->model('user_model');
$view['base_url'] = $this->config->item('base_url');
$view['user_display_name'] = $this->user_model->get_user_display_name($this->session->userdata('user_id')); $view['base_url'] = $this->config->item('base_url');
$view['active_menu'] = PRIV_CUSTOMERS; $view['user_display_name'] = $this->user_model->get_user_display_name($this->session->userdata('user_id'));
$view['company_name'] = $this->settings_model->get_setting('company_name'); $view['active_menu'] = PRIV_CUSTOMERS;
$view['customers'] = $this->customers_model->get_batch(); $view['company_name'] = $this->settings_model->get_setting('company_name');
$view['available_providers'] = $this->providers_model->get_available_providers(); $view['date_format'] = $this->settings_model->get_setting('date_format');
$view['available_services'] = $this->services_model->get_available_services(); $view['customers'] = $this->customers_model->get_batch();
$this->set_user_data($view); $view['available_providers'] = $this->providers_model->get_available_providers();
$view['available_services'] = $this->services_model->get_available_services();
$this->load->view('backend/header', $view); $this->set_user_data($view);
$this->load->view('backend/customers', $view);
$this->load->view('backend/footer', $view); $this->load->view('backend/header', $view);
} $this->load->view('backend/customers', $view);
$this->load->view('backend/footer', $view);
/** }
* Displays the backend services page.
* /**
* Here the admin user will be able to organize and create the services * Displays the backend services page.
* that the user will be able to book appointments in frontend. *
* * Here the admin user will be able to organize and create the services
* NOTICE: The services that each provider is able to service is managed * that the user will be able to book appointments in frontend.
* from the backend services page. *
*/ * NOTICE: The services that each provider is able to service is managed
public function services() { * from the backend services page.
$this->session->set_userdata('dest_url', $this->config->item('base_url') . '/index.php/backend/services'); */
if (!$this->has_privileges(PRIV_SERVICES)) return; public function services() {
$this->session->set_userdata('dest_url', $this->config->item('base_url') . '/index.php/backend/services');
$this->load->model('customers_model'); if (!$this->has_privileges(PRIV_SERVICES)) return;
$this->load->model('services_model');
$this->load->model('settings_model'); $this->load->model('customers_model');
$this->load->model('user_model'); $this->load->model('services_model');
$this->load->model('settings_model');
$view['base_url'] = $this->config->item('base_url'); $this->load->model('user_model');
$view['user_display_name'] = $this->user_model->get_user_display_name($this->session->userdata('user_id'));
$view['active_menu'] = PRIV_SERVICES; $view['base_url'] = $this->config->item('base_url');
$view['company_name'] = $this->settings_model->get_setting('company_name'); $view['user_display_name'] = $this->user_model->get_user_display_name($this->session->userdata('user_id'));
$view['services'] = $this->services_model->get_batch(); $view['active_menu'] = PRIV_SERVICES;
$view['categories'] = $this->services_model->get_all_categories(); $view['company_name'] = $this->settings_model->get_setting('company_name');
$this->set_user_data($view); $view['date_format'] = $this->settings_model->get_setting('date_format');
$view['services'] = $this->services_model->get_batch();
$this->load->view('backend/header', $view); $view['categories'] = $this->services_model->get_all_categories();
$this->load->view('backend/services', $view); $this->set_user_data($view);
$this->load->view('backend/footer', $view);
} $this->load->view('backend/header', $view);
$this->load->view('backend/services', $view);
/** $this->load->view('backend/footer', $view);
* Display the backend users page. }
*
* In this page the admin user will be able to manage the system users. /**
* By this, we mean the provider, secretary and admin users. This is also * Display the backend users page.
* the page where the admin defines which service can each provider provide. *
*/ * In this page the admin user will be able to manage the system users.
public function users() { * By this, we mean the provider, secretary and admin users. This is also
$this->session->set_userdata('dest_url', $this->config->item('base_url') . '/index.php/backend/users'); * the page where the admin defines which service can each provider provide.
if (!$this->has_privileges(PRIV_USERS)) return; */
public function users() {
$this->load->model('providers_model'); $this->session->set_userdata('dest_url', $this->config->item('base_url') . '/index.php/backend/users');
$this->load->model('secretaries_model'); if (!$this->has_privileges(PRIV_USERS)) return;
$this->load->model('admins_model');
$this->load->model('services_model'); $this->load->model('providers_model');
$this->load->model('settings_model'); $this->load->model('secretaries_model');
$this->load->model('user_model'); $this->load->model('admins_model');
$this->load->model('services_model');
$view['base_url'] = $this->config->item('base_url'); $this->load->model('settings_model');
$view['user_display_name'] = $this->user_model->get_user_display_name($this->session->userdata('user_id')); $this->load->model('user_model');
$view['active_menu'] = PRIV_USERS;
$view['company_name'] = $this->settings_model->get_setting('company_name'); $view['base_url'] = $this->config->item('base_url');
$view['admins'] = $this->admins_model->get_batch(); $view['user_display_name'] = $this->user_model->get_user_display_name($this->session->userdata('user_id'));
$view['providers'] = $this->providers_model->get_batch(); $view['active_menu'] = PRIV_USERS;
$view['secretaries'] = $this->secretaries_model->get_batch(); $view['company_name'] = $this->settings_model->get_setting('company_name');
$view['services'] = $this->services_model->get_batch(); $view['date_format'] = $this->settings_model->get_setting('date_format');
$view['working_plan'] = $this->settings_model->get_setting('company_working_plan'); $view['admins'] = $this->admins_model->get_batch();
$this->set_user_data($view); $view['providers'] = $this->providers_model->get_batch();
$view['secretaries'] = $this->secretaries_model->get_batch();
$this->load->view('backend/header', $view); $view['services'] = $this->services_model->get_batch();
$this->load->view('backend/users', $view); $view['working_plan'] = $this->settings_model->get_setting('company_working_plan');
$this->load->view('backend/footer', $view); $this->set_user_data($view);
}
$this->load->view('backend/header', $view);
/** $this->load->view('backend/users', $view);
* Display the user/system settings. $this->load->view('backend/footer', $view);
* }
* This page will display the user settings (name, password etc). If current user is
* an administrator, then he will be able to make change to the current Easy!Appointment /**
* installation (core settings like company name, book timeout etc). * Display the user/system settings.
*/ *
public function settings() { * This page will display the user settings (name, password etc). If current user is
$this->session->set_userdata('dest_url', $this->config->item('base_url') . '/index.php/backend/settings'); * an administrator, then he will be able to make change to the current Easy!Appointment
if (!$this->has_privileges(PRIV_SYSTEM_SETTINGS, FALSE) * installation (core settings like company name, book timeout etc).
&& !$this->has_privileges(PRIV_USER_SETTINGS)) return; */
public function settings() {
$this->load->model('settings_model'); $this->session->set_userdata('dest_url', $this->config->item('base_url') . '/index.php/backend/settings');
$this->load->model('user_model'); if (!$this->has_privileges(PRIV_SYSTEM_SETTINGS, FALSE)
&& !$this->has_privileges(PRIV_USER_SETTINGS)) return;
$this->load->library('session');
$user_id = $this->session->userdata('user_id'); $this->load->model('settings_model');
$this->load->model('user_model');
$view['base_url'] = $this->config->item('base_url');
$view['user_display_name'] = $this->user_model->get_user_display_name($user_id); $this->load->library('session');
$view['active_menu'] = PRIV_SYSTEM_SETTINGS; $user_id = $this->session->userdata('user_id');
$view['company_name'] = $this->settings_model->get_setting('company_name');
$view['role_slug'] = $this->session->userdata('role_slug'); $view['base_url'] = $this->config->item('base_url');
$view['system_settings'] = $this->settings_model->get_settings(); $view['user_display_name'] = $this->user_model->get_user_display_name($user_id);
$view['user_settings'] = $this->user_model->get_settings($user_id); $view['active_menu'] = PRIV_SYSTEM_SETTINGS;
$this->set_user_data($view); $view['company_name'] = $this->settings_model->get_setting('company_name');
$view['date_format'] = $this->settings_model->get_setting('date_format');
$this->load->view('backend/header', $view); $view['role_slug'] = $this->session->userdata('role_slug');
$this->load->view('backend/settings', $view); $view['system_settings'] = $this->settings_model->get_settings();
$this->load->view('backend/footer', $view); $view['user_settings'] = $this->user_model->get_settings($user_id);
} $this->set_user_data($view);
/** $this->load->view('backend/header', $view);
* Check whether current user is logged in and has the required privileges to $this->load->view('backend/settings', $view);
* view a page. $this->load->view('backend/footer', $view);
* }
* The backend page requires different privileges from the users to display pages. Not all
* pages are avaiable to all users. For example secretaries should not be able to edit the /**
* system users. * Check whether current user is logged in and has the required privileges to
* * view a page.
* @see Constant Definition In application/config/constants.php *
* * The backend page requires different privileges from the users to display pages. Not all
* @param string $page This argument must match the roles field names of each section * pages are avaiable to all users. For example secretaries should not be able to edit the
* (eg "appointments", "users" ...). * system users.
* @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 * @see Constant Definition In application/config/constants.php
* 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 * @param string $page This argument must match the roles field names of each section
* not. If the user is not logged in then he will be prompted to log in. If he hasn't the * (eg "appointments", "users" ...).
* required privileges then an info message will be displayed. * @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
private function has_privileges($page, $redirect = TRUE) { * to another page. Set this argument to FALSE when using ajax.
// Check if user is logged in. * @return bool Returns whether the user has the required privileges to view the page or
$user_id = $this->session->userdata('user_id'); * not. If the user is not logged in then he will be prompted to log in. If he hasn't the
if ($user_id == FALSE) { // User not logged in, display the login view. * required privileges then an info message will be displayed.
if ($redirect) { */
header('Location: ' . $this->config->item('base_url') . '/index.php/user/login'); private function has_privileges($page, $redirect = TRUE) {
} // Check if user is logged in.
return FALSE; $user_id = $this->session->userdata('user_id');
} if ($user_id == FALSE) { // User not logged in, display the login view.
if ($redirect) {
// Check if the user has the required privileges for viewing the selected page. header('Location: ' . $this->config->item('base_url') . '/index.php/user/login');
$role_slug = $this->session->userdata('role_slug'); }
$role_priv = $this->db->get_where('ea_roles', array('slug' => $role_slug))->row_array(); return FALSE;
if ($role_priv[$page] < PRIV_VIEW) { // User does not have the permission to view the page. }
if ($redirect) {
header('Location: ' . $this->config->item('base_url') . '/index.php/user/no_privileges'); // Check if the user has the required privileges for viewing the selected page.
} $role_slug = $this->session->userdata('role_slug');
return FALSE; $role_priv = $this->db->get_where('ea_roles', array('slug' => $role_slug))->row_array();
} if ($role_priv[$page] < PRIV_VIEW) { // User does not have the permission to view the page.
if ($redirect) {
return TRUE; header('Location: ' . $this->config->item('base_url') . '/index.php/user/no_privileges');
} }
return FALSE;
/** }
* Set the user data in order to be available at the view and js code.
* return TRUE;
* @param array $view Contains the view data. }
*/
public function set_user_data(&$view) { /**
$this->load->model('roles_model'); * Set the user data in order to be available at the view and js code.
*
// Get privileges * @param array $view Contains the view data.
$view['user_id'] = $this->session->userdata('user_id'); */
$view['user_email'] = $this->session->userdata('user_email'); public function set_user_data(&$view) {
$view['role_slug'] = $this->session->userdata('role_slug'); $this->load->model('roles_model');
$view['privileges'] = $this->roles_model->get_privileges($this->session->userdata('role_slug'));
} // Get privileges
$view['user_id'] = $this->session->userdata('user_id');
/** $view['user_email'] = $this->session->userdata('user_email');
* This method will update the installation to the latest available $view['role_slug'] = $this->session->userdata('role_slug');
* version in the server. IMPORTANT: The code files must exist in the $view['privileges'] = $this->roles_model->get_privileges($this->session->userdata('role_slug'));
* server, this method will not fetch any new files but will update }
* the database schema.
* /**
* This method can be used either by loading the page in the browser * This method will update the installation to the latest available
* or by an ajax request. But it will answer with json encoded data. * version in the server. IMPORTANT: The code files must exist in the
*/ * server, this method will not fetch any new files but will update
public function update() { * the database schema.
try { *
if (!$this->has_privileges(PRIV_SYSTEM_SETTINGS, TRUE)) * This method can be used either by loading the page in the browser
throw new Exception('You do not have the required privileges for this task!'); * or by an ajax request. But it will answer with json encoded data.
*/
$this->load->library('migration'); public function update() {
try {
if (!$this->migration->current()) if (!$this->has_privileges(PRIV_SYSTEM_SETTINGS, TRUE))
throw new Exception($this->migration->error_string()); throw new Exception('You do not have the required privileges for this task!');
echo json_encode(AJAX_SUCCESS); $this->load->library('migration');
} catch(Exception $exc) { if (!$this->migration->current())
echo json_encode(array( throw new Exception($this->migration->error_string());
'exceptions' => array(exceptionToJavaScript($exc))
)); echo json_encode(AJAX_SUCCESS);
}
} } catch(Exception $exc) {
} echo json_encode(array(
'exceptions' => array(exceptionToJavaScript($exc))
/* End of file backend.php */ ));
/* Location: ./application/controllers/backend.php */ }
}
}
/* End of file backend.php */
/* Location: ./application/controllers/backend.php */

View file

@ -17,6 +17,7 @@
'availableServices' : <?php echo json_encode($available_services); ?>, 'availableServices' : <?php echo json_encode($available_services); ?>,
'baseUrl' : <?php echo '"' . $base_url . '"'; ?>, 'baseUrl' : <?php echo '"' . $base_url . '"'; ?>,
'bookAdvanceTimeout' : <?php echo $book_advance_timeout; ?>, 'bookAdvanceTimeout' : <?php echo $book_advance_timeout; ?>,
'dateFormat' : <?php echo json_encode($date_format); ?>,
'editAppointment' : <?php echo json_encode($edit_appointment); ?>, 'editAppointment' : <?php echo json_encode($edit_appointment); ?>,
'customers' : <?php echo json_encode($customers); ?>, 'customers' : <?php echo json_encode($customers); ?>,
'secretaryProviders' : <?php echo json_encode($secretary_providers); ?>, 'secretaryProviders' : <?php echo json_encode($secretary_providers); ?>,

View file

@ -8,10 +8,11 @@
var GlobalVariables = { var GlobalVariables = {
'csrfToken': <?php echo json_encode($this->security->get_csrf_hash()); ?>, 'csrfToken': <?php echo json_encode($this->security->get_csrf_hash()); ?>,
'availableProviders': <?php echo json_encode($available_providers); ?>, 'availableProviders': <?php echo json_encode($available_providers); ?>,
'availableServices': <?php echo json_encode($available_services); ?>, 'availableServices' : <?php echo json_encode($available_services); ?>,
'baseUrl': <?php echo '"' . $base_url . '"'; ?>, 'dateFormat' : <?php echo json_encode($date_format); ?>,
'customers': <?php echo json_encode($customers); ?>, 'baseUrl' : <?php echo '"' . $base_url . '"'; ?>,
'user' : { 'customers' : <?php echo json_encode($customers); ?>,
'user' : {
'id' : <?php echo $user_id; ?>, 'id' : <?php echo $user_id; ?>,
'email' : <?php echo '"' . $user_email . '"'; ?>, 'email' : <?php echo '"' . $user_email . '"'; ?>,
'role_slug' : <?php echo '"' . $role_slug . '"'; ?>, 'role_slug' : <?php echo '"' . $role_slug . '"'; ?>,

View file

@ -3,11 +3,12 @@
<script type="text/javascript"> <script type="text/javascript">
var GlobalVariables = { var GlobalVariables = {
'csrfToken': <?php echo json_encode($this->security->get_csrf_hash()); ?>, 'csrfToken' : <?php echo json_encode($this->security->get_csrf_hash()); ?>,
'baseUrl': <?php echo '"' . $base_url . '"'; ?>, 'baseUrl' : <?php echo '"' . $base_url . '"'; ?>,
'services': <?php echo json_encode($services); ?>, 'dateFormat' : <?php echo json_encode($date_format); ?>,
'categories': <?php echo json_encode($categories); ?>, 'services' : <?php echo json_encode($services); ?>,
'user' : { 'categories' : <?php echo json_encode($categories); ?>,
'user' : {
'id' : <?php echo $user_id; ?>, 'id' : <?php echo $user_id; ?>,
'email' : <?php echo '"' . $user_email . '"'; ?>, 'email' : <?php echo '"' . $user_email . '"'; ?>,
'role_slug' : <?php echo '"' . $role_slug . '"'; ?>, 'role_slug' : <?php echo '"' . $role_slug . '"'; ?>,

View file

@ -9,14 +9,15 @@
<script type="text/javascript"> <script type="text/javascript">
var GlobalVariables = { var GlobalVariables = {
'csrfToken': <?php echo json_encode($this->security->get_csrf_hash()); ?>, 'csrfToken' : <?php echo json_encode($this->security->get_csrf_hash()); ?>,
'baseUrl': <?php echo '"' . $base_url . '"'; ?>, 'baseUrl' : <?php echo '"' . $base_url . '"'; ?>,
'userSlug': <?php echo '"' . $role_slug . '"'; ?>, 'dateFormat' : <?php echo json_encode($date_format); ?>,
'settings': { 'userSlug' : <?php echo '"' . $role_slug . '"'; ?>,
'system': <?php echo json_encode($system_settings); ?>, 'settings' : {
'user': <?php echo json_encode($user_settings); ?> 'system' : <?php echo json_encode($system_settings); ?>,
'user' : <?php echo json_encode($user_settings); ?>
}, },
'user' : { 'user' : {
'id' : <?php echo $user_id; ?>, 'id' : <?php echo $user_id; ?>,
'email' : <?php echo '"' . $user_email . '"'; ?>, 'email' : <?php echo '"' . $user_email . '"'; ?>,
'role_slug' : <?php echo '"' . $role_slug . '"'; ?>, 'role_slug' : <?php echo '"' . $role_slug . '"'; ?>,

View file

@ -18,14 +18,15 @@
<script type="text/javascript"> <script type="text/javascript">
var GlobalVariables = { var GlobalVariables = {
'csrfToken': <?php echo json_encode($this->security->get_csrf_hash()); ?>, 'csrfToken' : <?php echo json_encode($this->security->get_csrf_hash()); ?>,
'baseUrl': <?php echo '"' . $base_url . '"'; ?>, 'baseUrl' : <?php echo '"' . $base_url . '"'; ?>,
'admins': <?php echo json_encode($admins); ?>, 'dateFormat' : <?php echo json_encode($date_format); ?>,
'providers': <?php echo json_encode($providers); ?>, 'admins' : <?php echo json_encode($admins); ?>,
'secretaries': <?php echo json_encode($secretaries); ?>, 'providers' : <?php echo json_encode($providers); ?>,
'services': <?php echo json_encode($services); ?>, 'secretaries' : <?php echo json_encode($secretaries); ?>,
'workingPlan': $.parseJSON(<?php echo json_encode($working_plan); ?>), 'services' : <?php echo json_encode($services); ?>,
'user' : { 'workingPlan' : $.parseJSON(<?php echo json_encode($working_plan); ?>),
'user' : {
'id' : <?php echo $user_id; ?>, 'id' : <?php echo $user_id; ?>,
'email' : <?php echo '"' . $user_email . '"'; ?>, 'email' : <?php echo '"' . $user_email . '"'; ?>,
'role_slug' : <?php echo '"' . $role_slug . '"'; ?>, 'role_slug' : <?php echo '"' . $role_slug . '"'; ?>,

View file

@ -33,6 +33,31 @@ var BackendCalendar = {
initialize: function(defaultEventHandlers) { initialize: function(defaultEventHandlers) {
if (defaultEventHandlers === undefined) defaultEventHandlers = true; if (defaultEventHandlers === undefined) defaultEventHandlers = true;
// Dynamic Date Formats
var columnFormat = {};
switch(GlobalVariables.dateFormat) {
case 'DMY':
columnFormat = {
'month': 'ddd',
'week': 'ddd dd/MM',
'day': 'dddd dd/MM'
};
break;
case 'MDY':
case 'YMD':
columnFormat = {
'month': 'ddd',
'week': 'ddd MM/dd',
'day': 'dddd MM/dd'
};
break;
default:
throw new Error('Invalid date format setting provided!', GlobalVariables.dateFormat);
}
// Initialize page calendar // Initialize page calendar
$('#calendar').fullCalendar({ $('#calendar').fullCalendar({
'defaultView': 'agendaWeek', 'defaultView': 'agendaWeek',
@ -44,11 +69,7 @@ var BackendCalendar = {
'axisFormat': 'HH:mm', 'axisFormat': 'HH:mm',
'timeFormat': 'HH:mm{ - HH:mm}', 'timeFormat': 'HH:mm{ - HH:mm}',
'allDayText': EALang['all_day'], 'allDayText': EALang['all_day'],
'columnFormat': { 'columnFormat': columnFormat,
'month': 'ddd',
'week': 'ddd d/M',
'day': 'dddd d/M'
},
'titleFormat': { 'titleFormat': {
'month': 'MMMM yyyy', 'month': 'MMMM yyyy',
'week': "MMMM d[ yyyy]{ '&#8212;'[ MMM] d, yyyy}", 'week': "MMMM d[ yyyy]{ '&#8212;'[ MMM] d, yyyy}",