Datatables dans course user et users

This commit is contained in:
Fred Tempez 2023-10-15 14:53:20 +02:00
parent b1f1d1b54d
commit 03050aa1e2
13 changed files with 156 additions and 89 deletions

View File

@ -139,7 +139,8 @@ class common
'tippy', 'tippy',
'zwiico', 'zwiico',
'imagemap', 'imagemap',
'simplelightbox' 'simplelightbox',
'datatables'
], ],
'view' => '' 'view' => ''
]; ];

View File

@ -413,14 +413,16 @@ class course extends common
// Statistiques du cours sélectionné calcul du nombre de pages // Statistiques du cours sélectionné calcul du nombre de pages
$currentSite = self::$siteContent; $currentSite = self::$siteContent;
$this->initDB('page', $courseId); $this->initDB('page', $courseId);
$sumPages = count($this->getData(['page'])); $sumPages = count($this->getHierarchy(null, false)); // Supprimer les barres
self::$siteContent = $currentSite; self::$siteContent = $currentSite;
// Liste des inscrits dans le cours sélectionné. // Liste des inscrits dans le cours sélectionné.
$users = $this->getData(['enrolment', $courseId]); $users = $this->getData(['enrolment', $courseId]);
// Tri du tableau par défaut par $userId
ksort($users); ksort($users);
foreach ($users as $userId => $userValue) { foreach ($users as $userId => $userValue) {
$history = $userValue['history']; $history = $userValue['history'];
$maxTime = max($history); $maxTime = max($history);
$pageId = array_search($maxTime, $history); $pageId = array_search($maxTime, $history);
// Filtres // Filtres
@ -457,7 +459,8 @@ class course extends common
$this->getData(['user', $userId, 'firstname']) . ' ' . $this->getData(['user', $userId, 'lastname']), $this->getData(['user', $userId, 'firstname']) . ' ' . $this->getData(['user', $userId, 'lastname']),
$pageId, $pageId,
helper::dateUTF8('%d %B %Y - %H:%M', $maxTime), helper::dateUTF8('%d %B %Y - %H:%M', $maxTime),
round(($viewPages * 100)/ $sumPages, 1) . ' %', //round(($viewPages * 100)/ $sumPages, 1) . ' %',
$viewPages . ' / ' . $sumPages,
template::button('userDelete' . $userId, [ template::button('userDelete' . $userId, [
'class' => 'userDelete buttonRed', 'class' => 'userDelete buttonRed',
'href' => helper::baseUrl() . 'course/userDelete/' . $courseId . '/' . $userId, 'href' => helper::baseUrl() . 'course/userDelete/' . $courseId . '/' . $userId,
@ -471,7 +474,10 @@ class course extends common
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'title' => sprintf(helper::translate('Inscrits dans le cours %s'), $this->getData(['course', $courseId, 'title'])), 'title' => sprintf(helper::translate('Inscrits dans le cours %s'), $this->getData(['course', $courseId, 'title'])),
'view' => 'user' 'view' => 'user',
'vendor' => [
'datatables'
]
]); ]);
} }

View File

@ -28,4 +28,30 @@ $(document).ready((function () {
})) }))
})); }));
$('#dataTables').DataTable({
language: {
processing: "Traitement en cours...",
search: "Rechercher :",
lengthMenu: "Afficher _MENU_ éléments",
info: "Affichage de l'élement _START_ à _END_ sur _TOTAL_ éléments",
infoEmpty: "Affichage de l'élement 0 à 0 sur 0 éléments",
infoFiltered: "(filtré de _MAX_ éléments au total)",
infoPostFix: "",
loadingRecords: "Chargement en cours...",
zeroRecords: "Aucun élément à afficher",
emptyTable: "Aucune donnée disponible dans le tableau",
paginate: {
first: "Premier",
previous: "Précédent",
next: "Suivant",
last: "Dernier"
},
aria: {
sortAscending: ": activer pour trier la colonne par ordre croissant",
sortDescending: ": activer pour trier la colonne par ordre décroissant"
}
}
});
})); }));

View File

