PluginProbe ʕ •ᴥ•ʔ
Appointment Booking Plugin – LatePoint | Calendar & Scheduling for WordPress / 5.2.1
Appointment Booking Plugin – LatePoint | Calendar & Scheduling for WordPress v5.2.1
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 1 year ago _list.php 1 year ago _month.php 9 months ago _shared.php 1 year ago _week.php 1 year ago
_month.php
171 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">'.esc_html($agent->full_name).'</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">';
99 echo '<div class="ma-day-label">'.esc_html($day_date->format($date_format)).': </div>';
100 foreach($day_periods as $day_period){
101 echo '<div class="ma-day-work-period">';
102 echo esc_html(OsTimeHelper::minutes_to_hours_and_minutes($day_period->start_time).' - '.OsTimeHelper::minutes_to_hours_and_minutes($day_period->end_time));
103 echo '</div>';
104 }
105 echo '</div>';
106 } else {
107 echo '<div class="ma-day-off full"><span><strong>' . esc_html( $day_date->format( $date_format ) ) . ': </strong>' . esc_html__( 'Day Off', 'latepoint' ) . '</span></div>';
108 }
109
110 // show booking even if day is off
111 if(!empty($bookings_grouped_by_date_and_agent[$day_date->format('Y-m-d')][$agent->id])){
112 $overlaps_count = 1;
113 $total_attendees_in_group = 0;
114 $total_bookings_in_group = 0;
115 $total_bookings = count($bookings_grouped_by_date_and_agent[$day_date->format('Y-m-d')][$agent->id]);
116 foreach($bookings_grouped_by_date_and_agent[$day_date->format('Y-m-d')][$agent->id] as $index => $booking){
117 $next_booking = (($index + 1) < $total_bookings) ? $bookings_grouped_by_date_and_agent[$day_date->format('Y-m-d')][$agent->id][$index + 1] : false;
118 if(OsBookingHelper::check_if_group_bookings($booking, $next_booking)){
119 // skip this output because multiple bookings in the same slot because next booking has the same start and end time
120 $total_attendees_in_group+= $booking->total_attendees;
121 $total_bookings_in_group++;
122 continue;
123 }else{
124 if($booking->end_date && ($booking->start_date != $booking->end_date)){
125 $width = (24*60 - $booking->start_time) / $work_total_minutes * 100;
126 $left = ($booking->start_time - $work_boundaries->start_time) / $work_total_minutes * 100;
127 }else{
128 $width = ($booking->end_time - $booking->start_time) / $work_total_minutes * 100;
129 $left = ($booking->start_time - $work_boundaries->start_time) / $work_total_minutes * 100;
130 }
131
132 $max_capacity = OsServiceHelper::get_max_capacity($booking->service);
133 if($max_capacity > 1){
134 $action_html = OsBookingHelper::group_booking_btn_html($booking->id);
135 }else{
136 $action_html = OsBookingHelper::quick_booking_btn_html($booking->id);
137 }
138 if($width <= 0 || $left >= 100 || (($left + $width) <= 0)) continue;
139 if($left < 0){
140 $width = $width + $left;
141 $left = 0;
142 }
143 if(($left + $width) > 100) $width = 100 - $left;
144
145 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.'>';
146 $hide_agent_info = true;
147 include(LATEPOINT_VIEWS_ABSPATH.'dashboard/_booking_info_box_small.php');
148 echo '</div>';
149 // time overlaps
150 $overlaps_count = ($next_booking && ($next_booking->start_time < $booking->end_time)) ? $overlaps_count + 1 : 1;
151 // reset
152 $total_attendees_in_group = 0;
153 }
154 }
155 }
156 echo '</div>';
157
158 }
159 echo '</div>';
160 }
161 echo '</div>';
162 echo '</div>';
163 echo '</div>';
164 }else{ ?>
165 <div class="no-results-w">
166 <div class="icon-w"><i class="latepoint-icon latepoint-icon-grid"></i></div>
167 <h2><?php esc_html_e('No Agents Created', 'latepoint'); ?></h2>
168 <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>
169 </div>
170 <?php } ?>
171 <?php include('_shared.php'); ?>