|
|
|
|
|
|
|
|
// products |
|
|
// products |
|
|
$productsArray = Product::find() |
|
|
$productsArray = Product::find() |
|
|
->orWhere(['id_producer' => Producer::getId(),]) |
|
|
->orWhere(['id_producer' => Producer::getId(),]) |
|
|
->orWhere(['id_producer' => 0,]) // produit "Don" |
|
|
|
|
|
->joinWith(['productDistribution' => function($query) use($distribution) { |
|
|
->joinWith(['productDistribution' => function($query) use($distribution) { |
|
|
$query->andOnCondition('product_distribution.id_distribution = '.$distribution->id) ; |
|
|
$query->andOnCondition('product_distribution.id_distribution = '.$distribution->id) ; |
|
|
}]) |
|
|
}]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$potentialRevenues = 0; |
|
|
$potentialRevenues = 0; |
|
|
$potentialWeight = 0; |
|
|
$potentialWeight = 0; |
|
|
|
|
|
|
|
|
foreach($productsArray as &$product) { |
|
|
|
|
|
$quantityOrder = Order::getProductQuantity($product['id'], $ordersArray) ; |
|
|
|
|
|
$product['quantity_ordered'] = $quantityOrder ; |
|
|
|
|
|
$product['quantity_remaining'] = $product['quantity_max'] - $quantityOrder ; |
|
|
|
|
|
if($product['quantity_remaining'] < 0) $product['quantity_remaining'] = 0 ; |
|
|
|
|
|
$product['quantity_form'] = 0 ; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach($productsArray as &$theProduct) { |
|
|
|
|
|
$quantityOrder = Order::getProductQuantity($theProduct['id'], $ordersArray) ; |
|
|
|
|
|
$theProduct['quantity_ordered'] = $quantityOrder ; |
|
|
|
|
|
$theProduct['quantity_remaining'] = $theProduct['quantity_max'] - $quantityOrder ; |
|
|
|
|
|
if($theProduct['quantity_remaining'] < 0) $theProduct['quantity_remaining'] = 0 ; |
|
|
|
|
|
$theProduct['quantity_form'] = 0 ; |
|
|
|
|
|
|
|
|
if($product['productDistribution'][0]['active'] && $product['productDistribution'][0]['quantity_max']) { |
|
|
|
|
|
$potentialRevenues += $product['productDistribution'][0]['quantity_max'] * $product['price']; |
|
|
|
|
|
$potentialWeight += $product['productDistribution'][0]['quantity_max'] * $product['weight'] / 1000; |
|
|
|
|
|
|
|
|
if($theProduct['productDistribution'][0]['active'] && $theProduct['productDistribution'][0]['quantity_max']) { |
|
|
|
|
|
$potentialRevenues += $theProduct['productDistribution'][0]['quantity_max'] * $theProduct['price']; |
|
|
|
|
|
$potentialWeight += $theProduct['productDistribution'][0]['quantity_max'] * $theProduct['weight'] / 1000; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|