diff --git a/admin/themes/default/template/controllers/products/informations.tpl b/admin/themes/default/template/controllers/products/informations.tpl
index 68a6d2d18..201cbc41d 100644
--- a/admin/themes/default/template/controllers/products/informations.tpl
+++ b/admin/themes/default/template/controllers/products/informations.tpl
@@ -356,9 +356,8 @@
file="controllers/products/textarea_lang.tpl"
languages=$languages
input_name='description_short'
- class="autoload_rte"
input_value=$product->description_short
- max=$PS_PRODUCT_SHORT_DESC_LIMIT}
+ maxlength=$PS_PRODUCT_SHORT_DESC_LIMIT}
diff --git a/admin/themes/default/template/helpers/tree/tree.tpl b/admin/themes/default/template/helpers/tree/tree.tpl
index 30c4283c6..1eab06591 100644
--- a/admin/themes/default/template/helpers/tree/tree.tpl
+++ b/admin/themes/default/template/helpers/tree/tree.tpl
@@ -86,16 +86,27 @@
{if isset($auto_select_children) && $auto_select_children == true}
$('#{$id|escape:'html':'UTF-8'}').find(':input[type=checkbox]').on('click', function(){
- if ($(this).is(":checked")) {
- $(this).closest('.tree-folder').find(':input[type=checkbox]').each(function(){
- $(this).prop('checked', true);
- $(this).parent().addClass('tree-selected');
- });
- } else {
- $(this).closest('.tree-folder').find(':input[type=checkbox]').each(function(){
- $(this).prop('checked', false);
- $(this).parent().removeClass('tree-selected');
- });
+ if ($(this).closest('.tree-item').length ==0) {
+ if ($(this).is(":checked")) {
+ $(this).closest('.tree-folder').find(':input[type=checkbox]').each(function(){
+ $(this).prop('checked', true);
+ $(this).parent().addClass('tree-selected');
+ });
+ } else {
+ $(this).closest('.tree-folder').find(':input[type=checkbox]').each(function(){
+ $(this).prop('checked', false);
+ $(this).parent().removeClass('tree-selected');
+ });
+ }
+ }
+
+ if ($(this).closest('.tree-item').length) {
+ if (!$(this).is(":checked")) {
+ $(this).parents('.tree-folder').find(':input[type=checkbox]:first').each(function(){
+ $(this).prop('checked', false);
+ $(this).parent().removeClass('tree-selected');
+ });
+ }
}
});
{/if}
diff --git a/classes/Cart.php b/classes/Cart.php
index edc9cee2f..dc03b79b3 100644
--- a/classes/Cart.php
+++ b/classes/Cart.php
@@ -186,6 +186,8 @@ class CartCore extends ObjectModel
const ONLY_ROOM_SERVICES_WITH_AUTO_ADD_WITHOUT_CONVENIENCE_FEE = 17;
const ONLY_CONVENIENCE_FEE = 18;
+ const ONLY_PRODUCTS_WITH_DEMANDS = 19;
+
public function __construct($id = null, $id_lang = null)
{
parent::__construct($id);
@@ -366,8 +368,8 @@ class CartCore extends ObjectModel
*/
public function getAverageProductsTaxRate(&$cart_amount_te = null, &$cart_amount_ti = null)
{
- $cart_amount_ti = $this->getOrderTotal(true, Cart::ONLY_PRODUCTS);
- $cart_amount_te = $this->getOrderTotal(false, Cart::ONLY_PRODUCTS);
+ $cart_amount_ti = $this->getOrderTotal(true, Cart::ONLY_PRODUCTS_WITH_DEMANDS);
+ $cart_amount_te = $this->getOrderTotal(false, Cart::ONLY_PRODUCTS_WITH_DEMANDS);
$cart_vat_amount = $cart_amount_ti - $cart_amount_te;
@@ -1029,6 +1031,9 @@ class CartCore extends ObjectModel
if ((int)$cartRule->gift_product) {
$this->updateQty(1, $cartRule->gift_product, $cartRule->gift_product_attribute, false, 'up', 0, null, false);
}
+ // after adding new cart rule, check if any of the appled cart rules are not being used
+ CartRule::autoRemoveFromCart(Context::getContext());
+ CartRule::autoAddToCart(Context::getContext());
return true;
}
@@ -1612,6 +1617,7 @@ class CartCore extends ObjectModel
Cart::ONLY_PHYSICAL_PRODUCTS_WITHOUT_SHIPPING,
Cart::ADVANCE_PAYMENT,
Cart::ADVANCE_PAYMENT_ONLY_PRODUCTS,
+ Cart::ONLY_PRODUCTS_WITH_DEMANDS,
);
// Define virtual context to prevent case where the cart is not the in the global context
@@ -1875,16 +1881,14 @@ class CartCore extends ObjectModel
// price of extra demands on room type in the cart
- if ($type == Cart::BOTH || $type == Cart::BOTH_WITHOUT_SHIPPING || $type == Cart::ADVANCE_PAYMENT) {
- $totalDemandsPrice += $objCartBookingData->getCartExtraDemands($this->id, $product['id_product'], 0, 0, 0, 1, 0, (int)$with_taxes);
- }
+ $totalDemandsPrice += $objCartBookingData->getCartExtraDemands($this->id, $product['id_product'], 0, 0, 0, 1, 0, (int)$with_taxes);
}
foreach ($products_total as $key => $price) {
$order_total += $price;
}
- $order_total_products = $order_total;
+ $order_total_products = $order_total + $totalDemandsPrice;
if ($type == Cart::ONLY_DISCOUNTS) {
$order_total = 0;
@@ -1904,7 +1908,11 @@ class CartCore extends ObjectModel
}
// price of extra demands on room type in the cart
- if ($type == Cart::BOTH || $type == Cart::BOTH_WITHOUT_SHIPPING || $type == Cart::ADVANCE_PAYMENT) {
+ if ($type == Cart::BOTH
+ || $type == Cart::BOTH_WITHOUT_SHIPPING
+ || $type == Cart::ADVANCE_PAYMENT
+ || $type == Cart::ONLY_PRODUCTS_WITH_DEMANDS
+ ) {
$order_total += $totalDemandsPrice;
}
@@ -1921,7 +1929,8 @@ class CartCore extends ObjectModel
Cart::ONLY_CONVENIENCE_FEE,
Cart::ONLY_ROOM_SERVICES_WITHOUT_AUTO_ADD,
Cart::ONLY_ROOM_SERVICES_WITHOUT_CONVENIENCE_FEE,
- Cart::ONLY_ROOM_SERVICES_WITH_AUTO_ADD_WITHOUT_CONVENIENCE_FEE)
+ Cart::ONLY_ROOM_SERVICES_WITH_AUTO_ADD_WITHOUT_CONVENIENCE_FEE,
+ Cart::ONLY_PRODUCTS_WITH_DEMANDS)
) && CartRule::isFeatureActive()
) {
// First, retrieve the cart rules associated to this "getOrderTotal"
@@ -3814,10 +3823,6 @@ class CartCore extends ObjectModel
}
}
-
- if (((float)$cart_rule['value_real'] == 0 && (int)$cart_rule['free_shipping'] == 0)) {
- unset($cart_rules[$key]);
- }
}
$objHotelAdvancedPayment = new HotelAdvancedPayment();
diff --git a/classes/CartRule.php b/classes/CartRule.php
index 0d8748d83..17c6bd8ca 100644
--- a/classes/CartRule.php
+++ b/classes/CartRule.php
@@ -564,6 +564,9 @@ class CartRuleCore extends ObjectModel
if (strtotime($this->date_to) < time()) {
return (!$display_error) ? false : Tools::displayError('This voucher has expired');
}
+ if (!$alreadyInCart && $context->cart->getOrderTotal(true, Cart::BOTH) <= 0) {
+ return (!$display_error) ? false : Tools::displayError('You cannot add more vouchers. Please remove an existing voucher before applying a new one.');
+ }
if ($context->cart->id_customer) {
$quantityUsed = Db::getInstance()->getValue('
@@ -970,8 +973,8 @@ class CartRuleCore extends ObjectModel
$all_cart_rules_ids = $context->cart->getOrderedCartRulesIds();
- $cart_amount_ti = $context->cart->getOrderTotal(true, Cart::ONLY_PRODUCTS);
- $cart_amount_te = $context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS);
+ $cart_amount_ti = $context->cart->getOrderTotal(true, Cart::ONLY_PRODUCTS_WITH_DEMANDS);
+ $cart_amount_te = $context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS_WITH_DEMANDS);
// Free shipping on selected carriers
if ($this->free_shipping && in_array($filter, array(CartRule::FILTER_ACTION_ALL, CartRule::FILTER_ACTION_ALL_NOCAP, CartRule::FILTER_ACTION_SHIPPING))) {
@@ -997,7 +1000,7 @@ class CartRuleCore extends ObjectModel
// Discount (%) on the whole order
if ($this->reduction_percent && $this->reduction_product == 0) {
// Do not give a reduction on free products!
- $order_total = $context->cart->getOrderTotal($use_tax, Cart::ONLY_PRODUCTS, $package_products);
+ $order_total = $context->cart->getOrderTotal($use_tax, Cart::ONLY_PRODUCTS_WITH_DEMANDS, $package_products);
foreach ($context->cart->getCartRules(CartRule::FILTER_ACTION_GIFT) as $cart_rule) {
$order_total -= Tools::ps_round($cart_rule['obj']->getContextualValue($use_tax, $context, CartRule::FILTER_ACTION_GIFT, $package), _PS_PRICE_COMPUTE_PRECISION_);
}
@@ -1070,9 +1073,9 @@ class CartRuleCore extends ObjectModel
if ((float)$this->reduction_amount > 0) {
$prorata = 1;
if (!is_null($package) && count($all_products)) {
- $total_products = $context->cart->getOrderTotal($use_tax, Cart::ONLY_PRODUCTS);
+ $total_products = $context->cart->getOrderTotal($use_tax, Cart::ONLY_PRODUCTS_WITH_DEMANDS);
if ($total_products) {
- $prorata = $context->cart->getOrderTotal($use_tax, Cart::ONLY_PRODUCTS, $package['products']) / $total_products;
+ $prorata = $context->cart->getOrderTotal($use_tax, Cart::ONLY_PRODUCTS_WITH_DEMANDS, $package['products']) / $total_products;
}
}
@@ -1121,7 +1124,7 @@ class CartRuleCore extends ObjectModel
if ($this->reduction_tax == $use_tax) {
// The reduction cannot exceed the products total, except when we do not want it to be limited (for the partial use calculation)
if ($filter != CartRule::FILTER_ACTION_ALL_NOCAP) {
- $cart_amount = $context->cart->getOrderTotal($use_tax, Cart::ONLY_PRODUCTS);
+ $cart_amount = $context->cart->getOrderTotal($use_tax, Cart::ONLY_PRODUCTS_WITH_DEMANDS);
$reduction_amount = min($reduction_amount, $cart_amount);
}
$reduction_value += $prorata * $reduction_amount;
@@ -1377,12 +1380,20 @@ class CartRuleCore extends ObjectModel
return array();
}
+ $order_total = $context->cart->getOrderTotal(true, Cart::ONLY_PRODUCTS_WITH_DEMANDS, null, null, false);
static $errors = array();
foreach ($context->cart->getCartRules() as $cart_rule) {
if ($error = $cart_rule['obj']->checkValidity($context, true)) {
$context->cart->removeCartRule($cart_rule['obj']->id);
$context->cart->update();
$errors[] = $error;
+ } else {
+ if ($order_total <= 0) {
+ // remove cart rule if cart amount is already reached 0
+ $context->cart->removeCartRule($cart_rule['obj']->id);
+ } else {
+ $order_total = $order_total - $cart_rule['value_real'];
+ }
}
}
return $errors;
diff --git a/classes/PaymentModule.php b/classes/PaymentModule.php
index 1234b8f59..13fbaf1db 100644
--- a/classes/PaymentModule.php
+++ b/classes/PaymentModule.php
@@ -265,6 +265,7 @@ abstract class PaymentModuleCore extends Module
}
}
+ $orderTotals = array();
Hook::exec('actionPackageListGenerateOrder', array('package_list' => &$package_list));
foreach ($package_list as $id_address => $packageByAddress) {
foreach ($packageByAddress as $id_package => $package) {
@@ -364,6 +365,7 @@ abstract class PaymentModuleCore extends Module
// advance payment information
$order->is_advance_payment = $this->context->cart->is_advance_payment;
+ $order->amount_paid = 0;
if ($order->is_advance_payment) {
$order->advance_paid_amount = (float)Tools::ps_round(
(float)$this->context->cart->getOrderTotal(true, Cart::ADVANCE_PAYMENT, $order->product_list, $id_carrier),
@@ -390,6 +392,7 @@ abstract class PaymentModuleCore extends Module
// Creating order
$result = $order->add();
+ $orderTotals[$order->id] = array('incl' => $order->total_products_wt, 'excl' => $order->total_products);
if (!$result) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Order cannot be created', 3, null, 'Cart', (int)$id_cart, true);
@@ -492,6 +495,7 @@ abstract class PaymentModuleCore extends Module
// Make sure CartRule caches are empty
CartRule::cleanCache();
$objRoomType = new HotelRoomType();
+ $cart_rules = $this->context->cart->getCartRules();
foreach ($order_detail_list as $key => $order_detail) {
/** @var OrderDetail $order_detail */
@@ -604,7 +608,7 @@ abstract class PaymentModuleCore extends Module
}
$cart_rules_list = array();
- foreach ($cart_rules as $cart_rule) {
+ foreach ($cart_rules as $key => $cart_rule) {
if ($cart_rule['obj']->reduction_product > 0 && !$order->orderContainProduct($cart_rule['obj']->reduction_product)) {
continue;
}
@@ -620,90 +624,40 @@ abstract class PaymentModuleCore extends Module
continue;
}
- // IF
- // The value of the voucher is greater than the total of the order
- // Partial use is allowed
- // This is an "amount" reduction, not a reduction in % or a gift
- // THEN
- // The voucher is cloned with a new value corresponding to the remainder
- $reduction_amount_converted = $cart_rule['obj']->reduction_amount;
- if ((int) $cart_rule['obj']->reduction_currency !== (int) $this->context->cart->id_currency) {
- $reduction_amount_converted = Tools::convertPriceFull(
- $cart_rule['obj']->reduction_amount,
- new Currency($cart_rule['obj']->reduction_currency),
- new Currency($this->context->cart->id_currency)
- );
+ $used = array('incl' => 0, 'excl' => 0);
+ if (!isset($cart_rules[$key]['remaining'])) {
+ $cart_rules[$key]['remaining'] = $cart_rule['obj']->reduction_amount;
+ if ((int) $cart_rule['obj']->reduction_currency !== (int) $cart->id_currency) {
+ $cart_rules[$key]['remaining'] = Tools::convertPriceFull(
+ $cart_rule['obj']->reduction_amount,
+ new Currency($cart_rule['obj']->reduction_currency),
+ new Currency($cart->id_currency)
+ );
+ }
}
- if ($cart_rule['obj']->reduction_tax) {
- $remaining_amount = $values['tax_incl'] - $order->total_products_wt;
+
+ if ($cart_rule['reduction_tax']) {
+ if ($orderTotals[$order->id]['incl'] > $values['tax_incl']) {
+ $used['incl'] = $values['tax_incl'];
+ $used['excl'] = $values['tax_excl'];
+ } else {
+ $used['incl'] = $orderTotals[$order->id]['incl'];
+ $used['excl'] = $orderTotals[$order->id]['excl'];
+ }
+ $orderTotals[$order->id]['incl'] -= $used['incl'];
+ $orderTotals[$order->id]['excl'] -= $used['excl'];
+ $cart_rules[$key]['remaining'] -= $used['incl'];
} else {
- $remaining_amount = $values['tax_excl'] - $order->total_products;
- }
- if ($remaining_amount > 0 && $cart_rule['obj']->partial_use == 1 && $reduction_amount_converted > 0) {
- // Create a new voucher from the original
- $voucher = new CartRule((int)$cart_rule['obj']->id); // We need to instantiate the CartRule without lang parameter to allow saving it
- unset($voucher->id);
-
- // Set a new voucher code
- // For a customer, applying voucher ABCD will create partial vouchers ABCD-2, ABCD-3 and so on, and
- // applying voucher ABCD-2 will create vouchers ABCD-2-2, ABCD-2-3 and so on
- $voucher->code = empty($voucher->code) ? substr(md5($order->id.'-'.$order->id_customer.'-'.$cart_rule['obj']->id), 0, 16) : $voucher->code.'-2';
- while (CartRule::cartRuleExists($voucher->code, $order->id_customer)) {
- if (preg_match('/\-([0-9]{1,2})$/', $voucher->code, $matches)) {
- $voucher->code = preg_replace('/'.$matches[1].'$/', (intval($matches[1]) + 1), $voucher->code);
- }
- }
-
- // Set the new voucher value
- $voucher->reduction_amount = $remaining_amount;
- if ($voucher->reduction_tax) {
- // Add total shipping amout only if reduction amount > total shipping
- if ($voucher->free_shipping == 1 && $voucher->reduction_amount >= $order->total_shipping_tax_incl) {
- $voucher->reduction_amount -= $order->total_shipping_tax_incl;
- }
+ if ($orderTotals[$order->id]['excl'] > $values['tax_excl']) {
+ $used['incl'] = $values['tax_incl'];
+ $used['excl'] = $values['tax_excl'];
} else {
- // Add total shipping amout only if reduction amount > total shipping
- if ($voucher->free_shipping == 1 && $voucher->reduction_amount >= $order->total_shipping_tax_excl) {
- $voucher->reduction_amount -= $order->total_shipping_tax_excl;
- }
- }
- if ($voucher->reduction_amount <= 0) {
- continue;
- }
-
- if ($this->context->customer->isGuest()) {
- $voucher->id_customer = 0;
- } else {
- $voucher->id_customer = $order->id_customer;
- }
-
- $voucher->quantity = 1;
- $voucher->reduction_currency = $order->id_currency;
- $voucher->quantity_per_user = 1;
- $voucher->free_shipping = 0;
- if ($voucher->add()) {
- // If the voucher has conditions, they are now copied to the new voucher
- CartRule::copyConditions($cart_rule['obj']->id, $voucher->id);
- if ($send_mails) {
- $params = array(
- '{voucher_amount}' => Tools::displayPrice($voucher->reduction_amount, $this->context->currency, false),
- '{voucher_num}' => $voucher->code,
- '{firstname}' => $this->context->customer->firstname,
- '{lastname}' => $this->context->customer->lastname,
- '{id_order}' => $order->reference,
- '{order_name}' => $order->getUniqReference()
- );
- Mail::Send(
- (int)$order->id_lang,
- 'voucher',
- sprintf(Mail::l('New voucher for your order %s', (int)$order->id_lang), $order->reference),
- $params,
- $this->context->customer->email,
- $this->context->customer->firstname.' '.$this->context->customer->lastname,
- null, null, null, null, _PS_MAIL_DIR_, false, (int)$order->id_shop
- );
- }
+ $used['incl'] = $orderTotals[$order->id]['incl'];
+ $used['excl'] = $orderTotals[$order->id]['excl'];
}
+ $orderTotals[$order->id]['incl'] -= $used['incl'];
+ $orderTotals[$order->id]['excl'] -= $used['excl'];
+ $cart_rules[$key]['remaining'] -= $used['excl'];
}
$order->addCartRule($cart_rule['obj']->id, $cart_rule['obj']->name, $values, 0, $cart_rule['obj']->free_shipping);
@@ -1423,6 +1377,85 @@ abstract class PaymentModuleCore extends Module
}
} // End foreach $order_detail_list
+ if (count($cart_rules)) {
+ foreach ($cart_rules as $idCartRule => $cartRule) {
+
+ if ($cartRule['remaining'] > 0 && $cartRule['obj']->partial_use == 1) {
+ // IF
+ // The value of the voucher is greater than the used value
+ // Partial use is allowed
+ // This is an "amount" reduction, not a reduction in % or a gift
+ // THEN
+ // The voucher is cloned with a new value corresponding to the remainder
+
+ // Create a new voucher from the original
+ $voucher = new CartRule((int)$cartRule['obj']->id); // We need to instantiate the CartRule without lang parameter to allow saving it
+ unset($voucher->id);
+
+ // Set a new voucher code
+ // For a customer, applying voucher ABCD will create partial vouchers ABCD-2, ABCD-3 and so on, and
+ // applying voucher ABCD-2 will create vouchers ABCD-2-2, ABCD-2-3 and so on
+ $voucher->code = empty($voucher->code) ? substr(md5($order->id.'-'.$order->id_customer.'-'.$cartRule['obj']->id), 0, 16) : $voucher->code.'-2';
+ while (CartRule::cartRuleExists($voucher->code, $order->id_customer)) {
+ if (preg_match('/\-([0-9]{1,2})$/', $voucher->code, $matches)) {
+ $voucher->code = preg_replace('/'.$matches[1].'$/', (intval($matches[1]) + 1), $voucher->code);
+ }
+ }
+
+ // Set the new voucher value
+ $voucher->reduction_amount = $cartRule['remaining'];
+ if ($voucher->reduction_tax) {
+ // Add total shipping amout only if reduction amount > total shipping
+ if ($voucher->free_shipping == 1 && $voucher->reduction_amount >= $order->total_shipping_tax_incl) {
+ $voucher->reduction_amount -= $order->total_shipping_tax_incl;
+ }
+ } else {
+ // Add total shipping amout only if reduction amount > total shipping
+ if ($voucher->free_shipping == 1 && $voucher->reduction_amount >= $order->total_shipping_tax_excl) {
+ $voucher->reduction_amount -= $order->total_shipping_tax_excl;
+ }
+ }
+ if ($voucher->reduction_amount <= 0) {
+ continue;
+ }
+
+ if ($this->context->customer->isGuest()) {
+ $voucher->id_customer = 0;
+ } else {
+ $voucher->id_customer = $order->id_customer;
+ }
+
+ $voucher->quantity = 1;
+ $voucher->reduction_currency = $order->id_currency;
+ $voucher->quantity_per_user = 1;
+ $voucher->free_shipping = 0;
+ if ($voucher->add()) {
+ // If the voucher has conditions, they are now copied to the new voucher
+ CartRule::copyConditions($cartRule['obj']->id, $voucher->id);
+ if ($send_mails) {
+ $params = array(
+ '{voucher_amount}' => Tools::displayPrice($voucher->reduction_amount, $this->context->currency, false),
+ '{voucher_num}' => $voucher->code,
+ '{firstname}' => $this->context->customer->firstname,
+ '{lastname}' => $this->context->customer->lastname,
+ '{id_order}' => $order->reference,
+ '{order_name}' => $order->getUniqReference()
+ );
+ Mail::Send(
+ (int)$order->id_lang,
+ 'voucher',
+ sprintf(Mail::l('New voucher for your order %s', (int)$order->id_lang), $order->reference),
+ $params,
+ $this->context->customer->email,
+ $this->context->customer->firstname.' '.$this->context->customer->lastname,
+ null, null, null, null, _PS_MAIL_DIR_, false, (int)$order->id_shop
+ );
+ }
+ }
+ }
+ }
+ }
+
// Use the last order as currentOrder
if (isset($order) && $order->id) {
$this->currentOrder = (int)$order->id;
diff --git a/classes/Product.php b/classes/Product.php
index 862dd457d..3dcade6be 100644
--- a/classes/Product.php
+++ b/classes/Product.php
@@ -357,7 +357,7 @@ class ProductCore extends ObjectModel
),
'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isCatalogName', 'required' => true, 'size' => 128),
'description' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml'),
- 'description_short' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml'),
+ 'description_short' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isCleanHtml'),
'available_now' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255),
'available_later' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'IsGenericName', 'size' => 255),
),
diff --git a/classes/controller/AdminController.php b/classes/controller/AdminController.php
index 876652420..0ddbf4894 100644
--- a/classes/controller/AdminController.php
+++ b/classes/controller/AdminController.php
@@ -320,6 +320,9 @@ class AdminControllerCore extends Controller
/** @var string */
protected $display;
+ /** @var array */
+ public $kpis = array();
+
/** @var bool */
protected $_includeContainer = true;
@@ -2682,6 +2685,24 @@ class AdminControllerCore extends Controller
public function renderKpis()
{
+ Hook::exec('action'.$this->controller_name.'KPIListingModifier', array(
+ 'kpis' => &$this->kpis,
+ ));
+
+ if (count($this->kpis)) {
+ foreach ($this->kpis as $key => &$kpi) {
+ if (count($kpi->exclude_id_hotels)) {
+ if (empty($kpi->id_hotels)) {
+ $kpi->id_hotels = HotelBranchInformation::getProfileAccessedHotels($this->context->employee->id_profile, 1, 1);
+ }
+ $kpi->id_hotels = array_diff($kpi->id_hotels, $kpi->exclude_id_hotels);
+ }
+ }
+
+ $helper = new HelperKpiRow();
+ $helper->kpis = $this->kpis;
+ return $helper->generate();
+ }
}
/**
diff --git a/classes/helper/HelperKpi.php b/classes/helper/HelperKpi.php
index 179ac3045..927c19b37 100644
--- a/classes/helper/HelperKpi.php
+++ b/classes/helper/HelperKpi.php
@@ -38,6 +38,8 @@ class HelperKpiCore extends Helper
public $value;
public $data;
public $source;
+ public $id_hotels = false;
+ public $exclude_id_hotels = array();
public $href;
public $target;
public $tooltip;
@@ -57,6 +59,8 @@ class HelperKpiCore extends Helper
'value' => $this->value,
'data' => $this->data,
'source' => $this->source,
+ 'id_hotels' => $this->id_hotels,
+ 'exclude_id_hotels' => $this->exclude_id_hotels,
'href' => $this->href,
'target' => $this->target,
'tooltip' => $this->tooltip,
diff --git a/controllers/admin/AdminCartsController.php b/controllers/admin/AdminCartsController.php
index 7a53139cd..088f365a5 100644
--- a/controllers/admin/AdminCartsController.php
+++ b/controllers/admin/AdminCartsController.php
@@ -197,7 +197,7 @@ class AdminCartsControllerCore extends AdminController
$helper->data = ConfigurationKPI::get('CONVERSION_RATE_CHART');
}
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=conversion_rate';
- $kpis[] = $helper;
+ $this->kpis[] = $helper;
$helper = new HelperKpi();
$helper->id = 'box-carts';
@@ -209,7 +209,7 @@ class AdminCartsControllerCore extends AdminController
$helper->subtitle = sprintf($this->l('From %s to %s', null, null, false), $date_from, $date_to);
$helper->href = $this->context->link->getAdminLink('AdminCarts').'&action=filterOnlyAbandonedCarts&date_from='.$date_from.'&date_to='.$date_to;
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=abandoned_cart';
- $kpis[] = $helper;
+ $this->kpis[] = $helper;
$daysForAvgOrderVal = Configuration::get('PS_ORDER_KPI_AVG_ORDER_VALUE_NB_DAYS');
$helper = new HelperKpi();
@@ -219,7 +219,7 @@ class AdminCartsControllerCore extends AdminController
$helper->title = $this->l('Average Order Value', null, null, false);
$helper->subtitle = $daysForAvgOrderVal.' '.$this->l('days', null, null, false);
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=average_order_value';
- $kpis[] = $helper;
+ $this->kpis[] = $helper;
$daysForProfitPerVisitor = Configuration::get('PS_ORDER_KPI_PER_VISITOR_PROFIT_NB_DAYS');
$helper = new HelperKpi();
@@ -229,15 +229,9 @@ class AdminCartsControllerCore extends AdminController
$helper->title = $this->l('Net Profit per Visitor', null, null, false);
$helper->subtitle = $daysForProfitPerVisitor.' '.$this->l('days', null, null, false);
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=netprofit_visit';
- $kpis[] = $helper;
+ $this->kpis[] = $helper;
- Hook::exec('action'.$this->controller_name.'KPIListingModifier', array(
- 'kpis' => &$kpis,
- ));
-
- $helper = new HelperKpiRow();
- $helper->kpis = $kpis;
- return $helper->generate();
+ return parent::renderKpis();
}
diff --git a/controllers/admin/AdminCustomerThreadsController.php b/controllers/admin/AdminCustomerThreadsController.php
index c7a52fc5e..ac4ad3670 100644
--- a/controllers/admin/AdminCustomerThreadsController.php
+++ b/controllers/admin/AdminCustomerThreadsController.php
@@ -524,7 +524,7 @@ class AdminCustomerThreadsControllerCore extends AdminController
$helper->color = 'color1';
$helper->title = $this->l('Pending Discussion Threads', null, null, false);
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=pending_messages';
- $kpis[] = $helper;
+ $this->kpis[] = $helper;
$helper = new HelperKpi();
$helper->id = 'box-age';
@@ -533,7 +533,7 @@ class AdminCustomerThreadsControllerCore extends AdminController
$helper->title = $this->l('Average Response Time', null, null, false);
$helper->subtitle = $this->l('30 days', null, null, false);
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=avg_msg_response_time';
- $kpis[] = $helper;
+ $this->kpis[] = $helper;
$helper = new HelperKpi();
$helper->id = 'box-messages-per-thread';
@@ -542,15 +542,9 @@ class AdminCustomerThreadsControllerCore extends AdminController
$helper->title = $this->l('Messages per Thread', null, null, false);
$helper->subtitle = $this->l('30 day', null, null, false);
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=messages_per_thread';
- $kpis[] = $helper;
+ $this->kpis[] = $helper;
- Hook::exec('action'.$this->controller_name.'KPIListingModifier', array(
- 'kpis' => &$kpis,
- ));
-
- $helper = new HelperKpiRow();
- $helper->kpis = $kpis;
- return $helper->generate();
+ return parent::renderKpis();
}
public function renderView()
diff --git a/controllers/admin/AdminCustomersController.php b/controllers/admin/AdminCustomersController.php
index d97241a3b..ae8553e62 100644
--- a/controllers/admin/AdminCustomersController.php
+++ b/controllers/admin/AdminCustomersController.php
@@ -709,7 +709,7 @@ class AdminCustomersControllerCore extends AdminController
$helper->subtitle = $this->l('All Time', null, null, false);
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=orders_per_customer';
$helper->tooltip = $this->l('The average number of orders placed per customer in given period of time.', null, null, false);
- $kpis[] = $helper;
+ $this->kpis[] = $helper;
$helper = new HelperKpi();
$helper->id = 'box-total-frequent-customers';
@@ -720,7 +720,7 @@ class AdminCustomersControllerCore extends AdminController
$helper->href = $this->context->link->getAdminLink('AdminCustomers').'&submitFiltercustomer=1&customerFilter_total_orders%5B0%5D='.Configuration::get('PS_KPI_FREQUENT_CUSTOMER_NB_ORDERS').'&customerFilter_o%21date_add%5B0%5D='.date('Y-m-d', strtotime('-365 day')).'&customerFilter_o%21date_add%5B1%5D='.date('Y-m-d');
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=total_frequent_customers';
$helper->tooltip = $this->l('The total number of frequent customers in given period of time.', null, null, false);
- $kpis[] = $helper;
+ $this->kpis[] = $helper;
$helper = new HelperKpi();
$helper->id = 'box-revenue-per-available-customer';
@@ -731,7 +731,7 @@ class AdminCustomersControllerCore extends AdminController
$helper->subtitle = sprintf($this->l('%d Days', null, null, false), (int) $nbDaysRevPac);
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=revenue_per_available_customer';
$helper->tooltip = $this->l('Revenue per Available Customer (RevPAC) in given period of time.', null, null, false);
- $kpis[] = $helper;
+ $this->kpis[] = $helper;
$helper = new HelperKpi();
$helper->id = 'box-total-newsletter-registrations';
@@ -741,7 +741,7 @@ class AdminCustomersControllerCore extends AdminController
$helper->subtitle = $this->l('All Time', null, null, false);
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=total_newsletter_registrations';
$helper->tooltip = $this->l('The total number of newsletter registrations in given period of time.', null, null, false);
- $kpis[] = $helper;
+ $this->kpis[] = $helper;
$helper = new HelperKpi();
$helper->id = 'box-conversion-rate';
@@ -752,7 +752,7 @@ class AdminCustomersControllerCore extends AdminController
$helper->subtitle = sprintf($this->l('%d Days', null, null, false), (int) $nbDaysConversionRate);
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=conversion_rate';
$helper->tooltip = $this->l('The percentage of visitors who created a booking in given period of time.', null, null, false);
- $kpis[] = $helper;
+ $this->kpis[] = $helper;
$helper = new HelperKpi();
$helper->id = 'box-total-new-customers';
@@ -766,7 +766,7 @@ class AdminCustomersControllerCore extends AdminController
$helper->subtitle = sprintf($this->l('%d Days', null, null, false), (int) $nbDaysNewCustomers);
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=total_new_customers';
$helper->tooltip = $this->l('The total number of new customers who registered in given period of time.', null, null, false);
- $kpis[] = $helper;
+ $this->kpis[] = $helper;
$helper = new HelperKpi();
$helper->id = 'box-total-banned-customers';
@@ -777,7 +777,7 @@ class AdminCustomersControllerCore extends AdminController
$helper->href = $this->context->link->getAdminLink('AdminCustomers').'&customerFilter_deleted=1';
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=total_banned_customers';
$helper->tooltip = $this->l('The total number of banned customers.', null, null, false);
- $kpis[] = $helper;
+ $this->kpis[] = $helper;
$helper = new HelperKpi();
$helper->id = 'box-gender';
@@ -787,15 +787,9 @@ class AdminCustomersControllerCore extends AdminController
$helper->subtitle = $this->l('All Time', null, null, false);
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=customer_main_gender';
$helper->tooltip = $this->l('The main gender from all the customers.', null, null, false);
- $kpis[] = $helper;
+ $this->kpis[] = $helper;
- Hook::exec('action'.$this->controller_name.'KPIListingModifier', array(
- 'kpis' => &$kpis,
- ));
-
- $helper = new HelperKpiRow();
- $helper->kpis = $kpis;
- return $helper->generate();
+ return parent::renderKpis();
}
public function renderView()
diff --git a/controllers/admin/AdminModulesController.php b/controllers/admin/AdminModulesController.php
index a71362676..bfba269ae 100644
--- a/controllers/admin/AdminModulesController.php
+++ b/controllers/admin/AdminModulesController.php
@@ -1333,7 +1333,7 @@ class AdminModulesControllerCore extends AdminController
$helper->color = 'color1';
$helper->title = $this->l('Installed Modules', null, null, false);
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=installed_modules';
- $kpis[] = $helper;
+ $this->kpis[] = $helper;
$helper = new HelperKpi();
$helper->id = 'box-disabled-modules';
@@ -1341,7 +1341,7 @@ class AdminModulesControllerCore extends AdminController
$helper->color = 'color2';
$helper->title = $this->l('Disabled Modules', null, null, false);
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=disabled_modules';
- $kpis[] = $helper;
+ $this->kpis[] = $helper;
$helper = new HelperKpi();
$helper->id = 'box-update-modules';
@@ -1349,15 +1349,9 @@ class AdminModulesControllerCore extends AdminController
$helper->color = 'color3';
$helper->title = $this->l('Modules to Update', null, null, false);
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=update_modules';
- $kpis[] = $helper;
+ $this->kpis[] = $helper;
- Hook::exec('action'.$this->controller_name.'KPIListingModifier', array(
- 'kpis' => &$kpis,
- ));
-
- $helper = new HelperKpiRow();
- $helper->kpis = $kpis;
- return $helper->generate();
+ return parent::renderKpis();
}
public function initModal()
diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php
index 8fcf9b0b6..c2f6605ea 100644
--- a/controllers/admin/AdminOrdersController.php
+++ b/controllers/admin/AdminOrdersController.php
@@ -2384,7 +2384,7 @@ class AdminOrdersControllerCore extends AdminController
$helper->title = $this->l('Order Date');
$helper->tooltip = $this->l('The date when the order was placed.');
$helper->value = Tools::displayDate($objOrder->date_add);
- $kpis[] = $helper;
+ $this->kpis[] = $helper;
$helper = new HelperKpi();
$helper->id = 'box-order-total';
@@ -2393,7 +2393,7 @@ class AdminOrdersControllerCore extends AdminController
$helper->title = $this->l('Bookings Total');
$helper->tooltip = $this->l('Total booking amount of this order.');
$helper->value = Tools::displayPrice($objOrder->total_paid_tax_incl, new Currency($objOrder->id_currency));
- $kpis[] = $helper;
+ $this->kpis[] = $helper;
$helper = new HelperKpi();
$helper->id = 'box-total-paid';
@@ -2402,7 +2402,7 @@ class AdminOrdersControllerCore extends AdminController
$helper->title = $this->l('Total Paid');
$helper->tooltip = $this->l('Total paid is the amount which customer has already paid for this order.');
$helper->value = Tools::displayPrice($objOrder->total_paid_real, new Currency($objOrder->id_currency));
- $kpis[] = $helper;
+ $this->kpis[] = $helper;
$helper = new HelperKpi();
$helper->id = 'box-total-due';
@@ -2411,7 +2411,7 @@ class AdminOrdersControllerCore extends AdminController
$helper->title = $this->l('Total Due');
$helper->tooltip = $this->l('Total due is the amount which customer has to pay for this order.');
$helper->value = Tools::displayPrice(($objOrder->total_paid_tax_incl - $objOrder->total_paid_real), new Currency($objOrder->id_currency));
- $kpis[] = $helper;
+ $this->kpis[] = $helper;
$orderHistory = array_reverse($objOrder->getHistory($this->context->language->id));
$helper = new HelperKpi();
@@ -2422,7 +2422,7 @@ class AdminOrdersControllerCore extends AdminController
$helper->tooltip = $this->l('Order source shows from which source the order was placed.');
$helper->subtitle = $orderHistory[0]['id_employee'] ? $this->l('Back office') : $this->l('Front office');
$helper->value = $objOrder->source;
- $kpis[] = $helper;
+ $this->kpis[] = $helper;
$helper = new HelperKpi();
$helper->id = 'box-messages';
@@ -2432,7 +2432,7 @@ class AdminOrdersControllerCore extends AdminController
$helper->tooltip = $this->l('Messages is the number of customer messages for this order.');
$helper->href = $this->context->link->getAdminLink('AdminCustomerThreads').'&id_order='.$objOrder->id;
$helper->value = count(CustomerThread::getCustomerMessages($objOrder->id_customer, null, $objOrder->id));
- $kpis[] = $helper;
+ $this->kpis[] = $helper;
$objHotelBookingDetail = new HotelBookingDetail();
$numRooms = count($objHotelBookingDetail->getBookingDataByOrderId($objOrder->id));
@@ -2444,7 +2444,7 @@ class AdminOrdersControllerCore extends AdminController
$helper->tooltip = $this->l('Total rooms is the number of rooms booked in this order.');
$helper->href = '#start_products';
$helper->value = $numRooms;
- $kpis[] = $helper;
+ $this->kpis[] = $helper;
$helper = new HelperKpi();
$helper->id = 'box-payment-type';
@@ -2453,7 +2453,7 @@ class AdminOrdersControllerCore extends AdminController
$helper->title = $this->l('Payment Type');
$helper->tooltip = $this->l('The payment type refers to the type of payment that customer selected while placing this order.');
$helper->value = $objOrder->is_advance_payment ? $this->l('Partial Payment') : $this->l('Full Payment');
- $kpis[] = $helper;
+ $this->kpis[] = $helper;
if ($objOrder->is_advance_payment) {
$helper = new HelperKpi();
@@ -2463,7 +2463,7 @@ class AdminOrdersControllerCore extends AdminController
$helper->title = $this->l('Partial Payment Amount');
$helper->tooltip = $this->l('Partial payment amount refers to the amount that customer has to pay as advance payment, if payment type selected as partial payment while placing this order.');
$helper->value = Tools::displayPrice($objOrder->advance_paid_amount, new Currency($objOrder->id_currency));
- $kpis[] = $helper;
+ $this->kpis[] = $helper;
}
$objOrderReturn = new OrderReturn();
@@ -2476,7 +2476,7 @@ class AdminOrdersControllerCore extends AdminController
$helper->title = $this->l('Refunded Amount');
$helper->tooltip = $this->l('Refunded amount refers to the amount that has been refunded for this order.');
$helper->value = Tools::displayPrice($refundedAmount, new Currency($objOrder->id_currency));
- $kpis[] = $helper;
+ $this->kpis[] = $helper;
}
} else {
$time = time();
@@ -2489,7 +2489,7 @@ class AdminOrdersControllerCore extends AdminController
$helper->title = $this->l('Total Sales', null, null, false);
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=total_sales';
$helper->tooltip = $this->l('Total sales/revenue of all the orders created.', null, null, false);
- $kpis[] = $helper;
+ $this->kpis[] = $helper;
$helper = new HelperKpi();
$helper->id = 'box-total-due-amount';
@@ -2499,7 +2499,7 @@ class AdminOrdersControllerCore extends AdminController
$helper->href = $this->context->link->getAdminLink('AdminOrders').'&submitResetorder=1&due_amount_orders=1';
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=total_due_amount';
$helper->tooltip = $this->l('Total due amount of all the orders created.', null, null, false);
- $kpis[] = $helper;
+ $this->kpis[] = $helper;
$arivalDate = date('Y-m-d');
$helper = new HelperKpi();
@@ -2511,7 +2511,7 @@ class AdminOrdersControllerCore extends AdminController
$helper->href = $this->context->link->getAdminLink('AdminOrders').'&orders_arrival_today=1';
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=today_arrivals';
$helper->tooltip = $this->l('Total number of arrivals for today.', null, null, false);
- $kpis[] = $helper;
+ $this->kpis[] = $helper;
$departureDate = date('Y-m-d');
$helper = new HelperKpi();
@@ -2523,7 +2523,7 @@ class AdminOrdersControllerCore extends AdminController
$helper->href = $this->context->link->getAdminLink('AdminOrders').'&orders_departures_today=1';
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=today_departures';
$helper->tooltip = $this->l('Total number of departures for today.', null, null, false);
- $kpis[] = $helper;
+ $this->kpis[] = $helper;
$dateFrom = date('Y-m-d');
$dateTo = date('Y-m-d', strtotime('+1 day'));
@@ -2536,7 +2536,7 @@ class AdminOrdersControllerCore extends AdminController
$helper->href = $this->context->link->getAdminLink('AdminOrders').'&orders_stay_over=1';
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=today_stay_over';
$helper->tooltip = $this->l('Total number of stay overs for today.', null, null, false);
- $kpis[] = $helper;
+ $this->kpis[] = $helper;
$helper = new HelperKpi();
$helper->id = 'box-carts';
@@ -2549,7 +2549,7 @@ class AdminOrdersControllerCore extends AdminController
$helper->href = $this->context->link->getAdminLink('AdminCarts').'&action=filterOnlyAbandonedCarts&date_from='.$dateFrom.'&date_to='.$dateTo;
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=abandoned_cart';
$helper->tooltip = $this->l('Total number of abandoned carts in given period of time.', null, null, false);
- $kpis[] = $helper;
+ $this->kpis[] = $helper;
$daysForConversionRate = Configuration::get('PS_KPI_CONVERSION_RATE_NB_DAYS');
$helper = new HelperKpi();
@@ -2560,7 +2560,7 @@ class AdminOrdersControllerCore extends AdminController
$helper->subtitle = $daysForConversionRate.' '.$this->l('days', null, null, false);
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=conversion_rate';
$helper->tooltip = $this->l('Percentage of visits that resulted in an order/booking in given period of time.', null, null, false);
- $kpis[] = $helper;
+ $this->kpis[] = $helper;
$daysForAvgOrderVal = Configuration::get('PS_ORDER_KPI_AVG_ORDER_VALUE_NB_DAYS');
$helper = new HelperKpi();
@@ -2571,7 +2571,7 @@ class AdminOrdersControllerCore extends AdminController
$helper->subtitle = $daysForAvgOrderVal.' '.$this->l('days', null, null, false);
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=average_order_value';
$helper->tooltip = $this->l('Total average order value without tax in given period of time.', null, null, false);
- $kpis[] = $helper;
+ $this->kpis[] = $helper;
$helper = new HelperKpi();
$helper->id = 'box-average-lead-time';
@@ -2580,7 +2580,7 @@ class AdminOrdersControllerCore extends AdminController
$helper->title = $this->l('Average Lead Time', null, null, false);
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=average_lead_time';
$helper->tooltip = $this->l('Average number of days between the time guests book their rooms and the time guest schedule to arrive at the hotel.', null, null, false);
- $kpis[] = $helper;
+ $this->kpis[] = $helper;
$helper = new HelperKpi();
$helper->id = 'box-average-guest-in-booking';
@@ -2589,16 +2589,14 @@ class AdminOrdersControllerCore extends AdminController
$helper->title = $this->l('Average Guest Per Booking', null, null, false);
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=average_guest_in_booking';
$helper->tooltip = $this->l('Average number of guests per booking.', null, null, false);
- $kpis[] = $helper;
+ $this->kpis[] = $helper;
}
Hook::exec('action'.$this->controller_name.'KPIListingModifier', array(
'kpis' => &$kpis,
));
- $helper = new HelperKpiRow();
- $helper->kpis = $kpis;
- return $helper->generate();
+ return parent::renderKpis();
}
public function renderView()
@@ -5039,11 +5037,15 @@ class AdminOrdersControllerCore extends AdminController
$newTotalPriceTaxExcl = $newNumDays * $objRoomTypeServiceProductOrderDetail->quantity * $unitPriceTaxExcl; $unitPriceTaxIncl = $objRoomTypeServiceProductOrderDetail->unit_price_tax_incl;
$newTotalPriceTaxIncl = $newNumDays * $objRoomTypeServiceProductOrderDetail->quantity * $unitPriceTaxIncl;
+ $objOrder->total_products -= $objRoomTypeServiceProductOrderDetail->total_price_tax_excl;
+ $objOrder->total_products_wt -= $objRoomTypeServiceProductOrderDetail->total_price_tax_incl;
$objOrder->total_paid_tax_excl -= $objRoomTypeServiceProductOrderDetail->total_price_tax_excl;
$objOrder->total_paid_tax_incl -= $objRoomTypeServiceProductOrderDetail->total_price_tax_incl;
$objOrder->total_paid -= $objRoomTypeServiceProductOrderDetail->total_price_tax_incl;
// change order total
+ $objOrder->total_products += $newTotalPriceTaxExcl;
+ $objOrder->total_products_wt += $newTotalPriceTaxIncl;
$objOrder->total_paid_tax_excl += $newTotalPriceTaxExcl;
$objOrder->total_paid_tax_incl += $newTotalPriceTaxIncl;
$objOrder->total_paid += $newTotalPriceTaxIncl;
@@ -6309,6 +6311,8 @@ class AdminOrdersControllerCore extends AdminController
$res &= $order_invoice->update();
}
+ $order->total_products += $priceDiffTaxExcl;
+ $order->total_products_wt += $priceDiffTaxIncl;
$order->total_paid_tax_excl += $priceDiffTaxExcl;
$order->total_paid_tax_incl += $priceDiffTaxIncl;
$order->total_paid += $priceDiffTaxIncl;
@@ -6374,6 +6378,8 @@ class AdminOrdersControllerCore extends AdminController
$res &= $objOrderInvoice->update();
}
+ $order->total_products -= $priceTaxExcl;
+ $order->total_products_wt -= $priceTaxIncl;
$order->total_paid_tax_excl -= $priceTaxExcl;
$order->total_paid_tax_incl -= $priceTaxIncl;
$order->total_paid -= $priceTaxIncl;
diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php
index 6b58c036b..c0c47c968 100644
--- a/controllers/admin/AdminProductsController.php
+++ b/controllers/admin/AdminProductsController.php
@@ -2457,7 +2457,6 @@ class AdminProductsControllerCore extends AdminController
public function renderKpis()
{
$time = time();
- $kpis = array();
$helper = new HelperKpi();
$helper->id = 'box-total-rooms';
@@ -2467,7 +2466,7 @@ class AdminProductsControllerCore extends AdminController
$helper->subtitle = $this->l('Today', null, null, false);
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=total_rooms';
$helper->tooltip = $this->l('The total number of rooms in all hotels.', null, null, false);
- $kpis[] = $helper;
+ $this->kpis[] = $helper;
$helper = new HelperKpi();
$helper->id = 'box-occupied-rooms';
@@ -2477,7 +2476,7 @@ class AdminProductsControllerCore extends AdminController
$helper->subtitle = $this->l('Today', null, null, false);
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=occupied_rooms';
$helper->tooltip = $this->l('The count of rooms that are currently occupied by guests.', null, null, false);
- $kpis[] = $helper;
+ $this->kpis[] = $helper;
$helper = new HelperKpi();
$helper->id = 'box-vacant-rooms';
@@ -2487,7 +2486,7 @@ class AdminProductsControllerCore extends AdminController
$helper->subtitle = $this->l('Today', null, null, false);
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=vacant_rooms';
$helper->tooltip = $this->l('The count of rooms that are either booked but currently unoccupied or available for booking', null, null, false);
- $kpis[] = $helper;
+ $this->kpis[] = $helper;
$helper = new HelperKpi();
$helper->id = 'box-reserved-rooms';
@@ -2497,7 +2496,7 @@ class AdminProductsControllerCore extends AdminController
$helper->subtitle = $this->l('Today', null, null, false);
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=booked_rooms';
$helper->tooltip = $this->l('The total number of rooms that are currently booked and and awaiting guest check-in', null, null, false);
- $kpis[] = $helper;
+ $this->kpis[] = $helper;
$helper = new HelperKpi();
$helper->id = 'box-disabled-rooms';
@@ -2507,7 +2506,7 @@ class AdminProductsControllerCore extends AdminController
$helper->subtitle = $this->l('Today', null, null, false);
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=disabled_rooms';
$helper->tooltip = $this->l('The total number of rooms that are currently disabled.', null, null, false);
- $kpis[] = $helper;
+ $this->kpis[] = $helper;
$helper = new HelperKpi();
$helper->id = 'box-online-bookable-rooms';
@@ -2517,7 +2516,7 @@ class AdminProductsControllerCore extends AdminController
$helper->subtitle = $this->l('Today', null, null, false);
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=online_bookable_rooms';
$helper->tooltip = $this->l('The total number of rooms that can be booked directly from the front office.', null, null, false);
- $kpis[] = $helper;
+ $this->kpis[] = $helper;
$helper = new HelperKpi();
$helper->id = 'box-offline-bookable-rooms';
@@ -2527,7 +2526,7 @@ class AdminProductsControllerCore extends AdminController
$helper->subtitle = $this->l('Today', null, null, false);
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=offline_bookable_rooms';
$helper->tooltip = $this->l('The total number of rooms available for booking through the back office.', null, null, false);
- $kpis[] = $helper;
+ $this->kpis[] = $helper;
$helper = new HelperKpi();
$helper->id = 'box-best-selling-room-type';
@@ -2538,7 +2537,7 @@ class AdminProductsControllerCore extends AdminController
$helper->subtitle = sprintf($this->l('%d Days', null, null, false), (int) $nbDaysBestSelling);
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=best_selling_room_type';
$helper->tooltip = $this->l('Displays the best selling room type based on the last 30 days of sales.', null, null, false);
- $kpis[] = $helper;
+ $this->kpis[] = $helper;
$helper = new HelperKpi();
$helper->id = 'box-disbled-room-types';
@@ -2548,16 +2547,9 @@ class AdminProductsControllerCore extends AdminController
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=disabled_room_types';
$helper->href = Context::getContext()->link->getAdminLink('AdminProducts').'&productFilter_sa!active=0&submitFilterproduct=1';
$helper->tooltip = $this->l('The total number of room types that are currently disabled.', null, null, false);
- $kpis[] = $helper;
+ $this->kpis[] = $helper;
- Hook::exec('action'.$this->controller_name.'KPIListingModifier', array(
- 'kpis' => &$kpis,
- ));
-
- $helper = new HelperKpiRow();
- $helper->kpis = $kpis;
-
- return $helper->generate();
+ return parent::renderKpis();
}
public function renderList()
diff --git a/controllers/admin/AdminStatsController.php b/controllers/admin/AdminStatsController.php
index 94f56168f..140574201 100644
--- a/controllers/admin/AdminStatsController.php
+++ b/controllers/admin/AdminStatsController.php
@@ -226,17 +226,17 @@ class AdminStatsControllerCore extends AdminStatsTabController
if ($granularity == 'day') {
$sales = array();
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS(
- 'SELECT LEFT(`invoice_date`, 10) AS date, SUM(total_paid_tax_excl / o.conversion_rate) AS sales,
- (
- SELECT hbd.`id_hotel`
- FROM`'._DB_PREFIX_.'htl_booking_detail` hbd
- WHERE hbd.`id_order` = o.`id_order` LIMIT 1
- ) AS id_hotel
+ 'SELECT LEFT(`invoice_date`, 10) AS date, SUM(total_paid_tax_excl / o.conversion_rate) AS sales
FROM `'._DB_PREFIX_.'orders` o
LEFT JOIN `'._DB_PREFIX_.'order_state` os ON o.current_state = os.id_order_state
- WHERE os.logable = 1'. (($date_from && $date_to) ? ' AND `invoice_date` BETWEEN "'.pSQL($date_from).' 00:00:00" AND "'.pSQL($date_to).' 23:59:59"' : '').' GROUP BY LEFT(`invoice_date`, 10) HAVING 1 '.HotelBranchInformation::addHotelRestriction($id_hotel)
+ WHERE os.logable = 1'. (($date_from && $date_to) ? ' AND `invoice_date` BETWEEN "'.pSQL($date_from).' 00:00:00" AND "'.pSQL($date_to).' 23:59:59"' : '').'
+ AND EXISTS (
+ SELECT 1
+ FROM `qlo_htl_booking_detail` hbd
+ WHERE hbd.`id_order` = o.`id_order`' . HotelBranchInformation::addHotelRestriction($idHotel).'
+ )
+ GROUP BY LEFT(`invoice_date`, 10)'
);
-
foreach ($result as $row) {
$sales[strtotime($row['date'])] = $row['sales'];
}
@@ -244,15 +244,16 @@ class AdminStatsControllerCore extends AdminStatsTabController
} elseif ($granularity == 'month') {
$sales = array();
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS(
- 'SELECT LEFT(`invoice_date`, 7) AS date, SUM(total_paid_tax_excl / o.conversion_rate) AS sales,
- (
- SELECT hbd.`id_hotel`
- FROM`'._DB_PREFIX_.'htl_booking_detail` hbd
- WHERE hbd.`id_order` = o.`id_order` LIMIT 1
- ) AS id_hotel
+ 'SELECT LEFT(`invoice_date`, 7) AS date, SUM(total_paid_tax_excl / o.conversion_rate) AS sales
FROM `'._DB_PREFIX_.'orders` o
LEFT JOIN `'._DB_PREFIX_.'order_state` os ON o.current_state = os.id_order_state
- WHERE os.logable = 1'. (($date_from && $date_to) ? ' AND `invoice_date` BETWEEN "'.pSQL($date_from).' 00:00:00" AND "'.pSQL($date_to).' 23:59:59"' : '').' GROUP BY LEFT(`invoice_date`, 7) HAVING 1 '.HotelBranchInformation::addHotelRestriction($id_hotel)
+ WHERE os.logable = 1'. (($date_from && $date_to) ? ' AND `invoice_date` BETWEEN "'.pSQL($date_from).' 00:00:00" AND "'.pSQL($date_to).' 23:59:59"' : '').'
+ AND EXISTS (
+ SELECT 1
+ FROM `qlo_htl_booking_detail` hbd
+ WHERE hbd.`id_order` = o.`id_order`' . HotelBranchInformation::addHotelRestriction($idHotel).'
+ )
+ GROUP BY LEFT(`invoice_date`, 7)'
);
foreach ($result as $row) {
@@ -262,15 +263,16 @@ class AdminStatsControllerCore extends AdminStatsTabController
return $sales;
} else {
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue(
- 'SELECT SUM(total_paid_tax_excl / o.conversion_rate),
- (
- SELECT hbd.`id_hotel`
- FROM`'._DB_PREFIX_.'htl_booking_detail` hbd
- WHERE hbd.`id_order` = o.`id_order` LIMIT 1
- ) AS id_hotel
+ 'SELECT SUM(total_paid_tax_excl / o.`conversion_rate`), t.`id_hotel`
FROM `'._DB_PREFIX_.'orders` o
LEFT JOIN `'._DB_PREFIX_.'order_state` os ON o.current_state = os.id_order_state
- WHERE os.logable = 1'. (($date_from && $date_to) ? ' AND `invoice_date` BETWEEN "'.pSQL($date_from).' 00:00:00" AND "'.pSQL($date_to).' 23:59:59"' : '').' HAVING 1 '.HotelBranchInformation::addHotelRestriction($id_hotel)
+ LEFT JOIN (
+ SELECT hbd.`id_hotel` as id_hotel, hbd.`id_order` as id_order
+ FROM`'._DB_PREFIX_.'htl_booking_detail` hbd
+ GROUP BY hbd.`id_order`
+ ) t ON (t.`id_order` = o.`id_order`)
+ WHERE os.logable = 1'. (($date_from && $date_to) ? ' AND `invoice_date` BETWEEN "'.pSQL($date_from).' 00:00:00" AND "'.pSQL($date_to).' 23:59:59"' : '').
+ HotelBranchInformation::addHotelRestriction($id_hotel)
);
}
}
@@ -472,7 +474,7 @@ class AdminStatsControllerCore extends AdminStatsTabController
{
if ($granularity == 'day') {
$purchases = array();
- $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
+ $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT
LEFT(`invoice_date`, 10) as date,
SUM(od.`product_quantity` * IF(
@@ -488,8 +490,13 @@ class AdminStatsControllerCore extends AdminStatsTabController
FROM `'._DB_PREFIX_.'orders` o
LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON o.id_order = od.id_order
LEFT JOIN `'._DB_PREFIX_.'order_state` os ON o.current_state = os.id_order_state
- WHERE `invoice_date` BETWEEN "'.pSQL($date_from).' 00:00:00" AND "'.pSQL($date_to).' 23:59:59" AND os.logable = 1'.'
- GROUP BY LEFT(`invoice_date`, 10) HAVING 1 '.HotelBranchInformation::addHotelRestriction($id_hotel));
+ WHERE `invoice_date` BETWEEN "'.pSQL($date_from).' 00:00:00" AND "'.pSQL($date_to).' 23:59:59"
+ AND os.logable = 1 AND EXISTS (
+ SELECT 1
+ FROM `qlo_htl_booking_detail` hbd
+ WHERE hbd.`id_order` = o.`id_order`' . HotelBranchInformation::addHotelRestriction($idHotel).'
+ )
+ GROUP BY LEFT(`invoice_date`, 10)');
foreach ($result as $row) {
$purchases[strtotime($row['date'])] = $row['total_purchase_price'];
@@ -502,16 +509,16 @@ class AdminStatsControllerCore extends AdminStatsTabController
od.`purchase_supplier_price` > 0,
od.`purchase_supplier_price`,
(od.`original_product_price` / `conversion_rate`) * '.(int)Configuration::get('CONF_AVERAGE_PRODUCT_MARGIN').' / 100
- )),
- (
- SELECT hbd.`id_hotel`
- FROM`'._DB_PREFIX_.'htl_booking_detail` hbd
- WHERE hbd.`id_order` = o.`id_order` LIMIT 1
- ) AS id_hotel
+ ))
FROM `'._DB_PREFIX_.'orders` o
LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON o.id_order = od.id_order
LEFT JOIN `'._DB_PREFIX_.'order_state` os ON o.current_state = os.id_order_state
- WHERE `invoice_date` BETWEEN "'.pSQL($date_from).' 00:00:00" AND "'.pSQL($date_to).' 23:59:59" AND os.logable = 1 HAVING 1 '.HotelBranchInformation::addHotelRestriction($id_hotel)
+ WHERE `invoice_date` BETWEEN "'.pSQL($date_from).' 00:00:00" AND "'.pSQL($date_to).' 23:59:59"
+ AND os.logable = 1 AND EXISTS (
+ SELECT 1
+ FROM `qlo_htl_booking_detail` hbd
+ WHERE hbd.`id_order` = o.`id_order`' . HotelBranchInformation::addHotelRestriction($idHotel).'
+ )'
);
}
}
@@ -520,20 +527,20 @@ class AdminStatsControllerCore extends AdminStatsTabController
{
if ($granularity == 'day') {
$refunds = array();
- $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
+ $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT
LEFT(`invoice_date`, 10) as date,
- SUM(orr.`refunded_amount`) as total_refund_amount,
- (
- SELECT hbd.`id_hotel`
- FROM`'._DB_PREFIX_.'htl_booking_detail` hbd
- WHERE hbd.`id_order` = o.`id_order` LIMIT 1
- ) AS id_hotel
+ SUM(orr.`refunded_amount`) as total_refund_amount
FROM `'._DB_PREFIX_.'orders` o
LEFT JOIN `'._DB_PREFIX_.'order_return` orr ON (o.id_order = orr.id_order)
LEFT JOIN `'._DB_PREFIX_.'order_state` os ON (o.current_state = os.id_order_state)
- WHERE orr.`payment_mode` != "" AND `invoice_date` BETWEEN "'.pSQL($date_from).' 00:00:00" AND "'.pSQL($date_to).' 23:59:59" AND os.logable = 1'.'
- GROUP BY LEFT(`invoice_date`, 10) HAVING 1 '.HotelBranchInformation::addHotelRestriction($id_hotel));
+ WHERE orr.`payment_mode` != "" AND `invoice_date` BETWEEN "'.pSQL($date_from).' 00:00:00"
+ AND "'.pSQL($date_to).' 23:59:59" AND EXISTS (
+ SELECT 1
+ FROM `qlo_htl_booking_detail` hbd
+ WHERE hbd.`id_order` = o.`id_order`' . HotelBranchInformation::addHotelRestriction($idHotel).'
+ )
+ GROUP BY LEFT(`invoice_date`, 10)');
foreach ($result as $row) {
$refunds[strtotime($row['date'])] = $row['total_refund_amount'];
@@ -551,7 +558,13 @@ class AdminStatsControllerCore extends AdminStatsTabController
FROM `'._DB_PREFIX_.'orders` o
LEFT JOIN `'._DB_PREFIX_.'order_return` orr ON (o.id_order = orr.id_order)
LEFT JOIN `'._DB_PREFIX_.'order_state` os ON (o.current_state = os.id_order_state)
- WHERE orr.`payment_mode` != "" AND orr.`id_transaction` != "" AND `invoice_date` BETWEEN "'.pSQL($date_from).' 00:00:00" AND "'.pSQL($date_to).' 23:59:59" AND os.logable = 1 HAVING 1 '.HotelBranchInformation::addHotelRestriction($id_hotel)
+ WHERE orr.`payment_mode` != "" AND orr.`id_transaction` != ""
+ AND `invoice_date` BETWEEN "'.pSQL($date_from).' 00:00:00" AND "'.pSQL($date_to).' 23:59:59"
+ AND EXISTS (
+ SELECT 1
+ FROM `qlo_htl_booking_detail` hbd
+ WHERE hbd.`id_order` = o.`id_order`' . HotelBranchInformation::addHotelRestriction($idHotel).'
+ )'
);
}
}
@@ -633,7 +646,7 @@ class AdminStatsControllerCore extends AdminStatsTabController
public function displayAjaxGetKpi()
{
- $value = $this->getLatestKpiValue(Tools::getValue('kpi'));
+ $value = $this->getLatestKpiValue(Tools::getValue('kpi'), Tools::getValue('id_hotels'));
if ($value !== false) {
$array = array('value' => $value);
if (isset($data)) {
@@ -644,7 +657,7 @@ class AdminStatsControllerCore extends AdminStatsTabController
die(json_encode(array('has_errors' => true)));
}
- public function getLatestKpiValue($kpi)
+ public function getLatestKpiValue($kpi, $idHotels)
{
$currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
$value = false;
@@ -662,7 +675,8 @@ class AdminStatsControllerCore extends AdminStatsTabController
$orders = AdminStatsController::getOrders(
date('Y-m-d', strtotime('-'.($nbDaysConversionRate + 1).' day')),
date('Y-m-d', strtotime('-1 day')),
- false /*'day'*/
+ false /*'day'*/,
+ $idHotels
);
$visits_sum = $visitors; //array_sum($visitors);
@@ -720,7 +734,7 @@ class AdminStatsControllerCore extends AdminStatsTabController
break;
case 'disabled_room_types':
- $value = AdminStatsController::getDisabledRoomTypes(0);
+ $value = AdminStatsController::getDisabledRoomTypes($idHotels);
ConfigurationKPI::updateValue('DISABLED_ROOM_TYPES', $value);
ConfigurationKPI::updateValue('DISABLED_ROOM_TYPES_EXPIRE', strtotime('+2 hour'));
break;
@@ -824,15 +838,15 @@ class AdminStatsControllerCore extends AdminStatsTabController
$row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
SELECT
COUNT(o.`id_order`) as orders,
- SUM(o.`total_paid_tax_excl` / o.`conversion_rate`) as total_paid_tax_excl,
- (
- SELECT hbd.`id_hotel`
- FROM`'._DB_PREFIX_.'htl_booking_detail` hbd
- WHERE hbd.`id_order` = o.`id_order` LIMIT 1
- ) AS id_hotel
+ SUM(o.`total_paid_tax_excl` / o.`conversion_rate`) as total_paid_tax_excl
FROM `'._DB_PREFIX_.'orders` o
LEFT JOIN `'._DB_PREFIX_.'order_state` os ON os.`id_order_state` = o.`current_state`
- WHERE o.`invoice_date` BETWEEN "'.pSQL(date('Y-m-d', strtotime('-'.($daysForAvgOrderVal + 1).' day'))).' 00:00:00" AND "'.pSQL(date('Y-m-d', strtotime('-1 day'))).' 23:59:59" AND os.`logable` = 1 HAVING 1 '.HotelBranchInformation::addHotelRestriction(false));
+ WHERE o.`invoice_date` BETWEEN "'.pSQL(date('Y-m-d', strtotime('-'.($daysForAvgOrderVal + 1).' day'))).' 00:00:00"
+ AND "'.pSQL(date('Y-m-d')).' 23:59:59" AND os.`logable` = 1 AND EXISTS (
+ SELECT 1
+ FROM `qlo_htl_booking_detail` hbd
+ WHERE hbd.`id_order` = o.`id_order`' . HotelBranchInformation::addHotelRestriction($idHotel).'
+ )');
$value = Tools::displayPrice($row['orders'] ? $row['total_paid_tax_excl'] / $row['orders'] : 0, $currency).' ('.$this->l('tax excl.').')';
break;
@@ -844,9 +858,9 @@ class AdminStatsControllerCore extends AdminStatsTabController
$date_to = date('Y-m-d', strtotime('-1 day'));
$total_visitors = AdminStatsController::getVisits(false, $date_from, $date_to);
- $net_profits = AdminStatsController::getTotalSales($date_from, $date_to);
- $net_profits -= AdminStatsController::getExpenses($date_from, $date_to);
- $net_profits -= AdminStatsController::getPurchases($date_from, $date_to);
+ $net_profits = AdminStatsController::getTotalSales($date_from, $date_to, false, $idHotels);
+ $net_profits -= AdminStatsController::getExpenses($date_from, $date_to, false, $idHotels);
+ $net_profits -= AdminStatsController::getPurchases($date_from, $date_to, false, $idHotels);
if ($total_visitors) {
$value = Tools::displayPrice($net_profits / $total_visitors, $currency);
@@ -880,7 +894,7 @@ class AdminStatsControllerCore extends AdminStatsTabController
if (!($idProduct = AdminStatsController::getBestSellingRoomType(
date('Y-m-d', strtotime('-'.($nbDaysBestSelling + 1).' day')),
date('Y-m-d', strtotime('-1 day')),
- 0
+ $idHotels
))) {
$value = $this->l('--', null, null, false);
} else {
@@ -891,7 +905,7 @@ class AdminStatsControllerCore extends AdminStatsTabController
break;
case 'total_rooms':
- $value = AdminStatsController::getTotalRooms(0);
+ $value = AdminStatsController::getTotalRooms($idHotels);
break;
@@ -899,20 +913,20 @@ class AdminStatsControllerCore extends AdminStatsTabController
$value = AdminStatsController::getDistinctRoomBookingsCount(
date('Y-m-d', strtotime('-1 day')),
date('Y-m-d'),
- 0,
+ $idHotels,
HotelBookingDetail::STATUS_CHECKED_IN
);
break;
case 'vacant_rooms':
- $totalUnAvailRooms = AdminStatsController::getDisabledRoomsForDiscreteDates(date('Y-m-d'), null, 0);
+ $totalUnAvailRooms = AdminStatsController::getDisabledRoomsForDiscreteDates(date('Y-m-d'), null, $idHotels);
$totalUnAvailRooms = $totalUnAvailRooms[strtotime(date('Y-m-d'))];
- $totalRooms = AdminStatsController::getTotalRooms(0);
+ $totalRooms = AdminStatsController::getTotalRooms($idHotels);
$totalOccupiedRooms = AdminStatsController::getDistinctRoomBookingsCount(
date('Y-m-d', strtotime('-1 day')),
date('Y-m-d'),
- 0,
+ $idHotels,
HotelBookingDetail::STATUS_CHECKED_IN
);
$value = $totalRooms - ($totalUnAvailRooms + $totalOccupiedRooms);
@@ -923,26 +937,26 @@ class AdminStatsControllerCore extends AdminStatsTabController
$value = AdminStatsController::getDistinctRoomBookingsCount(
date('Y-m-d'),
date('Y-m-d', strtotime('+1 day')),
- 0,
+ $idHotels,
HotelBookingDetail::STATUS_ALLOTED
);
break;
case 'disabled_rooms':
- $value = AdminStatsController::getDisabledRoomsForDiscreteDates(date('Y-m-d'), null, 0);
+ $value = AdminStatsController::getDisabledRoomsForDiscreteDates(date('Y-m-d'), null, $idHotels);
$value = $value[strtotime(date('Y-m-d'))];
break;
case 'online_bookable_rooms':
- $value = AdminStatsController::getAvailableRoomsForDiscreteDates(date('Y-m-d'), null, 0, 1);
+ $value = AdminStatsController::getAvailableRoomsForDiscreteDates(date('Y-m-d'), null, $idHotels, 1);
$value = $value[strtotime(date('Y-m-d'))];
break;
case 'offline_bookable_rooms':
- $value = AdminStatsController::getAvailableRoomsForDiscreteDates(date('Y-m-d'), null, 0);
+ $value = AdminStatsController::getAvailableRoomsForDiscreteDates(date('Y-m-d'), null, $idHotels);
$value = $value[strtotime(date('Y-m-d'))];
break;
@@ -954,7 +968,7 @@ class AdminStatsControllerCore extends AdminStatsTabController
date('Y-m-d', strtotime('-365 day')),
date('Y-m-d'),
$nbOrdersFrequentCustomers,
- 0
+ $idHotels
);
break;
@@ -965,7 +979,7 @@ class AdminStatsControllerCore extends AdminStatsTabController
$value = AdminStatsController::getRevenuePerAvailableCustomer(
date('Y-m-d', strtotime('-'.($nbDaysRevPac + 1).' day')),
date('Y-m-d', strtotime('-1 day')),
- 0
+ $idHotels
);
$value = Tools::displayPrice($value, $currency);
@@ -989,7 +1003,7 @@ class AdminStatsControllerCore extends AdminStatsTabController
break;
case 'total_sales':
- $totalSales = AdminStatsController::getTotalSales('', '', false, false, 1);
+ $totalSales = AdminStatsController::getTotalSales('', '', false, $idHotels);
if ($totalSales > 0) {
$value = Tools::displayPrice($totalSales, $currency);
} else {
@@ -999,24 +1013,24 @@ class AdminStatsControllerCore extends AdminStatsTabController
case 'today_arrivals':
$dateToday = date('Y-m-d');
$value = 0;
- if ($arrivalsData = AdminStatsController::getArrivalsByDate($dateToday)) {
+ if ($arrivalsData = AdminStatsController::getArrivalsByDate($dateToday, $idHotels)) {
$value = $arrivalsData['total_arrivals'];
}
break;
case 'today_departures':
$dateToday = date('Y-m-d');
$value = 0;
- if ($departureData = AdminStatsController::getDeparturesByDate($dateToday)) {
+ if ($departureData = AdminStatsController::getDeparturesByDate($dateToday, $idHotels)) {
$value = $departureData['total_departures'];
}
break;
case 'today_stay_over':
$dateToday = date('Y-m-d');
- $value = AdminStatsController::getStayOversByDate($dateToday);
+ $value = AdminStatsController::getStayOversByDate($dateToday, $idHotels);
break;
case 'total_due_amount':
$dateToday = date('Y-m-d');
- $dueAmount = AdminStatsController::getTotalDueAmount('', '', false, 1);
+ $dueAmount = AdminStatsController::getTotalDueAmount('', '', $idHotels, 1);
if ($dueAmount > 0) {
$value = Tools::displayPrice($dueAmount, $currency);
} else {
@@ -1025,7 +1039,7 @@ class AdminStatsControllerCore extends AdminStatsTabController
break;
case 'average_lead_time':
$dateToday = date('Y-m-d');
- $value = Tools::ps_round(AdminStatsController::getAverageLeadTime(), 2);
+ $value = Tools::ps_round(AdminStatsController::getAverageLeadTime('', '', $idHotels), 2);
if ($value && $value <= 1) {
$value .= ' '.$this->l('day');
} else {
@@ -1035,7 +1049,7 @@ class AdminStatsControllerCore extends AdminStatsTabController
break;
case 'average_guest_in_booking':
$dateToday = date('Y-m-d');
- $value = AdminStatsController::getAverageGuestsPerBooking();
+ $value = AdminStatsController::getAverageGuestsPerBooking('', '', $idHotels);
$value = Tools::ps_round($value['avg_adults'], 2).''.$this->l('Adults').', '.Tools::ps_round($value['avg_children'], 2).''.$this->l('Children');
break;
default:
@@ -1893,16 +1907,15 @@ class AdminStatsControllerCore extends AdminStatsTabController
{
$sql = 'SELECT COUNT(t.`id_customer`)
FROM (
- SELECT o.`id_customer`, COUNT(o.`id_order`) AS nb_orders,
- (
- SELECT hbd.`id_hotel`
- FROM `'._DB_PREFIX_.'htl_booking_detail` hbd
- WHERE hbd.`id_order` = o.`id_order` LIMIT 1
- ) AS id_hotel
+ SELECT o.`id_customer`, COUNT(o.`id_order`) AS nb_orders
FROM `'._DB_PREFIX_.'orders` o
WHERE o.`valid` = 1 AND o.`date_add` BETWEEN "'.pSQL($dateFrom).' 00:00:00" AND "'.pSQL($dateTo).' 23:59:59"
+ AND EXISTS (
+ SELECT 1
+ FROM `qlo_htl_booking_detail` hbd
+ WHERE hbd.`id_order` = o.`id_order`' . HotelBranchInformation::addHotelRestriction($idHotel).'
+ )
GROUP BY o.`id_customer`
- HAVING 1 '.(!is_null($idHotel) ? HotelBranchInformation::addHotelRestriction($idHotel) : '').'
) AS t
WHERE t.`nb_orders` >= '.(int) $nbOrders;
$result = Db::getInstance()->getValue($sql);
@@ -2407,16 +2420,17 @@ class AdminStatsControllerCore extends AdminStatsTabController
$objHotelBooking = new HotelBookingDetail();
$invalidOrderStates = $objHotelBooking->getOrderStatusToFreeBookedRoom();
- $sql = 'SELECT (' . ($useTax ? 'SUM(o.`total_paid_tax_incl` / o.`conversion_rate`)' : 'SUM(o.`total_paid_tax_excl` / o.`conversion_rate`)') . ' - SUM(o.`total_paid_real` / o.`conversion_rate`)),
- (
- SELECT hbd.`id_hotel`
- FROM`'._DB_PREFIX_.'htl_booking_detail` hbd
- WHERE hbd.`id_order` = o.`id_order` LIMIT 1
- ) AS id_hotel
+ $sql = 'SELECT ' . ($useTax ? 'SUM(o.`total_paid_tax_incl` / o.`conversion_rate`)' : 'SUM(o.`total_paid_tax_excl` / o.`conversion_rate`)') . ' - SUM(o.`total_paid_real` / o.`conversion_rate`)
FROM `'._DB_PREFIX_.'orders` o
LEFT JOIN `'._DB_PREFIX_.'order_state` os ON o.current_state = os.id_order_state
- WHERE 1 ' . ($invalidOrderStates ? ' AND o.`current_state` NOT IN ('.implode(',', $invalidOrderStates).')' : '') . (($dateFrom && $dateTo) ? ' AND o.`date_add` BETWEEN "'.pSQL($dateFrom).' 00:00:00" AND "'.pSQL($dateTo).' 23:59:59"' : '').' HAVING 1 '.HotelBranchInformation::addHotelRestriction($idHotel);
-
+ WHERE 1 ' .
+ ($invalidOrderStates ? ' AND o.`current_state` NOT IN ('.implode(',', $invalidOrderStates).')' : '') .
+ (($dateFrom && $dateTo) ? ' AND o.`date_add` BETWEEN "'.pSQL($dateFrom).' 00:00:00" AND "'.pSQL($dateTo).' 23:59:59"' : '').
+ ' AND EXISTS (
+ SELECT 1
+ FROM `qlo_htl_booking_detail` hbd
+ WHERE hbd.`id_order` = o.`id_order`' . HotelBranchInformation::addHotelRestriction($idHotel).'
+ )';
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
}
diff --git a/controllers/admin/AdminTranslationsController.php b/controllers/admin/AdminTranslationsController.php
index e91e3cbc3..6ccc5713c 100644
--- a/controllers/admin/AdminTranslationsController.php
+++ b/controllers/admin/AdminTranslationsController.php
@@ -1374,7 +1374,7 @@ class AdminTranslationsControllerCore extends AdminController
$helper->href = $this->context->link->getAdminLink('AdminLanguages');
$helper->title = $this->l('Enabled Languages', null, null, false);
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=enabled_languages';
- $kpis[] = $helper;
+ $this->kpis[] = $helper;
$helper = new HelperKpi();
$helper->id = 'box-fo-translations';
@@ -1382,7 +1382,7 @@ class AdminTranslationsControllerCore extends AdminController
$helper->color = 'color3';
$helper->title = $this->l('Front office Translations', null, null, false);
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=frontoffice_translations';
- $kpis[] = $helper;
+ $this->kpis[] = $helper;
$helper = new HelperKpi();
$helper->id = 'box-bo-translations';
@@ -1394,15 +1394,9 @@ class AdminTranslationsControllerCore extends AdminController
}
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=backoffice_translations';
$helper->refresh = (bool)(ConfigurationKPI::get('BACKOFFICE_TRANSLATIONS_EXPIRE') < $time);
- $kpis[] = $helper;
+ $this->kpis[] = $helper;
- Hook::exec('action'.$this->controller_name.'KPIListingModifier', array(
- 'kpis' => &$kpis,
- ));
-
- $helper = new HelperKpiRow();
- $helper->kpis = $kpis;
- return $helper->generate();
+ return parent::renderKpis();
}
/**
diff --git a/js/admin/reallocation.js b/js/admin/reallocation.js
index 8306a3b3d..21846b804 100644
--- a/js/admin/reallocation.js
+++ b/js/admin/reallocation.js
@@ -72,6 +72,13 @@ const RoomReallocationModal = {
$("span.modal_curr_room_num").text(roomObj.data('room_num') + ', ' + roomObj.data('room_type_name'));
$(".cust_name").text(roomObj.data('cust_name'));
$(".cust_email").text(roomObj.data('cust_email'));
+ $(".modal_curr_allotent_type").text(roomObj.data('allotment_type_label'));
+
+ if ((roomObj.data('comment') == '') || (roomObj.data('comment') == null)) {
+ $(".allotment_comment_block").hide();
+ } else {
+ $(".modal_curr_allotment_comment").text(roomObj.data('comment'));
+ }
// reset price difference fields
$("#reallocation_price_diff").val(0);
diff --git a/modules/hotelreservationsystem/classes/HotelBranchInformation.php b/modules/hotelreservationsystem/classes/HotelBranchInformation.php
index 6a7c1bf50..e91aa93be 100644
--- a/modules/hotelreservationsystem/classes/HotelBranchInformation.php
+++ b/modules/hotelreservationsystem/classes/HotelBranchInformation.php
@@ -852,11 +852,19 @@ class HotelBranchInformation extends ObjectModel
$idProfile = Context::getContext()->employee->id_profile;
}
+ $accessedIds = self::getProfileAccessedHotels($idProfile, 1, 1);
if (!$idsHotel) {
- $idsHotel = self::getProfileAccessedHotels($idProfile, 1, 1);
+ $idsHotel = $accessedIds;
} else {
- $idsHotel = array($idsHotel);
+ if (!is_array($idsHotel)) {
+ $idsHotel = array($idsHotel);
+ }
+ // check if passed hotel id's are available for current employee
+ $idsHotel = array_filter($idsHotel, function ($idHotel) use($accessedIds) {
+ return in_array($idHotel, $accessedIds);
+ });
}
+
$restriction = ' AND ';
if (count($idsHotel)) {
if ($alias) {
@@ -866,7 +874,7 @@ class HotelBranchInformation extends ObjectModel
$identifier = "`$identifier`";
$restriction .= $alias.$identifier.' IN ('.implode(', ', $idsHotel).') ';
} else {
- $restriction .= 1;
+ $restriction .= 0;
}
return $restriction;
diff --git a/modules/hotelreservationsystem/classes/HotelCartBookingData.php b/modules/hotelreservationsystem/classes/HotelCartBookingData.php
index 6862659b3..4cd7f41b9 100644
--- a/modules/hotelreservationsystem/classes/HotelCartBookingData.php
+++ b/modules/hotelreservationsystem/classes/HotelCartBookingData.php
@@ -430,6 +430,9 @@ class HotelCartBookingData extends ObjectModel
}
}
}
+ // after room is removed from cart, check if any of the appled cart rules are not being used
+ CartRule::autoRemoveFromCart(Context::getContext());
+ CartRule::autoAddToCart(Context::getContext());
// return number of rooms deleted
return true;
@@ -1912,6 +1915,15 @@ class HotelCartBookingData extends ObjectModel
}
}
+ public function save($null_values = false, $auto_date = true)
+ {
+ $return = parent::save($null_values = false, $auto_date = true);
+ // after updating cart data, check if any of the appled cart rules are not being used
+ CartRule::autoRemoveFromCart(Context::getContext());
+ CartRule::autoAddToCart(Context::getContext());
+ return $return;
+ }
+
public function update($null_values = false)
{
if (!$this->extra_demands) {
diff --git a/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php b/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php
index ded152095..526701c08 100644
--- a/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php
+++ b/modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php
@@ -171,6 +171,36 @@ class AdminAddHotelController extends ModuleAdminController
}
}
$smartyVars['order_restrict_date_info'] = $restrictDateInfo;
+ $objHotelFeatures = new HotelFeatures();
+ $hotelFeatures = $this->object->getFeaturesOfHotelByHotelId($this->object->id);
+ if ($features = $objHotelFeatures->HotelBranchSelectedFeaturesArray($hotelFeatures)) {
+ foreach ($features as $idFeature => $feature) {
+ $features[$idFeature]['value'] = $idFeature;
+ $features[$idFeature]['input_name'] = 'id_feature_parents';
+ if (isset($feature['children']) && $feature['children']) {
+ $selectedChildFeatures = 0;
+ foreach ($feature['children'] as $childKey => $childFeature) {
+ $features[$idFeature]['children'][$childKey]['value'] = $childFeature['id'];
+ $features[$idFeature]['children'][$childKey]['input_name'] = 'id_features';
+ if (isset($childFeature['selected']) && $childFeature['selected']) {
+ $selectedChildFeatures++;
+ }
+ }
+
+ if ($selectedChildFeatures == count($feature['children'])) {
+ $features[$idFeature]['selected'] = true;
+ }
+ }
+ }
+
+ $tree = new HelperTree('hotel-features-tree', $features);
+ $tree->setShowCollapseExpandButton(true)
+ ->setUseCheckBox(true)
+ ->setAutoSelectChildren(true)
+ ->setUseBulkActions(true);
+ $treeContent = $tree->render();
+ $smartyVars['hotel_feature_tree'] = $treeContent;
+ }
} else {
$idCountry = Tools::getValue('hotel_country');
}
@@ -226,6 +256,7 @@ class AdminAddHotelController extends ModuleAdminController
$longitude = Tools::getValue('loclongitude');
$map_formated_address = Tools::getValue('locformatedAddr');
$map_input_text = Tools::getValue('googleInputField');
+ $hotelFeatures = Tools::getValue('id_features', array());
// check if field is atleast in default language. Not available in default prestashop
$defaultLangId = Configuration::get('PS_LANG_DEFAULT');
@@ -640,6 +671,12 @@ class AdminAddHotelController extends ModuleAdminController
$objHotelOrderRestrictDate->preparation_time = $preparationTime;
}
$objHotelOrderRestrictDate->save();
+
+ $objHotelFeatures = new HotelBranchFeatures();
+ $objHotelFeatures->deleteBranchFeaturesByHotelId($idHotel);
+ if (!$objHotelFeatures->assignFeaturesToHotel($idHotel, $hotelFeatures)) {
+ $this->errors[] = $this->l('Some problem occurred while assigning features to the hotel.');
+ }
}
if (Tools::isSubmit('submitAdd'.$this->table.'AndStay')) {
diff --git a/modules/hotelreservationsystem/controllers/admin/AdminAssignHotelFeatures.php b/modules/hotelreservationsystem/controllers/admin/AdminAssignHotelFeatures.php
deleted file mode 100644
index 171dd1a08..000000000
--- a/modules/hotelreservationsystem/controllers/admin/AdminAssignHotelFeatures.php
+++ /dev/null
@@ -1,229 +0,0 @@
-
-* @copyright 2010-2020 Webkul IN
-* @license https://store.webkul.com/license.html
-*/
-
-class AdminAssignHotelFeaturesController extends ModuleAdminController
-{
- public function __construct()
- {
- $this->bootstrap = true;
- $this->table = 'htl_branch_features';
- $this->className = 'HotelBranchFeatures';
- $this->identifier = 'id';
- $this->context = Context::getContext();
-
- // START send access query information to the admin controller
- $this->access_select = ' SELECT a.`id` FROM '._DB_PREFIX_.'htl_branch_features a';
- $this->access_join = ' INNER JOIN '._DB_PREFIX_.'htl_branch_info hbi ON (hbi.id = a.id_hotel)';
- if ($acsHtls = HotelBranchInformation::getProfileAccessedHotels($this->context->employee->id_profile, 1, 1)) {
- $this->access_where = ' WHERE hbi.id IN ('.implode(',', $acsHtls).')';
- }
-
- parent::__construct();
-
- $this->_join .= 'LEFT JOIN `'._DB_PREFIX_.'htl_branch_info` hi ON (hi.`id` = a.`id_hotel`)';
- $this->_join .= 'LEFT JOIN `'._DB_PREFIX_.'htl_branch_info_lang` hil
- ON (hi.`id` = hil.`id` AND hil.id_lang = '.(int)$this->context->language->id.')';
- $this->_join .= 'LEFT JOIN `'._DB_PREFIX_.'address` addr ON (addr.`id_hotel` = hi.`id`)';
- $this->_join .= 'LEFT JOIN `'._DB_PREFIX_.'state` s ON (s.`id_state` = addr.`id_state`)';
- $this->_join .= 'LEFT JOIN `'._DB_PREFIX_.'country_lang` cl ON (cl.`id_country` = addr.`id_country`
- AND cl.`id_lang` = '.(int)$this->context->language->id.')';
-
- $this->_select .= 'addr.`city` as htl_city, hi.`id` as htl_id, hil.`hotel_name` as htl_name,
- s.`name` as `state_name`, cl.`name`';
- $this->_group = 'GROUP BY a.`id_hotel`';
-
- $this->fields_list = array(
- 'htl_id' => array(
- 'title' => $this->l('Hotel ID'),
- 'align' => 'center',
- 'filter_key' => 'hi!id',
- ),
- 'htl_name' => array(
- 'title' => $this->l('Hotel Name'),
- 'align' => 'center',
- 'filter_key' => 'hil!hotel_name',
- ),
- 'htl_city' => array(
- 'title' => $this->l('City'),
- 'align' => 'center',
- 'filter_key' => 'addr!city',
- ),
-
- 'state_name' => array(
- 'title' => $this->l('State'),
- 'align' => 'center',
- 'filter_key' => 's!name',
- ),
- 'name' => array(
- 'title' => $this->l('Country'),
- 'align' => 'center',
- 'filter_key' => 'cl!name',
- ),
- 'date_add' => array(
- 'title' => $this->l('Date Added'),
- 'align' => 'center',
- 'type' => 'datetime',
- 'filter_key' => 'a!date_add',
- )
- );
-
- $this->bulk_actions = array(
- 'delete' => array(
- 'text' => $this->l('Delete selected'),
- 'icon' => 'icon-trash',
- 'confirm' => $this->l('Delete selected items?')
- )
- );
- }
-
- public function initToolbar()
- {
- parent::initToolbar();
-
- $this->page_header_toolbar_btn['new_feature'] = array(
- 'href' => $this->context->link->getAdminLink('AdminHotelFeatures'),
- 'desc' => $this->l('Hotel Features'),
- 'imgclass' => 'back'
- );
-
- $this->page_header_toolbar_btn['assignfeatures'] = array(
- 'href' => self::$currentIndex.'&add'.$this->table.'&token='.$this->token,
- 'desc' => $this->l('Assign Features'),
- 'imgclass' => 'new'
- );
- }
-
- public function renderList()
- {
- $this->addRowAction('edit');
- $this->addRowAction('delete');
-
- return parent::renderList();
- }
-
- public function renderForm()
- {
- $smartyVars = array();
- if ($this->display == 'add') {
- $objHotelFeatures = new HotelFeatures();
- $featuresList = $objHotelFeatures->HotelAllCommonFeaturesArray();
- $objBranchInfo = new HotelBranchInformation();
- $unassignedFtrsHotels = $objBranchInfo->getUnassignedFeaturesHotelIds();
- // filter hotels as per accessed hotels
- $unassignedFtrsHotels = HotelBranchInformation::filterDataByHotelAccess(
- $unassignedFtrsHotels,
- $this->context->employee->id_profile,
- 1
- );
-
- $smartyVars['hotels'] = $unassignedFtrsHotels;
- $smartyVars['features_list'] = $featuresList;
- } elseif ($this->display == 'edit') {
- $id = Tools::getValue('id');
- $objBranchFeatures = new HotelBranchFeatures($id);
- $smartyVars['edit'] = 1;
- $objHotelFeatures = new HotelFeatures();
- $objBranchInfo = new HotelBranchInformation();
-
- $features_hotel = $objBranchInfo->getFeaturesOfHotelByHotelId($objBranchFeatures->id_hotel);
- $featuresList = $objHotelFeatures->HotelBranchSelectedFeaturesArray($features_hotel);
-
- $hotels = $objBranchInfo->hotelsNameAndId();
- $smartyVars['hotel_id'] = $objBranchFeatures->id_hotel;
- $smartyVars['hotels'] = $hotels;
- $smartyVars['features_list'] = $featuresList;
- }
-
- $this->context->smarty->assign($smartyVars);
-
- $this->fields_form = array(
- 'submit' => array(
- 'title' => $this->l('Save')
- )
- );
- return parent::renderForm();
- }
-
- public function processSave()
- {
- if ($editId = Tools::getValue('edit_hotel_id')) {
- $objBranchFeatures = new HotelBranchFeatures();
- $objBranchFeatures->deleteBranchFeaturesByHotelId($editId);
- }
- if (!$hotelFeatures = Tools::getValue('hotel_fac')) {
- $this->errors[] = $this->l('Please select at least one feature to assign to a hotel.');
- }
- if (!$idHotel = Tools::getValue('id_hotel')) {
- $this->errors[] = $this->l('Please select a hotel first.');
- }
- if (!count($this->errors)) {
- $objHotelFeatures = new HotelBranchFeatures();
- if (!$objHotelFeatures->assignFeaturesToHotel($idHotel, $hotelFeatures)) {
- $this->errors[] = $this->l('Some problem occure while assigning Features to the hotel.');
- }
- if (empty($this->errors)) {
- if (Tools::isSubmit('submitAdd'.$this->table.'AndStay')) {
- Tools::redirectAdmin(
- self::$currentIndex.'&id='.(int)$idHotel.'&update'.$this->table.'&conf=3&token='.$this->token
- );
- } else {
- Tools::redirectAdmin(self::$currentIndex.'&conf=4&token='.$this->token);
- }
- }
- } else {
- $this->display = 'add';
- }
- }
-
- public function processDelete()
- {
- if (Validate::isLoadedObject($object = $this->loadObject())) {
- $object = $this->loadObject();
- if ($object->id) {
- $objBranchFeatures = new HotelBranchFeatures();
- $objBranchFeatures->deleteBranchFeaturesByHotelId($object->id_hotel);
- }
- } else {
- $this->errors[] = $this->l('An error occurred while deleting the object.').'
'.$this->table.' '.
- $this->l('(cannot load object)');
- }
- parent::processDelete();
- }
-
- protected function processBulkDelete()
- {
- if (is_array($this->boxes) && !empty($this->boxes)) {
- foreach ($this->boxes as $key => $value) {
- $objBranchFeatures = new HotelBranchFeatures($value);
- $objBranchFeatures->deleteBranchFeaturesByHotelId($objBranchFeatures->id_hotel);
- }
- parent::processBulkDelete();
- } else {
- $this->errors[] = $this->l('You must select at least one element to delete.');
- }
- }
-
- public function setMedia()
- {
- parent::setMedia();
- $this->addJs(_MODULE_DIR_.'hotelreservationsystem/views/js/HotelReservationAdmin.js');
- $this->addCSS(_MODULE_DIR_.'hotelreservationsystem/views/css/HotelReservationAdmin.css');
- }
-}
\ No newline at end of file
diff --git a/modules/hotelreservationsystem/controllers/admin/AdminHotelfeaturesController.php b/modules/hotelreservationsystem/controllers/admin/AdminHotelfeaturesController.php
index 77d352ac0..8d7611c62 100644
--- a/modules/hotelreservationsystem/controllers/admin/AdminHotelfeaturesController.php
+++ b/modules/hotelreservationsystem/controllers/admin/AdminHotelfeaturesController.php
@@ -41,11 +41,6 @@ class AdminHotelFeaturesController extends ModuleAdminController
'desc' => $this->l('Add new Features'),
'imgclass' => 'new'
);
-
- $this->page_header_toolbar_btn['new'] = array(
- 'href' => $this->context->link->getAdminLink('AdminAssignHotelFeatures'),
- 'desc' => $this->l('Assign Features To Hotel'),
- );
}
public function renderView()
diff --git a/modules/hotelreservationsystem/hotelreservationsystem.php b/modules/hotelreservationsystem/hotelreservationsystem.php
index 9ece7fe79..9ecea89e2 100644
--- a/modules/hotelreservationsystem/hotelreservationsystem.php
+++ b/modules/hotelreservationsystem/hotelreservationsystem.php
@@ -577,7 +577,6 @@ class HotelReservationSystem extends Module
$this->installTab('AdminHotelGeneralSettings', 'Hotel General Configuration', 'AdminHotelConfigurationSetting', false);
$this->installTab('AdminHotelFeaturePricesSettings', 'Advanced Price Rules', 'AdminHotelConfigurationSetting', false);
$this->installTab('AdminRoomTypeGlobalDemand', 'Additional Demand Configuration', 'AdminHotelConfigurationSetting', false);
- $this->installTab('AdminAssignHotelFeatures', 'Assign Hotel Features', false, false);
$this->installTab('AdminBookingDocument', 'Booking Documents', false, false);
return true;
diff --git a/modules/hotelreservationsystem/views/templates/admin/add_hotel/helpers/form/form.tpl b/modules/hotelreservationsystem/views/templates/admin/add_hotel/helpers/form/form.tpl
index d35e517cf..c53fb31bb 100644
--- a/modules/hotelreservationsystem/views/templates/admin/add_hotel/helpers/form/form.tpl
+++ b/modules/hotelreservationsystem/views/templates/admin/add_hotel/helpers/form/form.tpl
@@ -83,6 +83,12 @@
{l s='Refund Policies' mod='hotelreservationsystem'}
+
+
+
+ {l s='Features' mod='hotelreservationsystem'}
+
+
{hook h='displayAdminAddHotelFormTab' id_hotel=$hook_arg_id_hotel}
@@ -488,6 +494,29 @@
{hook h='displayAdminAddHotelFormRefundPoliciesTabAfter' id_hotel=$hook_arg_id_hotel}
+
+ {hook h='displayAdminAddHotelFormFeaturesTabBefore' id_hotel=$hook_arg_id_hotel}
+ {if isset($hotel_feature_tree)}
+
+ {elseif isset($hotel_info.id) && $hotel_info.id}
+
+ {else}
+
+ {l s='Please save hotel information before assigning hotel features.' mod='hotelreservationsystem'}
+
+ {/if}
+
+ {hook h='displayAdminAddHotelFormFeaturesTabAfter' id_hotel=$hook_arg_id_hotel}
+
{hook h='displayAdminAddHotelFormTabContent' id_hotel=$hook_arg_id_hotel}
diff --git a/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/_partials/booking-rooms.tpl b/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/_partials/booking-rooms.tpl
index 056d3698e..3787ea9a0 100644
--- a/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/_partials/booking-rooms.tpl
+++ b/modules/hotelreservationsystem/views/templates/admin/hotel_rooms_booking/helpers/view/_partials/booking-rooms.tpl
@@ -224,7 +224,7 @@