From acbe6e775fb14a14287dc8d88050c24de89dd807 Mon Sep 17 00:00:00 2001 From: marina Date: Tue, 17 Dec 2024 12:10:17 +0300 Subject: [PATCH] =?utf8?q?ERP-259=20=D0=94=D0=BE=D1=80=D0=B0=D0=B1=D0=BE?= =?utf8?q?=D1=82=D0=BA=D0=B0=20=D0=B2=D1=82=D0=BE=D1=80=D0=BE=D0=B3=D0=BE?= =?utf8?q?=20=D1=88=D0=B0=D0=B3=D0=B0=20=D0=BF=D0=B5=D1=80=D0=B5=D0=B4?= =?utf8?q?=D0=B0=D1=87=D0=B8=20=D1=81=D0=BC=D0=B5=D0=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/controllers/ShiftTransferController.php | 13 +++++++++-- erp24/views/shift-transfer/_replacement.php | 23 +++++++++---------- erp24/web/js/shift-transfer/replacement.js | 4 +++- 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/erp24/controllers/ShiftTransferController.php b/erp24/controllers/ShiftTransferController.php index 00a43815..24db308a 100644 --- a/erp24/controllers/ShiftTransferController.php +++ b/erp24/controllers/ShiftTransferController.php @@ -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, diff --git a/erp24/views/shift-transfer/_replacement.php b/erp24/views/shift-transfer/_replacement.php index a7edf2b5..a12cfcc0 100644 --- a/erp24/views/shift-transfer/_replacement.php +++ b/erp24/views/shift-transfer/_replacement.php @@ -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(); ?> - ?>
'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' => 'Количество', + 'title' => 'Необходимое количество', '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'] ?? ''; }, diff --git a/erp24/web/js/shift-transfer/replacement.js b/erp24/web/js/shift-transfer/replacement.js index 1a113750..d8a8ba43 100644 --- a/erp24/web/js/shift-transfer/replacement.js +++ b/erp24/web/js/shift-transfer/replacement.js @@ -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 = ''; } }); } -- 2.39.5