PluginProbe
Booktics – Appointment Booking Calendar for Service Businesses / 1.0.16
Booktics – Appointment Booking Calendar for Service Businesses v1.0.16
1.0.29 1.0.28 1.0.27 1.0.26 1.0.25 1.0.24 1.0.23 1.0.22 1.0.21 1.0.20 1.0.19 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.2 1.0.3 All 31 releases
booktics / core / appointment / schedule / default-only-strategy.php

default-only-strategy.php in Booktics – Appointment Booking Calendar for Service Businesses 1.0.16, at core/appointment/schedule/default-only-strategy.php

56 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Booktics\Appointment\Schedule;
3
4 /**
5 * Strategy that generates time slots based only on the default schedule entry.
6 * This class implements the Time_Slot_Strategy interface and provides a basic
7 * slot generation algorithm that ignores service and team member schedules.
8 */
9 class Default_Only_Strategy implements Time_Slot_Strategy {
10 /**
11 * Generates time slots based on the default schedule entry only.
12 *
13 * @param Schedule_Entry|null $service_entry The service schedule entry (not used)
14 * @param Schedule_Entry|null $team_entry The team member schedule entry (not used)
15 * @param Schedule_Entry|null $default_entry The default schedule entry
16 * @param Time_Slot_Manager $manager The time slot manager instance
17 * @param \DateTime $date The date for which to generate slots
18 *
19 * @return array Array of Time_Slot objects representing available time slots
20 */
21 public function generate_slots(
22 array $service_entries,
23 array $team_entries,
24 array $default_entries,
25 Time_Slot_Manager $manager,
26 \DateTime $date
27 ): array {
28 $slots = array();
29 if ( ! empty( $default_entries ) ) {
30 foreach ( $default_entries as $default_entry ) {
31 if ( ! $default_entry || $default_entry->is_holiday() ) {
32 continue;
33 }
34 $start_time = strtotime( $default_entry->get_start_time() );
35 $end_time = strtotime( $default_entry->get_end_time() );
36 $slot_length = $manager->get_slot_length() * 60;
37 $service_duration = $manager->get_service_duration() * 60;
38 $before_buffer = $manager->get_before_buffer_time() * 60;
39 $after_buffer = $manager->get_after_buffer_time() * 60;
40 $gap = $before_buffer + $after_buffer;
41 $current_start = $start_time;
42 while ( $current_start + $service_duration <= $end_time ) {
43 $slot_start = gmdate( 'H:i', $current_start );
44 $slot_end = gmdate( 'H:i', $current_start + $service_duration );
45 $max_capacity = $manager->get_service_max_capacity_for_timeslot(); // Get max capacity from group booking
46
47 $slots[] = new Time_Slot( $slot_start, $slot_end, true, $max_capacity );
48
49 $current_start += $slot_length + $gap;
50 }
51 }
52 }
53 return $slots;
54 }
55 }
56