浏览代码

[backend] Factures : tri des produits

dev
Guillaume 3 年前
父节点
当前提交
9d0f012958
共有 1 个文件被更改,包括 11 次插入4 次删除
  1. +11
    -4
      common/models/Document.php

+ 11
- 4
common/models/Document.php 查看文件

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


正在加载...
取消
保存