[-] MO : fixed #PSCFV-3940
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@17238 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -99,7 +99,7 @@ class StatsForecast extends Module
|
|||||||
$dataTable = array();
|
$dataTable = array();
|
||||||
if ($this->context->cookie->stats_granularity == 10)
|
if ($this->context->cookie->stats_granularity == 10)
|
||||||
for ($i = $from; $i <= $to2; $i = strtotime('+1 day', $i))
|
for ($i = $from; $i <= $to2; $i = strtotime('+1 day', $i))
|
||||||
$dataTable[date('Y-m-d', $i)] = array('fix_date' => date('Y-m-d', $i), 'countOrders' => 0, 'countProducts' => 0, 'totalProducts' => 0);
|
$dataTable[date('Y-m-d', $i)] = array('fix_date' => date('Y-m-d', $i), 'countOrders' => 0, 'countProducts' => 0, 'totalSales' => 0);
|
||||||
|
|
||||||
$dateFromGAdd = ($this->context->cookie->stats_granularity != 42
|
$dateFromGAdd = ($this->context->cookie->stats_granularity != 42
|
||||||
? 'LEFT(date_add, '.(int)$this->context->cookie->stats_granularity.')'
|
? 'LEFT(date_add, '.(int)$this->context->cookie->stats_granularity.')'
|
||||||
@@ -109,21 +109,17 @@ class StatsForecast extends Module
|
|||||||
? 'LEFT(invoice_date, '.(int)$this->context->cookie->stats_granularity.')'
|
? 'LEFT(invoice_date, '.(int)$this->context->cookie->stats_granularity.')'
|
||||||
: 'IFNULL(MAKEDATE(YEAR(invoice_date),DAYOFYEAR(invoice_date)-WEEKDAY(invoice_date)), CONCAT(YEAR(invoice_date),"-01-01*"))');
|
: 'IFNULL(MAKEDATE(YEAR(invoice_date),DAYOFYEAR(invoice_date)-WEEKDAY(invoice_date)), CONCAT(YEAR(invoice_date),"-01-01*"))');
|
||||||
|
|
||||||
$sql = 'SELECT
|
$result = $db->query('
|
||||||
'.$dateFromGInvoice.' as fix_date,
|
SELECT
|
||||||
COUNT(DISTINCT o.id_order) as countOrders,
|
'.$dateFromGInvoice.' as fix_date,
|
||||||
SUM(od.product_quantity) as countProducts,
|
COUNT(*) as countOrders,
|
||||||
SUM(od.product_price * od.product_quantity / o.conversion_rate) as totalProducts
|
(SELECT SUM(od.product_quantity) FROM '._DB_PREFIX_.'order_detail od WHERE o.id_order = od.id_order) as countProducts,
|
||||||
FROM '._DB_PREFIX_.'orders o
|
SUM(o.total_paid_tax_excl / o.conversion_rate) as totalSales
|
||||||
LEFT JOIN '._DB_PREFIX_.'order_detail od ON o.id_order = od.id_order
|
FROM '._DB_PREFIX_.'orders o
|
||||||
LEFT JOIN '._DB_PREFIX_.'product p ON od.product_id = p.id_product
|
WHERE o.valid = 1
|
||||||
WHERE o.valid = 1
|
AND o.invoice_date BETWEEN '.ModuleGraph::getDateBetween().'
|
||||||
AND o.invoice_date BETWEEN '.ModuleGraph::getDateBetween().'
|
'.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o').'
|
||||||
'.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o').'
|
GROUP BY '.$dateFromGInvoice);
|
||||||
GROUP BY '.$dateFromGInvoice.'
|
|
||||||
ORDER BY fix_date';
|
|
||||||
$result = $db->query($sql);
|
|
||||||
|
|
||||||
while ($row = $db->nextRow($result))
|
while ($row = $db->nextRow($result))
|
||||||
$dataTable[$row['fix_date']] = $row;
|
$dataTable[$row['fix_date']] = $row;
|
||||||
|
|
||||||
@@ -149,8 +145,7 @@ class StatsForecast extends Module
|
|||||||
<th style="text-align:center">'.$this->l('Items').'</th>
|
<th style="text-align:center">'.$this->l('Items').'</th>
|
||||||
<th style="text-align:center">'.$this->l('% Reg.').'</th>
|
<th style="text-align:center">'.$this->l('% Reg.').'</th>
|
||||||
<th style="text-align:center">'.$this->l('% Orders').'</th>
|
<th style="text-align:center">'.$this->l('% Orders').'</th>
|
||||||
<th style="width:80px;text-align:center">'.$this->l('Coupons').'</th>
|
<th style="width:100px;text-align:center">'.$this->l('Sales').'</th>
|
||||||
<th style="width:100px;text-align:center">'.$this->l('Products Sales').'</th>
|
|
||||||
</tr>';
|
</tr>';
|
||||||
|
|
||||||
$visitArray = array();
|
$visitArray = array();
|
||||||
@@ -163,34 +158,19 @@ class StatsForecast extends Module
|
|||||||
while ($row = $db->nextRow($visits))
|
while ($row = $db->nextRow($visits))
|
||||||
$visitArray[$row['fix_date']] = $row['visits'];
|
$visitArray[$row['fix_date']] = $row['visits'];
|
||||||
|
|
||||||
/*$discountArray = array();
|
|
||||||
$sql = 'SELECT '.$dateFromGInvoice.' as fix_date, SUM(od.value) as total
|
|
||||||
FROM '._DB_PREFIX_.'orders o
|
|
||||||
LEFT JOIN '._DB_PREFIX_.'order_discount od ON o.id_order = od.id_order
|
|
||||||
WHERE o.valid = 1
|
|
||||||
AND o.total_paid_real > 0
|
|
||||||
AND o.invoice_date BETWEEN '.ModuleGraph::getDateBetween()
|
|
||||||
.Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o').'
|
|
||||||
GROUP BY '.$dateFromGInvoice;
|
|
||||||
$discounts = Db::getInstance()->query($sql);
|
|
||||||
while ($row = $db->nextRow($discounts))
|
|
||||||
$discountArray[$row['fix_date']] = $row['total'];*/
|
|
||||||
|
|
||||||
$today = date('Y-m-d');
|
$today = date('Y-m-d');
|
||||||
foreach ($dataTable as $row)
|
foreach ($dataTable as $row)
|
||||||
{
|
{
|
||||||
$discountToday = 0;//(isset($discountArray[$row['fix_date']]) ? $discountArray[$row['fix_date']] : 0);
|
|
||||||
$visitsToday = (int)(isset($visitArray[$row['fix_date']]) ? $visitArray[$row['fix_date']] : 0);
|
$visitsToday = (int)(isset($visitArray[$row['fix_date']]) ? $visitArray[$row['fix_date']] : 0);
|
||||||
|
|
||||||
$dateFromGReg = ($this->context->cookie->stats_granularity != 42
|
$dateFromGReg = ($this->context->cookie->stats_granularity != 42
|
||||||
? 'LIKE \''.$row['fix_date'].'%\''
|
? 'LIKE \''.$row['fix_date'].'%\''
|
||||||
: 'BETWEEN \''.substr($row['fix_date'], 0, 10).' 00:00:00\' AND DATE_ADD(\''.substr($row['fix_date'], 0, 8).substr($row['fix_date'], 8, 2).' 23:59:59\', INTERVAL 7 DAY)');
|
: 'BETWEEN \''.substr($row['fix_date'], 0, 10).' 00:00:00\' AND DATE_ADD(\''.substr($row['fix_date'], 0, 8).substr($row['fix_date'], 8, 2).' 23:59:59\', INTERVAL 7 DAY)');
|
||||||
$sql = 'SELECT COUNT(*) FROM '._DB_PREFIX_.'customer
|
$row['registrations'] = Db::getInstance()->getValue('
|
||||||
WHERE date_add BETWEEN '.ModuleGraph::getDateBetween().'
|
SELECT COUNT(*) FROM '._DB_PREFIX_.'customer
|
||||||
AND date_add '.$dateFromGReg
|
WHERE date_add BETWEEN '.ModuleGraph::getDateBetween().'
|
||||||
.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER);
|
AND date_add '.$dateFromGReg
|
||||||
$row['registrations'] = Db::getInstance()->getValue($sql);
|
.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER));
|
||||||
$totalHT = $row['totalProducts'] - $discountToday;
|
|
||||||
|
|
||||||
$this->_html .= '
|
$this->_html .= '
|
||||||
<tr>
|
<tr>
|
||||||
@@ -201,16 +181,14 @@ class StatsForecast extends Module
|
|||||||
<td align="center">'.(int)($row['countProducts']).'</td>
|
<td align="center">'.(int)($row['countProducts']).'</td>
|
||||||
<td align="center">'.($visitsToday ? round(100 * (int)($row['registrations']) / $visitsToday, 2).' %' : '-').'</td>
|
<td align="center">'.($visitsToday ? round(100 * (int)($row['registrations']) / $visitsToday, 2).' %' : '-').'</td>
|
||||||
<td align="center">'.($visitsToday ? round(100 * (int)($row['countOrders']) / $visitsToday, 2).' %' : '-').'</td>
|
<td align="center">'.($visitsToday ? round(100 * (int)($row['countOrders']) / $visitsToday, 2).' %' : '-').'</td>
|
||||||
<td align="right">'.Tools::displayPrice($discountToday, $currency).'</td>
|
<td align="right" >'.Tools::displayPrice($row['totalSales'], $currency).'</td>
|
||||||
<td align="right" >'.Tools::displayPrice($totalHT, $currency).'</td>
|
|
||||||
</tr>';
|
</tr>';
|
||||||
|
|
||||||
$this->t1 += $visitsToday;
|
$this->t1 += $visitsToday;
|
||||||
$this->t2 += (int)($row['registrations']);
|
$this->t2 += (int)($row['registrations']);
|
||||||
$this->t3 += (int)($row['countOrders']);
|
$this->t3 += (int)($row['countOrders']);
|
||||||
$this->t4 += (int)($row['countProducts']);
|
$this->t4 += (int)($row['countProducts']);
|
||||||
$this->t7 += $discountToday;
|
$this->t8 += $row['totalSales'];
|
||||||
$this->t8 += $totalHT;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_html .= '
|
$this->_html .= '
|
||||||
@@ -222,8 +200,7 @@ class StatsForecast extends Module
|
|||||||
<th style="text-align:center">'.$this->l('Items').'</th>
|
<th style="text-align:center">'.$this->l('Items').'</th>
|
||||||
<th style="text-align:center">'.$this->l('% Reg.').'</th>
|
<th style="text-align:center">'.$this->l('% Reg.').'</th>
|
||||||
<th style="text-align:center">'.$this->l('% Orders').'</th>
|
<th style="text-align:center">'.$this->l('% Orders').'</th>
|
||||||
<th style="width:80px;text-align:center">'.$this->l('Coupons').'</th>
|
<th style="width:100px;text-align:center">'.$this->l('Sales').'</th>
|
||||||
<th style="width:100px;text-align:center">'.$this->l('Products Sales').'</th>
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>'.$this->l('Total').'</th>
|
<th>'.$this->l('Total').'</th>
|
||||||
@@ -233,7 +210,6 @@ class StatsForecast extends Module
|
|||||||
<td style="font-weight: 700" align="center">'.(int)($this->t4).'</td>
|
<td style="font-weight: 700" align="center">'.(int)($this->t4).'</td>
|
||||||
<td style="font-weight: 700" align="center">--</td>
|
<td style="font-weight: 700" align="center">--</td>
|
||||||
<td style="font-weight: 700" align="center">--</td>
|
<td style="font-weight: 700" align="center">--</td>
|
||||||
<td style="font-weight: 700" align="right">'.Tools::displayPrice($this->t7, $currency).'</td>
|
|
||||||
<td style="font-weight: 700" align="right">'.Tools::displayPrice($this->t8, $currency).'</td>
|
<td style="font-weight: 700" align="right">'.Tools::displayPrice($this->t8, $currency).'</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -244,7 +220,6 @@ class StatsForecast extends Module
|
|||||||
<td style="font-weight: 700" align="center">'.(int)($this->t4 / $intervalAvg).'</td>
|
<td style="font-weight: 700" align="center">'.(int)($this->t4 / $intervalAvg).'</td>
|
||||||
<td style="font-weight: 700" align="center">'.($this->t1 ? round(100 * $this->t2 / $this->t1, 2) .' %' : '-').'</td>
|
<td style="font-weight: 700" align="center">'.($this->t1 ? round(100 * $this->t2 / $this->t1, 2) .' %' : '-').'</td>
|
||||||
<td style="font-weight: 700" align="center">'.($this->t1 ? round(100 * $this->t3 / $this->t1, 2) .' %' : '-').'</td>
|
<td style="font-weight: 700" align="center">'.($this->t1 ? round(100 * $this->t3 / $this->t1, 2) .' %' : '-').'</td>
|
||||||
<td style="font-weight: 700" align="right">'.Tools::displayPrice($this->t7 / $intervalAvg, $currency).'</td>
|
|
||||||
<td style="font-weight: 700" align="right">'.Tools::displayPrice($this->t8 / $intervalAvg, $currency).'</td>
|
<td style="font-weight: 700" align="right">'.Tools::displayPrice($this->t8 / $intervalAvg, $currency).'</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -255,7 +230,6 @@ class StatsForecast extends Module
|
|||||||
<td style="font-weight: 700" align="center">'.(int)($this->t4 * $prop30).'</td>
|
<td style="font-weight: 700" align="center">'.(int)($this->t4 * $prop30).'</td>
|
||||||
<td style="font-weight: 700" align="center">--</td>
|
<td style="font-weight: 700" align="center">--</td>
|
||||||
<td style="font-weight: 700" align="center">--</td>
|
<td style="font-weight: 700" align="center">--</td>
|
||||||
<td style="font-weight: 700" align="right">'.Tools::displayPrice($this->t7 * $prop30, $currency).'</td>
|
|
||||||
<td style="font-weight: 700" align="right">'.Tools::displayPrice($this->t8 * $prop30, $currency).'</td>
|
<td style="font-weight: 700" align="right">'.Tools::displayPrice($this->t8 * $prop30, $currency).'</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
Reference in New Issue
Block a user