]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
[ERP-89] Мотивация rbac и фильтры feature_smirnov_erp-89_motivation_rbac_and_filters
authorAlexander Smirnov <fredeom@mail.ru>
Tue, 16 Jul 2024 12:19:35 +0000 (15:19 +0300)
committerAlexander Smirnov <fredeom@mail.ru>
Tue, 16 Jul 2024 12:19:35 +0000 (15:19 +0300)
erp24/actions/motivation/IndexAction.php [new file with mode: 0644]
erp24/controllers/MotivationController.php [new file with mode: 0644]
erp24/views/motivation/index.php [new file with mode: 0644]

diff --git a/erp24/actions/motivation/IndexAction.php b/erp24/actions/motivation/IndexAction.php
new file mode 100644 (file)
index 0000000..94a06fe
--- /dev/null
@@ -0,0 +1,29 @@
+<?php
+
+namespace yii_app\actions\motivation;
+
+use Yii;
+use yii\base\Action;
+use yii\base\DynamicModel;
+use yii\helpers\ArrayHelper;
+use yii_app\records\CityStore;
+
+class IndexAction extends Action
+{
+    public function run() {
+        $model = DynamicModel::validateData([
+                'store_id' => null, 'year' => null, 'month' => null
+            ], [
+                [['store_id', 'year', 'month'], 'safe']
+            ]);
+        $model->load(Yii::$app->request->get());
+
+        $stores = ArrayHelper::map(CityStore::find()->all(), 'id', 'name');
+
+        $years = [2023, 2024, 2025, 2026];
+        $months = ['Январь',' Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь'];
+
+        return $this->controller->render('index',
+            compact('model', 'stores', 'years', 'months'));
+    }
+}
\ No newline at end of file
diff --git a/erp24/controllers/MotivationController.php b/erp24/controllers/MotivationController.php
new file mode 100644 (file)
index 0000000..8175a6e
--- /dev/null
@@ -0,0 +1,30 @@
+<?php
+
+namespace app\controllers;
+
+use yii\filters\AccessControl;
+use yii\web\Controller;
+
+class MotivationController extends Controller
+{
+    public function actions() {
+        return [
+            'index' => \yii_app\actions\motivation\IndexAction::class,
+        ];
+    }
+
+    public function behaviors()
+    {
+        return [
+            'access' => [
+                'class' => AccessControl::class,
+                'rules' => [
+                    [
+                        'allow' => true,
+                        'permissions' => ['menu/motivation'],
+                    ]
+                ]
+            ]
+        ];
+    }
+}
\ No newline at end of file
diff --git a/erp24/views/motivation/index.php b/erp24/views/motivation/index.php
new file mode 100644 (file)
index 0000000..04a1860
--- /dev/null
@@ -0,0 +1,62 @@
+<?php
+
+use \yii\helpers\Html;
+use kartik\select2\Select2;
+use yii\widgets\ActiveForm;
+use yii\base\DynamicModel;
+
+/** @var $model DynamicModel */
+/** @var $stores array */
+/** @var $years array */
+/** @var $months array */
+
+?>
+
+<div class="motivationIndex m-5">
+
+    <?php $form = ActiveForm::begin(['method' => 'GET']) ?>
+
+    <div class="row">
+        <div class="col-4 d-flex justify-content-between align-items-center gap-4">
+            <div class="d-flex justify-content-around align-items-center gap-2">
+                <div class="mb-3">Магазин:</div>
+                <div style="display: inline-block"><?= $form->field($model, 'store_id')->widget(Select2::class, [
+                        'data' => $stores,
+                        'language' => 'ru',
+                        'options' => ['placeholder' => 'Магазин...'],
+                        'pluginOptions' => [
+                            'allowClear' => true
+                        ],
+                    ])->label(false) ?></div>
+            </div>
+            <div class="d-flex justify-content-around align-items-center gap-2">
+                <div class="mb-3">Год:</div>
+                <div style="display: inline-block"><?= $form->field($model, 'year')->widget(Select2::class, [
+                        'data' => $years,
+                        'language' => 'ru',
+                        'options' => ['placeholder' => 'Год...'],
+                        'pluginOptions' => [
+                            'allowClear' => true
+                        ],
+                    ])->label(false) ?></div>
+            </div>
+            <div class="d-flex justify-content-around align-items-center gap-2">
+                <div class="mb-3">Месяц:</div>
+                <div style="display: inline-block"><?= $form->field($model, 'month')->widget(Select2::class, [
+                        'data' => $months,
+                        'language' => 'ru',
+                        'options' => ['placeholder' => 'Месяц...'],
+                        'pluginOptions' => [
+                            'allowClear' => true
+                        ],
+                    ])->label(false) ?></div>
+            </div>
+            <div class="d-flex justify-content-around align-items-center gap-2">
+                <div class="mb-3"><?= Html::submitButton('Применить', ['class' => 'btn btn-secondary btn-sm'])?></div>
+            </div>
+        </div>
+    </div>
+
+    <?php ActiveForm::end() ?>
+
+</div>