Renommer les scripts + select en cours

This commit is contained in:
Fred Tempez 2023-11-21 19:42:46 +01:00
parent f88e6eced2
commit df01fba667
7 changed files with 56 additions and 52 deletions

View File

@ -28,10 +28,10 @@ class course extends common
'categoryAdd' => self::GROUP_ADMIN,
'categoryEdit' => self::GROUP_ADMIN,
'categoryDelete' => self::GROUP_ADMIN,
'user' => self::GROUP_EDITOR,
'userAdd' => self::GROUP_EDITOR,
'users' => self::GROUP_EDITOR,
'usersAdd' => self::GROUP_EDITOR,
'userDelete' => self::GROUP_EDITOR,
'userDeleteAll' => self::GROUP_EDITOR,
'usersDelete' => self::GROUP_EDITOR,
'userHistory' => self::GROUP_EDITOR,
'usersHistoryExport' => self::GROUP_EDITOR,
'userHistoryExport' => self::GROUP_EDITOR,
@ -95,7 +95,7 @@ class course extends common
$description,
'<a href="' . $categorieUrl . '" target="_blank">' . $categorieUrl . '</a>',
template::button('categoryUser' . $courseId, [
'href' => helper::baseUrl() . 'course/user/' . $courseId,
'href' => helper::baseUrl() . 'course/users/' . $courseId,
'value' => template::ico('users'),
'help' => 'Inscrits'
]),
@ -437,7 +437,7 @@ class course extends common
}
public function user()
public function users()
{
// Contenu sélectionné
@ -558,14 +558,14 @@ class course extends common
// Valeurs en sortie
$this->addOutput([
'title' => sprintf(helper::translate('Inscriptions dans le contenu %s'), $this->getData(['course', $courseId, 'title'])),
'view' => 'user',
'view' => 'users',
'vendor' => [
'datatables'
]
]);
}
public function userAdd()
public function usersAdd()
{
// Contenu sélectionné
$courseId = $this->getUrl(2);
@ -644,7 +644,9 @@ class course extends common
// Construction du tableau
self::$courseUsers[] = [
$userId,
$this->getData(['user', $userId, 'firstname']) . ' ' . $this->getData(['user', $userId, 'lastname']),
$this->getData(['user', $userId, 'firstname']),
$this->getData(['user', $userId, 'lastname']),
template::checkbox('courseUserSelect' . $userId , true, '')
];
}
@ -658,39 +660,6 @@ class course extends common
}
}
// Valeurs en sortie
$this->addOutput([
'title' => sprintf(helper::translate('Inscriptions dans le contenu %s'), $this->getData(['course', $courseId, 'title'])),
'view' => 'user',
'vendor' => [
'datatables'
]
]);
// Contenu sélectionné
$courseId = $this->getUrl(2);
// Liste des groupes et des profils
$courseGroups = $this->getData(['profil']);
foreach ($courseGroups as $groupId => $groupValue) {
switch ($groupId) {
case "-1":
case "0":
break;
case "3":
self::$courseGroups['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']);
$profils[$groupId . $profilId] = 0;
}
}
}
}
// Liste des inscrits dans le contenu sélectionné.
$users = $this->getData(['enrolment', $courseId]);
@ -728,7 +697,9 @@ class course extends common
// Construction du tableau
self::$courseUsers[] = [
$userId,
$this->getData(['user', $userId, 'firstname']) . ' ' . $this->getData(['user', $userId, 'lastname'])
$this->getData(['user', $userId, 'firstname']),
$this->getData(['user', $userId, 'lastname']),
template::checkbox('courseUserSelect' . $userId , true, '')
];
}
@ -736,7 +707,7 @@ class course extends common
// Valeurs en sortie
$this->addOutput([
'title' => helper::translate('Inscription en masse'),
'view' => 'userAdd'
'view' => 'usersAdd'
]);
}
@ -767,7 +738,7 @@ class course extends common
/**
* Désinscription de tous les utilisateurs
*/
public function userDeleteAll()
public function usersDelete()
{
// Accès refusé
if (

View File

@ -16,7 +16,7 @@
<div class="col1">
<?php echo template::button('userDeleteAll', [
'class' => 'userDeleteAll buttonRed',
'href' => helper::baseUrl() . 'course/userDeleteAll/' . $this->getUrl(2),
'href' => helper::baseUrl() . 'course/usersDelete/' . $this->getUrl(2),
'value' => template::ico('trash'),
'help' => 'Désinscrire tous les utilisateurs',
])?>
@ -24,7 +24,7 @@
<div class="col1">
<?php echo template::button('userDeleteAll', [
'class' => 'buttonGreen',
'href' => helper::baseUrl() . 'course/userAdd/' . $this->getUrl(2),
'href' => helper::baseUrl() . 'course/usersAdd/' . $this->getUrl(2),
'value' => template::ico('plus'),
'help' => 'Inscrire',
]) ?>

View File

@ -0,0 +1,31 @@
/**
* This file is part of Zwii.
* For full copyright and license information, please see the LICENSE
* file that was distributed with this source code.
*
* @author Rémi Jean <remi.jean@outlook.com>
* @copyright Copyright (C) 2008-2018, Rémi Jean
* @author Frédéric Tempez <frederic.tempez@outlook.com>
* @copyright Copyright (C) 2018-2023, Frédéric Tempez
* @license CC Attribution-NonCommercial-NoDerivatives 4.0 International
* @link http://zwiicms.fr/
*/
$(document).ready((function () {
$("#courseFilterGroup, #courseFilterFirstName, #courseFilterLastName").change(function () {
$("#courseUsersAddForm").submit();
});
$('#dataTables').DataTable({
language: {
url: "core/vendor/datatables/french.json"
},
"columnDefs": [
{
target: 3,
orderable: false,
searchable: false,
}
]
});
}));

View File

@ -1,14 +1,16 @@
<?php echo template::formOpen('courseUserAddForm'); ?>
<?php echo template::formOpen('courseUsersAddForm'); ?>
<div class="row">
<div class="col1">
<?php echo template::button('courseUserAddBack', [
'class' => 'buttonGrey',
'href' => helper::baseUrl() . 'course',
'href' => helper::baseUrl() . 'course/users/' . $this->getUrl(2),
'value' => template::ico('left')
]); ?>
</div>
<div class="col2 offset9">
<?php echo template::submit('courseUserAddSubmit'); ?>
<?php echo template::submit('courseUserAddSubmit', [
'value' => 'Ajouter'
]); ?>
</div>
</div>
<?php echo template::formOpen('courseFilterUserForm'); ?>
@ -32,9 +34,9 @@
]); ?>
</div>
</div>
<?php echo template::formClose(); ?>
<?php if ($module::$courseUsers): ?>
<?php echo '<pre>';var_dump($module::$courseUsers); ?>
<?php echo template::table([4, 4, 4, 1], $module::$courseUsers, ['Id', 'Prénom', 'Nom', ''], ['id' => 'dataTables']); ?>
<?php else: ?>
<?php echo template::speech('Aucun inscrit'); ?>
<?php endif; ?>
<?php echo template::formClose(); ?>