diff --git a/modules/statsbestcustomers/statsbestcustomers.php b/modules/statsbestcustomers/statsbestcustomers.php index 642cda99e..4cd7e1a77 100644 --- a/modules/statsbestcustomers/statsbestcustomers.php +++ b/modules/statsbestcustomers/statsbestcustomers.php @@ -146,7 +146,7 @@ class StatsBestCustomers extends ModuleGrid LEFT JOIN `'._DB_PREFIX_.'guest` g ON c.`id_customer` = g.`id_customer` LEFT JOIN `'._DB_PREFIX_.'connections` co ON g.`id_guest` = co.`id_guest` WHERE co.date_add BETWEEN '.$this->getDate() - .$this->sqlShopRestriction(true, 'c'). + .$this->sqlShopRestriction(Shop::SHARE_CUSTOMER, 'c'). 'GROUP BY c.`id_customer`, c.`lastname`, c.`firstname`, c.`email`'; if (Validate::IsName($this->_sort)) { diff --git a/modules/statsbestmanufacturers/statsbestmanufacturers.php b/modules/statsbestmanufacturers/statsbestmanufacturers.php index cd2b8b92f..4d14972da 100755 --- a/modules/statsbestmanufacturers/statsbestmanufacturers.php +++ b/modules/statsbestmanufacturers/statsbestmanufacturers.php @@ -118,7 +118,7 @@ class StatsBestManufacturers extends ModuleGrid LEFT JOIN '._DB_PREFIX_.'orders o ON (o.id_order = od.id_order) LEFT JOIN '._DB_PREFIX_.'manufacturer m ON (m.id_manufacturer = p.id_manufacturer) WHERE o.invoice_date BETWEEN '.$this->getDate() - .$this->sqlShopRestriction(false, 'o'). + .$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o'). 'AND o.valid = 1 AND m.id_manufacturer IS NOT NULL'; return Db::getInstance()->getValue($sql); @@ -134,7 +134,7 @@ class StatsBestManufacturers extends ModuleGrid LEFT JOIN '._DB_PREFIX_.'orders o ON (o.id_order = od.id_order) LEFT JOIN '._DB_PREFIX_.'currency c ON (c.id_currency = o.id_currency) LEFT JOIN '._DB_PREFIX_.'manufacturer m ON (m.id_manufacturer = p.id_manufacturer) - WHERE '.$this->sqlShopRestriction(false, 'o').' + WHERE '.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').' AND o.invoice_date BETWEEN '.$this->getDate().' AND o.valid = 1 AND m.id_manufacturer IS NOT NULL diff --git a/modules/statsbestsuppliers/statsbestsuppliers.php b/modules/statsbestsuppliers/statsbestsuppliers.php index 287d46045..ac482433b 100644 --- a/modules/statsbestsuppliers/statsbestsuppliers.php +++ b/modules/statsbestsuppliers/statsbestsuppliers.php @@ -119,7 +119,7 @@ class StatsBestSuppliers extends ModuleGrid LEFT JOIN '._DB_PREFIX_.'orders o ON o.id_order = od.id_order LEFT JOIN '._DB_PREFIX_.'supplier s ON s.id_supplier = p.id_supplier WHERE o.invoice_date BETWEEN '.$this->getDate().' - '.$this->sqlShopRestriction(false, 'o').' + '.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').' AND o.valid = 1 AND s.id_supplier IS NOT NULL'; return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); @@ -135,7 +135,7 @@ class StatsBestSuppliers extends ModuleGrid LEFT JOIN '._DB_PREFIX_.'orders o ON o.id_order = od.id_order LEFT JOIN '._DB_PREFIX_.'supplier s ON s.id_supplier = p.id_supplier WHERE o.invoice_date BETWEEN '.$this->getDate().' - '.$this->sqlShopRestriction(false, 'o').' + '.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').' AND o.valid = 1 AND s.id_supplier IS NOT NULL GROUP BY p.id_supplier'; diff --git a/modules/statsbestvouchers/statsbestvouchers.php b/modules/statsbestvouchers/statsbestvouchers.php index 89e867f0d..027095298 100644 --- a/modules/statsbestvouchers/statsbestvouchers.php +++ b/modules/statsbestvouchers/statsbestvouchers.php @@ -115,7 +115,7 @@ class StatsBestVouchers extends ModuleGrid FROM '._DB_PREFIX_.'order_discount od LEFT JOIN '._DB_PREFIX_.'orders o ON o.id_order = od.id_order WHERE o.valid = 1 - '.$this->sqlShopRestriction(false, 'o').' + '.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').' AND o.invoice_date BETWEEN '.$this->getDate().' GROUP BY od.id_discount'; if (Validate::IsName($this->_sort)) diff --git a/modules/statscarrier/statscarrier.php b/modules/statscarrier/statscarrier.php index 3c6bc2a9a..86bfde698 100644 --- a/modules/statscarrier/statscarrier.php +++ b/modules/statscarrier/statscarrier.php @@ -59,7 +59,7 @@ class StatsCarrier extends ModuleGraph $sql = 'SELECT COUNT(o.`id_order`) as total FROM `'._DB_PREFIX_.'orders` o WHERE o.`date_add` BETWEEN '.ModuleGraph::getDateBetween().' - '.$this->sqlShopRestriction(false, 'o').' + '.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').' '.((int)(Tools::getValue('id_order_state')) ? 'AND (SELECT oh.id_order_state FROM `'._DB_PREFIX_.'order_history` oh WHERE o.id_order = oh.id_order ORDER BY oh.date_add DESC, oh.id_order_history DESC LIMIT 1) = '.(int)(Tools::getValue('id_order_state')) : ''); $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql); $states = OrderState::getOrderStates($this->context->language->id); @@ -98,7 +98,7 @@ class StatsCarrier extends ModuleGraph FROM `'._DB_PREFIX_.'carrier` c LEFT JOIN `'._DB_PREFIX_.'orders` o ON o.id_carrier = c.id_carrier WHERE o.`date_add` BETWEEN '.ModuleGraph::getDateBetween().' - '.$this->sqlShopRestriction(false, 'o').' + '.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').' '.$stateQuery.' GROUP BY c.`id_carrier`'; $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql); diff --git a/modules/statscheckup/statscheckup.php b/modules/statscheckup/statscheckup.php index 78e116dee..7a3ee18f6 100644 --- a/modules/statscheckup/statscheckup.php +++ b/modules/statscheckup/statscheckup.php @@ -115,7 +115,7 @@ class StatsCheckUp extends Module LEFT JOIN '._DB_PREFIX_.'order_detail od ON o.id_order = od.id_order WHERE od.product_id = p.id_product AND o.invoice_date BETWEEN '.ModuleGraph::getDateBetween().' - '.$this->sqlShopRestriction().' + '.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').' ) as nbSales, IFNULL(( SELECT SUM(pa.quantity) FROM '._DB_PREFIX_.'product_attribute pa diff --git a/modules/statsforecast/statsforecast.php b/modules/statsforecast/statsforecast.php index f9b1e6eb1..eace61d6d 100644 --- a/modules/statsforecast/statsforecast.php +++ b/modules/statsforecast/statsforecast.php @@ -120,7 +120,7 @@ class StatsForecast extends Module LEFT JOIN '._DB_PREFIX_.'product p ON od.product_id = p.id_product WHERE o.valid = 1 AND o.invoice_date BETWEEN '.ModuleGraph::getDateBetween().' - '.$this->sqlShopRestriction(false, 'o').' + '.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').' GROUP BY '.$dateFromGInvoice.' ORDER BY fix_date'; $result = $db->ExecuteS($sql, false); @@ -180,7 +180,7 @@ class StatsForecast extends Module WHERE o.valid = 1 AND o.total_paid_real > 0 AND o.invoice_date BETWEEN '.ModuleGraph::getDateBetween() - .$this->sqlShopRestriction(false, 'o').' + .$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').' GROUP BY '.$dateFromGInvoice; $discounts = Db::getInstance()->ExecuteS($sql, false); while ($row = $db->nextRow($discounts)) @@ -198,7 +198,7 @@ class StatsForecast extends Module $sql = 'SELECT COUNT(*) FROM '._DB_PREFIX_.'customer WHERE date_add BETWEEN '.ModuleGraph::getDateBetween().' AND date_add '.$dateFromGReg - .$this->sqlShopRestriction(true); + .$this->sqlShopRestriction(Shop::SHARE_CUSTOMER); $row['registrations'] = Db::getInstance()->getValue($sql); $totalHT = $row['totalProducts'] - $discountToday; @@ -310,7 +310,7 @@ class StatsForecast extends Module FROM '._DB_PREFIX_.'orders o WHERE o.valid = 1 AND o.date_add BETWEEN '.ModuleGraph::getDateBetween() - .$this->sqlShopRestriction(false, 'o'); + .$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o'); $orders = Db::getInstance()->getValue($sql); $this->_html .= '
 
@@ -501,7 +501,7 @@ class StatsForecast extends Module WHERE o.valid = 1 AND o.`invoice_date` BETWEEN '.ModuleGraph::getDateBetween().' '.$where.' - '.$this->sqlShopRestriction(false, 'o').' + '.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').' GROUP BY p.id_category_default'; $ca['cat'] = Db::getInstance()->ExecuteS($sql); uasort($ca['cat'], 'statsforecast_sort'); @@ -522,7 +522,7 @@ class StatsForecast extends Module FROM `'._DB_PREFIX_.'orders` o WHERE o.valid = 1 AND o.`invoice_date` BETWEEN '.ModuleGraph::getDateBetween().' - '.$this->sqlShopRestriction(false, 'o'); + '.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o'); $ca['lang'] = Db::getInstance()->getRow($sql); arsort($ca['lang']); @@ -530,7 +530,7 @@ class StatsForecast extends Module FROM `'._DB_PREFIX_.'orders` o WHERE o.valid = 1 AND ADDDATE(o.`invoice_date`, interval 30 day) BETWEEN \''.$employee->stats_date_from.' 00:00:00\' AND \''.min(date('Y-m-d H:i:s'), $employee->stats_date_to.' 23:59:59').'\' - '.$this->sqlShopRestriction(false, 'o'); + '.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o'); $ca['langprev'] = Db::getInstance()->getRow($sql); } else @@ -545,7 +545,7 @@ class StatsForecast extends Module WHERE o.valid = 1 AND o.`invoice_date` BETWEEN '.ModuleGraph::getDateBetween().' '.$where.' - '.$this->sqlShopRestriction(false, 'o').' + '.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').' GROUP BY o.module ORDER BY total DESC'; $ca['payment'] = Db::getInstance()->ExecuteS($sql); @@ -557,7 +557,7 @@ class StatsForecast extends Module LEFT JOIN `'._DB_PREFIX_.'zone` z ON z.id_zone = c.id_zone WHERE o.valid = 1 AND o.`invoice_date` BETWEEN '.ModuleGraph::getDateBetween().' - '.$this->sqlShopRestriction(false, 'o').' + '.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').' GROUP BY c.id_zone ORDER BY total DESC'; $ca['zones'] = Db::getInstance()->ExecuteS($sql); @@ -569,7 +569,7 @@ class StatsForecast extends Module WHERE o.valid = 1 AND o.`invoice_date` BETWEEN '.ModuleGraph::getDateBetween().' '.$where.' - '.$this->sqlShopRestriction(false, 'o').' + '.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').' GROUP BY o.id_currency ORDER BY total DESC'; $ca['currencies'] = Db::getInstance()->ExecuteS($sql); @@ -578,7 +578,7 @@ class StatsForecast extends Module FROM `'._DB_PREFIX_.'orders` o WHERE o.valid = 1 AND o.`invoice_date` BETWEEN '.ModuleGraph::getDateBetween().' - '.$this->sqlShopRestriction(false, 'o'); + '.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o'); $ca['ventil'] = Db::getInstance()->getRow($sql); $sql = 'SELECT /*pac.id_attribute,*/ agl.name as gname, al.name as aname, COUNT(*) as total @@ -590,7 +590,7 @@ class StatsForecast extends Module INNER JOIN '._DB_PREFIX_.'attribute_lang al ON (a.id_attribute = al.id_attribute AND al.id_lang = '.(int)$this->context->language->id.') WHERE o.valid = 1 AND o.`invoice_date` BETWEEN '.ModuleGraph::getDateBetween().' - '.$this->sqlShopRestriction(false, 'o').' + '.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').' GROUP BY pac.id_attribute'; $ca['attributes'] = Db::getInstance()->ExecuteS($sql); diff --git a/modules/statsnewsletter/statsnewsletter.php b/modules/statsnewsletter/statsnewsletter.php index 565562eae..d746cd6f1 100644 --- a/modules/statsnewsletter/statsnewsletter.php +++ b/modules/statsnewsletter/statsnewsletter.php @@ -81,7 +81,7 @@ class StatsNewsletter extends ModuleGraph $sql = 'SELECT COUNT(*) as customers FROM `'._DB_PREFIX_.'customer` WHERE 1 - '.$this->sqlShopRestriction(true).' + '.$this->sqlShopRestriction(Shop::SHARE_CUSTOMER).' AND `newsletter_date_add` BETWEEN '.ModuleGraph::getDateBetween(); $result1 = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql); @@ -103,13 +103,13 @@ class StatsNewsletter extends ModuleGraph $this->_query = 'SELECT newsletter_date_add FROM `'._DB_PREFIX_.'customer` WHERE 1 - '.$this->sqlShopRestriction(true).' + '.$this->sqlShopRestriction(Shop::SHARE_CUSTOMER).' AND `newsletter_date_add` BETWEEN '; $this->_query2 = 'SELECT newsletter_date_add FROM '._DB_PREFIX_.'newsletter WHERE 1 - '.$this->sqlShopRestriction(true).' + '.$this->sqlShopRestriction(Shop::SHARE_CUSTOMER).' AND `newsletter_date_add` BETWEEN '; $this->setDateGraph($layers, true); } diff --git a/modules/statspersonalinfos/statspersonalinfos.php b/modules/statspersonalinfos/statspersonalinfos.php index 0f4f1dbaa..e35e7f1e4 100644 --- a/modules/statspersonalinfos/statspersonalinfos.php +++ b/modules/statspersonalinfos/statspersonalinfos.php @@ -127,7 +127,7 @@ class StatsPersonalInfos extends ModuleGraph $sql = 'SELECT `id_gender`, COUNT(`id_customer`) AS total FROM `'._DB_PREFIX_.'customer` WHERE 1 - '.$this->sqlShopRestriction(true).' + '.$this->sqlShopRestriction(Shop::SHARE_CUSTOMER).' GROUP BY `id_gender`'; $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql); $gender = array(1 => $this->l('Male'), 2 => $this->l('Female'), 9 => $this->l('Unknown'), 0 => $this->l('Unknown')); @@ -145,7 +145,7 @@ class StatsPersonalInfos extends ModuleGraph $sql = 'SELECT COUNT(`id_customer`) as total FROM `'._DB_PREFIX_.'customer` WHERE (YEAR(CURDATE()) - YEAR(`birthday`)) - (RIGHT(CURDATE(), 5) < RIGHT(`birthday`, 5)) < 18 - '.$this->sqlShopRestriction(true).' + '.$this->sqlShopRestriction(Shop::SHARE_CUSTOMER).' AND `birthday` IS NOT NULL'; $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql); if (isset($result['total']) AND $result['total']) @@ -159,7 +159,7 @@ class StatsPersonalInfos extends ModuleGraph FROM `'._DB_PREFIX_.'customer` WHERE (YEAR(CURDATE()) - YEAR(`birthday`)) - (RIGHT(CURDATE(), 5) < RIGHT(`birthday`, 5)) >= 18 AND (YEAR(CURDATE()) - YEAR(`birthday`)) - (RIGHT(CURDATE(), 5) < RIGHT(`birthday`, 5)) < 25 - '.$this->sqlShopRestriction(true).' + '.$this->sqlShopRestriction(Shop::SHARE_CUSTOMER).' AND `birthday` IS NOT NULL'; $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql); if (isset($result['total']) AND $result['total']) @@ -173,7 +173,7 @@ class StatsPersonalInfos extends ModuleGraph FROM `'._DB_PREFIX_.'customer` WHERE (YEAR(CURDATE()) - YEAR(`birthday`)) - (RIGHT(CURDATE(), 5) < RIGHT(`birthday`, 5)) >= 25 AND (YEAR(CURDATE()) - YEAR(`birthday`)) - (RIGHT(CURDATE(), 5) < RIGHT(`birthday`, 5)) < 35 - '.$this->sqlShopRestriction(true).' + '.$this->sqlShopRestriction(Shop::SHARE_CUSTOMER).' AND `birthday` IS NOT NULL'; $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql); if (isset($result['total']) AND $result['total']) @@ -187,7 +187,7 @@ class StatsPersonalInfos extends ModuleGraph FROM `'._DB_PREFIX_.'customer` WHERE (YEAR(CURDATE()) - YEAR(`birthday`)) - (RIGHT(CURDATE(), 5) < RIGHT(`birthday`, 5)) >= 35 AND (YEAR(CURDATE()) - YEAR(`birthday`)) - (RIGHT(CURDATE(), 5) < RIGHT(`birthday`, 5)) < 50 - '.$this->sqlShopRestriction(true).' + '.$this->sqlShopRestriction(Shop::SHARE_CUSTOMER).' AND `birthday` IS NOT NULL'; $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql); if (isset($result['total']) AND $result['total']) @@ -201,7 +201,7 @@ class StatsPersonalInfos extends ModuleGraph FROM `'._DB_PREFIX_.'customer` WHERE (YEAR(CURDATE()) - YEAR(`birthday`)) - (RIGHT(CURDATE(), 5) < RIGHT(`birthday`, 5)) >= 50 AND (YEAR(CURDATE()) - YEAR(`birthday`)) - (RIGHT(CURDATE(), 5) < RIGHT(`birthday`, 5)) < 60 - '.$this->sqlShopRestriction(true).' + '.$this->sqlShopRestriction(Shop::SHARE_CUSTOMER).' AND `birthday` IS NOT NULL'; $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql); if (isset($result['total']) AND $result['total']) @@ -214,7 +214,7 @@ class StatsPersonalInfos extends ModuleGraph $sql = 'SELECT COUNT(`id_customer`) as total FROM `'._DB_PREFIX_.'customer` WHERE (YEAR(CURDATE()) - YEAR(`birthday`)) - (RIGHT(CURDATE(), 5) < RIGHT(`birthday`, 5)) >= 60 - '.$this->sqlShopRestriction(true).' + '.$this->sqlShopRestriction(Shop::SHARE_CUSTOMER).' AND `birthday` IS NOT NULL'; $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql); if (isset($result['total']) AND $result['total']) @@ -227,7 +227,7 @@ class StatsPersonalInfos extends ModuleGraph $sql = 'SELECT COUNT(`id_customer`) as total FROM `'._DB_PREFIX_.'customer` WHERE `birthday` IS NULL - '.$this->sqlShopRestriction(true); + '.$this->sqlShopRestriction(Shop::SHARE_CUSTOMER); $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql); if (isset($result['total']) AND $result['total']) { @@ -244,7 +244,7 @@ class StatsPersonalInfos extends ModuleGraph LEFT JOIN `'._DB_PREFIX_.'country` c ON a.`id_country` = c.`id_country` LEFT JOIN `'._DB_PREFIX_.'country_lang` cl ON (c.`id_country` = cl.`id_country` AND cl.`id_lang` = '.(int)$this->context->language->id.') WHERE a.id_customer != 0 - '.$this->sqlShopRestriction(true, 'cu').' + '.$this->sqlShopRestriction(Shop::SHARE_CUSTOMER, 'cu').' GROUP BY c.`id_country`'; $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql); foreach ($result as $row) @@ -260,7 +260,7 @@ class StatsPersonalInfos extends ModuleGraph FROM `'._DB_PREFIX_.'orders` o LEFT JOIN `'._DB_PREFIX_.'currency` c ON o.`id_currency` = c.`id_currency` WHERE 1 - '.$this->sqlShopRestriction(false, 'o').' + '.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').' GROUP BY c.`id_currency`'; $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql); foreach ($result as $row) @@ -276,7 +276,7 @@ class StatsPersonalInfos extends ModuleGraph FROM `'._DB_PREFIX_.'orders` o LEFT JOIN `'._DB_PREFIX_.'lang` c ON o.`id_lang` = c.`id_lang` WHERE 1 - '.$this->sqlShopRestriction(false, 'o').' + '.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').' GROUP BY c.`id_lang`'; $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql); foreach ($result as $row) diff --git a/modules/statsproduct/statsproduct.php b/modules/statsproduct/statsproduct.php index ce860a0f9..41c5b3fa1 100644 --- a/modules/statsproduct/statsproduct.php +++ b/modules/statsproduct/statsproduct.php @@ -61,7 +61,7 @@ class StatsProduct extends ModuleGraph FROM `'._DB_PREFIX_.'order_detail` od LEFT JOIN `'._DB_PREFIX_.'orders` o ON o.`id_order` = od.`id_order` WHERE od.`product_id` = '.(int)$id_product.' - '.$this->sqlShopRestriction(false, 'o').' + '.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').' AND o.valid = 1 AND o.`date_add` BETWEEN '.$dateBetween; return (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); @@ -74,7 +74,7 @@ class StatsProduct extends ModuleGraph FROM `'._DB_PREFIX_.'order_detail` od LEFT JOIN `'._DB_PREFIX_.'orders` o ON o.`id_order` = od.`id_order` WHERE od.`product_id` = '.(int)($id_product).' - '.$this->sqlShopRestriction(false, 'o').' + '.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').' AND o.valid = 1 AND o.`date_add` BETWEEN '.$dateBetween; return (float)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql); @@ -88,7 +88,7 @@ class StatsProduct extends ModuleGraph LEFT JOIN `'._DB_PREFIX_.'date_range` dr ON pv.`id_date_range` = dr.`id_date_range` LEFT JOIN `'._DB_PREFIX_.'page` p ON pv.`id_page` = p.`id_page` LEFT JOIN `'._DB_PREFIX_.'page_type` pt ON pt.`id_page_type` = p.`id_page_type` - WHERE pt.`name` = \'product.php\' + WHERE pt.`name` = \'product\' '.$this->sqlShopRestriction(false, 'pv').' AND p.`id_object` = '.(int)($id_product).' AND dr.`time_start` BETWEEN '.$dateBetween.' @@ -117,7 +117,7 @@ class StatsProduct extends ModuleGraph FROM `'._DB_PREFIX_.'orders` o LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON o.id_order = od.id_order WHERE o.date_add BETWEEN '.$this->getDate().' - '.$this->sqlShopRestriction(false, 'o').' + '.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').' AND o.valid = 1 AND od.product_id = '.(int)($id_product); return Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql); @@ -135,12 +135,12 @@ class StatsProduct extends ModuleGraph LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON o.id_order = od.id_order WHERE o.date_add BETWEEN '.$this->getDate().' AND o.valid = 1 - AND od.product_id = '.(int)($id_product).' + AND od.product_id = '.(int)$id_product.' ) - '.$this->sqlShopRestriction(false, 'o').' + '.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').' AND o.date_add BETWEEN '.$this->getDate().' AND o.valid = 1 - AND od.product_id != '.(int)($id_product).' + AND od.product_id != '.(int)$id_product.' GROUP BY od.product_id ORDER BY pqty DESC'; return Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql); @@ -302,7 +302,7 @@ class StatsProduct extends ModuleGraph FROM `'._DB_PREFIX_.'order_detail` od LEFT JOIN `'._DB_PREFIX_.'orders` o ON o.`id_order` = od.`id_order` WHERE od.`product_id` = '.(int)($this->_id_product).' - '.$this->sqlShopRestriction(false, 'o').' + '.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').' AND o.valid = 1 AND o.`date_add` BETWEEN '.$dateBetween.' GROUP BY o.`date_add`'; @@ -312,7 +312,7 @@ class StatsProduct extends ModuleGraph LEFT JOIN `'._DB_PREFIX_.'date_range` dr ON pv.`id_date_range` = dr.`id_date_range` LEFT JOIN `'._DB_PREFIX_.'page` p ON pv.`id_page` = p.`id_page` LEFT JOIN `'._DB_PREFIX_.'page_type` pt ON pt.`id_page_type` = p.`id_page_type` - WHERE pt.`name` = \'product.php\' + WHERE pt.`name` = \'product\' '.$this->sqlShopRestriction(false, 'pv').' AND p.`id_object` = '.(int)($this->_id_product).' AND dr.`time_start` BETWEEN '.$dateBetween.' @@ -324,8 +324,8 @@ class StatsProduct extends ModuleGraph $this->_query = 'SELECT product_attribute_id, SUM(od.`product_quantity`) AS total FROM `'._DB_PREFIX_.'orders` o LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON o.`id_order` = od.`id_order` - WHERE od.`product_id` = '.(int)($this->_id_product).' - '.$this->sqlShopRestriction(false, 'o').' + WHERE od.`product_id` = '.(int)$this->_id_product.' + '.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').' AND o.valid = 1 AND o.`date_add` BETWEEN '.$dateBetween.' GROUP BY od.`product_attribute_id`'; diff --git a/modules/statsregistrations/statsregistrations.php b/modules/statsregistrations/statsregistrations.php index 9e3dca4f5..f7e71c3a1 100644 --- a/modules/statsregistrations/statsregistrations.php +++ b/modules/statsregistrations/statsregistrations.php @@ -63,7 +63,7 @@ class StatsRegistrations extends ModuleGraph $sql = 'SELECT COUNT(`id_customer`) as total FROM `'._DB_PREFIX_.'customer` WHERE `date_add` BETWEEN '.ModuleGraph::getDateBetween().' - '.$this->sqlShopRestriction(true); + '.$this->sqlShopRestriction(Shop::SHARE_ORDER); $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql); return isset($result['total']) ? $result['total'] : 0; } @@ -79,7 +79,7 @@ class StatsRegistrations extends ModuleGraph LEFT JOIN `'._DB_PREFIX_.'connections_page` cp ON p.id_page = cp.id_page LEFT JOIN `'._DB_PREFIX_.'connections` c ON c.id_connections = cp.id_connections LEFT JOIN `'._DB_PREFIX_.'guest` g ON c.id_guest = g.id_guest - WHERE pt.name = "authentication.php" + WHERE pt.name = "authentication" '.$this->sqlShopRestriction(false, 'c').' AND (g.id_customer IS NULL OR g.id_customer = 0) AND c.`date_add` BETWEEN '.ModuleGraph::getDateBetween(); @@ -94,7 +94,7 @@ class StatsRegistrations extends ModuleGraph LEFT JOIN `'._DB_PREFIX_.'guest` g ON o.id_customer = g.id_customer LEFT JOIN `'._DB_PREFIX_.'connections` c ON c.id_guest = g.id_guest WHERE o.`date_add` BETWEEN '.ModuleGraph::getDateBetween().' - '.$this->sqlShopRestriction(false, 'o').' + '.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').' AND o.valid = 1 AND ABS(TIMEDIFF(o.date_add, c.date_add)+0) < 120000'; $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql); @@ -142,7 +142,7 @@ class StatsRegistrations extends ModuleGraph SELECT `date_add` FROM `'._DB_PREFIX_.'customer` WHERE 1 - '.$this->sqlShopRestriction(true).' + '.$this->sqlShopRestriction(Shop::SHARE_CUSTOMER).' AND `date_add` BETWEEN'; $this->_titles['main'] = $this->l('Number of customer accounts created'); $this->setDateGraph($layers, true); diff --git a/modules/statssales/statssales.php b/modules/statssales/statssales.php index 6551ec313..d0c2d9bb5 100644 --- a/modules/statssales/statssales.php +++ b/modules/statssales/statssales.php @@ -109,7 +109,7 @@ class StatsSales extends ModuleGraph FROM `'._DB_PREFIX_.'orders` o '.((int)Tools::getValue('id_country') ? 'LEFT JOIN `'._DB_PREFIX_.'address` a ON o.id_address_delivery = a.id_address' : '').' WHERE o.valid = 1 - '.$this->sqlShopRestriction(false, 'o').' + '.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').' '.((int)Tools::getValue('id_country') ? 'AND a.id_country = '.(int)Tools::getValue('id_country') : '').' AND o.`invoice_date` BETWEEN '.ModuleGraph::getDateBetween(); $result1 = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql); @@ -119,7 +119,7 @@ class StatsSales extends ModuleGraph LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON od.`id_order` = o.`id_order` '.((int)Tools::getValue('id_country') ? 'LEFT JOIN `'._DB_PREFIX_.'address` a ON o.id_address_delivery = a.id_address' : '').' WHERE o.valid = 1 - '.$this->sqlShopRestriction(false, 'o').' + '.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').' '.((int)Tools::getValue('id_country') ? 'AND a.id_country = '.(int)Tools::getValue('id_country') : '').' AND o.`invoice_date` BETWEEN '.ModuleGraph::getDateBetween(); $result2 = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql); @@ -158,7 +158,7 @@ class StatsSales extends ModuleGraph LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON od.`id_order` = o.`id_order` '.((int)($this->id_country) ? 'LEFT JOIN `'._DB_PREFIX_.'address` a ON o.id_address_delivery = a.id_address' : '').' WHERE o.valid = 1 - '.$this->sqlShopRestriction('o').' + '.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').' '.((int)($this->id_country) ? 'AND a.id_country = '.(int)$this->id_country : '').' AND o.`invoice_date` BETWEEN '; $this->_query2 = ' GROUP BY o.id_order';