feat(appointment): enhance booking window functionality with day/week/month options and update defaults
This commit is contained in:
@@ -263,10 +263,13 @@ class SlotCalculatorService
|
||||
return false;
|
||||
}
|
||||
|
||||
/** آخرین روزی که رزرو عمومی روی آن مجاز است (شروعِ آن روز، 00:00). */
|
||||
private function bookingWindowEnd(array $meta): int
|
||||
{
|
||||
$value = max(1, (int) ($meta['booking_window_value'] ?? 1));
|
||||
$unit = ($meta['booking_window_unit'] ?? 'month') === 'week' ? 'week' : 'month';
|
||||
$value = max(1, (int) ($meta['booking_window_value'] ?? WeeklySchedule::DEFAULT_META['booking_window_value']));
|
||||
$unit = in_array($meta['booking_window_unit'] ?? null, WeeklySchedule::BOOKING_WINDOW_UNITS, true)
|
||||
? $meta['booking_window_unit']
|
||||
: WeeklySchedule::DEFAULT_META['booking_window_unit'];
|
||||
|
||||
return (int) strtotime("today +{$value} {$unit} 00:00:00");
|
||||
}
|
||||
@@ -309,11 +312,7 @@ class SlotCalculatorService
|
||||
return false;
|
||||
}
|
||||
|
||||
$value = max(1, (int)($meta['booking_window_value'] ?? 1));
|
||||
$unit = ($meta['booking_window_unit'] ?? 'month') === 'week' ? 'week' : 'month';
|
||||
$maxStart = (int) strtotime("today +{$value} {$unit} 00:00:00");
|
||||
|
||||
return $dayStart <= $maxStart;
|
||||
return $dayStart <= $this->bookingWindowEnd($meta);
|
||||
}
|
||||
|
||||
private function getBookingMeta(Doctor $doctor, ?Clinic $clinic): array
|
||||
|
||||
Reference in New Issue
Block a user