PluginProbe
VikBooking Hotel Booking Engine & PMS / 1.6.9
VikBooking Hotel Booking Engine & PMS v1.6.9
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.9, at admin/views/editorder/view.html.php

515 lines 21.6 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($row['id'])
162 ->setExtraData([
163 'amount_paid' => ($pnewamountrefunded - $prevrefunded),
164 ])
165 ->store('RU', JText::sprintf('VBO_NEWREFUND_AMOUNT', VikBooking::numberFormat($prevrefunded), VikBooking::numberFormat($pnewamountrefunded)));
166 }
167 $pnewamountpayable = VikRequest::getFloat('newamountpayable', -1, 'request');
168 // we update the amount payable also if the input is 0.0 (float) as the default value is -1 (int)
169 if (($pnewamountpayable > 0 || ($pnewamountpayable == 0 && is_float($pnewamountpayable))) && (float)$row['payable'] != $pnewamountpayable) {
170 $q = "UPDATE `#__vikbooking_orders` SET `payable`=" . $dbo->quote($pnewamountpayable) . " WHERE `id`=" . $row['id'] . ";";
171 $dbo->setQuery($q);
172 $dbo->execute();
173 $row['payable'] = $pnewamountpayable;
174 // booking history log for new amount payable
175 VikBooking::getBookingHistoryInstance()->setBid($row['id'])->store('PB', JText::sprintf('VBO_NEWPAYABLE_AMOUNT', VikBooking::numberFormat($pnewamountpayable)));
176 // make sure to update the payment counter, or if no payments ever made, the system won't accept a transaction
177 if (!$row['paymcount']) {
178 // turn flag on
179 $pmakepay = 1;
180 }
181 }
182 if ($pmakepay > 0) {
183 // check if the payment counter should be updated
184 $q = "UPDATE `#__vikbooking_orders` SET `paymcount`=" . $pmakepay . " WHERE `id`=" . $row['id'] . ";";
185 $dbo->setQuery($q);
186 $dbo->execute();
187 $row['paymcount'] = 1;
188 }
189 $pnewcancfee = VikRequest::getFloat('newcancfee', -1, 'request');
190 // we update the cancellation fee amount also if the input is 0.0 (float) as the default value is -1 (int)
191 if (($pnewcancfee > 0 || ($pnewcancfee == 0 && is_float($pnewcancfee))) && (float)$row['canc_fee'] != $pnewcancfee) {
192 $q = "UPDATE `#__vikbooking_orders` SET `canc_fee`=" . $dbo->quote($pnewcancfee) . " WHERE `id`=" . $row['id'] . ";";
193 $dbo->setQuery($q);
194 $dbo->execute();
195 $row['canc_fee'] = $pnewcancfee;
196 // booking history log for new cancellation fee amount
197 VikBooking::getBookingHistoryInstance()->setBid($row['id'])->store('MB', sprintf(JText::translate('VBO_CANC_FEE') . ': %s', VikBooking::numberFormat($pnewcancfee)));
198 }
199 if (!empty($padminnotes) || !empty($pupdadmnotes)) {
200 $q = "UPDATE `#__vikbooking_orders` SET `adminnotes`=".$dbo->quote($padminnotes)." WHERE `id`=".$row['id'].";";
201 $dbo->setQuery($q);
202 $dbo->execute();
203 $row['adminnotes'] = $padminnotes;
204 }
205 if (!empty($pinvnotes) || !empty($pupdinvnotes)) {
206 $pinvnotes = strpos($pinvnotes, '<br') !== false ? $pinvnotes : nl2br($pinvnotes);
207 $q = "UPDATE `#__vikbooking_orders` SET `inv_notes`=".$dbo->quote($pinvnotes)." WHERE `id`=".$row['id'].";";
208 $dbo->setQuery($q);
209 $dbo->execute();
210 $row['inv_notes'] = $pinvnotes;
211 }
212 if (!empty($pnewpayment) && $payments) {
213 foreach ($payments as $npay) {
214 if ((int)$npay['id'] == (int)$pnewpayment) {
215 $newpayvalid = $npay['id'].'='.$npay['name'];
216 $q = "UPDATE `#__vikbooking_orders` SET `idpayment`=".$dbo->quote($newpayvalid)." WHERE `id`=".$row['id'].";";
217 $dbo->setQuery($q);
218 $dbo->execute();
219 $row['idpayment'] = $newpayvalid;
220 break;
221 }
222 }
223 }
224 if (!empty($pnewlang)) {
225 $q = "UPDATE `#__vikbooking_orders` SET `lang`=".$dbo->quote($pnewlang)." WHERE `id`=".$row['id'].";";
226 $dbo->setQuery($q);
227 $dbo->execute();
228 $row['lang'] = $pnewlang;
229 }
230 if (strlen($padmindisc) > 0) {
231 if (floatval($padmindisc) > 0.00) {
232 $admincoupon = '-1;'.floatval($padmindisc).';'.JText::translate('VBADMINDISCOUNT');
233 } else {
234 $admincoupon = '';
235 }
236 $expcoupon = explode(";", $row['coupon']);
237 // make sure the new discount is different than the previous one, and that the total amount is greater than zero
238 if ($row['total'] > 0 && (empty($row['coupon']) || (float)$expcoupon[1] != (float)$padmindisc)) {
239 // re-calculate new total by adding the previous discount and by subtracting the new one
240 $newtotal = $row['total'] + (!empty($row['coupon']) ? (float)$expcoupon[1] : 0);
241 $newtotal -= (float)$padmindisc;
242 //
243 $q = "UPDATE `#__vikbooking_orders` SET `coupon`=" . $dbo->quote($admincoupon) . ", `total`=" . $dbo->quote($newtotal) . " WHERE `id`={$row['id']};";
244 $dbo->setQuery($q);
245 $dbo->execute();
246 $row['coupon'] = $admincoupon;
247 $row['total'] = $newtotal;
248 }
249 }
250 if (strlen($ptot_taxes) > 0) {
251 $q = "UPDATE `#__vikbooking_orders` SET `tot_taxes`='".floatval($ptot_taxes)."' WHERE `id`=".$row['id'].";";
252 $dbo->setQuery($q);
253 $dbo->execute();
254 $row['tot_taxes'] = $ptot_taxes;
255 }
256 if (strlen($ptot_city_taxes) > 0) {
257 $q = "UPDATE `#__vikbooking_orders` SET `tot_city_taxes`='".floatval($ptot_city_taxes)."' WHERE `id`=".$row['id'].";";
258 $dbo->setQuery($q);
259 $dbo->execute();
260 $row['tot_city_taxes'] = $ptot_city_taxes;
261 }
262 if (strlen($ptot_fees) > 0) {
263 $q = "UPDATE `#__vikbooking_orders` SET `tot_fees`='".floatval($ptot_fees)."' WHERE `id`=".$row['id'].";";
264 $dbo->setQuery($q);
265 $dbo->execute();
266 $row['tot_fees'] = $ptot_fees;
267 }
268 if (strlen($pcmms) > 0) {
269 $q = "UPDATE `#__vikbooking_orders` SET `cmms`='".floatval($pcmms)."' WHERE `id`=".$row['id'].";";
270 $dbo->setQuery($q);
271 $dbo->execute();
272 $row['cmms'] = $pcmms;
273 }
274 if (strlen($pcustmail) > 0) {
275 $q = "UPDATE `#__vikbooking_orders` SET `custmail`=".$dbo->quote($pcustmail)." WHERE `id`=".$row['id'].";";
276 $dbo->setQuery($q);
277 $dbo->execute();
278 $row['custmail'] = $pcustmail;
279 }
280 if (strlen($pcustphone) > 0) {
281 $q = "UPDATE `#__vikbooking_orders` SET `phone`=".$dbo->quote($pcustphone)." WHERE `id`=".$row['id'].";";
282 $dbo->setQuery($q);
283 $dbo->execute();
284 $row['phone'] = $pcustphone;
285 }
286
287 /**
288 * Vik Channel Manager booking assignable channels.
289 *
290 * @since 1.16.3 (J) - 1.6.3 (WP)
291 */
292 $vcm_assign_channel = VikRequest::getString('vcm_assign_channel', '', 'request');
293 if (!empty($vcm_assign_channel) && class_exists('VCMOtaBooking')) {
294 // current unix timestamp will be used in place of OTA Reservation ID
295 $set_ota_bid = time();
296
297 // update fields on db
298 $q = "UPDATE `#__vikbooking_orders` SET `idorderota`=" . $dbo->quote($set_ota_bid) . ", `channel`=" . $dbo->quote($vcm_assign_channel) . " WHERE `id`=" . $row['id'] . ";";
299 $dbo->setQuery($q);
300 $dbo->execute();
301
302 // overwrite booking properties
303 $row['idorderota'] = $set_ota_bid;
304 $row['channel'] = $vcm_assign_channel;
305
306 // update booking history
307 $user = JFactory::getUser();
308 VikBooking::getBookingHistoryInstance()->setBid($row['id'])->store('CM', "({$user->name}) " . JText::sprintf('VBO_BOOKING_OTA_ASSIGNED', $vcm_assign_channel));
309 }
310
311 // load data
312 $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;";
313 $dbo->setQuery($q);
314 $rooms = $dbo->loadAssocList();
315 $q = "SELECT * FROM `#__vikbooking_ordersbusy` WHERE `idorder`=".(int)$row['id'].";";
316 $dbo->setQuery($q);
317 $busy = $dbo->loadAssocList();
318
319 // Rooms Specific Unit
320 $proomindex = VikRequest::getVar('roomindex', array());
321 if (!empty($proomindex) && is_array($proomindex) && count($proomindex)) {
322 $orig_rooms = $rooms;
323 foreach ($proomindex as $or_id => $rind) {
324 if (empty($or_id)) {
325 continue;
326 }
327 $q = "UPDATE `#__vikbooking_ordersrooms` SET `roomindex`=".(!empty($rind) ? (int)$rind : "NULL")." WHERE `id`=".(int)$or_id." AND `idorder`=".(int)$row['id'].";";
328 $dbo->setQuery($q);
329 $dbo->execute();
330 // update global array reference
331 $sub_unit_changed = false;
332 foreach ($rooms as $korr => $orr) {
333 if ((int)$or_id == (int)$orr['id']) {
334 $sub_unit_changed = ((string)$orr['roomindex'] != (string)$rind);
335 $rooms[$korr]['roomindex'] = $rind;
336 break;
337 }
338 }
339 if (!$sub_unit_changed) {
340 // no need to store a booking history record
341 continue;
342 }
343 // try to store a booking history record when switching room sub-unit index
344 if (!empty($rind)) {
345 foreach ($orig_rooms as $korr => $orr) {
346 if ((int)$or_id != (int)$orr['id']) {
347 continue;
348 }
349 if (empty($orr['params'])) {
350 continue;
351 }
352 $room_params = json_decode($orr['params'], true);
353 if (is_array($room_params) && !empty($room_params['features'])) {
354 $prev_subindex = empty($orr['roomindex']) ? '---' : $orr['roomindex'];
355 $new_subindex = $rind;
356 foreach ($room_params['features'] as $origrind => $rfeatures) {
357 if ($orr['roomindex'] == $origrind) {
358 foreach ($rfeatures as $fname => $fval) {
359 if (strlen($fval)) {
360 $prev_subindex = '#' . $origrind . ' - ' . JText::translate($fname) . ': ' . $fval;
361 break;
362 }
363 }
364 }
365 if ($rind == $origrind) {
366 foreach ($rfeatures as $fname => $fval) {
367 if (strlen($fval)) {
368 $new_subindex = '#' . $origrind . ' - ' . JText::translate($fname) . ': ' . $fval;
369 break;
370 }
371 }
372 }
373 }
374 //Booking History
375 VikBooking::getBookingHistoryInstance()->setBid($row['id'])->store('MB', "({$user->name}) " . JText::sprintf('VBOROOMSUBUNITCHANGEFT', $orr['name'], $prev_subindex, $new_subindex));
376 //
377 }
378 }
379 }
380 }
381 }
382
383 // PCI DSS Checking
384 if (!empty($row['idorderota']) && !empty($row['channel']) && !empty($row['paymentlog'])) {
385 if (stripos($row['paymentlog'], 'card number') !== false && strpos($row['paymentlog'], '*') !== false) {
386 $checkout_info = getdate($row['checkout']);
387 /**
388 * Limit for accessing the credit card details has been changed to check-out
389 * day at 23:59:59 + 10 extra days. It used to be at 23:59:59 on check-out day.
390 *
391 * @since 1.13
392 */
393 $cardlimit = mktime(23, 59, 59, $checkout_info['mon'], ($checkout_info['mday'] + 10), $checkout_info['year']);
394 if (time() > $cardlimit) {
395 $newlogstr = JText::translate('VBOCCLOGDATAREMOVEDPCIDSS');
396 $q = "UPDATE `#__vikbooking_orders` SET `paymentlog`=".$dbo->quote($newlogstr)." WHERE `id`=".$row['id'].";";
397 $dbo->setQuery($q);
398 $dbo->execute();
399 $row['paymentlog'] = $newlogstr;
400 }
401 }
402 }
403
404 // unset credit card details, if needed, maybe to re-collect them
405 $unset_cc = VikRequest::getInt('unset_cc', 0, 'request');
406 if ($unset_cc && empty($row['idorderota']) && !empty($row['paymentlog'])) {
407 $q = "UPDATE `#__vikbooking_orders` SET `paymentlog` = NULL WHERE `id` = " . $row['id'] . ";";
408 $dbo->setQuery($q);
409 $dbo->execute();
410 $row['paymentlog'] = null;
411 }
412
413 // detect if VCM exists
414 $vcm_exists = is_file(VCM_SITE_PATH . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'lib.vikchannelmanager.php');
415
416 // attempt to get the VCM review ID with a try-catch to avoid SQL errors
417 $vcm_review = array();
418 if ($vcm_exists) {
419 try {
420 $q = "SELECT * FROM `#__vikchannelmanager_otareviews` WHERE `idorder`=" . (int)$row['id'] . ";";
421 $dbo->setQuery($q);
422 $dbo->execute();
423 if ($dbo->getNumRows()) {
424 $vcm_review = $dbo->loadAssoc();
425 }
426 } catch (Exception $e) {
427 // do nothing as VCM is probably not available/enabled/updated
428 }
429 }
430
431 /**
432 * Check if the reservation requires/supports additional actions.
433 *
434 * @since 1.14 (J) - 1.4.0 (WP)
435 */
436 $vcm_decline_actions = 0;
437 $vcm_pre_approval = 0;
438 $vcm_special_offer = 0;
439 $vcm_host_to_guest_review = 0;
440 $vcm_cancel_active_res = 0;
441 if ($vcm_exists) {
442 try {
443 require_once VCM_SITE_PATH . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'lib.vikchannelmanager.php';
444 if (method_exists('VikChannelManager', 'reservationNeedsDeclineReasons')) {
445 $vcm_decline_actions = (int)VikChannelManager::reservationNeedsDeclineReasons($row);
446 }
447 if (method_exists('VikChannelManager', 'reservationSupportsPreApproval')) {
448 $vcm_pre_approval = VikChannelManager::reservationSupportsPreApproval($row);
449 $vcm_pre_approval = $vcm_pre_approval === false ? 0 : $vcm_pre_approval;
450 }
451 if (method_exists('VikChannelManager', 'reservationSupportsSpecialOffer')) {
452 $vcm_special_offer = VikChannelManager::reservationSupportsSpecialOffer($row);
453 $vcm_special_offer = $vcm_special_offer === false ? 0 : $vcm_special_offer;
454 }
455 if (method_exists('VikChannelManager', 'hostToGuestReviewSupported')) {
456 $vcm_host_to_guest_review = VikChannelManager::hostToGuestReviewSupported($row);
457 $vcm_host_to_guest_review = $vcm_host_to_guest_review === false ? 0 : $vcm_host_to_guest_review;
458 }
459 if (method_exists('VikChannelManager', 'cancelActiveOtaReservation')) {
460 $vcm_cancel_active_res = (int)VikChannelManager::cancelActiveOtaReservation($row);
461 }
462 } catch (Exception $e) {
463 // do nothing as VCM is probably not available/enabled/updated
464 }
465 }
466
467 /**
468 * Build currency conversion details, if needed and supported.
469 *
470 * @since 1.15.0 (J) - 1.5.0 (WP)
471 */
472 $ota_helper = new VBOCurrencyOta($row);
473 $allows_conversion = $ota_helper->supportsConversion($row['total']);
474 $conv_from_currency = $allows_conversion !== false ? $ota_helper->getOTACurrency() : null;
475 $conv_to_currency = $allows_conversion !== false ? $ota_helper->getCurrencyName() : null;
476
477 $this->row = $row;
478 $this->rooms = $rooms;
479 $this->busy = $busy;
480 $this->customer = $customer;
481 $this->payments = $payments;
482 $this->vcm_review = $vcm_review;
483 $this->vcm_decline_actions = $vcm_decline_actions;
484 $this->vcm_pre_approval = $vcm_pre_approval;
485 $this->vcm_special_offer = $vcm_special_offer;
486 $this->vcm_host_to_guest_review = $vcm_host_to_guest_review;
487 $this->vcm_cancel_active_res = $vcm_cancel_active_res;
488 $this->allows_conversion = $allows_conversion;
489 $this->conv_from_currency = $conv_from_currency;
490 $this->conv_to_currency = $conv_to_currency;
491
492 // Display the template
493 parent::display($tpl);
494 }
495
496 /**
497 * Sets the toolbar
498 */
499 protected function addToolBar() {
500 $printreceipt = VikRequest::getInt('print', 0, 'request');
501 if ($printreceipt) {
502 // do not print any header or buttons if we are printing the receipt
503 return;
504 }
505
506 JToolBarHelper::title(JText::translate('VBMAINORDERTITLEEDIT'), 'vikbooking');
507 JToolBarHelper::cancel( 'canceledorder', JText::translate('VBBACK'));
508 JToolBarHelper::spacer();
509 JToolBarHelper::custom( 'prev_booking', 'backward', 'backward', JText::translate('VBJQCALPREV'), false);
510 JToolBarHelper::spacer();
511 JToolBarHelper::custom( 'next_booking', 'forward', 'forward', JText::translate('VBJQCALNEXT'), false);
512 JToolBarHelper::spacer();
513 }
514 }
515