Ver código fonte

[backend] Factures : tri des produits

dev
Guillaume 3 anos atrás
pai
commit
9d0f012958
1 arquivos alterados com 11 adições e 4 exclusões
  1. +11
    -4
      common/models/Document.php

+ 11
- 4
common/models/Document.php Ver arquivo

@@ -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;
}


Carregando…
Cancelar
Salvar