user enrol user filter okay

This commit is contained in:
Fred Tempez 2023-10-09 17:24:04 +02:00
parent ba721c0bdb
commit a99341aa82
2 changed files with 32 additions and 7 deletions

View File

@ -55,7 +55,7 @@ class course extends common
public static $alphabet = [];
public static $groups = [
self::GROUP_VISITOR => 'Aucun'
'all' => 'Tous'
];
public static $courses = [];
@ -393,13 +393,16 @@ class course extends common
case "2":
foreach ($groupValue as $profilId => $profilValue) {
if ($profilId) {
self::$groups [$groupId . $profilId]= sprintf(helper::translate('Groupe %s - Profil %s'),self::$groupPublics[$groupId], $profilValue['name']);
self::$groups[$groupId . $profilId] = sprintf(helper::translate('Groupe %s - Profil %s'), self::$groupPublics[$groupId], $profilValue['name']);
}
}
}
}
// Liste alphabétique
self::$alphabet= range('A', 'Z');
self::$alphabet = range('A', 'Z');
$alphabet = range('A', 'Z');
self::$alphabet = array_combine($alphabet, self::$alphabet);
self::$alphabet = array_merge(['all'=>'Toute'], self::$alphabet );
// Liste des inscrits dans le cours sélectionné.
$courseId = $this->getUrl(2);
$users = $this->getData(['enrolment', $courseId]);
@ -408,6 +411,25 @@ class course extends common
$history = $userValue['history'];
$maxTime = max($history);
$pageId = array_search($maxTime, $history);
// Filtres
if ($this->isPost()) {
// Groupe et profils
$group = (string) $this->getData(['user', $userId, 'group']);
$profil = (string) $this->getData(['user', $userId, 'profil']);
$firstName = $this->getData(['user', $userId, 'firstname']);
$lastName = $this->getData(['user', $userId, 'lastname']);
if ( $this->getInput('courseFilterGroup', helper::FILTER_INT) > 0
&& $this->getInput('courseFilterGroup', helper::FILTER_STRING_SHORT) !== $group . $profil )
continue;
// Première lettre du prénom
if ($this->getInput('courseFilterFirstName', helper::FILTER_STRING_SHORT) !== 'all'
&& $this->getInput('courseFilterFirstName', helper::FILTER_STRING_SHORT) !== strtoupper(substr($firstName, 0, 1)))
continue;
// Première lettre du nom
if ($this->getInput('courseFilterLastName', helper::FILTER_STRING_SHORT) !== 'all'
&& $this->getInput('courseFilterLastName', helper::FILTER_STRING_SHORT) !== strtoupper(substr($lastName, 0, 1)))
continue;
}
self::$courseUsers[] = [
$userId,
$this->getData(['user', $userId, 'firstname']) . ' ' . $this->getData(['user', $userId, 'lastname']),
@ -422,6 +444,7 @@ class course extends common
];
}
// Valeurs en sortie
$this->addOutput([
'title' => sprintf(helper::translate('Inscrits dans le cours %s'), $this->getData(['course', $courseId, 'title'])),

View File

@ -11,7 +11,8 @@
'class' => 'userDeleteAll buttonRed',
'href' => helper::baseUrl() . 'course/userDeleteAll/' . $this->getUrl(2),
'value' => helper::translate('Réinitialiser'),
'help' => 'Désinscrire tous les utilisateurs'
'help' => 'Désinscrire tous les utilisateurs',
'ico'=> 'minus'
])
?>
</div>
@ -27,23 +28,24 @@
<div class="col2">
<?php echo template::select('courseFilterGroup', $module::$groups, [
'label' => 'Groupes / Profils',
'selected' => isset($_POST['courseFilterGroup']) ? $_POST['courseFilterGroup'] : self::GROUP_VISITOR,
'selected' => isset($_POST['courseFilterGroup']) ? $_POST['courseFilterGroup'] : 'all',
]); ?>
</div>
<div class="col2">
<?php echo template::select('courseFilterFirstName', $module::$alphabet, [
'label' => 'Prénom commence par',
'selected' => isset($_POST['courseFilterFirstName']) ? $_POST['courseFilterFirstName'] : 'A',
'selected' => isset($_POST['courseFilterFirstName']) ? $_POST['courseFilterFirstName'] : 'all',
]); ?>
</div>
<div class="col2">
<?php echo template::select('courseFilterLastName', $module::$alphabet, [
'label' => 'Nom commence par',
'selected' => isset($_POST['courseFilterLastName']) ? $_POST['courseFilterLastName'] : 'A',
'selected' => isset($_POST['courseFilterLastName']) ? $_POST['courseFilterLastName'] : 'all',
]); ?>
</div>
<div class="col2 offset4">
<?php echo template::submit('courseFilterSubmit', [
'value' => 'Filtrer',
'uniqueSubmission' => true
]); ?>
</div>