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}
*/
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
'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()) {
'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;
}
}
'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',