Added extra line at the end of the files as configured in the .editorconfig file.
This commit is contained in:
parent
636f399c91
commit
a770a69660
16 changed files with 2665 additions and 2665 deletions
|
@ -1,340 +1,340 @@
|
||||||
<?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 - 2016, Alex Tselegidis
|
* @copyright Copyright (c) 2013 - 2016, 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
|
||||||
* ---------------------------------------------------------------------------- */
|
* ---------------------------------------------------------------------------- */
|
||||||
|
|
||||||
// Google API PHP Client is necessary to perform sync operations.
|
// Google API PHP Client is necessary to perform sync operations.
|
||||||
require_once __DIR__ . '/external/google-api-php-client/Google_Client.php';
|
require_once __DIR__ . '/external/google-api-php-client/Google_Client.php';
|
||||||
require_once __DIR__ . '/external/google-api-php-client/contrib/Google_CalendarService.php';
|
require_once __DIR__ . '/external/google-api-php-client/contrib/Google_CalendarService.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Google Synchronization Class
|
* Google Synchronization Class
|
||||||
*
|
*
|
||||||
* This class implements all the core synchronization between the Google Calendar
|
* This class implements all the core synchronization between the Google Calendar
|
||||||
* and the Easy!Appointments system. Do not place any model handling inside this
|
* and the Easy!Appointments system. Do not place any model handling inside this
|
||||||
* library.
|
* library.
|
||||||
*
|
*
|
||||||
* @package Libraries
|
* @package Libraries
|
||||||
*/
|
*/
|
||||||
class Google_Sync {
|
class Google_Sync {
|
||||||
private $CI;
|
private $CI;
|
||||||
private $client;
|
private $client;
|
||||||
private $service;
|
private $service;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Constructor
|
* Class Constructor
|
||||||
*
|
*
|
||||||
* This method initializes the Google client class and the Calendar service
|
* This method initializes the Google client class and the Calendar service
|
||||||
* class so that they can be used by the other methods.
|
* class so that they can be used by the other methods.
|
||||||
*/
|
*/
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->CI =& get_instance();
|
$this->CI =& get_instance();
|
||||||
|
|
||||||
if (!isset($_SESSION)) {
|
if (!isset($_SESSION)) {
|
||||||
@session_start();
|
@session_start();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize google client and calendar service.
|
// Initialize google client and calendar service.
|
||||||
$this->client = new Google_Client();
|
$this->client = new Google_Client();
|
||||||
$this->client->setUseObjects(true);
|
$this->client->setUseObjects(true);
|
||||||
|
|
||||||
$this->client->setApplicationName(Config::GOOGLE_PRODUCT_NAME);
|
$this->client->setApplicationName(Config::GOOGLE_PRODUCT_NAME);
|
||||||
$this->client->setClientId(Config::GOOGLE_CLIENT_ID);
|
$this->client->setClientId(Config::GOOGLE_CLIENT_ID);
|
||||||
$this->client->setClientSecret(Config::GOOGLE_CLIENT_SECRET);
|
$this->client->setClientSecret(Config::GOOGLE_CLIENT_SECRET);
|
||||||
$this->client->setDeveloperKey(Config::GOOGLE_API_KEY);
|
$this->client->setDeveloperKey(Config::GOOGLE_API_KEY);
|
||||||
$this->client->setRedirectUri($this->CI->config->item('base_url') . '/index.php/google/oauth_callback');
|
$this->client->setRedirectUri($this->CI->config->item('base_url') . '/index.php/google/oauth_callback');
|
||||||
|
|
||||||
$this->service = new Google_CalendarService($this->client);
|
$this->service = new Google_CalendarService($this->client);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Google OAuth authorization url.
|
* Get Google OAuth authorization url.
|
||||||
*
|
*
|
||||||
* This url must be used to redirect the user to the Google user consent page,
|
* This url must be used to redirect the user to the Google user consent page,
|
||||||
* where the user grants access to his data for the Easy!Appointments app.
|
* where the user grants access to his data for the Easy!Appointments app.
|
||||||
*/
|
*/
|
||||||
public function get_auth_url() {
|
public function get_auth_url() {
|
||||||
// "max_auth_age" is needed because the user needs to always log in
|
// "max_auth_age" is needed because the user needs to always log in
|
||||||
// and not use an existing session.
|
// and not use an existing session.
|
||||||
return $this->client->createAuthUrl() . '&max_auth_age=0';
|
return $this->client->createAuthUrl() . '&max_auth_age=0';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Authenticate the Google API usage.
|
* Authenticate the Google API usage.
|
||||||
*
|
*
|
||||||
* When the user grants consent for his data usage, google is going to redirect
|
* When the user grants consent for his data usage, google is going to redirect
|
||||||
* the browser back to the given redirect url. There a authentication code is
|
* the browser back to the given redirect url. There a authentication code is
|
||||||
* provided. Using this code, we can authenticate the API usage and store the
|
* provided. Using this code, we can authenticate the API usage and store the
|
||||||
* token information to the database.
|
* token information to the database.
|
||||||
*
|
*
|
||||||
* @see Google Controller
|
* @see Google Controller
|
||||||
*/
|
*/
|
||||||
public function authenticate($auth_code) {
|
public function authenticate($auth_code) {
|
||||||
$this->client->authenticate($auth_code);
|
$this->client->authenticate($auth_code);
|
||||||
return $this->client->getAccessToken();
|
return $this->client->getAccessToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Refresh the Google Client access token.
|
* Refresh the Google Client access token.
|
||||||
*
|
*
|
||||||
* This method must be executed every time we need to make actions on a
|
* This method must be executed every time we need to make actions on a
|
||||||
* provider's Google Calendar account. A new token is necessary and the
|
* provider's Google Calendar account. A new token is necessary and the
|
||||||
* only way to get it is to use the stored refresh token that was provided
|
* only way to get it is to use the stored refresh token that was provided
|
||||||
* when the provider granted consent to Easy!Appointments for use his
|
* when the provider granted consent to Easy!Appointments for use his
|
||||||
* Google Calendar account.
|
* Google Calendar account.
|
||||||
*
|
*
|
||||||
* @param string $refresh_token The provider's refresh token. This value is
|
* @param string $refresh_token The provider's refresh token. This value is
|
||||||
* stored in the database and used every time we need to make actions to his
|
* stored in the database and used every time we need to make actions to his
|
||||||
* Google Caledar account.
|
* Google Caledar account.
|
||||||
*/
|
*/
|
||||||
public function refresh_token($refresh_token) {
|
public function refresh_token($refresh_token) {
|
||||||
$this->client->refreshToken($refresh_token);
|
$this->client->refreshToken($refresh_token);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an appointment record to its providers Google Calendar account.
|
* Add an appointment record to its providers Google Calendar account.
|
||||||
*
|
*
|
||||||
* This method checks whether the appointment's provider has enabled the Google
|
* This method checks whether the appointment's provider has enabled the Google
|
||||||
* Sync utility of Easy!Appointments and the stored access token is still valid.
|
* Sync utility of Easy!Appointments and the stored access token is still valid.
|
||||||
* If yes, the selected appointment record is going to be added to the Google
|
* If yes, the selected appointment record is going to be added to the Google
|
||||||
* Calendar account.
|
* Calendar account.
|
||||||
*
|
*
|
||||||
* @param array $appointment Contains the appointment record data.
|
* @param array $appointment Contains the appointment record data.
|
||||||
* @param array $provider Contains the provider record data.
|
* @param array $provider Contains the provider record data.
|
||||||
* @param array $service Contains the service record data.
|
* @param array $service Contains the service record data.
|
||||||
* @param array $customer Contains the customer recod data.
|
* @param array $customer Contains the customer recod data.
|
||||||
* @parma array $company_settings Contains some company settings that are used
|
* @parma array $company_settings Contains some company settings that are used
|
||||||
* by this method. By the time the following values must be in the array:
|
* by this method. By the time the following values must be in the array:
|
||||||
* 'company_name'.
|
* 'company_name'.
|
||||||
* @return Google_Event Returns the Google_Event class object.
|
* @return Google_Event Returns the Google_Event class object.
|
||||||
*/
|
*/
|
||||||
public function add_appointment($appointment, $provider, $service, $customer, $company_settings) {
|
public function add_appointment($appointment, $provider, $service, $customer, $company_settings) {
|
||||||
$this->CI->load->helper('general');
|
$this->CI->load->helper('general');
|
||||||
|
|
||||||
$event = new Google_Event();
|
$event = new Google_Event();
|
||||||
$event->setSummary(($service != NULL) ? $service['name'] : 'Unavailable');
|
$event->setSummary(($service != NULL) ? $service['name'] : 'Unavailable');
|
||||||
$event->setLocation($company_settings['company_name']);
|
$event->setLocation($company_settings['company_name']);
|
||||||
|
|
||||||
$start = new Google_EventDateTime();
|
$start = new Google_EventDateTime();
|
||||||
$start->setDateTime(date3339(strtotime($appointment['start_datetime'])));
|
$start->setDateTime(date3339(strtotime($appointment['start_datetime'])));
|
||||||
$event->setStart($start);
|
$event->setStart($start);
|
||||||
|
|
||||||
$end = new Google_EventDateTime();
|
$end = new Google_EventDateTime();
|
||||||
$end->setDateTime(date3339(strtotime($appointment['end_datetime'])));
|
$end->setDateTime(date3339(strtotime($appointment['end_datetime'])));
|
||||||
$event->setEnd($end);
|
$event->setEnd($end);
|
||||||
|
|
||||||
$event->attendees = array();
|
$event->attendees = array();
|
||||||
|
|
||||||
$event_provider = new Google_EventAttendee();
|
$event_provider = new Google_EventAttendee();
|
||||||
$event_provider->setDisplayName($provider['first_name'] . ' '
|
$event_provider->setDisplayName($provider['first_name'] . ' '
|
||||||
. $provider['last_name']);
|
. $provider['last_name']);
|
||||||
$event_provider->setEmail($provider['email']);
|
$event_provider->setEmail($provider['email']);
|
||||||
$event->attendees[] = $event_provider;
|
$event->attendees[] = $event_provider;
|
||||||
|
|
||||||
if ($customer != NULL) {
|
if ($customer != NULL) {
|
||||||
$event_customer = new Google_EventAttendee();
|
$event_customer = new Google_EventAttendee();
|
||||||
$event_customer->setDisplayName($customer['first_name'] . ' '
|
$event_customer->setDisplayName($customer['first_name'] . ' '
|
||||||
. $customer['last_name']);
|
. $customer['last_name']);
|
||||||
$event_customer->setEmail($customer['email']);
|
$event_customer->setEmail($customer['email']);
|
||||||
$event->attendees[] = $event_customer;
|
$event->attendees[] = $event_customer;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the new event to the google calendar.
|
// Add the new event to the google calendar.
|
||||||
$created_event = $this->service->events->insert($provider['settings']['google_calendar'], $event);
|
$created_event = $this->service->events->insert($provider['settings']['google_calendar'], $event);
|
||||||
|
|
||||||
return $created_event;
|
return $created_event;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update an existing appointment that is already synced with Google Calendar.
|
* Update an existing appointment that is already synced with Google Calendar.
|
||||||
*
|
*
|
||||||
* This method updates the google calendar event item that is connected with the
|
* This method updates the google calendar event item that is connected with the
|
||||||
* provided appointment record of Easy!Appointments.
|
* provided appointment record of Easy!Appointments.
|
||||||
*
|
*
|
||||||
* @param array $appointment Contains the appointment record data.
|
* @param array $appointment Contains the appointment record data.
|
||||||
* @param array $provider Contains the provider record data.
|
* @param array $provider Contains the provider record data.
|
||||||
* @param array $service Contains the service record data.
|
* @param array $service Contains the service record data.
|
||||||
* @param array $customer Contains the customer recod data.
|
* @param array $customer Contains the customer recod data.
|
||||||
* @parma array $company_settings Contains some company settings that are used
|
* @parma array $company_settings Contains some company settings that are used
|
||||||
* by this method. By the time the following values must be in the array:
|
* by this method. By the time the following values must be in the array:
|
||||||
* 'company_name'.
|
* 'company_name'.
|
||||||
* @return Google_Event Returns the Google_Event class object.
|
* @return Google_Event Returns the Google_Event class object.
|
||||||
*/
|
*/
|
||||||
public function update_appointment($appointment, $provider, $service, $customer, $company_settings) {
|
public function update_appointment($appointment, $provider, $service, $customer, $company_settings) {
|
||||||
$this->CI->load->helper('general');
|
$this->CI->load->helper('general');
|
||||||
|
|
||||||
$event = $this->service->events->get($provider['settings']['google_calendar'], $appointment['id_google_calendar']);
|
$event = $this->service->events->get($provider['settings']['google_calendar'], $appointment['id_google_calendar']);
|
||||||
|
|
||||||
$event->setSummary($service['name']);
|
$event->setSummary($service['name']);
|
||||||
$event->setLocation($company_settings['company_name']);
|
$event->setLocation($company_settings['company_name']);
|
||||||
|
|
||||||
$start = new Google_EventDateTime();
|
$start = new Google_EventDateTime();
|
||||||
$start->setDateTime(date3339(strtotime($appointment['start_datetime'])));
|
$start->setDateTime(date3339(strtotime($appointment['start_datetime'])));
|
||||||
$event->setStart($start);
|
$event->setStart($start);
|
||||||
|
|
||||||
$end = new Google_EventDateTime();
|
$end = new Google_EventDateTime();
|
||||||
$end->setDateTime(date3339(strtotime($appointment['end_datetime'])));
|
$end->setDateTime(date3339(strtotime($appointment['end_datetime'])));
|
||||||
$event->setEnd($end);
|
$event->setEnd($end);
|
||||||
|
|
||||||
$event->attendees = array();
|
$event->attendees = array();
|
||||||
|
|
||||||
$event_provider = new Google_EventAttendee();
|
$event_provider = new Google_EventAttendee();
|
||||||
$event_provider->setDisplayName($provider['first_name'] . ' '
|
$event_provider->setDisplayName($provider['first_name'] . ' '
|
||||||
. $provider['last_name']);
|
. $provider['last_name']);
|
||||||
$event_provider->setEmail($provider['email']);
|
$event_provider->setEmail($provider['email']);
|
||||||
$event->attendees[] = $event_provider;
|
$event->attendees[] = $event_provider;
|
||||||
|
|
||||||
if ($customer != NULL) {
|
if ($customer != NULL) {
|
||||||
$event_customer = new Google_EventAttendee();
|
$event_customer = new Google_EventAttendee();
|
||||||
$event_customer->setDisplayName($customer['first_name'] . ' '
|
$event_customer->setDisplayName($customer['first_name'] . ' '
|
||||||
. $customer['last_name']);
|
. $customer['last_name']);
|
||||||
$event_customer->setEmail($customer['email']);
|
$event_customer->setEmail($customer['email']);
|
||||||
$event->attendees[] = $event_customer;
|
$event->attendees[] = $event_customer;
|
||||||
}
|
}
|
||||||
|
|
||||||
$updated_event = $this->service->events->update($provider['settings']['google_calendar'],
|
$updated_event = $this->service->events->update($provider['settings']['google_calendar'],
|
||||||
$event->getId(), $event);
|
$event->getId(), $event);
|
||||||
|
|
||||||
return $updated_event;
|
return $updated_event;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete an existing appointment from Google Calendar.
|
* Delete an existing appointment from Google Calendar.
|
||||||
*
|
*
|
||||||
* @param array $provider Contains the provider record data.
|
* @param array $provider Contains the provider record data.
|
||||||
* @param string $google_event_id The Google Calendar event id to
|
* @param string $google_event_id The Google Calendar event id to
|
||||||
* be deleted.
|
* be deleted.
|
||||||
*/
|
*/
|
||||||
public function delete_appointment($provider, $google_event_id) {
|
public function delete_appointment($provider, $google_event_id) {
|
||||||
$this->service->events->delete($provider['settings']['google_calendar'], $google_event_id);
|
$this->service->events->delete($provider['settings']['google_calendar'], $google_event_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add unavailable period event to Google Calendar.
|
* Add unavailable period event to Google Calendar.
|
||||||
*
|
*
|
||||||
* @param array $provider Contains the provider record data.
|
* @param array $provider Contains the provider record data.
|
||||||
* @param array $unavailable Contains unavailable period's data.
|
* @param array $unavailable Contains unavailable period's data.
|
||||||
* @return Google_Event Returns the google event's object.
|
* @return Google_Event Returns the google event's object.
|
||||||
*/
|
*/
|
||||||
public function add_unavailable($provider, $unavailable) {
|
public function add_unavailable($provider, $unavailable) {
|
||||||
$this->CI->load->helper('general');
|
$this->CI->load->helper('general');
|
||||||
|
|
||||||
$event = new Google_Event();
|
$event = new Google_Event();
|
||||||
$event->setSummary('Unavailable');
|
$event->setSummary('Unavailable');
|
||||||
$event->setDescription($unavailable['notes']);
|
$event->setDescription($unavailable['notes']);
|
||||||
|
|
||||||
$start = new Google_EventDateTime();
|
$start = new Google_EventDateTime();
|
||||||
$start->setDateTime(date3339(strtotime($unavailable['start_datetime'])));
|
$start->setDateTime(date3339(strtotime($unavailable['start_datetime'])));
|
||||||
$event->setStart($start);
|
$event->setStart($start);
|
||||||
|
|
||||||
$end = new Google_EventDateTime();
|
$end = new Google_EventDateTime();
|
||||||
$end->setDateTime(date3339(strtotime($unavailable['end_datetime'])));
|
$end->setDateTime(date3339(strtotime($unavailable['end_datetime'])));
|
||||||
$event->setEnd($end);
|
$event->setEnd($end);
|
||||||
|
|
||||||
// Add the new event to the google calendar.
|
// Add the new event to the google calendar.
|
||||||
$created_event = $this->service->events->insert($provider['settings']['google_calendar'], $event);
|
$created_event = $this->service->events->insert($provider['settings']['google_calendar'], $event);
|
||||||
|
|
||||||
return $created_event;
|
return $created_event;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update Google Calendar unavailable period event.
|
* Update Google Calendar unavailable period event.
|
||||||
*
|
*
|
||||||
* @param array $provider Contains the provider record data.
|
* @param array $provider Contains the provider record data.
|
||||||
* @param array $unavailable Contains the unavailable period data.
|
* @param array $unavailable Contains the unavailable period data.
|
||||||
* @return Google_Event Returns the Google_Event object.
|
* @return Google_Event Returns the Google_Event object.
|
||||||
*/
|
*/
|
||||||
public function update_unavailable($provider, $unavailable) {
|
public function update_unavailable($provider, $unavailable) {
|
||||||
$this->CI->load->helper('general');
|
$this->CI->load->helper('general');
|
||||||
|
|
||||||
$event = $this->service->events->get($provider['settings']['google_calendar'], $unavailable['id_google_calendar']);
|
$event = $this->service->events->get($provider['settings']['google_calendar'], $unavailable['id_google_calendar']);
|
||||||
$event->setDescription($unavailable['notes']);
|
$event->setDescription($unavailable['notes']);
|
||||||
|
|
||||||
$start = new Google_EventDateTime();
|
$start = new Google_EventDateTime();
|
||||||
$start->setDateTime(date3339(strtotime($unavailable['start_datetime'])));
|
$start->setDateTime(date3339(strtotime($unavailable['start_datetime'])));
|
||||||
$event->setStart($start);
|
$event->setStart($start);
|
||||||
|
|
||||||
$end = new Google_EventDateTime();
|
$end = new Google_EventDateTime();
|
||||||
$end->setDateTime(date3339(strtotime($unavailable['end_datetime'])));
|
$end->setDateTime(date3339(strtotime($unavailable['end_datetime'])));
|
||||||
$event->setEnd($end);
|
$event->setEnd($end);
|
||||||
|
|
||||||
$updated_event = $this->service->events->update($provider['settings']['google_calendar'],
|
$updated_event = $this->service->events->update($provider['settings']['google_calendar'],
|
||||||
$event->getId(), $event);
|
$event->getId(), $event);
|
||||||
|
|
||||||
return $updated_event;
|
return $updated_event;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete unavailable period event from Google Calendar.
|
* Delete unavailable period event from Google Calendar.
|
||||||
*
|
*
|
||||||
* @param array $provider Contains the provider record data.
|
* @param array $provider Contains the provider record data.
|
||||||
* @param string $google_event_id Google Calendar event id to be deleted.
|
* @param string $google_event_id Google Calendar event id to be deleted.
|
||||||
*/
|
*/
|
||||||
public function delete_unavailable($provider, $google_event_id) {
|
public function delete_unavailable($provider, $google_event_id) {
|
||||||
$this->service->events->delete($provider['settings']['google_calendar'], $google_event_id);
|
$this->service->events->delete($provider['settings']['google_calendar'], $google_event_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get an event object from gcal
|
* Get an event object from gcal
|
||||||
*
|
*
|
||||||
* @param array $provider Contains the provider record data.
|
* @param array $provider Contains the provider record data.
|
||||||
* @param string $google_event_id Id of the google calendar event
|
* @param string $google_event_id Id of the google calendar event
|
||||||
* @return Google_Event Returns the google event object.
|
* @return Google_Event Returns the google event object.
|
||||||
*/
|
*/
|
||||||
public function get_event($provider, $google_event_id) {
|
public function get_event($provider, $google_event_id) {
|
||||||
return $this->service->events->get($provider['settings']['google_calendar'], $google_event_id);
|
return $this->service->events->get($provider['settings']['google_calendar'], $google_event_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all the events between the sync period.
|
* Get all the events between the sync period.
|
||||||
*
|
*
|
||||||
* @param string $google_calendar The name of the google calendar to be used.
|
* @param string $google_calendar The name of the google calendar to be used.
|
||||||
* @param date $start The start date of sync period.
|
* @param date $start The start date of sync period.
|
||||||
* @param date $end The end date of sync period.
|
* @param date $end The end date of sync period.
|
||||||
* @return object Returns an array with Google_Event objects that belong on the given
|
* @return object Returns an array with Google_Event objects that belong on the given
|
||||||
* sync period (start, end).
|
* sync period (start, end).
|
||||||
*/
|
*/
|
||||||
public function get_sync_events($google_calendar, $start, $end) {
|
public function get_sync_events($google_calendar, $start, $end) {
|
||||||
$this->CI->load->helper('general');
|
$this->CI->load->helper('general');
|
||||||
|
|
||||||
$params = array(
|
$params = array(
|
||||||
'timeMin' => date3339($start),
|
'timeMin' => date3339($start),
|
||||||
'timeMax' => date3339($end)
|
'timeMax' => date3339($end)
|
||||||
);
|
);
|
||||||
|
|
||||||
return $this->service->events->listEvents($google_calendar, $params);
|
return $this->service->events->listEvents($google_calendar, $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return available google calendars for specific user.
|
* Return available google calendars for specific user.
|
||||||
*
|
*
|
||||||
* The given user's token must already exist in db in order to get access to his
|
* The given user's token must already exist in db in order to get access to his
|
||||||
* Google Calendar account.
|
* Google Calendar account.
|
||||||
*
|
*
|
||||||
* @param string $google_token The user's token will be used to grant access to google calendar.
|
* @param string $google_token The user's token will be used to grant access to google calendar.
|
||||||
* @return array Returns an array with the available calendars.
|
* @return array Returns an array with the available calendars.
|
||||||
*/
|
*/
|
||||||
public function get_google_calendars() {
|
public function get_google_calendars() {
|
||||||
$calendarList = $this->service->calendarList->listCalendarList();
|
$calendarList = $this->service->calendarList->listCalendarList();
|
||||||
$calendars = array();
|
$calendars = array();
|
||||||
foreach ($calendarList->items as $google_calendar) {
|
foreach ($calendarList->items as $google_calendar) {
|
||||||
$calendars[] = array(
|
$calendars[] = array(
|
||||||
'id' => $google_calendar->id,
|
'id' => $google_calendar->id,
|
||||||
'summary' => $google_calendar->summary
|
'summary' => $google_calendar->summary
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return $calendars;
|
return $calendars;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End of file google_sync.php */
|
/* End of file google_sync.php */
|
||||||
/* Location: ./application/libraries/google_sync.php */
|
/* Location: ./application/libraries/google_sync.php */
|
||||||
|
|
|
@ -1,406 +1,406 @@
|
||||||
<?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 - 2016, Alex Tselegidis
|
* @copyright Copyright (c) 2013 - 2016, 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
|
||||||
* ---------------------------------------------------------------------------- */
|
* ---------------------------------------------------------------------------- */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Appointments Model
|
* Appointments Model
|
||||||
*
|
*
|
||||||
* @package Models
|
* @package Models
|
||||||
*/
|
*/
|
||||||
class Appointments_Model extends CI_Model {
|
class Appointments_Model extends CI_Model {
|
||||||
/**
|
/**
|
||||||
* Class Constructor
|
* Class Constructor
|
||||||
*/
|
*/
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an appointment record to the database.
|
* Add an appointment record to the database.
|
||||||
*
|
*
|
||||||
* This method adds a new appointment to the database. If the
|
* This method adds a new appointment to the database. If the
|
||||||
* appointment doesn't exists it is going to be inserted, otherwise
|
* appointment doesn't exists it is going to be inserted, otherwise
|
||||||
* the record is going to be updated.
|
* the record is going to be updated.
|
||||||
*
|
*
|
||||||
* @param array $appointment Associative array with the appointment
|
* @param array $appointment Associative array with the appointment
|
||||||
* data. Each key has the same name with the database fields.
|
* data. Each key has the same name with the database fields.
|
||||||
* @return int Returns the appointments id.
|
* @return int Returns the appointments id.
|
||||||
*/
|
*/
|
||||||
public function add($appointment) {
|
public function add($appointment) {
|
||||||
// Validate the appointment data before doing anything.
|
// Validate the appointment data before doing anything.
|
||||||
$this->validate($appointment);
|
$this->validate($appointment);
|
||||||
|
|
||||||
// Perform insert() or update() operation.
|
// Perform insert() or update() operation.
|
||||||
if (!isset($appointment['id'])) {
|
if (!isset($appointment['id'])) {
|
||||||
$appointment['id'] = $this->insert($appointment);
|
$appointment['id'] = $this->insert($appointment);
|
||||||
} else {
|
} else {
|
||||||
$this->update($appointment);
|
$this->update($appointment);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $appointment['id'];
|
return $appointment['id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a particular appointment record already exists.
|
* Check if a particular appointment record already exists.
|
||||||
*
|
*
|
||||||
* This method checks wether the given appointment already exists
|
* This method checks wether the given appointment already exists
|
||||||
* in the database. It doesn't search with the id, but by using the
|
* in the database. It doesn't search with the id, but by using the
|
||||||
* following fields: "start_datetime", "end_datetime", "id_users_provider",
|
* following fields: "start_datetime", "end_datetime", "id_users_provider",
|
||||||
* "id_users_customer", "id_services".
|
* "id_users_customer", "id_services".
|
||||||
*
|
*
|
||||||
* @param array $appointment Associative array with the appointment's
|
* @param array $appointment Associative array with the appointment's
|
||||||
* data. Each key has the same name with the database fields.
|
* data. Each key has the same name with the database fields.
|
||||||
* @return bool Returns wether the record exists or not.
|
* @return bool Returns wether the record exists or not.
|
||||||
*/
|
*/
|
||||||
public function exists($appointment) {
|
public function exists($appointment) {
|
||||||
if (!isset($appointment['start_datetime'])
|
if (!isset($appointment['start_datetime'])
|
||||||
|| !isset($appointment['end_datetime'])
|
|| !isset($appointment['end_datetime'])
|
||||||
|| !isset($appointment['id_users_provider'])
|
|| !isset($appointment['id_users_provider'])
|
||||||
|| !isset($appointment['id_users_customer'])
|
|| !isset($appointment['id_users_customer'])
|
||||||
|| !isset($appointment['id_services'])) {
|
|| !isset($appointment['id_services'])) {
|
||||||
throw new Exception('Not all appointment field values '
|
throw new Exception('Not all appointment field values '
|
||||||
. 'are provided : ' . print_r($appointment, TRUE));
|
. 'are provided : ' . print_r($appointment, TRUE));
|
||||||
}
|
}
|
||||||
|
|
||||||
$num_rows = $this->db->get_where('ea_appointments', array(
|
$num_rows = $this->db->get_where('ea_appointments', array(
|
||||||
'start_datetime' => $appointment['start_datetime'],
|
'start_datetime' => $appointment['start_datetime'],
|
||||||
'end_datetime' => $appointment['end_datetime'],
|
'end_datetime' => $appointment['end_datetime'],
|
||||||
'id_users_provider' => $appointment['id_users_provider'],
|
'id_users_provider' => $appointment['id_users_provider'],
|
||||||
'id_users_customer' => $appointment['id_users_customer'],
|
'id_users_customer' => $appointment['id_users_customer'],
|
||||||
'id_services' => $appointment['id_services'],))
|
'id_services' => $appointment['id_services'],))
|
||||||
->num_rows();
|
->num_rows();
|
||||||
|
|
||||||
return ($num_rows > 0) ? TRUE : FALSE;
|
return ($num_rows > 0) ? TRUE : FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Insert a new appointment record to the database.
|
* Insert a new appointment record to the database.
|
||||||
*
|
*
|
||||||
* @param array $appointment Associative array with the appointment's
|
* @param array $appointment Associative array with the appointment's
|
||||||
* data. Each key has the same name with the database fields.
|
* data. Each key has the same name with the database fields.
|
||||||
* @return int Returns the id of the new record.
|
* @return int Returns the id of the new record.
|
||||||
*/
|
*/
|
||||||
private function insert($appointment) {
|
private function insert($appointment) {
|
||||||
$appointment['book_datetime'] = date('Y-m-d H:i:s');
|
$appointment['book_datetime'] = date('Y-m-d H:i:s');
|
||||||
$appointment['hash'] = $this->generate_hash();
|
$appointment['hash'] = $this->generate_hash();
|
||||||
|
|
||||||
if (!$this->db->insert('ea_appointments', $appointment)) {
|
if (!$this->db->insert('ea_appointments', $appointment)) {
|
||||||
throw new Exception('Could not insert appointment record.');
|
throw new Exception('Could not insert appointment record.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return intval($this->db->insert_id());
|
return intval($this->db->insert_id());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update an existing appointment record in the database.
|
* Update an existing appointment record in the database.
|
||||||
*
|
*
|
||||||
* The appointment data argument should already include the record
|
* The appointment data argument should already include the record
|
||||||
* id in order to process the update operation.
|
* id in order to process the update operation.
|
||||||
*
|
*
|
||||||
* @expectedException DatabaseException Raises when the update operation
|
* @expectedException DatabaseException Raises when the update operation
|
||||||
* failes to complete successfully.
|
* failes to complete successfully.
|
||||||
*
|
*
|
||||||
* @param array $appointment Associative array with the appointment's
|
* @param array $appointment Associative array with the appointment's
|
||||||
* data. Each key has the same name with the database fields.
|
* data. Each key has the same name with the database fields.
|
||||||
*/
|
*/
|
||||||
private function update($appointment) {
|
private function update($appointment) {
|
||||||
$this->db->where('id', $appointment['id']);
|
$this->db->where('id', $appointment['id']);
|
||||||
if (!$this->db->update('ea_appointments', $appointment)) {
|
if (!$this->db->update('ea_appointments', $appointment)) {
|
||||||
throw new Exception('Could not update appointment record.');
|
throw new Exception('Could not update appointment record.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find the database id of an appointment record.
|
* Find the database id of an appointment record.
|
||||||
*
|
*
|
||||||
* The appointment data should include the following fields in order
|
* The appointment data should include the following fields in order
|
||||||
* to get the unique id from the database: "start_datetime", "end_datetime",
|
* to get the unique id from the database: "start_datetime", "end_datetime",
|
||||||
* "id_users_provider", "id_users_customer", "id_services".
|
* "id_users_provider", "id_users_customer", "id_services".
|
||||||
*
|
*
|
||||||
* <strong>IMPORTANT!</strong> The record must already exists in the
|
* <strong>IMPORTANT!</strong> The record must already exists in the
|
||||||
* database, otherwise an exception is raised.
|
* database, otherwise an exception is raised.
|
||||||
*
|
*
|
||||||
* @param array $appointment Array with the appointment data. The
|
* @param array $appointment Array with the appointment data. The
|
||||||
* keys of the array should have the same names as the db fields.
|
* keys of the array should have the same names as the db fields.
|
||||||
* @return int Returns the db id of the record that matches the apppointment
|
* @return int Returns the db id of the record that matches the apppointment
|
||||||
* data.
|
* data.
|
||||||
*/
|
*/
|
||||||
public function find_record_id($appointment) {
|
public function find_record_id($appointment) {
|
||||||
$this->db->where(array(
|
$this->db->where(array(
|
||||||
'start_datetime' => $appointment['start_datetime'],
|
'start_datetime' => $appointment['start_datetime'],
|
||||||
'end_datetime' => $appointment['end_datetime'],
|
'end_datetime' => $appointment['end_datetime'],
|
||||||
'id_users_provider' => $appointment['id_users_provider'],
|
'id_users_provider' => $appointment['id_users_provider'],
|
||||||
'id_users_customer' => $appointment['id_users_customer'],
|
'id_users_customer' => $appointment['id_users_customer'],
|
||||||
'id_services' => $appointment['id_services']
|
'id_services' => $appointment['id_services']
|
||||||
));
|
));
|
||||||
|
|
||||||
$result = $this->db->get('ea_appointments');
|
$result = $this->db->get('ea_appointments');
|
||||||
|
|
||||||
if ($result->num_rows() == 0) {
|
if ($result->num_rows() == 0) {
|
||||||
throw new Exception('Could not find appointment record id.');
|
throw new Exception('Could not find appointment record id.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result->row()->id;
|
return $result->row()->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate appointment data before the insert or update operations
|
* Validate appointment data before the insert or update operations
|
||||||
* are executed.
|
* are executed.
|
||||||
*
|
*
|
||||||
* @param array $appointment Contains the appointment data.
|
* @param array $appointment Contains the appointment data.
|
||||||
* @return bool Returns the validation result.
|
* @return bool Returns the validation result.
|
||||||
*/
|
*/
|
||||||
public function validate($appointment) {
|
public function validate($appointment) {
|
||||||
$this->load->helper('data_validation');
|
$this->load->helper('data_validation');
|
||||||
|
|
||||||
// If a appointment id is given, check wether the record exists
|
// If a appointment id is given, check wether the record exists
|
||||||
// in the database.
|
// in the database.
|
||||||
if (isset($appointment['id'])) {
|
if (isset($appointment['id'])) {
|
||||||
$num_rows = $this->db->get_where('ea_appointments',
|
$num_rows = $this->db->get_where('ea_appointments',
|
||||||
array('id' => $appointment['id']))->num_rows();
|
array('id' => $appointment['id']))->num_rows();
|
||||||
if ($num_rows == 0) {
|
if ($num_rows == 0) {
|
||||||
throw new Exception('Provided appointment id does not '
|
throw new Exception('Provided appointment id does not '
|
||||||
. 'exist in the database.');
|
. 'exist in the database.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if appointment dates are valid.
|
// Check if appointment dates are valid.
|
||||||
if (!validate_mysql_datetime($appointment['start_datetime'])) {
|
if (!validate_mysql_datetime($appointment['start_datetime'])) {
|
||||||
throw new Exception('Appointment start datetime is invalid.');
|
throw new Exception('Appointment start datetime is invalid.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!validate_mysql_datetime($appointment['end_datetime'])) {
|
if (!validate_mysql_datetime($appointment['end_datetime'])) {
|
||||||
throw new Exception('Appointment end datetime is invalid.');
|
throw new Exception('Appointment end datetime is invalid.');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the provider's id is valid.
|
// Check if the provider's id is valid.
|
||||||
$num_rows = $this->db
|
$num_rows = $this->db
|
||||||
->select('*')
|
->select('*')
|
||||||
->from('ea_users')
|
->from('ea_users')
|
||||||
->join('ea_roles', 'ea_roles.id = ea_users.id_roles', 'inner')
|
->join('ea_roles', 'ea_roles.id = ea_users.id_roles', 'inner')
|
||||||
->where('ea_users.id', $appointment['id_users_provider'])
|
->where('ea_users.id', $appointment['id_users_provider'])
|
||||||
->where('ea_roles.slug', DB_SLUG_PROVIDER)
|
->where('ea_roles.slug', DB_SLUG_PROVIDER)
|
||||||
->get()->num_rows();
|
->get()->num_rows();
|
||||||
if ($num_rows == 0) {
|
if ($num_rows == 0) {
|
||||||
throw new Exception('Appointment provider id is invalid.');
|
throw new Exception('Appointment provider id is invalid.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($appointment['is_unavailable'] == FALSE) {
|
if ($appointment['is_unavailable'] == FALSE) {
|
||||||
// Check if the customer's id is valid.
|
// Check if the customer's id is valid.
|
||||||
$num_rows = $this->db
|
$num_rows = $this->db
|
||||||
->select('*')
|
->select('*')
|
||||||
->from('ea_users')
|
->from('ea_users')
|
||||||
->join('ea_roles', 'ea_roles.id = ea_users.id_roles', 'inner')
|
->join('ea_roles', 'ea_roles.id = ea_users.id_roles', 'inner')
|
||||||
->where('ea_users.id', $appointment['id_users_customer'])
|
->where('ea_users.id', $appointment['id_users_customer'])
|
||||||
->where('ea_roles.slug', DB_SLUG_CUSTOMER)
|
->where('ea_roles.slug', DB_SLUG_CUSTOMER)
|
||||||
->get()->num_rows();
|
->get()->num_rows();
|
||||||
if ($num_rows == 0) {
|
if ($num_rows == 0) {
|
||||||
throw new Exception('Appointment customer id is invalid.');
|
throw new Exception('Appointment customer id is invalid.');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the service id is valid.
|
// Check if the service id is valid.
|
||||||
$num_rows = $this->db->get_where('ea_services',
|
$num_rows = $this->db->get_where('ea_services',
|
||||||
array('id' => $appointment['id_services']))->num_rows();
|
array('id' => $appointment['id_services']))->num_rows();
|
||||||
if ($num_rows == 0) {
|
if ($num_rows == 0) {
|
||||||
throw new Exception('Appointment customer id is invalid.');
|
throw new Exception('Appointment customer id is invalid.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete an existing appointment record from the database.
|
* Delete an existing appointment record from the database.
|
||||||
*
|
*
|
||||||
* @expectedException InvalidArgumentException Raises when the $appointment_id
|
* @expectedException InvalidArgumentException Raises when the $appointment_id
|
||||||
* is not an integer.
|
* is not an integer.
|
||||||
*
|
*
|
||||||
* @param numeric $appointment_id The record id to be deleted.
|
* @param numeric $appointment_id The record id to be deleted.
|
||||||
* @return bool Returns the delete operation result.
|
* @return bool Returns the delete operation result.
|
||||||
*/
|
*/
|
||||||
public function delete($appointment_id) {
|
public function delete($appointment_id) {
|
||||||
if (!is_numeric($appointment_id)) {
|
if (!is_numeric($appointment_id)) {
|
||||||
throw new Exception('Invalid argument type $appointment_id (value:"' . $appointment_id . '")');
|
throw new Exception('Invalid argument type $appointment_id (value:"' . $appointment_id . '")');
|
||||||
}
|
}
|
||||||
|
|
||||||
$num_rows = $this->db->get_where('ea_appointments', array('id' => $appointment_id))->num_rows();
|
$num_rows = $this->db->get_where('ea_appointments', array('id' => $appointment_id))->num_rows();
|
||||||
|
|
||||||
if ($num_rows == 0) {
|
if ($num_rows == 0) {
|
||||||
return FALSE; // Record does not exist.
|
return FALSE; // Record does not exist.
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->db->where('id', $appointment_id);
|
$this->db->where('id', $appointment_id);
|
||||||
return $this->db->delete('ea_appointments');
|
return $this->db->delete('ea_appointments');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a specific row from the appointments table.
|
* Get a specific row from the appointments table.
|
||||||
*
|
*
|
||||||
* @param numeric $appointment_id The record's id to be returned.
|
* @param numeric $appointment_id The record's id to be returned.
|
||||||
* @return array Returns an associative array with the selected
|
* @return array Returns an associative array with the selected
|
||||||
* record's data. Each key has the same name as the database
|
* record's data. Each key has the same name as the database
|
||||||
* field names.
|
* field names.
|
||||||
*/
|
*/
|
||||||
public function get_row($appointment_id) {
|
public function get_row($appointment_id) {
|
||||||
if (!is_numeric($appointment_id)) {
|
if (!is_numeric($appointment_id)) {
|
||||||
throw new Exception('Invalid argument given. Expected '
|
throw new Exception('Invalid argument given. Expected '
|
||||||
. 'integer for the $appointment_id : ' . $appointment_id);
|
. 'integer for the $appointment_id : ' . $appointment_id);
|
||||||
}
|
}
|
||||||
return $this->db->get_where('ea_appointments',
|
return $this->db->get_where('ea_appointments',
|
||||||
array('id' => $appointment_id))->row_array();
|
array('id' => $appointment_id))->row_array();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a specific field value from the database.
|
* Get a specific field value from the database.
|
||||||
*
|
*
|
||||||
* @param string $field_name The field name of the value to be returned.
|
* @param string $field_name The field name of the value to be returned.
|
||||||
* @param numeric $appointment_id The selected record's id.
|
* @param numeric $appointment_id The selected record's id.
|
||||||
* @return string Returns the records value from the database.
|
* @return string Returns the records value from the database.
|
||||||
*/
|
*/
|
||||||
public function get_value($field_name, $appointment_id) {
|
public function get_value($field_name, $appointment_id) {
|
||||||
if (!is_numeric($appointment_id)) {
|
if (!is_numeric($appointment_id)) {
|
||||||
throw new Exception('Invalid argument given, expected '
|
throw new Exception('Invalid argument given, expected '
|
||||||
. 'integer for the $appointment_id : ' . $appointment_id);
|
. 'integer for the $appointment_id : ' . $appointment_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_string($field_name)) {
|
if (!is_string($field_name)) {
|
||||||
throw new Exception('Invalid argument given, expected '
|
throw new Exception('Invalid argument given, expected '
|
||||||
. 'string for the $field_name : ' . $field_name);
|
. 'string for the $field_name : ' . $field_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->db->get_where('ea_appointments',
|
if ($this->db->get_where('ea_appointments',
|
||||||
array('id' => $appointment_id))->num_rows() == 0) {
|
array('id' => $appointment_id))->num_rows() == 0) {
|
||||||
throw new Exception('The record with the provided id '
|
throw new Exception('The record with the provided id '
|
||||||
. 'does not exist in the database : ' . $appointment_id);
|
. 'does not exist in the database : ' . $appointment_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
$row_data = $this->db->get_where('ea_appointments',
|
$row_data = $this->db->get_where('ea_appointments',
|
||||||
array('id' => $appointment_id))->row_array();
|
array('id' => $appointment_id))->row_array();
|
||||||
|
|
||||||
if (!isset($row_data[$field_name])) {
|
if (!isset($row_data[$field_name])) {
|
||||||
throw new Exception('The given field name does not '
|
throw new Exception('The given field name does not '
|
||||||
. 'exist in the database : ' . $field_name);
|
. 'exist in the database : ' . $field_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $row_data[$field_name];
|
return $row_data[$field_name];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all, or specific records from appointment's table.
|
* Get all, or specific records from appointment's table.
|
||||||
*
|
*
|
||||||
* @example $this->Model->getBatch('id = ' . $recordId);
|
* @example $this->Model->getBatch('id = ' . $recordId);
|
||||||
*
|
*
|
||||||
* @param string $where_clause (OPTIONAL) The WHERE clause of
|
* @param string $where_clause (OPTIONAL) The WHERE clause of
|
||||||
* the query to be executed. DO NOT INCLUDE 'WHERE' KEYWORD.
|
* the query to be executed. DO NOT INCLUDE 'WHERE' KEYWORD.
|
||||||
* @return array Returns the rows from the database.
|
* @return array Returns the rows from the database.
|
||||||
*/
|
*/
|
||||||
public function get_batch($where_clause = '') {
|
public function get_batch($where_clause = '') {
|
||||||
if ($where_clause != '') {
|
if ($where_clause != '') {
|
||||||
$this->db->where($where_clause);
|
$this->db->where($where_clause);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->db->get('ea_appointments')->result_array();
|
return $this->db->get('ea_appointments')->result_array();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate a unique hash for the given appointment data.
|
* Generate a unique hash for the given appointment data.
|
||||||
*
|
*
|
||||||
* This method uses the current date-time to generate a unique
|
* This method uses the current date-time to generate a unique
|
||||||
* hash string that is later used to identify this appointment.
|
* hash string that is later used to identify this appointment.
|
||||||
* Hash is needed when the email is send to the user with an
|
* Hash is needed when the email is send to the user with an
|
||||||
* edit link.
|
* edit link.
|
||||||
*
|
*
|
||||||
* @return string Returns the unique appointment hash.
|
* @return string Returns the unique appointment hash.
|
||||||
*/
|
*/
|
||||||
public function generate_hash() {
|
public function generate_hash() {
|
||||||
$current_date = new DateTime();
|
$current_date = new DateTime();
|
||||||
return md5($current_date->getTimestamp());
|
return md5($current_date->getTimestamp());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inserts or updates an unavailable period record in the database.
|
* Inserts or updates an unavailable period record in the database.
|
||||||
*
|
*
|
||||||
* @param array $unavailable Contains the unavaible data.
|
* @param array $unavailable Contains the unavaible data.
|
||||||
* @return int Returns the record id.
|
* @return int Returns the record id.
|
||||||
*/
|
*/
|
||||||
public function add_unavailable($unavailable) {
|
public function add_unavailable($unavailable) {
|
||||||
// Validate period
|
// Validate period
|
||||||
$start = strtotime($unavailable['start_datetime']);
|
$start = strtotime($unavailable['start_datetime']);
|
||||||
$end = strtotime($unavailable['end_datetime']);
|
$end = strtotime($unavailable['end_datetime']);
|
||||||
if ($start > $end) {
|
if ($start > $end) {
|
||||||
throw new Exception('Unavailable period start must be prior to end.');
|
throw new Exception('Unavailable period start must be prior to end.');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate provider record
|
// Validate provider record
|
||||||
$where_clause = array(
|
$where_clause = array(
|
||||||
'id' => $unavailable['id_users_provider'],
|
'id' => $unavailable['id_users_provider'],
|
||||||
'id_roles' => $this->db->get_where('ea_roles', array('slug' => DB_SLUG_PROVIDER))->row()->id
|
'id_roles' => $this->db->get_where('ea_roles', array('slug' => DB_SLUG_PROVIDER))->row()->id
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($this->db->get_where('ea_users', $where_clause)->num_rows() == 0) {
|
if ($this->db->get_where('ea_users', $where_clause)->num_rows() == 0) {
|
||||||
throw new Exception('Provider id was not found in database.');
|
throw new Exception('Provider id was not found in database.');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add record to database (insert or update).
|
// Add record to database (insert or update).
|
||||||
if (!isset($unavailable['id'])) {
|
if (!isset($unavailable['id'])) {
|
||||||
$unavailable['book_datetime'] = date('Y-m-d H:i:s');
|
$unavailable['book_datetime'] = date('Y-m-d H:i:s');
|
||||||
$unavailable['is_unavailable'] = true;
|
$unavailable['is_unavailable'] = true;
|
||||||
|
|
||||||
$this->db->insert('ea_appointments', $unavailable);
|
$this->db->insert('ea_appointments', $unavailable);
|
||||||
$unavailable['id'] = $this->db->insert_id();
|
$unavailable['id'] = $this->db->insert_id();
|
||||||
} else {
|
} else {
|
||||||
$this->db->where(array('id' => $unavailable['id']));
|
$this->db->where(array('id' => $unavailable['id']));
|
||||||
$this->db->update('ea_appointments', $unavailable);
|
$this->db->update('ea_appointments', $unavailable);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $unavailable['id'];
|
return $unavailable['id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete an unavailable period.
|
* Delete an unavailable period.
|
||||||
*
|
*
|
||||||
* @param numeric $unavailable_id Record id to be deleted.
|
* @param numeric $unavailable_id Record id to be deleted.
|
||||||
*/
|
*/
|
||||||
public function delete_unavailable($unavailable_id) {
|
public function delete_unavailable($unavailable_id) {
|
||||||
if (!is_numeric($unavailable_id)) {
|
if (!is_numeric($unavailable_id)) {
|
||||||
throw new Exception('Invalid argument type $unavailable_id (value:"' .
|
throw new Exception('Invalid argument type $unavailable_id (value:"' .
|
||||||
$unavailable_id . '")');
|
$unavailable_id . '")');
|
||||||
}
|
}
|
||||||
|
|
||||||
$num_rows = $this->db->get_where('ea_appointments', array('id' => $unavailable_id))
|
$num_rows = $this->db->get_where('ea_appointments', array('id' => $unavailable_id))
|
||||||
->num_rows();
|
->num_rows();
|
||||||
if ($num_rows == 0) {
|
if ($num_rows == 0) {
|
||||||
return FALSE; // Record does not exist.
|
return FALSE; // Record does not exist.
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->db->where('id', $unavailable_id);
|
$this->db->where('id', $unavailable_id);
|
||||||
return $this->db->delete('ea_appointments');
|
return $this->db->delete('ea_appointments');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear google sync IDs from appointment record.
|
* Clear google sync IDs from appointment record.
|
||||||
*
|
*
|
||||||
* @param numeric $provider_id The appointment provider record id.
|
* @param numeric $provider_id The appointment provider record id.
|
||||||
*/
|
*/
|
||||||
public function clear_google_sync_ids($provider_id) {
|
public function clear_google_sync_ids($provider_id) {
|
||||||
if (!is_numeric($provider_id)) {
|
if (!is_numeric($provider_id)) {
|
||||||
throw new Exception('Invalid argument type $provider_id (value: "'
|
throw new Exception('Invalid argument type $provider_id (value: "'
|
||||||
. $provider_id . '")');
|
. $provider_id . '")');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->db->update('ea_appointments', array('id_google_calendar' => NULL),
|
$this->db->update('ea_appointments', array('id_google_calendar' => NULL),
|
||||||
array('id_users_provider' => $provider_id));
|
array('id_users_provider' => $provider_id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End of file appointments_model.php */
|
/* End of file appointments_model.php */
|
||||||
/* Location: ./application/models/appointments_model.php */
|
/* Location: ./application/models/appointments_model.php */
|
||||||
|
|
|
@ -1,327 +1,327 @@
|
||||||
<?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 - 2016, Alex Tselegidis
|
* @copyright Copyright (c) 2013 - 2016, 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
|
||||||
* ---------------------------------------------------------------------------- */
|
* ---------------------------------------------------------------------------- */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Customers Model
|
* Customers Model
|
||||||
*
|
*
|
||||||
* @package Models
|
* @package Models
|
||||||
*/
|
*/
|
||||||
class Customers_Model extends CI_Model {
|
class Customers_Model extends CI_Model {
|
||||||
/**
|
/**
|
||||||
* Class Constructor
|
* Class Constructor
|
||||||
*/
|
*/
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a customer record to the database.
|
* Add a customer record to the database.
|
||||||
*
|
*
|
||||||
* This method adds a customer to the database. If the customer
|
* This method adds a customer to the database. If the customer
|
||||||
* doesn't exists it is going to be inserted, otherwise the
|
* doesn't exists it is going to be inserted, otherwise the
|
||||||
* record is going to be updated.
|
* record is going to be updated.
|
||||||
*
|
*
|
||||||
* @param array $customer Associative array with the customer's
|
* @param array $customer Associative array with the customer's
|
||||||
* data. Each key has the same name with the database fields.
|
* data. Each key has the same name with the database fields.
|
||||||
* @return int Returns the customer id.
|
* @return int Returns the customer id.
|
||||||
*/
|
*/
|
||||||
public function add($customer) {
|
public function add($customer) {
|
||||||
// Validate the customer data before doing anything.
|
// Validate the customer data before doing anything.
|
||||||
$this->validate($customer);
|
$this->validate($customer);
|
||||||
|
|
||||||
// :: CHECK IF CUSTOMER ALREADY EXIST (FROM EMAIL).
|
// :: CHECK IF CUSTOMER ALREADY EXIST (FROM EMAIL).
|
||||||
if ($this->exists($customer) && !isset($customer['id'])) {
|
if ($this->exists($customer) && !isset($customer['id'])) {
|
||||||
// Find the customer id from the database.
|
// Find the customer id from the database.
|
||||||
$customer['id'] = $this->find_record_id($customer);
|
$customer['id'] = $this->find_record_id($customer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// :: INSERT OR UPDATE CUSTOMER RECORD
|
// :: INSERT OR UPDATE CUSTOMER RECORD
|
||||||
if (!isset($customer['id'])) {
|
if (!isset($customer['id'])) {
|
||||||
$customer['id'] = $this->insert($customer);
|
$customer['id'] = $this->insert($customer);
|
||||||
} else {
|
} else {
|
||||||
$this->update($customer);
|
$this->update($customer);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $customer['id'];
|
return $customer['id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a particular customer record already exists.
|
* Check if a particular customer record already exists.
|
||||||
*
|
*
|
||||||
* This method checks wether the given customer already exists in
|
* This method checks wether the given customer already exists in
|
||||||
* the database. It doesn't search with the id, but with the following
|
* the database. It doesn't search with the id, but with the following
|
||||||
* fields: "email"
|
* fields: "email"
|
||||||
*
|
*
|
||||||
* @param array $customer Associative array with the customer's
|
* @param array $customer Associative array with the customer's
|
||||||
* data. Each key has the same name with the database fields.
|
* data. Each key has the same name with the database fields.
|
||||||
* @return bool Returns wether the record exists or not.
|
* @return bool Returns wether the record exists or not.
|
||||||
*/
|
*/
|
||||||
public function exists($customer) {
|
public function exists($customer) {
|
||||||
if (!isset($customer['email'])) {
|
if (!isset($customer['email'])) {
|
||||||
throw new Exception('Customer\'s email is not provided.');
|
throw new Exception('Customer\'s email is not provided.');
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method shouldn't depend on another method of this class.
|
// This method shouldn't depend on another method of this class.
|
||||||
$num_rows = $this->db
|
$num_rows = $this->db
|
||||||
->select('*')
|
->select('*')
|
||||||
->from('ea_users')
|
->from('ea_users')
|
||||||
->join('ea_roles', 'ea_roles.id = ea_users.id_roles', 'inner')
|
->join('ea_roles', 'ea_roles.id = ea_users.id_roles', 'inner')
|
||||||
->where('ea_users.email', $customer['email'])
|
->where('ea_users.email', $customer['email'])
|
||||||
->where('ea_roles.slug', DB_SLUG_CUSTOMER)
|
->where('ea_roles.slug', DB_SLUG_CUSTOMER)
|
||||||
->get()->num_rows();
|
->get()->num_rows();
|
||||||
|
|
||||||
return ($num_rows > 0) ? TRUE : FALSE;
|
return ($num_rows > 0) ? TRUE : FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Insert a new customer record to the database.
|
* Insert a new customer record to the database.
|
||||||
*
|
*
|
||||||
* @param array $customer Associative array with the customer's
|
* @param array $customer Associative array with the customer's
|
||||||
* data. Each key has the same name with the database fields.
|
* data. Each key has the same name with the database fields.
|
||||||
* @return int Returns the id of the new record.
|
* @return int Returns the id of the new record.
|
||||||
*/
|
*/
|
||||||
private function insert($customer) {
|
private function insert($customer) {
|
||||||
// Before inserting the customer we need to get the customer's role id
|
// Before inserting the customer we need to get the customer's role id
|
||||||
// from the database and assign it to the new record as a foreign key.
|
// from the database and assign it to the new record as a foreign key.
|
||||||
$customer_role_id = $this->db
|
$customer_role_id = $this->db
|
||||||
->select('id')
|
->select('id')
|
||||||
->from('ea_roles')
|
->from('ea_roles')
|
||||||
->where('slug', DB_SLUG_CUSTOMER)
|
->where('slug', DB_SLUG_CUSTOMER)
|
||||||
->get()->row()->id;
|
->get()->row()->id;
|
||||||
|
|
||||||
$customer['id_roles'] = $customer_role_id;
|
$customer['id_roles'] = $customer_role_id;
|
||||||
|
|
||||||
if (!$this->db->insert('ea_users', $customer)) {
|
if (!$this->db->insert('ea_users', $customer)) {
|
||||||
throw new Exception('Could not insert customer to the database.');
|
throw new Exception('Could not insert customer to the database.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return intval($this->db->insert_id());
|
return intval($this->db->insert_id());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update an existing customer record in the database.
|
* Update an existing customer record in the database.
|
||||||
*
|
*
|
||||||
* The customer data argument should already include the record
|
* The customer data argument should already include the record
|
||||||
* id in order to process the update operation.
|
* id in order to process the update operation.
|
||||||
*
|
*
|
||||||
* @param array $customer Associative array with the customer's
|
* @param array $customer Associative array with the customer's
|
||||||
* data. Each key has the same name with the database fields.
|
* data. Each key has the same name with the database fields.
|
||||||
* @return int Returns the updated record id.
|
* @return int Returns the updated record id.
|
||||||
*/
|
*/
|
||||||
private function update($customer) {
|
private function update($customer) {
|
||||||
// Do not update empty string values.
|
// Do not update empty string values.
|
||||||
foreach ($customer as $key => $value) {
|
foreach ($customer as $key => $value) {
|
||||||
if ($value === '')
|
if ($value === '')
|
||||||
unset($customer[$key]);
|
unset($customer[$key]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->db->where('id', $customer['id']);
|
$this->db->where('id', $customer['id']);
|
||||||
if (!$this->db->update('ea_users', $customer)) {
|
if (!$this->db->update('ea_users', $customer)) {
|
||||||
throw new Exception('Could not update customer to the database.');
|
throw new Exception('Could not update customer to the database.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return intval($customer['id']);
|
return intval($customer['id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find the database id of a customer record.
|
* Find the database id of a customer record.
|
||||||
*
|
*
|
||||||
* The customer data should include the following fields in order to
|
* The customer data should include the following fields in order to
|
||||||
* get the unique id from the database: "email"
|
* get the unique id from the database: "email"
|
||||||
*
|
*
|
||||||
* <strong>IMPORTANT!</strong> The record must already exists in the
|
* <strong>IMPORTANT!</strong> The record must already exists in the
|
||||||
* database, otherwise an exception is raised.
|
* database, otherwise an exception is raised.
|
||||||
*
|
*
|
||||||
* @param array $customer Array with the customer data. The
|
* @param array $customer Array with the customer data. The
|
||||||
* keys of the array should have the same names as the db fields.
|
* keys of the array should have the same names as the db fields.
|
||||||
* @return int Returns the id.
|
* @return int Returns the id.
|
||||||
*/
|
*/
|
||||||
public function find_record_id($customer) {
|
public function find_record_id($customer) {
|
||||||
if (!isset($customer['email'])) {
|
if (!isset($customer['email'])) {
|
||||||
throw new Exception('Customer\'s email was not provided : '
|
throw new Exception('Customer\'s email was not provided : '
|
||||||
. print_r($customer, TRUE));
|
. print_r($customer, TRUE));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get customer's role id
|
// Get customer's role id
|
||||||
$result = $this->db
|
$result = $this->db
|
||||||
->select('ea_users.id')
|
->select('ea_users.id')
|
||||||
->from('ea_users')
|
->from('ea_users')
|
||||||
->join('ea_roles', 'ea_roles.id = ea_users.id_roles', 'inner')
|
->join('ea_roles', 'ea_roles.id = ea_users.id_roles', 'inner')
|
||||||
->where('ea_users.email', $customer['email'])
|
->where('ea_users.email', $customer['email'])
|
||||||
->where('ea_roles.slug', DB_SLUG_CUSTOMER)
|
->where('ea_roles.slug', DB_SLUG_CUSTOMER)
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
if ($result->num_rows() == 0) {
|
if ($result->num_rows() == 0) {
|
||||||
throw new Exception('Could not find customer record id.');
|
throw new Exception('Could not find customer record id.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result->row()->id;
|
return $result->row()->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate customer data before the insert or update operation is executed.
|
* Validate customer data before the insert or update operation is executed.
|
||||||
*
|
*
|
||||||
* @param array $customer Contains the customer data.
|
* @param array $customer Contains the customer data.
|
||||||
* @return bool Returns the validation result.
|
* @return bool Returns the validation result.
|
||||||
*/
|
*/
|
||||||
public function validate($customer) {
|
public function validate($customer) {
|
||||||
$this->load->helper('data_validation');
|
$this->load->helper('data_validation');
|
||||||
|
|
||||||
// If a customer id is provided, check whether the record
|
// If a customer id is provided, check whether the record
|
||||||
// exist in the database.
|
// exist in the database.
|
||||||
if (isset($customer['id'])) {
|
if (isset($customer['id'])) {
|
||||||
$num_rows = $this->db->get_where('ea_users',
|
$num_rows = $this->db->get_where('ea_users',
|
||||||
array('id' => $customer['id']))->num_rows();
|
array('id' => $customer['id']))->num_rows();
|
||||||
if ($num_rows == 0) {
|
if ($num_rows == 0) {
|
||||||
throw new Exception('Provided customer id does not '
|
throw new Exception('Provided customer id does not '
|
||||||
. 'exist in the database.');
|
. 'exist in the database.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Validate required fields
|
// Validate required fields
|
||||||
if (!isset($customer['last_name'])
|
if (!isset($customer['last_name'])
|
||||||
|| !isset($customer['email'])
|
|| !isset($customer['email'])
|
||||||
|| !isset($customer['phone_number'])) {
|
|| !isset($customer['phone_number'])) {
|
||||||
throw new Exception('Not all required fields are provided : '
|
throw new Exception('Not all required fields are provided : '
|
||||||
. print_r($customer, TRUE));
|
. print_r($customer, TRUE));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate email address
|
// Validate email address
|
||||||
if (!filter_var($customer['email'], FILTER_VALIDATE_EMAIL)) {
|
if (!filter_var($customer['email'], FILTER_VALIDATE_EMAIL)) {
|
||||||
throw new Exception('Invalid email address provided : '
|
throw new Exception('Invalid email address provided : '
|
||||||
. $customer['email']);
|
. $customer['email']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// When inserting a record the email address must be unique.
|
// When inserting a record the email address must be unique.
|
||||||
$customer_id = (isset($customer['id'])) ? $customer['id'] : '';
|
$customer_id = (isset($customer['id'])) ? $customer['id'] : '';
|
||||||
|
|
||||||
$num_rows = $this->db
|
$num_rows = $this->db
|
||||||
->select('*')
|
->select('*')
|
||||||
->from('ea_users')
|
->from('ea_users')
|
||||||
->join('ea_roles', 'ea_roles.id = ea_users.id_roles', 'inner')
|
->join('ea_roles', 'ea_roles.id = ea_users.id_roles', 'inner')
|
||||||
->where('ea_roles.slug', DB_SLUG_CUSTOMER)
|
->where('ea_roles.slug', DB_SLUG_CUSTOMER)
|
||||||
->where('ea_users.email', $customer['email'])
|
->where('ea_users.email', $customer['email'])
|
||||||
->where('ea_users.id <>', $customer_id)
|
->where('ea_users.id <>', $customer_id)
|
||||||
->get()
|
->get()
|
||||||
->num_rows();
|
->num_rows();
|
||||||
|
|
||||||
if ($num_rows > 0) {
|
if ($num_rows > 0) {
|
||||||
throw new Exception('Given email address belongs to another customer record. '
|
throw new Exception('Given email address belongs to another customer record. '
|
||||||
. 'Please use a different email.');
|
. 'Please use a different email.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete an existing customer record from the database.
|
* Delete an existing customer record from the database.
|
||||||
*
|
*
|
||||||
* @param numeric $customer_id The record id to be deleted.
|
* @param numeric $customer_id The record id to be deleted.
|
||||||
* @return bool Returns the delete operation result.
|
* @return bool Returns the delete operation result.
|
||||||
*/
|
*/
|
||||||
public function delete($customer_id) {
|
public function delete($customer_id) {
|
||||||
if (!is_numeric($customer_id)) {
|
if (!is_numeric($customer_id)) {
|
||||||
throw new Exception('Invalid argument type $customer_id : ' . $customer_id);
|
throw new Exception('Invalid argument type $customer_id : ' . $customer_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
$num_rows = $this->db->get_where('ea_users', array('id' => $customer_id))->num_rows();
|
$num_rows = $this->db->get_where('ea_users', array('id' => $customer_id))->num_rows();
|
||||||
if ($num_rows == 0) {
|
if ($num_rows == 0) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->db->delete('ea_users', array('id' => $customer_id));
|
return $this->db->delete('ea_users', array('id' => $customer_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a specific row from the appointments table.
|
* Get a specific row from the appointments table.
|
||||||
*
|
*
|
||||||
* @param numeric $customer_id The record's id to be returned.
|
* @param numeric $customer_id The record's id to be returned.
|
||||||
* @return array Returns an associative array with the selected
|
* @return array Returns an associative array with the selected
|
||||||
* record's data. Each key has the same name as the database
|
* record's data. Each key has the same name as the database
|
||||||
* field names.
|
* field names.
|
||||||
*/
|
*/
|
||||||
public function get_row($customer_id) {
|
public function get_row($customer_id) {
|
||||||
if (!is_numeric($customer_id)) {
|
if (!is_numeric($customer_id)) {
|
||||||
throw new Exception('Invalid argument provided as $customer_id : ' . $customer_id);
|
throw new Exception('Invalid argument provided as $customer_id : ' . $customer_id);
|
||||||
}
|
}
|
||||||
return $this->db->get_where('ea_users', array('id' => $customer_id))->row_array();
|
return $this->db->get_where('ea_users', array('id' => $customer_id))->row_array();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a specific field value from the database.
|
* Get a specific field value from the database.
|
||||||
*
|
*
|
||||||
* @param string $field_name The field name of the value to be
|
* @param string $field_name The field name of the value to be
|
||||||
* returned.
|
* returned.
|
||||||
* @param int $customer_id The selected record's id.
|
* @param int $customer_id The selected record's id.
|
||||||
* @return string Returns the records value from the database.
|
* @return string Returns the records value from the database.
|
||||||
*/
|
*/
|
||||||
public function get_value($field_name, $customer_id) {
|
public function get_value($field_name, $customer_id) {
|
||||||
if (!is_numeric($customer_id)) {
|
if (!is_numeric($customer_id)) {
|
||||||
throw new Exception('Invalid argument provided as $customer_id : '
|
throw new Exception('Invalid argument provided as $customer_id : '
|
||||||
. $customer_id);
|
. $customer_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_string($field_name)) {
|
if (!is_string($field_name)) {
|
||||||
throw new Exception('$field_name argument is not a string : '
|
throw new Exception('$field_name argument is not a string : '
|
||||||
. $field_name);
|
. $field_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->db->get_where('ea_users', array('id' => $customer_id))->num_rows() == 0) {
|
if ($this->db->get_where('ea_users', array('id' => $customer_id))->num_rows() == 0) {
|
||||||
throw new Exception('The record with the $customer_id argument '
|
throw new Exception('The record with the $customer_id argument '
|
||||||
. 'does not exist in the database : ' . $customer_id);
|
. 'does not exist in the database : ' . $customer_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
$row_data = $this->db->get_where('ea_users', array('id' => $customer_id)
|
$row_data = $this->db->get_where('ea_users', array('id' => $customer_id)
|
||||||
)->row_array();
|
)->row_array();
|
||||||
if (!isset($row_data[$field_name])) {
|
if (!isset($row_data[$field_name])) {
|
||||||
throw new Exception('The given $field_name argument does not'
|
throw new Exception('The given $field_name argument does not'
|
||||||
. 'exist in the database : ' . $field_name);
|
. 'exist in the database : ' . $field_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
$customer = $this->db->get_where('ea_users', array('id' => $customer_id))->row_array();
|
$customer = $this->db->get_where('ea_users', array('id' => $customer_id))->row_array();
|
||||||
|
|
||||||
return $customer[$field_name];
|
return $customer[$field_name];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all, or specific records from appointment's table.
|
* Get all, or specific records from appointment's table.
|
||||||
*
|
*
|
||||||
* @example $this->Model->getBatch('id = ' . $recordId);
|
* @example $this->Model->getBatch('id = ' . $recordId);
|
||||||
*
|
*
|
||||||
* @param string $whereClause (OPTIONAL) The WHERE clause of
|
* @param string $whereClause (OPTIONAL) The WHERE clause of
|
||||||
* the query to be executed. DO NOT INCLUDE 'WHERE' KEYWORD.
|
* the query to be executed. DO NOT INCLUDE 'WHERE' KEYWORD.
|
||||||
* @return array Returns the rows from the database.
|
* @return array Returns the rows from the database.
|
||||||
*/
|
*/
|
||||||
public function get_batch($where_clause = '') {
|
public function get_batch($where_clause = '') {
|
||||||
$customers_role_id = $this->get_customers_role_id();
|
$customers_role_id = $this->get_customers_role_id();
|
||||||
|
|
||||||
if ($where_clause != '') {
|
if ($where_clause != '') {
|
||||||
$this->db->where($where_clause);
|
$this->db->where($where_clause);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->db->where('id_roles', $customers_role_id);
|
$this->db->where('id_roles', $customers_role_id);
|
||||||
|
|
||||||
return $this->db->get('ea_users')->result_array();
|
return $this->db->get('ea_users')->result_array();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the customers role id from the database.
|
* Get the customers role id from the database.
|
||||||
*
|
*
|
||||||
* @return int Returns the role id for the customer records.
|
* @return int Returns the role id for the customer records.
|
||||||
*/
|
*/
|
||||||
public function get_customers_role_id() {
|
public function get_customers_role_id() {
|
||||||
return $this->db->get_where('ea_roles', array('slug' => DB_SLUG_CUSTOMER))->row()->id;
|
return $this->db->get_where('ea_roles', array('slug' => DB_SLUG_CUSTOMER))->row()->id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End of file customers_model.php */
|
/* End of file customers_model.php */
|
||||||
/* Location: ./application/models/customers_model.php */
|
/* Location: ./application/models/customers_model.php */
|
||||||
|
|
|
@ -1,89 +1,89 @@
|
||||||
<?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 - 2016, Alex Tselegidis
|
* @copyright Copyright (c) 2013 - 2016, 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
|
||||||
* ---------------------------------------------------------------------------- */
|
* ---------------------------------------------------------------------------- */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Roles Model
|
* Roles Model
|
||||||
*
|
*
|
||||||
* @package Models
|
* @package Models
|
||||||
*/
|
*/
|
||||||
class Roles_Model extends CI_Model {
|
class Roles_Model extends CI_Model {
|
||||||
/**
|
/**
|
||||||
* Class Constructor
|
* Class Constructor
|
||||||
*/
|
*/
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the record id of a particular role.
|
* Get the record id of a particular role.
|
||||||
*
|
*
|
||||||
* @param string $role_slug The selected role slug. Slugs are
|
* @param string $role_slug The selected role slug. Slugs are
|
||||||
* defined in the "application/config/constants.php" file.
|
* defined in the "application/config/constants.php" file.
|
||||||
* @return int Returns the database id of the roles record.
|
* @return int Returns the database id of the roles record.
|
||||||
*/
|
*/
|
||||||
public function get_role_id($role_slug) {
|
public function get_role_id($role_slug) {
|
||||||
return $this->db->get_where('ea_roles', array('slug' => $role_slug))->row()->id;
|
return $this->db->get_where('ea_roles', array('slug' => $role_slug))->row()->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all the privileges (bool values) of a role slug.
|
* Returns all the privileges (bool values) of a role slug.
|
||||||
*
|
*
|
||||||
* The privilege numbers are converted into bool values of the four main actions (view,
|
* The privilege numbers are converted into bool values of the four main actions (view,
|
||||||
* add, edit, delete). By checking each value you can know if the user is able to perform
|
* add, edit, delete). By checking each value you can know if the user is able to perform
|
||||||
* this action.
|
* this action.
|
||||||
*
|
*
|
||||||
* @param string $slug The role slug.
|
* @param string $slug The role slug.
|
||||||
* @return array Returns the privilege value.
|
* @return array Returns the privilege value.
|
||||||
*/
|
*/
|
||||||
public function get_privileges($slug) {
|
public function get_privileges($slug) {
|
||||||
$privileges = $this->db->get_where('ea_roles', array('slug' => $slug))->row_array();
|
$privileges = $this->db->get_where('ea_roles', array('slug' => $slug))->row_array();
|
||||||
unset($privileges['id'], $privileges['name'], $privileges['slug'], $privileges['is_admin']);
|
unset($privileges['id'], $privileges['name'], $privileges['slug'], $privileges['is_admin']);
|
||||||
|
|
||||||
// Convert the numeric values to bool so that is easier to check whether a
|
// Convert the numeric values to bool so that is easier to check whether a
|
||||||
// user has the required privileges for a specific action.
|
// user has the required privileges for a specific action.
|
||||||
foreach($privileges as &$value) {
|
foreach($privileges as &$value) {
|
||||||
$privileges_number = $value;
|
$privileges_number = $value;
|
||||||
|
|
||||||
$value = array(
|
$value = array(
|
||||||
'view' => FALSE,
|
'view' => FALSE,
|
||||||
'add' => FALSE,
|
'add' => FALSE,
|
||||||
'edit' => FALSE,
|
'edit' => FALSE,
|
||||||
'delete' => FALSE
|
'delete' => FALSE
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($privileges_number > 0) {
|
if ($privileges_number > 0) {
|
||||||
if (intval($privileges_number / PRIV_DELETE) == 1) {
|
if (intval($privileges_number / PRIV_DELETE) == 1) {
|
||||||
$value['delete'] = TRUE;
|
$value['delete'] = TRUE;
|
||||||
$privileges_number -= PRIV_DELETE;
|
$privileges_number -= PRIV_DELETE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (intval($privileges_number / PRIV_EDIT) == 1) {
|
if (intval($privileges_number / PRIV_EDIT) == 1) {
|
||||||
$value['edit'] = TRUE;
|
$value['edit'] = TRUE;
|
||||||
$privileges_number -= PRIV_EDIT;
|
$privileges_number -= PRIV_EDIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (intval($privileges_number / PRIV_ADD) == 1) {
|
if (intval($privileges_number / PRIV_ADD) == 1) {
|
||||||
$value['add'] = TRUE;
|
$value['add'] = TRUE;
|
||||||
$privileges_number -= PRIV_ADD;
|
$privileges_number -= PRIV_ADD;
|
||||||
}
|
}
|
||||||
|
|
||||||
$value['view'] = TRUE;
|
$value['view'] = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $privileges;
|
return $privileges;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End of file roles_model.php */
|
/* End of file roles_model.php */
|
||||||
/* Location: ./application/models/roles_model.php */
|
/* Location: ./application/models/roles_model.php */
|
||||||
|
|
|
@ -1,375 +1,375 @@
|
||||||
<?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 - 2016, Alex Tselegidis
|
* @copyright Copyright (c) 2013 - 2016, 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
|
||||||
* ---------------------------------------------------------------------------- */
|
* ---------------------------------------------------------------------------- */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Services Model
|
* Services Model
|
||||||
*
|
*
|
||||||
* @package Models
|
* @package Models
|
||||||
*/
|
*/
|
||||||
class Services_Model extends CI_Model {
|
class Services_Model extends CI_Model {
|
||||||
/**
|
/**
|
||||||
* Class Constructor
|
* Class Constructor
|
||||||
*/
|
*/
|
||||||
function __construct() {
|
function __construct() {
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add (insert or update) a service record on the database
|
* Add (insert or update) a service record on the database
|
||||||
*
|
*
|
||||||
* @param array $service Contains the service data. If an 'id' value is provided then
|
* @param array $service Contains the service data. If an 'id' value is provided then
|
||||||
* the record will be updated.
|
* the record will be updated.
|
||||||
* @return numeric Returns the record id.
|
* @return numeric Returns the record id.
|
||||||
*/
|
*/
|
||||||
public function add($service) {
|
public function add($service) {
|
||||||
$this->validate($service);
|
$this->validate($service);
|
||||||
|
|
||||||
if (!isset($service['id'])) {
|
if (!isset($service['id'])) {
|
||||||
$service['id'] = $this->insert($service);
|
$service['id'] = $this->insert($service);
|
||||||
} else {
|
} else {
|
||||||
$this->update($service);
|
$this->update($service);
|
||||||
}
|
}
|
||||||
|
|
||||||
return intval($service['id']);
|
return intval($service['id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Insert service record into database.
|
* Insert service record into database.
|
||||||
*
|
*
|
||||||
* @param array $service Contains the service record data.
|
* @param array $service Contains the service record data.
|
||||||
* @return int Returns the new service record id.
|
* @return int Returns the new service record id.
|
||||||
*/
|
*/
|
||||||
public function insert($service) {
|
public function insert($service) {
|
||||||
if (!$this->db->insert('ea_services', $service)) {
|
if (!$this->db->insert('ea_services', $service)) {
|
||||||
throw new Exception('Could not insert service record.');
|
throw new Exception('Could not insert service record.');
|
||||||
}
|
}
|
||||||
return intval($this->db->insert_id());
|
return intval($this->db->insert_id());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update service record.
|
* Update service record.
|
||||||
*
|
*
|
||||||
* @param array $service Contains the service data. The record id needs to be included in
|
* @param array $service Contains the service data. The record id needs to be included in
|
||||||
* the array.
|
* the array.
|
||||||
*/
|
*/
|
||||||
public function update($service) {
|
public function update($service) {
|
||||||
$this->db->where('id', $service['id']);
|
$this->db->where('id', $service['id']);
|
||||||
if (!$this->db->update('ea_services', $service)) {
|
if (!$this->db->update('ea_services', $service)) {
|
||||||
throw new Exception('Could not update service record');
|
throw new Exception('Could not update service record');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether an service record already exists in the database.
|
* Checks whether an service record already exists in the database.
|
||||||
*
|
*
|
||||||
* @param array $service Contains the service data. Name, duration and price values
|
* @param array $service Contains the service data. Name, duration and price values
|
||||||
* are mandatory in order to perform the checks.
|
* are mandatory in order to perform the checks.
|
||||||
*/
|
*/
|
||||||
public function exists($service) {
|
public function exists($service) {
|
||||||
if (!isset($service['name'])
|
if (!isset($service['name'])
|
||||||
|| !isset($service['duration'])
|
|| !isset($service['duration'])
|
||||||
|| !isset($service['price'])) {
|
|| !isset($service['price'])) {
|
||||||
throw new Exception('Not all service fields are provided in order to check whether '
|
throw new Exception('Not all service fields are provided in order to check whether '
|
||||||
. 'a service record already exists: ' . print_r($service, TRUE));
|
. 'a service record already exists: ' . print_r($service, TRUE));
|
||||||
}
|
}
|
||||||
|
|
||||||
$num_rows = $this->db->get_where('ea_services', array(
|
$num_rows = $this->db->get_where('ea_services', array(
|
||||||
'name' => $service['name'],
|
'name' => $service['name'],
|
||||||
'duration' => $service['duration'],
|
'duration' => $service['duration'],
|
||||||
'price' => $service['price']
|
'price' => $service['price']
|
||||||
))->num_rows();
|
))->num_rows();
|
||||||
|
|
||||||
return ($num_rows > 0) ? TRUE : FALSE;
|
return ($num_rows > 0) ? TRUE : FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate a service record data.
|
* Validate a service record data.
|
||||||
*
|
*
|
||||||
* @param array $service Contains the service data.
|
* @param array $service Contains the service data.
|
||||||
* @return bool Returns the validation result.
|
* @return bool Returns the validation result.
|
||||||
*/
|
*/
|
||||||
public function validate($service) {
|
public function validate($service) {
|
||||||
$this->load->helper('data_validation');
|
$this->load->helper('data_validation');
|
||||||
|
|
||||||
// If record id is provided we need to check whether the record exists
|
// If record id is provided we need to check whether the record exists
|
||||||
// in the database.
|
// in the database.
|
||||||
if (isset($service['id'])) {
|
if (isset($service['id'])) {
|
||||||
$num_rows = $this->db->get_where('ea_services', array('id' => $service['id']))
|
$num_rows = $this->db->get_where('ea_services', array('id' => $service['id']))
|
||||||
->num_rows();
|
->num_rows();
|
||||||
if ($num_rows == 0) {
|
if ($num_rows == 0) {
|
||||||
throw new Exception('Provided service id does not exist in the database.');
|
throw new Exception('Provided service id does not exist in the database.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if service category id is valid (only when present)
|
// Check if service category id is valid (only when present)
|
||||||
if ($service['id_service_categories'] != NULL) {
|
if ($service['id_service_categories'] != NULL) {
|
||||||
$num_rows = $this->db->get_where('ea_service_categories',
|
$num_rows = $this->db->get_where('ea_service_categories',
|
||||||
array('id' => $service['id_service_categories']))->num_rows();
|
array('id' => $service['id_service_categories']))->num_rows();
|
||||||
if ($num_rows == 0) {
|
if ($num_rows == 0) {
|
||||||
throw new Exception('Provided service category id does not exist in database.');
|
throw new Exception('Provided service category id does not exist in database.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for required fields
|
// Check for required fields
|
||||||
if ($service['name'] == '') {
|
if ($service['name'] == '') {
|
||||||
throw new Exception('Not all required service fields where provided: '
|
throw new Exception('Not all required service fields where provided: '
|
||||||
. print_r($service, TRUE));
|
. print_r($service, TRUE));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Duration must be numeric
|
// Duration must be numeric
|
||||||
if ($service['duration'] !== NULL) {
|
if ($service['duration'] !== NULL) {
|
||||||
if (!is_numeric($service['duration'])) {
|
if (!is_numeric($service['duration'])) {
|
||||||
throw new Exception('Service duration is not numeric.');
|
throw new Exception('Service duration is not numeric.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($service['price'] !== NULL) {
|
if ($service['price'] !== NULL) {
|
||||||
if (!is_numeric($service['price'])) {
|
if (!is_numeric($service['price'])) {
|
||||||
throw new Exception('Service price is not numeric.');
|
throw new Exception('Service price is not numeric.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the record id of an existing record.
|
* Get the record id of an existing record.
|
||||||
*
|
*
|
||||||
* NOTICE! The record must exist, otherwise an exeption will be raised.
|
* NOTICE! The record must exist, otherwise an exeption will be raised.
|
||||||
*
|
*
|
||||||
* @param array $service Contains the service record data. Name, duration and price values
|
* @param array $service Contains the service record data. Name, duration and price values
|
||||||
* are mandatory for this method to complete.
|
* are mandatory for this method to complete.
|
||||||
*/
|
*/
|
||||||
public function find_record_id($service) {
|
public function find_record_id($service) {
|
||||||
if (!isset($service['name'])
|
if (!isset($service['name'])
|
||||||
|| !isset($service['duration'])
|
|| !isset($service['duration'])
|
||||||
|| !isset($service['price'])) {
|
|| !isset($service['price'])) {
|
||||||
throw new Exception('Not all required fields where provided in order to find the '
|
throw new Exception('Not all required fields where provided in order to find the '
|
||||||
. 'service record id.');
|
. 'service record id.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->db->get_where('ea_services', array(
|
$result = $this->db->get_where('ea_services', array(
|
||||||
'name' => $service['name'],
|
'name' => $service['name'],
|
||||||
'duration' => $service['duration'],
|
'duration' => $service['duration'],
|
||||||
'price' => $service['price']
|
'price' => $service['price']
|
||||||
));
|
));
|
||||||
|
|
||||||
if ($result->num_rows() == 0) {
|
if ($result->num_rows() == 0) {
|
||||||
throw new Exception('Cound not find service record id');
|
throw new Exception('Cound not find service record id');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result->row()->id;
|
return $result->row()->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a service record from database.
|
* Delete a service record from database.
|
||||||
*
|
*
|
||||||
* @param numeric $service_id Record id to be deleted.
|
* @param numeric $service_id Record id to be deleted.
|
||||||
* @return bool Returns the delete operation result.
|
* @return bool Returns the delete operation result.
|
||||||
*/
|
*/
|
||||||
public function delete($service_id) {
|
public function delete($service_id) {
|
||||||
if (!is_numeric($service_id)) {
|
if (!is_numeric($service_id)) {
|
||||||
throw new Exception('Invalid argument type $service_id (value:"' . $service_id . '"');
|
throw new Exception('Invalid argument type $service_id (value:"' . $service_id . '"');
|
||||||
}
|
}
|
||||||
|
|
||||||
$num_rows = $this->db->get_where('ea_services', array('id' => $service_id))->num_rows();
|
$num_rows = $this->db->get_where('ea_services', array('id' => $service_id))->num_rows();
|
||||||
if ($num_rows == 0) {
|
if ($num_rows == 0) {
|
||||||
return FALSE; // Record does not exist
|
return FALSE; // Record does not exist
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->db->delete('ea_services', array('id' => $service_id));
|
return $this->db->delete('ea_services', array('id' => $service_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a specific row from the services db table.
|
* Get a specific row from the services db table.
|
||||||
*
|
*
|
||||||
* @param numeric $service_id The record's id to be returned.
|
* @param numeric $service_id The record's id to be returned.
|
||||||
* @return array Returns an associative array with the selected
|
* @return array Returns an associative array with the selected
|
||||||
* record's data. Each key has the same name as the database
|
* record's data. Each key has the same name as the database
|
||||||
* field names.
|
* field names.
|
||||||
*/
|
*/
|
||||||
public function get_row($service_id) {
|
public function get_row($service_id) {
|
||||||
if (!is_numeric($service_id)) {
|
if (!is_numeric($service_id)) {
|
||||||
throw new Exception('$service_id argument is not an numeric (value: "' . $service_id . '")');
|
throw new Exception('$service_id argument is not an numeric (value: "' . $service_id . '")');
|
||||||
}
|
}
|
||||||
return $this->db->get_where('ea_services', array('id' => $service_id))->row_array();
|
return $this->db->get_where('ea_services', array('id' => $service_id))->row_array();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a specific field value from the database.
|
* Get a specific field value from the database.
|
||||||
*
|
*
|
||||||
* @param string $field_name The field name of the value to be
|
* @param string $field_name The field name of the value to be
|
||||||
* returned.
|
* returned.
|
||||||
* @param int $service_id The selected record's id.
|
* @param int $service_id The selected record's id.
|
||||||
* @return string Returns the records value from the database.
|
* @return string Returns the records value from the database.
|
||||||
*/
|
*/
|
||||||
public function get_value($field_name, $service_id) {
|
public function get_value($field_name, $service_id) {
|
||||||
if (!is_numeric($service_id)) {
|
if (!is_numeric($service_id)) {
|
||||||
throw new Exception('Invalid argument provided as $service_id : ' . $service_id);
|
throw new Exception('Invalid argument provided as $service_id : ' . $service_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_string($field_name)) {
|
if (!is_string($field_name)) {
|
||||||
throw new Exception('$field_name argument is not a string : ' . $field_name);
|
throw new Exception('$field_name argument is not a string : ' . $field_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->db->get_where('ea_services', array('id' => $service_id))->num_rows() == 0) {
|
if ($this->db->get_where('ea_services', array('id' => $service_id))->num_rows() == 0) {
|
||||||
throw new Exception('The record with the $service_id argument does not exist in the database : ' . $service_id);
|
throw new Exception('The record with the $service_id argument does not exist in the database : ' . $service_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
$row_data = $this->db->get_where('ea_services', array('id' => $service_id))->row_array();
|
$row_data = $this->db->get_where('ea_services', array('id' => $service_id))->row_array();
|
||||||
if (!isset($row_data[$field_name])) {
|
if (!isset($row_data[$field_name])) {
|
||||||
throw new Exception('The given $field_name argument does not exist in the database : ' . $field_name);
|
throw new Exception('The given $field_name argument does not exist in the database : ' . $field_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
$setting = $this->db->get_where('ea_services', array('id' => $service_id))->row_array();
|
$setting = $this->db->get_where('ea_services', array('id' => $service_id))->row_array();
|
||||||
return $setting[$field_name];
|
return $setting[$field_name];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all, or specific records from service's table.
|
* Get all, or specific records from service's table.
|
||||||
*
|
*
|
||||||
* @example $this->Model->getBatch('id = ' . $recordId);
|
* @example $this->Model->getBatch('id = ' . $recordId);
|
||||||
*
|
*
|
||||||
* @param string $whereClause (OPTIONAL) The WHERE clause of
|
* @param string $whereClause (OPTIONAL) The WHERE clause of
|
||||||
* the query to be executed. DO NOT INCLUDE 'WHERE' KEYWORD.
|
* the query to be executed. DO NOT INCLUDE 'WHERE' KEYWORD.
|
||||||
* @return array Returns the rows from the database.
|
* @return array Returns the rows from the database.
|
||||||
*/
|
*/
|
||||||
public function get_batch($where_clause = NULL) {
|
public function get_batch($where_clause = NULL) {
|
||||||
if ($where_clause != NULL) {
|
if ($where_clause != NULL) {
|
||||||
$this->db->where($where_clause);
|
$this->db->where($where_clause);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->db->get('ea_services')->result_array();
|
return $this->db->get('ea_services')->result_array();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method returns all the services from the database.
|
* This method returns all the services from the database.
|
||||||
*
|
*
|
||||||
* @return array Returns an object array with all the
|
* @return array Returns an object array with all the
|
||||||
* database services.
|
* database services.
|
||||||
*/
|
*/
|
||||||
public function get_available_services() {
|
public function get_available_services() {
|
||||||
$this->db->distinct();
|
$this->db->distinct();
|
||||||
return $this->db
|
return $this->db
|
||||||
->select('ea_services.*, ea_service_categories.name AS category_name, '
|
->select('ea_services.*, ea_service_categories.name AS category_name, '
|
||||||
. 'ea_service_categories.id AS category_id')
|
. 'ea_service_categories.id AS category_id')
|
||||||
->from('ea_services')
|
->from('ea_services')
|
||||||
->join('ea_services_providers',
|
->join('ea_services_providers',
|
||||||
'ea_services_providers.id_services = ea_services.id', 'inner')
|
'ea_services_providers.id_services = ea_services.id', 'inner')
|
||||||
->join('ea_service_categories',
|
->join('ea_service_categories',
|
||||||
'ea_service_categories.id = ea_services.id_service_categories', 'left')
|
'ea_service_categories.id = ea_services.id_service_categories', 'left')
|
||||||
->get()->result_array();
|
->get()->result_array();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add (insert or update) a service category record into database.
|
* Add (insert or update) a service category record into database.
|
||||||
*
|
*
|
||||||
* @param array $category Containst the service category data.
|
* @param array $category Containst the service category data.
|
||||||
* @return int Returns the record id.s
|
* @return int Returns the record id.s
|
||||||
*/
|
*/
|
||||||
public function add_category($category) {
|
public function add_category($category) {
|
||||||
if (!$this->validate_category($category)) {
|
if (!$this->validate_category($category)) {
|
||||||
throw new Exception('Service category data are invalid.');
|
throw new Exception('Service category data are invalid.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($category['id'])) {
|
if (!isset($category['id'])) {
|
||||||
$this->db->insert('ea_service_categories', $category);
|
$this->db->insert('ea_service_categories', $category);
|
||||||
$category['id'] = $this->db->insert_id();
|
$category['id'] = $this->db->insert_id();
|
||||||
} else {
|
} else {
|
||||||
$this->db->where('id', $category['id']);
|
$this->db->where('id', $category['id']);
|
||||||
$this->db->update('ea_service_categories', $category);
|
$this->db->update('ea_service_categories', $category);
|
||||||
}
|
}
|
||||||
|
|
||||||
return intval($category['id']);
|
return intval($category['id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a service category record from the database.
|
* Delete a service category record from the database.
|
||||||
*
|
*
|
||||||
* @param numeric $category_id Record id to be deleted.
|
* @param numeric $category_id Record id to be deleted.
|
||||||
* @return bool Returns the delete operation result.
|
* @return bool Returns the delete operation result.
|
||||||
*/
|
*/
|
||||||
public function delete_category($category_id) {
|
public function delete_category($category_id) {
|
||||||
if (!is_numeric($category_id)) {
|
if (!is_numeric($category_id)) {
|
||||||
throw new Exception('Invalid argument given for $category_id: ' . $category_id);
|
throw new Exception('Invalid argument given for $category_id: ' . $category_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
$num_rows = $this->db->get_where('ea_service_categories', array('id' => $category_id))
|
$num_rows = $this->db->get_where('ea_service_categories', array('id' => $category_id))
|
||||||
->num_rows();
|
->num_rows();
|
||||||
if ($num_rows == 0) {
|
if ($num_rows == 0) {
|
||||||
throw new Exception('Service category record not found in database.');
|
throw new Exception('Service category record not found in database.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->db->where('id', $category_id);
|
$this->db->where('id', $category_id);
|
||||||
return $this->db->delete('ea_service_categories');
|
return $this->db->delete('ea_service_categories');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a service category record data.
|
* Get a service category record data.
|
||||||
*
|
*
|
||||||
* @param numeric $category_id Record id to be retrieved.
|
* @param numeric $category_id Record id to be retrieved.
|
||||||
* @return array Returns the record data from the database.
|
* @return array Returns the record data from the database.
|
||||||
*/
|
*/
|
||||||
public function get_category($category_id) {
|
public function get_category($category_id) {
|
||||||
if (!is_numeric($category_id)) {
|
if (!is_numeric($category_id)) {
|
||||||
throw new Exception('Invalid argument type given $category_id: ' . $category_id);
|
throw new Exception('Invalid argument type given $category_id: ' . $category_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->db->get_where('ea_service_categories', array('id' => $category_id));
|
$result = $this->db->get_where('ea_service_categories', array('id' => $category_id));
|
||||||
|
|
||||||
if ($result->num_rows() == 0) {
|
if ($result->num_rows() == 0) {
|
||||||
throw new Exception('Service category record does not exist.');
|
throw new Exception('Service category record does not exist.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result->row_array();
|
return $result->row_array();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all service category records from database.
|
* Get all service category records from database.
|
||||||
*
|
*
|
||||||
* @return array Returns an array that contains all the service category records.
|
* @return array Returns an array that contains all the service category records.
|
||||||
*/
|
*/
|
||||||
public function get_all_categories($where = '') {
|
public function get_all_categories($where = '') {
|
||||||
if ($where !== '') $this->db->where($where);
|
if ($where !== '') $this->db->where($where);
|
||||||
return $this->db->get('ea_service_categories')->result_array();
|
return $this->db->get('ea_service_categories')->result_array();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate a service category record data. This method must be used before adding
|
* Validate a service category record data. This method must be used before adding
|
||||||
* a service category record into database in order to secure the record integrity.
|
* a service category record into database in order to secure the record integrity.
|
||||||
*
|
*
|
||||||
* @param array $category Contains the service category data.
|
* @param array $category Contains the service category data.
|
||||||
* @return bool Returns the validation result.
|
* @return bool Returns the validation result.
|
||||||
*/
|
*/
|
||||||
public function validate_category($category) {
|
public function validate_category($category) {
|
||||||
try {
|
try {
|
||||||
// Required Fields
|
// Required Fields
|
||||||
if (!isset($category['name'])) {
|
if (!isset($category['name'])) {
|
||||||
throw new Exception('Not all required fields where provided ');
|
throw new Exception('Not all required fields where provided ');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($category['name'] == '' || $category['name'] == NULL) {
|
if ($category['name'] == '' || $category['name'] == NULL) {
|
||||||
throw new Exception('Required fields cannot be empty or null ($category: '
|
throw new Exception('Required fields cannot be empty or null ($category: '
|
||||||
. print_r($category, TRUE) . ')');
|
. print_r($category, TRUE) . ')');
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} catch(Exception $exc) {
|
} catch(Exception $exc) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End of file services_model.php */
|
/* End of file services_model.php */
|
||||||
/* Location: ./application/models/services_model.php */
|
/* Location: ./application/models/services_model.php */
|
||||||
|
|
|
@ -1,149 +1,149 @@
|
||||||
<?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 - 2016, Alex Tselegidis
|
* @copyright Copyright (c) 2013 - 2016, 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
|
||||||
* ---------------------------------------------------------------------------- */
|
* ---------------------------------------------------------------------------- */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Settings Model
|
* Settings Model
|
||||||
*
|
*
|
||||||
* @package Models
|
* @package Models
|
||||||
*/
|
*/
|
||||||
class Settings_Model extends CI_Model {
|
class Settings_Model extends CI_Model {
|
||||||
/**
|
/**
|
||||||
* Class Constructor
|
* Class Constructor
|
||||||
*/
|
*/
|
||||||
function __construct() {
|
function __construct() {
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get setting value from database.
|
* Get setting value from database.
|
||||||
*
|
*
|
||||||
* This method returns a system setting from the
|
* This method returns a system setting from the
|
||||||
* database.
|
* database.
|
||||||
*
|
*
|
||||||
* @expectedException Exception
|
* @expectedException Exception
|
||||||
*
|
*
|
||||||
* @param string $name The database setting name.
|
* @param string $name The database setting name.
|
||||||
* @return string Returns the database value for
|
* @return string Returns the database value for
|
||||||
* the selected setting.
|
* the selected setting.
|
||||||
*/
|
*/
|
||||||
function get_setting($name) {
|
function get_setting($name) {
|
||||||
if (!is_string($name)) { // Check argument type.
|
if (!is_string($name)) { // Check argument type.
|
||||||
throw new Exception('$name argument is not a string : ' . $name);
|
throw new Exception('$name argument is not a string : ' . $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->db->get_where('ea_settings', array('name' => $name))->num_rows() == 0) { // Check if setting exists in db.
|
if ($this->db->get_where('ea_settings', array('name' => $name))->num_rows() == 0) { // Check if setting exists in db.
|
||||||
throw new Exception('$name setting does not exist in database : ' . $name);
|
throw new Exception('$name setting does not exist in database : ' . $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = $this->db->get_where('ea_settings', array('name' => $name));
|
$query = $this->db->get_where('ea_settings', array('name' => $name));
|
||||||
$setting = ($query->num_rows() > 0) ? $query->row() : '';
|
$setting = ($query->num_rows() > 0) ? $query->row() : '';
|
||||||
return $setting->value;
|
return $setting->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method sets the value for a specific setting
|
* This method sets the value for a specific setting
|
||||||
* on the database. If the setting doesn't exist, it
|
* on the database. If the setting doesn't exist, it
|
||||||
* is going to be created, otherwise updated.
|
* is going to be created, otherwise updated.
|
||||||
*
|
*
|
||||||
* @expectedException Exception
|
* @expectedException Exception
|
||||||
*
|
*
|
||||||
* @param string $name The setting name.
|
* @param string $name The setting name.
|
||||||
* @param type $value The setting value.
|
* @param type $value The setting value.
|
||||||
* @return int Returns the setting database id.
|
* @return int Returns the setting database id.
|
||||||
*/
|
*/
|
||||||
function set_setting($name, $value) {
|
function set_setting($name, $value) {
|
||||||
if (!is_string($name)) {
|
if (!is_string($name)) {
|
||||||
throw new Exception('$name argument is not a string : ' . $name);
|
throw new Exception('$name argument is not a string : ' . $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = $this->db->get_where('ea_settings', array('name' => $name));
|
$query = $this->db->get_where('ea_settings', array('name' => $name));
|
||||||
if ($query->num_rows() > 0) {
|
if ($query->num_rows() > 0) {
|
||||||
// Update setting
|
// Update setting
|
||||||
if (!$this->db->update('ea_settings', array('value' => $value), array('name' => $name))) {
|
if (!$this->db->update('ea_settings', array('value' => $value), array('name' => $name))) {
|
||||||
throw new Exception('Could not update database setting.');
|
throw new Exception('Could not update database setting.');
|
||||||
}
|
}
|
||||||
$setting_id = intval($this->db->get_where('ea_settings', array('name' => $name))->row()->id);
|
$setting_id = intval($this->db->get_where('ea_settings', array('name' => $name))->row()->id);
|
||||||
} else {
|
} else {
|
||||||
// Insert setting
|
// Insert setting
|
||||||
$insert_data = array(
|
$insert_data = array(
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'value' => $value
|
'value' => $value
|
||||||
);
|
);
|
||||||
if (!$this->db->insert('ea_settings', $insert_data)) {
|
if (!$this->db->insert('ea_settings', $insert_data)) {
|
||||||
throw new Exception('Could not insert database setting');
|
throw new Exception('Could not insert database setting');
|
||||||
}
|
}
|
||||||
$setting_id = intval($this->db->insert_id());
|
$setting_id = intval($this->db->insert_id());
|
||||||
}
|
}
|
||||||
|
|
||||||
return $setting_id;
|
return $setting_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a setting from the database.
|
* Remove a setting from the database.
|
||||||
*
|
*
|
||||||
* @expectedException Exception
|
* @expectedException Exception
|
||||||
*
|
*
|
||||||
* @param string $name The setting name to be removed.
|
* @param string $name The setting name to be removed.
|
||||||
* @return bool Returns the delete operation result.
|
* @return bool Returns the delete operation result.
|
||||||
*/
|
*/
|
||||||
function remove_setting($name) {
|
function remove_setting($name) {
|
||||||
if (!is_string($name)) {
|
if (!is_string($name)) {
|
||||||
throw new Exception('$name is not a string : ' . $name);
|
throw new Exception('$name is not a string : ' . $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->db->get_where('ea_settings', array('name' => $name))->num_rows() == 0) {
|
if ($this->db->get_where('ea_settings', array('name' => $name))->num_rows() == 0) {
|
||||||
return FALSE; // There is no such setting.
|
return FALSE; // There is no such setting.
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->db->delete('ea_settings', array('name' => $name));
|
return $this->db->delete('ea_settings', array('name' => $name));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves all the system settings into the database.
|
* Saves all the system settings into the database.
|
||||||
*
|
*
|
||||||
* This method is usefull when trying to save all the system settings at once instead of
|
* This method is usefull when trying to save all the system settings at once instead of
|
||||||
* saving them one by one.
|
* saving them one by one.
|
||||||
*
|
*
|
||||||
* @param array $settings Contains all the system settings.
|
* @param array $settings Contains all the system settings.
|
||||||
* @return bool Returns the save operation result.
|
* @return bool Returns the save operation result.
|
||||||
*
|
*
|
||||||
* @throws Exception When the update operation won't work for a specific setting.
|
* @throws Exception When the update operation won't work for a specific setting.
|
||||||
*/
|
*/
|
||||||
public function save_settings($settings) {
|
public function save_settings($settings) {
|
||||||
if (!is_array($settings)) {
|
if (!is_array($settings)) {
|
||||||
throw new Exception('$settings argument is invalid: '. print_r($settings, TRUE));
|
throw new Exception('$settings argument is invalid: '. print_r($settings, TRUE));
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($settings as $setting) {
|
foreach($settings as $setting) {
|
||||||
$this->db->where('name', $setting['name']);
|
$this->db->where('name', $setting['name']);
|
||||||
if (!$this->db->update('ea_settings', array('value' => $setting['value']))) {
|
if (!$this->db->update('ea_settings', array('value' => $setting['value']))) {
|
||||||
throw new Exception('Could not save setting (' . $setting['name']
|
throw new Exception('Could not save setting (' . $setting['name']
|
||||||
. ' - ' . $setting['value'] . ')');
|
. ' - ' . $setting['value'] . ')');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all the system settings at once.
|
* Returns all the system settings at once.
|
||||||
*
|
*
|
||||||
* @return array Array of all the system settings stored in the 'ea_settings' table.
|
* @return array Array of all the system settings stored in the 'ea_settings' table.
|
||||||
*/
|
*/
|
||||||
public function get_settings() {
|
public function get_settings() {
|
||||||
return $this->db->get('ea_settings')->result_array();
|
return $this->db->get('ea_settings')->result_array();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End of file settings_model.php */
|
/* End of file settings_model.php */
|
||||||
/* Location: ./application/models/settings_model.php */
|
/* Location: ./application/models/settings_model.php */
|
||||||
|
|
|
@ -1,155 +1,155 @@
|
||||||
<?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 - 2016, Alex Tselegidis
|
* @copyright Copyright (c) 2013 - 2016, 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
|
||||||
* ---------------------------------------------------------------------------- */
|
* ---------------------------------------------------------------------------- */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User Model
|
* User Model
|
||||||
*
|
*
|
||||||
* Contains current user's methods.
|
* Contains current user's methods.
|
||||||
*
|
*
|
||||||
* @package Model
|
* @package Model
|
||||||
*/
|
*/
|
||||||
class User_Model extends CI_Model {
|
class User_Model extends CI_Model {
|
||||||
/**
|
/**
|
||||||
* Class Constructor
|
* Class Constructor
|
||||||
*/
|
*/
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the user settings from the database.
|
* Returns the user settings from the database.
|
||||||
*
|
*
|
||||||
* @param numeric $user_id User record id of which the settings will be returned.
|
* @param numeric $user_id User record id of which the settings will be returned.
|
||||||
* @return array Returns an array with user settings.
|
* @return array Returns an array with user settings.
|
||||||
*/
|
*/
|
||||||
public function get_settings($user_id) {
|
public function get_settings($user_id) {
|
||||||
$user = $this->db->get_where('ea_users', array('id' => $user_id))->row_array();
|
$user = $this->db->get_where('ea_users', array('id' => $user_id))->row_array();
|
||||||
$user['settings'] = $this->db->get_where('ea_user_settings', array('id_users' => $user_id))->row_array();
|
$user['settings'] = $this->db->get_where('ea_user_settings', array('id_users' => $user_id))->row_array();
|
||||||
unset($user['settings']['id_users']);
|
unset($user['settings']['id_users']);
|
||||||
return $user;
|
return $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method saves the user settings into the database.
|
* This method saves the user settings into the database.
|
||||||
*
|
*
|
||||||
* @param array $user Contains the current users settings.
|
* @param array $user Contains the current users settings.
|
||||||
* @return bool Returns the operation result.
|
* @return bool Returns the operation result.
|
||||||
*/
|
*/
|
||||||
public function save_settings($user) {
|
public function save_settings($user) {
|
||||||
$user_settings = $user['settings'];
|
$user_settings = $user['settings'];
|
||||||
$user_settings['id_users'] = $user['id'];
|
$user_settings['id_users'] = $user['id'];
|
||||||
unset($user['settings']);
|
unset($user['settings']);
|
||||||
|
|
||||||
// Prepare user password (hash).
|
// Prepare user password (hash).
|
||||||
if (isset($user_settings['password'])) {
|
if (isset($user_settings['password'])) {
|
||||||
$this->load->helper('general');
|
$this->load->helper('general');
|
||||||
$salt = $this->db->get_where('ea_user_settings', array('id_users' => $user['id']))->row()->salt;
|
$salt = $this->db->get_where('ea_user_settings', array('id_users' => $user['id']))->row()->salt;
|
||||||
$user_settings['password'] = hash_password($salt, $user_settings['password']);
|
$user_settings['password'] = hash_password($salt, $user_settings['password']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->db->update('ea_users', $user, array('id' => $user['id']))) {
|
if (!$this->db->update('ea_users', $user, array('id' => $user['id']))) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->db->update('ea_user_settings', $user_settings, array('id_users' => $user['id']))) {
|
if (!$this->db->update('ea_user_settings', $user_settings, array('id_users' => $user['id']))) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve user's salt from database.
|
* Retrieve user's salt from database.
|
||||||
*
|
*
|
||||||
* @param string $username This will be used to find the user record.
|
* @param string $username This will be used to find the user record.
|
||||||
* @return string Returns the salt db value.
|
* @return string Returns the salt db value.
|
||||||
*/
|
*/
|
||||||
public function get_salt($username) {
|
public function get_salt($username) {
|
||||||
$user = $this->db->get_where('ea_user_settings', array('username' => $username))->row_array();
|
$user = $this->db->get_where('ea_user_settings', array('username' => $username))->row_array();
|
||||||
return ($user) ? $user['salt'] : '';
|
return ($user) ? $user['salt'] : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs the check of the given user credentials.
|
* Performs the check of the given user credentials.
|
||||||
*
|
*
|
||||||
* @param string $username Given user's name.
|
* @param string $username Given user's name.
|
||||||
* @param type $password Given user's password (not hashed yet).
|
* @param type $password Given user's password (not hashed yet).
|
||||||
* @return array|null Returns the session data of the logged in user or null on
|
* @return array|null Returns the session data of the logged in user or null on
|
||||||
* failure.
|
* failure.
|
||||||
*/
|
*/
|
||||||
public function check_login($username, $password) {
|
public function check_login($username, $password) {
|
||||||
$this->load->helper('general');
|
$this->load->helper('general');
|
||||||
$salt = $this->user_model->get_salt($username);
|
$salt = $this->user_model->get_salt($username);
|
||||||
$password = hash_password($salt, $password);
|
$password = hash_password($salt, $password);
|
||||||
|
|
||||||
$user_data = $this->db
|
$user_data = $this->db
|
||||||
->select('ea_users.id AS user_id, ea_users.email AS user_email, '
|
->select('ea_users.id AS user_id, ea_users.email AS user_email, '
|
||||||
. 'ea_roles.slug AS role_slug, ea_user_settings.username')
|
. 'ea_roles.slug AS role_slug, ea_user_settings.username')
|
||||||
->from('ea_users')
|
->from('ea_users')
|
||||||
->join('ea_roles', 'ea_roles.id = ea_users.id_roles', 'inner')
|
->join('ea_roles', 'ea_roles.id = ea_users.id_roles', 'inner')
|
||||||
->join('ea_user_settings', 'ea_user_settings.id_users = ea_users.id')
|
->join('ea_user_settings', 'ea_user_settings.id_users = ea_users.id')
|
||||||
->where('ea_user_settings.username', $username)
|
->where('ea_user_settings.username', $username)
|
||||||
->where('ea_user_settings.password', $password)
|
->where('ea_user_settings.password', $password)
|
||||||
->get()->row_array();
|
->get()->row_array();
|
||||||
|
|
||||||
return ($user_data) ? $user_data : NULL;
|
return ($user_data) ? $user_data : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the given user's display name (first + last name).
|
* Get the given user's display name (first + last name).
|
||||||
*
|
*
|
||||||
* @param numeric $user_id The given user record id.
|
* @param numeric $user_id The given user record id.
|
||||||
* @return string Returns the user display name.
|
* @return string Returns the user display name.
|
||||||
*/
|
*/
|
||||||
public function get_user_display_name($user_id) {
|
public function get_user_display_name($user_id) {
|
||||||
if (!is_numeric($user_id))
|
if (!is_numeric($user_id))
|
||||||
throw new Exception ('Invalid argument given ($user_id = "' . $user_id . '").');
|
throw new Exception ('Invalid argument given ($user_id = "' . $user_id . '").');
|
||||||
$user = $this->db->get_where('ea_users', array('id' => $user_id))->row_array();
|
$user = $this->db->get_where('ea_users', array('id' => $user_id))->row_array();
|
||||||
return $user['first_name'] . ' ' . $user['last_name'];
|
return $user['first_name'] . ' ' . $user['last_name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the given arguments correspond to an existing user record, generate a new
|
* If the given arguments correspond to an existing user record, generate a new
|
||||||
* password and send it with an email.
|
* password and send it with an email.
|
||||||
*
|
*
|
||||||
* @param string $username
|
* @param string $username
|
||||||
* @param string $email
|
* @param string $email
|
||||||
* @return string|bool Returns the new password on success or FALSE on failure.
|
* @return string|bool Returns the new password on success or FALSE on failure.
|
||||||
*/
|
*/
|
||||||
public function regenerate_password($username, $email) {
|
public function regenerate_password($username, $email) {
|
||||||
$this->load->helper('general');
|
$this->load->helper('general');
|
||||||
|
|
||||||
$result = $this->db
|
$result = $this->db
|
||||||
->select('ea_users.id')
|
->select('ea_users.id')
|
||||||
->from('ea_users')
|
->from('ea_users')
|
||||||
->join('ea_user_settings', 'ea_user_settings.id_users = ea_users.id', 'inner')
|
->join('ea_user_settings', 'ea_user_settings.id_users = ea_users.id', 'inner')
|
||||||
->where('ea_users.email', $email)
|
->where('ea_users.email', $email)
|
||||||
->where('ea_user_settings.username', $username)
|
->where('ea_user_settings.username', $username)
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
if ($result->num_rows() == 0) return FALSE;
|
if ($result->num_rows() == 0) return FALSE;
|
||||||
|
|
||||||
$user_id = $result->row()->id;
|
$user_id = $result->row()->id;
|
||||||
|
|
||||||
// Create a new password and send it with an email to the given email address.
|
// Create a new password and send it with an email to the given email address.
|
||||||
$new_password = generate_random_string();
|
$new_password = generate_random_string();
|
||||||
$salt = $this->db->get_where('ea_user_settings', array('id_users' => $user_id))->row()->salt;
|
$salt = $this->db->get_where('ea_user_settings', array('id_users' => $user_id))->row()->salt;
|
||||||
$hash_password = hash_password($salt, $new_password);
|
$hash_password = hash_password($salt, $new_password);
|
||||||
$this->db->update('ea_user_settings', array('password' => $hash_password), array('id_users' => $user_id));
|
$this->db->update('ea_user_settings', array('password' => $hash_password), array('id_users' => $user_id));
|
||||||
|
|
||||||
return $new_password;
|
return $new_password;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End of file user_model.php */
|
/* End of file user_model.php */
|
||||||
/* Location: ./application/models/user_model.php */
|
/* Location: ./application/models/user_model.php */
|
||||||
|
|
|
@ -1,140 +1,140 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<title><?php echo $company_name; ?> | Easy!Appointments</title>
|
<title><?php echo $company_name; ?> | Easy!Appointments</title>
|
||||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
|
|
||||||
<link rel="icon" type="image/x-icon"
|
<link rel="icon" type="image/x-icon"
|
||||||
href="<?php echo $base_url; ?>/assets/img/favicon.ico">
|
href="<?php echo $base_url; ?>/assets/img/favicon.ico">
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
// ------------------------------------------------------------
|
// ------------------------------------------------------------
|
||||||
// INCLUDE CSS FILES
|
// INCLUDE CSS FILES
|
||||||
// ------------------------------------------------------------ ?>
|
// ------------------------------------------------------------ ?>
|
||||||
<link
|
<link
|
||||||
rel="stylesheet"
|
rel="stylesheet"
|
||||||
type="text/css"
|
type="text/css"
|
||||||
href="<?php echo $base_url; ?>/assets/ext/bootstrap/css/bootstrap.min.css">
|
href="<?php echo $base_url; ?>/assets/ext/bootstrap/css/bootstrap.min.css">
|
||||||
<link
|
<link
|
||||||
rel="stylesheet"
|
rel="stylesheet"
|
||||||
type="text/css"
|
type="text/css"
|
||||||
href="<?php echo $base_url; ?>/assets/ext/jquery-ui/jquery-ui.min.css">
|
href="<?php echo $base_url; ?>/assets/ext/jquery-ui/jquery-ui.min.css">
|
||||||
<link
|
<link
|
||||||
rel="stylesheet"
|
rel="stylesheet"
|
||||||
type="text/css"
|
type="text/css"
|
||||||
href="<?php echo $base_url; ?>/assets/ext/jquery-qtip/jquery.qtip.min.css">
|
href="<?php echo $base_url; ?>/assets/ext/jquery-qtip/jquery.qtip.min.css">
|
||||||
<link
|
<link
|
||||||
rel="stylesheet"
|
rel="stylesheet"
|
||||||
type="text/css"
|
type="text/css"
|
||||||
href="<?php echo $base_url; ?>/assets/ext/jquery-jscrollpane/jquery.jscrollpane.css">
|
href="<?php echo $base_url; ?>/assets/ext/jquery-jscrollpane/jquery.jscrollpane.css">
|
||||||
<link
|
<link
|
||||||
rel="stylesheet"
|
rel="stylesheet"
|
||||||
type="text/css"
|
type="text/css"
|
||||||
href="<?php echo $base_url; ?>/assets/css/backend.css">
|
href="<?php echo $base_url; ?>/assets/css/backend.css">
|
||||||
<link
|
<link
|
||||||
rel="stylesheet"
|
rel="stylesheet"
|
||||||
type="text/css"
|
type="text/css"
|
||||||
href="<?php echo $base_url; ?>/assets/css/general.css">
|
href="<?php echo $base_url; ?>/assets/css/general.css">
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
// ------------------------------------------------------------
|
// ------------------------------------------------------------
|
||||||
// INCLUDE JAVASCRIPT FILES
|
// INCLUDE JAVASCRIPT FILES
|
||||||
// ------------------------------------------------------------ ?>
|
// ------------------------------------------------------------ ?>
|
||||||
<script
|
<script
|
||||||
type="text/javascript"
|
type="text/javascript"
|
||||||
src="<?php echo $base_url; ?>/assets/ext/jquery/jquery.min.js"></script>
|
src="<?php echo $base_url; ?>/assets/ext/jquery/jquery.min.js"></script>
|
||||||
<script
|
<script
|
||||||
type="text/javascript"
|
type="text/javascript"
|
||||||
src="<?php echo $base_url; ?>/assets/ext/jquery-ui/jquery-ui.min.js"></script>
|
src="<?php echo $base_url; ?>/assets/ext/jquery-ui/jquery-ui.min.js"></script>
|
||||||
<script
|
<script
|
||||||
type="text/javascript"
|
type="text/javascript"
|
||||||
src="<?php echo $base_url; ?>/assets/ext/jquery-qtip/jquery.qtip.min.js"></script>
|
src="<?php echo $base_url; ?>/assets/ext/jquery-qtip/jquery.qtip.min.js"></script>
|
||||||
<script
|
<script
|
||||||
type="text/javascript"
|
type="text/javascript"
|
||||||
src="<?php echo $base_url; ?>/assets/ext/bootstrap/js/bootstrap.min.js"></script>
|
src="<?php echo $base_url; ?>/assets/ext/bootstrap/js/bootstrap.min.js"></script>
|
||||||
<script
|
<script
|
||||||
type="text/javascript"
|
type="text/javascript"
|
||||||
src="<?php echo $base_url; ?>/assets/ext/datejs/date.js"></script>
|
src="<?php echo $base_url; ?>/assets/ext/datejs/date.js"></script>
|
||||||
<script
|
<script
|
||||||
type="text/javascript"
|
type="text/javascript"
|
||||||
src="<?php echo $base_url; ?>/assets/ext/jquery-jscrollpane/jquery.jscrollpane.min.js"></script>
|
src="<?php echo $base_url; ?>/assets/ext/jquery-jscrollpane/jquery.jscrollpane.min.js"></script>
|
||||||
<script
|
<script
|
||||||
type="text/javascript"
|
type="text/javascript"
|
||||||
src="<?php echo $base_url; ?>/assets/ext/jquery-mousewheel/jquery.mousewheel.js"></script>
|
src="<?php echo $base_url; ?>/assets/ext/jquery-mousewheel/jquery.mousewheel.js"></script>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
// Global JavaScript Variables - Used in all backend pages.
|
// Global JavaScript Variables - Used in all backend pages.
|
||||||
var availableLanguages = <?php echo json_encode($this->config->item('available_languages')); ?>;
|
var availableLanguages = <?php echo json_encode($this->config->item('available_languages')); ?>;
|
||||||
var EALang = <?php echo json_encode($this->lang->language); ?>;
|
var EALang = <?php echo json_encode($this->lang->language); ?>;
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div id="header">
|
<div id="header">
|
||||||
<div id="header-logo">
|
<div id="header-logo">
|
||||||
<img src="<?php echo $base_url; ?>/assets/img/logo.png">
|
<img src="<?php echo $base_url; ?>/assets/img/logo.png">
|
||||||
<span><?php echo $company_name; ?></span>
|
<span><?php echo $company_name; ?></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="header-menu">
|
<div id="header-menu">
|
||||||
<?php // CALENDAR MENU ITEM
|
<?php // CALENDAR MENU ITEM
|
||||||
// ------------------------------------------------------ ?>
|
// ------------------------------------------------------ ?>
|
||||||
<?php $hidden = ($privileges[PRIV_APPOINTMENTS]['view'] == TRUE) ? '' : 'hidden'; ?>
|
<?php $hidden = ($privileges[PRIV_APPOINTMENTS]['view'] == TRUE) ? '' : 'hidden'; ?>
|
||||||
<?php $active = ($active_menu == PRIV_APPOINTMENTS) ? 'active' : ''; ?>
|
<?php $active = ($active_menu == PRIV_APPOINTMENTS) ? 'active' : ''; ?>
|
||||||
<a href="<?php echo $base_url; ?>/index.php/backend" class="menu-item <?php echo $hidden; ?><?php echo $active; ?>"
|
<a href="<?php echo $base_url; ?>/index.php/backend" class="menu-item <?php echo $hidden; ?><?php echo $active; ?>"
|
||||||
title="<?php echo $this->lang->line('manage_appointment_record_hint'); ?>">
|
title="<?php echo $this->lang->line('manage_appointment_record_hint'); ?>">
|
||||||
<?php echo $this->lang->line('calendar'); ?>
|
<?php echo $this->lang->line('calendar'); ?>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<?php // CUSTOMERS MENU ITEM
|
<?php // CUSTOMERS MENU ITEM
|
||||||
// ------------------------------------------------------ ?>
|
// ------------------------------------------------------ ?>
|
||||||
<?php $hidden = ($privileges[PRIV_CUSTOMERS]['view'] == TRUE) ? '' : 'hidden'; ?>
|
<?php $hidden = ($privileges[PRIV_CUSTOMERS]['view'] == TRUE) ? '' : 'hidden'; ?>
|
||||||
<?php $active = ($active_menu == PRIV_CUSTOMERS) ? 'active' : ''; ?>
|
<?php $active = ($active_menu == PRIV_CUSTOMERS) ? 'active' : ''; ?>
|
||||||
<a href="<?php echo $base_url; ?>/index.php/backend/customers" class="menu-item <?php echo $hidden; ?><?php echo $active; ?>"
|
<a href="<?php echo $base_url; ?>/index.php/backend/customers" class="menu-item <?php echo $hidden; ?><?php echo $active; ?>"
|
||||||
title="<?php echo $this->lang->line('manage_customers_hint'); ?>">
|
title="<?php echo $this->lang->line('manage_customers_hint'); ?>">
|
||||||
<?php echo $this->lang->line('customers'); ?>
|
<?php echo $this->lang->line('customers'); ?>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<?php // SERVICES MENU ITEM
|
<?php // SERVICES MENU ITEM
|
||||||
// ------------------------------------------------------ ?>
|
// ------------------------------------------------------ ?>
|
||||||
<?php $hidden = ($privileges[PRIV_SERVICES]['view'] == TRUE) ? '' : 'hidden'; ?>
|
<?php $hidden = ($privileges[PRIV_SERVICES]['view'] == TRUE) ? '' : 'hidden'; ?>
|
||||||
<?php $active = ($active_menu == PRIV_SERVICES) ? 'active' : ''; ?>
|
<?php $active = ($active_menu == PRIV_SERVICES) ? 'active' : ''; ?>
|
||||||
<a href="<?php echo $base_url; ?>/index.php/backend/services" class="menu-item <?php echo $hidden; ?><?php echo $active; ?>"
|
<a href="<?php echo $base_url; ?>/index.php/backend/services" class="menu-item <?php echo $hidden; ?><?php echo $active; ?>"
|
||||||
title="<?php echo $this->lang->line('manage_services_hint'); ?>">
|
title="<?php echo $this->lang->line('manage_services_hint'); ?>">
|
||||||
<?php echo $this->lang->line('services'); ?>
|
<?php echo $this->lang->line('services'); ?>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<?php // USERS MENU ITEM
|
<?php // USERS MENU ITEM
|
||||||
// ------------------------------------------------------ ?>
|
// ------------------------------------------------------ ?>
|
||||||
<?php $hidden = ($privileges[PRIV_USERS]['view'] == TRUE) ? '' : 'hidden'; ?>
|
<?php $hidden = ($privileges[PRIV_USERS]['view'] == TRUE) ? '' : 'hidden'; ?>
|
||||||
<?php $active = ($active_menu == PRIV_USERS) ? 'active' : ''; ?>
|
<?php $active = ($active_menu == PRIV_USERS) ? 'active' : ''; ?>
|
||||||
<a href="<?php echo $base_url; ?>/index.php/backend/users" class="menu-item <?php echo $hidden; ?><?php echo $active; ?>"
|
<a href="<?php echo $base_url; ?>/index.php/backend/users" class="menu-item <?php echo $hidden; ?><?php echo $active; ?>"
|
||||||
title="<?php echo $this->lang->line('manage_users_hint'); ?>">
|
title="<?php echo $this->lang->line('manage_users_hint'); ?>">
|
||||||
<?php echo $this->lang->line('users'); ?>
|
<?php echo $this->lang->line('users'); ?>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<?php // SETTINGS MENU ITEM
|
<?php // SETTINGS MENU ITEM
|
||||||
// ------------------------------------------------------ ?>
|
// ------------------------------------------------------ ?>
|
||||||
<?php $hidden = ($privileges[PRIV_SYSTEM_SETTINGS]['view'] == TRUE
|
<?php $hidden = ($privileges[PRIV_SYSTEM_SETTINGS]['view'] == TRUE
|
||||||
|| $privileges[PRIV_USER_SETTINGS]['view'] == TRUE) ? '' : 'hidden'; ?>
|
|| $privileges[PRIV_USER_SETTINGS]['view'] == TRUE) ? '' : 'hidden'; ?>
|
||||||
<?php $active = ($active_menu == PRIV_SYSTEM_SETTINGS) ? 'active' : ''; ?>
|
<?php $active = ($active_menu == PRIV_SYSTEM_SETTINGS) ? 'active' : ''; ?>
|
||||||
<a href="<?php echo $base_url; ?>/index.php/backend/settings" class="menu-item <?php echo $hidden; ?><?php echo $active; ?>"
|
<a href="<?php echo $base_url; ?>/index.php/backend/settings" class="menu-item <?php echo $hidden; ?><?php echo $active; ?>"
|
||||||
title="<?php echo $this->lang->line('settings_hint'); ?>">
|
title="<?php echo $this->lang->line('settings_hint'); ?>">
|
||||||
<?php echo $this->lang->line('settings'); ?>
|
<?php echo $this->lang->line('settings'); ?>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<?php // LOGOUT MENU ITEM
|
<?php // LOGOUT MENU ITEM
|
||||||
// ------------------------------------------------------ ?>
|
// ------------------------------------------------------ ?>
|
||||||
<a href="<?php echo $base_url; ?>/index.php/user/logout" class="menu-item"
|
<a href="<?php echo $base_url; ?>/index.php/user/logout" class="menu-item"
|
||||||
title="<?php echo $this->lang->line('log_out_hint'); ?>">
|
title="<?php echo $this->lang->line('log_out_hint'); ?>">
|
||||||
<?php echo $this->lang->line('log_out'); ?>
|
<?php echo $this->lang->line('log_out'); ?>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="notification" style="display: none;"></div>
|
<div id="notification" style="display: none;"></div>
|
||||||
|
|
||||||
<div id="loading" style="display: none;">
|
<div id="loading" style="display: none;">
|
||||||
<img src="<?php echo $base_url; ?>/assets/img/loading.gif" />
|
<img src="<?php echo $base_url; ?>/assets/img/loading.gif" />
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,71 +1,71 @@
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Appointment Details</title>
|
<title>Appointment Details</title>
|
||||||
</head>
|
</head>
|
||||||
<body style="font: 13px arial, helvetica, tahoma;">
|
<body style="font: 13px arial, helvetica, tahoma;">
|
||||||
<div class="email-container" style="width: 650px; border: 1px solid #eee;">
|
<div class="email-container" style="width: 650px; border: 1px solid #eee;">
|
||||||
<div id="header" style="background-color: #3DD481; border-bottom: 4px solid #1A865F;
|
<div id="header" style="background-color: #3DD481; border-bottom: 4px solid #1A865F;
|
||||||
height: 45px; padding: 10px 15px;">
|
height: 45px; padding: 10px 15px;">
|
||||||
<strong id="logo" style="color: white; font-size: 20px;
|
<strong id="logo" style="color: white; font-size: 20px;
|
||||||
text-shadow: 1px 1px 1px #8F8888; margin-top: 10px; display: inline-block">
|
text-shadow: 1px 1px 1px #8F8888; margin-top: 10px; display: inline-block">
|
||||||
$company_name</strong>
|
$company_name</strong>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="content" style="padding: 10px 15px;">
|
<div id="content" style="padding: 10px 15px;">
|
||||||
<h2>$email_title</h2>
|
<h2>$email_title</h2>
|
||||||
<p>$email_message</p>
|
<p>$email_message</p>
|
||||||
|
|
||||||
<h2>Appointment Details</h2>
|
<h2>Appointment Details</h2>
|
||||||
<table id="appointment-details">
|
<table id="appointment-details">
|
||||||
<tr>
|
<tr>
|
||||||
<td class="label" style="padding: 3px;font-weight: bold;">Service</td>
|
<td class="label" style="padding: 3px;font-weight: bold;">Service</td>
|
||||||
<td style="padding: 3px;">$appointment_service</td>
|
<td style="padding: 3px;">$appointment_service</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="label" style="padding: 3px;font-weight: bold;">Provider</td>
|
<td class="label" style="padding: 3px;font-weight: bold;">Provider</td>
|
||||||
<td style="padding: 3px;">$appointment_provider</td>
|
<td style="padding: 3px;">$appointment_provider</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="label" style="padding: 3px;font-weight: bold;">Start</td>
|
<td class="label" style="padding: 3px;font-weight: bold;">Start</td>
|
||||||
<td style="padding: 3px;">$appointment_start_date</td>
|
<td style="padding: 3px;">$appointment_start_date</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="label" style="padding: 3px;font-weight: bold;">End</td>
|
<td class="label" style="padding: 3px;font-weight: bold;">End</td>
|
||||||
<td style="padding: 3px;">$appointment_end_date</td>
|
<td style="padding: 3px;">$appointment_end_date</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<h2>Customer Details</h2>
|
<h2>Customer Details</h2>
|
||||||
<table id="customer-details">
|
<table id="customer-details">
|
||||||
<tr>
|
<tr>
|
||||||
<td class="label" style="padding: 3px;font-weight: bold;">Name</td>
|
<td class="label" style="padding: 3px;font-weight: bold;">Name</td>
|
||||||
<td style="padding: 3px;">$customer_name</td>
|
<td style="padding: 3px;">$customer_name</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="label" style="padding: 3px;font-weight: bold;">Email</td>
|
<td class="label" style="padding: 3px;font-weight: bold;">Email</td>
|
||||||
<td style="padding: 3px;">$customer_email</td>
|
<td style="padding: 3px;">$customer_email</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="label" style="padding: 3px;font-weight: bold;">Phone</td>
|
<td class="label" style="padding: 3px;font-weight: bold;">Phone</td>
|
||||||
<td style="padding: 3px;">$customer_phone</td>
|
<td style="padding: 3px;">$customer_phone</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="label" style="padding: 3px;font-weight: bold;">Address</td>
|
<td class="label" style="padding: 3px;font-weight: bold;">Address</td>
|
||||||
<td style="padding: 3px;">$customer_address</td>
|
<td style="padding: 3px;">$customer_address</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<h2>Appointment Link</h2>
|
<h2>Appointment Link</h2>
|
||||||
<a href="$appointment_link" style="width: 600px;">$appointment_link</a>
|
<a href="$appointment_link" style="width: 600px;">$appointment_link</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="footer" style="padding: 10px; text-align: center; margin-top: 10px;
|
<div id="footer" style="padding: 10px; text-align: center; margin-top: 10px;
|
||||||
border-top: 1px solid #EEE; background: #FAFAFA;">
|
border-top: 1px solid #EEE; background: #FAFAFA;">
|
||||||
Powered by
|
Powered by
|
||||||
<a href="http://easyappointments.org" style="text-decoration: none;">Easy!Appointments</a>
|
<a href="http://easyappointments.org" style="text-decoration: none;">Easy!Appointments</a>
|
||||||
|
|
|
|
||||||
<a href="$company_link" style="text-decoration: none;">$company_name</a>
|
<a href="$company_link" style="text-decoration: none;">$company_name</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,71 +1,71 @@
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>$email_title</title>
|
<title>$email_title</title>
|
||||||
</head>
|
</head>
|
||||||
<body style="font: 13px arial, helvetica, tahoma;">
|
<body style="font: 13px arial, helvetica, tahoma;">
|
||||||
<div class="email-container" style="width: 650px; border: 1px solid #eee;">
|
<div class="email-container" style="width: 650px; border: 1px solid #eee;">
|
||||||
<div id="header" style="background-color: #3DD481; border-bottom: 4px solid #1A865F;
|
<div id="header" style="background-color: #3DD481; border-bottom: 4px solid #1A865F;
|
||||||
height: 45px; padding: 10px 15px;">
|
height: 45px; padding: 10px 15px;">
|
||||||
<strong id="logo" style="color: white; font-size: 20px;
|
<strong id="logo" style="color: white; font-size: 20px;
|
||||||
text-shadow: 1px 1px 1px #8F8888; margin-top: 10px; display: inline-block">
|
text-shadow: 1px 1px 1px #8F8888; margin-top: 10px; display: inline-block">
|
||||||
$company_name</strong>
|
$company_name</strong>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="content" style="padding: 10px 15px;">
|
<div id="content" style="padding: 10px 15px;">
|
||||||
<h2>$email_title</h2>
|
<h2>$email_title</h2>
|
||||||
<p>$email_message</p>
|
<p>$email_message</p>
|
||||||
|
|
||||||
<h2>Appointment Details</h2>
|
<h2>Appointment Details</h2>
|
||||||
<table id="appointment-details">
|
<table id="appointment-details">
|
||||||
<tr>
|
<tr>
|
||||||
<td class="label" style="padding: 3px;font-weight: bold;">Service</td>
|
<td class="label" style="padding: 3px;font-weight: bold;">Service</td>
|
||||||
<td style="padding: 3px;">$appointment_service</td>
|
<td style="padding: 3px;">$appointment_service</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="label" style="padding: 3px;font-weight: bold;">Provider</td>
|
<td class="label" style="padding: 3px;font-weight: bold;">Provider</td>
|
||||||
<td style="padding: 3px;">$appointment_provider</td>
|
<td style="padding: 3px;">$appointment_provider</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="label" style="padding: 3px;font-weight: bold;">Date</td>
|
<td class="label" style="padding: 3px;font-weight: bold;">Date</td>
|
||||||
<td style="padding: 3px;">$appointment_date</td>
|
<td style="padding: 3px;">$appointment_date</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="label" style="padding: 3px;font-weight: bold;">Duration</td>
|
<td class="label" style="padding: 3px;font-weight: bold;">Duration</td>
|
||||||
<td style="padding: 3px;">$appointment_duration</td>
|
<td style="padding: 3px;">$appointment_duration</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<h2>Customer Details</h2>
|
<h2>Customer Details</h2>
|
||||||
<table id="customer-details">
|
<table id="customer-details">
|
||||||
<tr>
|
<tr>
|
||||||
<td class="label" style="padding: 3px;font-weight: bold;">Name</td>
|
<td class="label" style="padding: 3px;font-weight: bold;">Name</td>
|
||||||
<td style="padding: 3px;">$customer_name</td>
|
<td style="padding: 3px;">$customer_name</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="label" style="padding: 3px;font-weight: bold;">Email</td>
|
<td class="label" style="padding: 3px;font-weight: bold;">Email</td>
|
||||||
<td style="padding: 3px;">$customer_email</td>
|
<td style="padding: 3px;">$customer_email</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="label" style="padding: 3px;font-weight: bold;">Phone</td>
|
<td class="label" style="padding: 3px;font-weight: bold;">Phone</td>
|
||||||
<td style="padding: 3px;">$customer_phone</td>
|
<td style="padding: 3px;">$customer_phone</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="label" style="padding: 3px;font-weight: bold;">Address</td>
|
<td class="label" style="padding: 3px;font-weight: bold;">Address</td>
|
||||||
<td style="padding: 3px;">$customer_address</td>
|
<td style="padding: 3px;">$customer_address</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<h2>Reason</h2>
|
<h2>Reason</h2>
|
||||||
<p>$reason</p>
|
<p>$reason</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="footer" style="padding: 10px; text-align: center; margin-top: 10px;
|
<div id="footer" style="padding: 10px; text-align: center; margin-top: 10px;
|
||||||
border-top: 1px solid #EEE; background: #FAFAFA;">
|
border-top: 1px solid #EEE; background: #FAFAFA;">
|
||||||
Powered by
|
Powered by
|
||||||
<a href="http://easyappointments.org" style="text-decoration: none;">Easy!Appointments</a>
|
<a href="http://easyappointments.org" style="text-decoration: none;">Easy!Appointments</a>
|
||||||
|
|
|
|
||||||
<a href="$company_link" style="text-decoration: none;">$company_name</a>
|
<a href="$company_link" style="text-decoration: none;">$company_name</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,28 +1,28 @@
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>New Account Password</title>
|
<title>New Account Password</title>
|
||||||
</head>
|
</head>
|
||||||
<body style="font: 13px arial, helvetica, tahoma;">
|
<body style="font: 13px arial, helvetica, tahoma;">
|
||||||
<div class="email-container" style="width: 650px; border: 1px solid #eee;">
|
<div class="email-container" style="width: 650px; border: 1px solid #eee;">
|
||||||
<div id="header" style="background-color: #3DD481; border-bottom: 4px solid #1A865F;
|
<div id="header" style="background-color: #3DD481; border-bottom: 4px solid #1A865F;
|
||||||
height: 45px; padding: 10px 15px;">
|
height: 45px; padding: 10px 15px;">
|
||||||
<strong id="logo" style="color: white; font-size: 20px;
|
<strong id="logo" style="color: white; font-size: 20px;
|
||||||
text-shadow: 1px 1px 1px #8F8888; margin-top: 10px; display: inline-block">
|
text-shadow: 1px 1px 1px #8F8888; margin-top: 10px; display: inline-block">
|
||||||
$company_name</strong>
|
$company_name</strong>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="content" style="padding: 10px 15px;">
|
<div id="content" style="padding: 10px 15px;">
|
||||||
<h2>$email_title</h2>
|
<h2>$email_title</h2>
|
||||||
<p>$email_message</p>
|
<p>$email_message</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="footer" style="padding: 10px; text-align: center; margin-top: 10px;
|
<div id="footer" style="padding: 10px; text-align: center; margin-top: 10px;
|
||||||
border-top: 1px solid #EEE; background: #FAFAFA;">
|
border-top: 1px solid #EEE; background: #FAFAFA;">
|
||||||
Powered by
|
Powered by
|
||||||
<a href="http://easyappointments.org" style="text-decoration: none;">Easy!Appointments</a>
|
<a href="http://easyappointments.org" style="text-decoration: none;">Easy!Appointments</a>
|
||||||
|
|
|
|
||||||
<a href="$company_link" style="text-decoration: none;">$company_name</a>
|
<a href="$company_link" style="text-decoration: none;">$company_name</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,45 +1,45 @@
|
||||||
<script type="text/javascript" src="<?php echo $this->config->item('base_url'); ?>/assets/ext/jquery/jquery.min.js"></script>
|
<script type="text/javascript" src="<?php echo $this->config->item('base_url'); ?>/assets/ext/jquery/jquery.min.js"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
var passedTestsNumber = $('span').filter(function() {
|
var passedTestsNumber = $('span').filter(function() {
|
||||||
return $(this).text() === 'Passed';
|
return $(this).text() === 'Passed';
|
||||||
}).length;
|
}).length;
|
||||||
var totalTestsNumber = $('table').length;
|
var totalTestsNumber = $('table').length;
|
||||||
|
|
||||||
$('#test-results').text(passedTestsNumber + ' / ' + totalTestsNumber + ' Passed');
|
$('#test-results').text(passedTestsNumber + ' / ' + totalTestsNumber + ' Passed');
|
||||||
|
|
||||||
if (passedTestsNumber == totalTestsNumber) {
|
if (passedTestsNumber == totalTestsNumber) {
|
||||||
$('#test-header').css('background-color', '#3DD481');
|
$('#test-header').css('background-color', '#3DD481');
|
||||||
} else {
|
} else {
|
||||||
$('#test-header').css('background-color', '#D43D3D');
|
$('#test-header').css('background-color', '#D43D3D');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
#test-header {
|
#test-header {
|
||||||
font-size: 30px;
|
font-size: 30px;
|
||||||
font-family: arial, sans-serif;
|
font-family: arial, sans-serif;
|
||||||
height: 70px;
|
height: 70px;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
margin-bottom: 15px;
|
margin-bottom: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#test-heading {
|
#test-heading {
|
||||||
margin-top: 15px;
|
margin-top: 15px;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
margin-right: 21px;
|
margin-right: 21px;
|
||||||
color: #DBFFA6;
|
color: #DBFFA6;
|
||||||
/* color: #C0FFD9;
|
/* color: #C0FFD9;
|
||||||
text-shadow: 0px 1px 1px #0D9E41;*/
|
text-shadow: 0px 1px 1px #0D9E41;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
#test-results {
|
#test-results {
|
||||||
color: #FFF;
|
color: #FFF;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<div id="test-header">
|
<div id="test-header">
|
||||||
<strong id="test-heading">Easy!Appointments Unit Testing</strong>
|
<strong id="test-heading">Easy!Appointments Unit Testing</strong>
|
||||||
<strong id="test-results"></strong>
|
<strong id="test-results"></strong>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,149 +1,149 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<meta name="theme-color" content="#35A768">
|
<meta name="theme-color" content="#35A768">
|
||||||
<title><?php echo $this->lang->line('forgot_your_password') . ' - ' . $company_name; ?></title>
|
<title><?php echo $this->lang->line('forgot_your_password') . ' - ' . $company_name; ?></title>
|
||||||
|
|
||||||
<?php // INCLUDE JS FILES ?>
|
<?php // INCLUDE JS FILES ?>
|
||||||
<script
|
<script
|
||||||
type="text/javascript"
|
type="text/javascript"
|
||||||
src="<?php echo $this->config->item('base_url'); ?>/assets/ext/jquery/jquery.min.js"></script>
|
src="<?php echo $this->config->item('base_url'); ?>/assets/ext/jquery/jquery.min.js"></script>
|
||||||
<script
|
<script
|
||||||
type="text/javascript"
|
type="text/javascript"
|
||||||
src="<?php echo $this->config->item('base_url'); ?>/assets/ext/bootstrap/js/bootstrap.min.js"></script>
|
src="<?php echo $this->config->item('base_url'); ?>/assets/ext/bootstrap/js/bootstrap.min.js"></script>
|
||||||
<script
|
<script
|
||||||
type="text/javascript"
|
type="text/javascript"
|
||||||
src="<?php echo $this->config->item('base_url'); ?>/assets/ext/datejs/date.js"></script>
|
src="<?php echo $this->config->item('base_url'); ?>/assets/ext/datejs/date.js"></script>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var EALang = <?php echo json_encode($this->lang->language); ?>;
|
var EALang = <?php echo json_encode($this->lang->language); ?>;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<?php // INCLUDE CSS FILES ?>
|
<?php // INCLUDE CSS FILES ?>
|
||||||
<link
|
<link
|
||||||
rel="stylesheet"
|
rel="stylesheet"
|
||||||
type="text/css"
|
type="text/css"
|
||||||
href="<?php echo $this->config->item('base_url'); ?>/assets/ext/bootstrap/css/bootstrap.min.css">
|
href="<?php echo $this->config->item('base_url'); ?>/assets/ext/bootstrap/css/bootstrap.min.css">
|
||||||
|
|
||||||
<?php // SET FAVICON FOR PAGE ?>
|
<?php // SET FAVICON FOR PAGE ?>
|
||||||
<link
|
<link
|
||||||
rel="icon"
|
rel="icon"
|
||||||
type="image/x-icon"
|
type="image/x-icon"
|
||||||
href="<?php echo $this->config->item('base_url'); ?>/assets/img/favicon.ico">
|
href="<?php echo $this->config->item('base_url'); ?>/assets/img/favicon.ico">
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
width: 100vw;
|
width: 100vw;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
display: table-cell;
|
display: table-cell;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
background-color: #CAEDF3;
|
background-color: #CAEDF3;
|
||||||
}
|
}
|
||||||
|
|
||||||
#forgot-password-frame {
|
#forgot-password-frame {
|
||||||
width: 630px;
|
width: 630px;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
background: #FFF;
|
background: #FFF;
|
||||||
border: 1px solid #DDDADA;
|
border: 1px solid #DDDADA;
|
||||||
padding: 70px;
|
padding: 70px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.user-login {
|
.user-login {
|
||||||
margin-left: 20px;
|
margin-left: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media(max-width: 640px) {
|
@media(max-width: 640px) {
|
||||||
#forgot-password-frame {
|
#forgot-password-frame {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
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 . '"'; ?>,
|
||||||
'AJAX_SUCCESS': 'SUCCESS',
|
'AJAX_SUCCESS': 'SUCCESS',
|
||||||
'AJAX_FAILURE': 'FAILURE'
|
'AJAX_FAILURE': 'FAILURE'
|
||||||
};
|
};
|
||||||
|
|
||||||
var EALang = <?php echo json_encode($this->lang->language); ?>;
|
var EALang = <?php echo json_encode($this->lang->language); ?>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event: Login Button "Click"
|
* Event: Login Button "Click"
|
||||||
*
|
*
|
||||||
* Make an ajax call to the server and check whether the user's credentials are right.
|
* Make an ajax call to the server and check whether the user's credentials are right.
|
||||||
* If yes then redirect him to his desired page, otherwise display a message.
|
* If yes then redirect him to his desired page, otherwise display a message.
|
||||||
*/
|
*/
|
||||||
$('form').submit(function(event) {
|
$('form').submit(function(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
var postUrl = GlobalVariables.baseUrl + '/index.php/user/ajax_forgot_password';
|
var postUrl = GlobalVariables.baseUrl + '/index.php/user/ajax_forgot_password';
|
||||||
var postData = {
|
var postData = {
|
||||||
'csrfToken': GlobalVariables.csrfToken,
|
'csrfToken': GlobalVariables.csrfToken,
|
||||||
'username': $('#username').val(),
|
'username': $('#username').val(),
|
||||||
'email': $('#email').val()
|
'email': $('#email').val()
|
||||||
};
|
};
|
||||||
|
|
||||||
$('.alert').addClass('hidden');
|
$('.alert').addClass('hidden');
|
||||||
$('#get-new-password').prop('disabled', true);
|
$('#get-new-password').prop('disabled', true);
|
||||||
|
|
||||||
$.post(postUrl, postData, function(response) {
|
$.post(postUrl, postData, function(response) {
|
||||||
//////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////
|
||||||
console.log('Regenerate Password Response: ', response);
|
console.log('Regenerate Password Response: ', response);
|
||||||
//////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////
|
||||||
|
|
||||||
$('#get-new-password').prop('disabled', false);
|
$('#get-new-password').prop('disabled', false);
|
||||||
if (!GeneralFunctions.handleAjaxExceptions(response)) return;
|
if (!GeneralFunctions.handleAjaxExceptions(response)) return;
|
||||||
|
|
||||||
if (response == GlobalVariables.AJAX_SUCCESS) {
|
if (response == GlobalVariables.AJAX_SUCCESS) {
|
||||||
$('.alert').addClass('alert-success');
|
$('.alert').addClass('alert-success');
|
||||||
$('.alert').text(EALang['new_password_sent_with_email']);
|
$('.alert').text(EALang['new_password_sent_with_email']);
|
||||||
} else {
|
} else {
|
||||||
$('.alert').text('The operation failed! Please enter a valid username '
|
$('.alert').text('The operation failed! Please enter a valid username '
|
||||||
+ 'and email address in order to get a new password.');
|
+ 'and email address in order to get a new password.');
|
||||||
}
|
}
|
||||||
$('.alert')
|
$('.alert')
|
||||||
.removeClass('hidden alert-danger alert-success')
|
.removeClass('hidden alert-danger alert-success')
|
||||||
.addClass('alert-danger');
|
.addClass('alert-danger');
|
||||||
}, 'json');
|
}, 'json');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="forgot-password-frame" class="frame-container">
|
<div id="forgot-password-frame" class="frame-container">
|
||||||
<h2><?php echo $this->lang->line('forgot_your_password'); ?></h2>
|
<h2><?php echo $this->lang->line('forgot_your_password'); ?></h2>
|
||||||
<p><?php echo $this->lang->line('type_username_and_email_for_new_password'); ?></p>
|
<p><?php echo $this->lang->line('type_username_and_email_for_new_password'); ?></p>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="alert hidden"></div>
|
<div class="alert hidden"></div>
|
||||||
<form>
|
<form>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="username"><?php echo $this->lang->line('username'); ?></label>
|
<label for="username"><?php echo $this->lang->line('username'); ?></label>
|
||||||
<input type="text" id="username" placeholder="<?php echo $this->lang->line('enter_username_here'); ?>" class="form-control" />
|
<input type="text" id="username" placeholder="<?php echo $this->lang->line('enter_username_here'); ?>" class="form-control" />
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="email"><?php echo $this->lang->line('email'); ?></label>
|
<label for="email"><?php echo $this->lang->line('email'); ?></label>
|
||||||
<input type="text" id="email" placeholder="<?php echo $this->lang->line('enter_email_here'); ?>" class="form-control" />
|
<input type="text" id="email" placeholder="<?php echo $this->lang->line('enter_email_here'); ?>" class="form-control" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
<button type="submit" id="get-new-password" class="btn btn-primary btn-large">
|
<button type="submit" id="get-new-password" class="btn btn-primary btn-large">
|
||||||
<?php echo $this->lang->line('regenerate_password'); ?>
|
<?php echo $this->lang->line('regenerate_password'); ?>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<a href="<?php echo $base_url; ?>/index.php/user/login" class="user-login">
|
<a href="<?php echo $base_url; ?>/index.php/user/login" class="user-login">
|
||||||
<?php echo $this->lang->line('go_to_login'); ?></a>
|
<?php echo $this->lang->line('go_to_login'); ?></a>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<script
|
<script
|
||||||
type="text/javascript"
|
type="text/javascript"
|
||||||
src="<?php echo $this->config->item('base_url'); ?>/assets/js/general_functions.js"></script>
|
src="<?php echo $this->config->item('base_url'); ?>/assets/js/general_functions.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,156 +1,156 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<meta name="theme-color" content="#35A768">
|
<meta name="theme-color" content="#35A768">
|
||||||
<title><?php echo $this->lang->line('login') . ' - ' . $company_name; ?></title>
|
<title><?php echo $this->lang->line('login') . ' - ' . $company_name; ?></title>
|
||||||
|
|
||||||
|
|
||||||
<?php // INCLUDE JS FILES ?>
|
<?php // INCLUDE JS FILES ?>
|
||||||
<script
|
<script
|
||||||
type="text/javascript"
|
type="text/javascript"
|
||||||
src="<?php echo $this->config->item('base_url'); ?>/assets/ext/jquery/jquery.min.js"></script>
|
src="<?php echo $this->config->item('base_url'); ?>/assets/ext/jquery/jquery.min.js"></script>
|
||||||
<script
|
<script
|
||||||
type="text/javascript"
|
type="text/javascript"
|
||||||
src="<?php echo $this->config->item('base_url'); ?>/assets/ext/bootstrap/js/bootstrap.min.js"></script>
|
src="<?php echo $this->config->item('base_url'); ?>/assets/ext/bootstrap/js/bootstrap.min.js"></script>
|
||||||
<script
|
<script
|
||||||
type="text/javascript"
|
type="text/javascript"
|
||||||
src="<?php echo $this->config->item('base_url'); ?>/assets/ext/datejs/date.js"></script>
|
src="<?php echo $this->config->item('base_url'); ?>/assets/ext/datejs/date.js"></script>
|
||||||
|
|
||||||
<?php // INCLUDE CSS FILES ?>
|
<?php // INCLUDE CSS FILES ?>
|
||||||
<link
|
<link
|
||||||
rel="stylesheet"
|
rel="stylesheet"
|
||||||
type="text/css"
|
type="text/css"
|
||||||
href="<?php echo $this->config->item('base_url'); ?>/assets/ext/bootstrap/css/bootstrap.min.css">
|
href="<?php echo $this->config->item('base_url'); ?>/assets/ext/bootstrap/css/bootstrap.min.css">
|
||||||
<link
|
<link
|
||||||
rel="stylesheet"
|
rel="stylesheet"
|
||||||
type="text/css"
|
type="text/css"
|
||||||
href="<?php echo $this->config->item('base_url'); ?>/assets/css/general.css">
|
href="<?php echo $this->config->item('base_url'); ?>/assets/css/general.css">
|
||||||
|
|
||||||
<?php // SET FAVICON FOR PAGE ?>
|
<?php // SET FAVICON FOR PAGE ?>
|
||||||
<link
|
<link
|
||||||
rel="icon"
|
rel="icon"
|
||||||
type="image/x-icon"
|
type="image/x-icon"
|
||||||
href="<?php echo $this->config->item('base_url'); ?>/assets/img/favicon.ico">
|
href="<?php echo $this->config->item('base_url'); ?>/assets/img/favicon.ico">
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
width: 100vw;
|
width: 100vw;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
display: table-cell;
|
display: table-cell;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
background-color: #CAEDF3;
|
background-color: #CAEDF3;
|
||||||
}
|
}
|
||||||
|
|
||||||
#login-frame {
|
#login-frame {
|
||||||
width: 630px;
|
width: 630px;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
background: #FFF;
|
background: #FFF;
|
||||||
border: 1px solid #DDDADA;
|
border: 1px solid #DDDADA;
|
||||||
padding: 70px;
|
padding: 70px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media(max-width: 640px) {
|
@media(max-width: 640px) {
|
||||||
#login-frame {
|
#login-frame {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<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 . '"'; ?>,
|
||||||
'destUrl': <?php echo '"' . $dest_url . '"'; ?>,
|
'destUrl': <?php echo '"' . $dest_url . '"'; ?>,
|
||||||
'AJAX_SUCCESS': 'SUCCESS',
|
'AJAX_SUCCESS': 'SUCCESS',
|
||||||
'AJAX_FAILURE': 'FAILURE'
|
'AJAX_FAILURE': 'FAILURE'
|
||||||
};
|
};
|
||||||
|
|
||||||
var EALang = <?php echo json_encode($this->lang->language); ?>;
|
var EALang = <?php echo json_encode($this->lang->language); ?>;
|
||||||
var availableLanguages = <?php echo json_encode($this->config->item('available_languages')); ?>;
|
var availableLanguages = <?php echo json_encode($this->config->item('available_languages')); ?>;
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
GeneralFunctions.enableLanguageSelection($('#select-language'));
|
GeneralFunctions.enableLanguageSelection($('#select-language'));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event: Login Button "Click"
|
* Event: Login Button "Click"
|
||||||
*
|
*
|
||||||
* Make an ajax call to the server and check whether the user's credentials are right.
|
* Make an ajax call to the server and check whether the user's credentials are right.
|
||||||
* If yes then redirect him to his desired page, otherwise display a message.
|
* If yes then redirect him to his desired page, otherwise display a message.
|
||||||
*/
|
*/
|
||||||
$('#login-form').submit(function(event) {
|
$('#login-form').submit(function(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
var postUrl = GlobalVariables.baseUrl + '/index.php/user/ajax_check_login';
|
var postUrl = GlobalVariables.baseUrl + '/index.php/user/ajax_check_login';
|
||||||
var postData = {
|
var postData = {
|
||||||
'csrfToken': GlobalVariables.csrfToken,
|
'csrfToken': GlobalVariables.csrfToken,
|
||||||
'username': $('#username').val(),
|
'username': $('#username').val(),
|
||||||
'password': $('#password').val()
|
'password': $('#password').val()
|
||||||
};
|
};
|
||||||
|
|
||||||
$('.alert').addClass('hidden');
|
$('.alert').addClass('hidden');
|
||||||
|
|
||||||
$.post(postUrl, postData, function(response) {
|
$.post(postUrl, postData, function(response) {
|
||||||
//////////////////////////////////////////////////
|
//////////////////////////////////////////////////
|
||||||
console.log('Check Login Response: ', response);
|
console.log('Check Login Response: ', response);
|
||||||
//////////////////////////////////////////////////
|
//////////////////////////////////////////////////
|
||||||
|
|
||||||
if (!GeneralFunctions.handleAjaxExceptions(response)) return;
|
if (!GeneralFunctions.handleAjaxExceptions(response)) return;
|
||||||
|
|
||||||
if (response == GlobalVariables.AJAX_SUCCESS) {
|
if (response == GlobalVariables.AJAX_SUCCESS) {
|
||||||
window.location.href = GlobalVariables.destUrl;
|
window.location.href = GlobalVariables.destUrl;
|
||||||
} else {
|
} else {
|
||||||
$('.alert').text(EALang['login_failed']);
|
$('.alert').text(EALang['login_failed']);
|
||||||
$('.alert')
|
$('.alert')
|
||||||
.removeClass('hidden alert-danger alert-success')
|
.removeClass('hidden alert-danger alert-success')
|
||||||
.addClass('alert-danger');
|
.addClass('alert-danger');
|
||||||
}
|
}
|
||||||
}, 'json');
|
}, 'json');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="login-frame" class="frame-container">
|
<div id="login-frame" class="frame-container">
|
||||||
<h2><?php echo $this->lang->line('backend_section'); ?></h2>
|
<h2><?php echo $this->lang->line('backend_section'); ?></h2>
|
||||||
<p><?php echo $this->lang->line('you_need_to_login'); ?></p>
|
<p><?php echo $this->lang->line('you_need_to_login'); ?></p>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="alert hidden"></div>
|
<div class="alert hidden"></div>
|
||||||
<form id="login-form">
|
<form id="login-form">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="username"><?php echo $this->lang->line('username'); ?></label>
|
<label for="username"><?php echo $this->lang->line('username'); ?></label>
|
||||||
<input type="text" id="username"
|
<input type="text" id="username"
|
||||||
placeholder="<?php echo $this->lang->line('enter_username_here'); ?>"
|
placeholder="<?php echo $this->lang->line('enter_username_here'); ?>"
|
||||||
class="form-control" />
|
class="form-control" />
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="password"><?php echo $this->lang->line('password'); ?></label>
|
<label for="password"><?php echo $this->lang->line('password'); ?></label>
|
||||||
<input type="password" id="password"
|
<input type="password" id="password"
|
||||||
placeholder="<?php echo $this->lang->line('enter_password_here'); ?>"
|
placeholder="<?php echo $this->lang->line('enter_password_here'); ?>"
|
||||||
class="form-control" />
|
class="form-control" />
|
||||||
</div>
|
</div>
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
<button type="submit" id="login" class="btn btn-primary">
|
<button type="submit" id="login" class="btn btn-primary">
|
||||||
<?php echo $this->lang->line('login'); ?>
|
<?php echo $this->lang->line('login'); ?>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<br><br>
|
<br><br>
|
||||||
|
|
||||||
<a href="<?php echo $base_url; ?>/index.php/user/forgot_password" class="forgot-password">
|
<a href="<?php echo $base_url; ?>/index.php/user/forgot_password" class="forgot-password">
|
||||||
<?php echo $this->lang->line('forgot_your_password'); ?></a>
|
<?php echo $this->lang->line('forgot_your_password'); ?></a>
|
||||||
|
|
|
|
||||||
<span id="select-language" class="label label-success">
|
<span id="select-language" class="label label-success">
|
||||||
<?php echo ucfirst($this->config->item('language')); ?>
|
<?php echo ucfirst($this->config->item('language')); ?>
|
||||||
</span>
|
</span>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script
|
<script
|
||||||
type="text/javascript"
|
type="text/javascript"
|
||||||
src="<?php echo $this->config->item('base_url'); ?>/assets/js/general_functions.js"></script>
|
src="<?php echo $this->config->item('base_url'); ?>/assets/js/general_functions.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,85 +1,85 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<meta name="theme-color" content="#35A768">
|
<meta name="theme-color" content="#35A768">
|
||||||
<title><?php echo $this->lang->line('log_out') . ' - ' . $company_name; ?></title>
|
<title><?php echo $this->lang->line('log_out') . ' - ' . $company_name; ?></title>
|
||||||
|
|
||||||
<?php // SET FAVICON FOR PAGE ?>
|
<?php // SET FAVICON FOR PAGE ?>
|
||||||
<link rel="icon" type="image/x-icon" href="<?php echo $this->config->item('base_url'); ?>/assets/img/favicon.ico">
|
<link rel="icon" type="image/x-icon" href="<?php echo $this->config->item('base_url'); ?>/assets/img/favicon.ico">
|
||||||
|
|
||||||
<?php // INCLUDE JS FILES ?>
|
<?php // INCLUDE JS FILES ?>
|
||||||
<script
|
<script
|
||||||
type="text/javascript"
|
type="text/javascript"
|
||||||
src="<?php echo $this->config->item('base_url'); ?>/assets/ext/jquery/jquery.min.js"></script>
|
src="<?php echo $this->config->item('base_url'); ?>/assets/ext/jquery/jquery.min.js"></script>
|
||||||
<script
|
<script
|
||||||
type="text/javascript"
|
type="text/javascript"
|
||||||
src="<?php echo $this->config->item('base_url'); ?>/assets/ext/bootstrap/js/bootstrap.min.js"></script>
|
src="<?php echo $this->config->item('base_url'); ?>/assets/ext/bootstrap/js/bootstrap.min.js"></script>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var EALang = <?php echo json_encode($this->lang->language); ?>;
|
var EALang = <?php echo json_encode($this->lang->language); ?>;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<?php // INCLUDE CSS FILES ?>
|
<?php // INCLUDE CSS FILES ?>
|
||||||
<link
|
<link
|
||||||
rel="stylesheet"
|
rel="stylesheet"
|
||||||
type="text/css"
|
type="text/css"
|
||||||
href="<?php echo $this->config->item('base_url'); ?>/assets/ext/bootstrap/css/bootstrap.min.css">
|
href="<?php echo $this->config->item('base_url'); ?>/assets/ext/bootstrap/css/bootstrap.min.css">
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
width: 100vw;
|
width: 100vw;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
display: table-cell;
|
display: table-cell;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
background-color: #CAEDF3;
|
background-color: #CAEDF3;
|
||||||
}
|
}
|
||||||
|
|
||||||
#logout-frame {
|
#logout-frame {
|
||||||
width: 630px;
|
width: 630px;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
background: #FFF;
|
background: #FFF;
|
||||||
border: 1px solid #DDDADA;
|
border: 1px solid #DDDADA;
|
||||||
padding: 70px;
|
padding: 70px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn {
|
.btn {
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media(max-width: 640px) {
|
@media(max-width: 640px) {
|
||||||
#logout-frame {
|
#logout-frame {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn {
|
.btn {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
margin-bottom: 20px;
|
margin-bottom: 20px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="logout-frame" class="frame-container">
|
<div id="logout-frame" class="frame-container">
|
||||||
<h3><?php echo $this->lang->line('log_out'); ?></h3>
|
<h3><?php echo $this->lang->line('log_out'); ?></h3>
|
||||||
<p>
|
<p>
|
||||||
<?php echo $this->lang->line('logout_success'); ?>
|
<?php echo $this->lang->line('logout_success'); ?>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
<a href="<?php echo $this->config->item('base_url'); ?>" class="btn btn-primary btn-large">
|
<a href="<?php echo $this->config->item('base_url'); ?>" class="btn btn-primary btn-large">
|
||||||
<span class="glyphicon glyphicon-calendar"></span>
|
<span class="glyphicon glyphicon-calendar"></span>
|
||||||
<?php echo $this->lang->line('book_appointment_title'); ?>
|
<?php echo $this->lang->line('book_appointment_title'); ?>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a href="<?php echo $this->config->item('base_url'); ?>/index.php/backend" class="btn btn-danger btn-large">
|
<a href="<?php echo $this->config->item('base_url'); ?>/index.php/backend" class="btn btn-danger btn-large">
|
||||||
<span class="glyphicon glyphicon-home"></span>
|
<span class="glyphicon glyphicon-home"></span>
|
||||||
<?php echo $this->lang->line('backend_section'); ?>
|
<?php echo $this->lang->line('backend_section'); ?>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,79 +1,79 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<meta name="theme-color" content="#35A768">
|
<meta name="theme-color" content="#35A768">
|
||||||
<title><?php echo $this->lang->line('no_privileges') . ' - ' . $company_name; ?></title>
|
<title><?php echo $this->lang->line('no_privileges') . ' - ' . $company_name; ?></title>
|
||||||
|
|
||||||
<?php // INCLUDE JS FILES ?>
|
<?php // INCLUDE JS FILES ?>
|
||||||
<script
|
<script
|
||||||
type="text/javascript"
|
type="text/javascript"
|
||||||
src="<?php echo $this->config->item('base_url'); ?>/assets/ext/jquery/jquery.min.js"></script>
|
src="<?php echo $this->config->item('base_url'); ?>/assets/ext/jquery/jquery.min.js"></script>
|
||||||
<script
|
<script
|
||||||
type="text/javascript"
|
type="text/javascript"
|
||||||
src="<?php echo $this->config->item('base_url'); ?>/assets/ext/bootstrap/js/bootstrap.min.js"></script>
|
src="<?php echo $this->config->item('base_url'); ?>/assets/ext/bootstrap/js/bootstrap.min.js"></script>
|
||||||
|
|
||||||
<?php // INCLUDE CSS FILES ?>
|
<?php // INCLUDE CSS FILES ?>
|
||||||
<link
|
<link
|
||||||
rel="stylesheet"
|
rel="stylesheet"
|
||||||
type="text/css"
|
type="text/css"
|
||||||
href="<?php echo $this->config->item('base_url'); ?>/assets/ext/bootstrap/css/bootstrap.min.css">
|
href="<?php echo $this->config->item('base_url'); ?>/assets/ext/bootstrap/css/bootstrap.min.css">
|
||||||
|
|
||||||
<?php // SET FAVICON FOR PAGE ?>
|
<?php // SET FAVICON FOR PAGE ?>
|
||||||
<link
|
<link
|
||||||
rel="icon"
|
rel="icon"
|
||||||
type="image/x-icon"
|
type="image/x-icon"
|
||||||
href="<?php echo $this->config->item('base_url'); ?>/assets/img/favicon.ico">
|
href="<?php echo $this->config->item('base_url'); ?>/assets/img/favicon.ico">
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
width: 100vw;
|
width: 100vw;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
display: table-cell;
|
display: table-cell;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
background-color: #CAEDF3;
|
background-color: #CAEDF3;
|
||||||
}
|
}
|
||||||
|
|
||||||
#no-priv-frame {
|
#no-priv-frame {
|
||||||
width: 630px;
|
width: 630px;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
background: #FFF;
|
background: #FFF;
|
||||||
border: 1px solid #DDDADA;
|
border: 1px solid #DDDADA;
|
||||||
padding: 70px;
|
padding: 70px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn {
|
.btn {
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media(max-width: 640px) {
|
@media(max-width: 640px) {
|
||||||
#no-priv-frame {
|
#no-priv-frame {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn {
|
.btn {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
margin-bottom: 20px;
|
margin-bottom: 20px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="no-priv-frame" class="frame-container">
|
<div id="no-priv-frame" class="frame-container">
|
||||||
<h3><?php echo $this->lang->line('no_privileges'); ?></h3>
|
<h3><?php echo $this->lang->line('no_privileges'); ?></h3>
|
||||||
<p>
|
<p>
|
||||||
<?php echo $this->lang->line('no_provileges_message'); ?>
|
<?php echo $this->lang->line('no_provileges_message'); ?>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
<a href="<?php echo $this->config->item('base_url'); ?>/index.php/backend" class="btn btn-success btn-large">
|
<a href="<?php echo $this->config->item('base_url'); ?>/index.php/backend" class="btn btn-success btn-large">
|
||||||
<i class="icon-calendar icon-white"></i>
|
<i class="icon-calendar icon-white"></i>
|
||||||
<?php echo $this->lang->line('backend_calendar'); ?>
|
<?php echo $this->lang->line('backend_calendar'); ?>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in a new issue