forked from mirrors/easyappointments
Make sure the selected hour is checked before selecting a provider on behalf of the customer, if he selected the any-provider option (#982).
This commit is contained in:
parent
7718b32cfb
commit
7c9137f69d
1 changed files with 9 additions and 7 deletions
|
@ -340,7 +340,7 @@ class Appointments extends EA_Controller {
|
||||||
// that will provide the requested service.
|
// that will provide the requested service.
|
||||||
if ($provider_id === ANY_PROVIDER)
|
if ($provider_id === ANY_PROVIDER)
|
||||||
{
|
{
|
||||||
$provider_id = $this->search_any_provider($selected_date, $service_id);
|
$provider_id = $this->search_any_provider($service_id, $selected_date);
|
||||||
|
|
||||||
if ($provider_id === NULL)
|
if ($provider_id === NULL)
|
||||||
{
|
{
|
||||||
|
@ -378,14 +378,15 @@ class Appointments extends EA_Controller {
|
||||||
*
|
*
|
||||||
* This method will return the database ID of the provider with the most available periods.
|
* This method will return the database ID of the provider with the most available periods.
|
||||||
*
|
*
|
||||||
* @param string $date The date to be searched (Y-m-d).
|
|
||||||
* @param int $service_id The requested service ID.
|
* @param int $service_id The requested service ID.
|
||||||
|
* @param string $date The date to be searched (Y-m-d).
|
||||||
|
* @param string $hour The hour to be searched (H:i).
|
||||||
*
|
*
|
||||||
* @return int Returns the ID of the provider that can provide the service at the selected date.
|
* @return int Returns the ID of the provider that can provide the service at the selected date.
|
||||||
*
|
*
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
protected function search_any_provider($date, $service_id)
|
protected function search_any_provider($service_id, $date, $hour = null)
|
||||||
{
|
{
|
||||||
$available_providers = $this->providers_model->get_available_providers();
|
$available_providers = $this->providers_model->get_available_providers();
|
||||||
|
|
||||||
|
@ -404,7 +405,7 @@ class Appointments extends EA_Controller {
|
||||||
// Check if the provider is available for the requested date.
|
// Check if the provider is available for the requested date.
|
||||||
$available_hours = $this->availability->get_available_hours($date, $service, $provider);
|
$available_hours = $this->availability->get_available_hours($date, $service, $provider);
|
||||||
|
|
||||||
if (count($available_hours) > $max_hours_count)
|
if (count($available_hours) > $max_hours_count && (empty($hour) || in_array($hour, $available_hours, false)))
|
||||||
{
|
{
|
||||||
$provider_id = $provider['id'];
|
$provider_id = $provider['id'];
|
||||||
$max_hours_count = count($available_hours);
|
$max_hours_count = count($available_hours);
|
||||||
|
@ -527,12 +528,13 @@ class Appointments extends EA_Controller {
|
||||||
|
|
||||||
$appointment = $post_data['appointment'];
|
$appointment = $post_data['appointment'];
|
||||||
|
|
||||||
$date = date('Y-m-d', strtotime($appointment['start_datetime']));
|
$appointment_start = new DateTime($appointment['start_datetime']);
|
||||||
|
$date = $appointment_start->format('Y-m-d');
|
||||||
|
$hour = $appointment_start->format('H:i');
|
||||||
|
|
||||||
if ($appointment['id_users_provider'] === ANY_PROVIDER)
|
if ($appointment['id_users_provider'] === ANY_PROVIDER)
|
||||||
{
|
{
|
||||||
|
$appointment['id_users_provider'] = $this->search_any_provider($appointment['id_services'], $date, $hour);
|
||||||
$appointment['id_users_provider'] = $this->search_any_provider($date, $appointment['id_services']);
|
|
||||||
|
|
||||||
return $appointment['id_users_provider'];
|
return $appointment['id_users_provider'];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue