Merge branch 'Qloapps:develop' into gli-1534

This commit is contained in:
abhishek-webkul
2024-03-20 17:29:47 +05:30
committed by GitHub
12 changed files with 470 additions and 169 deletions

View File

@@ -1797,13 +1797,18 @@ class CartCore extends ObjectModel
(int)$product['id_product'],
isset($product['id_hotel']) ? $product['id_hotel'] : 0,
0,
0,
0,
isset($product['date_from']) ? $product['date_from'] : 0,
isset($product['date_to']) ? $product['date_to'] : 0,
0,
$with_taxes,
null
);
} else if ($roomTypesByIdProduct = $objCartBookingData->getCartInfoIdCartIdProduct($this->id, $product['id_product'])) {
} else if ($roomTypesByIdProduct = $objCartBookingData->getCartInfoIdCartIdProduct(
$this->id,
$product['id_product'],
isset($product['date_from']) ? $product['date_from'] : 0,
isset($product['date_to']) ? $product['date_to'] : 0,
)) {
// by webkul to calculate rates of the product from hotelreservation syatem tables with feature prices....
$totalPriceByProduct = 0;
$priceDisplay = Group::getPriceDisplayMethod(Group::getCurrent()->id);
@@ -2350,28 +2355,78 @@ class CartCore extends ObjectModel
foreach ($packages as $id_package => $package) {
foreach ($package['product_list'] as $product) {
if ($product['booking_product']) {
$productInfo = $objRoomType->getRoomTypeInfoByIdProduct($product['id_product']);
$idHotel = $productInfo['id_hotel'] ? $productInfo['id_hotel'] : 0;
if ($roomsBookingDetails = $objHtlCartBookingData->getOnlyCartBookingData(
$this->id,
$this->id_guest,
$product['id_product']
)) {
$productInfo = $objRoomType->getRoomTypeInfoByIdProduct($product['id_product']);
$idHotel = $productInfo['id_hotel'] ? $productInfo['id_hotel'] : 0;
$cartRoomInfo = array();
foreach ($roomsBookingDetails as $roomBooking) {
$dateJoinKey = $idHotel.'-'.strtotime($roomBooking['date_from']).strtotime($roomBooking['date_to']);
$roomTotalPrice = HotelRoomTypeFeaturePricing::getRoomTypeTotalPrice(
$product['id_product'],
$roomBooking['date_from'],
$roomBooking['date_to'],
0,
Group::getCurrent()->id,
$this->id,
$this->id_guest,
0,
0
);
$newQty = HotelHelper::getNumberOfDays(
$roomBooking['date_from'],
$roomBooking['date_to']
);
if (isset($cartRoomInfo[$dateJoinKey])) {
$cartRoomInfo[$dateJoinKey]['cart_quantity'] += $newQty;
$cartRoomInfo[$dateJoinKey]['total_price_tax_incl'] += $roomTotalPrice['total_price_tax_incl'];
$cartRoomInfo[$dateJoinKey]['total_price_tax_excl'] += $roomTotalPrice['total_price_tax_excl'];
} else {
$cartRoomInfo[$dateJoinKey] = array(
'cart_quantity' => $newQty,
'total_price_tax_incl' => $roomTotalPrice['total_price_tax_incl'],
'total_price_tax_excl' => $roomTotalPrice['total_price_tax_excl'],
'date_from' => $roomBooking['date_from'],
'date_to' => $roomBooking['date_to'],
);
}
}
foreach ($cartRoomInfo as $dateJoinKey => $cartRoom) {
if (!isset($orderPackage[$id_address][$dateJoinKey])) {
$orderPackage[$id_address][$dateJoinKey]['product_list'] = array();
$orderPackage[$id_address][$idHotel]['product_list'][] = $product;
$orderPackage[$id_address][$idHotel]['id_hotel'] = $idHotel;
if (!isset($orderPackage[$id_address][$idHotel]['id_hotel'])) {
$orderPackage[$id_address][$idHotel]['id_hotel'] = $productInfo['id_hotel'];
}
if (!isset($orderPackage[$id_address][$idHotel]['carrier_list'])) {
$orderPackage[$id_address][$idHotel]['carrier_list'] = $product['carrier_list'];
} else {
$orderPackage[$id_address][$idHotel]['carrier_list'] = array_intersect($orderPackage[$id_address][$idHotel]['carrier_list'], $product['carrier_list']);
}
if (!isset($orderPackage[$id_address][$idHotel]['warehouse_list'])) {
$orderPackage[$id_address][$idHotel]['warehouse_list'] = $package['warehouse_list'];
}
if (!isset($orderPackage[$id_address][$idHotel]['id_warehouse'])) {
$orderPackage[$id_address][$idHotel]['id_warehouse'] = $package['id_warehouse'];
}
if (isset($package['id_carrier'])) {
if (!isset($orderPackage[$id_address][$idHotel]['id_carrier'])) {
$orderPackage[$id_address][$idHotel]['id_carrier'] = $package['id_carrier'];
$orderPackage[$id_address][$dateJoinKey]['id_hotel'] = $idHotel;
if (!isset($orderPackage[$id_address][$dateJoinKey]['id_hotel'])) {
$orderPackage[$id_address][$dateJoinKey]['id_hotel'] = $productInfo['id_hotel'];
}
if (!isset($orderPackage[$id_address][$dateJoinKey]['carrier_list'])) {
$orderPackage[$id_address][$dateJoinKey]['carrier_list'] = $product['carrier_list'];
} else {
$orderPackage[$id_address][$dateJoinKey]['carrier_list'] = array_intersect($orderPackage[$id_address][$dateJoinKey]['carrier_list'], $product['carrier_list']);
}
if (!isset($orderPackage[$id_address][$dateJoinKey]['warehouse_list'])) {
$orderPackage[$id_address][$dateJoinKey]['warehouse_list'] = $package['warehouse_list'];
}
if (!isset($orderPackage[$id_address][$dateJoinKey]['id_warehouse'])) {
$orderPackage[$id_address][$dateJoinKey]['id_warehouse'] = $package['id_warehouse'];
}
if (isset($package['id_carrier'])) {
if (!isset($orderPackage[$id_address][$dateJoinKey]['id_carrier'])) {
$orderPackage[$id_address][$dateJoinKey]['id_carrier'] = $package['id_carrier'];
}
}
}
$product['date_from'] = $cartRoom['date_from'];
$product['date_to'] = $cartRoom['date_to'];
$product['total_wt'] = $cartRoom['total_price_tax_incl'];
$product['total'] = $cartRoom['total_price_tax_excl'];
$product['cart_quantity'] = $cartRoom['cart_quantity'];
$product['price_wt'] = $cartRoom['total_price_tax_incl'] / $cartRoom['cart_quantity'];
$product['price'] = $cartRoom['total_price_tax_excl'] / $cartRoom['cart_quantity'];
$orderPackage[$id_address][$dateJoinKey]['product_list'][] = $product;
}
}
} else {
@@ -2379,44 +2434,59 @@ class CartCore extends ObjectModel
if ($selectedServiceProducts = $objRoomTypeServiceProductCartDetail->getServiceProductsInCart($this->id, $product['id_product'], 0, 0, 0, 0, 0, 0, null, null)) {
$array = array();
foreach($selectedServiceProducts as $selectedProduct) {
if (isset($array[$selectedProduct['id_hotel']])) {
$array[$selectedProduct['id_hotel']]['quantity'] += $selectedProduct['quantity'];
$array[$selectedProduct['id_hotel']]['total_price_tax_excl'] += $selectedProduct['total_price_tax_excl'];
$array[$selectedProduct['id_hotel']]['total_price_tax_incl'] += $selectedProduct['total_price_tax_incl'];
$dateJoinKey = $selectedProduct['id_hotel'].'-'.strtotime($selectedProduct['date_from']).strtotime($selectedProduct['date_to']);
if (isset($array[$dateJoinKey])) {
$array[$dateJoinKey]['total_price_tax_excl'] += $selectedProduct['total_price_tax_excl'];
$array[$dateJoinKey]['total_price_tax_incl'] += $selectedProduct['total_price_tax_incl'];
} else {
$array[$selectedProduct['id_hotel']] = array(
'quantity' => $selectedProduct['quantity'],
$array[$dateJoinKey] = array(
'id_hotel' => $selectedProduct['id_hotel'],
'quantity' => 0,
'date_from' => $selectedProduct['date_from'],
'date_to' => $selectedProduct['date_to'],
'total_price_tax_excl' => $selectedProduct['total_price_tax_excl'],
'total_price_tax_incl' => $selectedProduct['total_price_tax_incl'],
);
}
if (Product::PRICE_CALCULATION_METHOD_PER_DAY == $selectedProduct['price_calculation_method']) {
$numDays = HotelHelper::getNumberOfDays(
$selectedProduct['date_from'],
$selectedProduct['date_to']
);
$array[$dateJoinKey]['quantity'] += ($selectedProduct['quantity'] * $numDays);
} else {
$array[$dateJoinKey]['quantity'] += $selectedProduct['quantity'];
}
}
foreach($array as $selectedProduct) {
foreach($array as $dateJoinKey => $selectedProduct) {
$product['cart_quantity'] = $selectedProduct['quantity'];
$product['total'] = $selectedProduct['total_price_tax_excl'];
$product['total_wt'] = $selectedProduct['total_price_tax_incl'];
$product['price_wt'] = $selectedProduct['total_price_tax_incl'] / $product['cart_quantity'];
$product['price'] = $selectedProduct['total_price_tax_excl'] / $product['cart_quantity'];
$product['id_hotel'] = $selectedProduct['id_hotel'];
$orderPackage[$id_address][$selectedProduct['id_hotel']]['product_list'][] = $product;
if (!isset($orderPackage[$id_address][$selectedProduct['id_hotel']]['id_hotel'])) {
$orderPackage[$id_address][$selectedProduct['id_hotel']]['id_hotel'] = $selectedProduct['id_hotel'];
$product['date_from'] = $selectedProduct['date_from'];
$product['date_to'] = $selectedProduct['date_to'];
$orderPackage[$id_address][$dateJoinKey]['product_list'][] = $product;
if (!isset($orderPackage[$id_address][$dateJoinKey]['id_hotel'])) {
$orderPackage[$id_address][$dateJoinKey]['id_hotel'] = $selectedProduct['id_hotel'];
}
if (!isset($orderPackage[$id_address][$selectedProduct['id_hotel']]['carrier_list'])) {
$orderPackage[$id_address][$selectedProduct['id_hotel']]['carrier_list'] = $product['carrier_list'];
if (!isset($orderPackage[$id_address][$dateJoinKey]['carrier_list'])) {
$orderPackage[$id_address][$dateJoinKey]['carrier_list'] = $product['carrier_list'];
} else {
$orderPackage[$id_address][$selectedProduct['id_hotel']]['carrier_list'] = array_intersect($orderPackage[$id_address][$selectedProduct['id_hotel']]['carrier_list'], $product['carrier_list']);
$orderPackage[$id_address][$dateJoinKey]['carrier_list'] = array_intersect($orderPackage[$id_address][$dateJoinKey]['carrier_list'], $product['carrier_list']);
}
if (!isset($orderPackage[$id_address][$selectedProduct['id_hotel']]['warehouse_list'])) {
$orderPackage[$id_address][$selectedProduct['id_hotel']]['warehouse_list'] = $package['warehouse_list'];
if (!isset($orderPackage[$id_address][$dateJoinKey]['warehouse_list'])) {
$orderPackage[$id_address][$dateJoinKey]['warehouse_list'] = $package['warehouse_list'];
}
if (!isset($orderPackage[$id_address][$selectedProduct['id_hotel']]['id_warehouse'])) {
$orderPackage[$id_address][$selectedProduct['id_hotel']]['id_warehouse'] = $package['id_warehouse'];
if (!isset($orderPackage[$id_address][$dateJoinKey]['id_warehouse'])) {
$orderPackage[$id_address][$dateJoinKey]['id_warehouse'] = $package['id_warehouse'];
}
if (isset($package['id_carrier'])) {
if (!isset($orderPackage[$id_address][$selectedProduct['id_hotel']]['id_carrier'])) {
$orderPackage[$id_address][$selectedProduct['id_hotel']]['id_carrier'] = $package['id_carrier'];
if (!isset($orderPackage[$id_address][$dateJoinKey]['id_carrier'])) {
$orderPackage[$id_address][$dateJoinKey]['id_carrier'] = $package['id_carrier'];
}
}
}
@@ -2455,28 +2525,28 @@ class CartCore extends ObjectModel
}
}
$hotelWisePackageList = array();
$hotelAndDateWisePackageList = array();
$numHotels = 0;
if (!empty($serviceProducts)) {
foreach ($serviceProducts as $id_address => $packagesByHotels) {
foreach ($packagesByHotels as $packageByHotel) {
$hotelWisePackageList[$id_address][] = $packageByHotel;
$hotelAndDateWisePackageList[$id_address][] = $packageByHotel;
}
}
}
foreach ($orderPackage as $id_address => $packageByAddress) {
$numHotels += count($packageByAddress);
foreach ($packageByAddress as $id_package => $package) {
$hotelWisePackageList[$id_address][] = $package;
$hotelAndDateWisePackageList[$id_address][] = $package;
}
}
// add sevice products as new package if there are multiple hotels in cart
// if ($numHotels > 1 || count($serviceProducts) > 1) {
// foreach ($serviceProducts as $productsByAddress) {
// if (isset($orderPackage[$id_address])) {
// $hotelWisePackageList[$id_address][] = array(
// $hotelAndDateWisePackageList[$id_address][] = array(
// 'product_list' => $productsByAddress['products'],
// 'carrier_list' => $productsByAddress['carrier_list'],
// 'warehouse_list' => $productsByAddress['warehouse_list'],
@@ -2489,13 +2559,13 @@ class CartCore extends ObjectModel
// } else if (!empty($serviceProducts)) {
// $serviceProductsIdAddress = array_keys($serviceProducts)[0];
// $productsByAddress = array_shift($serviceProducts);
// if (isset($hotelWisePackageList[$serviceProductsIdAddress])) {
// $hotelWisePackageList[$serviceProductsIdAddress][0]['product_list'] = array_merge(
// $hotelWisePackageList[$serviceProductsIdAddress][0]['product_list'],
// if (isset($hotelAndDateWisePackageList[$serviceProductsIdAddress])) {
// $hotelAndDateWisePackageList[$serviceProductsIdAddress][0]['product_list'] = array_merge(
// $hotelAndDateWisePackageList[$serviceProductsIdAddress][0]['product_list'],
// $productsByAddress['products']
// );
// } else {
// $hotelWisePackageList[$id_address][] = array(
// $hotelAndDateWisePackageList[$id_address][] = array(
// 'product_list' => $productsByAddress['products'],
// 'carrier_list' => $productsByAddress['carrier_list'],
// 'warehouse_list' => $productsByAddress['warehouse_list'],
@@ -2505,7 +2575,7 @@ class CartCore extends ObjectModel
// );
// }
// }
$final_package_list = $hotelWisePackageList;
$final_package_list = $hotelAndDateWisePackageList;
// END $package_list hotel wise
$cache[$cache_key] = $final_package_list;
return $final_package_list;

View File

@@ -908,7 +908,7 @@ class LanguageCore extends ObjectModel
}
if ($version == null) {
$version = _PS_VERSION_;
$version = _QLOAPPS_VERSION_;
}
$lang_pack = false;

View File

@@ -772,8 +772,9 @@ abstract class PaymentModuleCore extends Module
$maxOverbookingCount = 0;
foreach ($order->product_list as $product) {
$idProduct = $product['id_product'];
$cartBookingData = $objCartBookingData->getOnlyCartBookingData($this->context->cart->id, $this->context->cart->id_guest, $idProduct);
if ($cartBookingData) {
if ($product['booking_product']
&& $cartBookingData = $objCartBookingData->getCartInfoIdCartIdProduct($this->context->cart->id, $idProduct, $product['date_from'], $product['date_to'])
) {
foreach ($cartBookingData as $bookingInfo) {
$objCartBookingData = new HotelCartBookingData($bookingInfo['id']);
$objCartBookingData->id_order = $order->id;
@@ -986,8 +987,8 @@ abstract class PaymentModuleCore extends Module
$product['id_product'],
isset($product['id_hotel']) ? $product['id_hotel'] : 0,
0,
0,
0,
$product['date_from'],
$product['date_to'],
0,
0,
null,

View File

@@ -161,13 +161,15 @@ class AdminCartsControllerCore extends AdminController
$time = time();
$kpis = array();
$daysForConversionRate = Configuration::get('PS_KPI_CONVERSION_RATE_NB_DAYS');
$helper = new HelperKpi();
$helper->id = 'box-conversion-rate';
$helper->icon = 'icon-sort-by-attributes-alt';
//$helper->chart = true;
$helper->color = 'color1';
$helper->title = $this->l('Conversion Rate', null, null, false);
$helper->subtitle = $this->l('30 days', null, null, false);
$helper->subtitle = $daysForConversionRate.' '.$this->l('days', null, null, false);
if (ConfigurationKPI::get('CONVERSION_RATE_CHART') !== false) {
$helper->data = ConfigurationKPI::get('CONVERSION_RATE_CHART');
}
@@ -186,21 +188,23 @@ class AdminCartsControllerCore extends AdminController
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=abandoned_cart';
$kpis[] = $helper;
$daysForAvgOrderVal = Configuration::get('PS_ORDER_KPI_AVG_ORDER_VALUE_NB_DAYS');
$helper = new HelperKpi();
$helper->id = 'box-average-order';
$helper->icon = 'icon-money';
$helper->color = 'color3';
$helper->title = $this->l('Average Order Value', null, null, false);
$helper->subtitle = $this->l('30 days', 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;
$daysForProfitPerVisitor = Configuration::get('PS_ORDER_KPI_PER_VISITOR_PROFIT_NB_DAYS');
$helper = new HelperKpi();
$helper->id = 'box-net-profit-visitor';
$helper->icon = 'icon-user';
$helper->color = 'color4';
$helper->title = $this->l('Net Profit per Visitor', null, null, false);
$helper->subtitle = $this->l('30 days', 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;

View File

@@ -203,6 +203,22 @@ class AdminOrderPreferencesControllerCore extends AdminController
'list' => $displayCurrencyOptions,
'identifier' => 'value',
),
'PS_ORDER_KPI_AVG_ORDER_VALUE_NB_DAYS' => array(
'title' => $this->l('Days for Average Order Value KPI'),
'hint' => $this->l('Set for last how many days, the \'Average order value\' in the KPI to be calculated.'),
'type' => 'text',
'validation' => 'isUnsignedInt',
'class' => 'fixed-width-xl',
'suffix' => $this->l('day(s)'),
),
'PS_ORDER_KPI_PER_VISITOR_PROFIT_NB_DAYS' => array(
'title' => $this->l('Days for Net Profit Per Visitor KPI'),
'hint' => $this->l('Set for last how many days, the \'Net Profit per Visitor\' in the KPI to be calculated.'),
'type' => 'text',
'validation' => 'isUnsignedInt',
'class' => 'fixed-width-xl',
'suffix' => $this->l('day(s)'),
),
),
'submit' => array('title' => $this->l('Save'))
),

View File

@@ -47,6 +47,8 @@ class AdminOrdersControllerCore extends AdminController
protected $hotelsArray = array();
protected $roomTypesArray = array();
protected $roomsArray = array();
protected $orderCurrenciesArray = array();
public function __construct()
{
@@ -90,6 +92,18 @@ class AdminOrdersControllerCore extends AdminController
LEFT JOIN `'._DB_PREFIX_.'htl_booking_detail` hbd ON (hbd.`id_order` = a.`id_order`)
LEFT JOIN `'._DB_PREFIX_.'htl_branch_info_lang` hbil ON (hbil.`id` = hbd.`id_hotel`)';
// Filters for KPIs because unable to filter orders by defult filters
if (Tools::getValue('orders_arrival_today')) {
$this->_where .= ' AND hbd.`is_refunded` = 0 AND hbd.`date_from` = \''.pSQL(date('Y-m-d')).' 00:00:00\' AND hbd.`id_status` != '.
(int) HotelBookingDetail::STATUS_CHECKED_IN.' AND hbd.`id_status` != '.(int) HotelBookingDetail::STATUS_CHECKED_OUT;
} elseif (Tools::getValue('orders_departures_today')) {
$this->_where .= ' AND hbd.`is_refunded` = 0 AND hbd.`date_to` = \''.pSQL(date('Y-m-d')).' 00:00:00\' AND hbd.`id_status` = '.
(int) HotelBookingDetail::STATUS_CHECKED_IN;
} elseif (Tools::getValue('orders_stay_over')) {
$this->_where .= ' AND hbd.`is_refunded` = 0 AND hbd.`is_back_order` = 0 AND hbd.`id_status` = '.(int) HotelBookingDetail::STATUS_CHECKED_IN.'
AND hbd.`date_to` > \''.pSQL(date('Y-m-d')).' 00:00:00\'';
}
$this->_orderBy = 'id_order';
$this->_orderWay = 'DESC';
$this->_use_found_rows = true;
@@ -1861,65 +1875,12 @@ class AdminOrdersControllerCore extends AdminController
parent::postProcess();
}
// KPIs on listing page
// public function renderKpis()
// {
// $time = time();
// $kpis = array();
// $helper = new HelperKpi();
// $helper->id = 'box-conversion-rate';
// $helper->icon = 'icon-sort-by-attributes-alt';
// //$helper->chart = true;
// $helper->color = 'color1';
// $helper->title = $this->l('Conversion Rate', null, null, false);
// $helper->subtitle = $this->l('30 days', null, null, false);
// if (ConfigurationKPI::get('CONVERSION_RATE_CHART') !== false) {
// $helper->data = ConfigurationKPI::get('CONVERSION_RATE_CHART');
// }
// $helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=conversion_rate';
// $kpis[] = $helper->generate();
// $helper = new HelperKpi();
// $helper->id = 'box-carts';
// $helper->icon = 'icon-shopping-cart';
// $helper->color = 'color2';
// $helper->title = $this->l('Abandoned Carts', null, null, false);
// $helper->subtitle = $this->l('Today', null, null, false);
// $helper->href = $this->context->link->getAdminLink('AdminCarts').'&action=filterOnlyAbandonedCarts';
// $helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=abandoned_cart';
// $kpis[] = $helper->generate();
// $helper = new HelperKpi();
// $helper->id = 'box-average-order';
// $helper->icon = 'icon-money';
// $helper->color = 'color3';
// $helper->title = $this->l('Average Order Value', null, null, false);
// $helper->subtitle = $this->l('30 days', null, null, false);
// $helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=average_order_value';
// $kpis[] = $helper->generate();
// $helper = new HelperKpi();
// $helper->id = 'box-net-profit-visit';
// $helper->icon = 'icon-user';
// $helper->color = 'color4';
// $helper->title = $this->l('Net Profit per Visit', null, null, false);
// $helper->subtitle = $this->l('30 days', null, null, false);
// $helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=netprofit_visit';
// $kpis[] = $helper->generate();
// $helper = new HelperKpiRow();
// $helper->kpis = $kpis;
// return $helper->generate();
// }
// KPIs on view page
public function renderKpis()
{
$kpis = array();
$objOrder = new Order(Tools::getValue('id_order'));
if (Validate::isLoadedObject($objOrder)) {
$kpis = array();
$helper = new HelperKpi();
$helper->id = 'box-order-date';
$helper->icon = 'icon-calendar';
@@ -1959,12 +1920,123 @@ class AdminOrdersControllerCore extends AdminController
Hook::exec('action'.$this->controller_name.'KPIListingModifier', array(
'kpis' => &$kpis,
));
} else {
$time = time();
$kpis = array();
$helper = new HelperKpiRow();
$helper->kpis = $kpis;
$helper = new HelperKpi();
$helper->id = 'box-total-sales';
$helper->icon = 'icon-money';
$helper->color = 'color4';
$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;
return $helper->generate();
$helper = new HelperKpi();
$helper->id = 'box-total-due-amount';
$helper->icon = 'icon-money';
$helper->color = 'color2';
$helper->title = $this->l('Total Due Amount', null, null, false);
$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;
$arivalDate = date('Y-m-d');
$helper = new HelperKpi();
$helper->id = 'box-today-arrivals';
$helper->icon = 'icon-user';
$helper->color = 'color1';
$helper->title = $this->l('Arrivals', null, null, false);
$helper->subtitle = $this->l('Today', null, null, false);
$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;
$departureDate = date('Y-m-d');
$helper = new HelperKpi();
$helper->id = 'box-today-departures';
$helper->icon = 'icon-user';
$helper->color = 'color2';
$helper->title = $this->l('Departures', null, null, false);
$helper->subtitle = $this->l('Today', null, null, false);
$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;
$dateFrom = date('Y-m-d');
$dateTo = date('Y-m-d', strtotime('+1 day'));
$helper = new HelperKpi();
$helper->id = 'box-today-stay-over';
$helper->icon = 'icon-user';
$helper->color = 'color4';
$helper->title = $this->l('Stay Overs', null, null, false);
$helper->subtitle = $this->l('Today', null, null, false);
$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;
$helper = new HelperKpi();
$helper->id = 'box-carts';
$helper->icon = 'icon-shopping-cart';
$helper->color = 'color2';
$helper->title = $this->l('Abandoned Carts', null, null, false);
$dateFrom = date(Context::getContext()->language->date_format_lite, strtotime('-2 day'));
$dateTo = date(Context::getContext()->language->date_format_lite, strtotime('-1 day'));
$helper->subtitle = sprintf($this->l('From %s to %s', null, null, false), $dateFrom, $dateTo);
$helper->href = $this->context->link->getAdminLink('AdminCarts').'&action=filterOnlyAbandonedCarts';
$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;
$daysForConversionRate = Configuration::get('PS_KPI_CONVERSION_RATE_NB_DAYS');
$helper = new HelperKpi();
$helper->id = 'box-conversion-rate';
$helper->icon = 'icon-sort-by-attributes-alt';
$helper->color = 'color1';
$helper->title = $this->l('Conversion Rate', null, null, false);
$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;
$daysForAvgOrderVal = Configuration::get('PS_ORDER_KPI_AVG_ORDER_VALUE_NB_DAYS');
$helper = new HelperKpi();
$helper->id = 'box-average-order';
$helper->icon = 'icon-money';
$helper->color = 'color3';
$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';
$helper->tooltip = $this->l('Total average order value without tax in given period of time.', null, null, false);
$kpis[] = $helper;
$helper = new HelperKpi();
$helper->id = 'box-average-lead-time';
$helper->icon = 'icon-time';
$helper->color = 'color4';
$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;
$helper = new HelperKpi();
$helper->id = 'box-average-guest-in-booking';
$helper->icon = 'icon-users';
$helper->color = 'color3';
$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;
}
$helper = new HelperKpiRow();
$helper->kpis = $kpis;
return $helper->generate();
}
public function renderView()

View File

@@ -224,27 +224,33 @@ 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 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
FROM `'._DB_PREFIX_.'orders` o
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'.
((int) $id_hotel ? ' AND o.`id_order` IN (SELECT id_order FROM `'._DB_PREFIX_.'htl_booking_detail` WHERE id_hotel = '.(int)$id_hotel.')' : '').'
GROUP BY LEFT(`invoice_date`, 10)'
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)
);
foreach ($result as $row) {
$sales[strtotime($row['date'])] = $row['sales'];
}
return $sales;
} 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 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
FROM `'._DB_PREFIX_.'orders` o
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'.
((int) $id_hotel ? ' AND o.`id_order` IN (SELECT id_order FROM `'._DB_PREFIX_.'htl_booking_detail` WHERE id_hotel = '.(int)$id_hotel.')' : '').' GROUP BY LEFT(`invoice_date`, 7)'
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)
);
foreach ($result as $row) {
@@ -254,11 +260,15 @@ 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 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
FROM `'._DB_PREFIX_.'orders` o
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'.
((int) $id_hotel ? ' AND o.`id_order` IN (SELECT id_order FROM `'._DB_PREFIX_.'htl_booking_detail` WHERE id_hotel = '.(int)$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"' : '').' HAVING 1 '.HotelBranchInformation::addHotelRestriction($id_hotel)
);
}
}
@@ -467,13 +477,17 @@ 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
)) as total_purchase_price
)) as total_purchase_price,
(
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'.
((int) $id_hotel ? ' AND o.`id_order` IN (SELECT id_order FROM `'._DB_PREFIX_.'htl_booking_detail` WHERE id_hotel = '.(int)$id_hotel.')' : '').Shop::addSqlRestriction(false, 'o').'
GROUP BY LEFT(`invoice_date`, 10)');
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));
foreach ($result as $row) {
$purchases[strtotime($row['date'])] = $row['total_purchase_price'];
@@ -481,17 +495,22 @@ class AdminStatsControllerCore extends AdminStatsTabController
return $purchases;
} else {
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT SUM(od.`product_quantity` * IF(
od.`purchase_supplier_price` > 0,
od.`purchase_supplier_price`,
(od.`original_product_price` / `conversion_rate`) * '.(int)Configuration::get('CONF_AVERAGE_PRODUCT_MARGIN').' / 100
)) as total_purchase_price
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'.
((int) $id_hotel ? ' AND o.`id_order` IN (SELECT id_order FROM `'._DB_PREFIX_.'htl_booking_detail` WHERE id_hotel = '.(int)$id_hotel.')' : '').Shop::addSqlRestriction(false, 'o'));
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue(
'SELECT SUM(od.`product_quantity` * IF(
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)
);
}
}
@@ -505,15 +524,19 @@ class AdminStatsControllerCore extends AdminStatsTabController
total_paid_tax_incl / o.conversion_rate as total_paid_tax_incl,
total_shipping_tax_excl / o.conversion_rate as total_shipping_tax_excl,
o.module,
hbd.id_country,
ad.id_country,
o.id_currency,
c.id_reference as carrier_reference
c.id_reference as carrier_reference,
(
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_.'address` hbd ON o.id_address_delivery = hbd.id_address
LEFT JOIN `'._DB_PREFIX_.'address` ad ON o.id_address_delivery = ad.id_address
LEFT JOIN `'._DB_PREFIX_.'carrier` c ON o.id_carrier = c.id_carrier
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'.
((int) $id_hotel ? ' AND o.`id_order` IN (SELECT id_order FROM `'._DB_PREFIX_.'htl_booking_detail` WHERE id_hotel = '.(int)$id_hotel.')' : '').Shop::addSqlRestriction(false, 'o'));
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));
foreach ($orders as $order) {
// Add flat fees for this order
@@ -590,7 +613,7 @@ class AdminStatsControllerCore extends AdminStatsTabController
$visitors = AdminStatsController::getVisits(
true,
date('Y-m-d', strtotime('-'.($nbDaysConversionRate + 1).' day')),
date('Y-m-d', strtotime('-1 day')),
date('Y-m-d', strtotime('+1 day')),
false /*'day'*/
);
@@ -750,20 +773,28 @@ class AdminStatsControllerCore extends AdminStatsTabController
break;
case 'average_order_value':
$daysForAvgOrderVal = Configuration::get('PS_ORDER_KPI_AVG_ORDER_VALUE_NB_DAYS');
$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
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
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('-31 day'))).' 00:00:00" AND "'.pSQL(date('Y-m-d', strtotime('-1 day'))).' 23:59:59" AND os.`logable` = 1
'.Shop::addSqlRestriction());
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));
$value = Tools::displayPrice($row['orders'] ? $row['total_paid_tax_excl'] / $row['orders'] : 0, $currency).' ('.$this->l('tax excl.').')';
$value = Tools::displayPrice($row['orders'] ? $row['total_paid_tax_excl'] / $row['orders'] : 0, $currency);
break;
case 'netprofit_visit':
$date_from = date('Y-m-d', strtotime('-31 day'));
$daysForProfitPerVisitor = Configuration::get('PS_ORDER_KPI_PER_VISITOR_PROFIT_NB_DAYS');
$date_from = date('Y-m-d', strtotime('-'.($daysForProfitPerVisitor + 1).' day'));
$date_to = date('Y-m-d', strtotime('-1 day'));
$total_visitors = AdminStatsController::getVisits(false, $date_from, $date_to);
@@ -890,7 +921,50 @@ class AdminStatsControllerCore extends AdminStatsTabController
$value = AdminStatsController::getTotalBannedCustomers();
break;
case 'total_sales':
$totalSales = AdminStatsController::getTotalSales('', '', false, false, 1);
if ($totalSales > 0) {
$value = Tools::displayPrice($totalSales, $currency);
} else {
$value = Tools::displayPrice(0, $currency);
}
break;
case 'today_arrivals':
$dateToday = date('Y-m-d');
$value = 0;
if ($arrivalsData = AdminStatsController::getArrivalsByDate($dateToday)) {
$value = $arrivalsData['total_arrivals'];
}
break;
case 'today_departures':
$dateToday = date('Y-m-d');
$value = 0;
if ($departureData = AdminStatsController::getDeparturesByDate($dateToday)) {
$value = $departureData['total_departures'];
}
break;
case 'today_stay_over':
$dateToday = date('Y-m-d');
$value = AdminStatsController::getStayOversByDate($dateToday);
break;
case 'total_due_amount':
$dateToday = date('Y-m-d');
$dueAmount = AdminStatsController::getTotalDueAmount('', '', false, 1);
if ($dueAmount > 0) {
$value = Tools::displayPrice($dueAmount, $currency);
} else {
$value = Tools::displayPrice(0, $currency);
}
break;
case 'average_lead_time':
$dateToday = date('Y-m-d');
$value = Tools::ps_round(AdminStatsController::getAverageLeadTime(), 2);
break;
case 'average_guest_in_booking':
$dateToday = date('Y-m-d');
$value = AdminStatsController::getAverageGuestsPerBooking();
$value = Tools::ps_round($value['avg_adults'], 2).''.$this->l('Adults').', '.Tools::ps_round($value['avg_children'], 2).''.$this->l('Children');
break;
default:
$value = false;
}
@@ -2266,4 +2340,56 @@ class AdminStatsControllerCore extends AdminStatsTabController
return $result;
}
// Get to totalo due amount in the orders
public static function getTotalDueAmount($dateFrom = '', $dateTo = '', $idHotel = false, $useTax = 0)
{
$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
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);
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
}
// Booking or Reservation Lead Time is the period of time (most typically measured in calendar days) between when a guest makes the reservation and the actual check-in/arrival date.
public static function getAverageLeadTime($dateFrom = '', $dateTo = '', $idHotel = false)
{
$sql = 'SELECT (SUM(DATEDIFF(hbd.`date_from`, hbd.`date_add`)) / COUNT(hbd.`id`)) FROM `'._DB_PREFIX_.'htl_booking_detail` hbd
WHERE hbd.`is_refunded` = 0 AND hbd.`is_back_order` = 0'
.(($dateFrom && $dateTo) ? ' AND hbd.`date_add` BETWEEN "'.pSQL($dateFrom).' 00:00:00" AND "'.pSQL($dateTo).' 23:59:59"' : '')
.HotelBranchInformation::addHotelRestriction($idHotel, 'hbd');
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
}
// This function is used to calculate the average number of guests per booking
/**
* This function is used to calculate the average number of guests per booking
* @param string $dateFrom : Date from in date range of booking creation
* @param string $dateTo : Date to in date range of booking creation
* @param boolean $idHotel: : Send id hotel if want to get for specific hotel
* @return array: of avg_adults and avg_children
*/
public static function getAverageGuestsPerBooking($dateFrom = '', $dateTo = '', $idHotel = false)
{
$sql = 'SELECT (SUM(hbd.`adults`) / COUNT(hbd.`id`)) as avg_adults, (SUM(hbd.`children`) / COUNT(hbd.`id`)) as avg_children FROM `'._DB_PREFIX_.'htl_booking_detail` hbd
WHERE hbd.`is_refunded` = 0 AND hbd.`is_back_order` = 0'
.(($dateFrom && $dateTo) ? ' AND hbd.`date_add` BETWEEN "'.pSQL($dateFrom).' 00:00:00" AND "'.pSQL($dateTo).' 23:59:59"' : '')
.HotelBranchInformation::addHotelRestriction($idHotel, 'hbd');
if ($result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql)) {
return $result[0];
} else {
return array ('avg_adults' => 0, 'avg_children' => 0);
}
}
}

