Merge branch 'Qloapps:develop' into gli-2943
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
{**
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/license/osl-3-0-php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to support@qloapps.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this module to a newer
|
||||
* versions in the future. If you wish to customize this module for your needs
|
||||
* please refer to https://store.webkul.com/customisation-guidelines for more information.
|
||||
*
|
||||
* @author Webkul IN
|
||||
* @copyright Since 2010 Webkul
|
||||
* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0
|
||||
*}
|
||||
|
||||
{capture name='stay_periods_tooltip'}
|
||||
<div class="bootstrap tooltip_cont">
|
||||
<div class="tip_header">
|
||||
<div>{l s='Stay Periods'}</div>
|
||||
</div>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="tip_element_head">{l s='Duration'}</th>
|
||||
<th class="tip_element_head">{l s='Rooms'}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{foreach from=$stay_periods item=stay_period}
|
||||
<tr>
|
||||
<td class="tip_element_value">{$stay_period.from} – {$stay_period.to}</td>
|
||||
<td class="tip_element_value center">{$stay_period.count}</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{/capture}
|
||||
{capture name='stay_periods_tooltip_title'}<span class="badge tooltip-trigger">+{$extra_stay_periods_count}</span>{/capture}
|
||||
{include file='helpers/tooltip.tpl' tooltip_content=$smarty.capture.stay_periods_tooltip tooltip_title=$smarty.capture.stay_periods_tooltip_title}
|
||||
@@ -229,11 +229,17 @@ abstract class PaymentModuleCore extends Module
|
||||
$this->currentOrderReference = $reference;
|
||||
|
||||
$order_creation_failed = false;
|
||||
$cart_total_paid = (float)Tools::ps_round((float)$this->context->cart->getOrderTotal(true, Cart::BOTH), _PS_PRICE_COMPUTE_PRECISION_);
|
||||
|
||||
if ($this->context->cart->is_advance_payment) {
|
||||
$full_cart_total = (float)Tools::ps_round((float)$this->context->cart->getOrderTotal(true, Cart::BOTH), _PS_PRICE_COMPUTE_PRECISION_);
|
||||
$amount_paid = !$dont_touch_amount ? Tools::ps_round((float)$amount_paid, _PS_PRICE_COMPUTE_PRECISION_) : $amount_paid;
|
||||
|
||||
if ($amount_paid >= $full_cart_total) {
|
||||
$is_advance_payment = false;
|
||||
$cart_total_paid = $full_cart_total;
|
||||
} else {
|
||||
$is_advance_payment = true;
|
||||
$cart_total_paid = (float)Tools::ps_round(
|
||||
(float)$this->context->cart->getOrderTotal(true, CART::ADVANCE_PAYMENT),
|
||||
(float)$this->context->cart->getOrderTotal(true, Cart::ADVANCE_PAYMENT),
|
||||
_PS_PRICE_COMPUTE_PRECISION_
|
||||
);
|
||||
}
|
||||
@@ -314,7 +320,6 @@ abstract class PaymentModuleCore extends Module
|
||||
$order->gift_message = $this->context->cart->gift_message;
|
||||
$order->mobile_theme = $this->context->cart->mobile_theme;
|
||||
$order->conversion_rate = $this->context->currency->conversion_rate;
|
||||
$amount_paid = !$dont_touch_amount ? Tools::ps_round((float)$amount_paid, _PS_PRICE_COMPUTE_PRECISION_) : $amount_paid;
|
||||
$order->total_paid_real = 0;
|
||||
|
||||
$order->total_products = (float)$this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS, $order->product_list, $id_carrier);
|
||||
@@ -371,7 +376,7 @@ abstract class PaymentModuleCore extends Module
|
||||
}
|
||||
|
||||
// advance payment information
|
||||
$order->is_advance_payment = $this->context->cart->is_advance_payment;
|
||||
$order->is_advance_payment = (int)$is_advance_payment;
|
||||
$order->amount_paid = 0;
|
||||
if ($order->is_advance_payment) {
|
||||
$order->advance_paid_amount = (float)Tools::ps_round(
|
||||
@@ -893,7 +898,7 @@ abstract class PaymentModuleCore extends Module
|
||||
|
||||
/*for saving details of the advance payment product wise*/
|
||||
$objBookingDetail->total_paid_amount = $total_price['total_price_tax_incl'];
|
||||
if ($this->context->cart->is_advance_payment) {
|
||||
if ($is_advance_payment) {
|
||||
$prod_adv_payment = $objAdvancedPayment->getIdAdvPaymentByIdProduct($idProduct);
|
||||
if (!$prod_adv_payment
|
||||
|| (isset($prod_adv_payment['payment_type']) && $prod_adv_payment['payment_type'])
|
||||
|
||||
@@ -72,6 +72,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
) FROM `'._DB_PREFIX_.'htl_booking_detail` hbd WHERE hbd.`id_order` = a.`id_order`) as total_guests,
|
||||
(SELECT SUM(DATEDIFF(hbd.`date_to`, hbd.`date_from`)) FROM `'._DB_PREFIX_.'htl_booking_detail` hbd WHERE hbd.`id_order` = a.`id_order`) as los,
|
||||
hbd.`id_room` AS id_room_information,
|
||||
(SELECT GROUP_CONCAT(CONCAT(ps.period, \'~\', ps.cnt) ORDER BY ps.period SEPARATOR \'::\') FROM (SELECT CONCAT(hbd.`date_from`, \'|\', hbd.`date_to`) AS period, COUNT(*) AS cnt FROM `'._DB_PREFIX_.'htl_booking_detail` hbd WHERE hbd.`id_order` = a.`id_order` GROUP BY hbd.`date_from`, hbd.`date_to`) AS ps) AS stay_periods,
|
||||
(SELECT COUNT(spod.`id_service_product_order_detail`) FROM `'._DB_PREFIX_.'service_product_order_detail` spod WHERE spod.`id_order` = a.`id_order` AND spod.`id_htl_booking_detail`=0) as num_products';
|
||||
|
||||
$this->_join = '
|
||||
@@ -196,6 +197,15 @@ class AdminOrdersControllerCore extends AdminController
|
||||
'type'=>'date',
|
||||
'displayed' => false,
|
||||
),
|
||||
'stay_periods' => array(
|
||||
'title' => $this->l('Stay Periods'),
|
||||
'type' => 'text',
|
||||
'callback' => 'formatStayPeriods',
|
||||
'optional' => true,
|
||||
'search' => false,
|
||||
'displayed' => true,
|
||||
'visible_default' => true,
|
||||
),
|
||||
'total_guests' => array(
|
||||
'title' => $this->l('Guests'),
|
||||
'type' => 'range',
|
||||
@@ -212,7 +222,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
'visible_default' => true
|
||||
),
|
||||
'los' => array(
|
||||
'title' => $this->l('Stay period'),
|
||||
'title' => $this->l('Stay duration'),
|
||||
'align' => 'text-center',
|
||||
'type' => 'range',
|
||||
'havingFilter' => true,
|
||||
@@ -359,6 +369,43 @@ class AdminOrdersControllerCore extends AdminController
|
||||
return Tools::displayPrice($echo, (int)$idCurrency);
|
||||
}
|
||||
|
||||
public function formatStayPeriods($value, $row)
|
||||
{
|
||||
if (empty($value)) {
|
||||
return '--';
|
||||
}
|
||||
|
||||
$stayPeriods = array();
|
||||
foreach (explode('::', $value) as $stays) {
|
||||
$countStays = explode('~', $stays);
|
||||
$stayDates = explode('|', $countStays[0]);
|
||||
if (count($stayDates) === 2) {
|
||||
$stayPeriods[] = array(
|
||||
'from' => Tools::displayDate(trim($stayDates[0])),
|
||||
'to' => Tools::displayDate(trim($stayDates[1])),
|
||||
'count' => isset($countStays[1]) ? (int)$countStays[1] : 1,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$datesDisplay = array();
|
||||
foreach (array_slice($stayPeriods, 0, 1) as $stayPeriod) {
|
||||
$datesDisplay[] = $stayPeriod['from'].' - '.$stayPeriod['to'];
|
||||
}
|
||||
|
||||
$stayPeriodHtml = implode('<br>', $datesDisplay);
|
||||
$uniqueStayPeriods = count($stayPeriods);
|
||||
|
||||
if ($uniqueStayPeriods > 1) {
|
||||
$this->context->smarty->assign(array(
|
||||
'stay_periods' => $stayPeriods,
|
||||
'extra_stay_periods_count' => $uniqueStayPeriods - 1,
|
||||
));
|
||||
$stayPeriodHtml .= ' '.$this->createTemplate('_stay_periods_tooltip.tpl')->fetch();
|
||||
}
|
||||
return $stayPeriodHtml;
|
||||
}
|
||||
|
||||
public function initPageHeaderToolbar()
|
||||
{
|
||||
if (empty($this->display)) {
|
||||
@@ -1377,7 +1424,6 @@ class AdminOrdersControllerCore extends AdminController
|
||||
|
||||
$this->addJqueryUI('ui.datepicker');
|
||||
$this->addJqueryUI('ui.tooltip', 'base', true);
|
||||
|
||||
$this->addJS(_PS_JS_DIR_.'vendor/d3.v3.min.js');
|
||||
|
||||
if ($this->display == 'view') {
|
||||
|
||||
@@ -97,11 +97,13 @@ class WkPaypalCommerceWebhook
|
||||
if ($eventData['event_type'] == 'CHECKOUT.ORDER.COMPLETED') {
|
||||
$cartID = $transactionData['id_cart'];
|
||||
$objCart = new Cart($cartID);
|
||||
if ($objCart->is_advance_payment) {
|
||||
$orderStatus = Configuration::get('PS_OS_PARTIAL_PAYMENT_ACCEPTED');
|
||||
} else {
|
||||
$orderStatus = Configuration::get('PS_OS_PAYMENT_ACCEPTED');
|
||||
}
|
||||
$capturedAmount = isset($purchase['payments']['captures'][0]['amount']['value'])
|
||||
? (float)$purchase['payments']['captures'][0]['amount']['value']
|
||||
: 0;
|
||||
$fullTotal = (float)$objCart->getOrderTotal(true, Cart::BOTH);
|
||||
$orderStatus = $capturedAmount >= $fullTotal
|
||||
? Configuration::get('PS_OS_PAYMENT_ACCEPTED')
|
||||
: Configuration::get('PS_OS_PARTIAL_PAYMENT_ACCEPTED');
|
||||
if ($orders = WkPaypalCommerceHelper::getOrdersByCartId($cartID)) {
|
||||
foreach ($orders as $order) {
|
||||
$this->updatePaymentStatus(
|
||||
@@ -127,11 +129,13 @@ class WkPaypalCommerceWebhook
|
||||
)) {
|
||||
$cartID = $transactionData['id_cart'];
|
||||
$objCart = new Cart($cartID);
|
||||
if ($objCart->is_advance_payment) {
|
||||
$orderStatus = Configuration::get('PS_OS_PARTIAL_PAYMENT_ACCEPTED');
|
||||
} else {
|
||||
$orderStatus = Configuration::get('PS_OS_PAYMENT_ACCEPTED');
|
||||
}
|
||||
$capturedAmount = isset($eventData['resource']['amount']['value'])
|
||||
? (float)$eventData['resource']['amount']['value']
|
||||
: 0;
|
||||
$fullTotal = (float)$objCart->getOrderTotal(true, Cart::BOTH);
|
||||
$orderStatus = $capturedAmount >= $fullTotal
|
||||
? Configuration::get('PS_OS_PAYMENT_ACCEPTED')
|
||||
: Configuration::get('PS_OS_PARTIAL_PAYMENT_ACCEPTED');
|
||||
if ($orders = WkPaypalCommerceHelper::getOrdersByCartId($cartID)) {
|
||||
foreach ($orders as $order) {
|
||||
$this->updatePaymentStatus(
|
||||
|
||||
@@ -126,20 +126,19 @@ class QloPaypalCommercePaymentModuleFrontController extends ModuleFrontControlle
|
||||
$transaction_id = $this->saveOrderData($returnData);
|
||||
if ($paypalOrderID) {
|
||||
$currency = $this->context->currency;
|
||||
$total = (float)$cart->getOrderTotal(true, Cart::BOTH);
|
||||
if ($cart->is_advance_payment) {
|
||||
$total = (float)$cart->getOrderTotal(true, Cart::ADVANCE_PAYMENT);
|
||||
} else {
|
||||
$total = (float)$cart->getOrderTotal(true, Cart::BOTH);
|
||||
}
|
||||
// Order status/amount must reflect what PayPal actually captured,
|
||||
// not the cart's is_advance_payment flag (still editable by the
|
||||
// customer after payment, so it cannot be trusted here).
|
||||
$capturedAmount = isset($returnData['data']['purchase_units'][0]['payments']['captures'][0]['amount']['value']) ?
|
||||
(float) $returnData['data']['purchase_units'][0]['payments']['captures'][0]['amount']['value'] : 0;
|
||||
$fullTotal = (float) $cart->getOrderTotal(true, Cart::BOTH);
|
||||
$isFullyPaid = $capturedAmount >= $fullTotal;
|
||||
|
||||
// set order status
|
||||
if ($returnData['data']['status'] == 'COMPLETED') {
|
||||
if ($cart->is_advance_payment) {
|
||||
$orderStatus = Configuration::get('PS_OS_PARTIAL_PAYMENT_ACCEPTED');
|
||||
} else {
|
||||
$orderStatus = Configuration::get('PS_OS_PAYMENT_ACCEPTED');
|
||||
}
|
||||
$orderStatus = $isFullyPaid
|
||||
? Configuration::get('PS_OS_PAYMENT_ACCEPTED')
|
||||
: Configuration::get('PS_OS_PARTIAL_PAYMENT_ACCEPTED');
|
||||
} else {
|
||||
$orderStatus = Configuration::get('PS_OS_AWAITING_PAYMENT');
|
||||
}
|
||||
@@ -149,7 +148,7 @@ class QloPaypalCommercePaymentModuleFrontController extends ModuleFrontControlle
|
||||
$this->module->validateOrder(
|
||||
$cart->id,
|
||||
$orderStatus,
|
||||
$total,
|
||||
$capturedAmount,
|
||||
$this->module->l('PayPal Checkout', 'payment'),
|
||||
null,
|
||||
$extraVars,
|
||||
@@ -389,4 +388,4 @@ class QloPaypalCommercePaymentModuleFrontController extends ModuleFrontControlle
|
||||
{
|
||||
return _PS_PRICE_COMPUTE_PRECISION_;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user