PluginProbe
Booktics – Appointment Booking Calendar for Service Businesses / 1.0.21
Booktics – Appointment Booking Calendar for Service Businesses v1.0.21
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 / team-member-only-strategy.php

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

56 lines 2.3 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 for generating time slots based solely on team member availability.
7 * This strategy ignores service schedule and uses only team member's schedule to generate slots.
8 *
9 * @package Booktics\Appointment\Schedule
10 */
11 class Team_Member_Only_Strategy implements Time_Slot_Strategy {
12 /**
13 * Generates time slots based on team member's schedule.
14 *
15 * @param Schedule_Entry|null $service_entry Service schedule entry (not used in this strategy)
16 * @param Schedule_Entry|null $team_entry Team member's schedule entry
17 * @param Schedule_Entry|null $default_entry Default schedule entry (not used in this strategy)
18 * @param Time_Slot_Manager $manager Slot manager instance to get slot configuration
19 * @param \DateTime $date Date for which to generate slots
20 *
21 * @return array Array of Time_Slot objects representing available time slots
22 */
23 public function generate_slots(
24 array $service_entries,
25 array $team_entries,
26 array $default_entries,
27 Time_Slot_Manager $manager,
28 \DateTime $date
29 ): array {
30 $slots = array();
31 foreach ( $team_entries as $team_entry ) {
32 if ( ! $team_entry || $team_entry->is_holiday() ) {
33 continue;
34 }
35 $start_time = strtotime( $team_entry->get_start_time() );
36 $end_time = strtotime( $team_entry->get_end_time() );
37 $slot_length = $manager->get_slot_length() * 60;
38 $service_duration = $manager->get_service_duration() * 60;
39 $before_buffer = $manager->get_before_buffer_time() * 60;
40 $after_buffer = $manager->get_after_buffer_time() * 60;
41 $gap = $before_buffer + $after_buffer;
42 $current_start = $start_time;
43 while ( $current_start + $service_duration <= $end_time ) {
44 $slot_start = gmdate( 'H:i', $current_start );
45 $slot_end = gmdate( 'H:i', $current_start + $service_duration );
46 $max_capacity = $manager->get_service_max_capacity_for_timeslot(); // Get max capacity from group booking
47
48 $slots[] = new Time_Slot( $slot_start, $slot_end, true, $max_capacity );
49
50 $current_start += $slot_length + $gap;
51 }
52 }
53 return $slots;
54 }
55 }
56