@ -12,44 +12,35 @@
'href' => helper::baseUrl() . 'course/userDeleteAll/' . $this->getUrl(2), 'href' => helper::baseUrl() . 'course/userDeleteAll/' . $this->getUrl(2),
'value' => helper::translate('Réinitialiser'), 'value' => helper::translate('Réinitialiser'),
'help' => 'Désinscrire tous les utilisateurs', 'help' => 'Désinscrire tous les utilisateurs',
'ico'=> 'minus' 'ico' => 'minus'
]) ])
?> ?>
</div> </div>
</div> </div>
<?php echo template::formOpen('courseFilterUserForm'); ?> <?php echo template::formOpen('courseFilterUserForm'); ?>
<div class="row"> <div class="row">
<div class="col12"> <div class="col3">
<div class="block"> <?php echo template::select('courseFilterGroup', $module::$courseGroups, [
<h4> 'label' => 'Groupes / Profils',
<?php echo helper::translate('Filtres'); ?> 'selected' => isset($_POST['courseFilterGroup']) ? $_POST['courseFilterGroup'] : 'all',
</h4> ]); ?>
<div class="row"> </div>
<div class="col3"> <div class="col3">
<?php echo template::select('courseFilterGroup', $module::$courseGroups, [ <?php echo template::select('courseFilterFirstName', $module::$alphabet, [
'label' => 'Groupes / Profils', 'label' => 'Prénom commence par',
'selected' => isset($_POST['courseFilterGroup']) ? $_POST['courseFilterGroup'] : 'all', 'selected' => isset($_POST['courseFilterFirstName']) ? $_POST['courseFilterFirstName'] : 'all',
]); ?> ]); ?>
</div> </div>
<div class="col3"> <div class="col3">
<?php echo template::select('courseFilterFirstName', $module::$alphabet, [ <?php echo template::select('courseFilterLastName', $module::$alphabet, [
'label' => 'Prénom commence par', 'label' => 'Nom commence par',
'selected' => isset($_POST['courseFilterFirstName']) ? $_POST['courseFilterFirstName'] : 'all', 'selected' => isset($_POST['courseFilterLastName']) ? $_POST['courseFilterLastName'] : 'all',
]); ?> ]); ?>
</div>
<div class="col3">
<?php echo template::select('courseFilterLastName', $module::$alphabet, [
'label' => 'Nom commence par',
'selected' => isset($_POST['courseFilterLastName']) ? $_POST['courseFilterLastName'] : 'all',
]); ?>
</div>
</div>
</div>
</div> </div>
</div> </div>
<?php echo template::formClose(); ?> <?php echo template::formClose(); ?>
<?php if ($module::$courseUsers): ?> <?php if ($module::$courseUsers): ?>
<?php echo template::table([2, 3, 3, 2, 1, 1], $module::$courseUsers, ['Id', 'Nom Prénom', 'Id dernière page', 'Date - Heure', 'Progression', '']); ?> <?php echo template::table([2, 3, 3, 2, 1, 1], $module::$courseUsers, ['Id', 'Nom Prénom', 'Id dernière page', 'Date - Heure', 'Progression', ''], ['id' => 'dataTables']); ?>
<?php else: ?> <?php else: ?>
<?php echo template::speech('Aucun inscrit'); ?> <?php echo template::speech('Aucun inscrit'); ?>
<?php endif; ?> <?php endif; ?>

View File

@ -18,7 +18,34 @@ $(document).ready((function () {
$(location).attr("href", _this.attr("href")) $(location).attr("href", _this.attr("href"))
})) }))
})); }));
$("#userFilterGroup, #userFilterFirstName, #userFilterLastName").change(function() {
$("#userFilterGroup, #userFilterFirstName, #userFilterLastName").change(function () {
$("#userFilterUserForm").submit(); $("#userFilterUserForm").submit();
}); });
$('#dataTables').DataTable({
language: {
processing: "Traitement en cours...",
search: "Rechercher&nbsp;:",
lengthMenu: "Afficher _MENU_ &eacute;l&eacute;ments",
info: "Affichage de l'&eacute;lement _START_ &agrave; _END_ sur _TOTAL_ &eacute;l&eacute;ments",
infoEmpty: "Affichage de l'&eacute;lement 0 &agrave; 0 sur 0 &eacute;l&eacute;ments",
infoFiltered: "(filtr&eacute; de _MAX_ &eacute;l&eacute;ments au total)",
infoPostFix: "",
loadingRecords: "Chargement en cours...",
zeroRecords: "Aucun &eacute;l&eacute;ment &agrave; afficher",
emptyTable: "Aucune donnée disponible dans le tableau",
paginate: {
first: "Premier",
previous: "Pr&eacute;c&eacute;dent",
next: "Suivant",
last: "Dernier"
},
aria: {
sortAscending: ": activer pour trier la colonne par ordre croissant",
sortDescending: ": activer pour trier la colonne par ordre décroissant"
}
}
});
})); }));

View File

