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;
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;
'monthlyVacationSum' => $monthlyVacationSum,
'monthlySalaryWithoutVacation' => $monthlySalaryWithoutVacation,
]);
+
+ } else {
+ Yii::warning("Неправильный ввод данных.");
+ return $this->controller->redirect(['motivation/index']);
+ }
}
}
<?= 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>