user->getId();
?>
= Html::button('Выделить все', [
'class' => 'btn btn-outline-secondary',
'id' => 'checkAll',
]) ?>
= Html::button('Снять выделение', [
'class' => 'btn btn-outline-secondary',
'id' => 'uncheckAll',
]) ?>
true,
'headerContainer' => ['class' => 'thead-light'],
'tableOptions' => ['class' => 'table-sm'],
'striped' => false,
'summary' => false,
'pager' => [
'firstPageLabel' => '<<',
'prevPageLabel' => '<',
'nextPageLabel' => '>',
'lastPageLabel' => '>>',
],
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'id' => 'custom-users-grid',
'filterUrl' => ['user/index'],
'columns' => [
[
'class' => CheckboxColumn::class,
'contentOptions' => ['style' => 'width: 30px'],
'checkboxOptions' => function ($model, $key, $index, $column) use ($exceptions) {
$role = Yii::$app->authManager->getRolesByUser($model->id);
$result = array_diff(array_keys($role), $exceptions);
if (!empty($result)) {
return ['value' => $key];
}
return [
'disabled' => true,
'class' => 'disabled_checkbox',
'style' => ['display' => 'none'],
];
},
],
'id',
[
'attribute' => 'block_status',
'label' => 'Статус блокировки',
'value' => function (User $model) {
$blockStatusTooltip = array_filter(
array_unique(array_map(
function (BachelorApplication $application) {
if ($application->block_status) {
return ArrayHelper::getValue($application, 'type.rawCampaign.name', '');
}
return '';
},
$model->rawApplications
)),
function ($blockStatus) {
return !empty($blockStatus);
}
);
if (empty($blockStatusTooltip)) {
return '';
}
$tooltipString = implode(
", ",
$blockStatusTooltip
);
return Html::tag(
'i',
null,
[
'class' => 'fa fa-lock',
'title' => $tooltipString,
'data-toggle' => 'tooltip',
'data-placement' => 'right',
]
);
},
'format' => 'raw',
'filter' => Html::dropDownList(
$searchModel->formName() . '[block_status]',
$searchModel->block_status,
[
null => 'Все',
BachelorApplication::BLOCK_STATUS_ENABLED => 'Заблокировано',
]
),
],
[
'attribute' => 'admission_campaign',
'label' => 'Приемная кампания',
'value' => function (User $model) {
$campaign_names = array_map(function (BachelorApplication $application) {
$campaign = $application->type->rawCampaign;
return $campaign->name ?? null;
}, $model->applications);
return implode('
', array_filter(array_unique($campaign_names)));
},
'format' => 'raw',
],
[
'attribute' => 'group_name',
'label' => 'Конкурсная группа',
'value' => function (User $model) {
$group_names = array_map(
function (BachelorApplication $application) {
return array_map(
function (BachelorSpeciality $spec) {
return $spec->speciality->group_name;
},
$application->specialities
);
},
$model->applications
);
$group_names = array_merge(...$group_names);
if (!is_array($group_names)) {
return '';
}
return implode('
', array_filter(array_unique($group_names)));
},
'format' => 'raw',
],
[
'attribute' => 'fio',
'label' => 'ФИО',
'value' => function (User $model) {
return $model->absFullName;
},
'format' => 'raw',
],
'username',
'email:email',
[
'class' => EnumColumn::class,
'attribute' => 'role',
'enum' => User::getRoles(),
'filter' => User::getRoles()
],
[
'class' => EnumColumn::class,
'attribute' => 'status',
'enum' => User::getStatuses(),
'filter' => User::getStatuses()
],
'created_at:datetime',
'logged_at:datetime',
[
'class' => EnumColumn::class,
'attribute' => 'is_archive',
'label' => 'Запись в архиве',
'enum' => User::getArchives(),
'contentOptions' => ['style' => 'width: 130px'],
],
[
'class' => ActionColumn::class,
'template' => '{view} {update} {delete} {transfer} {juxtapose}',
'buttons' => [
'transfer' => function ($url, $model) use ($loggedId) {
if ($model->id !== $loggedId) {
return Html::a(
'',
'/transfer/transfer?id=' . $model->id,
GridviewActionColumn::buttonOptions(
[
'class' => '',
'title' => 'Сменить пользователя'
]
)
);
}
return '';
},
'juxtapose' => function ($url, $model) use ($loggedId) {
if ($model->id !== $loggedId) {
return Html::a(
'',
['/juxtapose/index', 'user_id' => $model->id],
GridviewActionColumn::buttonOptions(
[
'class' => '',
'title' => 'Сопоставить пользователя с физ. лицом'
]
)
);
}
return '';
}
],
],
],
]);