|
|
@@ -342,12 +342,16 @@ class Document extends ActiveRecordCommon |
|
|
|
if ($ordersArray && count($ordersArray)) { |
|
|
|
foreach ($ordersArray as $order) { |
|
|
|
foreach ($order->productOrder as $productOrder) { |
|
|
|
if (!isset($productsOrdersArray[$productOrder->id_product])) { |
|
|
|
|
|
|
|
//$indexProductOrder = $productOrder->id_product ; |
|
|
|
$indexProductOrder = $productOrder->product->order ; |
|
|
|
|
|
|
|
if (!isset($productsOrdersArray[$indexProductOrder])) { |
|
|
|
$newProductOrder = clone $productOrder ; |
|
|
|
$productsOrdersArray[$productOrder->id_product] = [$newProductOrder]; |
|
|
|
$productsOrdersArray[$indexProductOrder] = [$newProductOrder]; |
|
|
|
} else { |
|
|
|
$productOrderMatch = false; |
|
|
|
foreach ($productsOrdersArray[$productOrder->id_product] as &$theProductOrder) { |
|
|
|
foreach ($productsOrdersArray[$indexProductOrder] as &$theProductOrder) { |
|
|
|
if ($theProductOrder->unit == $productOrder->unit |
|
|
|
&& ($theProductOrder->price == $productOrder->price |
|
|
|
|| ($this->isInvoicePrice() |
|
|
@@ -357,13 +361,16 @@ class Document extends ActiveRecordCommon |
|
|
|
} |
|
|
|
} |
|
|
|
if (!$productOrderMatch) { |
|
|
|
$productsOrdersArray[$productOrder->id_product][] = $productOrder; |
|
|
|
$productsOrdersArray[$indexProductOrder][] = $productOrder; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// tri des orderProduct par product.order |
|
|
|
ksort($productsOrdersArray); |
|
|
|
|
|
|
|
return $productsOrdersArray; |
|
|
|
} |
|
|
|
|