View File

@@ -154,9 +154,6 @@ class OrderConfirmationControllerCore extends FrontController
if (!empty($orderProducts)) {
foreach ($orderProducts as $type_key => $type_value) {
if (in_array($type_value['product_id'], $processed_product)) {
continue;
}
$processed_product[] = $type_value['product_id'];
$product = new Product($type_value['product_id'], false, $this->context->language->id);
@@ -365,13 +362,6 @@ class OrderConfirmationControllerCore extends FrontController
}
}
if (!empty($cart_htl_data)) {
$this->context->smarty->assign('cart_htl_data', $cart_htl_data);
}
if (!empty($cart_service_products)) {
$this->context->smarty->assign('cart_service_products', $cart_service_products);
}
}
if (!$objCartOrder->hasInvoice()) {
$orders_has_invoice = 0;
@@ -395,6 +385,13 @@ class OrderConfirmationControllerCore extends FrontController
}
}
if (!empty($cart_htl_data)) {
$this->context->smarty->assign('cart_htl_data', $cart_htl_data);
}
if (!empty($cart_service_products)) {
$this->context->smarty->assign('cart_service_products', $cart_service_products);
}
$this->context->smarty->assign('orderTotalInfo', $orderTotalInfo);
$this->context->smarty->assign('orders_has_invoice', $orders_has_invoice);
}

