From aca607e28735f55c8b07d47c236a0ef893064b04 Mon Sep 17 00:00:00 2001 From: Alexander Smirnov Date: Tue, 21 May 2024 22:35:48 +0300 Subject: [PATCH] fix part 017 --- .../shipment/fields/write_offs_4week_sum.php | 19 ++++++++-------- .../modul/shipment/fields/write_offs_sum.php | 22 ++++++++++--------- erp24/modul/shipment/functionsShipment.php | 1 + 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/erp24/modul/shipment/fields/write_offs_4week_sum.php b/erp24/modul/shipment/fields/write_offs_4week_sum.php index d799f08..abf8965 100644 --- a/erp24/modul/shipment/fields/write_offs_4week_sum.php +++ b/erp24/modul/shipment/fields/write_offs_4week_sum.php @@ -5,19 +5,20 @@ global $orderStoresArrayRelation_in, $whereInProductsId, $date_start_sale; //списания за 4 недели среднее - 4-х недельное списание от даты старта / 4 = среднее за неделю в рублях $periodDaysStats=28; if(!empty($orderStoresArrayRelation_in) && !empty($date_start_sale)) { -$data2=$db::getRows("SELECT p.product_id,p.summ, w.store_id + $sql = "SELECT p.product_id,p.summ, w.store_id FROM write_offs as w, write_offs_products as p WHERE p.write_offs_id=w.id AND w.type='Брак' AND p.product_id $whereInProductsId AND w.store_id $orderStoresArrayRelation_in AND w.date<='$date_start_sale 00:00:00' -AND w.date>='$date_start_sale'::date -interval '$periodDaysStats day' group BY p.product_id,w.store_id"); - foreach($data2 as $row2) { - $a=round ($row2["summ"]/4) ; - if(!empty($a)) { - $data_up[$row2["product_id"]][$row2["store_id"]][0]=$a; - $data_up[$row2["product_id"]][0][0] +=$a; - } - } +AND w.date>='$date_start_sale'::date -interval '$periodDaysStats day' group BY p.product_id,w.store_id, p.summ"; + $data2=$db::getRows($sql); + foreach($data2 as $row2) { + $a=round ($row2["summ"]/4) ; + if(!empty($a)) { + $data_up[$row2["product_id"]][$row2["store_id"]][0] = $a; + $data_up[$row2["product_id"]][0][0] = ($data_up[$row2["product_id"]][0][0] ?? 0) + $a; + } + } } \ No newline at end of file diff --git a/erp24/modul/shipment/fields/write_offs_sum.php b/erp24/modul/shipment/fields/write_offs_sum.php index 67df15d..2e390f7 100644 --- a/erp24/modul/shipment/fields/write_offs_sum.php +++ b/erp24/modul/shipment/fields/write_offs_sum.php @@ -5,17 +5,19 @@ global $orderStoresArrayRelation_in, $date_start_sale, $whereInProductsId; if(!empty($orderStoresArrayRelation_in) and !empty($date_start_sale) and !empty($products)) { - $periodDaysStats=7; - -$data2=$db::getRows("SELECT p.product_id, p.summ, w.store_id + $periodDaysStats=7; + + $sql = "SELECT p.product_id, p.summ, w.store_id FROM write_offs as w, write_offs_products as p WHERE p.write_offs_id=w.id AND w.type='Брак' AND p.product_id $whereInProductsId AND w.store_id $orderStoresArrayRelation_in -AND w.date<='$date_start_sale 00:00:00' AND w.date>='$date_start_sale'::date -interval '$periodDaysStats day' group BY p.product_id,w.store_id"); - foreach($data2 as $row2) { - $a=$row2["summ"]; - $data_up[$row2["product_id"]][$row2["store_id"]][0]=$a; - $data_up[$row2["product_id"]][0][0] = ($data_up[$row2["product_id"]][0][0] ?? 0) +$a; - } - } \ No newline at end of file +AND w.date<='$date_start_sale 00:00:00' AND w.date>='$date_start_sale'::date -interval '$periodDaysStats day' group BY p.product_id,w.store_id, p.summ"; +// var_dump($sql); die; + $data2=$db::getRows($sql); + foreach($data2 as $row2) { + $a=$row2["summ"]; + $data_up[$row2["product_id"]][$row2["store_id"]][0] = $a; + $data_up[$row2["product_id"]][0][0] = ($data_up[$row2["product_id"]][0][0] ?? 0) + $a; + } +} \ No newline at end of file diff --git a/erp24/modul/shipment/functionsShipment.php b/erp24/modul/shipment/functionsShipment.php index f583973..7a1d426 100644 --- a/erp24/modul/shipment/functionsShipment.php +++ b/erp24/modul/shipment/functionsShipment.php @@ -23,6 +23,7 @@ $orderStoresArrayRelation_in // SQL условие для выборки по , $productGroupArray // массив с ID подгруппы группы товаров для автозакупки Короткие розы ,$related_order_id ,$date_start_division +,$date_start_sale //,$param ; -- 2.39.5