Bläddra i källkod

Backend : Montant des dons du mois précédent pour chaque producteur

refactoring
Guillaume Bourgeois 5 år sedan
förälder
incheckning
952ab8c26f
1 ändrade filer med 22 tillägg och 4 borttagningar
  1. +22
    -4
      backend/views/producer-admin/index.php

+ 22
- 4
backend/views/producer-admin/index.php Visa fil

@@ -40,6 +40,7 @@ use yii\helpers\Html;
use yii\grid\GridView;
use common\models\User ;
use common\models\Producer ;
use common\models\Distribution ;

$this->setTitle('Producteurs') ;
$this->addBreadcrumb($this->getTitle()) ;
@@ -139,12 +140,29 @@ $this->addBreadcrumb($this->getTitle()) ;
}
],
[
'attribute' => 'Cours',
'label' => 'CA mois en cours',
'label' => 'Dons (mois précédent)',
'format' => 'raw',
'value' => function($model) {
$turnover = $model->getTurnover(date('Y-m')) ;
return 'CA : '.number_format($turnover,2).' €<br />' ;
$productGift = Product::getProductGift() ;
$distributionsArray = Distribution::find()
->where(['>=', 'distribution.date', date('Y-m-01', strtotime("-1 month"))])
->andWhere(['<=', 'distribution.date', date('Y-m-31', strtotime("-1 month"))])
->andWhere(['distribution.id_producer' => $model->id])
->with(['order','order.productOrder'])
->all() ;
$gifts = 0 ;
foreach($distributionsArray as $distribution) {
foreach($distribution->order as $order) {
foreach($order->productOrder as $productOrder) {
if($productOrder->id_product == $productGift->id) {
$gifts += $productOrder->quantity * $productGift->price ;
}
}
}
}
return Price::format($gifts) ;
}
],
],

Laddar…
Avbryt
Spara