$curators = Profile::find()
->leftJoin('auth_assignment', 'auth_assignment.user_id = profile.user_id')
->leftJoin('user', 'user.id = profile.user_id')
->where(['item_name' => 'curator']);
$agents = User::getChildrenSQL($curator->user_id);
$usersChild = ArrayHelper::getColumn($agents, function ($element) {
return (int)$element['id'];
});
$usersChild[] = $curator->user_id;
$policies = Policy::find()->where(['IN', 'user_id', $usersChild])
->andWhere(['status' => 'payed'])
public function curatorSearch($params)
{
$curators = Profile::find()
->leftJoin('auth_assignment', 'auth_assignment.user_id = profile.user_id')
->leftJoin('user', 'user.id = profile.user_id')
->where(['item_name' => 'curator']);
$dataProvider = new ActiveDataProvider([
'query' => $curators,
'sort' => ['defaultOrder' => [
'count' => SORT_DESC
]],
'pagination' => ['pageSize' => 10],
]);
$this->load($params);
$curators->andFilterWhere(['like', 'full_name', $this->full_name])
->andFilterWhere(['=', 'profile.user_id', $this->user_id]);
return $dataProvider;
}
foreach ($curators->all() as $item) {
$agents = User::getChildrenSQL($item->user_id);
$usersChild = ArrayHelper::getColumn($agents, function ($element) {
return (int)$element['id'];
});
$usersChild[] = $item->user_id;
$this->count = Policy::find()->where(['IN', 'user_id', $usersChild])->andWhere(['status' => 'payed'])->count();
}
$dataProvider->setSort([
'attributes'=>[
$this->count => [
'asc'=>['count'=>SORT_ASC,],
'desc'=>['count'=>SORT_DESC],
'default' => SORT_DESC
],
]
]);
$dataProvider = new ActiveDataProvider([
'query' => $curators,
'sort' => ['defaultOrder' => [
'count' => SORT_DESC
]],
'pagination' => ['pageSize' => 10],
]);
[
'attribute' => 'count',
],
if ($('#driver-foreign_license').prop('checked')) {
$('#driver-license_series, #driver-license_number').inputmask.remove();
}
'components' => [
'formatter' => [
'dateFormat' => 'php:d.m.Y',
'nullDisplay' => '',
'defaultTimeZone' => 'Europe/Moscow',
'decimalSeparator' => '.',
'thousandSeparator' => ' ',
'currencyCode' => 'RUB',
],
]