Skip to content
Snippets Groups Projects
Commit 5e59574e authored by Ricardo Marcelino's avatar Ricardo Marcelino
Browse files

#3427811 - Days in advance

parent 502897a6
Branches main
No related tags found
No related merge requests found
......@@ -52,6 +52,14 @@ class WebformBookingController extends ControllerBase {
$actualEndDate = $endDate < $endOfMonth ? $endDate : $endOfMonth;
$actualEndDate->modify('+1 day');
// Adjusting end date based on 'days_advance' if set.
if (isset($config['#days_advance']) && is_numeric($config['#days_advance'])) {
$advanceDate = (new \DateTime())->modify('+' . $config['#days_advance'] . ' days');
if ($actualStartDate < $advanceDate) {
$actualStartDate = $advanceDate;
}
}
// Interval of 1 day.
$interval = new \DateInterval('P1D');
$dateRange = new \DatePeriod($actualStartDate, $interval, $actualEndDate);
......
......@@ -33,6 +33,7 @@ class WebformBooking extends WebformElementBase {
'start_date' => '',
'end_date' => '',
'exclusion_dates' => '',
'days_advance' => '0',
'excluded_weekdays' => [],
'time_interval' => '',
'slot_duration' => '',
......@@ -77,7 +78,13 @@ class WebformBooking extends WebformElementBase {
'#title' => $this->t('End Date'),
'#default_value' => $this->getDefaultProperty('end_date'),
];
// Days in advance.
$form['appointment_settings']['days_advance'] = [
'#type' => 'number',
'#title' => $this->t('Days in Advance'),
'#default_value' => $this->getDefaultProperty('days_advance'),
'#description' => $this->t('Number of days in advance a booking can be made'),
];
// Exclusion Dates.
$form['appointment_settings']['exclusion_dates'] = [
'#type' => 'textarea',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment