diff --git a/install/data/xml/configuration.xml b/install/data/xml/configuration.xml
index 6a465c94a..c9babed8d 100644
--- a/install/data/xml/configuration.xml
+++ b/install/data/xml/configuration.xml
@@ -686,6 +686,24 @@
3
+
+ 50
+
+
+ 150
+
+
+ 1
+
+
+ 2
+
+
+ 1
+
+
+ 2
+
diff --git a/modules/statsbestproducts/statsbestproducts.php b/modules/statsbestproducts/statsbestproducts.php
index 1d91fd849..1d8449bfd 100644
--- a/modules/statsbestproducts/statsbestproducts.php
+++ b/modules/statsbestproducts/statsbestproducts.php
@@ -202,7 +202,7 @@ class StatsBestProducts extends ModuleGrid
FROM `'._DB_PREFIX_.'product` p
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl
ON (pl.`id_product` = p.`id_product` AND pl.`id_lang` = '.(int) $id_lang .')
- LEFT JOIN `'._DB_PREFIX_.'htl_room_type` hrt
+ INNER JOIN `'._DB_PREFIX_.'htl_room_type` hrt
ON (hrt.`id_product` = p.`id_product`)
LEFT JOIN `'._DB_PREFIX_.'htl_branch_info_lang` hbil
ON (hbil.`id` = hrt.`id_hotel` AND hbil.`id_lang` = '.(int) $id_lang .')
diff --git a/modules/statscatalog/statscatalog.php b/modules/statscatalog/statscatalog.php
index a91052559..34d951c9d 100644
--- a/modules/statscatalog/statscatalog.php
+++ b/modules/statscatalog/statscatalog.php
@@ -46,7 +46,7 @@ class StatsCatalog extends Module
parent::__construct();
- $this->displayName = $this->l('Catalog statistics');
+ $this->displayName = $this->l('Hotel statistics');
$this->description = $this->l('Adds a tab containing general statistics about your catalog to the Stats dashboard.');
$this->ps_versions_compliancy = array('min' => '1.6', 'max' => '1.7.0.99');
}
@@ -119,7 +119,7 @@ class StatsCatalog extends Module
LEFT JOIN `'._DB_PREFIX_.'page` pa ON pv.`id_page` = pa.`id_page`
LEFT JOIN `'._DB_PREFIX_.'page_type` pt ON pt.`id_page_type` = pa.`id_page_type`
LEFT JOIN `'._DB_PREFIX_.'product` p ON p.`id_product` = pa.`id_object`
- LEFT JOIN `'._DB_PREFIX_.'htl_room_type` hrt ON (p.`id_product` = hrt.`id_product`)
+ INNER JOIN `'._DB_PREFIX_.'htl_room_type` hrt ON (p.`id_product` = hrt.`id_product`)
'.Shop::addSqlAssociation('product', 'p').'
'.$this->join.'
WHERE pt.`name` IN ("product.php", "product")
@@ -149,7 +149,7 @@ class StatsCatalog extends Module
FROM `'._DB_PREFIX_.'image` i
LEFT JOIN `'._DB_PREFIX_.'product` p
ON (p.`id_product` = i.`id_product`)
- LEFT JOIN `'._DB_PREFIX_.'htl_room_type` hrt
+ INNER JOIN `'._DB_PREFIX_.'htl_room_type` hrt
ON (hrt.`id_product` = i.`id_product`)
WHERE hrt.`id_hotel` = hbi.`id`
) AS room_type_images
@@ -174,7 +174,7 @@ class StatsCatalog extends Module
FROM `'._DB_PREFIX_.'orders` o
LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON o.`id_order` = od.`id_order`
LEFT JOIN `'._DB_PREFIX_.'product` p ON p.`id_product` = od.`product_id`
- LEFT JOIN `'._DB_PREFIX_.'htl_room_type` hrt ON (p.`id_product` = hrt.`id_product`)
+ INNER JOIN `'._DB_PREFIX_.'htl_room_type` hrt ON (p.`id_product` = hrt.`id_product`)
'.Shop::addSqlAssociation('product', 'p').'
'.$this->join.'
WHERE o.valid = 1
@@ -194,7 +194,7 @@ class StatsCatalog extends Module
$sql = 'SELECT p.id_product, pl.name, pl.link_rewrite
FROM `'._DB_PREFIX_.'product` p
'.Shop::addSqlAssociation('product', 'p').'
- LEFT JOIN `'._DB_PREFIX_.'htl_room_type` hrt ON (p.`id_product` = hrt.`id_product`)
+ INNER JOIN `'._DB_PREFIX_.'htl_room_type` hrt ON (p.`id_product` = hrt.`id_product`)
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl
ON (pl.`id_product` = p.`id_product` AND pl.id_lang = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').')
'.$this->join.'
@@ -293,7 +293,7 @@ class StatsCatalog extends Module
if (count($products_nb) && count($products_nb) < 50) {
$html .= '
-
'.$this->l('Room types never booked').'
+ '.$this->l('Room types never booked').'
diff --git a/modules/statscheckup/statscheckup.php b/modules/statscheckup/statscheckup.php
index 132a933bf..5ef5451e6 100644
--- a/modules/statscheckup/statscheckup.php
+++ b/modules/statscheckup/statscheckup.php
@@ -91,6 +91,8 @@ class StatsCheckUp extends Module
.$this->displayName.'
';
+ $activeTab = 'hotels';
+
if (Tools::isSubmit('submitCheckupRoomType')) {
$confs = array(
'ROOM_TYPE_CHECKUP_DESCRIPTIONS_LT',
@@ -129,6 +131,25 @@ class StatsCheckUp extends Module
$this->html .= $this->displayConfirmation($this->l('Configuration updated.'));
}
+ if (Tools::isSubmit('submitCheckupService')) {
+ $confs = array(
+ 'SERVICE_CHECKUP_DESCRIPTIONS_SHORT_LT',
+ 'SERVICE_CHECKUP_DESCRIPTIONS_SHORT_GT',
+ 'SERVICE_CHECKUP_IMAGES_LT',
+ 'SERVICE_CHECKUP_IMAGES_GT',
+ 'SERVICE_CHECKUP_ORDERS_LT',
+ 'SERVICE_CHECKUP_ORDERS_GT',
+ );
+
+ foreach ($confs as $confname) {
+ Configuration::updateValue($confname, (int)Tools::getValue($confname));
+ }
+
+ $this->html .= $this->displayConfirmation($this->l('Configuration updated.'));
+
+ $activeTab = 'services';
+ }
+
if (Tools::isSubmit('submitCheckupOrder')) {
$this->context->cookie->checkup_order = (int)Tools::getValue('submitCheckupOrder');
$this->html .= $this->displayConfirmation($this->l('Configuration updated.'));
@@ -142,6 +163,35 @@ class StatsCheckUp extends Module
$this->id_hotel = (int) Tools::getValue('id_hotel');
}
+ $this->html .= '
+
+
+
+
+ '.$this->getHotelsTab().'
+
+
+ '.$this->getServicesTab().'
+
+
+ ';
+
+ return $this->html;
+ }
+
+ private function getHotelsTab()
+ {
$employee = Context::getContext()->employee;
$prop30 = ((strtotime($employee->stats_date_to.' 23:59:59') - strtotime($employee->stats_date_from.' 00:00:00')) / 60 / 60 / 24) / 30;
@@ -187,7 +237,7 @@ class StatsCheckUp extends Module
'TOTAL_ROOMS' => array('name' => $this->l('Total rooms'), 'text' => $this->l('rooms')),
);
- $this->html .= '
+ $hotelsHtml = '
@@ -251,12 +301,12 @@ class StatsCheckUp extends Module
| '.$this->l('ID').' |
- '.$this->l('Room type').' |
+ '.(!$this->id_hotel ? $this->l('Hotel') : $this->l('Room type')).' |
'.$this->l('Active').' | ';
foreach ($languages as $language) {
- $this->html .= ''.$this->l('Desc.').' ('.Tools::strtoupper($language['iso_code']).') | ';
+ $hotelsHtml .= ''.$this->l('Desc.').' ('.Tools::strtoupper($language['iso_code']).') | ';
}
- $this->html .= '
+ $hotelsHtml .= '
'.$this->l('Images').' |
'.$this->l('Orders').' |
'.$this->l('Total rooms').' |
@@ -280,17 +330,6 @@ class StatsCheckUp extends Module
);
foreach ($result as $row) {
- $row['stock'] = 0;
- if ($roomTypeInfo = $objHotelRoomType->getRoomTypeInfoByIdProduct($row['id_product'])) {
- $bookingParams['hotel_id'] = $roomTypeInfo['id_hotel'];
- $bookingParams['id_room_type'] = $row['id_product'];
- if ($booking_data = $objBookingDtl->getBookingData($bookingParams)) {
- if (isset($booking_data['stats']['num_avail'])) {
- $row['stock'] = $booking_data['stats']['num_avail'];
- }
- }
- }
-
$totals['products']++;
$scores = array(
'active' => ($row['active'] ? 2 : 0),
@@ -302,7 +341,7 @@ class StatsCheckUp extends Module
$totals['images'] += (int)$scores['images'];
$totals['orders'] += (int)$scores['orders'];
$totals['total_rooms'] += (int)$scores['total_rooms'];
- $descriptions = $this->getDescriptions($row['id_object']);
+ $descriptions = $this->getDescriptions($this->id_hotel ? 'room_type' : 'hotel', $row['id_object']);
foreach ($descriptions as $description) {
if (isset($description['iso_code']) && isset($description['description'])) {
$row['desclength_'.$description['iso_code']] = Tools::strlen(strip_tags($description['description']));
@@ -321,16 +360,16 @@ class StatsCheckUp extends Module
} else {
$objectLink = $this->context->link->getAdminLink('AdminAddHotel').'&updatehtl_branch_info&id='.$row['id_object'];
}
- $this->html .= '
+ $hotelsHtml .= '
| '.$row['id_object'].' |
'.Tools::substr($row['object_name'], 0, 42).' |
'.$array_colors[$scores['active']].' | ';
foreach ($languages as $language) {
if (isset($row['desclength_'.$language['iso_code']])) {
- $this->html .= ''.(int)$row['desclength_'.$language['iso_code']].' '.$array_colors[$scores['description_'.$language['iso_code']]].' | ';
+ $hotelsHtml .= ''.(int)$row['desclength_'.$language['iso_code']].' '.$array_colors[$scores['description_'.$language['iso_code']]].' | ';
} else {
- $this->html .= '0 '.$array_colors[0].' | ';
+ $hotelsHtml .= '0 '.$array_colors[0].' | ';
}
}
@@ -339,7 +378,7 @@ class StatsCheckUp extends Module
$objectViewLink = $this->context->link->getAdminLink('AdminStats').'&module='.$this->name.'&id_hotel='.$row['id_object'];
}
- $this->html .= '
+ $hotelsHtml .= '
'.(int)$row['nbImages'].' '.$array_colors[$scores['images']].' |
'.(int)$row['nbOrders'].' '.$array_colors[$scores['orders']].' |
'.(int)$row['totalRooms'].' '.$array_colors[$scores['total_rooms']].' |
@@ -348,7 +387,7 @@ class StatsCheckUp extends Module
';
}
- $this->html .= '';
+ $hotelsHtml .= '';
$totals['active'] = $totals['active'] / $totals['products'];
$totals['active'] = ($totals['active'] < 1 ? 0 : ($totals['active'] > 1.5 ? 2 : 1));
@@ -365,15 +404,15 @@ class StatsCheckUp extends Module
$totals['average'] = array_sum($totals) / $divisor;
$totals['average'] = ($totals['average'] < 1 ? 0 : ($totals['average'] > 1.5 ? 2 : 1));
- $this->html .= '
+ $hotelsHtml .= '
|
'.$this->l('Active').' | ';
foreach ($languages as $language) {
- $this->html .= ''.$this->l('Desc.').' ('.Tools::strtoupper($language['iso_code']).') | ';
+ $hotelsHtml .= ''.$this->l('Desc.').' ('.Tools::strtoupper($language['iso_code']).') | ';
}
- $this->html .= '
+ $hotelsHtml .= '
'.$this->l('Images').' |
'.$this->l('Orders').' |
'.$this->l('Total rooms').' |
@@ -384,19 +423,248 @@ class StatsCheckUp extends Module
|
'.$array_colors[$totals['active']].' | ';
foreach ($languages as $language) {
- $this->html .= ''.$array_colors[$totals['description_'.$language['iso_code']]].' | ';
+ $hotelsHtml .= ''.$array_colors[$totals['description_'.$language['iso_code']]].' | ';
}
- $this->html .= '
+ $hotelsHtml .= '
'.$array_colors[$totals['images']].' |
'.$array_colors[$totals['orders']].' |
'.$array_colors[$totals['total_rooms']].' |
'.$array_colors[$totals['average']].' |
'.(!$this->id_hotel ? ' | ' : '').'
+ '.($this->id_hotel ? '
+
+ |
+
+ '.$this->l('Back').'
+
+ |
+
' : '').'
';
- return $this->html;
+ return $hotelsHtml;
+ }
+
+ private function getServicesTab()
+ {
+ $employee = Context::getContext()->employee;
+ $prop30 = ((strtotime($employee->stats_date_to.' 23:59:59') - strtotime($employee->stats_date_from.' 00:00:00')) / 60 / 60 / 24) / 30;
+
+ // Get languages
+ $sql = 'SELECT l.*
+ FROM '._DB_PREFIX_.'lang l'
+ .Shop::addSqlAssociation('lang', 'l');
+ $languages = Db::getInstance()->executeS($sql);
+
+ $array_colors = array(
+ 0 => '
',
+ 1 => '
',
+ 2 => '
'
+ );
+
+ $divisor = 4;
+ $totals = array('services' => 0, 'active' => 0, 'images' => 0, 'orders' => 0, 'associated_room_types' => 0);
+ foreach ($languages as $language) {
+ $divisor++;
+ $totals['description_'.$language['iso_code']] = 0;
+ }
+
+ // set data from here
+ $result = $this->getServiceStats();
+
+ if (!$result) {
+ return $this->l('No service was found.');
+ }
+
+ $array_conf = array(
+ 'DESCRIPTIONS_SHORT' => array('name' => $this->l('Descriptions'), 'text' => $this->l('chars (without HTML)')),
+ 'IMAGES' => array('name' => $this->l('Images'), 'text' => $this->l('images')),
+ 'ORDERS' => array('name' => $this->l('Orders'), 'text' => $this->l('orders / month')),
+ );
+
+ $servicesHtml = '
+
+
+
+
+
+
+ | '.$this->l('ID').' |
+ '.$this->l('Service').' |
+ '.$this->l('Active').' |
+ '.$this->l('Associated room types').' | ';
+ foreach ($languages as $language) {
+ $servicesHtml .= ''.$this->l('Desc.').' ('.Tools::strtoupper($language['iso_code']).') | ';
+ }
+ $servicesHtml .= '
+ '.$this->l('Images').' |
+ '.$this->l('Orders').' |
+ '.$this->l('Overall status').' |
+ '.(!$this->id_hotel ? ''.$this->l('Action').' | ' : '').'
+
+
+ ';
+
+
+ $confCheckup = array(
+ 'IMAGES_LT' => Configuration::get('SERVICE_CHECKUP_IMAGES_LT'),
+ 'IMAGES_GT' => Configuration::get('SERVICE_CHECKUP_IMAGES_GT'),
+ 'ORDERS_LT' => Configuration::get('SERVICE_CHECKUP_ORDERS_LT'),
+ 'ORDERS_GT' => Configuration::get('SERVICE_CHECKUP_ORDERS_GT'),
+ 'DESCRIPTIONS_SHORT_LT' => Configuration::get('SERVICE_CHECKUP_DESCRIPTIONS_SHORT_LT'),
+ 'DESCRIPTIONS_SHORT_GT' => Configuration::get('SERVICE_CHECKUP_DESCRIPTIONS_SHORT_GT'),
+ );
+
+ foreach ($result as $row) {
+ $totals['services']++;
+ $scores = array(
+ 'active' => ($row['active'] ? 2 : 0),
+ 'images' => ($row['nbImages'] < $confCheckup['IMAGES_LT'] ? 0 : ($row['nbImages'] > $confCheckup['IMAGES_GT'] ? 2 : 1)),
+ 'orders' => (($row['nbOrders'] * $prop30 < $confCheckup['ORDERS_LT']) ? 0 : (($row['nbOrders'] * $prop30 > $confCheckup['ORDERS_GT']) ? 2 : 1)),
+ );
+ $totals['active'] += (int)$scores['active'];
+ $totals['images'] += (int)$scores['images'];
+ $totals['orders'] += (int)$scores['orders'];
+ $descriptions = $this->getDescriptions('service', $row['id_object']);
+ foreach ($descriptions as $description) {
+ if (isset($description['iso_code']) && isset($description['description_short'])) {
+ $row['desclength_'.$description['iso_code']] = Tools::strlen(strip_tags($description['description_short']));
+ }
+ if (isset($description['iso_code'])) {
+ $scores['description_'.$description['iso_code']] = ($row['desclength_'.$description['iso_code']] < $confCheckup['DESCRIPTIONS_SHORT_LT'] ? 0 : ($row['desclength_'.$description['iso_code']] > $confCheckup['DESCRIPTIONS_SHORT_GT'] ? 2 : 1));
+ $totals['description_'.$description['iso_code']] += $scores['description_'.$description['iso_code']];
+ }
+ }
+ $scores['average'] = array_sum($scores) / $divisor;
+ $scores['average'] = ($scores['average'] < 1 ? 0 : ($scores['average'] > 1.5 ? 2 : 1));
+
+ $objectLink = $this->context->link->getAdminLink('AdminNormalProducts').'&updateproduct&id_product='.$row['id_object'];
+ $servicesHtml .= '
+
+ | '.$row['id_object'].' |
+ '.Tools::substr($row['object_name'], 0, 42).' |
+ '.$array_colors[$scores['active']].' |
+ '.$row['nbAssociatedRoomTypes'].' | ';
+ foreach ($languages as $language) {
+ if (isset($row['desclength_'.$language['iso_code']])) {
+ $servicesHtml .= ''.(int)$row['desclength_'.$language['iso_code']].' '.$array_colors[$scores['description_'.$language['iso_code']]].' | ';
+ } else {
+ $servicesHtml .= '0 '.$array_colors[0].' | ';
+ }
+ }
+
+ $servicesHtml .= '
+ '.(int)$row['nbImages'].' '.$array_colors[$scores['images']].' |
+ '.(int)$row['nbOrders'].' '.$array_colors[$scores['orders']].' |
+ '.$array_colors[$scores['average']].' |
+
';
+ }
+
+ $servicesHtml .= '';
+
+ $totals['active'] = $totals['active'] / $totals['services'];
+ $totals['active'] = ($totals['active'] < 1 ? 0 : ($totals['active'] > 1.5 ? 2 : 1));
+ $totals['images'] = $totals['images'] / $totals['services'];
+ $totals['images'] = ($totals['images'] < 1 ? 0 : ($totals['images'] > 1.5 ? 2 : 1));
+ $totals['orders'] = $totals['orders'] / $totals['services'];
+ $totals['orders'] = ($totals['orders'] < 1 ? 0 : ($totals['orders'] > 1.5 ? 2 : 1));
+ $totals['associated_room_types'] = $totals['associated_room_types'] / $totals['services'];
+ $totals['associated_room_types'] = ($totals['associated_room_types'] < 1 ? 0 : ($totals['associated_room_types'] > 1.5 ? 2 : 1));
+ foreach ($languages as $language) {
+ $totals['description_'.$language['iso_code']] = $totals['description_'.$language['iso_code']] / $totals['services'];
+ $totals['description_'.$language['iso_code']] = ($totals['description_'.$language['iso_code']] < 1 ? 0 : ($totals['description_'.$language['iso_code']] > 1.5 ? 2 : 1));
+ }
+ $totals['average'] = array_sum($totals) / $divisor;
+ $totals['average'] = ($totals['average'] < 1 ? 0 : ($totals['average'] > 1.5 ? 2 : 1));
+
+ $servicesHtml .= '
+
+
+ |
+ '.$this->l('Active').' |
+ '.$this->l('Associated room types').' | ';
+ foreach ($languages as $language) {
+ $servicesHtml .= ''.$this->l('Desc.').' ('.Tools::strtoupper($language['iso_code']).') | ';
+ }
+ $servicesHtml .= '
+ '.$this->l('Images').' |
+ '.$this->l('Orders').' |
+ '.$this->l('Overall status').' |
+ '.(!$this->id_hotel ? ' | ' : '').'
+
+
+ |
+ '.$array_colors[$totals['active']].' |
+ NA | ';
+ foreach ($languages as $language) {
+ $servicesHtml .= ''.$array_colors[$totals['description_'.$language['iso_code']]].' | ';
+ }
+ $servicesHtml .= '
+ '.$array_colors[$totals['images']].' |
+ '.$array_colors[$totals['orders']].' |
+ '.$array_colors[$totals['average']].' |
+
+
+
';
+
+ return $servicesHtml;
}
public function getHotelStats()
@@ -479,20 +747,49 @@ class StatsCheckUp extends Module
return Db::getInstance()->executeS($sql);
}
- public function getDescriptions($id_object)
+ public function getServiceStats()
{
- if ($this->id_hotel) {
- return Db::getInstance()->executeS(
- 'SELECT l.`iso_code`, pl.`description`
- FROM '._DB_PREFIX_.'product_lang pl
- LEFT JOIN '._DB_PREFIX_.'lang l
- ON pl.`id_lang` = l.`id_lang`
- LEFT JOIN '._DB_PREFIX_.'htl_room_type hrt
- ON (hrt.`id_product` = pl.`id_product`)
- WHERE hrt.`id_hotel` = '.(int) $this->id_hotel.'
- AND pl.`id_product` = '.(int) $id_object
- );
- } else {
+ $date_from = date('Y-m-d', strtotime($this->context->employee->stats_date_from));
+ $date_to = date('Y-m-d', strtotime($this->context->employee->stats_date_to));
+ $id_lang = $this->context->language->id;
+
+ $order_by = 'p.`id_product`';
+ if ($this->context->cookie->checkup_order == self::ORDER_BY_NAME) {
+ $order_by = 'object_name';
+ } elseif ($this->context->cookie->checkup_order == self::ORDER_BY_ORDERS) {
+ $order_by = 'nbOrders DESC';
+ }
+
+ $sql = 'SELECT p.`id_product` AS id_object, p.`active`, pl.`name` AS object_name,
+ (
+ SELECT COUNT(*)
+ FROM '._DB_PREFIX_.'image i
+ WHERE i.`id_product` = p.`id_product`
+ ) AS nbImages,
+ (
+ SELECT COUNT(DISTINCT rsod.`id_order`) FROM `'._DB_PREFIX_.'htl_room_type_service_product_order_detail` rsod
+ LEFT JOIN `'._DB_PREFIX_.'orders` o ON (o.`id_order` = rsod.`id_order`)
+ LEFT JOIN `'._DB_PREFIX_.'htl_booking_detail` hbd ON (hbd.`id` = rsod.`id_htl_booking_detail`)
+ WHERE rsod.`id_product` = p.`id_product` AND o.`valid` = 1
+ AND hbd.`date_to` > "'.pSQL($date_from).'" AND hbd.`date_from` < "'.pSQL($date_to).'"
+ ) AS nbOrders,
+ (
+ SELECT COUNT(*)
+ FROM `'._DB_PREFIX_.'htl_room_type_service_product` rsp
+ WHERE rsp.`id_product` = p.`id_product`
+ ) AS nbAssociatedRoomTypes
+ FROM '._DB_PREFIX_.'product p
+ LEFT JOIN '._DB_PREFIX_.'product_lang pl
+ ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.(int) $id_lang.')
+ WHERE p.`booking_product` = 0
+ ORDER BY '.$order_by;
+
+ return Db::getInstance()->executeS($sql);
+ }
+
+ public function getDescriptions($object_type, $id_object = null)
+ {
+ if ($object_type == 'hotel') {
return Db::getInstance()->executeS(
'SELECT l.`iso_code`, hbil.`description`
FROM '._DB_PREFIX_.'htl_branch_info_lang hbil
@@ -500,6 +797,27 @@ class StatsCheckUp extends Module
ON hbil.`id_lang` = l.`id_lang`
WHERE hbil.`id` = '.(int) $id_object
);
+ } elseif ($object_type == 'room_type') {
+ return Db::getInstance()->executeS(
+ 'SELECT l.`iso_code`, pl.`description`
+ FROM '._DB_PREFIX_.'product_lang pl
+ LEFT JOIN '._DB_PREFIX_.'lang l
+ ON pl.`id_lang` = l.`id_lang`
+ INNER JOIN '._DB_PREFIX_.'htl_room_type hrt
+ ON (hrt.`id_product` = pl.`id_product`)
+ WHERE hrt.`id_hotel` = '.(int) $this->id_hotel.'
+ AND pl.`id_product` = '.(int) $id_object
+ );
+ } elseif ($object_type == 'service') {
+ return Db::getInstance()->executeS(
+ 'SELECT l.`iso_code`, pl.`description_short`
+ FROM '._DB_PREFIX_.'product p
+ LEFT JOIN '._DB_PREFIX_.'product_lang pl
+ ON (pl.`id_product` = p.`id_product`)
+ LEFT JOIN '._DB_PREFIX_.'lang l
+ ON pl.`id_lang` = l.`id_lang`
+ WHERE p.`booking_product` = 0'
+ );
}
}
}
diff --git a/modules/statsproduct/statsproduct.php b/modules/statsproduct/statsproduct.php
index 53aff5c72..40c3ff7fd 100644
--- a/modules/statsproduct/statsproduct.php
+++ b/modules/statsproduct/statsproduct.php
@@ -119,6 +119,7 @@ class StatsProduct extends ModuleGraph
$sql .= ' INNER JOIN `'._DB_PREFIX_.'htl_room_type` hrt ON (hrt.`id_product` = p.`id_product` AND hrt.`id_hotel` = '.(int)Tools::getValue('id_hotel').')';
}
$sql .= ' LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang`='.(int)$this->context->language->id.')
+ WHERE p.`booking_product` = 1
ORDER BY pl.`name`';
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
@@ -302,20 +303,8 @@ class StatsProduct extends ModuleGraph
';
- $bookingParams = array();
- $bookingParams['date_from'] = $dateFrom;
- $bookingParams['date_to'] = $dateTo;
- foreach ($this->getProducts($this->context->language->id) as $product) {
- $availRooms = 0;
- if ($roomTypeInfo = $objHotelRoomType->getRoomTypeInfoByIdProduct($product['id_product'])) {
- $bookingParams['hotel_id'] = $roomTypeInfo['id_hotel'];
- $bookingParams['id_room_type'] = $product['id_product'];
- if ($booking_data = $objBookingDtl->getBookingData($bookingParams)) {
- if (isset($booking_data['stats']['num_avail'])) {
- $availRooms = $booking_data['stats']['num_avail'];
- }
- }
- }
+ // get room types info
+ foreach ($this->getProducts() as $product) {
$this->html .= '
|
|