1.4.23 Tri des champs date en cours de test

This commit is contained in:
Fred Tempez 2024-02-08 19:39:51 +01:00
parent 25d1c2400e
commit fcee5a8cde
13 changed files with 94 additions and 165 deletions

View File

@ -674,8 +674,10 @@ class course extends common
? $pages[$this->getData(['enrolment', $courseId, $userId, 'lastPageView'])]['title']
: '',
$this->getData(['enrolment', $courseId, $userId, 'datePageView'])
? $this->getData(['enrolment', $courseId, $userId, 'datePageView'])
//? helper::dateUTF8('%d %B %Y - %H:%M', $this->getData(['enrolment', $courseId, $userId, 'datePageView']))
? helper::dateUTF8('%d/%m/%Y', $this->getData(['enrolment', $courseId, $userId, 'datePageView']))
: '',
$this->getData(['enrolment', $courseId, $userId, 'datePageView'])
? helper::dateUTF8('%H:%M', $this->getData(['enrolment', $courseId, $userId, 'datePageView']))
: '',
$this->getData(['user', $userId, 'tags']),
template::button('userHistory' . $userId, [
@ -1147,7 +1149,8 @@ class course extends common
self::$userHistory[] = [
$pages[$pageId]['number'],
html_entity_decode($pages[$pageId]['title']),
helper::dateUTF8('%d %B %Y %H:%M', $time)
helper::dateUTF8('%d %B %Y', $time),
helper::dateUTF8('%H:%M', $time)
];
$floorTime = isset($floorTime) && $floorTime < $time ? $floorTime : $time;
$topTime = isset($topTime) && $topTime > $time ? $topTime : $time;
@ -1158,7 +1161,8 @@ class course extends common
self::$userHistory[] = [
$pages[$pageId]['number'],
html_entity_decode($pages[$pageId]['title']),
helper::dateUTF8('%d %B %Y %H:%M', $times)
helper::dateUTF8('%d %B %Y', $times),
helper::dateUTF8('%H:%M', $times)
];
$floorTime = isset($floorTime) && $floorTime < $times ? $floorTime : $times;
$topTime = isset($topTime) && $topTime > $times ? $topTime : $times;

View File

@ -12,10 +12,12 @@
*/
$(document).ready((function () {
$.fn.dataTable.moment( 'DD/MM/YYYY' );
$('#dataTables').DataTable({
language: {
url: "core/vendor/datatables/french.json"
},
order: [[0, 'asc']],
locale: 'fr',
searching: false,
pageLength: 100,

View File

@ -32,7 +32,7 @@
</div>
<div class="row textAlignCenter">
<div class="col8">
<?php echo template::table([1, 6, 5], $module::$userHistory, ['Ordre', 'Page', 'Consultation'], ['id' => 'dataTables']);?>
<?php echo template::table([1, 5, 3, 3], $module::$userHistory, ['#', 'Page', 'Date Consultation', 'Heure'], ['id' => 'dataTables']);?>
</div>
</div>
<?php else: ?>

View File

@ -21,17 +21,14 @@ $(document).ready((function () {
$(location).attr("href", _this.attr("href"))
}))
}));
$.fn.dataTable.moment( 'DD/MM/YYYY' );
$('#dataTables').DataTable({
language: {
url: "core/vendor/datatables/french.json"
},
order: [[3, 'desc']],
locale: 'fr',
"columnDefs": [
{
target: 3,
render: DataTable.render.moment( 'YYYY/MM/DD', 'Do MMM YY', 'fr' )
},
{
target: 6,
orderable: false,

View File

@ -53,7 +53,7 @@
</div>
<?php echo template::formClose(); ?>
<?php if ($module::$courseUsers): ?>
<?php echo template::table([2, 2, 2, 2, 2, 1, 1], $module::$courseUsers, ['Id', 'Nom Prénom', 'Dernière page vue', 'Date - Heure', 'Étiquettes', 'Progression', ''], ['id' => 'dataTables']); ?>
<?php echo template::table([2, 2, 3, 1, 1, 1 , 1, 1], $module::$courseUsers, ['Id', 'Nom Prénom', 'Dernière page vue', 'Date' , 'Heure', 'Étiquettes', 'Progression', ''], ['id' => 'dataTables']); ?>
<?php else: ?>
<?php echo template::speech('Aucun participant'); ?>
<?php endif; ?>

View File

@ -1,133 +0,0 @@
/*! © SpryMedia Ltd - datatables.net/license */
(function( factory ){
if ( typeof define === 'function' && define.amd ) {
// AMD
define( ['jquery', 'datatables.net'], function ( $ ) {
return factory( $, window, document );
} );
}
else if ( typeof exports === 'object' ) {
// CommonJS
var jq = require('jquery');
var cjsRequires = function (root, $) {
if ( ! $.fn.dataTable ) {
require('datatables.net')(root, $);
}
};
if (typeof window === 'undefined') {
module.exports = function (root, $) {
if ( ! root ) {
// CommonJS environments without a window global must pass a
// root. This will give an error otherwise
root = window;
}
if ( ! $ ) {
$ = jq( root );
}
cjsRequires( root, $ );
return factory( $, root, root.document );
};
}
else {
cjsRequires( window, jq );
module.exports = factory( jq, window, window.document );
}
}
else {
// Browser
factory( jQuery, window, document );
}
}(function( $, window, document, undefined ) {
'use strict';
var DataTable = $.fn.dataTable;
/**
* NOTE - As of DataTables 1.12, DataTables has a built in date / time renderer
* which should be used in place of this renderer. See
* [the manual](https://datatables.net/manual/data/renderers#Date-and-time-helpers)
* for details.
*
* Date / time formats often from back from server APIs in a format that you
* don't wish to display to your end users (ISO8601 for example). This rendering
* helper can be used to transform any source date / time format into something
* which can be easily understood by your users when reading the table, and also
* by DataTables for sorting the table.
*
* The [MomentJS library](http://momentjs.com/) is used to accomplish this and
* you simply need to tell it which format to transfer from, to and specify a
* locale if required.
*
* This function should be used with the `dt-init columns.render` configuration
* option of DataTables.
*
* It accepts one, two or three parameters:
*
* * `DataTable.render.moment( to );`
* * `DataTable.render.moment( from, to );`
* * `DataTable.render.moment( from, to, locale );`
*
* Where:
*
* * `to` - the format that will be displayed to the end user
* * `from` - the format that is supplied in the data (the default is ISO8601 -
* `YYYY-MM-DD`)
* * `locale` - the locale which MomentJS should use - the default is `en`
* (English).
*
* @name datetime
* @summary Convert date / time source data into one suitable for display
* @author [Allan Jardine](http://datatables.net)
* @requires DataTables 1.10+, Moment.js 1.7+
*
* @example
* // Convert ISO8601 dates into a simple human readable format
* $('#example').DataTable( {
* columnDefs: [ {
* targets: 1,
* render: DataTable.render.moment( 'Do MMM YYYY' )
* } ]
* } );
*
* @example
* // Specify a source format - in this case a unix timestamp
* $('#example').DataTable( {
* columnDefs: [ {
* targets: 2,
* render: DataTable.render.moment( 'X', 'Do MMM YY' )
* } ]
* } );
*
* @example
* // Specify a source format and locale
* $('#example').DataTable( {
* columnDefs: [ {
* targets: 2,
* render: DataTable.render.moment( 'YYYY/MM/DD', 'Do MMM YY', 'fr' )
* } ]
* } );
*/
DataTable.render.moment = function (from, to, locale) {
// Argument shifting
if (arguments.length === 1) {
to = from;
from = 'YYYY-MM-DD';
}
return function (d, type, row) {
if (!d) {
return type === 'sort' || type === 'type' ? 0 : d;
}
var m = window.moment(d, from, locale, true);
// Order and type get a number value from Moment, everything else
// sees the rendered value
return m.format(type === 'sort' || type === 'type' ? 'x' : to);
};
};
return DateTime;
}));

71
core/vendor/datatables/datetime.min.js vendored Normal file
View File

@ -0,0 +1,71 @@
/**
* This plug-in for DataTables represents the ultimate option in extensibility
* for sorting date / time strings correctly. It uses
* [Moment.js](http://momentjs.com) to create automatic type detection and
* sorting plug-ins for DataTables based on a given format. This way, DataTables
* will automatically detect your temporal information and sort it correctly.
*
* For usage instructions, please see the DataTables blog
* post that [introduces it](//datatables.net/blog/2014-12-18).
*
* @name Ultimate Date / Time sorting
* @summary Sort date and time in any format using Moment.js
* @author [Allan Jardine](//datatables.net)
* @depends DataTables 1.10+, Moment.js 1.7+
* @deprecated
*
* @example
* $.fn.dataTable.moment( 'HH:mm MMM D, YY' );
* $.fn.dataTable.moment( 'dddd, MMMM Do, YYYY' );
*
* $('#example').DataTable();
*/
(function (factory) {
if (typeof define === "function" && define.amd) {
define(["jquery", "moment", "datatables.net"], factory);
} else {
factory(jQuery, moment);
}
}(function ($, moment) {
function strip (d) {
if ( typeof d === 'string' ) {
// Strip HTML tags and newline characters if possible
d = d.replace(/(<.*?>)|(\r?\n|\r)/g, '');
// Strip out surrounding white space
d = d.trim();
}
return d;
}
$.fn.dataTable.moment = function ( format, locale, reverseEmpties ) {
var types = $.fn.dataTable.ext.type;
// Add type detection
types.detect.unshift( function ( d ) {
d = strip(d);
// Null and empty values are acceptable
if ( d === '' || d === null ) {
return 'moment-'+format;
}
return moment( d, format, locale, true ).isValid() ?
'moment-'+format :
null;
} );
// Add sorting method - use an integer for the sorting
types.order[ 'moment-'+format+'-pre' ] = function ( d ) {
d = strip(d);
return !moment(d, format, locale, true).isValid() ?
(reverseEmpties ? -Infinity : Infinity) :
parseInt( moment( d, format, locale, true ).format( 'x' ), 10 );
};
};
}));

View File

@ -1,5 +1,6 @@
[
"datatables.min.js",
"datatime.js",
"moment.min.js",
"datetime.min.js",
"datatables.min.css"
]

7
core/vendor/datatables/moment.min.js vendored Normal file

File diff suppressed because one or more lines are too long

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/