Sfoglia il codice sorgente

Merge branch 'dev'

master
parent
commit
7dc255a741
1 ha cambiato i file con 18 aggiunte e 19 eliminazioni
  1. +18
    -19
      backend/views/producer-admin/index.php

+ 18
- 19
backend/views/producer-admin/index.php Vedi File

@@ -145,25 +145,24 @@ $this->addButton(['label' => '+', 'url' => 'producer-admin/create', 'class' => '
'format' => 'raw',
'value' => function($model) {
$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) ;

$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
AND product_order.id_product = :id_product_gift
")
->bindValue(':id_producer', $model->id)
->bindValue(':date_start', date('Y-m-01', strtotime("-1 month")))
->bindValue(':date_end', date('Y-m-31', strtotime("-1 month")))
->bindValue(':id_product_gift', $productGift->id)
->queryOne();

return Price::format($res['total']) ;

}
],
],

Loading…
Annulla
Salva