PluginProbe
VikBooking Hotel Booking Engine & PMS / 1.6.6
VikBooking Hotel Booking Engine & PMS v1.6.6
1.8.16 1.8.15 1.8.14 1.8.13 1.8.12 1.8.11 1.8.10 1.8.9 1.8.6 1.8.7 1.8.8 trunk 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 All 37 releases
vikbooking / site / views / tableaux / view.html.php

view.html.php in VikBooking Hotel Booking Engine & PMS 1.6.6, at site/views/tableaux/view.html.php

176 lines 6.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package VikBooking
4 * @subpackage com_vikbooking
5 * @author Alessio Gaggii - e4j - Extensionsforjoomla.com
6 * @copyright Copyright (C) 2018 e4j - Extensionsforjoomla.com. All rights reserved.
7 * @license GNU General Public License version 2 or later; see LICENSE
8 * @link https://vikwp.com
9 */
10
11 defined('ABSPATH') or die('No script kiddies please!');
12
13 jimport('joomla.application.component.view');
14
15 class VikbookingViewTableaux extends JViewVikBooking
16 {
17 function display($tpl = null)
18 {
19 //set noindex instruction for robots
20 $document = JFactory::getDocument();
21 $document->setMetaData('robots', 'noindex,follow');
22 //
23 $app = JFactory::getApplication();
24 $dbo = JFactory::getDbo();
25 $opobj = VikBooking::getOperatorInstance();
26
27 $operator = $opobj->getOperatorAccount();
28 if ($operator === false) {
29 // operator needs to log in
30 $pitemid = VikRequest::getInt('Itemid', '', 'request');
31 $app->redirect(JRoute::rewrite('index.php?option=com_vikbooking&view=operators'.(!empty($pitemid) ? '&Itemid='.$pitemid : ''), false));
32 exit;
33 }
34
35 // check permissions for tableaux
36 if (!$opobj->checkPermissions($operator, 'tableaux')) {
37 // operator is not authorized
38 VikError::raiseWarning('', JText::translate('VBONOTAUTHORIZEDRES'));
39 $pitemid = VikRequest::getInt('Itemid', '', 'request');
40 $app->redirect(JRoute::rewrite('index.php?option=com_vikbooking&view=operators'.(!empty($pitemid) ? '&Itemid='.$pitemid : ''), false));
41 exit;
42 }
43
44 // prepare tableaux data
45 $tsinfo = getdate();
46 $fromts = mktime(0, 0, 0, $tsinfo['mon'], $tsinfo['mday'], $tsinfo['year']);
47 $tots = mktime(23, 59, 59, $tsinfo['mon'], ($tsinfo['mday'] + $operator['perms']['days']), $tsinfo['year']);
48
49 $roomids = $operator['perms']['rooms'];
50 if (count($roomids) && empty($roomids[0])) {
51 $roomids = array();
52 }
53
54 // get all rooms enabled for the operator
55 $rooms = array();
56 $q = "SELECT `id`,`name`,`units`,`params` FROM `#__vikbooking_rooms`".(count($roomids) ? " WHERE `id` IN (".implode(', ', $roomids).")" : "")." ORDER BY `name` ASC;";
57 $dbo->setQuery($q);
58 $dbo->execute();
59 if ($dbo->getNumRows()) {
60 $all = $dbo->loadAssocList();
61 foreach ($all as $r) {
62 $rooms[$r['id']] = $r;
63 }
64 }
65 if (!count($rooms)) {
66 VikError::raiseWarning('', JText::translate('VBONOTAUTHORIZEDRES').' (#2)');
67 $pitemid = VikRequest::getInt('Itemid', '', 'request');
68 $app->redirect(JRoute::rewrite('index.php?option=com_vikbooking&view=operators'.(!empty($pitemid) ? '&Itemid='.$pitemid : ''), false));
69 exit;
70 }
71
72 // get all occupied dates for these rooms
73 $rooms_busy = array();
74 $q = "SELECT `b`.*,`ob`.`idorder`,`o`.`custdata`,`o`.`status`,`o`.`country`,`oc`.`idcustomer`,`c`.`first_name`,`c`.`last_name`,
75 (SELECT GROUP_CONCAT(`or`.`roomindex` SEPARATOR ';') FROM `#__vikbooking_ordersrooms` AS `or` WHERE `or`.`idorder`=`ob`.`idorder`) AS `indexes`,
76 (SELECT GROUP_CONCAT(`or`.`adults` SEPARATOR ';') FROM `#__vikbooking_ordersrooms` AS `or` WHERE `or`.`idorder`=`ob`.`idorder`) AS `adults`,
77 (SELECT GROUP_CONCAT(`or`.`children` SEPARATOR ';') FROM `#__vikbooking_ordersrooms` AS `or` WHERE `or`.`idorder`=`ob`.`idorder`) AS `children`,
78 (SELECT GROUP_CONCAT(`or`.`pets` SEPARATOR ';') FROM `#__vikbooking_ordersrooms` AS `or` WHERE `or`.`idorder`=`ob`.`idorder`) AS `pets`,
79 (SELECT GROUP_CONCAT(`or`.`t_first_name` SEPARATOR ';') FROM `#__vikbooking_ordersrooms` AS `or` WHERE `or`.`idorder`=`ob`.`idorder`) AS `tnames`,
80 (SELECT GROUP_CONCAT(`or`.`t_last_name` SEPARATOR ';') FROM `#__vikbooking_ordersrooms` AS `or` WHERE `or`.`idorder`=`ob`.`idorder`) AS `tlnames`,
81 (SELECT GROUP_CONCAT(`or`.`optionals` SEPARATOR '__') FROM `#__vikbooking_ordersrooms` AS `or` WHERE `or`.`idorder`=`ob`.`idorder`) AS `roptions`,
82 (SELECT GROUP_CONCAT(`or`.`extracosts` SEPARATOR '__') FROM `#__vikbooking_ordersrooms` AS `or` WHERE `or`.`idorder`=`ob`.`idorder`) AS `rextras`,
83 (SELECT GROUP_CONCAT(`or`.`idtar` SEPARATOR '__') FROM `#__vikbooking_ordersrooms` AS `or` WHERE `or`.`idorder`=`ob`.`idorder`) AS `ridtars`,
84 (SELECT GROUP_CONCAT(`or`.`otarplan` SEPARATOR '__') FROM `#__vikbooking_ordersrooms` AS `or` WHERE `or`.`idorder`=`ob`.`idorder`) AS `rotarplans`
85 FROM `#__vikbooking_busy` AS `b`
86 LEFT JOIN `#__vikbooking_ordersbusy` AS `ob` ON `b`.`id`=`ob`.`idbusy`
87 LEFT JOIN `#__vikbooking_orders` AS `o` ON `ob`.`idorder`=`o`.`id`
88 LEFT JOIN `#__vikbooking_customers_orders` AS `oc` ON `ob`.`idorder`=`oc`.`idorder`
89 LEFT JOIN `#__vikbooking_customers` AS `c` ON `oc`.`idcustomer`=`c`.`id`
90 WHERE `b`.`idroom` IN (".implode(', ', array_keys($rooms)).") AND (`b`.`checkin`>=".$fromts." OR `b`.`checkout`>=".$fromts.") AND (`b`.`checkin`<=".$tots." OR `b`.`checkout`<=".$fromts.") AND `o`.`status`='confirmed' AND `o`.`closure`=0
91 ORDER BY `b`.`checkin` ASC, `ob`.`idorder` ASC;";
92 $dbo->setQuery($q);
93 $dbo->execute();
94 if ($dbo->getNumRows()) {
95 $busy = $dbo->loadAssocList();
96 foreach ($busy as $b) {
97 if (!isset($rooms_busy[$b['idroom']])) {
98 $rooms_busy[$b['idroom']] = array();
99 }
100 array_push($rooms_busy[$b['idroom']], $b);
101 }
102 }
103
104 /**
105 * Check the next festivities periodically
106 *
107 * @since 1.13.5
108 */
109 $fests = VikBooking::getFestivitiesInstance();
110 if ($fests->shouldCheckFestivities()) {
111 $fests->storeNextFestivities();
112 }
113 $festivities = $fests->loadFestDates(date('Y-m-d', $fromts), date('Y-m-d', $tots));
114
115 /**
116 * Load room day notes from first month
117 *
118 * @since 1.13.5
119 */
120 $rdaynotes = VikBooking::getCriticalDatesInstance()->loadRoomDayNotes(date('Y-m-d', $fromts), date('Y-m-d', $tots));
121
122 // load all options
123 $all_options = [];
124 $q = "SELECT * FROM `#__vikbooking_optionals` WHERE `forcesel`=0 AND `is_citytax`=0 AND `is_fee`=0;";
125 $dbo->setQuery($q);
126 $dbo->execute();
127 if ($dbo->getNumRows()) {
128 $records = $dbo->loadAssocList();
129 foreach ($records as $opt) {
130 $all_options[$opt['id']] = $opt;
131 }
132 }
133
134 $this->operator = $operator;
135 $this->rooms = $rooms;
136 $this->rooms_busy = $rooms_busy;
137 $this->fromts = $fromts;
138 $this->tots = $tots;
139 $this->festivities = $festivities;
140 $this->rdaynotes = $rdaynotes;
141 $this->all_options = $all_options;
142
143 parent::display($tpl);
144 }
145
146 /**
147 * Gets the rate plan name from the given tariff ID.
148 *
149 * @param int $idtar the tariff id.
150 *
151 * @return null|string the rate plan name or null.
152 */
153 public function getRatePlanFromTariff($idtar)
154 {
155 $idtar = (int)$idtar;
156 if (empty($idtar)) {
157 return null;
158 }
159
160 $dbo = JFactory::getDbo();
161
162 $q = "SELECT `d`.`idprice`, `p`.`name`
163 FROM `#__vikbooking_dispcost` AS `d`
164 LEFT JOIN `#__vikbooking_prices` AS `p` ON `d`.`idprice`=`p`.`id`
165 WHERE `d`.`id`={$idtar} AND `p`.`name` IS NOT NULL";
166 $dbo->setQuery($q, 0, 1);
167 $dbo->execute();
168 if (!$dbo->getNumRows()) {
169 return null;
170 }
171 $record = $dbo->loadAssoc();
172
173 return $record['name'];
174 }
175 }
176