mirror of
https://github.com/alextselegidis/easyappointments.git
synced 2024-11-22 16:02:54 +03:00
Unavailable dates generation must take into concern the appointment edit mode of the booking page (#433).
This commit is contained in:
parent
9805fe7c80
commit
6fe70d0723
2 changed files with 34 additions and 3 deletions
|
@ -609,12 +609,34 @@ class Appointments extends CI_Controller {
|
||||||
$selected_date = new DateTime($selected_date_string);
|
$selected_date = new DateTime($selected_date_string);
|
||||||
$number_of_days_in_month = (int)$selected_date->format('t');
|
$number_of_days_in_month = (int)$selected_date->format('t');
|
||||||
$unavailable_dates = [];
|
$unavailable_dates = [];
|
||||||
|
$manage_mode = filter_var($this->input->get('manage_mode'), FILTER_VALIDATE_BOOLEAN);
|
||||||
|
|
||||||
|
$exclude_appointments = ($_REQUEST['manage_mode'] === 'true')
|
||||||
|
? [$_REQUEST['appointment_id']]
|
||||||
|
: [];
|
||||||
|
|
||||||
// Handle the "Any Provider" case.
|
// Handle the "Any Provider" case.
|
||||||
if ($provider_id === ANY_PROVIDER)
|
if ($provider_id === ANY_PROVIDER)
|
||||||
{
|
{
|
||||||
$provider_id = $this->_search_any_provider($service_id, $selected_date_string);
|
$provider_id = $this->_search_any_provider($service_id, $selected_date_string);
|
||||||
|
|
||||||
|
if ($provider_id === null) {
|
||||||
|
$current_date = new DateTime($selected_date_string);
|
||||||
|
$current_date->add(new DateInterval('P1D'));
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
$provider_id = $this->_search_any_provider($service_id, $current_date->format('Y-m-d H:i:s'));
|
||||||
|
|
||||||
|
if ($provider_id)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$current_date->add(new DateInterval('P1D'));
|
||||||
|
} while ((int)$current_date->format('d') <= $number_of_days_in_month);
|
||||||
|
}
|
||||||
|
|
||||||
if ($provider_id === NULL)
|
if ($provider_id === NULL)
|
||||||
{
|
{
|
||||||
// No provider is available in the selected date.
|
// No provider is available in the selected date.
|
||||||
|
@ -653,10 +675,10 @@ class Appointments extends CI_Controller {
|
||||||
|
|
||||||
$empty_periods = $this->_get_provider_available_time_periods($provider_id,
|
$empty_periods = $this->_get_provider_available_time_periods($provider_id,
|
||||||
$service_id,
|
$service_id,
|
||||||
$current_date->format('Y-m-d'));
|
$current_date->format('Y-m-d'), $exclude_appointments);
|
||||||
|
|
||||||
$available_hours = $this->_calculate_available_hours($empty_periods, $current_date->format('Y-m-d'),
|
$available_hours = $this->_calculate_available_hours($empty_periods, $current_date->format('Y-m-d'),
|
||||||
$service['duration'], FALSE, $service['availabilities_type']);
|
$service['duration'], $manage_mode, $service['availabilities_type']);
|
||||||
|
|
||||||
if ($service['attendants_number'] > 1)
|
if ($service['attendants_number'] > 1)
|
||||||
{
|
{
|
||||||
|
@ -871,6 +893,11 @@ class Appointments extends CI_Controller {
|
||||||
$remove_current_period = TRUE;
|
$remove_current_period = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($break_start == $period_start && $break_end == $period_end)
|
||||||
|
{
|
||||||
|
$remove_current_period = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
if ($remove_current_period)
|
if ($remove_current_period)
|
||||||
{
|
{
|
||||||
unset($periods[$key]);
|
unset($periods[$key]);
|
||||||
|
|
|
@ -207,12 +207,16 @@ window.FrontendBookApi = window.FrontendBookApi || {};
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var appointmentId = FrontendBook.manageMode ? GlobalVariables.appointmentData.id : undefined;
|
||||||
|
|
||||||
var url = GlobalVariables.baseUrl + '/index.php/appointments/ajax_get_unavailable_dates';
|
var url = GlobalVariables.baseUrl + '/index.php/appointments/ajax_get_unavailable_dates';
|
||||||
var data = {
|
var data = {
|
||||||
provider_id: providerId,
|
provider_id: providerId,
|
||||||
service_id: serviceId,
|
service_id: serviceId,
|
||||||
selected_date: encodeURIComponent(selectedDateString),
|
selected_date: encodeURIComponent(selectedDateString),
|
||||||
csrfToken: GlobalVariables.csrfToken
|
csrfToken: GlobalVariables.csrfToken,
|
||||||
|
manage_mode: FrontendBook.manageMode,
|
||||||
|
appointment_id: appointmentId
|
||||||
};
|
};
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
|
Loading…
Reference in a new issue