diff --git a/build/generic/view/history/details/main.php b/build/generic/view/history/details/main.php
new file mode 100644
index 0000000..9c7912f
--- /dev/null
+++ b/build/generic/view/history/details/main.php
@@ -0,0 +1,20 @@
+id_history = $id_history;
+ }
+
+ }
\ No newline at end of file
diff --git a/build/generic/view/history/details/main.twig b/build/generic/view/history/details/main.twig
new file mode 100644
index 0000000..89e4228
--- /dev/null
+++ b/build/generic/view/history/details/main.twig
@@ -0,0 +1 @@
+details
\ No newline at end of file
diff --git a/build/generic/view/history/view/main.php b/build/generic/view/history/view/main.php
new file mode 100644
index 0000000..5bea74c
--- /dev/null
+++ b/build/generic/view/history/view/main.php
@@ -0,0 +1,110 @@
+dispatch();
+
+ // si erreur, on retourne rien par défaut
+ if( $res->error->get() != Err::Success )
+ return [];
+
+ return $res->get('history');
+ }
+
+
+
+
+ public function ts_format($ts){
+ date_default_timezone_set('Europe/Paris');
+ return date('d/m/Y H:i:s', $ts);
+ }
+
+
+
+
+ public function ts_relative($ts){
+ $r = self::relativetime($ts);
+
+ // if only one
+ $o = $r[0] <= 1;
+
+ switch($r[1]){
+
+ case 'Y': return $r[0].' an'.($o?'':'s'); break;
+ case 'm': return $r[0].' mois'; break;
+ case 'd': return $r[0].' jour'.($o?'':'s'); break;
+
+ case 'H': return $r[0].' heure'.($o?'':'s'); break;
+ case 'i': return $r[0].' minute'.($o?'':'s'); break;
+ case 's': return $r[0].' seconde'.($o?'':'s'); break;
+
+ default: return 'peu de temps'; break;
+ }
+ }
+
+
+ private static function relativetime($ts){
+
+ /* [1] Explode time into human-readable time units
+ =========================================================*/
+ $units = [];
+
+ /* (1) Date units */
+ $units['year'] = (int) date('Y', $ts);
+ $units['month'] = (int) date('m', $ts);
+ $units['day'] = (int) date('d', $ts);
+
+ /* (2) Time units */
+ $units['hour'] = (int) date('H', $ts);
+ $units['minute'] = (int) date('i', $ts);
+ $units['second'] = (int) date('s', $ts);
+
+
+ /* [2] Calculate relative time for each unit
+ =========================================================*/
+ /* (1) Date units */
+ $units['year'] = intval(date('Y')) - $units['year'];
+ $units['month'] = intval(date('m')) - $units['month'];
+ $units['day'] = intval(date('d')) - $units['day'];
+
+ /* (2) Time units */
+ $units['hour'] = intval(date('H')) - $units['hour'];
+ $units['minute'] = intval(date('i')) - $units['minute'];
+ $units['second'] = intval(date('s')) - $units['second'];
+
+
+ /* [3] Return significative relative time
+ =========================================================*/
+ /* (1) Date units */
+ if( $units['year'] > 0 ) return [ $units['year'], 'Y' ];
+ if( $units['month'] > 0 ) return [ $units['month'], 'm' ];
+ if( $units['day'] > 0 ) return [ $units['day'], 'd' ];
+
+ /* (2) Time units */
+ if( $units['hour'] > 0 ) return [ $units['hour'], 'H' ];
+ if( $units['minute'] > 0 ) return [ $units['minute'], 'i' ];
+ if( $units['second'] > 0 ) return [ $units['second'], 's' ];
+
+ /* (3) Default value */
+ return [0, '.'];
+ }
+
+
+ }
\ No newline at end of file
diff --git a/build/generic/view/history/view/main.twig b/build/generic/view/history/view/main.twig
new file mode 100644
index 0000000..7676f76
--- /dev/null
+++ b/build/generic/view/history/view/main.twig
@@ -0,0 +1,44 @@
+
+
+
+
+{% for entry in core.get_history() %}
+
+
+ {% if loop.index == 1 %}
+
+
+ Machine
+ Dernière utilisation
+ Utilisateur
+ Action
+ Historique détaillé
+
+
+ {% endif %}
+
+
+
+ #{{ entry.machine_name }}
+
+
+ {{ core.ts_format(entry.timestamp) }}
+ Il y a {{ core.ts_relative(entry.timestamp) }}
+
+
+
+
+ {{ entry.user_name }}
+ {{ entry.user_firstname }} {{ entry.user_lastname }}
+
+
+
+ {{ entry.action_name }}
+
+
+
+
+
+
+
+{% endfor %}
diff --git a/public_html/view/history.php b/public_html/view/history.php
index 748032d..bb8a589 100755
--- a/public_html/view/history.php
+++ b/public_html/view/history.php
@@ -1,11 +1,7 @@
@@ -45,8 +41,8 @@
=========================================================*/
echo "";
- $view = new Viewer('history.view', []);
- $view->view();
+ $view = View::load('history.view');
+ echo $view->render();
echo '';
@@ -60,9 +56,10 @@
echo "";
- echo "details";
- $view = new Viewer('history.details', []);
- $view->view();
+ $view = View::load('history.details');
+ echo $view->render([
+ $post[1] // id_history
+ ]);
echo '';