From 0132f45b1b3d871ccce3aa6817e69621be67d647 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Fri, 8 Jul 2016 20:28:44 +0200 Subject: [PATCH] Prototype HTML pour la page des 'groupes' --- manager/module/clusterDefault.php | 8 ++++---- manager/repo/cluster.php | 32 +++++++++++++++++++++++++++++ view/groups.php | 34 ++++++++++++++++--------------- view/machines.php | 4 +++- view/users.php | 3 ++- 5 files changed, 59 insertions(+), 22 deletions(-) diff --git a/manager/module/clusterDefault.php b/manager/module/clusterDefault.php index 048d1af..21d2b12 100644 --- a/manager/module/clusterDefault.php +++ b/manager/module/clusterDefault.php @@ -176,16 +176,16 @@ - /* RENVOIE LA LISTE EXHAUSTIVE DES UTILISATEURS + /* RENVOIE LA LISTE EXHAUSTIVE DES GROUPES * - * @return utilisateurs Liste des utilisateurs + * @return clusters Liste des groupes * */ public static function getAll(){ // On recupere les donnees - $users = new Repo('user/getAll', [ $_SESSION['WAREHOUSE']['id'] ]); + $clusters = new Repo('cluster/getAll', [ $_SESSION['WAREHOUSE']['id'] ]); - return [ 'users' => $users->answer() ]; + return [ 'clusters' => $clusters->answer() ]; } diff --git a/manager/repo/cluster.php b/manager/repo/cluster.php index 560baf8..f0607be 100755 --- a/manager/repo/cluster.php +++ b/manager/repo/cluster.php @@ -235,6 +235,38 @@ + /* RENVOIE LA LISTE DES GROUPES D'UN ENTREPOT + * + * @id_warehouse UID de l'entrepot + * + * @return clusters Renvoie la liste des groupes + * Renvoie FALSE si une erreur occure + * + */ + public static function getAll($id_warehouse){ + // On ecrit la requete + $request = Database::getPDO()->prepare("SELECT c.*, count(cm.id_cluster_merge) as count + FROM cluster as c, cluster_merge as cm + WHERE cm.id_cluster = c.id_cluster + AND c.id_warehouse = :id_warehouse + GROUP BY c.id_cluster + ORDER BY c.name ASC"); + + // On execute la requete + $request->execute([ + ':id_warehouse' => $id_warehouse + ]); + + // On retourne en supprimant les indices numeriques + return Database::delNumeric( $request->fetchAll() ); + } + + + + + + + /* RENVOIE LES MEMBRES D'UN GROUPE DONNE * diff --git a/view/groups.php b/view/groups.php index 9b6be83..f67482d 100755 --- a/view/groups.php +++ b/view/groups.php @@ -48,13 +48,12 @@ - /* [1] VIEW -> Liste des utilisateurs + /* [1] VIEW -> Liste des groupes =========================================================*/ - $request = new ModuleRequest('userDefault/getAll'); // On utilise la methode 'getAll' du module 'userDefault' + $request = new ModuleRequest('clusterDefault/getAll'); // On utilise la methode 'getAll' du module 'groupDefault' $answer = $request->dispatch(); // On recupere la reponse echo "
"; - // echo 'Liste des utilisateurs:
'; // si erreur, on affiche l'explicitation if( $answer->error != ManagerError::Success ){ @@ -70,24 +69,25 @@ echo ""; // Liste des utilisateurs - foreach( $answer->get('users') as $user){ - $clusters = new Repo('user/getClusters', array($user['id_user'])); - $clusters = $clusters->answer(); + // TODO: Récupérer la liste des utilisateurs et machines en implémentant 'clusterDefault/getMembers' + // mettre dans la variable '$members' - echo "
"; + foreach($answer->get('clusters') as $cluster){ + + echo "
"; // Prenom Nom - echo "".$user['firstname']." ".$user['lastname']." #".$user['username'].""; + echo "".$cluster['name'].""; // Icone vers la suppression - echo ""; + echo ""; echo file_get_contents( __ROOT__.'/src/static/sub-menu-side/remove.svg' ); echo ""; // Icone vers la modification - echo ""; + echo ""; echo file_get_contents( __ROOT__.'/src/static/sub-menu-side/edit.svg' ); echo ""; @@ -98,7 +98,7 @@ echo file_get_contents( __ROOT__.'/src/static/container/card.svg' ); echo ""; - echo $user['code']; + echo "groupe d". ($cluster['class']==0 ? '\'utilisateurs' : 'e machines'); echo ""; echo""; @@ -106,8 +106,8 @@ echo ""; echo file_get_contents( __ROOT__.'/src/static/container/mail.svg' ); - echo ""; - echo $user['mail']; + echo ""; + echo $cluster['count'].' membre(s)'; echo ""; echo""; @@ -115,9 +115,11 @@ echo ""; echo file_get_contents( __ROOT__.'/src/static/container/group.svg' ); - if( $clusters != false ) - foreach($clusters as $cluster) - echo "".$cluster['name'].""; + foreach($members as $member) + if( $member['name'] != $cluster['name'] ) // Si c'est le groupe personnel, on ne l'affiche pas + echo "".$member['name'].""; + + echo "+"; echo""; diff --git a/view/machines.php b/view/machines.php index e946687..e34d472 100755 --- a/view/machines.php +++ b/view/machines.php @@ -115,7 +115,9 @@ if( $clusters != false ) foreach($clusters as $cluster) - echo "".$cluster['name'].""; + if( $cluster['name'] != $machine['name'] ) // Si c'est le groupe personnel, on ne l'affiche pas + echo "".$cluster['name'].""; + echo "+"; echo""; diff --git a/view/users.php b/view/users.php index e628106..ae0a372 100755 --- a/view/users.php +++ b/view/users.php @@ -125,7 +125,8 @@ if( $clusters != false ) foreach($clusters as $cluster) - echo "".$cluster['name'].""; + if( $cluster['name'] != $user['username'] ) // Si c'est le groupe personnel, on ne l'affiche pas + echo "".$cluster['name'].""; echo "+"; echo"";