PluginProbe ʕ •ᴥ•ʔ
VikAppointments Services Booking Calendar / 1.2.21
VikAppointments Services Booking Calendar v1.2.21
1.2.21 1.2.20 trunk 1.2.17 1.2.18 1.2.19
vikappointments / site / views / order / tmpl / default_orderdetails.php
vikappointments / site / views / order / tmpl Last commit date
default.php 3 days ago default.xml 3 days ago default_appointment.php 3 days ago default_attendees.php 3 days ago default_backbutton.php 3 days ago default_countdown.php 3 days ago default_locations.php 3 days ago default_orderdetails.php 3 days ago default_service.php 3 days ago default_usernote.php 3 days ago default_usernote_block.php 3 days ago index.html 3 days ago track.php 3 days ago
default_orderdetails.php
388 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 $order = $this->order;
15
16 $currency = VAPFactory::getCurrency();
17
18 $dispatcher = VAPFactory::getEventDispatcher();
19
20 $forms = array();
21
22 foreach (array('before', 'top', 'actions', 'order', 'payment', 'fields', 'bottom', 'after') as $location)
23 {
24 /**
25 * Trigger event to let the plugins add custom HTML contents within the order details box.
26 *
27 * @param string $location The HTML will be always placed after the specified location.
28 * @param object $order The object holding the order details.
29 *
30 * @return string The HTML to display.
31 *
32 * @since 1.7
33 */
34 $html = array_filter($dispatcher->trigger('onDisplayOrderDetails', array($location, $order)));
35
36 // display all returned blocks, separated by a new line
37 $forms[$location] = implode("\n", $html);
38 }
39
40 ?>
41
42 <!-- Define role to detect the supported hook -->
43 <!-- {"rule":"customizer","event":"onDisplayOrderDetails","type":"sitepage","key":"before"} -->
44
45 <?php
46 // display custom HTML before the summary block
47 echo $forms['before'];
48 ?>
49
50 <div class="vaporderboxcontent">
51
52 <!-- BOX TITLE -->
53
54 <div class="vap-order-first">
55
56 <h3 class="vaporderheader vap-head-first"><?php echo JText::translate('VAPORDERTITLE1'); ?></h3>
57
58 <?php
59 // check whether the customer is allowed to print the orders
60 if (VAPFactory::getConfig()->getBool('printorders'))
61 {
62 ?>
63 <div class="vap-printable">
64 <a
65 href="<?php echo JRoute::rewrite('index.php?option=com_vikappointments&task=order.doprint&id=' . $order->id . '&sid=' . $order->sid . '&tmpl=component' . ($this->itemid ? '&Itemid=' . $this->itemid : '')); ?>"
66 target="_blank"
67 title="<?php echo $this->escape(JText::translate('VAPORDERPRINTACT')); ?>"
68 >
69 <i class="fas fa-print"></i>
70 </a>
71 </div>
72 <?php
73 }
74
75 // check whether we should display the link to download the invoice
76 if ($order->invoice)
77 {
78 ?>
79 <div class="vap-printable">
80 <a
81 href="<?php echo $order->invoice->uri; ?>"
82 target="_blank"
83 title="<?php echo $this->escape(JText::translate('VAPORDERINVOICEACT')); ?>"
84 >
85 <i class="fas fa-file-pdf"></i>
86 </a>
87 </div>
88 <?php
89 }
90 ?>
91
92 <!-- Define role to detect the supported hook -->
93 <!-- {"rule":"customizer","event":"onDisplayOrderDetails","type":"sitepage","key":"actions"} -->
94
95 <?php
96 // display custom HTML within the actions toolbar
97 echo $forms['actions'];
98 ?>
99
100 </div>
101
102 <!-- LEFT SIDE -->
103
104 <div class="vaporderboxleft">
105
106 <div class="vapordercontentinfo">
107
108 <!-- Define role to detect the supported hook -->
109 <!-- {"rule":"customizer","event":"onDisplayOrderDetails","type":"sitepage","key":"top"} -->
110
111 <?php
112 // display custom HTML at the beginning of the order details
113 echo $forms['top'];
114 ?>
115
116 <div class="vaporderinfo">
117 <span class="vaporderinfo-lbl"><?php echo JText::translate('VAPORDERNUMBER'); ?></span>
118 <span class="vaporderinfo-value"><?php echo $order->id; ?></span>
119 </div>
120
121 <div class="vaporderinfo">
122 <span class="vaporderinfo-lbl"><?php echo JText::translate('VAPORDERKEY'); ?></span>
123 <span class="vaporderinfo-value"><?php echo $order->sid; ?></span>
124 </div>
125
126 <div class="vaporderinfo">
127 <span class="vaporderinfo-lbl"><?php echo JText::translate('VAPORDERSTATUS'); ?></span>
128 <span class="vaporderinfo-value">
129 <?php
130 echo JHtml::fetch('vaphtml.status.display', $order->status);
131
132 /**
133 * Check whether the user is able to self-confirm the appointment.
134 *
135 * @since 1.7.1
136 */
137 if (VikAppointments::canUserApproveOrder($order))
138 {
139 // display a tooltip to inform the user that the appointment should
140 // be confirmed by clicking the apposite link received via e-mail
141 JHtml::fetch('bootstrap.tooltip', '.status-help');
142
143 ?>
144 <i class="fas fa-question-circle status-help" title="<?php echo $this->escape(JText::translate('VAP_ORDER_APPROVE_HELP')); ?>"></i>
145 <?php
146 }
147 ?>
148 </span>
149 </div>
150
151 <!-- Define role to detect the supported hook -->
152 <!-- {"rule":"customizer","event":"onDisplayOrderDetails","type":"sitepage","key":"order"} -->
153
154 <?php
155 // display custom HTML within the order section, after the status
156 echo $forms['order'];
157 ?>
158
159 <br clear="all" />
160
161 <?php
162 if ($order->payment)
163 {
164 ?>
165 <div class="vaporderinfo">
166 <span class="vaporderinfo-lbl"><?php echo JText::translate('VAPORDERPAYMENT'); ?></span>
167 <span class="vaporderinfo-value">
168 <?php
169 echo $order->payment->name;
170
171 if ($order->totals->payCharge > 0)
172 {
173 echo ' (' . $currency->format($order->totals->payCharge + $order->totals->payTax) . ')';
174 }
175 ?>
176 </span>
177 </div>
178
179 <?php
180 if ($this->payment && $order->statusRole == 'PENDING')
181 {
182 ?>
183 <div class="vaporderinfo">
184 <span class="vaporderinfo-lbl"><?php echo JText::translate('VAPORDERRESERVATIONCOST'); ?></span>
185 <span class="vaporderinfo-value"><?php echo $currency->format($this->payment['total_to_pay']); ?></span>
186 </div>
187 <?php
188 }
189 }
190
191 if ($order->totals->gross > 0)
192 {
193 ?>
194 <div class="vaporderinfo">
195 <span class="vaporderinfo-lbl"><?php echo JText::translate('VAPORDERDEPOSIT'); ?></span>
196 <span class="vaporderinfo-value">
197 <?php
198 echo $currency->format($order->totals->gross);
199
200 if ($order->coupon)
201 {
202 // display the coupon code next to the total gross
203 echo ' (' . $order->coupon->code . ')';
204 }
205 ?>
206 </span>
207 </div>
208
209 <?php
210 if ($order->totals->paid > 0)
211 {
212 ?>
213 <div class="vaporderinfo">
214 <span class="vaporderinfo-lbl"><?php echo JText::translate('VAPORDERTOTALPAID'); ?></span>
215 <span class="vaporderinfo-value"><?php echo $currency->format($order->totals->paid); ?></span>
216 </div>
217 <?php
218 }
219 }
220 ?>
221
222 <!-- Define role to detect the supported hook -->
223 <!-- {"rule":"customizer","event":"onDisplayOrderDetails","type":"sitepage","key":"payment"} -->
224
225 <?php
226 // display custom HTML within the payment section
227 echo $forms['payment'];
228 ?>
229
230 </div>
231
232 <?php
233 /**
234 * In case of PENDING status, display a countdown to inform the users that they need
235 * to pay/confirm their appointments within the specified range of time.
236 *
237 * @since 1.7
238 * @since 1.7.9 In case of partially paid appointment, the countdown doesn't appear any longer.
239 */
240 if ($order->statusRole == 'PENDING' && VAPFactory::getConfig()->getBool('showcountdown') && (float) $order->totals->paid == 0)
241 {
242 // the template will be shown only if explicitly enabled from the configuration
243 echo $this->loadTemplate('countdown');
244 }
245 ?>
246
247 <!-- Define role to detect the supported hook -->
248 <!-- {"rule":"customizer","event":"onDisplayOrderDetails","type":"sitepage","key":"bottom"} -->
249
250 <?php
251 // display custom HTML at the end of the order details
252 echo $forms['bottom'];
253 ?>
254
255 </div>
256
257 <!-- RIGHT SIDE -->
258
259 <div class="vaorderboxright" id="order-summary-custfields">
260 <?php foreach ($order->displayFields as $key => $val): ?>
261 <div class="vaporderinfo">
262 <span class="vaporderinfo-lbl"><?php echo $key; ?></span>
263 <span class="vaporderinfo-value"><?php echo nl2br($val); ?></span>
264 </div>
265 <?php endforeach; ?>
266
267 <!-- Define role to detect the supported hook -->
268 <!-- {"rule":"customizer","event":"onDisplayOrderDetails","type":"sitepage","key":"fields"} -->
269
270 <?php
271 // display custom HTML within the user fields section
272 echo $forms['fields'];
273
274 /**
275 * Check whether the customer is allowed to edit the custom fields.
276 *
277 * @since 1.7.7
278 */
279 if ($this->editableFields)
280 {
281 ?>
282 <br />
283 <button type="button" class="vap-btn blue" id="edit-custfields-toggle"><?php echo JText::translate('VAPEDIT'); ?></button>
284 <?php
285 }
286 ?>
287 </div>
288
289 <?php if ($this->editableFields): ?>
290 <div class="vaorderboxright" id="order-summary-custfields-edit" style="display: none;">
291 <div class="vapcustomfields">
292 <?php
293 // render the custom fields form by using the apposite helper
294 VAPLoader::import('libraries.customfields.renderer');
295 echo VAPCustomFieldsRenderer::display($this->editableFields, array_merge((array) $order->fields, (array) $order->uploads));
296 ?>
297
298 <div style="flex-basis: 100%;">
299 <button type="button" class="vap-btn blue" id="edit-custfields-submit"><?php echo JText::translate('VAPSAVE'); ?></button>
300 <button type="button" class="vap-btn" id="edit-custfields-cancel"><?php echo JText::translate('VAPCANCEL'); ?></button>
301 </div>
302 </div>
303 </div>
304 <?php endif; ?>
305
306 </div>
307
308 <!-- Define role to detect the supported hook -->
309 <!-- {"rule":"customizer","event":"onDisplayOrderDetails","type":"sitepage","key":"after"} -->
310
311 <?php
312 // display custom HTML after the summary block
313 echo $forms['after'];
314 ?>
315
316 <script>
317 (function($) {
318 'use strict';
319
320 $(function() {
321 // create validator once the document is ready, because certain themes
322 // might load the resources after the body
323 const fieldsValidator = new VikFormValidator('#orderform', 'vapinvalid');
324
325 // render dropdown elements with Select2 jQuery plugin
326 $('.vapcustomfields .cf-value select').each(function() {
327 let option = $(this).find('option').first();
328
329 let data = {
330 // hide search bar in case the number of options is lower than 10
331 minimumResultsForSearch: $(this).find('option').length >= 10 ? 1 : -1,
332 // allow clear selection in case the value of the first option is empty
333 allowClear: option.val() ? false : true,
334 // take the whole space
335 width: '100%',
336 };
337
338 if (data.allowClear && !$(this).prop('multiple')) {
339 // set placeholder by using the option text
340 data.placeholder = option.text();
341
342 // unset the text from the option for a correct rendering
343 option.text('');
344 }
345
346 $(this).select2(data);
347 });
348
349 onInstanceReady(() => {
350 return fieldsValidator;
351 }).then((form) => {
352 /**
353 * Overwrite getLabel method to properly access the
354 * label by using our custom layout.
355 *
356 * @param mixed input The input element.
357 *
358 * @param mixed The label of the input.
359 */
360 form.getLabel = (input) => {
361 return $(input).closest('.cf-control').find('.cf-label *[id^="vapcf"]');
362 }
363 });
364
365 $('#edit-custfields-toggle').on('click', () => {
366 $('#order-summary-custfields').hide();
367 $('#order-summary-custfields-edit').show();
368 });
369
370 $('#edit-custfields-cancel').on('click', () => {
371 $('#order-summary-custfields-edit').hide();
372 $('#order-summary-custfields').show();
373 });
374
375 $('#edit-custfields-submit').on('click', function() {
376 if (!fieldsValidator.validate()) {
377 return false;
378 }
379
380 $(this).prop('disabled', true);
381
382 this.form.method = 'post';
383 this.form.task.value = 'order.updatefields';
384 $(this.form).submit();
385 });
386 });
387 })(jQuery);
388 </script>