PluginProbe ʕ •ᴥ•ʔ
LatePoint – Calendar Booking Plugin for Appointments and Events / 5.6.6
LatePoint – Calendar Booking Plugin for Appointments and Events v5.6.6
5.6.7 5.6.6 5.6.5 5.6.4 5.6.3 5.6.2 5.6.1 5.6.0 5.5.2 5.5.1 5.5.0 5.4.2 trunk 5.1.0 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5 5.1.6 5.1.7 5.1.8 5.1.9 5.1.91 5.1.92 5.1.93 5.1.94 5.2.0 5.2.1 5.2.10 5.2.11 5.2.2 5.2.3 5.2.4 5.2.5 5.2.6 5.2.7 5.2.8 5.2.9 5.3.0 5.3.1 5.3.2 5.4.0 5.4.1
latepoint / lib / helpers / events_helper.php
latepoint / lib / helpers Last commit date
activities_helper.php 3 months ago agent_helper.php 3 months ago analytics_helper.php 1 week ago auth_helper.php 6 days ago blocks_helper.php 3 weeks ago booking_helper.php 4 days ago bricks_helper.php 3 months ago bundles_helper.php 4 days ago calendar_helper.php 3 days ago carts_helper.php 3 months ago connector_helper.php 3 months ago csv_helper.php 3 months ago customer_helper.php 1 month ago customer_import_helper.php 1 month ago database_helper.php 1 week ago debug_helper.php 3 months ago defaults_helper.php 3 months ago elementor_helper.php 3 months ago email_helper.php 3 months ago encrypt_helper.php 3 months ago events_helper.php 3 months ago form_helper.php 3 months ago icalendar_helper.php 3 months ago image_helper.php 3 months ago invoices_helper.php 3 weeks ago license_helper.php 3 months ago location_helper.php 3 months ago marketing_systems_helper.php 3 months ago meeting_systems_helper.php 3 months ago menu_helper.php 3 weeks ago meta_helper.php 3 months ago migrations_helper.php 3 months ago money_helper.php 3 months ago notifications_helper.php 3 months ago nps_survey_helper.php 3 months ago order_intent_helper.php 2 months ago orders_helper.php 3 months ago otp_helper.php 3 months ago pages_helper.php 3 months ago params_helper.php 3 months ago payments_helper.php 2 months ago plugin_version_update_helper.php 2 months ago price_breakdown_helper.php 3 months ago process_jobs_helper.php 3 months ago processes_helper.php 3 months ago razorpay_connect_helper.php 1 week ago replacer_helper.php 3 months ago resource_helper.php 4 days ago roles_helper.php 3 weeks ago router_helper.php 3 months ago service_helper.php 3 months ago sessions_helper.php 3 months ago settings_helper.php 1 week ago short_links_systems_helper.php 3 months ago shortcodes_helper.php 3 weeks ago sms_helper.php 3 months ago steps_helper.php 1 week ago stripe_connect_helper.php 1 week ago styles_helper.php 3 months ago support_topics_helper.php 3 months ago time_helper.php 2 months ago timeline_helper.php 2 months ago transaction_helper.php 1 month ago transaction_intent_helper.php 3 months ago util_helper.php 1 month ago version_specific_updates_helper.php 3 months ago whatsapp_helper.php 1 month ago work_periods_helper.php 3 months ago wp_datetime.php 3 months ago wp_user_helper.php 3 months ago
events_helper.php
477 lines
1 <?php
2 /*
3 * Copyright (c) 2022 LatePoint LLC. All rights reserved.
4 */
5
6
7 class OsEventsHelper {
8
9 public static function week_grid( OsWpDateTime $calendar_start, OsWpDateTime $calendar_end, OsWpDateTime $target_date, array $services_with_resources, array $filter = [] ) {
10 $now_datetime = OsTimeHelper::now_datetime_object();
11 $html = '';
12
13
14 $start_time = 540;
15 $end_time = 1080;
16
17 $min_service_duration = false;
18
19 $day_slots = [];
20 for ( $day_date = clone $calendar_start; $day_date <= $calendar_end; $day_date->modify( '+1 day' ) ) {
21 $day_slots[ $day_date->format( 'Y-m-d' ) ] = [];
22 foreach ( $services_with_resources as $service_resources ) {
23 if ( empty( $service_resources['resources'][ $day_date->format( 'Y-m-d' ) ] ) ) {
24 continue;
25 }
26 $clean_periods = [];
27 foreach ( $service_resources['resources'][ $day_date->format( 'Y-m-d' ) ] as $resource ) {
28 if ( ! empty( $filter['agent_id'] ) && $resource->agent_id != $filter['agent_id'] ) {
29 continue;
30 }
31 if ( ! empty( $filter['service_id'] ) && $resource->service_id != $filter['service_id'] ) {
32 continue;
33 }
34 if ( ! empty( $filter['location_id'] ) && $resource->location_id != $filter['location_id'] ) {
35 continue;
36 }
37 foreach ( $resource->work_time_periods as $time_period ) {
38 $clean_periods[] = $time_period;
39 }
40 }
41 $merged_periods = \LatePoint\Misc\TimePeriod::merge_periods( $clean_periods );
42
43
44 foreach ( $merged_periods as $time_period ) {
45 if ( ( $time_period->end_time - $time_period->start_time ) > 0 ) {
46 $min_service_duration = $min_service_duration ? min( $min_service_duration, ( $time_period->end_time - $time_period->start_time ) ) : $time_period->end_time - $time_period->start_time;
47 }
48 $service_box_data = [
49 'model' => $service_resources['model'],
50 'time_period' => $time_period,
51 ];
52 $day_slots[ $day_date->format( 'Y-m-d' ) ][ $time_period->start_time ][] = $service_box_data;
53 $start_time = min( $start_time, $time_period->start_time );
54 $end_time = max( $end_time, $time_period->end_time );
55 }
56 }
57 ksort( $day_slots[ $day_date->format( 'Y-m-d' ) ] );
58 }
59
60 $html .= '<div class="latepoint-calendar-week">';
61
62 // make it start a little earlier so that there is some space between day labels and first bookings
63 $start_time = $start_time - 60;
64
65 // make sure timeline starts at hour marks
66 if ( $start_time % 60 != 0 ) {
67 $start_time = $start_time - ( $start_time % 60 );
68 }
69 $day_duration = $end_time - $start_time;
70
71 $hour_height_css = '';
72 if ( $min_service_duration && $min_service_duration < 60 ) {
73 $default_hour_height = 44;
74 $hour_height = ceil( 60 / $min_service_duration ) * $default_hour_height;
75 $hour_height_css = 'style="height: ' . $hour_height . 'px"';
76 }
77
78 for ( $day_date = clone $calendar_start; $day_date <= $calendar_end; $day_date->modify( '+1 day' ) ) {
79
80
81
82 $is_today = ( $day_date->format( 'Y-m-d' ) == $now_datetime->format( 'Y-m-d' ) );
83 $is_day_in_past = ( $day_date->format( 'Y-m-d' ) < $now_datetime->format( 'Y-m-d' ) );
84 $is_target_month = ( $day_date->format( 'm' ) == $target_date->format( 'm' ) );
85 $is_next_month = ( $day_date->format( 'm' ) > $target_date->format( 'm' ) );
86 $is_prev_month = ( $day_date->format( 'm' ) < $target_date->format( 'm' ) );
87
88
89 $day_class = '';
90 if ( $is_today ) {
91 $day_class .= ' os-today';
92 }
93 if ( $is_day_in_past ) {
94 $day_class .= ' os-day-passed';
95 }
96 if ( $is_target_month ) {
97 $day_class .= ' os-month-current';
98 }
99 if ( $is_next_month ) {
100 $day_class .= ' os-month-next';
101 }
102 if ( $is_prev_month ) {
103 $day_class .= ' os-month-prev';
104 }
105 $day_class .= ' day-weekday-' . $day_date->format( 'N' );
106
107 $html .= '<div class="le-day-wrapper ' . $day_class . '">';
108
109
110 $html .= '<div class="le-day-weekday-wrapper">';
111 $html .= '<div class="le-day-weekday">' . OsBookingHelper::get_weekday_name_by_number( $day_date->format( 'N' ) ) . '</div>';
112 if ( $day_date->format( 'd' ) == '1' ) {
113 $html .= '<div class="os-day-month">' . OsUtilHelper::get_month_name_by_number( $day_date->format( 'n' ) ) . '</div>';
114 }
115 $html .= '<div class="le-day-number"
116 data-os-params="' . OsUtilHelper::build_os_params(
117 [
118 'target_date_string' => $day_date->format( 'Y-m-d' ),
119 'filter' => $filter,
120 ]
121 ) . '"
122 data-os-output-target="lightbox"
123 data-os-lightbox-classes="width-600"
124 data-os-action="' . OsRouterHelper::build_route_name( 'events', 'events_day_view' ) . '">' . $day_date->format( 'j' ) .
125 '</div>';
126 $html .= '</div>';
127
128 $html .= '<div class="le-day-schedule-wrapper">';
129 $html .= '<div class="day-schedule-timeslots">';
130 for ( $i = $start_time; $i < $end_time; $i += 60 ) {
131 $html .= '<div class="day-schedule-timeslot-wrapper">';
132 $html .= '<div class="day-schedule-timeslot" ' . $hour_height_css . '><div class="day-schedule-timeslot-value">' . OsTimeHelper::minutes_to_hours_and_minutes( $i, null, true, true ) . '</div></div>';
133 $html .= '</div>';
134
135 }
136 foreach ( $day_slots[ $day_date->format( 'Y-m-d' ) ] as $day_slot_services ) {
137 foreach ( $day_slot_services as $day_slot_service ) {
138 $slot_duration = $day_slot_service['time_period']->end_time - $day_slot_service['time_period']->start_time;
139 $start_position = ( $day_slot_service['time_period']->start_time - $start_time ) / $day_duration * 100;
140 $height = $slot_duration / $day_duration * 100;
141 $extra_attrs = 'style="top: ' . $start_position . '%; height: ' . $height . '%"';
142 $html .= self::event_service_box_html( $day_slot_service['model'], $day_slot_service['time_period'], $filter, $day_date, $extra_attrs );
143 }
144 }
145 $html .= '</div>';
146 $html .= '</div>';
147 $html .= '</div>';
148 }
149 $html .= '</div>';
150 return $html;
151 }
152
153 public static function month_grid( OsWpDateTime $calendar_start, OsWpDateTime $calendar_end, OsWpDateTime $target_date, array $services_with_resources, array $filter = [] ) {
154 $now_datetime = OsTimeHelper::now_datetime_object();
155 $html = '';
156 $html .= '<div class="latepoint-calendar-month">';
157
158 $weekdays = OsBookingHelper::get_weekdays_arr();
159 foreach ( $weekdays as $weekday_number => $weekday_name ) {
160 $html .= '<div class="le-weekday weekday-' . ( $weekday_number + 1 ) . '">' . $weekday_name . '</div>';
161 }
162
163 for ( $day_date = clone $calendar_start; $day_date <= $calendar_end; $day_date->modify( '+1 day' ) ) {
164 $is_today = ( $day_date->format( 'Y-m-d' ) == $now_datetime->format( 'Y-m-d' ) );
165 $is_day_in_past = ( $day_date->format( 'Y-m-d' ) < $now_datetime->format( 'Y-m-d' ) );
166 $is_target_month = ( $day_date->format( 'm' ) == $target_date->format( 'm' ) );
167 $is_next_month = ( $day_date->format( 'm' ) > $target_date->format( 'm' ) );
168 $is_prev_month = ( $day_date->format( 'm' ) < $target_date->format( 'm' ) );
169
170 $day_class = '';
171 if ( $is_today ) {
172 $day_class .= ' os-today';
173 }
174 if ( $is_day_in_past ) {
175 $day_class .= ' os-day-passed';
176 }
177 if ( $is_target_month ) {
178 $day_class .= ' os-month-current';
179 }
180 if ( $is_next_month ) {
181 $day_class .= ' os-month-next';
182 }
183 if ( $is_prev_month ) {
184 $day_class .= ' os-month-prev';
185 }
186 $day_class .= ' day-weekday-' . $day_date->format( 'N' );
187
188 $html .= '<div class="le-day-wrapper ' . $day_class . '">';
189
190 if ( $day_date->format( 'd' ) == '1' ) {
191 $html .= '<div class="os-day-month">' . OsUtilHelper::get_month_name_by_number( $day_date->format( 'n' ) ) . '</div>';
192 }
193 $html .= '<div class="le-day-number"
194 data-os-params="' . OsUtilHelper::build_os_params(
195 [
196 'target_date_string' => $day_date->format( 'Y-m-d' ),
197 'filter' => $filter,
198 ]
199 ) . '"
200 data-os-output-target="lightbox"
201 data-os-lightbox-classes="width-600"
202 data-os-action="' . OsRouterHelper::build_route_name( 'events', 'events_day_view' ) . '">' . $day_date->format( 'j' ) .
203 '</div>';
204 $day_services_html = [];
205 foreach ( $services_with_resources as $service_resources ) {
206 if ( empty( $service_resources['resources'][ $day_date->format( 'Y-m-d' ) ] ) ) {
207 continue;
208 }
209 $clean_periods = [];
210 foreach ( $service_resources['resources'][ $day_date->format( 'Y-m-d' ) ] as $resource ) {
211 if ( ! empty( $filter['agent_id'] ) && $resource->agent_id != $filter['agent_id'] ) {
212 continue;
213 }
214 if ( ! empty( $filter['service_id'] ) && $resource->service_id != $filter['service_id'] ) {
215 continue;
216 }
217 if ( ! empty( $filter['location_id'] ) && $resource->location_id != $filter['location_id'] ) {
218 continue;
219 }
220 foreach ( $resource->work_time_periods as $time_period ) {
221 $clean_periods[] = $time_period;
222 }
223 }
224 $merged_periods = \LatePoint\Misc\TimePeriod::merge_periods( $clean_periods );
225 foreach ( $merged_periods as $time_period ) {
226 $day_services_html[ $time_period->start_time ][] = self::event_service_box_html( $service_resources['model'], $time_period, $filter, $day_date );
227 }
228 }
229 ksort( $day_services_html );
230 $daily_count = 0;
231 foreach ( $day_services_html as $day_service_html ) {
232 if ( $daily_count >= 4 ) {
233 // translators: %d is the number of services
234 $more = sprintf( __( '+ %d more', 'latepoint' ), count( $day_services_html ) - 4 );
235 $html .= '<div class="le-more-services"
236 data-os-params="' . esc_attr(
237 OsUtilHelper::build_os_params(
238 [
239 'target_date_string' => $day_date->format( 'Y-m-d' ),
240 'filter' => $filter,
241 ]
242 )
243 ) . '"
244 data-os-output-target="lightbox"
245 data-os-lightbox-classes="width-600"
246 data-os-action="' . esc_attr( OsRouterHelper::build_route_name( 'events', 'events_day_view' ) ) . '">' . esc_html( $more ) . '</div>';
247 break;
248 }
249 $daily_count++;
250 $html .= implode( '', $day_service_html );
251 }
252 $html .= '</div>';
253 }
254 $html .= '</div>';
255 return $html;
256 }
257
258 public static function event_service_box_html( OsServiceModel $service, \LatePoint\Misc\TimePeriod $time_period, array $filter, OsWpDateTime $start_date, string $extra_attrs = '' ) {
259 $service_box_html = '';
260 $selected_attributes = '';
261
262 if ( ! empty( $filter['agent_id'] ) ) {
263 $selected_attributes .= ' data-selected-agent="' . esc_attr( $filter['agent_id'] ) . '" ';
264 }
265 if ( ! empty( $filter['location_id'] ) ) {
266 $selected_attributes .= ' data-selected-location="' . esc_attr( $filter['location_id'] ) . '" ';
267 }
268 if ( ! empty( $filter['show_agents'] ) ) {
269 $selected_attributes .= ' data-show-agents="' . esc_attr( $filter['show_agents'] ) . '" ';
270 }
271 if ( ! empty( $filter['show_locations'] ) ) {
272 $selected_attributes .= ' data-show-locations="' . esc_attr( $filter['show_locations'] ) . '" ';
273 }
274
275
276 if ( OsEventsHelper::is_service_slot_passed( $service, $start_date, $time_period ) ) {
277 $service_box_html .= '<div class="le-service-wrapper is-passed" ' . $extra_attrs . '><div class="is-passed-message">' . esc_html__( 'This event has passed', 'latepoint' ) . '</div>';
278 } else {
279 $start_time_attr = ( ( $time_period->end_time - $time_period->start_time ) > $service->duration ) ? '' : 'data-selected-start-time="' . esc_attr( $time_period->start_time ) . '"';
280 $service_box_html .= '<div class="le-service-wrapper os_trigger_booking" ' . $extra_attrs . ' ' . $selected_attributes . '
281 data-selected-service="' . esc_attr( $service->id ) . '"
282 data-selected-start-date="' . esc_attr( $start_date->format( 'Y-m-d' ) ) . '"
283 ' . $start_time_attr . '
284 data-hide-side-panel="yes">';
285 }
286 $service_box_html .= '<div class="le-service-inner">';
287 $service_box_html .= '<div class="le-color-elem" style="background-color: ' . esc_attr( $service->bg_color ) . '"></div>';
288 $service_box_html .= '<div class="le-service-name">' . esc_html( $service->name ) . '</div>';
289 $service_box_html .= '<div class="le-service-time-period">' . OsTimeHelper::minutes_to_hours_and_minutes( $time_period->start_time ) . ' - ' . OsTimeHelper::minutes_to_hours_and_minutes( $time_period->end_time ) . '</div>';
290 $service_box_html .= '</div>';
291 $service_box_html .= '</div>';
292 return $service_box_html;
293 }
294
295 public static function events_grid( OsWpDateTime $target_date, array $filter = [], $range_type = 'week', array $restrictions = [] ): string {
296 $html = '';
297
298 switch ( $range_type ) {
299 case 'week':
300 # Get bounds for a month of a targeted day
301 $calendar_start = clone $target_date;
302 // set monday as start of the week
303 $start_of_the_week_day = 1;
304 // figure out what week day is target and then find start and end of that week
305 $shift = $calendar_start->format( 'N' ) - $start_of_the_week_day;
306 if ( $shift ) {
307 $calendar_start->modify( '-' . $shift . ' days' );
308 }
309 $calendar_end = clone $calendar_start;
310 $calendar_end->modify( '+6 days' );
311
312 $next_period = clone $calendar_start;
313 $next_period->modify( '+7 days' );
314
315 $prev_period = clone $calendar_start;
316 $prev_period->modify( '-7 days' );
317 break;
318 case 'month':
319 # Get bounds for a month of a targeted day
320 $calendar_start = clone $target_date;
321 $calendar_start->modify( 'first day of this month' );
322 $calendar_end = clone $target_date;
323 $calendar_end->modify( 'last day of this month' );
324
325 $next_period = clone $target_date;
326 $next_period->modify( 'first day of next month' );
327
328 $prev_period = clone $target_date;
329 $prev_period->modify( 'first day of previous month' );
330
331
332 $weekday_for_first_day_of_month = $calendar_start->format( 'N' ) - 1;
333 $weekday_for_last_day_of_month = $calendar_end->format( 'N' ) - 1;
334
335
336 if ( $weekday_for_first_day_of_month > 0 ) {
337 $calendar_start->modify( '-' . $weekday_for_first_day_of_month . ' days' );
338 }
339
340 if ( $weekday_for_last_day_of_month < 6 ) {
341 $days_to_add = 6 - $weekday_for_last_day_of_month;
342 $calendar_end->modify( '+' . $days_to_add . ' days' );
343 }
344 break;
345 }
346
347
348 $now_datetime = OsTimeHelper::now_datetime_object();
349
350
351 $services = new OsServiceModel();
352 if ( ! empty( $restrictions['show_services'] ) ) {
353 $services->where( [ 'id' => explode( ',', $restrictions['show_services'] ) ] );
354 }
355 $services = $services->should_be_active()->get_results_as_models();
356
357 $services_with_resources = [];
358
359 foreach ( $services as $service ) {
360 $services_with_resources[ 'service_' . $service->id ] = [
361 'model' => $service,
362 'work_periods' => [],
363 ];
364 $booking_request = new \LatePoint\Misc\BookingRequest(
365 [
366 'service_id' => $service->id,
367 ]
368 );
369 $services_with_resources[ 'service_' . $service->id ]['resources'] = OsResourceHelper::get_resources_grouped_by_day( $booking_request, $calendar_start, $calendar_end );
370 }
371
372 $clean_filter = [];
373 foreach ( $filter as $filter_key => $filter_value ) {
374 if ( ! empty( $filter_value ) ) {
375 $clean_filter[ $filter_key ] = $filter_value;
376 }
377 }
378
379 $filter_class = empty( $clean_filter ) ? '' : 'show-filters';
380
381 $clean_filter = array_merge( $clean_filter, $restrictions );
382 $agent_restriction = ! empty( $restrictions['show_agents'] ) ? explode( ',', $restrictions['show_agents'] ) : [];
383 $service_restriction = ! empty( $restrictions['show_services'] ) ? explode( ',', $restrictions['show_services'] ) : [];
384
385 $html .= '<div class="latepoint-calendar-wrapper ' . $filter_class . '" data-route-name="' . OsRouterHelper::build_route_name( 'events', 'load_calendar_events' ) . '" data-target-date="' . $target_date->format( 'Y-m-d' ) . '">';
386 $html .= '<div class="latepoint-calendar-controls-wrapper">';
387 $html .= OsFormHelper::hidden_field( 'restrictions', wp_json_encode( $restrictions ) );
388 $html .= '<div class="latepoint-calendar-controls">';
389 if ( $range_type == 'week' ) {
390 if ( $calendar_start->format( 'M' ) == $calendar_end->format( 'M' ) ) {
391 $html .= '<div class="le-week">' . $calendar_start->format( 'M j' ) . ' - ' . $calendar_end->format( 'j' ) . '</div>';
392 } else {
393 $html .= '<div class="le-week">' . $calendar_start->format( 'M j' ) . ' - ' . $calendar_end->format( 'M j' ) . '</div>';
394 }
395 }
396 if ( $range_type == 'month' ) {
397 $html .= '<div class="le-month">' . OsUtilHelper::get_month_name_by_number( $target_date->format( 'n' ) ) . '</div>';
398 }
399 $html .= '<div class="le-range-selector">' . OsFormHelper::select_field(
400 'calendar_range_type',
401 false,
402 [
403 'week' => __( 'Weekly', 'latepoint' ),
404 'month' => __( 'Monthly', 'latepoint' ),
405 ],
406 $range_type
407 ) . '</div>';
408 $html .= '<div class="le-filter le-filter-trigger"><i class="latepoint-icon latepoint-icon-ui-47"></i><span>' . __( 'Filters', 'latepoint' ) . '</span></div>';
409 $html .= OsFormHelper::hidden_field( 'target_date_string', $target_date->format( 'Y-m-d' ) );
410 $html .= '<div class="le-navigation-wrapper">';
411 $html .= '<div class="le-navigation">
412 <div class="le-navigation-button le-navigation-trigger" data-target-date="' . $prev_period->format( 'Y-m-d' ) . '"><i class="latepoint-icon latepoint-icon-arrow-left"></i></div>
413 <div class="le-today le-navigation-trigger" data-target-date="' . $now_datetime->format( 'Y-m-d' ) . '">' . __( 'Today', 'latepoint' ) . '</div>
414 <div class="le-navigation-button le-navigation-trigger" data-target-date="' . $next_period->format( 'Y-m-d' ) . '"><i class="latepoint-icon latepoint-icon-arrow-right"></i></div>
415 </div>';
416 $html .= '</div>';
417 $html .= '</div>';
418 $html .= '<div class="latepoint-calendar-filters">';
419 $html .= '<div class="le-filters-label">' . __( 'Show:', 'latepoint' ) . '</div>';
420 $html .= OsFormHelper::select_field(
421 'filter[agent_id]',
422 false,
423 array_merge(
424 [
425 [
426 'value' => '',
427 'label' => __( 'All Agents', 'latepoint' ),
428 ],
429 ],
430 OsAgentHelper::get_agents_list( false, $agent_restriction )
431 ),
432 $clean_filter['agent_id'] ?? ''
433 );
434 $html .= OsFormHelper::select_field(
435 'filter[service_id]',
436 false,
437 array_merge(
438 [
439 [
440 'value' => '',
441 'label' => __( 'All Services', 'latepoint' ),
442 ],
443 ],
444 OsServiceHelper::get_services_list( false, $service_restriction )
445 ),
446 $clean_filter['service_id'] ?? ''
447 );
448 $html .= '</div>';
449 $html .= '</div>';
450
451 switch ( $range_type ) {
452 case 'week':
453 $html .= self::week_grid( $calendar_start, $calendar_end, $target_date, $services_with_resources, $clean_filter );
454 break;
455 case 'month':
456 $html .= self::month_grid( $calendar_start, $calendar_end, $target_date, $services_with_resources, $clean_filter );
457 break;
458 }
459
460 $html .= '</div>';
461 return $html;
462 }
463
464 private static function is_service_slot_passed( OsServiceModel $service, OsWpDateTime $start_date, \LatePoint\Misc\TimePeriod $time_period ): bool {
465 $now_datetime = OsTimeHelper::now_datetime_object();
466 $is_day_in_past = ( $start_date->format( 'Y-m-d' ) < $now_datetime->format( 'Y-m-d' ) );
467 $is_today = ( $start_date->format( 'Y-m-d' ) == $now_datetime->format( 'Y-m-d' ) );
468
469 try {
470 $is_passed = ( $is_day_in_past || $is_today && ( OsWpDateTime::os_createFromFormat( LATEPOINT_DATETIME_DB_FORMAT, $start_date->format( 'Y-m-d' ) . ' ' . OsTimeHelper::minutes_to_army_hours_and_minutes( $time_period->end_time - $service->duration ) . ':00' ) < $now_datetime ) );
471 } catch ( Exception $e ) {
472 $is_passed = false;
473 }
474 return $is_passed;
475 }
476 }
477