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.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 / views / events / events_day_view.php
latepoint / lib / views / events Last commit date
events_day_view.php 1 year ago load_calendar_events.php 1 year ago
events_day_view.php
109 lines
1 <?php
2 /** @var $target_date OsWpDateTime */
3 /** @var $filter array */
4
5
6 if ( ! defined( 'ABSPATH' ) ) {
7 exit; // Exit if accessed directly
8 }
9
10 ?>
11 <div class="le-day-view-wrapper" data-route-name="<?php echo esc_attr(OsRouterHelper::build_route_name('events', 'events_day_view')); ?>">
12 <div class="le-day-info-section">
13 <div class="le-day-info">
14 <div class="le-day-number"><?php echo esc_html($target_date->format('j')); ?></div>
15 <div class="le-day-month"><?php echo esc_html($target_date->format('M')); ?></div>
16 </div>
17 <div class="le-day-filters-wrapper">
18 <div class="le-day-heading"><?php esc_html_e('Daily Schedule', 'latepoint'); ?></div>
19 <div class="le-day-filters">
20 <?php echo OsFormHelper::hidden_field('target_date_string', $target_date->format('Y-m-d')); ?>
21 <?php echo OsFormHelper::select_field('filter[agent_id]', false, array_merge([['value' => '', 'label' => __('All Agents', 'latepoint')]], OsAgentHelper::get_agents_list()), $filter['agent_id'] ?? ''); ?>
22 <?php echo OsFormHelper::select_field('filter[service_id]', false, array_merge([['value' => '', 'label' => __('All Services', 'latepoint')]], OsServiceHelper::get_services_list()), $filter['service_id'] ?? ''); ?>
23 </div>
24 </div>
25 <a href="#" class="latepoint-lightbox-close"><i class="latepoint-icon latepoint-icon-x"></i></a>
26 </div>
27 <div class="le-day-schedule-wrapper">
28 <?php
29 $services_with_resources = [];
30
31 $clean_filter = [];
32 foreach($filter as $filter_key => $filter_value){
33 if(!empty($filter_value)) $clean_filter[$filter_key] = $filter_value;
34 }
35
36 $services = new OsServiceModel();
37 $services = $services->should_be_active()->get_results_as_models();
38
39 foreach ($services as $service) {
40 $services_with_resources['service_' . $service->id] = ['model' => $service, 'work_periods' => []];
41 $booking_request = new \LatePoint\Misc\BookingRequest([
42 'service_id' => $service->id
43 ]);
44 $services_with_resources['service_' . $service->id]['resources'] = OsResourceHelper::get_resources_grouped_by_day($booking_request, $target_date);
45 }
46
47 $start_time = 540;
48 $end_time = 1080;
49 $min_service_duration = false;
50
51 $day_slots = [];
52 foreach ($services_with_resources as $service_resources) {
53 if (empty($service_resources['resources'][$target_date->format('Y-m-d')])) continue;
54 $clean_periods = [];
55 foreach ($service_resources['resources'][$target_date->format('Y-m-d')] as $resource) {
56 if(!empty($clean_filter['agent_id']) && $resource->agent_id != $clean_filter['agent_id']) continue;
57 if(!empty($clean_filter['service_id']) && $resource->service_id != $clean_filter['service_id']) continue;
58 if(!empty($clean_filter['location_id']) && $resource->location_id != $clean_filter['location_id']) continue;
59 foreach ($resource->work_time_periods as $time_period) {
60 $clean_periods[] = $time_period;
61 }
62 }
63 $merged_periods = \LatePoint\Misc\TimePeriod::merge_periods($clean_periods);
64
65
66 foreach ($merged_periods as $time_period) {
67 if(($time_period->end_time - $time_period->start_time) > 0){
68 $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;
69 }
70 $service_box_data = ['model' => $service_resources['model'], 'time_period' => $time_period];
71 $day_slots[$time_period->start_time][] = $service_box_data;
72 $start_time = min($start_time, $time_period->start_time);
73 $end_time = max($end_time, $time_period->end_time);
74 }
75 }
76 ksort($day_slots);
77 // make sure timeline starts at hour marks
78 if($start_time % 60 != 0) $start_time = $start_time - ($start_time % 60);
79 $is_today = $target_date->format('Y-m-d') == OsTimeHelper::today_date('Y-m-d');
80 $is_day_in_past = $target_date->format('Y-m-d') < OsTimeHelper::today_date('Y-m-d');
81 echo '<div class="day-schedule-timeslots">';
82 $hour_height_css = '';
83 if($min_service_duration && $min_service_duration < 60){
84 $default_hour_height = 44;
85 $hour_height = ceil(60 / $min_service_duration) * $default_hour_height;
86 $hour_height_css = 'style="height: '.esc_attr($hour_height).'px"';
87 }
88 for($i = $start_time; $i<$end_time; $i+= 60){
89 echo '<div class="day-schedule-timeslot-wrapper">';
90 echo '<div class="day-schedule-timeslot" '.$hour_height_css.'><div class="day-schedule-timeslot-value">'.esc_html(OsTimeHelper::minutes_to_hours_and_minutes($i, null, true, true)).'</div></div>';
91 echo '</div>';
92 }
93 $day_duration = $end_time - $start_time;
94 foreach($day_slots as $day_slot_services){
95 foreach($day_slot_services as $day_slot_service){
96 $slot_duration = $day_slot_service['time_period']->end_time - $day_slot_service['time_period']->start_time;
97 $start_position = ($day_slot_service['time_period']->start_time - $start_time) / $day_duration * 100;
98 $height = $slot_duration / $day_duration * 100;
99 $extra_attrs = 'style="top: '.esc_attr($start_position).'%; height: '.esc_attr($height).'%"';
100 echo OsEventsHelper::event_service_box_html($day_slot_service['model'], $day_slot_service['time_period'], $clean_filter, $target_date, $extra_attrs);
101 }
102 }
103 echo '</div>';
104
105 ?>
106 </div>
107 </div>
108
109