mirror of
https://github.com/alextselegidis/easyappointments.git
synced 2024-11-14 03:52:21 +03:00
When selecting the any provider option in the booking page then merge all the available hours of all providers that can serve the selected service (#1147).
This commit is contained in:
parent
86bc718782
commit
6b179c3b58
1 changed files with 22 additions and 13 deletions
|
@ -338,25 +338,34 @@ class Appointments extends EA_Controller {
|
|||
|
||||
// If the user has selected the "any-provider" option then we will need to search for an available provider
|
||||
// that will provide the requested service.
|
||||
if ($provider_id === ANY_PROVIDER)
|
||||
{
|
||||
$provider_id = $this->search_any_provider($service_id, $selected_date);
|
||||
|
||||
if ($provider_id === NULL)
|
||||
{
|
||||
$this->output
|
||||
->set_content_type('application/json')
|
||||
->set_output(json_encode([]));
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$service = $this->services_model->get_row($service_id);
|
||||
|
||||
$provider = $this->providers_model->get_row($provider_id);
|
||||
if ($provider_id === ANY_PROVIDER)
|
||||
{
|
||||
$providers = $this->providers_model->get_batch();
|
||||
|
||||
$response = $this->availability->get_available_hours($selected_date, $service, $provider, $exclude_appointment_id);
|
||||
$available_hours = [];
|
||||
|
||||
foreach($providers as $provider)
|
||||
{
|
||||
if (!in_array($service_id, $provider['services']))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$provider_available_hours = $this->availability->get_available_hours($selected_date, $service, $provider, $exclude_appointment_id);
|
||||
|
||||
$available_hours = array_merge($available_hours, $provider_available_hours);
|
||||
}
|
||||
|
||||
$response = array_unique(array_values($available_hours));
|
||||
}
|
||||
else
|
||||
{
|
||||
$provider = $this->providers_model->get_row($provider_id);
|
||||
|
||||
$response = $this->availability->get_available_hours($selected_date, $service, $provider, $exclude_appointment_id);
|
||||
}
|
||||
}
|
||||
catch (Exception $exception)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue