user card search fix

This commit is contained in:
Kavalar 2023-05-04 17:53:14 +03:00
parent 5c9411726f
commit 80c11b55ca

View File

@ -15,6 +15,7 @@ class UserCardSearch extends UserCard
{ {
public $skills; public $skills;
public $total; public $total;
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
@ -48,17 +49,10 @@ class UserCardSearch extends UserCard
if (Yii::$app->user->can('show_all_profiles')) { if (Yii::$app->user->can('show_all_profiles')) {
$query = UserCard::find(); $query = UserCard::find();
} else { } else {
$userCard = User::find() $employeeIdList = ManagerEmployee::find()
->where(['id' => Yii::$app->user->id]) ->where(['manager_id' => Yii::$app->user->id])
->one(); ->select('employee_id')
->column();
$employeeIdList = false;
if (isset($userCard->manager)) {
$employeeIdList = ManagerEmployee::find()
->where(['manager_id' => Yii::$app->user->id])
->select('employee_id')
->column();
}
$query = UserCard::find()->where(['in', 'user_card.id', $employeeIdList]); $query = UserCard::find()->where(['in', 'user_card.id', $employeeIdList]);
} }
@ -88,8 +82,8 @@ class UserCardSearch extends UserCard
$query->andFilterWhere(['=', 'DAY(dob)', $params['day']]); $query->andFilterWhere(['=', 'DAY(dob)', $params['day']]);
} }
if (isset($params['date'])) { if (isset($params['date'])) {
$query->andFilterWhere(['=', 'MONTH(dob)', substr($params['date'], 5,2)]); $query->andFilterWhere(['=', 'MONTH(dob)', substr($params['date'], 5, 2)]);
$query->andFilterWhere(['=', 'DAY(dob)', substr($params['date'],8,2)]); $query->andFilterWhere(['=', 'DAY(dob)', substr($params['date'], 8, 2)]);
} }
// grid filtering conditions // grid filtering conditions