PluginProbe ʕ •ᴥ•ʔ
VikAppointments Services Booking Calendar / trunk
VikAppointments Services Booking Calendar vtrunk
1.2.21 1.2.20 trunk 1.2.17 1.2.18 1.2.19
vikappointments / admin / views / orderinfo / view.html.php
vikappointments / admin / views / orderinfo Last commit date
tmpl 15 hours ago index.html 4 years ago view.html.php 2 years ago
view.html.php
120 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 VAPLoader::import('libraries.order.factory');
15
16 /**
17 * VikAppointments order info view.
18 *
19 * @since 1.0
20 * @since 1.7 Renamed from VikAppointmentsViewpurchaserinfo.
21 */
22 class VikAppointmentsVieworderinfo extends JViewVAP
23 {
24 /**
25 * VikAppointments view display method.
26 *
27 * @return void
28 */
29 function display($tpl = null)
30 {
31 $app = JFactory::getApplication();
32 $input = $app->input;
33 $dbo = JFactory::getDbo();
34
35 $oid = $input->get('cid', array(0), 'uint');
36 $back = $input->get('back', '', 'base64');
37
38 if (count($oid) == 1)
39 {
40 $order = null;
41
42 try
43 {
44 /**
45 * Load order details into the current language.
46 *
47 * @since 1.7
48 */
49 $order = VAPOrderFactory::getAppointments($oid[0], JFactory::getLanguage()->getTag());
50 }
51 catch (Exception $e)
52 {
53 /**
54 * Fallback to check if we are looking for a closure.
55 *
56 * @since 1.6
57 */
58
59 $q = $dbo->getQuery(true)
60 ->select($dbo->qn(array('r.id', 'r.checkin_ts', 'r.duration')))
61 ->select($dbo->qn('e.nickname'))
62 ->from($dbo->qn('#__vikappointments_reservation', 'r'))
63 ->leftjoin($dbo->qn('#__vikappointments_employee', 'e') . ' ON ' . $dbo->qn('r.id_employee') . ' = ' . $dbo->qn('e.id'))
64 ->where(array(
65 $dbo->qn('r.id') . ' = ' . $oid[0],
66 $dbo->qn('r.closure') . ' = 1',
67 ));
68
69 $dbo->setQuery($q, 0, 1);
70 $order = $dbo->loadObject();
71
72 if ($order)
73 {
74 // switch template layout
75 $this->setLayout('closure');
76 }
77 else
78 {
79 // order not found, use list layout, which will show
80 // a warning message
81 $this->setLayout('list');
82 }
83 }
84
85 $this->order = $order;
86 }
87 else
88 {
89 $rows = array();
90
91 // iterate specified IDs
92 foreach ($oid as $id)
93 {
94 try
95 {
96 // record order details
97 $order = VAPOrderFactory::getAppointments($id, JFactory::getLanguage()->getTag());
98
99 // join order
100 $rows[] = $order;
101 }
102 catch (Exception $e)
103 {
104 // catch silently and go aeahd
105 }
106 }
107
108 // use list layout
109 $this->setLayout('list');
110
111 $this->rows = $rows;
112 }
113
114 $this->back = $back;
115
116 // display the template
117 parent::display($tpl);
118 }
119 }
120