View File

@@ -905,6 +905,12 @@
<configuration id="PS_KPI_CONVERSION_RATE_NB_DAYS" name="PS_KPI_CONVERSION_RATE_NB_DAYS">
<value>30</value>
</configuration>
<configuration id="PS_ORDER_KPI_AVG_ORDER_VALUE_NB_DAYS" name="PS_ORDER_KPI_AVG_ORDER_VALUE_NB_DAYS">
<value>30</value>
</configuration>
<configuration id="PS_ORDER_KPI_PER_VISITOR_PROFIT_NB_DAYS" name="PS_ORDER_KPI_PER_VISITOR_PROFIT_NB_DAYS">
<value>30</value>
</configuration>
<configuration id="PS_KPI_NEW_CUSTOMERS_NB_DAYS" name="PS_KPI_NEW_CUSTOMERS_NB_DAYS">
<value>30</value>
</configuration>

View File

@@ -339,7 +339,7 @@ class InstallModelInstall extends InstallAbstractModel
if (InstallSession::getInstance()->safe_mode) {
Language::checkAndAddLanguage($iso, false, true, $params_lang);
} else {
Language::downloadAndInstallLanguagePack($iso, _PS_INSTALL_VERSION_, $params_lang);
Language::downloadAndInstallLanguagePack($iso, _QLO_INSTALL_VERSION_, $params_lang);
}
Language::loadLanguages();

