From: marina Date: Fri, 13 Dec 2024 10:18:35 +0000 (+0300) Subject: ERP-259 Доработка второго шага передачи смен X-Git-Tag: 1.7~169^2~1 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=39d21039160c7a602ea2eaf2668268803d2de8b9;p=erp24_rep%2Fyii-erp24%2F.git ERP-259 Доработка второго шага передачи смен --- diff --git a/erp24/controllers/ShiftTransferController.php b/erp24/controllers/ShiftTransferController.php index 9f2d0354..53632e2b 100644 --- a/erp24/controllers/ShiftTransferController.php +++ b/erp24/controllers/ShiftTransferController.php @@ -267,7 +267,7 @@ class ShiftTransferController extends Controller WaybillWriteOffs::setData($model); } - $this->redirect(Yii::$app->request->referrer); + return $this->redirect(Yii::$app->request->referrer); } $shiftTransfer = ShiftTransfer::findOne($id); diff --git a/erp24/records/WaybillIncomingProducts.php b/erp24/records/WaybillIncomingProducts.php index 8ee8c107..63d8c5b1 100644 --- a/erp24/records/WaybillIncomingProducts.php +++ b/erp24/records/WaybillIncomingProducts.php @@ -72,17 +72,18 @@ class WaybillIncomingProducts extends \yii\db\ActiveRecord $itemCount = abs($item->fact_and_1c_diff); $er = EqualizationRemains::findOne([ 'shift_transfer_id' => $shiftTransfer->id, - 'product_id' => $item->product_guid + 'product_replacement_id' => $item->product_guid ]); - + $count = 0; if ($er) { if ($er->product_count == $itemCount) { return; } - $count = $er->product_count > $itemCount - ? $er->product_count - $itemCount - : $er->product_count; + if ($itemCount > $er->product_count) { + $count = $itemCount - $er->product_count; + } + } else { $count = $itemCount; } diff --git a/erp24/records/WaybillWriteOffsProducts.php b/erp24/records/WaybillWriteOffsProducts.php index 6f9bec60..8adf0880 100644 --- a/erp24/records/WaybillWriteOffsProducts.php +++ b/erp24/records/WaybillWriteOffsProducts.php @@ -77,14 +77,16 @@ class WaybillWriteOffsProducts extends \yii\db\ActiveRecord 'product_id' => $item->product_guid ]); + if ($er) { if ($er->product_count == $itemCount) { return; } - $count = $er->product_count > $itemCount - ? $er->product_count - $itemCount - : $er->product_count; + if ($itemCount > $er->product_count) { + $count = $itemCount - $er->product_count; + } + } else { $count = $itemCount; } diff --git a/erp24/views/shift-transfer/_replacement.php b/erp24/views/shift-transfer/_replacement.php index 446a97df..66ad1309 100644 --- a/erp24/views/shift-transfer/_replacement.php +++ b/erp24/views/shift-transfer/_replacement.php @@ -19,8 +19,8 @@ use yii\widgets\ActiveForm; $this->registerJsFile('/js/shift-transfer/replacement.js', ['position' => \yii\web\View::POS_END]); $totalBalance = array_sum(array_column($shiftTransfer->equalizationRemains, 'balance')); -$writeOffsBalance = \yii_app\records\WaybillWriteOffs::findOne(['shift_transfer_id' => $shiftTransfer->id])->summ ?? null; -$incomingBalance = \yii_app\records\WaybillIncoming::findOne(['shift_transfer_id' => $shiftTransfer->id])->summ ?? null; +$writeOffsBalance = \yii_app\records\WaybillWriteOffs::findOne(['shift_transfer_id' => $shiftTransfer->id])->summ ?? 0; +$incomingBalance = \yii_app\records\WaybillIncoming::findOne(['shift_transfer_id' => $shiftTransfer->id])->summ ?? 0; $form = \yii\widgets\ActiveForm::begin(); ?> @@ -168,18 +168,12 @@ if (in_array($shiftTransfer->status_id, [ShiftTransfer::STATUS_ID_TRANSFER_ACTIO 'iconSource' => 'fa', ])->label(false); - echo $btn = Html::submitButton('Продолжить', [ + echo Html::submitButton('Продолжить', [ 'class' => 'btn btn-primary float-right', 'name' => 'action', 'value' => 'resume' ]); - ?> - - - - new \yii\data\ArrayDataProvider([ 'allModels' => $shiftTransfer->equalizationRemains, @@ -335,15 +329,15 @@ if (in_array($shiftTransfer->status_id, [ShiftTransfer::STATUS_ID_TRANSFER_ACTIO status_id == ShiftTransfer::STATUS_OF_THE_FORMATION_OF_SURPLUSES_AND_SHORTAGES && Yii::$app->user->id == $shiftTransfer->end_shift_admin_id) { - echo $btn = Html::submitButton('Назад', [ - 'class' => 'btn btn-primary float-right', - 'name' => 'action', - 'value' => 'rejection' - ]) . '  ' . Html::submitButton('Сохранить', [ - 'class' => 'btn btn-success float-right', - 'name' => 'action', - 'value' => 'save' - ]); + echo Html::submitButton('Назад', [ + 'class' => 'btn btn-primary float-right', + 'name' => 'action', + 'value' => 'rejection' + ]) . '  ' . Html::submitButton('Сохранить', [ + 'class' => 'btn btn-success float-right', + 'name' => 'action', + 'value' => 'save' + ]); } if (