diff --git a/manager/view/users.php b/manager/view/users.php
index a9c0b4d..e62b9ef 100644
--- a/manager/view/users.php
+++ b/manager/view/users.php
@@ -2,22 +2,136 @@
namespace manager\view;
use \manager\View;
- use \manager\sessionManager;
+ use \manager\ModuleRequest;
use \manager\Authentification;
use \manager\ManagerError;
class users{
- public static function template(){
- return "@var1";
+ public static function templateUserlist($type=null){
+
+ switch($type){
+ case 'cluster': return "
+
+ @cluster_name
+
+ ";
+ break;
+
+
+
+ case 'user': return "
+
+
+ @user_firstname @user_lastname #@user_username
+ @icon_remove
+
+ @icon_edit
+
+
+ @icon_card
+ @user_code
+
+
+
+ @icon_mail
+
+
+ @user_mail
+
+
+
+
+ @icon_group
+ @grouplist
+ +
+
+
+ ";
+ break;
+
+
+ default: return "
+
+ @userlist";
+ break;
+
+ }
+ }
+
+ public static function userlist($params){
+ $view = '';
+
+ /* [1] On récupère la liste des utilisateurs
+ =========================================================*/
+ $request = new ModuleRequest('userDefault/getAll'); // On utilise la methode 'getAll' du module 'userDefault'
+ $answer = $request->dispatch(); // On recupere la reponse
+
+ // si erreur, on affiche l'explicitation
+ if( $answer->error != ManagerError::Success )
+ return "Une erreur est survenue, veuilez contacter le webmaster si cette erreur persiste.";
+
+
+
+ $view_user = '';
+
+ foreach($answer->get('users') as $user){
+ $view_cluster = '';
+
+
+
+ /* [2] On ajoute les données de ses groupes
+ =========================================================*/
+ /* (1) On récupère les groupes de la machine */
+ $clustersReq = new ModuleRequest('userDefault/getClusters', [ 'id_user' => $user['id_user'] ]);
+ $clustersRes = $clustersReq->dispatch();
+
+ /* (2) Gestion si erreur */
+ if( $clustersRes->error == ManagerError::Success ) $clusters = $clustersRes->get('clusters');
+ else $clusters = [];
+
+ /* (3) On crée la vue */
+ foreach($clusters as $cluster){
+ $view_cluster .= View::replace(self::templateUserlist('cluster'),[
+ 'cluster_id' => $cluster['id_cluster'],
+ 'user_id' => $user['id_user']
+ ]);
+ }
+
+
+
+ /* [3] On ajoute les données utilisateurs
+ =========================================================*/
+ $view_user .= View::replace(self::templateUserlist('user'),[
+ 'user_id' => $user['id_user'],
+ 'user_username' => $user['username'],
+ 'user_firstname' => $user['firstname'],
+ 'user_lastname' => $user['lastname'],
+ 'user_code' => $user['code'],
+ 'user_mail' => $user['mail'],
+ 'icon_remove' => file_get_contents( __ROOT__.'/src/static/sub-menu-side/remove.svg' ),
+ 'icon_edit' => file_get_contents( __ROOT__.'/src/static/sub-menu-side/edit.svg' ),
+ 'icon_card' => file_get_contents( __ROOT__.'/src/static/container/card.svg' ),
+ 'icon_mail' => file_get_contents( __ROOT__.'/src/static/container/mail.svg' ),
+ 'icon_group' => file_get_contents( __ROOT__.'/src/static/container/group.svg' ),
+ 'grouplist' => $view_cluster
+ ]);
+
+ $view .= $view_user;
+ }
+
+
+
+
+ return View::replace(self::templateUserlist(), [ 'userlist' => $view_user ]);
}
- public static function aaa($params){
- return View::replace(self::template(), $params);
- }
+
+
+
}
diff --git a/test/automate.php b/test/automate.php
index d1950d3..8ea00eb 100755
--- a/test/automate.php
+++ b/test/automate.php
@@ -330,7 +330,7 @@
}//createWarehouse();
debug();
- $myView = new View('users.aaa', ['var1'=>'coucou']);
+ $myView = new View('users.userlist', []);
$myView->view();
diff --git a/view/users.php b/view/users.php
index cae2f9e..dd2b011 100755
--- a/view/users.php
+++ b/view/users.php
@@ -2,6 +2,7 @@
require_once __ROOT__.'/manager/autoloader.php';
use \manager\ModuleRequest;
use \manager\ManagerError;
+ use \manager\View;
use \manager\Repo;
?>
@@ -50,92 +51,10 @@
/* [1] VIEW -> Liste des utilisateurs
=========================================================*/
- $request = new ModuleRequest('userDefault/getAll'); // On utilise la methode 'getAll' du module 'userDefault'
- $answer = $request->dispatch(); // On recupere la reponse
-
echo "';