PluginProbe
VikBooking Hotel Booking Engine & PMS / 1.6.8
VikBooking Hotel Booking Engine & PMS v1.6.8
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 / admin / views / editorder / view.html.php

view.html.php in VikBooking Hotel Booking Engine & PMS 1.6.8, at admin/views/editorder/view.html.php

511 lines 21.5 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 // import Joomla view library
14 jimport('joomla.application.component.view');
15
16 class VikBookingViewEditorder extends JViewVikBooking
17 {
18 public function display($tpl = null)
19 {
20 // Set the toolbar
21 $this->addToolBar();
22
23 if (!JFactory::getUser()->authorise('core.vbo.bookings', 'com_vikbooking')) {
24 VBOHttpDocument::getInstance()->close(403, JText::translate('JERROR_ALERTNOAUTHOR'));
25 }
26
27 $cid = VikRequest::getVar('cid', array(0));
28 $ido = $cid[0];
29
30 if (is_file(VCM_ADMIN_PATH.DIRECTORY_SEPARATOR.'assets'.DIRECTORY_SEPARATOR.'css'.DIRECTORY_SEPARATOR.'vcm-channels.css')) {
31 $document = JFactory::getDocument();
32 $document->addStyleSheet(VCM_ADMIN_URI.'assets/css/vikchannelmanager.css');
33 $document->addStyleSheet(VCM_ADMIN_URI.'assets/css/vcm-channels.css');
34 }
35
36 $dbo = JFactory::getDbo();
37 $app = JFactory::getApplication();
38 $user = JFactory::getUser();
39
40 $q = "SELECT * FROM `#__vikbooking_orders` WHERE `id`=" . $dbo->quote($ido);
41 $dbo->setQuery($q, 0, 1);
42 $row = $dbo->loadAssoc();
43 if (!$row) {
44 $app->redirect("index.php?option=com_vikbooking&task=orders");
45 $app->close();
46 return;
47 }
48
49 /**
50 * Check currency conversion request, if needed and supported.
51 *
52 * @since 1.15.0 (J) - 1.5.0 (WP)
53 */
54 $do_ota_curr_conv = VikRequest::getInt('do_ota_curr_conv', 0, 'request');
55 if ($do_ota_curr_conv) {
56 $ota_helper = new VBOCurrencyOta($row);
57 if (!$ota_helper->convertReservationCurrency()) {
58 VikError::raiseWarning('', 'Something went wrong while trying to convert the OTA currency');
59 }
60 $app->redirect('index.php?option=com_vikbooking&task=editorder&cid[]=' . $row['id']);
61 $app->close();
62 }
63
64 $q = "SELECT `id`,`name` FROM `#__vikbooking_gpayments` ORDER BY `#__vikbooking_gpayments`.`name` ASC;";
65 $dbo->setQuery($q);
66 $payments = $dbo->loadAssocList();
67
68 $cpin = VikBooking::getCPinIstance();
69 // VBO 1.11 - change customer assigned to this booking
70 $pnewcustid = VikRequest::getInt('newcustid', 0, 'request');
71 if (!empty($pnewcustid)) {
72 $cpin->updateCustomerBooking($row['id'], $pnewcustid);
73 // update empty values for the booking
74 if (empty($row['custmail']) || empty($row['phone'])) {
75 // get customer information
76 $customer = $cpin->getCustomerByID($pnewcustid);
77 if ($customer && (!empty($customer['email']) || !empty($customer['phone']))) {
78 if (empty($row['custmail']) && !empty($customer['email'])) {
79 $q = "UPDATE `#__vikbooking_orders` SET `custmail`=" . $dbo->quote($customer['email']) . " WHERE `id`=" . $row['id'] . ";";
80 $dbo->setQuery($q);
81 $dbo->execute();
82 $row['custmail'] = $customer['email'];
83 }
84 if (empty($row['phone']) && !empty($customer['phone'])) {
85 $q = "UPDATE `#__vikbooking_orders` SET `phone`=" . $dbo->quote($customer['phone']) . " WHERE `id`=" . $row['id'] . ";";
86 $dbo->setQuery($q);
87 $dbo->execute();
88 $row['phone'] = $customer['phone'];
89 }
90 }
91 }
92 }
93
94 $customer = $cpin->getCustomerFromBooking($row['id']);
95 if ($customer && !empty($customer['country'])) {
96 if (file_exists(VBO_ADMIN_PATH.DIRECTORY_SEPARATOR.'resources'.DIRECTORY_SEPARATOR.'countries'.DIRECTORY_SEPARATOR.$customer['country'].'.png')) {
97 $customer['country_img'] = '<img src="'.VBO_ADMIN_URI.'resources/countries/'.$customer['country'].'.png'.'" title="'.$customer['country'].'" class="vbo-country-flag vbo-country-flag-left"/>';
98 }
99 }
100
101 $padminnotes = VikRequest::getString('adminnotes', '', 'request');
102 $pupdadmnotes = VikRequest::getString('updadmnotes', '', 'request');
103 $pinvnotes = VikRequest::getString('invnotes', '', 'request', VIKREQUEST_ALLOWHTML);
104 $pupdinvnotes = VikRequest::getString('updinvnotes', '', 'request');
105 $pnewpayment = VikRequest::getString('newpayment', '', 'request');
106 $pnewlang = VikRequest::getString('newlang', '', 'request');
107 $padmindisc = VikRequest::getString('admindisc', '', 'request');
108 $ptot_taxes = VikRequest::getString('tot_taxes', '', 'request');
109 $ptot_city_taxes = VikRequest::getString('tot_city_taxes', '', 'request');
110 $ptot_fees = VikRequest::getString('tot_fees', '', 'request');
111 $pcmms = VikRequest::getString('cmms', '', 'request');
112 $pcustmail = VikRequest::getString('custmail', '', 'request');
113 $pcustphone = VikRequest::getString('custphone', '', 'request');
114 $pmakepay = VikRequest::getInt('makepay', 0, 'request');
115 $pnewamountpaid = VikRequest::getFloat('newamountpaid', -1, 'request');
116 $pnewamountpaymeth = VikRequest::getString('newamountpaymeth', '', 'request');
117 // we update the total paid also if the input is 0.0 (float) as the default value is -1 (int)
118 if (($pnewamountpaid > 0 || ($pnewamountpaid == 0 && is_float($pnewamountpaid))) && (float)$row['totpaid'] != $pnewamountpaid) {
119 $prevpaid = (float)$row['totpaid'];
120 $q = "UPDATE `#__vikbooking_orders` SET `totpaid`=".$dbo->quote($pnewamountpaid)." WHERE `id`=".$row['id'].";";
121 $dbo->setQuery($q);
122 $dbo->execute();
123 $row['totpaid'] = $pnewamountpaid;
124 // Booking History log for new amount paid (payment update)
125 $extra_data = null;
126 $newpaympaytype = '';
127 if ($pnewamountpaid > $prevpaid) {
128 $extra_data = new stdClass;
129 $extra_data->amount_paid = ($pnewamountpaid - $prevpaid);
130 if (!empty($pnewamountpaymeth)) {
131 $payparts = explode('_', $pnewamountpaymeth);
132 $newpaympaytype = count($payparts) > 1 ? $payparts[1] : $pnewamountpaymeth;
133 $extra_data->payment_method = $newpaympaytype;
134 }
135 }
136 VikBooking::getBookingHistoryInstance()->setBid($row['id'])->setExtraData($extra_data)->store('PU', JText::sprintf('VBOPREVAMOUNTPAID', VikBooking::numberFormat($prevpaid) . (!empty($newpaympaytype) ? ' ('.$newpaympaytype.')' : '')));
137 //
138 }
139 $pnewamountrefunded = VikRequest::getFloat('newamountrefunded', -1, 'request');
140 // we update the total refunded also if the input is 0.0 (float) as the default value is -1 (int)
141 if (($pnewamountrefunded > 0 || ($pnewamountrefunded == 0 && is_float($pnewamountrefunded))) && (float)$row['refund'] != $pnewamountrefunded) {
142 $prevrefunded = $row['refund'];
143 $refund_diff = $pnewamountrefunded - $row['refund'];
144 if ($refund_diff > 0) {
145 // refund amount increased, lower the booking total
146 $newtotal = $row['total'] - $refund_diff;
147 // lower also the amount paid
148 $newtotpaid = $row['totpaid'] > 0 ? ($row['totpaid'] - $refund_diff) : $row['totpaid'];
149 } else {
150 // refund amount decreased, increase the booking total
151 $newtotal = $row['total'] + abs($refund_diff);
152 // leave the totpaid unchanged in this case
153 $newtotpaid = $row['totpaid'];
154 }
155 $q = "UPDATE `#__vikbooking_orders` SET `total`=" . $dbo->quote($newtotal) . ", `totpaid`=" . ($newtotpaid == null ? 'NULL' : $dbo->quote($newtotpaid)) . ", `refund`=" . $dbo->quote($pnewamountrefunded) . " WHERE `id`=" . $row['id'] . ";";
156 $dbo->setQuery($q);
157 $dbo->execute();
158 $row['total'] = $newtotal;
159 $row['refund'] = $pnewamountrefunded;
160 // booking history log for new amount refunded
161 VikBooking::getBookingHistoryInstance()->setBid($row['id'])->store('RU', JText::sprintf('VBO_NEWREFUND_AMOUNT', VikBooking::numberFormat($prevrefunded), VikBooking::numberFormat($pnewamountrefunded)));
162 }
163 $pnewamountpayable = VikRequest::getFloat('newamountpayable', -1, 'request');
164 // we update the amount payable also if the input is 0.0 (float) as the default value is -1 (int)
165 if (($pnewamountpayable > 0 || ($pnewamountpayable == 0 && is_float($pnewamountpayable))) && (float)$row['payable'] != $pnewamountpayable) {
166 $q = "UPDATE `#__vikbooking_orders` SET `payable`=" . $dbo->quote($pnewamountpayable) . " WHERE `id`=" . $row['id'] . ";";
167 $dbo->setQuery($q);
168 $dbo->execute();
169 $row['payable'] = $pnewamountpayable;
170 // booking history log for new amount payable
171 VikBooking::getBookingHistoryInstance()->setBid($row['id'])->store('PB', JText::sprintf('VBO_NEWPAYABLE_AMOUNT', VikBooking::numberFormat($pnewamountpayable)));
172 // make sure to update the payment counter, or if no payments ever made, the system won't accept a transaction
173 if (!$row['paymcount']) {
174 // turn flag on
175 $pmakepay = 1;
176 }
177 }
178 if ($pmakepay > 0) {
179 // check if the payment counter should be updated
180 $q = "UPDATE `#__vikbooking_orders` SET `paymcount`=" . $pmakepay . " WHERE `id`=" . $row['id'] . ";";
181 $dbo->setQuery($q);
182 $dbo->execute();
183 $row['paymcount'] = 1;
184 }
185 $pnewcancfee = VikRequest::getFloat('newcancfee', -1, 'request');
186 // we update the cancellation fee amount also if the input is 0.0 (float) as the default value is -1 (int)
187 if (($pnewcancfee > 0 || ($pnewcancfee == 0 && is_float($pnewcancfee))) && (float)$row['canc_fee'] != $pnewcancfee) {
188 $q = "UPDATE `#__vikbooking_orders` SET `canc_fee`=" . $dbo->quote($pnewcancfee) . " WHERE `id`=" . $row['id'] . ";";
189 $dbo->setQuery($q);
190 $dbo->execute();
191 $row['canc_fee'] = $pnewcancfee;
192 // booking history log for new cancellation fee amount
193 VikBooking::getBookingHistoryInstance()->setBid($row['id'])->store('MB', sprintf(JText::translate('VBO_CANC_FEE') . ': %s', VikBooking::numberFormat($pnewcancfee)));
194 }
195 if (!empty($padminnotes) || !empty($pupdadmnotes)) {
196 $q = "UPDATE `#__vikbooking_orders` SET `adminnotes`=".$dbo->quote($padminnotes)." WHERE `id`=".$row['id'].";";
197 $dbo->setQuery($q);
198 $dbo->execute();
199 $row['adminnotes'] = $padminnotes;
200 }
201 if (!empty($pinvnotes) || !empty($pupdinvnotes)) {
202 $pinvnotes = strpos($pinvnotes, '<br') !== false ? $pinvnotes : nl2br($pinvnotes);
203 $q = "UPDATE `#__vikbooking_orders` SET `inv_notes`=".$dbo->quote($pinvnotes)." WHERE `id`=".$row['id'].";";
204 $dbo->setQuery($q);
205 $dbo->execute();
206 $row['inv_notes'] = $pinvnotes;
207 }
208 if (!empty($pnewpayment) && $payments) {
209 foreach ($payments as $npay) {
210 if ((int)$npay['id'] == (int)$pnewpayment) {
211 $newpayvalid = $npay['id'].'='.$npay['name'];
212 $q = "UPDATE `#__vikbooking_orders` SET `idpayment`=".$dbo->quote($newpayvalid)." WHERE `id`=".$row['id'].";";
213 $dbo->setQuery($q);
214 $dbo->execute();
215 $row['idpayment'] = $newpayvalid;
216 break;
217 }
218 }
219 }
220 if (!empty($pnewlang)) {
221 $q = "UPDATE `#__vikbooking_orders` SET `lang`=".$dbo->quote($pnewlang)." WHERE `id`=".$row['id'].";";
222 $dbo->setQuery($q);
223 $dbo->execute();
224 $row['lang'] = $pnewlang;
225 }
226 if (strlen($padmindisc) > 0) {
227 if (floatval($padmindisc) > 0.00) {
228 $admincoupon = '-1;'.floatval($padmindisc).';'.JText::translate('VBADMINDISCOUNT');
229 } else {
230 $admincoupon = '';
231 }
232 $expcoupon = explode(";", $row['coupon']);
233 // make sure the new discount is different than the previous one, and that the total amount is greater than zero
234 if ($row['total'] > 0 && (empty($row['coupon']) || (float)$expcoupon[1] != (float)$padmindisc)) {
235 // re-calculate new total by adding the previous discount and by subtracting the new one
236 $newtotal = $row['total'] + (!empty($row['coupon']) ? (float)$expcoupon[1] : 0);
237 $newtotal -= (float)$padmindisc;
238 //
239 $q = "UPDATE `#__vikbooking_orders` SET `coupon`=" . $dbo->quote($admincoupon) . ", `total`=" . $dbo->quote($newtotal) . " WHERE `id`={$row['id']};";
240 $dbo->setQuery($q);
241 $dbo->execute();
242 $row['coupon'] = $admincoupon;
243 $row['total'] = $newtotal;
244 }
245 }
246 if (strlen($ptot_taxes) > 0) {
247 $q = "UPDATE `#__vikbooking_orders` SET `tot_taxes`='".floatval($ptot_taxes)."' WHERE `id`=".$row['id'].";";
248 $dbo->setQuery($q);
249 $dbo->execute();
250 $row['tot_taxes'] = $ptot_taxes;
251 }
252 if (strlen($ptot_city_taxes) > 0) {
253 $q = "UPDATE `#__vikbooking_orders` SET `tot_city_taxes`='".floatval($ptot_city_taxes)."' WHERE `id`=".$row['id'].";";
254 $dbo->setQuery($q);
255 $dbo->execute();
256 $row['tot_city_taxes'] = $ptot_city_taxes;
257 }
258 if (strlen($ptot_fees) > 0) {
259 $q = "UPDATE `#__vikbooking_orders` SET `tot_fees`='".floatval($ptot_fees)."' WHERE `id`=".$row['id'].";";
260 $dbo->setQuery($q);
261 $dbo->execute();
262 $row['tot_fees'] = $ptot_fees;
263 }
264 if (strlen($pcmms) > 0) {
265 $q = "UPDATE `#__vikbooking_orders` SET `cmms`='".floatval($pcmms)."' WHERE `id`=".$row['id'].";";
266 $dbo->setQuery($q);
267 $dbo->execute();
268 $row['cmms'] = $pcmms;
269 }
270 if (strlen($pcustmail) > 0) {
271 $q = "UPDATE `#__vikbooking_orders` SET `custmail`=".$dbo->quote($pcustmail)." WHERE `id`=".$row['id'].";";
272 $dbo->setQuery($q);
273 $dbo->execute();
274 $row['custmail'] = $pcustmail;
275 }
276 if (strlen($pcustphone) > 0) {
277 $q = "UPDATE `#__vikbooking_orders` SET `phone`=".$dbo->quote($pcustphone)." WHERE `id`=".$row['id'].";";
278 $dbo->setQuery($q);
279 $dbo->execute();
280 $row['phone'] = $pcustphone;
281 }
282
283 /**
284 * Vik Channel Manager booking assignable channels.
285 *
286 * @since 1.16.3 (J) - 1.6.3 (WP)
287 */
288 $vcm_assign_channel = VikRequest::getString('vcm_assign_channel', '', 'request');
289 if (!empty($vcm_assign_channel) && class_exists('VCMOtaBooking')) {
290 // current unix timestamp will be used in place of OTA Reservation ID
291 $set_ota_bid = time();
292
293 // update fields on db
294 $q = "UPDATE `#__vikbooking_orders` SET `idorderota`=" . $dbo->quote($set_ota_bid) . ", `channel`=" . $dbo->quote($vcm_assign_channel) . " WHERE `id`=" . $row['id'] . ";";
295 $dbo->setQuery($q);
296 $dbo->execute();
297
298 // overwrite booking properties
299 $row['idorderota'] = $set_ota_bid;
300 $row['channel'] = $vcm_assign_channel;
301
302 // update booking history
303 $user = JFactory::getUser();
304 VikBooking::getBookingHistoryInstance()->setBid($row['id'])->store('CM', "({$user->name}) " . JText::sprintf('VBO_BOOKING_OTA_ASSIGNED', $vcm_assign_channel));
305 }
306
307 // load data
308 $q = "SELECT `or`.*,`r`.`name`,`r`.`fromadult`,`r`.`toadult`,`r`.`params` FROM `#__vikbooking_ordersrooms` AS `or`,`#__vikbooking_rooms` AS `r` WHERE `or`.`idorder`=".(int)$row['id']." AND `or`.`idroom`=`r`.`id` ORDER BY `or`.`id` ASC;";
309 $dbo->setQuery($q);
310 $rooms = $dbo->loadAssocList();
311 $q = "SELECT * FROM `#__vikbooking_ordersbusy` WHERE `idorder`=".(int)$row['id'].";";
312 $dbo->setQuery($q);
313 $busy = $dbo->loadAssocList();
314
315 // Rooms Specific Unit
316 $proomindex = VikRequest::getVar('roomindex', array());
317 if (!empty($proomindex) && is_array($proomindex) && count($proomindex)) {
318 $orig_rooms = $rooms;
319 foreach ($proomindex as $or_id => $rind) {
320 if (empty($or_id)) {
321 continue;
322 }
323 $q = "UPDATE `#__vikbooking_ordersrooms` SET `roomindex`=".(!empty($rind) ? (int)$rind : "NULL")." WHERE `id`=".(int)$or_id." AND `idorder`=".(int)$row['id'].";";
324 $dbo->setQuery($q);
325 $dbo->execute();
326 // update global array reference
327 $sub_unit_changed = false;
328 foreach ($rooms as $korr => $orr) {
329 if ((int)$or_id == (int)$orr['id']) {
330 $sub_unit_changed = ((string)$orr['roomindex'] != (string)$rind);
331 $rooms[$korr]['roomindex'] = $rind;
332 break;
333 }
334 }
335 if (!$sub_unit_changed) {
336 // no need to store a booking history record
337 continue;
338 }
339 // try to store a booking history record when switching room sub-unit index
340 if (!empty($rind)) {
341 foreach ($orig_rooms as $korr => $orr) {
342 if ((int)$or_id != (int)$orr['id']) {
343 continue;
344 }
345 if (empty($orr['params'])) {
346 continue;
347 }
348 $room_params = json_decode($orr['params'], true);
349 if (is_array($room_params) && !empty($room_params['features'])) {
350 $prev_subindex = empty($orr['roomindex']) ? '---' : $orr['roomindex'];
351 $new_subindex = $rind;
352 foreach ($room_params['features'] as $origrind => $rfeatures) {
353 if ($orr['roomindex'] == $origrind) {
354 foreach ($rfeatures as $fname => $fval) {
355 if (strlen($fval)) {
356 $prev_subindex = '#' . $origrind . ' - ' . JText::translate($fname) . ': ' . $fval;
357 break;
358 }
359 }
360 }
361 if ($rind == $origrind) {
362 foreach ($rfeatures as $fname => $fval) {
363 if (strlen($fval)) {
364 $new_subindex = '#' . $origrind . ' - ' . JText::translate($fname) . ': ' . $fval;
365 break;
366 }
367 }
368 }
369 }
370 //Booking History
371 VikBooking::getBookingHistoryInstance()->setBid($row['id'])->store('MB', "({$user->name}) " . JText::sprintf('VBOROOMSUBUNITCHANGEFT', $orr['name'], $prev_subindex, $new_subindex));
372 //
373 }
374 }
375 }
376 }
377 }
378
379 // PCI DSS Checking
380 if (!empty($row['idorderota']) && !empty($row['channel']) && !empty($row['paymentlog'])) {
381 if (stripos($row['paymentlog'], 'card number') !== false && strpos($row['paymentlog'], '*') !== false) {
382 $checkout_info = getdate($row['checkout']);
383 /**
384 * Limit for accessing the credit card details has been changed to check-out
385 * day at 23:59:59 + 10 extra days. It used to be at 23:59:59 on check-out day.
386 *
387 * @since 1.13
388 */
389 $cardlimit = mktime(23, 59, 59, $checkout_info['mon'], ($checkout_info['mday'] + 10), $checkout_info['year']);
390 if (time() > $cardlimit) {
391 $newlogstr = JText::translate('VBOCCLOGDATAREMOVEDPCIDSS');
392 $q = "UPDATE `#__vikbooking_orders` SET `paymentlog`=".$dbo->quote($newlogstr)." WHERE `id`=".$row['id'].";";
393 $dbo->setQuery($q);
394 $dbo->execute();
395 $row['paymentlog'] = $newlogstr;
396 }
397 }
398 }
399
400 // unset credit card details, if needed, maybe to re-collect them
401 $unset_cc = VikRequest::getInt('unset_cc', 0, 'request');
402 if ($unset_cc && empty($row['idorderota']) && !empty($row['paymentlog'])) {
403 $q = "UPDATE `#__vikbooking_orders` SET `paymentlog` = NULL WHERE `id` = " . $row['id'] . ";";
404 $dbo->setQuery($q);
405 $dbo->execute();
406 $row['paymentlog'] = null;
407 }
408
409 // detect if VCM exists
410 $vcm_exists = is_file(VCM_SITE_PATH . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'lib.vikchannelmanager.php');
411
412 // attempt to get the VCM review ID with a try-catch to avoid SQL errors
413 $vcm_review = array();
414 if ($vcm_exists) {
415 try {
416 $q = "SELECT * FROM `#__vikchannelmanager_otareviews` WHERE `idorder`=" . (int)$row['id'] . ";";
417 $dbo->setQuery($q);
418 $dbo->execute();
419 if ($dbo->getNumRows()) {
420 $vcm_review = $dbo->loadAssoc();
421 }
422 } catch (Exception $e) {
423 // do nothing as VCM is probably not available/enabled/updated
424 }
425 }
426
427 /**
428 * Check if the reservation requires/supports additional actions.
429 *
430 * @since 1.14 (J) - 1.4.0 (WP)
431 */
432 $vcm_decline_actions = 0;
433 $vcm_pre_approval = 0;
434 $vcm_special_offer = 0;
435 $vcm_host_to_guest_review = 0;
436 $vcm_cancel_active_res = 0;
437 if ($vcm_exists) {
438 try {
439 require_once VCM_SITE_PATH . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'lib.vikchannelmanager.php';
440 if (method_exists('VikChannelManager', 'reservationNeedsDeclineReasons')) {
441 $vcm_decline_actions = (int)VikChannelManager::reservationNeedsDeclineReasons($row);
442 }
443 if (method_exists('VikChannelManager', 'reservationSupportsPreApproval')) {
444 $vcm_pre_approval = VikChannelManager::reservationSupportsPreApproval($row);
445 $vcm_pre_approval = $vcm_pre_approval === false ? 0 : $vcm_pre_approval;
446 }
447 if (method_exists('VikChannelManager', 'reservationSupportsSpecialOffer')) {
448 $vcm_special_offer = VikChannelManager::reservationSupportsSpecialOffer($row);
449 $vcm_special_offer = $vcm_special_offer === false ? 0 : $vcm_special_offer;
450 }
451 if (method_exists('VikChannelManager', 'hostToGuestReviewSupported')) {
452 $vcm_host_to_guest_review = VikChannelManager::hostToGuestReviewSupported($row);
453 $vcm_host_to_guest_review = $vcm_host_to_guest_review === false ? 0 : $vcm_host_to_guest_review;
454 }
455 if (method_exists('VikChannelManager', 'cancelActiveOtaReservation')) {
456 $vcm_cancel_active_res = (int)VikChannelManager::cancelActiveOtaReservation($row);
457 }
458 } catch (Exception $e) {
459 // do nothing as VCM is probably not available/enabled/updated
460 }
461 }
462
463 /**
464 * Build currency conversion details, if needed and supported.
465 *
466 * @since 1.15.0 (J) - 1.5.0 (WP)
467 */
468 $ota_helper = new VBOCurrencyOta($row);
469 $allows_conversion = $ota_helper->supportsConversion($row['total']);
470 $conv_from_currency = $allows_conversion !== false ? $ota_helper->getOTACurrency() : null;
471 $conv_to_currency = $allows_conversion !== false ? $ota_helper->getCurrencyName() : null;
472
473 $this->row = $row;
474 $this->rooms = $rooms;
475 $this->busy = $busy;
476 $this->customer = $customer;
477 $this->payments = $payments;
478 $this->vcm_review = $vcm_review;
479 $this->vcm_decline_actions = $vcm_decline_actions;
480 $this->vcm_pre_approval = $vcm_pre_approval;
481 $this->vcm_special_offer = $vcm_special_offer;
482 $this->vcm_host_to_guest_review = $vcm_host_to_guest_review;
483 $this->vcm_cancel_active_res = $vcm_cancel_active_res;
484 $this->allows_conversion = $allows_conversion;
485 $this->conv_from_currency = $conv_from_currency;
486 $this->conv_to_currency = $conv_to_currency;
487
488 // Display the template
489 parent::display($tpl);
490 }
491
492 /**
493 * Sets the toolbar
494 */
495 protected function addToolBar() {
496 $printreceipt = VikRequest::getInt('print', 0, 'request');
497 if ($printreceipt) {
498 // do not print any header or buttons if we are printing the receipt
499 return;
500 }
501
502 JToolBarHelper::title(JText::translate('VBMAINORDERTITLEEDIT'), 'vikbooking');
503 JToolBarHelper::cancel( 'canceledorder', JText::translate('VBBACK'));
504 JToolBarHelper::spacer();
505 JToolBarHelper::custom( 'prev_booking', 'backward', 'backward', JText::translate('VBJQCALPREV'), false);
506 JToolBarHelper::spacer();
507 JToolBarHelper::custom( 'next_booking', 'forward', 'forward', JText::translate('VBJQCALNEXT'), false);
508 JToolBarHelper::spacer();
509 }
510 }
511