default.php
1 month ago
default_calendar.php
1 month ago
default_create_modal.php
1 month ago
default_day.php
1 month ago
default_filterbar.php
1 month ago
default_modal.php
1 month ago
default_sidebar.php
1 month ago
index.html
1 month ago
default_sidebar.php
251 lines
| 1 | <?php |
| 2 | /** |
| 3 | * @package VikAppointments |
| 4 | * @subpackage core |
| 5 | * @author E4J s.r.l. |
| 6 | * @copyright Copyright (C) 2021 E4J s.r.l. All Rights Reserved. |
| 7 | * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL |
| 8 | * @link https://vikwp.com |
| 9 | */ |
| 10 | |
| 11 | // No direct access |
| 12 | defined('ABSPATH') or die('No script kiddies please!'); |
| 13 | |
| 14 | $vik = VAPApplication::getInstance(); |
| 15 | $config = VAPFactory::getConfig(); |
| 16 | |
| 17 | $calendar = $this->calendar->calendar; |
| 18 | |
| 19 | ?> |
| 20 | |
| 21 | <!-- SERVICES --> |
| 22 | |
| 23 | <?php echo $vik->openEmptyFieldset(); ?> |
| 24 | |
| 25 | <div class="cal-services-list"> |
| 26 | <?php |
| 27 | foreach ($this->services as $i => $s) |
| 28 | { |
| 29 | $checked = empty($this->filters['services']) || in_array($s->id, $this->filters['services']) ? 'checked="checked"' : ''; |
| 30 | |
| 31 | ?> |
| 32 | <div class="cal-service" style="<?php echo $i >= 10 ? 'display: none;' : ''; ?>"> |
| 33 | <span class="check"> |
| 34 | <input type="checkbox" name="services[]" id="service-checkbox<?php echo $s->id; ?>" |
| 35 | value="<?php echo $s->id; ?>" <?php echo $checked; ?> /> |
| 36 | </span> |
| 37 | |
| 38 | <span class="name"> |
| 39 | <label for="service-checkbox<?php echo $s->id; ?>"><?php echo $s->name; ?></span> |
| 40 | </span> |
| 41 | |
| 42 | <span class="color-thumb clickable" data-id="<?php echo $s->id; ?>" data-hex="<?php echo $s->color; ?>" style="background-color: #<?php echo $s->color ?: '7777'; ?>;"> </span> |
| 43 | </div> |
| 44 | <?php |
| 45 | } |
| 46 | |
| 47 | if (count($this->services) >= 10) |
| 48 | { |
| 49 | ?> |
| 50 | <div class="show-all-services"> |
| 51 | <button type="button" class="btn" onclick="jQuery('.cal-service').show();jQuery(this).hide();"><?php echo JText::translate('VAPSHOWALL'); ?></button> |
| 52 | </div> |
| 53 | <?php |
| 54 | } |
| 55 | ?> |
| 56 | </div> |
| 57 | |
| 58 | <?php echo $vik->closeEmptyFieldset(); ?> |
| 59 | |
| 60 | <!-- EVENTS --> |
| 61 | |
| 62 | <?php echo $vik->openEmptyFieldset(); ?> |
| 63 | |
| 64 | <div class="cal-events-list"> |
| 65 | |
| 66 | <?php |
| 67 | if (!$calendar->has()) |
| 68 | { |
| 69 | ?> |
| 70 | <p class="no-event"><?php echo JText::translate('JGLOBAL_NO_MATCHING_RESULTS'); ?></p> |
| 71 | <?php |
| 72 | } |
| 73 | else |
| 74 | { |
| 75 | $max_events = 5; |
| 76 | $i = 0; |
| 77 | |
| 78 | foreach ($calendar->getEventsList() as $i => $event) |
| 79 | { |
| 80 | $dt_str = JHtml::fetch('date', $event->checkin_ts, $config->get('dateformat')); |
| 81 | $tm_str = JHtml::fetch('date', $event->checkin_ts, $config->get('timeformat')); |
| 82 | ?> |
| 83 | <div class="event-row" style="<?php echo $i >= $max_events ? 'display: none;' : ''; ?>"> |
| 84 | |
| 85 | <div class="event-id"> |
| 86 | <span><?php echo $event->id; ?></span> |
| 87 | </div> |
| 88 | |
| 89 | <div class="event-checkin"> |
| 90 | <span><?php echo $dt_str; ?></span> |
| 91 | <span> |
| 92 | <span> |
| 93 | <a href="javascript:void(0)" onclick="goToSlot(<?php echo $event->id; ?>);"><?php echo '@' . $tm_str; ?></a> |
| 94 | </span> |
| 95 | <span class="duration"><?php echo VikAppointments::formatMinutesToTime($event->duration); ?></span> |
| 96 | </span> |
| 97 | </div> |
| 98 | |
| 99 | <div class="event-details"> |
| 100 | <span class="service-name" style="color: #<?php echo $event->service_color; ?>;"><?php echo $event->service_name; ?></span> |
| 101 | <span><?php echo $event->employee_name; ?></span> |
| 102 | </div> |
| 103 | |
| 104 | <div class="event-customer"> |
| 105 | <span><?php echo $event->purchaser_nominative; ?></span> |
| 106 | </div> |
| 107 | |
| 108 | <div class="event-guests"> |
| 109 | <?php |
| 110 | if ($event->people > 1) |
| 111 | { |
| 112 | ?> |
| 113 | <span><?php echo $event->people; ?> <i class="fas fa-users"></i></span> |
| 114 | <?php |
| 115 | } |
| 116 | ?> |
| 117 | </div> |
| 118 | |
| 119 | </div> |
| 120 | <?php |
| 121 | } |
| 122 | |
| 123 | if ($i >= $max_events) |
| 124 | { |
| 125 | ?> |
| 126 | <div class="show-all-events"> |
| 127 | <button type="button" class="btn" onclick="jQuery('.event-row').show();jQuery(this).hide();"><?php echo JText::translate('VAPSHOWALL'); ?></button> |
| 128 | </div> |
| 129 | <?php |
| 130 | } |
| 131 | } |
| 132 | ?> |
| 133 | |
| 134 | </div> |
| 135 | |
| 136 | <?php echo $vik->closeEmptyFieldset(); ?> |
| 137 | |
| 138 | <script> |
| 139 | |
| 140 | (function($) { |
| 141 | 'use strict'; |
| 142 | |
| 143 | let POINTER_TIMER = null; |
| 144 | |
| 145 | window['goToSlot'] = (id) => { |
| 146 | $('td div[data-id]').each(function() { |
| 147 | var ids = $(this).data('id'); |
| 148 | |
| 149 | if (!isNaN(ids)) { |
| 150 | ids = [ids]; |
| 151 | } else { |
| 152 | ids = ids.split(','); |
| 153 | } |
| 154 | |
| 155 | for (var i = 0; i < ids.length; i++) { |
| 156 | if (ids[i] == id) { |
| 157 | animateSlot(this); |
| 158 | return false; |
| 159 | } |
| 160 | } |
| 161 | }); |
| 162 | } |
| 163 | |
| 164 | const animateSlot = (slot) => { |
| 165 | // animate only in case the slot is not visible |
| 166 | var px_to_scroll = isBoxOutOfMonitor($(slot), 50); |
| 167 | |
| 168 | if (px_to_scroll !== false) { |
| 169 | let op = px_to_scroll > 0 ? '+=' : '-='; |
| 170 | px_to_scroll = Math.abs(px_to_scroll) + $(slot).height() / 2 + 50; |
| 171 | $('html,body').animate( {scrollTop: op + px_to_scroll}, {duration:'normal'} ); |
| 172 | } |
| 173 | |
| 174 | var pointer = $('.slot-pointer'); |
| 175 | var offset = $(slot).offset(); |
| 176 | |
| 177 | var top = offset.top + $(slot).height() / 2 - pointer.height() / 2; |
| 178 | var left = offset.left + $(slot).width() + 30; |
| 179 | |
| 180 | pointer.css('top', top + 'px'); |
| 181 | pointer.css('left', left + 'px'); |
| 182 | |
| 183 | pointer.show(); |
| 184 | |
| 185 | if (POINTER_TIMER) { |
| 186 | clearTimeout(POINTER_TIMER); |
| 187 | } |
| 188 | |
| 189 | POINTER_TIMER = setTimeout(function() { |
| 190 | // pointer.hide(); |
| 191 | }, 2000); |
| 192 | } |
| 193 | |
| 194 | // delay submit on service checkbox change by 2 seconds |
| 195 | const debounceCheckboxChange = VikTimer.debounce('serviceCheckboxChange', () => { |
| 196 | document.adminForm.submit(); |
| 197 | }, 2000); |
| 198 | |
| 199 | $(function() { |
| 200 | var THUMB_ELEM = null; |
| 201 | var THUMB_COLOR = null; |
| 202 | |
| 203 | const changeThumbColor = (color, elem) => { |
| 204 | $(elem).attr('data-hex', color); |
| 205 | $(elem).css('background-color', '#' + color); |
| 206 | |
| 207 | var id_service = $(elem).data('id'); |
| 208 | |
| 209 | $('td div[data-service="' + id_service + '"]').css('background-color', '#' + color); |
| 210 | |
| 211 | UIAjax.do( |
| 212 | '<?php echo $vik->ajaxUrl('index.php?option=com_vikappointments&task=service.changecolorajax'); ?>', |
| 213 | { |
| 214 | id: id_service, |
| 215 | color: color, |
| 216 | } |
| 217 | ); |
| 218 | }; |
| 219 | |
| 220 | $('.color-thumb.clickable').ColorPicker({ |
| 221 | onShow: function() { |
| 222 | THUMB_COLOR = $(this).attr('data-hex'); |
| 223 | $(this).ColorPickerSetColor('#' + THUMB_COLOR.toUpperCase()); |
| 224 | |
| 225 | THUMB_ELEM = this; |
| 226 | }, |
| 227 | onChange: function (hsb, hex, rgb) { |
| 228 | THUMB_COLOR = hex; |
| 229 | }, |
| 230 | onHide: function() { |
| 231 | if (THUMB_COLOR.toUpperCase() != $(THUMB_ELEM).attr('data-hex').toUpperCase()) { |
| 232 | changeThumbColor(THUMB_COLOR, THUMB_ELEM); |
| 233 | } |
| 234 | } |
| 235 | }); |
| 236 | |
| 237 | /** |
| 238 | * Append slot pointer at the end of the body to prevent unexpected |
| 239 | * translations because of parent elements with relative position. |
| 240 | * |
| 241 | * @since 1.7 |
| 242 | */ |
| 243 | $('body').append('<div class="slot-pointer" style="display: none;"></div>'); |
| 244 | |
| 245 | // submit form when the status of a service checkbox changes |
| 246 | $('#adminForm input[name="services[]"]').on('change', debounceCheckboxChange); |
| 247 | }); |
| 248 | })(jQuery); |
| 249 | |
| 250 | </script> |
| 251 |