Procházet zdrojové kódy

Merge branch 'dev'

prodstable
Guillaume Bourgeois před 5 roky
rodič
revize
30cf2de717
1 změnil soubory, kde provedl 19 přidání a 14 odebrání
  1. +19
    -14
      backend/controllers/StatsController.php

+ 19
- 14
backend/controllers/StatsController.php Zobrazit soubor

@@ -96,22 +96,27 @@ class StatsController extends BackendController
foreach ($period as $date) {
$month = date('m/Y', $date->getTimestamp());
$dataLabels[] = $month;
$data[$month] = 0;
}

// commandes
$ordersArray = Order::searchAll([],[
'conditions' => 'distribution.date > :date',
'params' => [':date' => $dateStart]
]) ;

if($ordersArray) {
foreach ($ordersArray as $order) {
$month = date('m/Y', strtotime($order->distribution->date));
if (isset($data[$month])) {
$data[$month] += $order->amount;
}
$res = Yii::$app->db->createCommand("SELECT SUM(product_order.price * product_order.quantity) AS total
FROM `order`, product_order, distribution
WHERE distribution.id_producer = :id_producer
AND `order`.id_distribution = distribution.id
AND `order`.id = product_order.id_order
AND distribution.date >= :date_start
AND distribution.date <= :date_end
")
->bindValue(':id_producer', Producer::getId())
->bindValue(':date_start', date('Y-m-', $date->getTimestamp()).'01')
->bindValue(':date_end', date('Y-m-', $date->getTimestamp()).'31' )
->queryOne();

if($res['total']) {
$data[$month] = $res['total'];
}
else {
$data[$month] = 0;
}

}

// création d'un tableau sans index car chart.js n'accepte pas les index

Načítá se…
Zrušit
Uložit