course user form filter in form

This commit is contained in:
Fred Tempez 2023-10-09 13:47:11 +02:00
parent 4b06c0c0e0
commit ba721c0bdb
2 changed files with 68 additions and 10 deletions

View File

@ -51,6 +51,13 @@ class course extends common
public static $courseUsers = [];
public static $alphabet = [];
public static $groups = [
self::GROUP_VISITOR => 'Aucun'
];
public static $courses = [];
public static $swapMessage = [];
@ -374,7 +381,28 @@ class course extends common
public function user()
{
$users = $this->getData(['enrolment', $this->getUrl(2)]);
// Liste des groupes et des profils
$groups = $this->getData(['profil']);
foreach ($groups as $groupId => $groupValue) {
switch ($groupId) {
case "-1":
case "0":
case "3":
break;
case "1":
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']);
}
}
}
}
// Liste alphabétique
self::$alphabet= range('A', 'Z');
// Liste des inscrits dans le cours sélectionné.
$courseId = $this->getUrl(2);
$users = $this->getData(['enrolment', $courseId]);
ksort($users);
foreach ($users as $userId => $userValue) {
$history = $userValue['history'];
@ -387,7 +415,7 @@ class course extends common
helper::dateUTF8('%d %B %Y - %H:%M', $maxTime),
template::button('userDelete' . $userId, [
'class' => 'userDelete buttonRed',
'href' => helper::baseUrl() . 'course/userDelete/'. $this->getUrl(2) . '/' . $userId,
'href' => helper::baseUrl() . 'course/userDelete/' . $courseId . '/' . $userId,
'value' => template::ico('minus'),
'help' => 'Désinscrire'
])
@ -396,7 +424,7 @@ class course extends common
// Valeurs en sortie
$this->addOutput([
'title' => sprintf(helper::translate('Inscrits dans le cours %s'),$this->getData(['course', $this->getUrl(2), 'title'])),
'title' => sprintf(helper::translate('Inscrits dans le cours %s'), $this->getData(['course', $courseId, 'title'])),
'view' => 'user'
]);
}

View File

@ -15,13 +15,43 @@
])
?>
</div>
<?php /*echo template::button('courseUserAdd', [
'class' => 'buttonGreen',
'href' => helper::baseUrl() . 'course/userAdd',
'value' => template::ico('plus')
]); */?>
</div>
<?php echo template::formOpen('courseFilterUserForm'); ?>
<div class="row">
<div class="col10 offset1">
<div class="block">
<h4>
<?php echo helper::translate('Filtres'); ?>
</h4>
<div class="row">
<div class="col2">
<?php echo template::select('courseFilterGroup', $module::$groups, [
'label' => 'Groupes / Profils',
'selected' => isset($_POST['courseFilterGroup']) ? $_POST['courseFilterGroup'] : self::GROUP_VISITOR,
]); ?>
</div>
<div class="col2">
<?php echo template::select('courseFilterFirstName', $module::$alphabet, [
'label' => 'Prénom commence par',
'selected' => isset($_POST['courseFilterFirstName']) ? $_POST['courseFilterFirstName'] : 'A',
]); ?>
</div>
<div class="col2">
<?php echo template::select('courseFilterLastName', $module::$alphabet, [
'label' => 'Nom commence par',
'selected' => isset($_POST['courseFilterLastName']) ? $_POST['courseFilterLastName'] : 'A',
]); ?>
</div>
<div class="col2 offset4">
<?php echo template::submit('courseFilterSubmit', [
'uniqueSubmission' => true
]); ?>
</div>
</div>
</div>
</div>
</div>
<?php echo template::formClose(); ?>
<?php if ($module::$courseUsers): ?>
<?php echo template::table([2, 3, 3, 3, 1], $module::$courseUsers, ['Id', 'Nom Prénom', 'Id dernière page', 'Date - Heure', '']); ?>
<?php else: ?>