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