PluginProbe ʕ •ᴥ•ʔ
LatePoint – Calendar Booking Plugin for Appointments and Events / 5.2.11
LatePoint – Calendar Booking Plugin for Appointments and Events v5.2.11
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 / views / calendars / scopes / _month.php
latepoint / lib / views / calendars / scopes Last commit date
_booking_box_on_calendar.php 1 year ago _day.php 9 months ago _list.php 1 year ago _month.php 9 months ago _shared.php 1 year ago _week.php 9 months ago
_month.php
193 lines
1 <?php
2 /**
3 * @var $target_date OsWpDateTime
4 * @var $today_date OsWpDateTime
5 * @var $calendar_start OsWpDateTime
6 * @var $calendar_end OsWpDateTime
7 * @var $booking_request \LatePoint\Misc\BookingRequest
8 * @var $calendar_settings array
9 * @var $agents OsAgentModel[]
10 * @var $resources \LatePoint\Misc\BookingResource[]
11 */
12
13
14 if ( ! defined( 'ABSPATH' ) ) {
15 exit; // Exit if accessed directly
16 }
17 ?>
18
19 <?php
20 if($agents){ ?>
21 <?php
22 $agents_head_html = '';
23 foreach($agents as $agent){
24 $agents_head_html.=
25 '<div class="ma-head-agent">
26 <div class="ma-head-agent-avatar" style="background-image: url('.esc_url($agent->get_avatar_url()).')"></div>
27 <div class="ma-head-agent-name"><a href="'.esc_url(OsRouterHelper::build_link(['agents', 'edit_form'], ['id' => $agent->id])).'">'.esc_html($agent->full_name).'</a></div>
28 </div>';
29 }
30 $calendar_not_scrollable_class = (count($agents) > 4) ? '' : 'calendar-month-not-scrollable';
31 echo '<div class="calendar-month-agents-w '.esc_attr($calendar_not_scrollable_class).'" data-route="'.esc_attr(OsRouterHelper::build_route_name('calendars', 'month_view')).'">';
32 echo '<div class="ma-floated-days-w">';
33 echo '<div class="ma-head-info"><span>'.esc_html__('Date', 'latepoint').'</span><span>'.esc_html__('Agent', 'latepoint').'</span></div>';
34 for($day_date=clone $calendar_start; $day_date<=$calendar_end; $day_date->modify('+1 day')){
35 echo '<div class="ma-day ma-day-number-'.esc_attr($day_date->format('N')).' '.(($today_date == $day_date) ? 'is-today' : '').'">';
36 echo '<div class="ma-day-info">';
37 echo '<span class="ma-day-number">'.esc_html($day_date->format('j')).'</span>';
38 echo '<span class="ma-day-weekday">'.esc_html(OsUtilHelper::get_weekday_name_by_number($day_date->format('N'), true)).'</span>';
39 echo '</div>';
40 echo '</div>';
41 }
42 echo '</div>';
43
44 echo '<div class="ma-days-with-bookings-w">';
45 echo '<div class="ma-days-with-bookings-i">';
46 echo '<div class="ma-head">';
47 echo $agents_head_html;
48 echo '</div>';
49 for($day_date=clone $calendar_start; $day_date<=$calendar_end; $day_date->modify('+1 day')){
50 echo '<div class="ma-day ma-day-number-'.esc_attr($day_date->format('N')).' '.(($today_date == $day_date) ? 'is-today' : '').'">';
51 foreach($agents as $agent){
52 $day_periods = [];
53 $blocked_blocks = [];
54 foreach($resources[$day_date->format('Y-m-d')] as $resource){
55 // TODO if multiple resources available for this day - merge blocked periods to find intersections - those intersection perons are truly blocked
56 if($resource->agent_id == $agent->id){
57 $day_periods = array_merge($day_periods, $resource->work_time_periods);
58 foreach($resource->blocked_time_periods as $blocked_time_period){
59 if($blocked_time_period->service_id != 0){
60 if(is_array($booking_request->service_id)){
61 if(empty($booking_request->service_id) || count($booking_request->service_id) > 1){
62 continue;
63 }elseif($blocked_time_period->service_id != reset($booking_request->service_id)){
64 continue;
65 }
66 }
67 }
68 if($blocked_time_period->location_id != 0){
69 if(is_array($booking_request->location_id)){
70 if(empty($booking_request->location_id) || count($booking_request->location_id) > 1){
71 continue;
72 }elseif($blocked_time_period->location_id != reset($booking_request->location_id)){
73 continue;
74 }
75 }
76 }
77 $left = max(($blocked_time_period->start_time - $work_boundaries->start_time) / $work_total_minutes * 100, 0);
78 $right = max(($work_boundaries->end_time - $blocked_time_period->end_time) / $work_total_minutes * 100, 0);
79 $blocked_blocks[] = ['left' => $left, 'right' => $right];
80 }
81 }
82 }
83
84
85 usort($day_periods,function($first,$second){
86 return ($first->start_time > $second->start_time) ? 1 : 0;
87 });
88 $day_periods = \LatePoint\Misc\TimePeriod::merge_periods($day_periods);
89
90
91
92 $slot_class = !$day_periods ? 'is-day-off' : '';
93 echo '<div class="ma-day-agent-bookings '. $slot_class . '" ' . OsOrdersHelper::quick_order_btn_html(false, array( 'agent_id' => $agent->id, 'location_id' => $booking_request->location_id, 'start_date' => $day_date->format('Y-m-d'))) . '>';
94
95 if($day_periods){
96 $off_blocks = [];
97 foreach($day_periods as $day_period){
98 if($day_period->start_time > $work_boundaries->start_time){
99 if($off_blocks){
100 $right = ($work_boundaries->end_time - $day_period->start_time) / $work_total_minutes * 100;
101 $off_blocks[count($off_blocks) - 1]['right'] = $right;
102 }else{
103 $right = ($work_boundaries->end_time - $day_period->start_time) / $work_total_minutes * 100;
104 $off_blocks[] = ['left' => 0, 'right' => $right];
105 }
106 }
107 if($day_period->end_time < $work_boundaries->end_time){
108 $left = ($day_period->end_time - $work_boundaries->start_time) / $work_total_minutes * 100;
109 $off_blocks[] = ['left' => $left, 'right' => 0];
110 }
111 }
112 foreach($blocked_blocks as $blocked_block){
113 echo '<div class="ma-day-off ma-period-off" style="left:'.esc_attr($blocked_block["left"]).'%; right: '.esc_attr($blocked_block["right"]).'%;"></div>';
114 }
115 foreach($off_blocks as $off_block){
116 echo '<div class="ma-day-off" style="left:'.esc_attr($off_block["left"]).'%; right: '.esc_attr($off_block["right"]).'%;"></div>';
117 }
118 echo '<div class="ma-day-work-periods-w">';
119 echo '<div class="ma-day-label">'.esc_html($day_date->format($date_format)).'</div>';
120 echo '<div class="ma-day-work-periods">';
121 foreach($day_periods as $day_period){
122 echo '<div class="ma-day-work-period">';
123 echo esc_html(OsTimeHelper::minutes_to_hours_and_minutes($day_period->start_time).' - '.OsTimeHelper::minutes_to_hours_and_minutes($day_period->end_time));
124 echo '</div>';
125 }
126 echo '</div>';
127 echo '</div>';
128 } else {
129 echo '<div class="ma-day-off full"><div class="ma-day-work-periods-w"><div class="ma-day-label">'.esc_html($day_date->format($date_format)).'</div><div class="ma-day-work-periods"><div class="ma-day-work-period">' . esc_html__( 'Day Off', 'latepoint' ) . '</div></div></div></div>';
130 }
131
132 // show booking even if day is off
133 if(!empty($bookings_grouped_by_date_and_agent[$day_date->format('Y-m-d')][$agent->id])){
134 $overlaps_count = 1;
135 $total_attendees_in_group = 0;
136 $total_bookings_in_group = 0;
137 $total_bookings = count($bookings_grouped_by_date_and_agent[$day_date->format('Y-m-d')][$agent->id]);
138 foreach($bookings_grouped_by_date_and_agent[$day_date->format('Y-m-d')][$agent->id] as $index => $booking){
139 $next_booking = (($index + 1) < $total_bookings) ? $bookings_grouped_by_date_and_agent[$day_date->format('Y-m-d')][$agent->id][$index + 1] : false;
140 if(OsBookingHelper::check_if_group_bookings($booking, $next_booking)){
141 // skip this output because multiple bookings in the same slot because next booking has the same start and end time
142 $total_attendees_in_group+= $booking->total_attendees;
143 $total_bookings_in_group++;
144 continue;
145 }else{
146 if($booking->end_date && ($booking->start_date != $booking->end_date)){
147 $width = (24*60 - $booking->start_time) / $work_total_minutes * 100;
148 $left = ($booking->start_time - $work_boundaries->start_time) / $work_total_minutes * 100;
149 }else{
150 $width = ($booking->end_time - $booking->start_time) / $work_total_minutes * 100;
151 $left = ($booking->start_time - $work_boundaries->start_time) / $work_total_minutes * 100;
152 }
153
154 $max_capacity = OsServiceHelper::get_max_capacity($booking->service);
155 if($max_capacity > 1){
156 $action_html = OsBookingHelper::group_booking_btn_html($booking->id);
157 }else{
158 $action_html = OsBookingHelper::quick_booking_btn_html($booking->id);
159 }
160 if($width <= 0 || $left >= 100 || (($left + $width) <= 0)) continue;
161 if($left < 0){
162 $width = $width + $left;
163 $left = 0;
164 }
165 if(($left + $width) > 100) $width = 100 - $left;
166
167 echo '<div class="ma-day-booking" style="left: '.esc_attr($left).'%; width: '.esc_attr($width).'%; background-color: '.esc_attr($booking->service->bg_color).'" '.$action_html.'>';
168 $hide_agent_info = true;
169 include(LATEPOINT_VIEWS_ABSPATH.'dashboard/_booking_info_box_small.php');
170 echo '</div>';
171 // time overlaps
172 $overlaps_count = ($next_booking && ($next_booking->start_time < $booking->end_time)) ? $overlaps_count + 1 : 1;
173 // reset
174 $total_attendees_in_group = 0;
175 }
176 }
177 }
178 echo '</div>';
179
180 }
181 echo '</div>';
182 }
183 echo '</div>';
184 echo '</div>';
185 echo '</div>';
186 }else{ ?>
187 <div class="no-results-w">
188 <div class="icon-w"><i class="latepoint-icon latepoint-icon-grid"></i></div>
189 <h2><?php esc_html_e('No Agents Created', 'latepoint'); ?></h2>
190 <a href="<?php echo esc_url(OsRouterHelper::build_link(OsRouterHelper::build_route_name('agents', 'new_form') )); ?>" class="latepoint-btn"><i class="latepoint-icon latepoint-icon-plus-square"></i><span><?php esc_html_e('Create Agent', 'latepoint'); ?></span></a>
191 </div>
192 <?php } ?>
193 <?php include('_shared.php'); ?>