From: marina Date: Tue, 17 Dec 2024 09:10:17 +0000 (+0300) Subject: ERP-259 Доработка второго шага передачи смен X-Git-Tag: 1.7~156^2~13 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=acbe6e775fb14a14287dc8d88050c24de89dd807;p=erp24_rep%2Fyii-erp24%2F.git ERP-259 Доработка второго шага передачи смен --- 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 = ''; } }); }