From: fomichev Date: Fri, 25 Oct 2024 13:14:33 +0000 (+0300) Subject: Добавил фильтр активности X-Git-Tag: 1.7~228^2~13 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=9ecaae9b2adcb1c9ec8a2b75374363a942f0cb19;p=erp24_rep%2Fyii-erp24%2F.git Добавил фильтр активности --- diff --git a/erp24/views/crud/cluster-admin/index.php b/erp24/views/crud/cluster-admin/index.php index e75a4608..3e44de9b 100644 --- a/erp24/views/crud/cluster-admin/index.php +++ b/erp24/views/crud/cluster-admin/index.php @@ -10,7 +10,7 @@ use yii\grid\GridView; /* @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; ?> @@ -97,30 +97,3 @@ $this->params['breadcrumbs'][] = $this->title; -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 diff --git a/erp24/views/crud/cluster-admin/view.php b/erp24/views/crud/cluster-admin/view.php index cddfa892..ff909846 100644 --- a/erp24/views/crud/cluster-admin/view.php +++ b/erp24/views/crud/cluster-admin/view.php @@ -4,12 +4,15 @@ use yii\helpers\Html; 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; @@ -20,6 +23,15 @@ $this->params['breadcrumbs'][] = $this->title; 'btn btn-danger my-2']) ?>

title) ?>

+ 'get', 'id' => 'filter-form']); ?> + request->get('only_active'), [ + 'label' => 'Показать только активные', + 'id' => 'only-active-checkbox' + ]); ?> + + +

group_id, [81])): ?> $cluster->id], ['class' => 'btn btn-success']) ?> @@ -30,9 +42,13 @@ $this->params['breadcrumbs'][] = $this->title;

Привязки кустового к кусту

+ + request->get('only_active'); + $filteredData = $onlyActive ? array_filter($clusterAdmins, fn($model) => $model['active'] == 1) : $clusterAdmins; ?> new ArrayDataProvider([ - 'allModels' => $clusterAdmins, + 'allModels' => $filteredData, 'pagination' => [ 'pageSize' => 10, ], @@ -81,4 +97,5 @@ $this->params['breadcrumbs'][] = $this->title; ], ]); ?> - \ No newline at end of file + + diff --git a/erp24/web/js/crud/cluster-admin/index.js b/erp24/web/js/crud/cluster-admin/index.js new file mode 100644 index 00000000..3edd322a --- /dev/null +++ b/erp24/web/js/crud/cluster-admin/index.js @@ -0,0 +1,28 @@ +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('Ошибка при запросе'); + } + }); + } + }); + + +}); + diff --git a/erp24/web/js/crud/cluster-admin/view.js b/erp24/web/js/crud/cluster-admin/view.js new file mode 100644 index 00000000..7e284755 --- /dev/null +++ b/erp24/web/js/crud/cluster-admin/view.js @@ -0,0 +1,18 @@ +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