@ -8,12 +8,12 @@
</div> </div>
<div class="col1"> <div class="col1">
<?php /**echo template::button('userHelp', [ <?php /**echo template::button('userHelp', [
'href' => 'https://doc.zwiicms.fr/gestion-des-utilisateurs', 'href' => 'https://doc.zwiicms.fr/gestion-des-utilisateurs',
'target' => '_blank', 'target' => '_blank',
'value' => template::ico('help'), 'value' => template::ico('help'),
'class' => 'buttonHelp', 'class' => 'buttonHelp',
'help' => 'Consulter l\'aide en ligne' 'help' => 'Consulter l\'aide en ligne'
]);*/ ?> ]);*/?>
</div> </div>
<div class="col1 offset7"> <div class="col1 offset7">
<?php echo template::button('userImport', [ <?php echo template::button('userImport', [
@ -40,33 +40,24 @@
</div> </div>
<?php echo template::formOpen('userFilterUserForm'); ?> <?php echo template::formOpen('userFilterUserForm'); ?>
<div class="row"> <div class="row">
<div class="col12"> <div class="col3">
<div class="block"> <?php echo template::select('userFilterGroup', $module::$courseGroups, [
<h4> 'label' => 'Groupes / Profils',
<?php echo helper::translate('Filtres'); ?> 'selected' => isset($_POST['userFilterGroup']) ? $_POST['userFilterGroup'] : 'all',
</h4> ]); ?>
<div class="row"> </div>
<div class="col3"> <div class="col3">
<?php echo template::select('userFilterGroup', $module::$courseGroups, [ <?php echo template::select('userFilterFirstName', $module::$alphabet, [
'label' => 'Groupes / Profils', 'label' => 'Prénom commence par',
'selected' => isset($_POST['userFilterGroup']) ? $_POST['userFilterGroup'] : 'all', 'selected' => isset($_POST['userFilterFirstName']) ? $_POST['userFilterFirstName'] : 'all',
]); ?> ]); ?>
</div> </div>
<div class="col3"> <div class="col3">
<?php echo template::select('userFilterFirstName', $module::$alphabet, [ <?php echo template::select('userFilterLastName', $module::$alphabet, [
'label' => 'Prénom commence par', 'label' => 'Nom commence par',
'selected' => isset($_POST['userFilterFirstName']) ? $_POST['userFilterFirstName'] : 'all', 'selected' => isset($_POST['userFilterLastName']) ? $_POST['userFilterLastName'] : 'all',
]); ?> ]); ?>
</div> </div>
<div class="col3">
<?php echo template::select('userFilterLastName', $module::$alphabet, [
'label' => 'Nom commence par',
'selected' => isset($_POST['userFilterLastName']) ? $_POST['userFilterLastName'] : 'all',
]); ?>
</div>
</div>
</div>
</div>
</div> </div>
<?php echo template::formClose(); ?> <?php echo template::formClose(); ?>
<?php echo template::table([2, 2 , 3, 3, 1, 1], $module::$users, ['Identifiant', 'Nom', 'Groupe', 'Profil', '', '']); ?> <?php echo template::table([2, 2, 3, 3, 1, 1], $module::$users, ['Identifiant', 'Nom', 'Groupe', 'Profil', '', ''], ['id' => 'dataTables']); ?>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

4
core/vendor/datatables/inc.json vendored Normal file
View File

@ -0,0 +1,4 @@
[
"datatables.min.js",
"datatables.min.css"
]

View File

@ -1,8 +0,0 @@
/**
* Copyright (c) 2018, Travis Clarke (https://www.travismclarke.com/)
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("jquery")):"function"==typeof define&&define.amd?define(["jquery"],t):e.ImageMap=t(e.$)}(this,function(e){"use strict";function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function r(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}function o(e){return i(e)||a(e)||u()}function i(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}}function a(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}function u(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function c(e,t){return new s(e,t)}e=e&&e.hasOwnProperty("default")?e.default:e;var d="resize",f="load",l="complete",s=function(){function e(n,r){t(this,e),this.selector=n instanceof Array?n:o(document.querySelectorAll(n)),document.readyState!==l?window.addEventListener(f,this.update.bind(this)):this.update(),window.addEventListener(d,this.debounce(this.update,r).bind(this))}return r(e,[{key:"update",value:function(){var e=this;this.selector.forEach(function(t){if(void 0!==t.getAttribute("usemap")){t.cloneNode().addEventListener(f,e.handleImageLoad(t.offsetWidth,t.offsetHeight))}})}},{key:"debounce",value:function(e){var t,n=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:500;return function(){for(var o=arguments.length,i=Array(o),a=0;a<o;a++)i[a]=arguments[a];window.clearTimeout(t),t=window.setTimeout(function(t){return e.apply(t,i)},r,n)}}},{key:"handleImageLoad",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return function(r){var i=r.target.width,a=r.target.height,u=t/100,c=n/100,d=r.target.getAttribute("usemap").replace(/^#/,"")
;o(document.querySelectorAll(e.genAreaSelector(d))).forEach(function(e){var t=e.dataset.coords=e.dataset.coords||e.getAttribute("coords"),n=t.split(",");e.setAttribute("coords",""+n.map(function(e,t){return t%2==0?+(n[t]/i*100*u):+(n[t]/a*100*c)}))})}}}],[{key:"genAreaSelector",value:function(e){return'map[name="'.concat(e,'"] area')}}]),e}();return void 0!==e&&e.fn&&(e.fn.imageMap=function(e){return new s(this.toArray(),e)}),c.VERSION="1.1.5",c});

View File

@ -1,4 +0,0 @@
[
"image-map.min.js",
"init.js"
]

View File

@ -1,6 +0,0 @@
/**
* Initialisation du redimensionner de mapf
*/
$(function() {
$('img[usemap]').imageMap();
});

View File

@ -1,2 +0,0 @@
Article https://blog.travismclarke.com/project/imagemap/
Générateur : https://www.image-map.net/