// 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

@@ -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()');
}
}