From df01fba667d667de064b5b07738e959b089d1d5e Mon Sep 17 00:00:00 2001 From: fredtempez Date: Tue, 21 Nov 2023 19:42:46 +0100 Subject: [PATCH] Renommer les scripts + select en cours --- core/module/course/course.php | 59 +++++-------------- .../view/{user/user.css => users/users.css} | 0 .../{user/user.js.php => users/users.js.php} | 0 .../view/{user/user.php => users/users.php} | 4 +- .../userAdd.css => usersAdd/usersAdd.css} | 0 .../course/view/usersAdd/usersAdd.js.php | 31 ++++++++++ .../userAdd.php => usersAdd/usersAdd.php} | 14 +++-- 7 files changed, 56 insertions(+), 52 deletions(-) rename core/module/course/view/{user/user.css => users/users.css} (100%) rename core/module/course/view/{user/user.js.php => users/users.js.php} (100%) rename core/module/course/view/{user/user.php => users/users.php} (92%) rename core/module/course/view/{userAdd/userAdd.css => usersAdd/usersAdd.css} (100%) create mode 100644 core/module/course/view/usersAdd/usersAdd.js.php rename core/module/course/view/{userAdd/userAdd.php => usersAdd/usersAdd.php} (75%) diff --git a/core/module/course/course.php b/core/module/course/course.php index d173221..9b753fc 100644 --- a/core/module/course/course.php +++ b/core/module/course/course.php @@ -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, '' . $categorieUrl . '', 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 ( diff --git a/core/module/course/view/user/user.css b/core/module/course/view/users/users.css similarity index 100% rename from core/module/course/view/user/user.css rename to core/module/course/view/users/users.css diff --git a/core/module/course/view/user/user.js.php b/core/module/course/view/users/users.js.php similarity index 100% rename from core/module/course/view/user/user.js.php rename to core/module/course/view/users/users.js.php diff --git a/core/module/course/view/user/user.php b/core/module/course/view/users/users.php similarity index 92% rename from core/module/course/view/user/user.php rename to core/module/course/view/users/users.php index d942bfa..1dbd647 100644 --- a/core/module/course/view/user/user.php +++ b/core/module/course/view/users/users.php @@ -16,7 +16,7 @@
'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 @@
'buttonGreen', - 'href' => helper::baseUrl() . 'course/userAdd/' . $this->getUrl(2), + 'href' => helper::baseUrl() . 'course/usersAdd/' . $this->getUrl(2), 'value' => template::ico('plus'), 'help' => 'Inscrire', ]) ?> diff --git a/core/module/course/view/userAdd/userAdd.css b/core/module/course/view/usersAdd/usersAdd.css similarity index 100% rename from core/module/course/view/userAdd/userAdd.css rename to core/module/course/view/usersAdd/usersAdd.css diff --git a/core/module/course/view/usersAdd/usersAdd.js.php b/core/module/course/view/usersAdd/usersAdd.js.php new file mode 100644 index 0000000..19d67c5 --- /dev/null +++ b/core/module/course/view/usersAdd/usersAdd.js.php @@ -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 + * @copyright Copyright (C) 2008-2018, Rémi Jean + * @author Frédéric Tempez + * @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, + + } + ] + }); +})); \ No newline at end of file diff --git a/core/module/course/view/userAdd/userAdd.php b/core/module/course/view/usersAdd/usersAdd.php similarity index 75% rename from core/module/course/view/userAdd/userAdd.php rename to core/module/course/view/usersAdd/usersAdd.php index 925bfc1..79dcd4e 100644 --- a/core/module/course/view/userAdd/userAdd.php +++ b/core/module/course/view/usersAdd/usersAdd.php @@ -1,14 +1,16 @@ - +
'buttonGrey', - 'href' => helper::baseUrl() . 'course', + 'href' => helper::baseUrl() . 'course/users/' . $this->getUrl(2), 'value' => template::ico('left') ]); ?>
- + 'Ajouter' + ]); ?>
@@ -32,9 +34,9 @@ ]); ?>
- - ';var_dump($module::$courseUsers); ?> + 'dataTables']); ?> - \ No newline at end of file + + \ No newline at end of file