mirror of
https://github.com/alextselegidis/easyappointments.git
synced 2024-11-10 10:02:33 +03:00
Minor refactoring for the appointments page
This commit is contained in:
parent
eb64b6c7ef
commit
d2be2327e8
1 changed files with 112 additions and 126 deletions
|
@ -52,12 +52,11 @@ class Appointments extends EA_Controller {
|
|||
* @param string $appointment_hash The appointment hash identifier.
|
||||
*/
|
||||
public function index(string $appointment_hash = '')
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( ! is_app_installed())
|
||||
{
|
||||
redirect('installation');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -84,20 +83,19 @@ class Appointments extends EA_Controller {
|
|||
$timezones = $this->timezones->to_array();
|
||||
|
||||
// Remove the data that are not needed inside the $available_providers array.
|
||||
foreach ($available_providers as $index => $provider)
|
||||
foreach ($available_providers as &$available_provider)
|
||||
{
|
||||
$stripped_data = [
|
||||
'id' => $provider['id'],
|
||||
'first_name' => $provider['first_name'],
|
||||
'last_name' => $provider['last_name'],
|
||||
'services' => $provider['services'],
|
||||
'timezone' => $provider['timezone']
|
||||
];
|
||||
$available_providers[$index] = $stripped_data;
|
||||
$this->providers_model->only($available_provider, [
|
||||
'id',
|
||||
'first_name',
|
||||
'last_name',
|
||||
'services',
|
||||
'timezone'
|
||||
]);
|
||||
}
|
||||
|
||||
// If an appointment hash is provided then it means that the customer is trying to edit a registered
|
||||
// appointment record.
|
||||
// If an appointment hash is provided then it means that the customer is trying to edit a registered appointment
|
||||
// record.
|
||||
if ($appointment_hash !== '')
|
||||
{
|
||||
// Load the appointments data and enable the manage mode of the page.
|
||||
|
@ -108,13 +106,11 @@ class Appointments extends EA_Controller {
|
|||
if (empty($results))
|
||||
{
|
||||
// The requested appointment was not found in the database.
|
||||
$view = [
|
||||
$this->load->layout('layouts/message/message_layout', 'pages/booking/booking_message_page', [
|
||||
'message_title' => lang('appointment_not_found'),
|
||||
'message_text' => lang('appointment_does_not_exist_in_db'),
|
||||
'message_icon' => base_url('assets/img/error.png')
|
||||
];
|
||||
|
||||
$this->load->layout('layouts/message/message_layout', 'pages/booking/booking_message_page', $view);
|
||||
]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -130,15 +126,13 @@ class Appointments extends EA_Controller {
|
|||
$hours = floor($book_advance_timeout / 60);
|
||||
$minutes = ($book_advance_timeout % 60);
|
||||
|
||||
$view = [
|
||||
$this->load->layout('layouts/message/message_layout', 'pages/booking/booking_message_page', [
|
||||
'message_title' => lang('appointment_locked'),
|
||||
'message_text' => strtr(lang('appointment_locked_message'), [
|
||||
'{$limit}' => sprintf('%02d:%02d', $hours, $minutes)
|
||||
]),
|
||||
'message_icon' => base_url('assets/img/error.png')
|
||||
];
|
||||
|
||||
$this->load->layout('layouts/message/message_layout', 'pages/booking/booking_message_page', $view);
|
||||
]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -151,7 +145,7 @@ class Appointments extends EA_Controller {
|
|||
|
||||
$customer_token = md5(uniqid(mt_rand(), TRUE));
|
||||
|
||||
// Save the token for 10 minutes.
|
||||
// Cache the token for 10 minutes.
|
||||
$this->cache->save('customer-token-' . $customer_token, $customer['id'], 600);
|
||||
}
|
||||
else
|
||||
|
@ -165,8 +159,7 @@ class Appointments extends EA_Controller {
|
|||
$customer = [];
|
||||
}
|
||||
|
||||
// Load the book appointment view.
|
||||
$view = [
|
||||
$this->load->layout('layouts/booking/booking_layout', 'pages/booking/booking_page', [
|
||||
'available_services' => $available_services,
|
||||
'available_providers' => $available_providers,
|
||||
'company_name' => $company_name,
|
||||
|
@ -188,14 +181,7 @@ class Appointments extends EA_Controller {
|
|||
'privacy_policy_content' => $privacy_policy_content,
|
||||
'timezones' => $timezones,
|
||||
'display_any_provider' => $display_any_provider,
|
||||
];
|
||||
}
|
||||
catch (Throwable $e)
|
||||
{
|
||||
$view['exceptions'][] = $e;
|
||||
}
|
||||
|
||||
$this->load->layout('layouts/booking/booking_layout', 'pages/booking/booking_page', $view);
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue