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:
Alex Tselegidis 2021-10-18 13:04:32 +02:00
parent cf19ea717c
commit a3d6d473fa

View file

@ -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 // 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. // that will provide the requested service.
$service = $this->services_model->get_row($service_id);
if ($provider_id === ANY_PROVIDER) if ($provider_id === ANY_PROVIDER)
{ {
$provider_id = $this->search_any_provider($service_id, $selected_date); $providers = $this->providers_model->get_batch();
if ($provider_id === NULL) $available_hours = [];
foreach($providers as $provider)
{ {
$this->output if (!in_array($service_id, $provider['services']))
->set_content_type('application/json') {
->set_output(json_encode([])); continue;
}
return;
$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);
$service = $this->services_model->get_row($service_id); $response = $this->availability->get_available_hours($selected_date, $service, $provider, $exclude_appointment_id);
}
$provider = $this->providers_model->get_row($provider_id);
$response = $this->availability->get_available_hours($selected_date, $service, $provider, $exclude_appointment_id);
} }
catch (Exception $exception) catch (Exception $exception)
{ {