Fix filtre empêchant le décompte

This commit is contained in:
Fred Tempez 2023-10-17 22:25:56 +02:00
parent 84aa5bb45d
commit 6419c77074
3 changed files with 30 additions and 11 deletions

View File

@ -430,6 +430,10 @@ class course extends common
$maxTime = max($history); $maxTime = max($history);
$pageId = array_search($maxTime, $history); $pageId = array_search($maxTime, $history);
// Compte les rôles
$profils[$this->getData(['user', $userId, 'group']) . $this->getData(['user', $userId, 'profil'])]++;
// Filtres // Filtres
if ($this->isPost()) { if ($this->isPost()) {
// Groupe et profils // 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 // Ajoute les effectifs aux profils du sélecteur
foreach (self::$courseGroups as $groupId => $groupValue) { foreach (self::$courseGroups as $groupId => $groupValue) {
if($groupId === 'all') { if ($groupId === 'all') {
self::$courseGroups['all'] = self::$courseGroups['all'] . ' (' . array_sum($profils) . ')'; self::$courseGroups['all'] = self::$courseGroups['all'] . ' (' . array_sum($profils) . ')';
} else { } else {
self::$courseGroups[$groupId] = self::$courseGroups[$groupId] . ' ('.$profils[$groupId].')'; self::$courseGroups[$groupId] = self::$courseGroups[$groupId] . ' (' . $profils[$groupId] . ')';
} }
} }

View File

@ -75,7 +75,7 @@ class user extends common
public static $alphabet = []; public static $alphabet = [];
public static $courseGroups = [ public static $usersGroups = [
'all' => 'Tous' 'all' => 'Tous'
]; ];
@ -437,20 +437,22 @@ class user extends common
public function index() public function index()
{ {
// Liste des groupes et des profils // Liste des groupes et des profils
$courseGroups = $this->getData(['profil']); $usersGroups = $this->getData(['profil']);
foreach ($courseGroups as $groupId => $groupValue) { foreach ($usersGroups as $groupId => $groupValue) {
switch ($groupId) { switch ($groupId) {
case "-1": case "-1":
case "0": case "0":
break; break;
case "3": case "3":
self::$courseGroups['30'] = 'Administrateur'; self::$usersGroups['30'] = 'Administrateur';
$profils['30'] = 0;
break; break;
case "1": case "1":
case "2": case "2":
foreach ($groupValue as $profilId => $profilValue) { foreach ($groupValue as $profilId => $profilValue) {
if ($profilId) { 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); ksort($userIdsLastNames);
foreach ($userIdsLastNames as $userId => $userLastNames) { foreach ($userIdsLastNames as $userId => $userLastNames) {
if ($this->getData(['user', $userId, 'group'])) { if ($this->getData(['user', $userId, 'group'])) {
// Compte les rôles
$profils[$this->getData(['user', $userId, 'group']) . $this->getData(['user', $userId, 'profil'])]++;
// Filtres // Filtres
if ($this->isPost()) { if ($this->isPost()) {
// Groupe et profils // Groupe et profils
@ -493,6 +499,8 @@ class user extends common
continue; continue;
} }
// Formatage de la liste // Formatage de la liste
self::$users[] = [ self::$users[] = [
$userId, $userId,
@ -513,6 +521,16 @@ class user extends common
'help' => 'Supprimer' '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] . ')';
} }
} }

View File

@ -41,7 +41,7 @@
<?php echo template::formOpen('userFilterUserForm'); ?> <?php echo template::formOpen('userFilterUserForm'); ?>
<div class="row"> <div class="row">
<div class="col3"> <div class="col3">
<?php echo template::select('userFilterGroup', $module::$courseGroups, [ <?php echo template::select('userFilterGroup', $module::$usersGroups, [
'label' => 'Groupes / Profils', 'label' => 'Groupes / Profils',
'selected' => isset($_POST['userFilterGroup']) ? $_POST['userFilterGroup'] : 'all', 'selected' => isset($_POST['userFilterGroup']) ? $_POST['userFilterGroup'] : 'all',
]); ?> ]); ?>