]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Добавление фильтров origin/feature_fomichev_erp-466_add_filter_to_admin-person-bonuses
authorVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Fri, 12 Sep 2025 09:43:56 +0000 (12:43 +0300)
committerVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Fri, 12 Sep 2025 09:43:56 +0000 (12:43 +0300)
erp24/records/AdminPersonBonusesSearch.php
erp24/views/admin_person_bonuses/index.php

index 038cf5f4c6fe796dc56899876e0726d7d97cb3a7..9b75758ea344cefe3cd03f895db68a4c0a1708f3 100755 (executable)
@@ -17,12 +17,26 @@ class AdminPersonBonusesSearch extends AdminPersonBonuses
     public function rules()
     {
         return [
-            [['id', 'admin_id', 'year', 'month', 'vacation_day', 'bonuses', 'retention', 'prepaid_expense', 'counting'], 'integer'],
+            [['id',
+                'admin_id',
+                'year',
+                'month',
+                'vacation_day',
+                'bonuses',
+                'retention',
+                'prepaid_expense',
+                'counting',
+                'color_ruble_bonuses'
+            ], 'integer'],
+            [['adminName', 'adminGroup', 'store'], 'safe'],
             [['date', 'shift_correction', 'date_time'], 'safe'],
+            [['overtime'], 'number'],
         ];
     }
 
-    public string $adminName;
+    public string $adminName = '';
+    public string $adminGroup = '';
+    public string $store = '';
 
     /**
      * {@inheritdoc}
@@ -42,7 +56,10 @@ class AdminPersonBonusesSearch extends AdminPersonBonuses
      */
     public function search($params)
     {
-        $query = AdminPersonBonuses::find();
+        $query = AdminPersonBonuses::find()
+            ->joinWith(['admin a'])
+            ->joinWith(['adminGroup ag'])
+            ->joinWith(['store s']);
 
         // add conditions that should always apply here
 
@@ -50,6 +67,28 @@ class AdminPersonBonusesSearch extends AdminPersonBonuses
             'query' => $query,
         ]);
 
+        $dataProvider->setSort([
+            'attributes' => [
+                'id','admin_id','year','month','date_time',
+                'adminName' => [
+                    'asc'  => ['a.name' => SORT_ASC],
+                    'desc' => ['a.name' => SORT_DESC],
+                    'label'=> 'Сотрудник',
+                ],
+                'adminGroup' => [
+                    'asc'  => ['ag.name' => SORT_ASC],
+                    'desc' => ['ag.name' => SORT_DESC],
+                    'label' => 'Должность',
+                ],
+                'store' => [
+                    'asc'  => ['s.name' => SORT_ASC],
+                    'desc' => ['s.name' => SORT_DESC],
+                    'label' => 'Магазин',
+                ],
+            ],
+            'defaultOrder' => ['id' => SORT_DESC],
+        ]);
+
         $this->load($params);
 
         if (!$this->validate()) {
@@ -69,11 +108,15 @@ class AdminPersonBonusesSearch extends AdminPersonBonuses
             'retention' => $this->retention,
             'prepaid_expense' => $this->prepaid_expense,
             'counting' => $this->counting,
+            'color_ruble_bonuses' => $this->color_ruble_bonuses,
+            'overtime' => $this->overtime,
             'date_time' => $this->date_time,
         ]);
 
         $query->andFilterWhere(['like', 'date', $this->date]);
-
+        $query->andFilterWhere(['ilike', 'a.name', $this->adminName]);
+        $query->andFilterWhere(['ilike', 'ag.name', $this->adminGroup]);
+        $query->andFilterWhere(['ilike', 's.name', $this->store]);
         return $dataProvider;
     }
 }
index a8cffb8c42a0ca50f024d71943e92756662df855..c5b47d2c80522dd63046c6d7857c2c591ada9426 100755 (executable)
@@ -40,9 +40,27 @@ $this->params['breadcrumbs'][] = $this->title;
                 'filter' => ArrayHelper::map(\yii_app\records\Admin::find()->andWhere(['group_id' => Admin::ADMIN_CABINET_GROUP_IDS])->orderBy(['name_full' => SORT_ASC])->all(), 'id', 'name_full'),
                 'filterInputOptions' => ['class' => 'form-control form-control-sm']
             ],
-            'admin.name:text:Сотрудник',
-            'adminGroup.name:text:Должность',
-            'store.name:text:Магазин',
+            [
+                'attribute' => 'adminName',
+                'value'     => 'admin.name',
+                'label'     => 'Сотрудник',
+                'filter' => ArrayHelper::map(\yii_app\records\Admin::find()->andWhere(['group_id' => Admin::ADMIN_CABINET_GROUP_IDS])->orderBy(['name' => SORT_ASC])->all(), 'name', 'name'),
+                'filterInputOptions' => ['class' => 'form-control form-control-sm']
+            ],
+            [
+                'attribute' => 'adminGroup',
+                'value'     => 'adminGroup.name',
+                'label'     => 'Должность',
+                'filter' => ArrayHelper::map(\yii_app\records\AdminGroup::find()->andWhere(['id' => Admin::ADMIN_CABINET_GROUP_IDS])->orderBy(['name' => SORT_ASC])->all(), 'name', 'name'),
+                'filterInputOptions' => ['class' => 'form-control form-control-sm']
+            ],
+            [
+                'attribute' => 'store',
+                'value'     => 'store.name',
+                'label'     => 'Магазин',
+                'filter' => ArrayHelper::map(\yii_app\records\CityStore::find()->orderBy(['name' => SORT_ASC])->all(), 'name', 'name'),
+                'filterInputOptions' => ['class' => 'form-control form-control-sm']
+            ],
 //            'date',
 //            'year',
 //            'month',