/* @var $clusterMapping array */
/* @var $clustersList array */
/* @var $admins array */
-
+$this->registerJsFile('/js/crud/cluster-admin/index.js', ['position' => \yii\web\View::POS_END]);
$this->title = 'Привязка Куст-Кустовой';
$this->params['breadcrumbs'][] = $this->title;
?>
</div>
-<?php
-
-/*$this->registerJs("
- $('.transfer-select').on('change', function () {
- let adminId = $(this).val();
- let clusterId = $(this).data('id');
-
- if (adminId) {
- $.post({
- url: 'move-admin', // Укажите правильный маршрут для назначения администратора
- data: { admin_id: adminId, cluster_id: clusterId },
- success: function(response) {
- if (response.success) {
- alert('Администратор успешно назначен');
- window.location.reload();
- } else {
- alert('Ошибка при назначении администратора');
- }
- },
- error: function() {
- alert('Ошибка при запросе');
- }
- });
- }
-});
-");*/
-?>
\ No newline at end of file
use yii\widgets\DetailView;
use yii\grid\GridView;
use yii\data\ArrayDataProvider;
-
+use yii\widgets\ActiveForm;
/** @var yii\web\View $this */
/** @var yii_app\records\Cluster $cluster */
/** @var array $clusterAdmins */
/** @var yii_app\records\Admin $user */
+
+$this->registerJsFile('/js/crud/cluster-admin/view.js', ['position' => \yii\web\View::POS_END]);
+
$this->title = "Детали кластера: " . $cluster->name;
$this->params['breadcrumbs'][] = ['label' => 'Cluster Admins', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
<?= Html::a('Назад', ['index'], ['class' => 'btn btn-danger my-2']) ?>
<h1><?= Html::encode($this->title) ?></h1>
+ <?php
+ $form = ActiveForm::begin(['method' => 'get', 'id' => 'filter-form']); ?>
+ <?= Html::checkbox('only_active', Yii::$app->request->get('only_active'), [
+ 'label' => 'Показать только активные',
+ 'id' => 'only-active-checkbox'
+ ]); ?>
+
+ <?php ActiveForm::end(); ?>
+
<p>
<?php if (in_array($user->group_id, [81])): ?> <!-- Проверяем, принадлежит ли пользователь к группе 81 -->
<?= Html::a('Создать новую привязку', ['create', 'cluster_id' => $cluster->id], ['class' => 'btn btn-success']) ?>
<h2>Привязки кустового к кусту</h2>
+
+ <?php
+ $onlyActive = Yii::$app->request->get('only_active');
+ $filteredData = $onlyActive ? array_filter($clusterAdmins, fn($model) => $model['active'] == 1) : $clusterAdmins; ?>
<?= GridView::widget([
'dataProvider' => new ArrayDataProvider([
- 'allModels' => $clusterAdmins,
+ 'allModels' => $filteredData,
'pagination' => [
'pageSize' => 10,
],
],
]); ?>
-</div>
\ No newline at end of file
+</div>
+
--- /dev/null
+document.addEventListener('DOMContentLoaded', function () {
+
+ $('.transfer-select').on('change', function () {
+ var adminId = $(this).val();
+ var clusterId = $(this).data('id');
+
+ if (adminId) {
+ $.post({
+ url: 'move-admin', // Укажите правильный маршрут для назначения администратора
+ data: { admin_id: adminId, cluster_id: clusterId },
+ success: function(response) {
+ if (response.success) {
+ alert('Администратор успешно назначен');
+ window.location.reload();
+ } else {
+ alert('Ошибка при назначении администратора');
+ }
+ },
+ error: function() {
+ alert('Ошибка при запросе');
+ }
+ });
+ }
+ });
+
+
+});
+
--- /dev/null
+document.addEventListener('DOMContentLoaded', function () {
+
+ $('#only-active-checkbox').on('change', function() {
+ var form = $('#filter-form');
+ var isChecked = $(this).is(':checked');
+
+ if (isChecked) {
+ form.find('input[name="only_active"]').val(1);
+ } else {
+ form.find('input[name="only_active"]').remove();
+ }
+
+ form.submit();
+
+ });
+
+
+});
\ No newline at end of file