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){
|
2016-07-18 14:46:06 +00:00
|
|
|
|
case 'machine': return "
|
2016-07-12 10:06:46 +00:00
|
|
|
|
<span>
|
|
|
|
|
@name
|
2016-07-18 14:46:06 +00:00
|
|
|
|
<span class='rem-member' data-member='@id_machine' data-cluster='@id_machine_cluster'></span>
|
2016-07-12 10:06:46 +00:00
|
|
|
|
</span>";
|
|
|
|
|
break;
|
2016-07-18 14:46:06 +00:00
|
|
|
|
case 'user': return "
|
|
|
|
|
<span>
|
|
|
|
|
@username
|
|
|
|
|
<span class='rem-member' data-member='@id_user' data-cluster='@id_user_cluster'></span>
|
|
|
|
|
</span>";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 'machine_cluster': return "
|
|
|
|
|
<article class='inline-box' id='@id_machine_cluster'>
|
|
|
|
|
<input type='hidden' value='@class'>
|
|
|
|
|
|
|
|
|
|
<span class='title' style='color: ".$_SESSION['WAREHOUSE']['theme']."'>@name <span>#@name</span></span>
|
|
|
|
|
<span class='link_remove' data-cluster='@id_machine_cluster'>@icon_remove</span>
|
|
|
|
|
|
|
|
|
|
<span class='link_edit' data-cluster='@id_machine_cluster'>@icon_edit</span>
|
|
|
|
|
|
|
|
|
|
<span class='code'>
|
|
|
|
|
@icon_type
|
|
|
|
|
<span>machines (@nb_members)</span>
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
<span class='groups'>
|
|
|
|
|
@icon_group
|
|
|
|
|
@machines
|
|
|
|
|
<span class='add-member' data-cluster='@id_machine_cluster'>+</span>
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
</article>";
|
|
|
|
|
break;
|
2016-07-12 10:06:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-07-18 14:46:06 +00:00
|
|
|
|
case 'user_cluster': return "
|
|
|
|
|
<article class='inline-box' id='@id_user_cluster'>
|
2016-07-15 12:55:59 +00:00
|
|
|
|
<input type='hidden' value='@class'>
|
2016-07-12 10:06:46 +00:00
|
|
|
|
|
|
|
|
|
<span class='title' style='color: ".$_SESSION['WAREHOUSE']['theme']."'>@name <span>#@name</span></span>
|
2016-07-18 14:46:06 +00:00
|
|
|
|
<span class='link_remove' data-cluster='@id_user_cluster'>@icon_remove</span>
|
2016-07-12 10:06:46 +00:00
|
|
|
|
|
2016-07-18 14:46:06 +00:00
|
|
|
|
<span class='link_edit' data-cluster='@id_user_cluster'>@icon_edit</span>
|
2016-07-12 10:06:46 +00:00
|
|
|
|
|
|
|
|
|
<span class='code'>
|
|
|
|
|
@icon_type
|
2016-07-18 14:46:06 +00:00
|
|
|
|
<span>utilisateurs (@nb_members)</span>
|
2016-07-12 10:06:46 +00:00
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
<span class='groups'>
|
|
|
|
|
@icon_group
|
2016-07-18 14:46:06 +00:00
|
|
|
|
@users
|
|
|
|
|
<span class='add-member' data-cluster='@id_user_cluster'>+</span>
|
2016-07-12 10:06:46 +00:00
|
|
|
|
</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'] ]
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
2016-07-18 14:46:06 +00:00
|
|
|
|
$CLUSTERLIST[$u]['class'] = (isset($cluster['id_user_cluster'])) ? 0 : 1;
|
2016-07-12 10:06:46 +00:00
|
|
|
|
$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 ]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
?>
|