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