]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Лист с остатками GUID 2
authorAlexander Smirnov <fredeom@mail.ru>
Fri, 13 Dec 2024 14:31:09 +0000 (17:31 +0300)
committerAlexander Smirnov <fredeom@mail.ru>
Fri, 13 Dec 2024 14:31:09 +0000 (17:31 +0300)
erp24/controllers/ShiftTransferController.php

index 4269dd8cc361f2d17c3ffec428f80d1d15115f3a..3d27fd4ce72c5d45bf47e6fecf16c25150dfcf72 100644 (file)
@@ -61,7 +61,7 @@ class ShiftTransferController extends Controller
         return $this->render('index', compact('shiftTransfers', 'storeNameById', 'admins'));
     }
 
-    public function buildLoadDataShiftRemains($groups, $storeGuid)
+    public function buildLoadDataShiftRemains($groups, $storeGuid, $normal = true)
     {
         $productsClass = ProductsClass::find()->select(['category_id'])->where(['tip' => $groups])->column();
         $products = ArrayHelper::map(Products1c::find()->alias('p')->select(['id', 'name'])->leftJoin('products_class pc', 'pc.category_id = p.parent_id')
@@ -74,9 +74,11 @@ class ShiftTransferController extends Controller
             if (isset($balance[$key]) && $balance[$key] > 0) {
                 $productGuids[$key] = $name . ' (' . $balance[$key] . ' шт.)';
             }
-//            else {
-//                $productGuids[$key] = $name;
-//            }
+            else {
+                if (!$normal) {
+                    $productGuids[$key] = $name;
+                }
+            }
         }
         $price = ArrayHelper::map(Prices::find()->select(['product_id', 'price'])->where(['product_id' => array_keys($products)])->all(), 'product_id', 'price');
         $storeEIT = ExportImportTable::find()->select(['entity_id'])->where(['entity' => 'city_store', 'export_val' => $storeGuid, 'export_id' => 1])->one();
@@ -126,9 +128,12 @@ class ShiftTransferController extends Controller
 
         $shiftTransfer->shiftRemainsCopy = $loadDataShiftRemains ?? $shiftTransfer->shiftRemains;
 
+        $data = self::buildLoadDataShiftRemains($shiftTransfer->groups2, $firstId, false);
+        $productGuidsUnnormal = $data['productGuids'];
+
         $existingKeys = ArrayHelper::getColumn($shiftTransfer->shiftRemainsCopy, 'product_guid');
         $productGuidsForRest = [];
-        foreach ($productGuids as $key => $value) {
+        foreach ($productGuidsUnnormal as $key => $value) {
             if (!in_array($key, $existingKeys)) {
                 $productGuidsForRest[$key] = $value;
             }
@@ -212,9 +217,12 @@ class ShiftTransferController extends Controller
 
         $shiftTransfer->shiftRemainsCopy = $loadDataShiftRemains ?? $shiftTransfer->shiftRemains;
 
+        $data = self::buildLoadDataShiftRemains($shiftTransfer->groups2, $firstId, false);
+        $productGuidsUnnormal = $data['productGuids'];
+
         $existingKeys = ArrayHelper::getColumn($shiftTransfer->shiftRemainsCopy, 'product_guid');
         $productGuidsForRest = [];
-        foreach ($productGuids as $key => $value) {
+        foreach ($productGuidsUnnormal as $key => $value) {
             if (!in_array($key, $existingKeys)) {
                 $productGuidsForRest[$key] = $value;
             }