|
|
@@ -194,14 +194,7 @@ class DistributionController extends BackendController |
|
|
|
]) |
|
|
|
->orderBy('product_distribution.active DESC, order ASC'); |
|
|
|
|
|
|
|
/*$productsObjectsArray = $productsQuery->all(); |
|
|
|
foreach($productsObjectsArray as $product) { |
|
|
|
$productsObjectsArray[$product->id] = $product; |
|
|
|
}*/ |
|
|
|
|
|
|
|
$productsArray = $productsQuery->asArray()->all(); |
|
|
|
|
|
|
|
|
|
|
|
$potentialRevenues = 0; |
|
|
|
$potentialWeight = 0; |
|
|
|
|
|
|
@@ -241,30 +234,24 @@ class DistributionController extends BackendController |
|
|
|
$ordersArrayObject = $ordersArray; |
|
|
|
if ($ordersArray) { |
|
|
|
foreach ($ordersArray as &$order) { |
|
|
|
$user = $order->user ? : null; |
|
|
|
$pointSale = $order->pointSale ? : null; |
|
|
|
|
|
|
|
$productOrderArray = []; |
|
|
|
foreach ($order->productOrder as $productOrder) { |
|
|
|
//$product = isset($productsObjectsArray[$productOrder->id_product]) ? $productsObjectsArray[$productOrder->id_product] : null; |
|
|
|
$productOrderArray[$productOrder->id_product] = [ |
|
|
|
'quantity' => $productOrder->quantity * Product::$unitsArray[$productOrder->unit]['coefficient'], |
|
|
|
'unit' => $productOrder->unit, |
|
|
|
'price' => $productOrder->price, |
|
|
|
'price' => number_format($productOrder->price, 3), |
|
|
|
'price_with_tax' => Price::getPriceWithTax($productOrder->price, $productOrder->taxRate->value), |
|
|
|
//'prices' => $product ? $product->getPriceArray($user, $pointSale) : [] |
|
|
|
]; |
|
|
|
} |
|
|
|
|
|
|
|
foreach ($productsArray as $product) { |
|
|
|
//$productObject = isset($productsObjectsArray[$productOrder->id_product]) ? $productsObjectsArray[$productOrder->id_product] : null; |
|
|
|
if (!isset($productOrderArray[$product['id']])) { |
|
|
|
$productOrderArray[$product['id']] = [ |
|
|
|
'quantity' => 0, |
|
|
|
'unit' => $product['unit'], |
|
|
|
'price' => $product['price'], |
|
|
|
'price' => number_format($product['price'], 3), |
|
|
|
'price_with_tax' => Price::getPriceWithTax($product['price'], $product['taxRate']['value']), |
|
|
|
//'prices' => $productObject ? $productObject->getPriceArray($user, $pointSale) : [] |
|
|
|
]; |
|
|
|
} |
|
|
|
} |