View File

@@ -1298,9 +1298,15 @@ class HotelCartBookingData extends ObjectModel
*
* @return [array/false] [returns all entries if data found else return false]
*/
public function getCartInfoIdCartIdProduct($id_cart, $id_product)
public function getCartInfoIdCartIdProduct($id_cart, $id_product, $date_from = false, $date_to = false)
{
return Db::getInstance()->executeS('SELECT * FROM `'._DB_PREFIX_.'htl_cart_booking_data` WHERE `id_cart`='.(int) $id_cart.' AND `id_product`='.(int) $id_product);
$sql = 'SELECT *
FROM `'._DB_PREFIX_.'htl_cart_booking_data`
WHERE `id_cart`='.(int) $id_cart.' AND `id_product`='.(int) $id_product;
if ($date_from && $date_to) {
$sql .= ' AND `date_from` = \''.pSQL($date_from).'\' AND `date_to` = \''.pSQL($date_to).'\'';
}
return Db::getInstance()->executeS($sql);
}
/**

View File

@@ -356,7 +356,7 @@ class RoomTypeServiceProductCartDetail extends ObjectModel
cbd.`id_product` as `room_type_id_product`, cbd.`adults`, cbd.`children`, cbd.`date_from`, cbd.`date_to`';
if (!$getTotalPrice) {
$sql .= ', pl.`name`, cbd.`id_guest`, cbd.`id_customer`, p.`auto_add_to_cart`, p.`price_addition_type`,
cbd.`id_hotel`, cbd.`id_room`, cbd.`date_from`, cbd.`date_to`, cbd.`is_refunded`';
p.`price_calculation_method`, cbd.`id_hotel`, cbd.`id_room`, cbd.`date_from`, cbd.`date_to`, cbd.`is_refunded`';
}
$sql .= ' FROM `'._DB_PREFIX_.'htl_cart_booking_data` cbd
LEFT JOIN `'._DB_PREFIX_.'htl_room_type_service_product_cart_detail` rscd
@@ -429,6 +429,7 @@ class RoomTypeServiceProductCartDetail extends ObjectModel
'quantity' => $product['quantity'],
'auto_add_to_cart' => $product['auto_add_to_cart'],
'price_addition_type' => $product['price_addition_type'],
'price_calculation_method' => $product['price_calculation_method'],
'unit_price_tax_excl' => $objRoomTypeServiceProductPrice->getServicePrice(
(int)$product['id_product'],
(int)$product['room_type_id_product'],
@@ -500,6 +501,7 @@ class RoomTypeServiceProductCartDetail extends ObjectModel
$selectedServiceProducts[$product['htl_cart_booking_id']]['quantity'] = $product['quantity'];
$selectedServiceProducts[$product['htl_cart_booking_id']]['auto_add_to_cart'] = $product['auto_add_to_cart'];
$selectedServiceProducts[$product['htl_cart_booking_id']]['price_addition_type'] = $product['price_addition_type'];
$selectedServiceProducts[$product['htl_cart_booking_id']]['price_calculation_method'] = $product['price_calculation_method'];
$selectedServiceProducts[$product['htl_cart_booking_id']]['unit_price_tax_excl'] = $objRoomTypeServiceProductPrice->getServicePrice(
(int)$product['id_product'],
(int)$product['room_type_id_product'],
@@ -527,6 +529,7 @@ class RoomTypeServiceProductCartDetail extends ObjectModel
'quantity' => $product['quantity'],
'auto_add_to_cart' => $product['auto_add_to_cart'],
'price_addition_type' => $product['price_addition_type'],
'price_calculation_method' => $product['price_calculation_method'],
'unit_price_tax_excl' => $objRoomTypeServiceProductPrice->getServicePrice(
(int)$product['id_product'],
(int)$product['room_type_id_product'],