blocked_period.php
3 months ago
booked_period.php
3 months ago
booking_request.php
3 months ago
booking_resource.php
3 months ago
booking_slot.php
3 months ago
filter.php
3 months ago
process_action.php
1 month ago
process_event.php
1 month ago
role.php
3 weeks ago
router.php
3 months ago
step.php
3 months ago
stripe_connect_customer.php
3 months ago
time_period.php
3 months ago
user.php
3 months ago
work_period.php
3 months ago
booked_period.php
56 lines
| 1 | <?php |
| 2 | /* |
| 3 | * Copyright (c) 2022 LatePoint LLC. All rights reserved. |
| 4 | * |
| 5 | * This class is used to create booked periods in resources |
| 6 | */ |
| 7 | |
| 8 | namespace LatePoint\Misc; |
| 9 | |
| 10 | class BookedPeriod extends BlockedPeriod { |
| 11 | public int $buffer_before = 0; |
| 12 | public int $buffer_after = 0; |
| 13 | public int $total_attendees = 1; |
| 14 | |
| 15 | |
| 16 | public static function create_from_booking_model( \OsBookingModel $booking ): BookedPeriod { |
| 17 | return new BookedPeriod( |
| 18 | [ |
| 19 | 'start_date' => $booking->start_date, |
| 20 | 'end_date' => $booking->end_date, |
| 21 | 'start_time' => $booking->start_time, |
| 22 | 'end_time' => $booking->end_time, |
| 23 | 'buffer_before' => $booking->buffer_before, |
| 24 | 'buffer_after' => $booking->buffer_after, |
| 25 | 'total_attendees' => $booking->total_attendees ?? 1, |
| 26 | 'agent_id' => $booking->agent_id, |
| 27 | 'service_id' => $booking->service_id, |
| 28 | 'location_id' => $booking->location_id, |
| 29 | ] |
| 30 | ); |
| 31 | } |
| 32 | |
| 33 | function start_time_with_buffer(): int { |
| 34 | return $this->start_time - $this->buffer_before; |
| 35 | } |
| 36 | |
| 37 | function end_time_with_buffer(): int { |
| 38 | return $this->end_time + $this->buffer_after; |
| 39 | } |
| 40 | |
| 41 | public static function allowed_props(): array { |
| 42 | return [ |
| 43 | 'start_date', |
| 44 | 'end_date', |
| 45 | 'start_time', |
| 46 | 'end_time', |
| 47 | 'buffer_before', |
| 48 | 'buffer_after', |
| 49 | 'total_attendees', |
| 50 | 'service_id', |
| 51 | 'agent_id', |
| 52 | 'location_id', |
| 53 | ]; |
| 54 | } |
| 55 | } |
| 56 |