2016-07-12 10:06:46 +00:00
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace manager\view\group;
|
|
|
|
|
use \manager\View;
|
|
|
|
|
use \manager\ModuleRequest;
|
|
|
|
|
use \manager\Authentification;
|
|
|
|
|
use \manager\ManagerError;
|
|
|
|
|
|
|
|
|
|
class view{
|
|
|
|
|
|
|
|
|
|
public static function template($type=null){
|
|
|
|
|
|
|
|
|
|
switch($type){
|
|
|
|
|
case 'member': return "
|
|
|
|
|
<span>
|
|
|
|
|
@name
|
|
|
|
|
<span class='rem-member' data-member='@id_member' data-cluster='@id_cluster'></span>
|
|
|
|
|
</span>";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 'cluster': return "
|
|
|
|
|
<article class='inline-box' id='@id_cluster'>
|
|
|
|
|
|
|
|
|
|
<span class='title' style='color: ".$_SESSION['WAREHOUSE']['theme']."'>@name <span>#@name</span></span>
|
|
|
|
|
<span class='link_remove' data-cluster='@id_cluster'>@icon_remove</span>
|
|
|
|
|
|
|
|
|
|
<span class='link_edit' data-cluster='@id_cluster'>@icon_edit</span>
|
|
|
|
|
|
|
|
|
|
<span class='code'>
|
|
|
|
|
@icon_type
|
|
|
|
|
|
|
|
|
|
<span>@_classtext (@nb_members)</span>
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
<span class='groups'>
|
|
|
|
|
@icon_group
|
|
|
|
|
@members
|
|
|
|
|
<span class='add-group' data-cluster='@id_cluster'>+</span>
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
</article>";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
default: return "
|
|
|
|
|
<input type='text' class='searchbar' placeholder='Recherche'>
|
|
|
|
|
@clusterlist";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function view($params){
|
|
|
|
|
$view = '';
|
|
|
|
|
|
|
|
|
|
/* [1] On récupère la liste des utilisateurs
|
|
|
|
|
=========================================================*/
|
|
|
|
|
$request = new ModuleRequest('clusterDefault/getAll'); // On utilise la methode 'getAll' du module 'clusterDefault'
|
|
|
|
|
$answer = $request->dispatch(); // On recupere la reponse
|
|
|
|
|
|
|
|
|
|
// si erreur, on affiche l'explicitation
|
|
|
|
|
if( $answer->error != ManagerError::Success )
|
2016-07-14 08:16:11 +00:00
|
|
|
|
return View::$htmlError;
|
2016-07-12 10:06:46 +00:00
|
|
|
|
|
|
|
|
|
$CLUSTERLIST = $answer->get('clusters');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach($CLUSTERLIST as $u=>$cluster){
|
|
|
|
|
$membersReq = new ModuleRequest('clusterDefault/getMembers', [ 'id_cluster' => $cluster['id_cluster'] ]);
|
|
|
|
|
$membersRes = $membersReq->dispatch();
|
|
|
|
|
|
|
|
|
|
/* (2) Gestion si erreur */
|
|
|
|
|
if( $membersRes->error == ManagerError::Success ) $members = $membersRes->get('members');
|
|
|
|
|
else $members = [];
|
|
|
|
|
|
|
|
|
|
$CLUSTERLIST[$u]['members'] = View::replaceMultiple(
|
|
|
|
|
self::template('member'),
|
|
|
|
|
$members,
|
|
|
|
|
[ 'id_cluster' => $cluster['id_cluster'] ]
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$CLUSTERLIST[$u]['_classtext'] = ($cluster['class']==0) ? 'utilisateurs' : 'machines';
|
|
|
|
|
$CLUSTERLIST[$u]['nb_members'] = (count($members)<2) ? count($members).' membre' : count($members).'membres';
|
|
|
|
|
$CLUSTERLIST[$u]['icon_type'] = ($cluster['class']==0) ? file_get_contents( __ROOT__.'/src/static/menu-side/users.svg' ) : file_get_contents( __ROOT__.'/src/static/menu-side/device.svg' );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$view_cluster = View::replaceMultiple(
|
|
|
|
|
self::template('cluster'),
|
|
|
|
|
$CLUSTERLIST, [
|
|
|
|
|
'icon_remove' => file_get_contents( __ROOT__.'/src/static/sub-menu-side/remove.svg' ),
|
|
|
|
|
'icon_group' => file_get_contents( __ROOT__.'/src/static/container/group.svg' ),
|
2016-07-14 08:16:11 +00:00
|
|
|
|
'icon_edit' => file_get_contents( __ROOT__.'/src/static/sub-menu-side/edit.svg' )
|
2016-07-12 10:06:46 +00:00
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return View::replaceSingle(self::template(), [ 'clusterlist' => $view_cluster ]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
?>
|