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

index 00a4381594ba2a5de2346e79554a59ff9392bf88..24db308afafedb44159be6b286c5f78bfbd529ee 100644 (file)
@@ -426,11 +426,20 @@ class ShiftTransferController extends Controller
     {
         \Yii::$app->response->format = Response::FORMAT_JSON;
 
-        $product = Products1c::findOne(['name' => $productName]);
+        if (preg_match('/^[a-f0-9\-]{36}$/i', $productName)) {
+            $productId = $productName;
+        } else {
+            if (preg_match('/^(.*)\s\(арт\.\s(\d+)\)$/', $productName, $matches)) {
+                $productId = Products1c::findOne(['name' => $matches[1], 'articule' => $matches[2]])->id;
+            } else {
+                $productId = null;
+            }
+        }
+
+        $product = Products1c::findOne(['id' => $productId]);
 
         if ($product) {
             $shiftRemain = ShiftRemains::findOne(['shift_transfer_id' => $shiftTransferId, 'product_guid' => $product->id]);
-
             if ($shiftRemain) {
                 return [
                     'maxValue' => $shiftRemain->fact_and_1c_diff ?? 0,
index a7edf2b5267cf16dec3843971bffa4e68180e088..a12cfcc00b8c629df803fb7bbdea16fbde91b456 100644 (file)
@@ -24,7 +24,6 @@ $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']); ?>
@@ -72,17 +71,17 @@ if (in_array($shiftTransfer->status_id, [ShiftTransfer::STATUS_ID_TRANSFER_ACTIO
             ],
             [
                 'name' => 'product_price',
-                'type' => BaseColumn::TYPE_TEXT_INPUT,
-                'options' => ['type' => 'number', 'step' => 0.01, 'readonly' => true,],
+                'type' => BaseColumn::TYPE_TEXT_INPUT, // Если это верно, оставляем так.
+                'options' => ['type' => 'number', 'step' => 0.01, 'readonly' => true],
                 'title' => 'Цена товара',
                 'value' => function ($data) {
-                    return $data['product_price'] ?? '';
+                    return isset($data['product_price']) ? $data['product_price'] : '';
                 },
             ],
             [
                 'name' => 'product_self_cost',
-                'type' => BaseColumn::TYPE_TEXT_INPUT,
-                'options' => ['type' => 'number', 'step' => 0.01, 'readonly' => true,],
+                'type' => BaseColumn::TYPE_HIDDEN_INPUT,
+                'options' => ['step' => 0.01, 'readonly' => true,],
                 'title' => 'Себестоимость товара',
                 'value' => function ($data) {
                     return $data['product_self_cost'] ?? '';
@@ -92,9 +91,9 @@ if (in_array($shiftTransfer->status_id, [ShiftTransfer::STATUS_ID_TRANSFER_ACTIO
                 'name' => 'product_count',
                 'type' => BaseColumn::TYPE_TEXT_INPUT,
                 'options' => ['type' => 'number', 'step' => 1, 'readonly' => true,],
-                'title' => 'Ð\9aоличество',
+                'title' => 'Ð\9dеобÑ\85одимое Ðºоличество',
                 'value' => function ($data) {
-                    return $data['product_count'] ?? '';
+                    return !empty($data) ? abs($data['product_count']) : '';
                 }
             ],
             [
@@ -136,8 +135,8 @@ if (in_array($shiftTransfer->status_id, [ShiftTransfer::STATUS_ID_TRANSFER_ACTIO
             ],
             [
                 'name' => 'product_replacement_self_cost',
-                'type' => BaseColumn::TYPE_TEXT_INPUT,
-                'options' => ['type' => 'number', 'step' => 0.01, 'readonly' => true,],
+                'type' => BaseColumn::TYPE_HIDDEN_INPUT,
+                'options' => ['step' => 0.01, 'readonly' => true,],
                 'title' => 'Себестоимость замещаемого товара',
                 'value' => function ($data) {
                     return $data['product_replacement_self_cost'] ?? '';
@@ -164,8 +163,8 @@ if (in_array($shiftTransfer->status_id, [ShiftTransfer::STATUS_ID_TRANSFER_ACTIO
             [
                 'name' => 'balance_self_cost',
                 'title' => 'Разница в сумме (Себестоиомость)',
-                'type' => BaseColumn::TYPE_TEXT_INPUT,
-                'options' => ['type' => 'number', 'step' => 0.01, 'readonly' => true,],
+                'type' => BaseColumn::TYPE_HIDDEN_INPUT,
+                'options' => ['step' => 0.01, 'readonly' => true,],
                 'value' => function ($data) {
                     return $data['balance_self_cost'] ?? '';
                 },
index 1a113750cbee12189d1eace58615fd7753822670..d8a8ba438cdc24866f13d974ef444a111fe2bc58 100644 (file)
@@ -37,7 +37,8 @@ function setProductData() {
             }
 
             const index = $this.closest('tr').data('index');
-            document.querySelector(`#shifttransfer-equalizationremains-${index}-product_replacement_count`).value = '';
+            $(`#shifttransfer-equalizationremains-${index}-product_replacement_count`).value = '';
+            $(`#shifttransfer-equalizationremains-${index}-product_replacement_price`).value = '';
             $('#shifttransfer-equalizationremains-' + index + '-product_price').val(data.product_price);
             $(`#shifttransfer-equalizationremains-${index}-product_count`).val(data.product_count);
 
@@ -240,6 +241,7 @@ function setDynamicMaxValue(inputElement, rowId) {
             }
         },
         error: function () {
+            $('#shifttransfer-equalizationremains-' + rowId + '-product_replacement_id').value = '';
         }
     });
 }