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

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