| Server IP : 47.82.179.145 / Your IP : 216.73.217.129 Web Server : nginx/1.26.3 System : Linux iZt4n9czhka2zvqfajdlr2Z 6.8.0-63-generic #66-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 13 20:25:30 UTC 2025 x86_64 User : www ( 1001) PHP Version : 8.3.30 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wwwroot/scuipturepactory.com/wp-content/plugins.off/latepoint/lib/helpers/ |
Upload File : |
<?php
/*
* Copyright (c) 2022 LatePoint LLC. All rights reserved.
*/
class OsTimelineHelper{
/**
* @param \LatePoint\Misc\BookingRequest $booking_request
* @param \LatePoint\Misc\TimePeriod
* @param \LatePoint\Misc\BookingResource[]
* @param array $settings
* @return string
* @throws Exception
*/
public static function availability_timeline(\LatePoint\Misc\BookingRequest $booking_request, \LatePoint\Misc\TimePeriod $timeline_boundaries, array $resources, array $settings = []){
$default_settings = [
'agent_to_show' => false,
'book_on_click' => true,
'show_ticks' => true
];
$settings = array_merge($default_settings, $settings);
$total_timeline_minutes = $timeline_boundaries->end_time - $timeline_boundaries->start_time;
$html = '<div class="agent-day-availability-w">';
if($settings['agent_to_show']){
// show agent avatar if agent was passed
$agent = $settings['agent_to_show'];
$html.= '<a href="'.OsRouterHelper::build_link(['agents', 'edit_form'], ['id' => $agent->id] ).'" class="agent-avatar-w with-hover-name" style="background-image: url('.$agent->get_avatar_url().');"><span>'.$agent->full_name.'</span></a>';
}
$booking_slots = OsResourceHelper::get_ordered_booking_slots_from_resources($resources);
$html.= '<div class="agent-timeslots">';
if($booking_slots){
$total_slots = count($booking_slots);
$after_slot_html = false;
$slot_width = false;
$gap = false;
// find minimum gap
$minimum_slot_gap = \LatePoint\Misc\BookingSlot::find_minimum_gap_between_slots($booking_slots);
if($booking_slots[0]->start_time != $timeline_boundaries->start_time){
$slot_width = ($booking_slots[0]->start_time - $timeline_boundaries->start_time) / $total_timeline_minutes * 100;
$html.= self::timeline_timeslot_off($slot_width);
}
for($i = 0; $i<$total_slots; $i++){
if($i == $total_slots - 1){
// last slot in a day
$prev_width = $slot_width;
$slot_width = ($timeline_boundaries->end_time - $booking_slots[$i]->start_time) / $total_timeline_minutes * 100;
if($prev_width && $prev_width < $slot_width){
$after_slot_html = self::timeline_timeslot_off($slot_width - $prev_width);
$slot_width = $prev_width;
}
}else{
$gap = $booking_slots[$i + 1]->start_time - $booking_slots[$i]->start_time;
if($gap > $minimum_slot_gap){
$slot_width = $minimum_slot_gap / $total_timeline_minutes * 100;
$after_slot_html = self::timeline_timeslot_off(($gap - $minimum_slot_gap) / $total_timeline_minutes * 100);
}else{
$slot_width = ($booking_slots[$i + 1]->start_time - $booking_slots[$i]->start_time) / $total_timeline_minutes * 100;
}
}
$html.= self::timeline_timeslot($booking_slots[$i], $booking_request, ['show_ticks' => $settings['show_ticks'], 'book_on_click' => $settings['book_on_click'], 'slot_width' => $slot_width]);
if($after_slot_html){
$html.=$after_slot_html;
$after_slot_html = false;
}
}
}else{
$html.= self::availability_timeline_off();
}
$html.= '</div>';
$html.= '</div>';
return $html;
}
public static function availability_timeline_off(string $off_label = ''){
$off_label = $off_label ? $off_label : __('Not Available', 'latepoint');
return '<div class="agent-timeslot is-off full-day-off"><span class="agent-timeslot-label">'.$off_label.'</span></div>';
}
/**
* @param \LatePoint\Misc\BookingSlot $booking_slot
* @param \LatePoint\Misc\BookingRequest $booking_request
* @param array $settings
* @return string
*/
public static function timeline_timeslot(\LatePoint\Misc\BookingSlot $booking_slot, \LatePoint\Misc\BookingRequest $booking_request, array $settings = []){
$default_settings = [
'book_on_click' => true,
'show_ticks' => true,
'slot_width' => false
];
$settings = array_merge($default_settings, $settings);
$ampm = OsTimeHelper::am_or_pm($booking_slot->start_time);
$tick_html = '';
$timeslot_class = '';
if($settings['show_ticks'] && ($booking_slot->start_time % 60) == 0){
$timeslot_class.= ' with-tick';
$tick_html = '<span class="agent-timeslot-tick"><strong>'. OsTimeHelper::minutes_to_hours($booking_slot->start_time) .'</strong>'.' '.$ampm.'</span>';
}
$data_attrs = '';
if($booking_slot->can_accomodate($booking_request->total_attendees)){
$timeslot_class.= ' is-available';
if($settings['book_on_click']){
// clicking a timeslot will result in opening a new booking slideout
$data_attrs = OsOrdersHelper::quick_order_btn_html(false, ['start_time'=> $booking_slot->start_time,
'agent_id' => $booking_request->agent_id,
'service_id' => $booking_request->service_id,
'location_id' => $booking_request->location_id,
'start_date' => $booking_request->start_date]);
}else{
// fills in the data of a booking form slideout
$data_attrs = 'data-date="'.$booking_slot->start_date.'" data-formatted-date="'.OsTimeHelper::reformat_date_string($booking_slot->start_date, 'Y-m-d', OsSettingsHelper::get_date_format()).'" data-minutes="'.$booking_slot->start_time.'"';
$timeslot_class.= ' fill-booking-time';
}
}else{
$timeslot_class.= ' is-booked';
}
$style = $settings['slot_width'] ? 'width: '.$settings['slot_width'].'%' : '';
$timeslot_html = '<div '.$data_attrs.' style="'.$style.'" class="agent-timeslot '.$timeslot_class.'">
<span class="agent-timeslot-label"><div class="at-sub-value">'.OsTimeHelper::get_nice_date_with_optional_year($booking_slot->start_date).'</div><div class="at-main-value">'.OsTimeHelper::minutes_to_hours_and_minutes($booking_slot->start_time).'</div></span>'.
$tick_html.'
</div>';
return $timeslot_html;
}
public static function timeline_timeslot_off($slot_width){
return '<div class="agent-timeslot is-off" style="width: '.esc_attr($slot_width).'%"><span class="agent-timeslot-label">'.__('Not Available', 'latepoint').'</span></div>';
}
}