time()) {
// attempt to obtain the door access control passcode details
try {
// obtain the passcode details for this booking
$passcodeDetails = VBOFactory::getDoorAccessControl()->getBookingDevicePasscodes($registry);
} catch (Exception $e) {
// do nothing on error
$passcodeDetails = null;
}
?>
-
%s', '%s']); ?>
0) {
?>
%s', '%s']); ?>
%s', '%s']); ?>
0 && ($ord['totpaid'] + ($this->damage_deposit_payment['damagedep_gross'] ?? 0)) < $ord['total'] && $ord['paymcount'] > 0) || $ord['payable'] > 0);
$ota_will_pay = false;
$dd_payable_later = false;
if ($payable && $ord['status'] == 'confirmed' && !empty($ord['idorderota']) && $ord['payable'] > 0 && !$this->prev_dd_payments) {
if (($this->damage_deposit_payment['damagedep_gross'] ?? 0) == $ord['payable'] && ($this->damage_deposit_payment['payment_window']['pay_id'] ?? 0)) {
// upselling event must have added the damage deposit to an OTA booking, and this is the only outstanding amount that will be paid separately
$payable = false;
// check if the damage deposit is payable later
if (!($this->damage_deposit_payment['payment_window']['payable'] ?? 0) && ($this->damage_deposit_payment['payment_window']['payment_from_dt'] ?? null)) {
$dd_payable_later = true;
}
}
}
if ($payable && !empty($ord['idorderota']) && !empty($ord['channel']) && $ord['cmms'] && ($ord['total'] - $ord['totpaid'] - $ord['cmms']) < 1) {
// the difference of the amount paid is equal to the OTA commissions amount
$payable = false;
if ($ord['payable'] > 0 && $ord['total'] > $ord['totpaid'] && round(($ord['total'] - $ord['totpaid']), 0) == round($ord['payable'], 0)) {
// there must have been an upselling event or a payment request
$payable = true;
}
}
if ($payable && $isotabooking && !((float) $ord['payable'])) {
// access OTA payout events
$prev_ota_payments = VikBooking::getBookingHistoryInstance($ord['id'])
->getEventsWithData('PO', null, false);
if (!$prev_ota_payments) {
// the OTA will pay the remaining balance
$payable = false;
$ota_will_pay = true;
}
}
/**
* Check if we have an outstanding balance after a deposit paid for a direct booking.
*
* @since 1.18.6 (J) - 1.8.6 (WP)
*/
$pay_balance_days_adv = (int) VBOFactory::getConfig()->get('depbalancedays');
if ($pay_balance_days_adv > 0 && !((float) $ord['payable']) && $ord['status'] == 'confirmed' && empty($ord['idorderota']) && $ord['totpaid'] > 0 && $ord['total'] > $ord['totpaid']) {
// ensure the outstanding balance for direct booking is payable at this time
if ($ord['ts'] < strtotime(sprintf('-%d days', $pay_balance_days_adv), $ord['checkin'])) {
// outstanding balance not yet payable according to settings
$payable = false;
}
}
if ($ord['status'] == 'confirmed' && is_array($payment) && VikBooking::multiplePayments() && $ord['total'] > 0 && $payable) {
// write again the payment form because the order was not fully paid
if (VBOPlatformDetection::isWordPress()) {
/**
* @wponly
*
* @since 1.0.5
*/
$return_url = JUri::root() . "index.php?option=com_vikbooking&view=booking&sid=" . (!empty($ord['idorderota']) && !empty($ord['channel']) ? $ord['idorderota'] : $ord['sid']) . "&ts=" . $ord['ts'];
$error_url = JUri::root() . "index.php?option=com_vikbooking&view=booking&sid=" . (!empty($ord['idorderota']) && !empty($ord['channel']) ? $ord['idorderota'] : $ord['sid']) . "&ts=" . $ord['ts'];
$notify_url = JUri::root() . "index.php?option=com_vikbooking&task=notifypayment&sid=" . (!empty($ord['idorderota']) && !empty($ord['channel']) ? $ord['idorderota'] : $ord['sid']) . "&ts=" . $ord['ts']."&tmpl=component";
/**
* @wponly the URLs must be routed differently for WP
*/
$model = JModel::getInstance('vikbooking', 'shortcodes', 'admin');
$itemid = $model->best(['booking'], (!empty($ord['lang']) ? $ord['lang'] : null));
if ($itemid) {
$return_url = str_replace(JUri::root(), '', $return_url);
$error_url = str_replace(JUri::root(), '', $error_url);
$notify_url = str_replace(JUri::root(), '', $notify_url);
$return_url = JRoute::rewrite($return_url . "&Itemid={$itemid}", false);
$error_url = JRoute::rewrite($error_url . "&Itemid={$itemid}", false);
$notify_url = JRoute::rewrite($notify_url . "&Itemid={$itemid}", false);
}
} else {
$return_url = VikBooking::externalroute("index.php?option=com_vikbooking&view=booking&sid=" . (!empty($ord['idorderota']) && !empty($ord['channel']) ? $ord['idorderota'] : $ord['sid']) . "&ts=" . $ord['ts'], false, (!empty($bestitemid) ? $bestitemid : null));
$error_url = VikBooking::externalroute("index.php?option=com_vikbooking&view=booking&sid=" . (!empty($ord['idorderota']) && !empty($ord['channel']) ? $ord['idorderota'] : $ord['sid']) . "&ts=" . $ord['ts'], false, (!empty($bestitemid) ? $bestitemid : null));
$notify_url = VikBooking::externalroute("index.php?option=com_vikbooking&task=notifypayment&sid=" . (!empty($ord['idorderota']) && !empty($ord['channel']) ? $ord['idorderota'] : $ord['sid']) . "&ts=" . $ord['ts']."&tmpl=component", false, null);
}
$transaction_name = VikBooking::getPaymentName();
$leave_deposit = 0;
$percentdeposit = "";
// calculate the outstanding balance to pay
if ($ord['payable'] > 0) {
$remainingamount = $ord['payable'];
} else {
$prev_dd_paid = 0;
if ($this->prev_dd_payments || ($this->damage_deposit_payment['payment_window'] ?? [])) {
$prev_dd_paid = $this->damage_deposit_payment['damagedep_gross'] ?? 0;
}
$prev_recorded_payment = $ord['totpaid'] + $prev_dd_paid;
$remainingamount = $ord['total'] - $prev_recorded_payment;
}
$array_order = [];
$array_order['details'] = $ord;
if (empty($array_order['details']['sid']) && !empty($array_order['details']['idorderota']) && !empty($array_order['details']['channel'])) {
$array_order['details']['sid'] = $array_order['details']['idorderota'];
$ord['sid'] = $ord['idorderota'];
}
$array_order['customer_email'] = $ord['custmail'];
$array_order['account_name'] = VikBooking::getPaypalAcc();
$array_order['transaction_currency'] = VikBooking::getCurrencyCodePp();
$array_order['rooms_name'] = implode(", ", $roomsnames);
$array_order['transaction_name'] = !empty($transaction_name) ? $transaction_name : (JText::translate('VBORDERNUMBER') . ' ' . $ord['id']);
$array_order['order_total'] = $remainingamount;
$array_order['currency_symb'] = $currencysymb;
$array_order['net_price'] = $remainingamount;
$array_order['tax'] = 0;
$array_order['return_url'] = $return_url;
$array_order['error_url'] = $error_url;
$array_order['notify_url'] = $notify_url;
$array_order['total_to_pay'] = $remainingamount;
$array_order['total_net_price'] = $remainingamount;
$array_order['total_tax'] = 0;
$array_order['leave_deposit'] = $leave_deposit;
$array_order['percentdeposit'] = $percentdeposit;
$array_order['payment_info'] = $payment;
$array_order = array_merge($ord, $array_order);
?>
%s', '%s']); ?>
%s', '%s']); ?>
$ord['id'],
'source' => (($ord['channel'] ?? '') ?: 'Website'),
'ota_booking_id' => (($ord['idorderota'] ?? '') ?: ''),
];
// increase payment processor instances
$payProcessorInstances++;
/**
* Trigger event to allow third-party plugins to manipulate the transaction data.
*
* @since 1.18.5 (J) - 1.8.5 (WP)
*/
VBOFactory::getPlatform()->getDispatcher()->trigger('onInitPaymentTransaction', [&$array_order, &$payment['params'], []]);
if (VBOPlatformDetection::isWordPress()) {
/**
* @wponly The payment gateway is now loaded
* using the apposite dispatcher.
*
* @since 1.0.5
*/
JLoader::import('adapter.payment.dispatcher');
$obj = JPaymentDispatcher::getInstance('vikbooking', $payment['file'], $array_order, $payment['params']);
// remember to echo the payment
echo $obj->showPayment();
} else {
/**
* @joomlaonly The Payment Factory library will invoke the gateway.
*
* @since 1.14.3
*/
require_once VBO_ADMIN_PATH . DIRECTORY_SEPARATOR . 'payments' . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'factory.php';
$obj = VBOPaymentFactory::getPaymentInstance($payment['file'], $array_order, $payment['params']);
$obj->showPayment();
}
?>
0 && $ord['totpaid'] > 0 && $ord['totpaid'] < $ord['total']) {
/**
* Calculate the amount paid so far, by considering the damage deposit and its payment.
*
* @since 1.17.6 (J) - 1.7.6 (WP)
*/
$paid_so_far = $ord['totpaid'];
if (($this->damage_deposit_payment['damagedep_gross'] ?? 0) > 0 && $this->prev_dd_payments) {
$paid_so_far += $this->damage_deposit_payment['damagedep_gross'];
}
// calculate the remainig balance to be paid
$remainingamount = $ord['total'] - $paid_so_far;
?>
1) {
// some services have been reviewed ("review_score" is always present)
?>
$servicescore) {
if ($servicename == 'review_score') {
// protected keyword for the global review score
$counter++;
continue;
}
$stars_count = floor($servicescore / 2);
?>
upselling);
if ($tot_upselling) {
// at least one room has options that can be up-sold
$formatparts = explode(':', VikBooking::getNumberFormatData());
?>
0) {
// -1 means that VCM is not enabled
$chat_available = true;
// check if chat can still be displayed to the guest
$chat_params = VikBooking::getChatParams();
if (!isset($chat_params->res_status) || !in_array($ord['status'], $chat_params->res_status)) {
// chat is disabled for this reservation status
$chat_available = false;
}
if (isset($chat_params->av_type) && isset($chat_params->av_days)) {
// check days of validity after checkin or checkout
$chat_lim_ts = $chat_params->av_type == 'checkin' ? strtotime("+{$chat_params->av_days} days", $ord['checkin']) : strtotime("+{$chat_params->av_days} days", $ord['checkout']);
// compare limits at midnight
$now_midnight = mktime(0, 0, 0, date('n'), date('j'), date('Y'));
$lim_midnight = mktime(0, 0, 0, date('n', $chat_lim_ts), date('j', $chat_lim_ts), date('Y', $chat_lim_ts));
if ($now_midnight > $lim_midnight) {
// limit date is in the past
$chat_available = false;
}
}
if ($chat_available) {
// attempt to get the class instance
$messaging = VikBooking::getVcmChatInstance([$ord['id'], $ord['ts']], 'vikbooking');
}
}
if (!is_null($messaging)) {
$tot_unread = VCMChatHandler::countUnreadMessages($ord['id']);
?>