_booking_info_box_small.php
9 months ago
index.php
1 year ago
widget_bookings_and_availability_timeline.php
9 months ago
widget_daily_bookings_chart.php
1 year ago
widget_upcoming_appointments.php
1 year ago
widget_bookings_and_availability_timeline.php
151 lines
| 1 | <?php |
| 2 | if ( ! defined( 'ABSPATH' ) ) { |
| 3 | exit; // Exit if accessed directly |
| 4 | } |
| 5 | ?> |
| 6 | <div class="os-widget os-widget-agents-bookings-timeline os-widget-animated" data-os-reload-action="<?php echo esc_attr(OsRouterHelper::build_route_name('dashboard', 'widget_bookings_and_availability_timeline')); ?>"> |
| 7 | <div class="os-widget-header with-actions"> |
| 8 | <h3 class="os-widget-header-text"><?php esc_html_e('Day Preview', 'latepoint'); ?></h3> |
| 9 | <div class="os-widget-header-actions-trigger"><i class="latepoint-icon latepoint-icon-more-horizontal"></i></div> |
| 10 | <div class="os-widget-header-actions"> |
| 11 | <div class="os-date-range-picker" data-single-date="yes"> |
| 12 | <span class="range-picker-value"><?php echo esc_html(OsTimeHelper::get_readable_date($target_date_obj)); ?></span> |
| 13 | <i class="latepoint-icon latepoint-icon-chevron-down"></i> |
| 14 | <input type="hidden" name="date_from" value="<?php echo esc_attr($target_date_obj->format('Y-m-d')); ?>"/> |
| 15 | <input type="hidden" name="date_to" value="<?php echo esc_attr($target_date_obj->format('Y-m-d')); ?>"/> |
| 16 | </div> |
| 17 | <?php echo OsFormHelper::hidden_field('what_to_show', $what_to_show, ['class' => 'os-trigger-reload-widget', 'id' => 'what_to_show_on_timeline_widget']); ?> |
| 18 | <select name="location_id" id="" class="os-trigger-reload-widget"> |
| 19 | <?php if(OsSettingsHelper::is_on('one_location_at_time')) echo '<option value="">'.esc_html__('All Locations', 'latepoint').'</option>'; ?> |
| 20 | <?php foreach($locations as $location){ ?> |
| 21 | <option value="<?php echo esc_attr($location->id); ?>" <?php if($location->id == $selected_location_id) echo 'selected="selected"' ?>><?php echo esc_html($location->name); ?></option> |
| 22 | <?php } ?> |
| 23 | </select> |
| 24 | <select name="service_id" id="" class="os-trigger-reload-widget"> |
| 25 | <?php echo '<option value="">'.esc_html__('All Services', 'latepoint').'</option>'; ?> |
| 26 | <?php foreach($services as $service){ ?> |
| 27 | <option value="<?php echo esc_attr($service->id); ?>" <?php if($service->id == $selected_service_id) echo 'selected="selected"' ?>><?php echo esc_html($service->name); ?></option> |
| 28 | <?php } ?> |
| 29 | </select> |
| 30 | <div class="timeline-type-toggle" data-value-holder-id="what_to_show_on_timeline_widget"> |
| 31 | <div class="timeline-type-option <?php echo ($what_to_show == 'appointments') ? 'active' : ''; ?>" data-value="appointments"><?php esc_html_e('Appointments', 'latepoint'); ?></div> |
| 32 | <div class="timeline-type-option <?php echo ($what_to_show == 'availability') ? 'active' : ''; ?>" data-value="availability"><?php esc_html_e('Availability', 'latepoint'); ?></div> |
| 33 | </div> |
| 34 | </div> |
| 35 | </div> |
| 36 | <div class="os-widget-content no-padding"> |
| 37 | <?php if($agents){ ?> |
| 38 | <div class="timeline-with-info-w"> |
| 39 | <div class="timeline-and-availability-w"> |
| 40 | <div class="timeline-and-availability-contents shows-<?php echo esc_attr($what_to_show); ?>"> |
| 41 | <div class="agent-day-bookings-timeline-compact-w"> |
| 42 | <div class="agents-avatars"> |
| 43 | <?php foreach($agents as $agent){ ?> |
| 44 | <div class="avatar-w"> |
| 45 | <a href="<?php echo esc_url(OsRouterHelper::build_link(['agents', 'edit_form'], ['id' => $agent->id] )); ?>" class="avatar-i" style="background-image: url(<?php echo esc_url($agent->get_avatar_url()); ?>);"> |
| 46 | <span><?php echo esc_html($agent->full_name); ?></span> |
| 47 | </a> |
| 48 | </div> |
| 49 | <?php } ?> |
| 50 | </div> |
| 51 | <div class="agents-timelines-w"> |
| 52 | <?php if($show_today_indicator) echo '<div class="current-time-indicator" style="left: '.esc_attr($time_now_indicator_left_offset).'%"><span>'.esc_html($time_now_label).'</span></div>'; ?> |
| 53 | <div class="timeline-top-w"> |
| 54 | <?php |
| 55 | for($minutes = $work_boundaries->start_time; $minutes <= $work_boundaries->end_time; $minutes+= 5){ |
| 56 | if(($minutes % 60) == 0){ |
| 57 | echo '<div class="timeslot with-tick"><div class="tick"></div><div class="timeslot-time"><div class="timeslot-hour">'.esc_html(OsTimeHelper::minutes_to_hours($minutes)).'</div><div class="timeslot-ampm">'.esc_html(OsTimeHelper::am_or_pm($minutes)).'</div></div></div>'; |
| 58 | }else{ |
| 59 | echo '<div class="timeslot"></div>'; |
| 60 | } |
| 61 | } |
| 62 | ?> |
| 63 | </div> |
| 64 | <?php foreach($agents as $agent){ |
| 65 | $timeline_booking_request = clone $availability_booking_request; |
| 66 | $timeline_booking_request->agent_id = $agent->id; ?> |
| 67 | <div class="agent-timeline-w"> |
| 68 | <div class="agent-timeline"> |
| 69 | <?php echo OsTimelineHelper::availability_timeline($timeline_booking_request, $work_boundaries, $agents_resources['agent_'.$agent->id], ['show_ticks' => false]); ?> |
| 70 | <?php |
| 71 | $bookings_filter = new \LatePoint\Misc\Filter(['statuses' => OsCalendarHelper::get_booking_statuses_to_display_on_calendar(), 'date_from' => $target_date, 'agent_id' => $agent->id, 'location_id' => $selected_location_id]); |
| 72 | $bookings = OsBookingHelper::get_bookings($bookings_filter, true); |
| 73 | echo '<div class="booking-blocks">'; |
| 74 | if($bookings && $work_total_minutes){ |
| 75 | $overlaps_count = 1; |
| 76 | $total_attendees_in_group = 0; |
| 77 | $total_bookings_in_group = 0; |
| 78 | $total_bookings = count($bookings); |
| 79 | foreach($bookings as $index => $booking){ |
| 80 | $next_booking = (($index + 1) < $total_bookings) ? $bookings[$index + 1] : false; |
| 81 | if(OsBookingHelper::check_if_group_bookings($booking, $next_booking)){ |
| 82 | // skip this output because multiple bookings in the same slot because next booking has the same start and end time |
| 83 | $total_attendees_in_group+= $booking->total_attendees; |
| 84 | $total_bookings_in_group++; |
| 85 | continue; |
| 86 | }else{ |
| 87 | |
| 88 | $width = ($booking->end_time - $booking->start_time) / $work_total_minutes * 100; |
| 89 | $left = ($booking->start_time - $work_boundaries->start_time) / $work_total_minutes * 100; |
| 90 | if($width <= 0 || $left >= 100 || (($left + $width) <= 0)) continue; |
| 91 | if($left < 0){ |
| 92 | $width = $width + $left; |
| 93 | $left = 0; |
| 94 | } |
| 95 | if(($left + $width) > 100) $width = 100 - $left; |
| 96 | $max_capacity = OsServiceHelper::get_max_capacity($booking->service); |
| 97 | if($max_capacity > 1){ |
| 98 | $action_html = OsBookingHelper::group_booking_btn_html($booking->id); |
| 99 | }else{ |
| 100 | $action_html = OsBookingHelper::quick_booking_btn_html($booking->id); |
| 101 | } |
| 102 | |
| 103 | $custom_height = (isset($overlaps_count) && $overlaps_count > 1) ? 'height:'.(26 / $overlaps_count).'px;' : ''; |
| 104 | |
| 105 | echo '<div data-start="'.esc_attr($booking->start_time).'" data-end="'.esc_attr($booking->end_time).'" class="booking-block status-'.esc_attr($booking->status).'" '.$action_html.' style="background-color: '.esc_attr($booking->service->bg_color).'; left: '.esc_attr($left).'%; width: '.esc_attr($width).'%;'.esc_attr($custom_height).'">'; |
| 106 | $hide_agent_info = true; |
| 107 | include('_booking_info_box_small.php'); |
| 108 | echo '</div>'; |
| 109 | |
| 110 | // time overlaps |
| 111 | $overlaps_count = ($next_booking && ($next_booking->start_time < $booking->end_time)) ? $overlaps_count + 1 : 1; |
| 112 | // reset |
| 113 | $total_attendees_in_group = 0; |
| 114 | } |
| 115 | } |
| 116 | } |
| 117 | do_action('latepoint_appointments_timeline', OsWpDateTime::os_createFromFormat('Y-m-d', $target_date), ['agent_id' => $agent->id,'work_start_minutes' => $work_boundaries->start_time, 'work_end_minutes' => $work_boundaries->end_time, 'work_total_minutes' => $work_total_minutes]); |
| 118 | echo '</div>'; |
| 119 | ?> |
| 120 | </div> |
| 121 | </div> |
| 122 | <?php } ?> |
| 123 | <?php if(count($agents) > 3){ ?> |
| 124 | <div class="timeline-bottom-w"> |
| 125 | <?php |
| 126 | |
| 127 | for($minutes = $work_boundaries->start_time; $minutes <= $work_boundaries->end_time; $minutes+= 5){ |
| 128 | if(($minutes % 60) == 0){ |
| 129 | echo '<div class="timeslot with-tick"><div class="timeslot-time"><div class="timeslot-hour">'.esc_html(OsTimeHelper::minutes_to_hours($minutes)).'</div><div class="timeslot-ampm">'.esc_html(OsTimeHelper::am_or_pm($minutes)).'</div></div></div>'; |
| 130 | }else{ |
| 131 | echo '<div class="timeslot"></div>'; |
| 132 | } |
| 133 | } |
| 134 | ?> |
| 135 | </div> |
| 136 | <?php } ?> |
| 137 | </div> |
| 138 | </div> |
| 139 | </div> |
| 140 | </div> |
| 141 | </div> |
| 142 | <?php |
| 143 | }else{ ?> |
| 144 | <div class="no-results-w"> |
| 145 | <div class="icon-w"><i class="latepoint-icon latepoint-icon-user-plus"></i></div> |
| 146 | <h2><?php esc_html_e('No Agents Created', 'latepoint'); ?></h2> |
| 147 | <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> |
| 148 | </div> |
| 149 | <?php } ?> |
| 150 | </div> |
| 151 | </div> |