// Stats cleaning

This commit is contained in:
Damien Metzger
2013-10-29 15:29:55 +01:00
parent f06eb84d9f
commit 4fe4d71361
5 changed files with 34 additions and 22 deletions
@@ -103,7 +103,7 @@ abstract class AdminStatsTabControllerCore extends AdminPreferencesControllerCor
$action .= ($identifier && $id ? '&'.Tools::safeOutput($identifier).'='.(int)$id : '');
$module = Tools::getValue('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(
'current' => self::$currentIndex,
'token' => $token,
@@ -57,13 +57,13 @@ class StatsBestProducts extends ModuleGrid
'id' => 'reference',
'header' => $this->l('Ref.'),
'dataIndex' => 'reference',
'align' => 'center'
'align' => 'left'
),
array(
'id' => 'name',
'header' => $this->l('Name'),
'dataIndex' => 'name',
'align' => 'center'
'align' => 'left'
),
array(
'id' => 'totalQuantitySold',
@@ -75,13 +75,13 @@ class StatsBestProducts extends ModuleGrid
'id' => 'avgPriceSold',
'header' => $this->l('Price sold'),
'dataIndex' => 'avgPriceSold',
'align' => 'center'
'align' => 'right'
),
array(
'id' => 'totalPriceSold',
'header' => $this->l('Sales'),
'dataIndex' => 'totalPriceSold',
'align' => 'center'
'align' => 'right'
),
array(
'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.');
}
@@ -140,6 +140,7 @@ class StatsBestProducts extends ModuleGrid
public function getData()
{
$currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
$dateBetween = $this->getDate();
$arrayDateBetween = explode(' AND ', $dateBetween);
@@ -178,7 +179,13 @@ class StatsBestProducts extends ModuleGrid
if (($this->_start === 0 || Validate::IsUnsignedInt($this->_start)) && Validate::IsUnsignedInt($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()');
}
}
@@ -57,19 +57,19 @@ class StatsBestVouchers extends ModuleGrid
'id' => 'code',
'header' => $this->l('Code'),
'dataIndex' => 'code',
'align' => 'center'
'align' => 'left'
),
array(
'id' => 'name',
'header' => $this->l('Name'),
'dataIndex' => 'name',
'align' => 'center'
'align' => 'left'
),
array(
'id' => 'ca',
'header' => $this->l('Sales'),
'dataIndex' => 'ca',
'align' => 'center'
'align' => 'right'
),
array(
'id' => 'total',
@@ -116,6 +116,7 @@ class StatsBestVouchers extends ModuleGrid
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
FROM '._DB_PREFIX_.'order_cart_rule ocr
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))
$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()');
}
}
+10 -9
View File
@@ -48,14 +48,14 @@ class StatsCheckUp extends Module
public function install()
{
$confs = array(
'CHECKUP_DESCRIPTIONS_LT'=>100,
'CHECKUP_DESCRIPTIONS_GT'=>400,
'CHECKUP_IMAGES_LT'=>1,
'CHECKUP_IMAGES_GT'=>2,
'CHECKUP_SALES_LT'=>1,
'CHECKUP_SALES_GT'=>2,
'CHECKUP_STOCK_LT'=>1,
'CHECKUP_STOCK_GT'=>3
'CHECKUP_DESCRIPTIONS_LT' => 100,
'CHECKUP_DESCRIPTIONS_GT' => 400,
'CHECKUP_IMAGES_LT' => 1,
'CHECKUP_IMAGES_GT' => 2,
'CHECKUP_SALES_LT' => 1,
'CHECKUP_SALES_GT' => 2,
'CHECKUP_STOCK_LT' => 1,
'CHECKUP_STOCK_GT' => 3
);
foreach ($confs as $confname => $confdefault)
if (!Configuration::get($confname))
@@ -213,6 +213,7 @@ class StatsCheckUp extends Module
</div>
</div>
</form>
<div style="overflow-x:auto">
<table class="table checkup2">
<thead>
<tr>
@@ -318,7 +319,7 @@ class StatsCheckUp extends Module
<td class="center">'.$arrayColors[$totals['average']].'</td>
</tr>
</tfoot>
</table>';
</table></div>';
return $this->html;
}
+2 -2
View File
@@ -41,7 +41,7 @@ class StatsStock extends Module
parent::__construct();
$this->displayName = $this->l('Stats on available quantities.');
$this->displayName = $this->l('Stats on available quantities');
$this->description = '';
}
@@ -143,7 +143,7 @@ class StatsStock extends Module
<tr>
<th colspan="3"></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>
</tr>
<tr>