scopes
2 months ago
load_monthly_calendar_days_only.php
1 year ago
missing_resources.php
1 year ago
quick_actions.php
1 year ago
view.php
9 months ago
view.php
197 lines
| 1 | <?php |
| 2 | /* |
| 3 | * Copyright (c) 2023 LatePoint LLC. All rights reserved. |
| 4 | */ |
| 5 | |
| 6 | /** |
| 7 | * |
| 8 | * @var $target_date OsWpDateTime |
| 9 | * @var $today_date OsWpDateTime |
| 10 | * @var $calendar_settings array |
| 11 | * @var $locations OsLocationModel[] |
| 12 | * @var $services OsServiceModel[] |
| 13 | * @var $agents OsAgentModel[] |
| 14 | * @var $categorized_services_list array |
| 15 | */ |
| 16 | |
| 17 | |
| 18 | if ( ! defined( 'ABSPATH' ) ) { |
| 19 | exit; // Exit if accessed directly |
| 20 | } |
| 21 | |
| 22 | if(!empty($services) && !empty($agents)){ ?> |
| 23 | <div class="calendar-wrapper" data-view="<?php echo esc_attr($calendar_settings['view']); ?>"> |
| 24 | <form class="os-calendar-settings-form" action=""> |
| 25 | <div class="os-calendar-settings-main"> |
| 26 | <div class="os-current-month-label-w calendar-mobile-controls"> |
| 27 | <div class="os-current-month-label"> |
| 28 | <div class="current-month"> |
| 29 | <?php echo esc_html($top_date_label); ?> |
| 30 | </div> |
| 31 | <div class="current-year"><?php echo esc_html($target_date->format('Y')); ?></div> |
| 32 | </div> |
| 33 | <div class="cc-panel"> |
| 34 | <div class="cc-actions"> |
| 35 | |
| 36 | <a href="#" class="cc-action-today os-calendar-today-btn calendar-load-target-date" data-target-date="<?php echo esc_attr($today_date->format('Y-m-d')); ?>"> |
| 37 | <span><?php esc_html_e('Today', 'latepoint'); ?></span> |
| 38 | </a> |
| 39 | <div class="cc-navigate-arrows"> |
| 40 | <a href="#" class="cc-action-prev os-calendar-prev-btn"><i class="latepoint-icon latepoint-icon-arrow-left"></i></a> |
| 41 | <a href="#" class="cc-action-next os-calendar-next-btn"><i class="latepoint-icon latepoint-icon-arrow-right"></i></a> |
| 42 | </div> |
| 43 | </div> |
| 44 | <div class="cc-view"> |
| 45 | <?php |
| 46 | $views = ['day' => __('Day', 'latepoint'), 'week' => __('Week', 'latepoint'), 'month' => __('Month', 'latepoint'), 'list' => __('List', 'latepoint')]; |
| 47 | echo '<div class="os-calendar-view-toggle" data-update-element-by-name="calendar_settings[view]">'; |
| 48 | foreach($views as $view => $label){ |
| 49 | $selected = $calendar_settings['view'] == $view ? 'os-selected' : ''; |
| 50 | echo '<div class="os-calendar-view-option '.$selected.'" data-value="'.$view.'">'.$label.'</div>'; |
| 51 | } |
| 52 | echo '</div>'; |
| 53 | echo OsFormHelper::hidden_field('calendar_settings[view]', $calendar_settings['view']); ?> |
| 54 | </div> |
| 55 | <?php if(count($services) > 1 || count($agents) > 1 || count($locations) > 1){ ?> |
| 56 | <div class="os-calendar-settings-toggler-wrapper"> |
| 57 | <a href="#" class="calendar-settings-toggler"><i class="latepoint-icon latepoint-icon-more-horizontal"></i></a> |
| 58 | </div> |
| 59 | <?php } ?> |
| 60 | </div> |
| 61 | </div> |
| 62 | </div> |
| 63 | <div class="os-calendar-settings-extra"> |
| 64 | <?php if(count($services) > 1){ ?> |
| 65 | <div class="cc-availability-toggler-w"> |
| 66 | <div class="cc-availability-toggler"><?php echo OsFormHelper::toggler_field('calendar_settings[overlay_service_availability]', __('Overlay service hours', 'latepoint'), ($calendar_settings['availability_service_id'] ? true : false), 'cc-service-availability-selector'); ?></div> |
| 67 | <div class="cc-service-availability-selector" id="cc-service-availability-selector"> |
| 68 | <?php echo OsFormHelper::select_field('calendar_settings[availability_service_id]', __('For:', 'latepoint'), OsUtilHelper::models_to_select_options($services, 'id', 'name'), $calendar_settings['availability_service_id']); ?> |
| 69 | </div> |
| 70 | </div> |
| 71 | <?php } ?> |
| 72 | <div class="resource-filters-wrapper"> |
| 73 | <?php if(count($services) > 1){ ?> |
| 74 | <div class="latecheckbox-w"> |
| 75 | <a href="#" class="latecheckbox"> |
| 76 | <div class="filter-label"><?php esc_html_e('Services:', 'latepoint'); ?></div> |
| 77 | <div class="filter-value"><?php esc_html_e('All', 'latepoint'); ?></div> |
| 78 | </a> |
| 79 | <div class="latecheckbox-options-w"> |
| 80 | <?php if(count($services) >= 5){ ?> |
| 81 | <div class="latecheckbox-filter-input-w"> |
| 82 | <input class="latecheckbox-all-check" type="checkbox" checked/> |
| 83 | <input class="latecheckbox-filter-input" type="text" placeholder="<?php esc_attr_e('Type to filter...', 'latepoint'); ?>"/> |
| 84 | </div> |
| 85 | <?php } ?> |
| 86 | <div class="latecheckbox-options"> |
| 87 | <?php if(!empty($categorized_services_list)){ |
| 88 | foreach($categorized_services_list as $category){ |
| 89 | if(empty($category['items'])) continue; |
| 90 | echo '<div class="latecheckbox-group">'; |
| 91 | echo '<div class="latecheckbox-group-heading"><label><input type="checkbox" class="latecheckbox-group-check" checked/><span>'.esc_html($category['name']).'</span></label></div>'; |
| 92 | echo '<div class="latecheckbox-group-options">'; |
| 93 | foreach($category['items'] as $service){ |
| 94 | echo '<div class="latecheckbox-option">'; |
| 95 | echo '<label>'; |
| 96 | echo '<input name="calendar_settings[show_service_ids][]" type="checkbox" checked value="'.esc_attr($service->id).'"/>'; |
| 97 | echo '<span>'.esc_html($service->name).'</span>'; |
| 98 | echo '</label>'; |
| 99 | echo '</div>'; |
| 100 | } |
| 101 | echo '</div>'; |
| 102 | echo '</div>'; |
| 103 | } |
| 104 | }else{ |
| 105 | foreach($services as $service) { |
| 106 | echo '<div class="latecheckbox-option">'; |
| 107 | echo '<label>'; |
| 108 | echo '<input name="calendar_settings[show_service_ids][]" type="checkbox" checked value="' . esc_attr($service->id) . '"/>'; |
| 109 | echo '<span class="late-label">' . esc_html($service->name) . '</span>'; |
| 110 | echo '</label>'; |
| 111 | echo '</div>'; |
| 112 | } |
| 113 | } |
| 114 | ?> |
| 115 | </div> |
| 116 | </div> |
| 117 | </div> |
| 118 | <?php } ?> |
| 119 | <?php if(count($locations) > 1){ ?> |
| 120 | <div class="latecheckbox-w"> |
| 121 | <a href="#" class="latecheckbox"> |
| 122 | <div class="filter-label"><?php esc_html_e('Locations:', 'latepoint'); ?></div> |
| 123 | <div class="filter-value"><?php esc_html_e('All', 'latepoint'); ?></div> |
| 124 | </a> |
| 125 | <div class="latecheckbox-options-w"> |
| 126 | <?php if(count($locations) >= 5){ ?> |
| 127 | <div class="latecheckbox-filter-input-w"> |
| 128 | <input class="latecheckbox-all-check" type="checkbox" checked/> |
| 129 | <input class="latecheckbox-filter-input" type="text" placeholder="<?php esc_attr_e('Type to filter...', 'latepoint'); ?>"/> |
| 130 | </div> |
| 131 | <?php } ?> |
| 132 | <div class="latecheckbox-options"> |
| 133 | <?php foreach($locations as $location){ |
| 134 | echo '<div class="latecheckbox-option">'; |
| 135 | echo '<label>'; |
| 136 | echo '<input name="calendar_settings[show_location_ids][]" type="checkbox" checked value="'.esc_attr($location->id).'"/>'; |
| 137 | echo '<span class="late-label">'.esc_html($location->name).'</span>'; |
| 138 | echo '</label>'; |
| 139 | echo '</div>'; |
| 140 | } |
| 141 | ?> |
| 142 | </div> |
| 143 | </div> |
| 144 | </div> |
| 145 | |
| 146 | <?php } ?> |
| 147 | <?php if(count($agents) > 1){ ?> |
| 148 | <div class="latecheckbox-w"> |
| 149 | <a href="#" class="latecheckbox"> |
| 150 | <div class="filter-label"><?php esc_html_e('Agents:', 'latepoint'); ?></div> |
| 151 | <div class="filter-value"><?php esc_html_e('All', 'latepoint'); ?></div> |
| 152 | </a> |
| 153 | <div class="latecheckbox-options-w"> |
| 154 | <?php if(count($agents) >= 5){ ?> |
| 155 | <div class="latecheckbox-filter-input-w"> |
| 156 | <input class="latecheckbox-all-check" type="checkbox" checked/> |
| 157 | <input class="latecheckbox-filter-input" type="text" placeholder="<?php esc_attr_e('Type to filter...', 'latepoint'); ?>"/> |
| 158 | </div> |
| 159 | <?php } ?> |
| 160 | <div class="latecheckbox-options"> |
| 161 | <?php foreach($agents as $agent){ |
| 162 | echo '<div class="latecheckbox-option">'; |
| 163 | echo '<label>'; |
| 164 | echo '<input name="calendar_settings[show_agent_ids][]" type="checkbox" checked value="'.esc_attr($agent->id).'"/>'; |
| 165 | echo '<span class="late-avatar" style="background-image: url('.esc_url($agent->get_avatar_url()).')"></span>'; |
| 166 | echo '<span class="late-label">'.esc_html($agent->full_name).'</span>'; |
| 167 | echo '</label>'; |
| 168 | echo '</div>'; |
| 169 | } |
| 170 | ?> |
| 171 | </div> |
| 172 | </div> |
| 173 | </div> |
| 174 | <?php } ?> |
| 175 | </div> |
| 176 | <?php |
| 177 | echo OsFormHelper::hidden_field('calendar_settings[target_date_string]', $target_date->format('Y-m-d')); |
| 178 | echo OsFormHelper::hidden_field('calendar_settings[selected_agent_id]', $calendar_settings['selected_agent_id']); |
| 179 | ?> |
| 180 | </div> |
| 181 | </form> |
| 182 | <div class="calendar-view-wrapper" data-route="<?php echo esc_attr(OsRouterHelper::build_route_name('calendars', 'view')); ?>"> |
| 183 | <?php include_once('scopes/_'.$calendar_settings['view'].'.php'); ?> |
| 184 | </div> |
| 185 | </div> |
| 186 | <?php |
| 187 | }else{ ?> |
| 188 | <div class="no-results-w"> |
| 189 | <div class="icon-w"><i class="latepoint-icon latepoint-icon-grid"></i></div> |
| 190 | <h2><?php esc_html_e('No Agents or Services Created', 'latepoint'); ?></h2> |
| 191 | <?php if(OsAuthHelper::is_admin_logged_in()){ ?> |
| 192 | <a href="<?php echo esc_url(OsRouterHelper::build_link(['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> |
| 193 | <a href="<?php echo esc_url(OsRouterHelper::build_link(['services', 'new_form'] )); ?>" class="latepoint-btn"><i class="latepoint-icon latepoint-icon-plus-square"></i><span><?php esc_html_e('Create Service', 'latepoint'); ?></span></a> |
| 194 | <?php } ?> |
| 195 | </div> |
| 196 | <?php |
| 197 | } |