]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
fix form salary data
authorJoySystem_v <fvv2011@gmail.com>
Thu, 8 Aug 2024 10:32:55 +0000 (13:32 +0300)
committerJoySystem_v <fvv2011@gmail.com>
Thu, 8 Aug 2024 10:32:55 +0000 (13:32 +0300)
erp24/actions/motivation/GetSalaryAction.php
erp24/views/motivation/run-sum-salary.php

index 6395ffd9a2a5e6ece5c97a3c13d0466a37fd6511..5fa26fda4c53bebbb7a8d5949b718002ff2aba9a 100644 (file)
@@ -5,6 +5,7 @@ namespace yii_app\actions\motivation;
 use Yii;
 use yii\base\Action;
 use yii\base\DynamicModel;
+use yii_app\models\SumSalaryForm;
 use yii_app\services\MotivationService;
 use yii_app\records\TimetableFactModel;
 use DateTime;
@@ -16,10 +17,12 @@ class GetSalaryAction extends Action
 
     public function run()
     {
-        $request = Yii::$app->request;
-        $store_id = $request->get('store_id', 1);
-        $month = $request->get('month', 7);
-        $year = $request->get('year', 2024);
+        $model = new SumSalaryForm();
+
+        if ($model->load(Yii::$app->request->post()) && $model->validate()) {
+            $store_id = $model->store_id;
+            $year = $model->year;
+            $month = $model->month;
         $records = [];
         $vacationSum = 0;
 
@@ -115,5 +118,10 @@ class GetSalaryAction extends Action
             'monthlyVacationSum' => $monthlyVacationSum,
             'monthlySalaryWithoutVacation' => $monthlySalaryWithoutVacation,
         ]);
+
+        } else {
+            Yii::warning("Неправильный ввод данных.");
+            return $this->controller->redirect(['motivation/index']);
+        }
     }
 }
index 554db4025919bfd7899687b9cd58057e6ac9d700..2f35fb6a2efc30c986bf0eb905321a6e8aa425de 100644 (file)
@@ -33,24 +33,24 @@ $this->title = 'Запуск экшена SumSalary';
     <?= Html::submitButton('Запустить', ['class' => 'btn btn-primary']) ?>
     <?= Html::endForm() ?>
 
-    <!--<p>Получить данные по сменам.</p>
+    <p>Получить данные по сменам.</p>
     <div class="get-salary-action">
-        <h1><?/*= Html::encode($this->title) */?></h1>
+        <h1><?= Html::encode($this->title) ?></h1>
 
-        <?php /*$form = ActiveForm::begin([
-            'method' => 'get',
+        <?php $form = ActiveForm::begin([
+            'method' => 'post',
             'action' => ['motivation/get-salary'],
-        ]); */?>
+        ]); ?>
 
-        <?/*= $form->field($model, 'store_id')->textInput() */?>
-        <?/*= $form->field($model, 'month')->textInput() */?>
-        <?/*= $form->field($model, 'year')->textInput() */?>
+        <?= $form->field($model, 'store_id')->textInput() ?>
+        <?= $form->field($model, 'month')->textInput() ?>
+        <?= $form->field($model, 'year')->textInput() ?>
 
         <div class="form-group">
-            <?/*= Html::submitButton('Получить данные', ['class' => 'btn btn-primary']) */?>
+            <?= Html::submitButton('Получить данные', ['class' => 'btn btn-primary']) ?>
         </div>
 
-        <?php /*ActiveForm::end(); */?>
-    </div>-->
+        <?php ActiveForm::end(); ?>
+    </div>
 
 </div>