Module admin
This commit is contained in:
parent
6cd0c20981
commit
e130a76dd6
@ -11,11 +11,11 @@ class Admin_ServiceController extends Zend_Controller_Action
|
||||
public function detailAction()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
$id = $request->getParam('id');
|
||||
$code = $request->getParam('code');
|
||||
|
||||
$ws = new Scores_Ws_Client('gestion', '0.4');
|
||||
$params = new stdClass();
|
||||
$params->id = $id;
|
||||
$params->code = $code;
|
||||
$responses = $ws->getService($params);
|
||||
$this->view->Info = $responses;
|
||||
|
||||
|
@ -1,7 +1,61 @@
|
||||
<?php
|
||||
class Admin_UserController extends Zend_Controller_Action
|
||||
{
|
||||
public function indexAction(){}
|
||||
public function listAction(){}
|
||||
public function itemAction(){}
|
||||
public function indexAction()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
$code = $request->getParam('code');
|
||||
|
||||
// Get Service Name
|
||||
// Ne pas créer d'utilisateur lorsque Service Editable = 0
|
||||
$ws = new Scores_Ws_Client('gestion', '0.4');
|
||||
$params = new stdClass();
|
||||
$params->code = $code;
|
||||
$serviceResponse = $ws->getService($params);
|
||||
$this->view->Service = $serviceResponse;
|
||||
|
||||
// Get Users
|
||||
$ws = new Scores_Ws_Client('gestion', '0.4');
|
||||
$params = new stdClass();
|
||||
$params->actif = 1;
|
||||
$params->service = $code;
|
||||
$responses = $ws->getUserList($params);
|
||||
$this->view->List = $responses->item;
|
||||
}
|
||||
|
||||
public function detailAction(){}
|
||||
|
||||
public function formAction()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
|
||||
if ( $request->isPost() ) {
|
||||
$this->view->FormIsPost = true;
|
||||
$this->_helper->layout()->disableLayout();
|
||||
|
||||
$data = array();
|
||||
$data['status'] = 0;
|
||||
|
||||
$values = $request->getPost();
|
||||
|
||||
if ( $values['id']===null ) {
|
||||
$data['dateInsert'] = date('Y-m-d H:i:s');
|
||||
try {
|
||||
|
||||
$data['status'] = 1;
|
||||
$data['login'] = $values['login'];
|
||||
$data['email'] = $values['email'];
|
||||
$data['civilite'] = $values['civilite'];
|
||||
$data['nom'] = $values['nom'];
|
||||
$data['prenom'] = $values['prenom'];
|
||||
} catch(Zend_Db_Exception $e) {
|
||||
$data['status'] = 0;
|
||||
$data['msg'] = "Erreur lors de la création de l'utilisateur ! ".$e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
$this->view->data = $data;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -28,7 +28,7 @@ if ($l->Editable == 0) { $class = ''; } ?>
|
||||
aria-expanded="false">Action <span class="caret"></span>
|
||||
</button>
|
||||
<ul class="dropdown-menu dropdown-menu-right">
|
||||
<li><a href="<?=$this->url(array('module'=>'admin', 'controller'=>'service', 'action'=>'detail', 'id'=>$l->id),
|
||||
<li><a href="<?=$this->url(array('module'=>'admin', 'controller'=>'service', 'action'=>'detail', 'code'=>$l->Code),
|
||||
'default', true)?>">Paramètres</a></li>
|
||||
<li><a href="<?=$this->url(array('module'=>'admin', 'controller'=>'user', 'action'=>'index', 'code'=>$l->Code),
|
||||
'default', true)?>">Utilisateurs</a></li>
|
||||
|
@ -0,0 +1,11 @@
|
||||
<div id="content">
|
||||
|
||||
<div class="page-header">
|
||||
<h1>Utilisateur : {login}</h1>
|
||||
</div>
|
||||
|
||||
<pre>
|
||||
Liste des informations
|
||||
</pre>
|
||||
|
||||
</div>
|
@ -0,0 +1,94 @@
|
||||
<?php if ($this->FormIsPost) {?>
|
||||
|
||||
<?=json_encode($this->data)?>
|
||||
|
||||
<?php } else {?>
|
||||
|
||||
<div id="content">
|
||||
|
||||
<div class="page-header">
|
||||
<h1>Utilisateurs - <small><?=$this->Service->Label?></small></h1>
|
||||
</div>
|
||||
|
||||
<a href="<?=$this->url(array('module'=>'admin', 'controller'=>'user', 'action'=>'index'),
|
||||
'default', true)?>">Retour à la liste des utilisateurs</a>
|
||||
|
||||
<table class="table table-hover table-condensed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Identifiant</th>
|
||||
<th>Email</th>
|
||||
<th>Civilité</th>
|
||||
<th>Nom</th>
|
||||
<th>Prénom</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div id="user-msg"></div>
|
||||
|
||||
<form name="user" class="form-inline" role="form" action="<?=$this->url(array('module'=>'admin', 'controller'=>'user',
|
||||
'action'=>'form'), 'default', true)?>" method="post">
|
||||
<input type="hidden" name="idClient" value="<?=$this->client?>" />
|
||||
<input type="hidden" name="idService" value="<?=$this->Service->id?>" />
|
||||
<div class="form-group">
|
||||
<input class="form-control" type="text" name="login" value="" placeholder="Login" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input class="form-control" type="text" name="email" value="" placeholder="nom@domain.fr" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<select name="civilite" class="form-control">
|
||||
<option value="M">M</option>
|
||||
<option value="Mme">Mme</option>
|
||||
<option value="Mlle">Mlle</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input class="form-control" type="text" name="nom" value="" placeholder="Nom" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input class="form-control" type="text" name="prenom" value="" placeholder="Prénom" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<button id="btnUserSubmit" type="submit" class="btn btn-primary btn-sm" data-submit-text="Création...">Valider</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$('form[name=user]').submit(function(e){
|
||||
e.preventDefault();
|
||||
var btn = $('button#btnUserSubmit');
|
||||
var btnText = btn.html();
|
||||
btn.html(btn.data('submit-text'));
|
||||
var obj = $(this);
|
||||
var url = obj.attr('action');
|
||||
$.post(url, obj.serialize(), function(data){
|
||||
if(data.status==0) {
|
||||
$('#user-msg').html(data.msg).addClass('alert alert-info');
|
||||
} else if (data.status==1) {
|
||||
$('table#users tbody').append(
|
||||
'<tr>' +
|
||||
'<td>' + data.login +'</td>' +
|
||||
'<td>' + data.email +'</td>' +
|
||||
'<td>' + data.civilite +'</td>' +
|
||||
'<td>' + data.nom +'</td>' +
|
||||
'<td>' + data.prenom +'</td>' +
|
||||
'<td></td>'+
|
||||
'</tr>'
|
||||
);
|
||||
}
|
||||
}, 'json').fail(function(){
|
||||
$('#user-msg').html("<p>Error</p>").addClass('alert alert-info');
|
||||
}).always(function(){
|
||||
btn.html(btnText);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<?php }?>
|
@ -0,0 +1,55 @@
|
||||
<div id="content">
|
||||
|
||||
<div class="page-header">
|
||||
<h1>Utilisateurs - <small><?=$this->Service->Label?></small></h1>
|
||||
</div>
|
||||
|
||||
<div class="btn-group">
|
||||
<a href="#" class="btn btn-sm btn-default dropdown-toggle" data-toggle="dropdown">
|
||||
Filtre <span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="<?=$this->url(array('module'=>'admin', 'controller'=>'user', 'action'=>'index', 'filtre'=>'enable'))?>">Actif</a></li>
|
||||
<li><a href="<?=$this->url(array('module'=>'admin', 'controller'=>'user', 'action'=>'index', 'filtre'=>'disable'))?>">Inactif</a></li>
|
||||
<li><a href="<?=$this->url(array('module'=>'admin', 'controller'=>'user', 'action'=>'index', 'filtre'=>'deleted'))?>">Supprimé</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<a href="<?=$this->url(array('module'=>'admin', 'controller'=>'user', 'action'=>'form', 'idClient'=>$this->client,
|
||||
'idService'=>$this->service), 'default', true)?>"
|
||||
class="btn btn-sm btn-default">Nouvel utilisateur</a>
|
||||
|
||||
<?php if (count($this->List) > 0) {?>
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Login</th>
|
||||
<th>Identité</th>
|
||||
<th>Courriel</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach($this->List as $l) {?>
|
||||
<tr>
|
||||
<td><?=$l->Login?></td>
|
||||
<td><?=$l->Civilite . ". " . $l->Nom . " " . $l->Prenom?></td>
|
||||
<td><?=$l->Email?></td>
|
||||
<td>
|
||||
<div class="btn-group">
|
||||
<button type="button" class="btn btn-xs btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true"
|
||||
aria-expanded="false">Action <span class="caret"></span>
|
||||
</button>
|
||||
<ul class="dropdown-menu dropdown-menu-right">
|
||||
<li><a href="">Fiche</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php }?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php } else {?>
|
||||
|
||||
<?php }?>
|
||||
</div>
|
Loading…
Reference in New Issue
Block a user