2016-07-11 15:44:18 +00:00
|
|
|
|
<?php
|
|
|
|
|
|
2016-07-24 22:26:58 +00:00
|
|
|
|
namespace manager\views\user;
|
2016-08-06 09:32:50 +00:00
|
|
|
|
use \manager\ViewManager;
|
2016-07-11 16:14:18 +00:00
|
|
|
|
use \manager\ModuleRequest;
|
2016-07-11 15:44:18 +00:00
|
|
|
|
use \manager\Authentification;
|
|
|
|
|
use \manager\ManagerError;
|
|
|
|
|
|
2016-08-06 09:32:50 +00:00
|
|
|
|
class user_view{
|
2016-07-11 15:44:18 +00:00
|
|
|
|
|
2016-07-12 10:06:46 +00:00
|
|
|
|
public static function template($type=null){
|
2016-07-11 16:14:18 +00:00
|
|
|
|
|
|
|
|
|
switch($type){
|
|
|
|
|
case 'cluster': return "
|
|
|
|
|
<span>
|
2016-07-12 08:40:51 +00:00
|
|
|
|
@name
|
2016-07-24 13:35:00 +00:00
|
|
|
|
<span class='rem-group' data-group='@id_user_cluster' data-user='@id_user'></span>
|
2016-07-11 16:14:18 +00:00
|
|
|
|
</span>";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 'user': return "
|
2016-07-12 08:40:51 +00:00
|
|
|
|
<article class='inline-box' id='@id_user'>
|
2016-07-11 16:14:18 +00:00
|
|
|
|
|
2016-07-12 10:06:46 +00:00
|
|
|
|
<span class='title' style='color: ".$_SESSION['WAREHOUSE']['theme']."'>@firstname @lastname <span>#@username</span></span>
|
2016-07-12 08:40:51 +00:00
|
|
|
|
<span class='link_remove' data-user='@id_user'>@icon_remove</span>
|
2016-07-11 16:14:18 +00:00
|
|
|
|
|
2016-07-12 08:40:51 +00:00
|
|
|
|
<span class='link_edit' data-user='@id_user'>@icon_edit</span>
|
2016-07-11 16:14:18 +00:00
|
|
|
|
|
|
|
|
|
<span class='code'>
|
|
|
|
|
@icon_card
|
2016-07-12 08:40:51 +00:00
|
|
|
|
<span>@code</span>
|
2016-07-11 16:14:18 +00:00
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
<span class='mail'>
|
2016-07-12 10:06:46 +00:00
|
|
|
|
@icon_mail
|
2016-07-11 16:14:18 +00:00
|
|
|
|
|
2016-07-12 08:40:51 +00:00
|
|
|
|
<a href='mailto:@mail'>
|
|
|
|
|
<span>@mail</span>
|
2016-07-11 16:14:18 +00:00
|
|
|
|
</a>
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
<span class='groups'>
|
|
|
|
|
@icon_group
|
|
|
|
|
@grouplist
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
</article>";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
default: return "
|
|
|
|
|
<input type='text' class='searchbar' placeholder='Recherche'>
|
|
|
|
|
@userlist";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
}
|
2016-07-11 15:44:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-07-12 10:06:46 +00:00
|
|
|
|
public static function view($params){
|
2016-07-11 16:14:18 +00:00
|
|
|
|
$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 )
|
2016-08-06 09:32:50 +00:00
|
|
|
|
return ViewManager::$htmlError;
|
2016-07-11 16:14:18 +00:00
|
|
|
|
|
2016-07-12 08:40:51 +00:00
|
|
|
|
$USERLIST = $answer->get('users');
|
2016-07-11 16:14:18 +00:00
|
|
|
|
|
2016-07-12 08:40:51 +00:00
|
|
|
|
foreach($USERLIST as $u=>$user){
|
2016-07-11 16:14:18 +00:00
|
|
|
|
$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 = [];
|
|
|
|
|
|
2016-08-06 09:32:50 +00:00
|
|
|
|
$USERLIST[$u]['grouplist'] = ViewManager::replaceMultiple(
|
2016-07-12 10:06:46 +00:00
|
|
|
|
self::template('cluster'),
|
2016-07-12 08:40:51 +00:00
|
|
|
|
$clusters,
|
|
|
|
|
[ 'id_user' => $user['id_user'] ]
|
|
|
|
|
);
|
2016-07-11 16:14:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2016-08-06 09:32:50 +00:00
|
|
|
|
$view_user = ViewManager::replaceMultiple(
|
2016-07-12 10:06:46 +00:00
|
|
|
|
self::template('user'),
|
2016-07-12 08:40:51 +00:00
|
|
|
|
$USERLIST, [
|
|
|
|
|
'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' ),
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-07-11 16:14:18 +00:00
|
|
|
|
|
|
|
|
|
|
2016-08-06 09:32:50 +00:00
|
|
|
|
return ViewManager::replaceSingle(self::template(), [ 'userlist' => $view_user ]);
|
2016-07-11 15:44:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-07-11 16:14:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-07-11 15:44:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
?>
|