// Stats cleaning

This commit is contained in:
Damien Metzger committed 2013-10-29 15:29:55 +01:00
1 parent f06eb84d9f
commit 4fe4d71361
5 files changed
+34 -22

No files matched your search

@@ -103,7 +103,7 @@ abstract class AdminStatsTabControllerCore extends AdminPreferencesControllerCor
$action .= ($identifier && $id ? '&'.Tools::safeOutput($identifier).'='.(int)$id : ''); $action .= ($identifier && $id ? '&'.Tools::safeOutput($identifier).'='.(int)$id : '');
$module = Tools::getValue('module'); $module = Tools::getValue('module');
$action .= ($module ? '&module='.Tools::safeOutput($module) : ''); $action .= ($module ? '&module='.Tools::safeOutput($module) : '');
$action .= ($id_product = Tools::getValue('id_product') ? '&id_product='.Tools::safeOutput($id_product) : ''); $action .= (($id_product = Tools::getValue('id_product')) ? '&id_product='.Tools::safeOutput($id_product) : '');
$tpl->assign(array( $tpl->assign(array(
'current' => self::$currentIndex, 'current' => self::$currentIndex,
'token' => $token, 'token' => $token,
@@ -57,13 +57,13 @@ class StatsBestProducts extends ModuleGrid
'id' => 'reference', 'id' => 'reference',
'header' => $this->l('Ref.'), 'header' => $this->l('Ref.'),
'dataIndex' => 'reference', 'dataIndex' => 'reference',
'align' => 'center' 'align' => 'left'
), ),
array( array(
'id' => 'name', 'id' => 'name',
'header' => $this->l('Name'), 'header' => $this->l('Name'),
'dataIndex' => 'name', 'dataIndex' => 'name',
'align' => 'center' 'align' => 'left'
), ),
array( array(
'id' => 'totalQuantitySold', 'id' => 'totalQuantitySold',
@@ -75,13 +75,13 @@ class StatsBestProducts extends ModuleGrid
'id' => 'avgPriceSold', 'id' => 'avgPriceSold',
'header' => $this->l('Price sold'), 'header' => $this->l('Price sold'),
'dataIndex' => 'avgPriceSold', 'dataIndex' => 'avgPriceSold',
'align' => 'center' 'align' => 'right'
), ),
array( array(
'id' => 'totalPriceSold', 'id' => 'totalPriceSold',
'header' => $this->l('Sales'), 'header' => $this->l('Sales'),
'dataIndex' => 'totalPriceSold', 'dataIndex' => 'totalPriceSold',
'align' => 'center' 'align' => 'right'
), ),
array( array(
'id' => 'averageQuantitySold', 'id' => 'averageQuantitySold',
@@ -103,7 +103,7 @@ class StatsBestProducts extends ModuleGrid
) )
); );
$this->displayName = $this->l('Best-selling products.'); $this->displayName = $this->l('Best-selling products');
$this->description = $this->l('A list of the best-selling products.'); $this->description = $this->l('A list of the best-selling products.');
} }
@@ -140,6 +140,7 @@ class StatsBestProducts extends ModuleGrid
public function getData() public function getData()
{ {
$currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
$dateBetween = $this->getDate(); $dateBetween = $this->getDate();
$arrayDateBetween = explode(' AND ', $dateBetween); $arrayDateBetween = explode(' AND ', $dateBetween);
@@ -178,7 +179,13 @@ class StatsBestProducts extends ModuleGrid
if (($this->_start === 0 || Validate::IsUnsignedInt($this->_start)) && Validate::IsUnsignedInt($this->_limit)) if (($this->_start === 0 || Validate::IsUnsignedInt($this->_start)) && Validate::IsUnsignedInt($this->_limit))
$this->_query .= ' LIMIT '.$this->_start.', '.($this->_limit); $this->_query .= ' LIMIT '.$this->_start.', '.($this->_limit);
$this->_values = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($this->_query); $values = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($this->_query);
foreach ($values as &$value)
{
$value['avgPriceSold'] = Tools::displayPrice($value['avgPriceSold'], $currency);
$value['totalPriceSold'] = Tools::displayPrice($value['totalPriceSold'], $currency);
}
$this->_values = $values;
$this->_totalCount = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('SELECT FOUND_ROWS()'); $this->_totalCount = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('SELECT FOUND_ROWS()');
} }
} }
@@ -57,19 +57,19 @@ class StatsBestVouchers extends ModuleGrid
'id' => 'code', 'id' => 'code',
'header' => $this->l('Code'), 'header' => $this->l('Code'),
'dataIndex' => 'code', 'dataIndex' => 'code',
'align' => 'center' 'align' => 'left'
), ),
array( array(
'id' => 'name', 'id' => 'name',
'header' => $this->l('Name'), 'header' => $this->l('Name'),
'dataIndex' => 'name', 'dataIndex' => 'name',
'align' => 'center' 'align' => 'left'
), ),
array( array(
'id' => 'ca', 'id' => 'ca',
'header' => $this->l('Sales'), 'header' => $this->l('Sales'),
'dataIndex' => 'ca', 'dataIndex' => 'ca',
'align' => 'center' 'align' => 'right'
), ),
array( array(
'id' => 'total', 'id' => 'total',
@@ -116,6 +116,7 @@ class StatsBestVouchers extends ModuleGrid
public function getData() public function getData()
{ {
$currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
$this->_query = 'SELECT SQL_CALC_FOUND_ROWS cr.code, ocr.name, COUNT(ocr.id_cart_rule) as total, ROUND(SUM(o.total_paid_real) / o.conversion_rate,2) as ca $this->_query = 'SELECT SQL_CALC_FOUND_ROWS cr.code, ocr.name, COUNT(ocr.id_cart_rule) as total, ROUND(SUM(o.total_paid_real) / o.conversion_rate,2) as ca
FROM '._DB_PREFIX_.'order_cart_rule ocr FROM '._DB_PREFIX_.'order_cart_rule ocr
LEFT JOIN '._DB_PREFIX_.'orders o ON o.id_order = ocr.id_order LEFT JOIN '._DB_PREFIX_.'orders o ON o.id_order = ocr.id_order
@@ -133,7 +134,10 @@ class StatsBestVouchers extends ModuleGrid
if (($this->_start === 0 || Validate::IsUnsignedInt($this->_start)) && Validate::IsUnsignedInt($this->_limit)) if (($this->_start === 0 || Validate::IsUnsignedInt($this->_start)) && Validate::IsUnsignedInt($this->_limit))
$this->_query .= ' LIMIT '.$this->_start.', '.($this->_limit); $this->_query .= ' LIMIT '.$this->_start.', '.($this->_limit);
$this->_values = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($this->_query); $values = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($this->_query);
foreach ($values as &$value)
$value['ca'] = Tools::displayPrice($value['ca'], $currency);
$this->_values = $values;
$this->_totalCount = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('SELECT FOUND_ROWS()'); $this->_totalCount = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('SELECT FOUND_ROWS()');
} }
} }
+10 -9
View File
@@ -48,14 +48,14 @@ class StatsCheckUp extends Module
public function install() public function install()
{ {
$confs = array( $confs = array(
'CHECKUP_DESCRIPTIONS_LT'=>100, 'CHECKUP_DESCRIPTIONS_LT' => 100,
'CHECKUP_DESCRIPTIONS_GT'=>400, 'CHECKUP_DESCRIPTIONS_GT' => 400,
'CHECKUP_IMAGES_LT'=>1, 'CHECKUP_IMAGES_LT' => 1,
'CHECKUP_IMAGES_GT'=>2, 'CHECKUP_IMAGES_GT' => 2,
'CHECKUP_SALES_LT'=>1, 'CHECKUP_SALES_LT' => 1,
'CHECKUP_SALES_GT'=>2, 'CHECKUP_SALES_GT' => 2,
'CHECKUP_STOCK_LT'=>1, 'CHECKUP_STOCK_LT' => 1,
'CHECKUP_STOCK_GT'=>3 'CHECKUP_STOCK_GT' => 3
); );
foreach ($confs as $confname => $confdefault) foreach ($confs as $confname => $confdefault)
if (!Configuration::get($confname)) if (!Configuration::get($confname))
@@ -213,6 +213,7 @@ class StatsCheckUp extends Module
</div> </div>
</div> </div>
</form> </form>
<div style="overflow-x:auto">
<table class="table checkup2"> <table class="table checkup2">
<thead> <thead>
<tr> <tr>
@@ -318,7 +319,7 @@ class StatsCheckUp extends Module
<td class="center">'.$arrayColors[$totals['average']].'</td> <td class="center">'.$arrayColors[$totals['average']].'</td>
</tr> </tr>
</tfoot> </tfoot>
</table>'; </table></div>';
return $this->html; return $this->html;
} }
+2 -2
View File
@@ -41,7 +41,7 @@ class StatsStock extends Module
parent::__construct(); parent::__construct();
$this->displayName = $this->l('Stats on available quantities.'); $this->displayName = $this->l('Stats on available quantities');
$this->description = ''; $this->description = '';
} }
@@ -143,7 +143,7 @@ class StatsStock extends Module
<tr> <tr>
<th colspan="3"></th> <th colspan="3"></th>
<th><span class="title_box active">'.$this->l('Total quantities').'</span></th> <th><span class="title_box active">'.$this->l('Total quantities').'</span></th>
<th><span class="title_box active">'.$this->l('Avg price').'</span></th> <th><span class="title_box active">'.$this->l('Average price').'</span></th>
<th><span class="title_box active">'.$this->l('Total value').'</span></th> <th><span class="title_box active">'.$this->l('Total value').'</span></th>
</tr> </tr>
<tr> <tr>