]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
ERP-259 Доработка второго шага передачи смен
authormarina <m.zozirova@gmail.com>
Tue, 17 Dec 2024 07:22:25 +0000 (10:22 +0300)
committermarina <m.zozirova@gmail.com>
Tue, 17 Dec 2024 07:22:25 +0000 (10:22 +0300)
erp24/controllers/ShiftTransferController.php
erp24/records/EqualizationRemains.php
erp24/records/WaybillIncomingProducts.php
erp24/records/WaybillWriteOffsProducts.php
erp24/views/shift-transfer/_replacement.php
erp24/web/js/shift-transfer/replacement.js

index 53632e2bc0f37c84604c5b744dd89cc9e1780f0d..2e120b25bbdf42816712bd9ba364d433cc4ebf9c 100644 (file)
@@ -282,7 +282,9 @@ class ShiftTransferController extends Controller
                     ->andWhere(['shift_transfer_id' => $id])
                     ->andWhere(['<', 'fact_and_1c_diff', 0])
                     ->select('product_guid')->column()]),
-            'id', 'name');
+            'id', function($model) {
+            return $model->name . ' (арт. ' . $model->articule . ')';
+        });
 
         return $this->render('view',
             compact('shiftTransfer', 'storeNameById', 'admins', 'products'));
index bad1ff4eba50268623a90cad225ed3774a615982..4b0b995bf461c12f09a883f7a4b12e112f54ad3c 100644 (file)
@@ -105,6 +105,16 @@ class EqualizationRemains extends \yii\db\ActiveRecord
         }
 
         foreach ($equalizationRemains as $er) {
+            if (preg_match('/^[a-f0-9\-]{36}$/i', $er['product_replacement_id'])) {
+                $productReplacementId = $er['product_replacement_id'];
+            } else {
+                if (preg_match('/^(.*)\s\(арт\.\s(\d+)\)$/', $er['product_replacement_id'], $matches)) {
+                    $productReplacementId = Products1c::findOne(['name' => $matches[1], 'articule' => $matches[2]])->id;
+                } else {
+                    $productReplacementId = null;
+                }
+            }
+
             $equalizationRemain = new EqualizationRemains();
             $equalizationRemain->setAttributes([
                 'shift_transfer_id' => $shift_transfer_id,
@@ -112,7 +122,7 @@ class EqualizationRemains extends \yii\db\ActiveRecord
                 'product_count' => $er['product_replacement_count'],
                 'product_price' => $er['product_price'],
                 'product_self_cost' => $er['product_self_cost'],
-                'product_replacement_id' => Products1c::findOne(['name' => $er['product_replacement_id']])->id ?? $er['product_replacement_id'],
+                'product_replacement_id' => $productReplacementId ?? '',
                 'product_replacement_count' => $er['product_replacement_count'],
                 'product_replacement_price' => $er['product_replacement_price'],
                 'product_replacement_self_cost' => $er['product_replacement_self_cost'],
index 2dbcd71e2994218109913c5c9f182f3e58d95d08..5acff155f2028de7228d0ac8fbfc8573d145dcbf 100644 (file)
@@ -140,4 +140,8 @@ class WaybillIncomingProducts extends \yii\db\ActiveRecord
     {
         return $this->hasOne(WaybillIncoming::class, ['id' => 'waybill_incoming_id']);
     }
+
+    public function getProduct() {
+        return $this->hasOne(Products1c::class, ['id' => 'product_id']);
+    }
 }
index 508cc733e46bac28507113b32077d05c21661ca8..87173039a1c3e9db30e22149b68403bb11da56ef 100644 (file)
@@ -141,4 +141,8 @@ class WaybillWriteOffsProducts extends \yii\db\ActiveRecord
     {
         return $this->hasOne(WaybillWriteOffs::class, ['id' => 'waybill_write_offs_id']);
     }
+
+    public function getProduct() {
+        return $this->hasOne(Products1c::class, ['id' => 'product_id']);
+    }
 }
index 8bad38061efbebbd6c67c5e5cd28ffa60ca52c7c..49d12a91d4495b57735ef6a139be151d8a36e432 100644 (file)
@@ -7,6 +7,7 @@ use unclead\multipleinput\MultipleInput;
 use yii\data\ArrayDataProvider;
 use yii\helpers\Html;
 use yii\helpers\Url;
+use yii_app\records\Products1c;
 use yii_app\records\ShiftTransfer;
 use yii\widgets\ActiveForm;
 
@@ -23,7 +24,7 @@ $writeOffsBalance = \yii_app\records\WaybillWriteOffs::findOne(['shift_transfer_
 $incomingBalance = \yii_app\records\WaybillIncoming::findOne(['shift_transfer_id' => $shiftTransfer->id])->summ ?? 0;
 
 $form = \yii\widgets\ActiveForm::begin(); ?>
-
+    ?>
     <div class="row py-2">
         <div class="col-2">
             <?= Html::label('Таблица замен', null, ['class' => 'h4 font-weight-bold']); ?>
@@ -68,9 +69,6 @@ if (in_array($shiftTransfer->status_id, [ShiftTransfer::STATUS_ID_TRANSFER_ACTIO
                         'change' => new \yii\web\JsExpression('function() { setProductData.call(this); }'),
                     ],
                 ],
-                'value' => function ($model) {
-                    return $model->product->id ?? '';
-                },
             ],
             [
                 'name' => 'product_price',
@@ -118,9 +116,14 @@ if (in_array($shiftTransfer->status_id, [ShiftTransfer::STATUS_ID_TRANSFER_ACTIO
                     }'),
                     ],
                 ],
-                'value' => function ($model) {
-                    return $model->productReplacement->name ?? '';
+                'value' => function ($data) {
+                    if (!empty($data)) {
+                        $product = Products1c::findOne($data['product_replacement_id']);
+                        return $product->name . ' (арт. ' . $product->articule . ')';
+                    }
+                    return '';
                 },
+
             ],
             [
                 'name' => 'product_replacement_price',
@@ -196,7 +199,7 @@ if (in_array($shiftTransfer->status_id, [ShiftTransfer::STATUS_ID_TRANSFER_ACTIO
                 'attribute' => 'product_id',
                 'label' => 'Товар',
                 'value' => function ($model) {
-                    return $model->product->name;
+                    return $model->product->name . ' (арт. ' . $model->product->articule . ')';
                 },
                 'pageSummary' => Html::tag('b', 'Итого'),
             ],
@@ -214,7 +217,7 @@ if (in_array($shiftTransfer->status_id, [ShiftTransfer::STATUS_ID_TRANSFER_ACTIO
                 'attribute' => 'product_replacement_id',
                 'label' => 'Товар замена',
                 'value' => function ($model) {
-                    return $model->productReplacement->name;
+                    return $model->productReplacement->name . ' (арт. ' . $model->productReplacement->articule . ')';
                 }
             ],
             [
@@ -270,6 +273,9 @@ if (in_array($shiftTransfer->status_id, [ShiftTransfer::STATUS_ID_TRANSFER_ACTIO
                         'label' => 'Товар',
                         'attribute' => 'name',
                         'pageSummary' => 'Итого:',
+                        'value' => function ($model) {
+                            return $model->product->name . ' (арт. ' . $model->product->articule . ')';
+                        }
                     ],
                     [
                         'label' => 'Количество товара',
@@ -310,6 +316,9 @@ if (in_array($shiftTransfer->status_id, [ShiftTransfer::STATUS_ID_TRANSFER_ACTIO
                     'label' => 'Товар',
                     'attribute' => 'name',
                     'pageSummary' => 'Итого:',
+                    'value' => function ($model) {
+                        return $model->product->name . ' (арт. ' . $model->product->articule . ')';
+                    }
                 ],
                 [
                     'label' => 'Количество товара',
index a74a3121716a8c190e7e06bf586b7e6abb3742b4..7744833b78c0ce44b27a4360203d9947a74c025f 100644 (file)
@@ -258,7 +258,7 @@ $('.field-shifttransfer-equalizationremains').on('input', '.list-cell__product_r
 $(window).on('load', function() {
     setTimeout(function() {
         $('.field-shifttransfer-equalizationremains [class$="-product_id"]').css('pointer-events', 'none');
-    }, 5000); // Задержка в 1 секунду (можно настроить)
+    }, 5000);
 });