blocked_period.php
1 year ago
booked_period.php
1 year ago
booking_request.php
1 year ago
booking_resource.php
1 year ago
booking_slot.php
1 year ago
filter.php
1 year ago
process_action.php
9 months ago
process_event.php
1 year ago
role.php
1 year ago
router.php
1 year ago
step.php
1 year ago
stripe_connect_customer.php
1 year ago
time_period.php
1 year ago
user.php
1 year ago
work_period.php
1 year ago
booked_period.php
50 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([ 'start_date' => $booking->start_date, |
| 18 | 'end_date' => $booking->end_date, |
| 19 | 'start_time' => $booking->start_time, |
| 20 | 'end_time' => $booking->end_time, |
| 21 | 'buffer_before' => $booking->buffer_before, |
| 22 | 'buffer_after' => $booking->buffer_after, |
| 23 | 'total_attendees' => $booking->total_attendees ?? 1, |
| 24 | 'agent_id' => $booking->agent_id, |
| 25 | 'service_id' => $booking->service_id, |
| 26 | 'location_id' => $booking->location_id |
| 27 | ]); |
| 28 | } |
| 29 | |
| 30 | function start_time_with_buffer(): int{ |
| 31 | return $this->start_time - $this->buffer_before; |
| 32 | } |
| 33 | |
| 34 | function end_time_with_buffer(): int{ |
| 35 | return $this->end_time + $this->buffer_after; |
| 36 | } |
| 37 | |
| 38 | public static function allowed_props(): array{ |
| 39 | return ['start_date', |
| 40 | 'end_date', |
| 41 | 'start_time', |
| 42 | 'end_time', |
| 43 | 'buffer_before', |
| 44 | 'buffer_after', |
| 45 | 'total_attendees', |
| 46 | 'service_id', |
| 47 | 'agent_id', |
| 48 | 'location_id']; |
| 49 | } |
| 50 | } |