PluginProbe
Booktics – Appointment Booking Calendar for Service Businesses / 1.0.26
Booktics – Appointment Booking Calendar for Service Businesses v1.0.26
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 / service-only-strategy.php

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

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