|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Retourne le CA de l'établissement pour un mois donné. |
|
|
* Retourne le CA de l'établissement pour un mois donné. |
|
|
* |
|
|
* |
|
|
* @param string $periode |
|
|
|
|
|
|
|
|
* @param string $period |
|
|
* @param boolean $format |
|
|
* @param boolean $format |
|
|
* @return string |
|
|
* @return string |
|
|
*/ |
|
|
*/ |
|
|
public function getTurnover($period = '', $format = false) |
|
|
public function getTurnover($period = '', $format = false) |
|
|
{ |
|
|
{ |
|
|
if (!$periode) { |
|
|
|
|
|
$periode = date('Y-m'); |
|
|
|
|
|
|
|
|
if (!$period) { |
|
|
|
|
|
$period = date('Y-m'); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
$connection = Yii::$app->getDb(); |
|
|
$connection = Yii::$app->getDb(); |
|
|
$command = $connection->createCommand(' |
|
|
$command = $connection->createCommand(' |
|
|
SELECT SUM(productOrder.price * productOrder.quantity) AS turnover |
|
|
|
|
|
FROM order, productOrder, distribution, product |
|
|
|
|
|
WHERE order.id = productOrder.id_order |
|
|
|
|
|
|
|
|
SELECT SUM(product_order.price * product_order.quantity) AS turnover |
|
|
|
|
|
FROM `order`, product_order, distribution, product |
|
|
|
|
|
WHERE `order`.id = product_order.id_order |
|
|
AND distribution.id_producer = :id_producer |
|
|
AND distribution.id_producer = :id_producer |
|
|
AND order.id_distribution = distribution.id |
|
|
|
|
|
|
|
|
AND `order`.id_distribution = distribution.id |
|
|
AND product_order.id_product = product.id |
|
|
AND product_order.id_product = product.id |
|
|
AND distribution.date > :date_begin |
|
|
AND distribution.date > :date_begin |
|
|
AND distribution.date < :date_end', [ |
|
|
AND distribution.date < :date_end', [ |