mirror of
https://github.com/alextselegidis/easyappointments.git
synced 2024-11-10 10:02:33 +03:00
Refactored the get_available_providers method.
This commit is contained in:
parent
7dbe929218
commit
0dc88a85a9
3 changed files with 600 additions and 588 deletions
|
@ -62,6 +62,17 @@ class Appointments extends CI_Controller {
|
|||
$company_name = $this->settings_model->get_setting('company_name');
|
||||
$date_format = $this->settings_model->get_setting('date_format');
|
||||
|
||||
// Remove the data that are not needed inside the $available_providers array.
|
||||
foreach ($available_providers as $index=>$provider) {
|
||||
$stripped_data = array(
|
||||
'id' => $provider['id'],
|
||||
'first_name' => $provider['first_name'],
|
||||
'last_name' => $provider['last_name'],
|
||||
'services' => $provider['services']
|
||||
);
|
||||
$available_providers[$index] = $stripped_data;
|
||||
}
|
||||
|
||||
// If an appointment hash is provided then it means that the customer
|
||||
// is trying to edit a registered appointment record.
|
||||
if ($appointment_hash !== ''){
|
||||
|
|
|
@ -259,21 +259,6 @@ class Backend extends CI_Controller {
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the user data in order to be available at the view and js code.
|
||||
*
|
||||
* @param array $view Contains the view data.
|
||||
*/
|
||||
public function set_user_data(&$view) {
|
||||
$this->load->model('roles_model');
|
||||
|
||||
// Get privileges
|
||||
$view['user_id'] = $this->session->userdata('user_id');
|
||||
$view['user_email'] = $this->session->userdata('user_email');
|
||||
$view['role_slug'] = $this->session->userdata('role_slug');
|
||||
$view['privileges'] = $this->roles_model->get_privileges($this->session->userdata('role_slug'));
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will update the installation to the latest available
|
||||
* version in the server. IMPORTANT: The code files must exist in the
|
||||
|
@ -301,6 +286,21 @@ class Backend extends CI_Controller {
|
|||
));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the user data in order to be available at the view and js code.
|
||||
*
|
||||
* @param array $view Contains the view data.
|
||||
*/
|
||||
private function set_user_data(&$view) {
|
||||
$this->load->model('roles_model');
|
||||
|
||||
// Get privileges
|
||||
$view['user_id'] = $this->session->userdata('user_id');
|
||||
$view['user_email'] = $this->session->userdata('user_email');
|
||||
$view['role_slug'] = $this->session->userdata('role_slug');
|
||||
$view['privileges'] = $this->roles_model->get_privileges($this->session->userdata('role_slug'));
|
||||
}
|
||||
}
|
||||
|
||||
/* End of file backend.php */
|
||||
|
|
|
@ -430,8 +430,6 @@ class Providers_Model extends CI_Model {
|
|||
* provide.
|
||||
*
|
||||
* @return array Returns an array with the providers data.
|
||||
*
|
||||
* @deprecated since version 0.5 - Use get_batch() instead.
|
||||
*/
|
||||
public function get_available_providers() {
|
||||
// Get provider records from database.
|
||||
|
@ -448,6 +446,7 @@ class Providers_Model extends CI_Model {
|
|||
// Services
|
||||
$services = $this->db->get_where('ea_services_providers',
|
||||
array('id_users' => $provider['id']))->result_array();
|
||||
|
||||
$provider['services'] = array();
|
||||
foreach($services as $service) {
|
||||
$provider['services'][] = $service['id_services'];
|
||||
|
@ -456,7 +455,9 @@ class Providers_Model extends CI_Model {
|
|||
// Settings
|
||||
$provider['settings'] = $this->db->get_where('ea_user_settings',
|
||||
array('id_users' => $provider['id']))->row_array();
|
||||
unset($provider['settings']['id_users']);
|
||||
unset($provider['settings']['username']);
|
||||
unset($provider['settings']['password']);
|
||||
unset($provider['settings']['salt']);
|
||||
}
|
||||
|
||||
// Return provider records.
|
||||
|
|
Loading…
Reference in a new issue