| @@ -19,8 +19,12 @@ | ||
| 19 | 19 | { |
| 20 | 20 | // Set the toolbar |
| 21 | 21 | $this->addToolBar(); |
| 22 | 22 | |
| 23 | + if (!JFactory::getUser()->authorise('core.vbo.bookings', 'com_vikbooking')) { | |
| 24 | + VBOHttpDocument::getInstance()->close(403, JText::translate('JERROR_ALERTNOAUTHOR')); | |
| 25 | + } | |
| 26 | + | |
| 23 | 27 | $cid = VikRequest::getVar('cid', array(0)); |
| 24 | 28 | $ido = $cid[0]; |
| 25 | 29 | |
| 26 | 30 | if (is_file(VCM_ADMIN_PATH.DIRECTORY_SEPARATOR.'assets'.DIRECTORY_SEPARATOR.'css'.DIRECTORY_SEPARATOR.'vcm-channels.css')) { |
| @@ -26,8 +30,11 @@ | ||
| 26 | 30 | if (is_file(VCM_ADMIN_PATH.DIRECTORY_SEPARATOR.'assets'.DIRECTORY_SEPARATOR.'css'.DIRECTORY_SEPARATOR.'vcm-channels.css')) { |
| 27 | 31 | $document = JFactory::getDocument(); |
| 28 | 32 | $document->addStyleSheet(VCM_ADMIN_URI.'assets/css/vikchannelmanager.css'); |
| 29 | 33 | $document->addStyleSheet(VCM_ADMIN_URI.'assets/css/vcm-channels.css'); |
| 34 | + if (method_exists('VikChannelManager', 'loadAppearancePreferenceAssets')) { | |
| 35 | + VikChannelManager::loadAppearancePreferenceAssets(); | |
| 36 | + } | |
| 30 | 37 | } |
| 31 | 38 | |
| 32 | 39 | $dbo = JFactory::getDbo(); |
| 33 | 40 | $app = JFactory::getApplication(); |
| @@ -34,14 +41,14 @@ | ||
| 34 | 41 | $user = JFactory::getUser(); |
| 35 | 42 | |
| 36 | 43 | $q = "SELECT * FROM `#__vikbooking_orders` WHERE `id`=" . $dbo->quote($ido); |
| 37 | 44 | $dbo->setQuery($q, 0, 1); |
| 38 | - $dbo->execute(); | |
| 39 | - if (!$dbo->getNumRows()) { | |
| 45 | + $row = $dbo->loadAssoc(); | |
| 46 | + if (!$row) { | |
| 40 | 47 | $app->redirect("index.php?option=com_vikbooking&task=orders"); |
| 41 | 48 | $app->close(); |
| 49 | + return; | |
| 42 | 50 | } |
| 43 | - $row = $dbo->loadAssoc(); | |
| 44 | 51 | |
| 45 | 52 | /** |
| 46 | 53 | * Check currency conversion request, if needed and supported. |
| 47 | 54 | * |
| @@ -58,10 +65,9 @@ | ||
| 58 | 65 | } |
| 59 | 66 | |
| 60 | 67 | $q = "SELECT `id`,`name` FROM `#__vikbooking_gpayments` ORDER BY `#__vikbooking_gpayments`.`name` ASC;"; |
| 61 | 68 | $dbo->setQuery($q); |
| 62 | - $dbo->execute(); | |
| 63 | - $payments = $dbo->getNumRows() > 0 ? $dbo->loadAssocList() : ''; | |
| 69 | + $payments = $dbo->loadAssocList(); | |
| 64 | 70 | |
| 65 | 71 | $cpin = VikBooking::getCPinIstance(); |
| 66 | 72 | // VBO 1.11 - change customer assigned to this booking |
| 67 | 73 | $pnewcustid = VikRequest::getInt('newcustid', 0, 'request'); |
| @@ -105,8 +111,9 @@ | ||
| 105 | 111 | $ptot_taxes = VikRequest::getString('tot_taxes', '', 'request'); |
| 106 | 112 | $ptot_city_taxes = VikRequest::getString('tot_city_taxes', '', 'request'); |
| 107 | 113 | $ptot_fees = VikRequest::getString('tot_fees', '', 'request'); |
| 108 | 114 | $pcmms = VikRequest::getString('cmms', '', 'request'); |
| 115 | + $ptot_damage_dep = VikRequest::getString('tot_damage_dep', '', 'request'); | |
| 109 | 116 | $pcustmail = VikRequest::getString('custmail', '', 'request'); |
| 110 | 117 | $pcustphone = VikRequest::getString('custphone', '', 'request'); |
| 111 | 118 | $pmakepay = VikRequest::getInt('makepay', 0, 'request'); |
| 112 | 119 | $pnewamountpaid = VikRequest::getFloat('newamountpaid', -1, 'request'); |
| @@ -154,9 +161,13 @@ | ||
| 154 | 161 | $dbo->execute(); |
| 155 | 162 | $row['total'] = $newtotal; |
| 156 | 163 | $row['refund'] = $pnewamountrefunded; |
| 157 | 164 | // booking history log for new amount refunded |
| 158 | - VikBooking::getBookingHistoryInstance()->setBid($row['id'])->store('RU', JText::sprintf('VBO_NEWREFUND_AMOUNT', VikBooking::numberFormat($prevrefunded), VikBooking::numberFormat($pnewamountrefunded))); | |
| 165 | + VikBooking::getBookingHistoryInstance($row['id']) | |
| 166 | + ->setExtraData([ | |
| 167 | + 'amount_paid' => ($pnewamountrefunded - $prevrefunded), | |
| 168 | + ]) | |
| 169 | + ->store('RU', JText::sprintf('VBO_NEWREFUND_AMOUNT', VikBooking::numberFormat($prevrefunded), VikBooking::numberFormat($pnewamountrefunded))); | |
| 159 | 170 | } |
| 160 | 171 | $pnewamountpayable = VikRequest::getFloat('newamountpayable', -1, 'request'); |
| 161 | 172 | // we update the amount payable also if the input is 0.0 (float) as the default value is -1 (int) |
| 162 | 173 | if (($pnewamountpayable > 0 || ($pnewamountpayable == 0 && is_float($pnewamountpayable))) && (float)$row['payable'] != $pnewamountpayable) { |
| @@ -201,9 +212,9 @@ | ||
| 201 | 212 | $dbo->setQuery($q); |
| 202 | 213 | $dbo->execute(); |
| 203 | 214 | $row['inv_notes'] = $pinvnotes; |
| 204 | 215 | } |
| 205 | - if (!empty($pnewpayment) && is_array($payments)) { | |
| 216 | + if (!empty($pnewpayment) && $payments) { | |
| 206 | 217 | foreach ($payments as $npay) { |
| 207 | 218 | if ((int)$npay['id'] == (int)$pnewpayment) { |
| 208 | 219 | $newpayvalid = $npay['id'].'='.$npay['name']; |
| 209 | 220 | $q = "UPDATE `#__vikbooking_orders` SET `idpayment`=".$dbo->quote($newpayvalid)." WHERE `id`=".$row['id'].";"; |
| @@ -263,8 +274,14 @@ | ||
| 263 | 274 | $dbo->setQuery($q); |
| 264 | 275 | $dbo->execute(); |
| 265 | 276 | $row['cmms'] = $pcmms; |
| 266 | 277 | } |
| 278 | + if (strlen($ptot_damage_dep) > 0) { | |
| 279 | + $q = "UPDATE `#__vikbooking_orders` SET `tot_damage_dep`='".floatval($ptot_damage_dep)."' WHERE `id`=".$row['id'].";"; | |
| 280 | + $dbo->setQuery($q); | |
| 281 | + $dbo->execute(); | |
| 282 | + $row['tot_damage_dep'] = $ptot_damage_dep; | |
| 283 | + } | |
| 267 | 284 | if (strlen($pcustmail) > 0) { |
| 268 | 285 | $q = "UPDATE `#__vikbooking_orders` SET `custmail`=".$dbo->quote($pcustmail)." WHERE `id`=".$row['id'].";"; |
| 269 | 286 | $dbo->setQuery($q); |
| 270 | 287 | $dbo->execute(); |
| @@ -403,22 +420,20 @@ | ||
| 403 | 420 | $row['paymentlog'] = null; |
| 404 | 421 | } |
| 405 | 422 | |
| 406 | 423 | // detect if VCM exists |
| 407 | - $vcm_exists = is_file(VCM_SITE_PATH . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'lib.vikchannelmanager.php'); | |
| 424 | + $vcm_exists = class_exists('VikChannelManager'); | |
| 408 | 425 | |
| 409 | - // attempt to get the VCM review ID with a try-catch to avoid SQL errors | |
| 410 | - $vcm_review = array(); | |
| 426 | + // attempt to get the VCM review ID within a try-catch statement to avoid SQL errors | |
| 427 | + $vcm_review = null; | |
| 411 | 428 | if ($vcm_exists) { |
| 412 | 429 | try { |
| 413 | 430 | $q = "SELECT * FROM `#__vikchannelmanager_otareviews` WHERE `idorder`=" . (int)$row['id'] . ";"; |
| 414 | 431 | $dbo->setQuery($q); |
| 415 | - $dbo->execute(); | |
| 416 | - if ($dbo->getNumRows()) { | |
| 417 | - $vcm_review = $dbo->loadAssoc(); | |
| 418 | - } | |
| 432 | + $vcm_review = $dbo->loadAssoc(); | |
| 419 | 433 | } catch (Exception $e) { |
| 420 | 434 | // do nothing as VCM is probably not available/enabled/updated |
| 435 | + $vcm_review = null; | |
| 421 | 436 | } |
| 422 | 437 | } |
| 423 | 438 | |
| 424 | 439 | /** |
| @@ -432,9 +447,8 @@ | ||
| 432 | 447 | $vcm_host_to_guest_review = 0; |
| 433 | 448 | $vcm_cancel_active_res = 0; |
| 434 | 449 | if ($vcm_exists) { |
| 435 | 450 | try { |
| 436 | - require_once VCM_SITE_PATH . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'lib.vikchannelmanager.php'; | |
| 437 | 451 | if (method_exists('VikChannelManager', 'reservationNeedsDeclineReasons')) { |
| 438 | 452 | $vcm_decline_actions = (int)VikChannelManager::reservationNeedsDeclineReasons($row); |
| 439 | 453 | } |
| 440 | 454 | if (method_exists('VikChannelManager', 'reservationSupportsPreApproval')) { |