From 6419c770749a60cd2ff2c410d3f24d0647741291 Mon Sep 17 00:00:00 2001 From: fredtempez Date: Tue, 17 Oct 2023 22:25:56 +0200 Subject: [PATCH] =?UTF-8?q?Fix=20filtre=20emp=C3=AAchant=20le=20d=C3=A9com?= =?UTF-8?q?pte?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/module/course/course.php | 11 ++++++----- core/module/user/user.php | 28 ++++++++++++++++++++++----- core/module/user/view/index/index.php | 2 +- 3 files changed, 30 insertions(+), 11 deletions(-) diff --git a/core/module/course/course.php b/core/module/course/course.php index 4b3d095..98e785f 100644 --- a/core/module/course/course.php +++ b/core/module/course/course.php @@ -430,6 +430,10 @@ class course extends common $maxTime = max($history); $pageId = array_search($maxTime, $history); + + // Compte les rôles + $profils[$this->getData(['user', $userId, 'group']) . $this->getData(['user', $userId, 'profil'])]++; + // Filtres if ($this->isPost()) { // Groupe et profils @@ -474,17 +478,14 @@ class course extends common ]) ]; - // Compte les rôles - $group = $this->getData(['user', $userId, 'group']) . $this->getData(['user', $userId, 'profil']); - $profils[$group]++; } // Ajoute les effectifs aux profils du sélecteur foreach (self::$courseGroups as $groupId => $groupValue) { - if($groupId === 'all') { + if ($groupId === 'all') { self::$courseGroups['all'] = self::$courseGroups['all'] . ' (' . array_sum($profils) . ')'; } else { - self::$courseGroups[$groupId] = self::$courseGroups[$groupId] . ' ('.$profils[$groupId].')'; + self::$courseGroups[$groupId] = self::$courseGroups[$groupId] . ' (' . $profils[$groupId] . ')'; } } diff --git a/core/module/user/user.php b/core/module/user/user.php index 9fc924b..88fede3 100644 --- a/core/module/user/user.php +++ b/core/module/user/user.php @@ -75,7 +75,7 @@ class user extends common public static $alphabet = []; - public static $courseGroups = [ + public static $usersGroups = [ 'all' => 'Tous' ]; @@ -437,20 +437,22 @@ class user extends common public function index() { // Liste des groupes et des profils - $courseGroups = $this->getData(['profil']); - foreach ($courseGroups as $groupId => $groupValue) { + $usersGroups = $this->getData(['profil']); + foreach ($usersGroups as $groupId => $groupValue) { switch ($groupId) { case "-1": case "0": break; case "3": - self::$courseGroups['30'] = 'Administrateur'; + self::$usersGroups['30'] = 'Administrateur'; + $profils['30'] = 0; break; case "1": case "2": foreach ($groupValue as $profilId => $profilValue) { if ($profilId) { - self::$courseGroups[$groupId . $profilId] = sprintf(helper::translate('Groupe %s - Profil %s'), self::$groupPublics[$groupId], $profilValue['name']); + self::$usersGroups[$groupId . $profilId] = sprintf(helper::translate('Groupe %s - Profil %s'), self::$groupPublics[$groupId], $profilValue['name']); + $profils[$groupId . $profilId] = 0; } } } @@ -467,6 +469,10 @@ class user extends common ksort($userIdsLastNames); foreach ($userIdsLastNames as $userId => $userLastNames) { if ($this->getData(['user', $userId, 'group'])) { + + // Compte les rôles + $profils[$this->getData(['user', $userId, 'group']) . $this->getData(['user', $userId, 'profil'])]++; + // Filtres if ($this->isPost()) { // Groupe et profils @@ -493,6 +499,8 @@ class user extends common continue; } + + // Formatage de la liste self::$users[] = [ $userId, @@ -513,6 +521,16 @@ class user extends common 'help' => 'Supprimer' ]) ]; + + } + } + + // Ajoute les effectifs aux profils du sélecteur + foreach (self::$usersGroups as $groupId => $groupValue) { + if ($groupId === 'all') { + self::$usersGroups['all'] = self::$usersGroups['all'] . ' (' . array_sum($profils) . ')'; + } else { + self::$usersGroups[$groupId] = self::$usersGroups[$groupId] . ' (' . $profils[$groupId] . ')'; } } diff --git a/core/module/user/view/index/index.php b/core/module/user/view/index/index.php index 9b9f560..10783d0 100644 --- a/core/module/user/view/index/index.php +++ b/core/module/user/view/index/index.php @@ -41,7 +41,7 @@
- 'Groupes / Profils', 'selected' => isset($_POST['userFilterGroup']) ? $_POST['userFilterGroup'] : 'all', ]); ?>