Commit 3e14e943 authored by Christian BUFFIN's avatar Christian BUFFIN

Amélioration de la page de résumé pour la recette (ajout de la liste des...

Amélioration de la page de résumé pour la recette (ajout de la liste des formulaires de toute l'application dans la page dédiée à la recette)
parent 318aa822
<?php
App::uses('AuthComponent', 'Controller/Component');
class RecettesController extends AppController {
public $uses = [
......@@ -59,6 +61,38 @@ class RecettesController extends AppController {
return $this->Organisation->find('all', $query);
}
protected function _getFormulaires() {
$Formulaire = ClassRegistry::init('Formulaire');
$Formulaire->belongsTo['Organisation'] = [
'className' => 'Organisation',
'foreignKey' => 'organisations_id',
'conditions' => null,
'fields' => null,
'order' => null,
'counterCache' => null
];
$query = [
'fields' => [
'Organisation.raisonsociale',
'Formulaire.libelle',
'Formulaire.active',
'Formulaire.rt_externe',
],
'contain' => [
'Organisation'
],
'order' => [
'Organisation.raisonsociale',
'Formulaire.rt_externe',
'Formulaire.libelle',
'Formulaire.id'
]
];
return $Formulaire->find('all', $query);
}
protected function _getUsers() {
$query = [
'fields' => array_merge(
......@@ -66,6 +100,8 @@ class RecettesController extends AppController {
'User.username',
'User.nom_complet',
'User.email',
'User.notification',
'User.password',
'("Admin"."id" IS NOT NULL) AS "User__is_superadmin"',
'(CASE
WHEN "User"."username" = \'superadmin\' THEN \'admin\'
......@@ -125,13 +161,19 @@ class RecettesController extends AppController {
}
}
// Si le mot de passe n'est pas un de ceux auxquels on s'attend, on le note pour avertir dans la vue
foreach (array_keys($users) as $idx) {
$users[$idx]['User']['password'] = AuthComponent::password($users[$idx]['User']['pwd']) === $users[$idx]['User']['password'];
}
return $users;
}
public function index() {
$formulaires = $this->_getFormulaires();
$organisations = $this->_getOrganisations();
$users = $this->_getUsers();
$this->set(compact('organisations', 'users'));
$this->set(compact('formulaires', 'organisations', 'users'));
}
}
<h1>Données actuelles pour la recette</h1>
<style type="text/css" media="all">
td ul, td li {
margin: 0;
padding: 0;
}
td ul {
padding-left: 0.666em;
}
</style>
<?php
$this->set('title', sprintf('Recette v. %s', VERSION));
$yes = '<span class="fa fa-check-square-o fa-fw"> </span><span class="sr-only">Oui</span>';
$no = '<span class="fa fa-square-o fa-fw"> </span><span class="sr-only">Non</span>';
?>
<h2>Liste des entités</h2>
<h2>Entités</h2>
<table border="1" cellpadding="1" cellspacing="1" class="table">
<thead>
<tr>
<th>Raison sociale</th>
<th>Profils</th>
<th>Responsables</th>
<th>Services</th>
<th>Sous-traitants</th>
<th>Types d'annexes</th>
<th>Utilisateurs</th>
</tr>
</thead>
<tbody>
<?php foreach ($organisations as $organisation):?>
<tr>
<td><?php echo $organisation['Organisation']['raisonsociale']?></td>
<?php
<div class="table-responsive">
<table border="1" cellpadding="1" cellspacing="1" class="table">
<thead>
<tr>
<th rowspan="2">Raison sociale</th>
<th rowspan="2">Profils</th>
<th rowspan="2">Services</th>
<th rowspan="2">Utilisateurs</th>
<th colspan="3">Associations</th>
</tr>
<tr>
<th>Sous-traitants</th>
<th>Responsables</th>
<th>Types d'annexes</th>
</tr>
</thead>
<tbody>
<?php foreach ($organisations as $organisation):?>
<tr>
<td><?php echo $organisation['Organisation']['raisonsociale']?></td>
<?php
$colums = [
'Role.{n}.libelle',
'Responsable.{n}.nom_complet',
'Service.{n}.libelle',
'User.{n}.username',
'Soustraitant.{n}.raisonsocialestructure',
'Responsable.{n}.nom_complet',
'Typage.{n}.libelle',
'User.{n}.username'
];
?>
<?php foreach($colums as $column):?>
<td>
<?php
$items = Hash::extract($organisation, $column);
if (empty($items) === false) {
echo sprintf('<ul><li>%s</li></ul>', implode('</li><li>', $items));
}
?>
</td>
<?php endforeach;?>
</tr>
<?php endforeach;?>
</tbody>
</table>
?>
<?php foreach($colums as $column):?>
<td>
<?php
$items = Hash::extract($organisation, $column);
if (empty($items) === false) {
echo sprintf('<ul><li>%s</li></ul>', implode('</li><li>', $items));
}
?>
</td>
<?php endforeach;?>
</tr>
<?php endforeach;?>
</tbody>
</table>
</div>
<?php /*debug($organisations);*/?>
<h2>Liste des utilisateurs</h2>
<h2>Utilisateurs</h2>
<table border="1" cellpadding="1" cellspacing="1" class="table">
<thead>
<div class="table-responsive">
<table border="1" cellpadding="1" cellspacing="1" class="table">
<thead>
<tr>
<th>Identifiant</th>
<th>Nom</th>
<th>Mot de passe</th>
<th>Courriel</th>
<th>Notifications</th>
<th>Spécial</th>
<th>Entité</th>
<th>Profil</th>
<th>Services</th>
</tr>
</thead>
<tbody>
</thead>
<tbody>
<?php foreach ($users as $user):?>
<tr>
<?php
$links = 0;
if (isset($user['Organisation']) === true) {
$links = count($user['Organisation']);
}
$rowspan = $links < 1 ? 1 : $links;
?>
<td rowspan="<?php echo $rowspan;?>"><?php echo $user['User']['username'];?></td>
<td rowspan="<?php echo $rowspan;?>"><?php echo $user['User']['nom_complet'];?></td>
<td rowspan="<?php echo $rowspan;?>">
<?php
$links = 0;
if (isset($user['Organisation']) === true) {
$links = count($user['Organisation']);
}
$rowspan = $links < 1 ? 1 : $links;
if ($user['User']['password'] === true) {
echo $user['User']['pwd'];
} else {
printf('<span class="text-danger"><strong>Devrait être:</strong> %s</span>', $user['User']['pwd']);
}
?>
<td rowspan="<?php echo $rowspan;?>"><?php echo $user['User']['username']?></td>
<td rowspan="<?php echo $rowspan;?>"><?php echo $user['User']['nom_complet']?></td>
<td rowspan="<?php echo $rowspan;?>"><?php echo $user['User']['pwd']?></td>
<td rowspan="<?php echo $rowspan;?>"><?php echo $user['User']['email']?></td>
<?php if ($links === 0):?>
<td>Superadmin</td>
<td colspan="3"></td>
<?php else:?>
<?php foreach ($user['Organisation'] as $uo):?>
<td><?php
if ($uo['User']['is_dpo'] === true) {
echo 'DPO';
}
</td>
<td rowspan="<?php echo $rowspan;?>"><?php echo $user['User']['email'];?></td>
<td rowspan="<?php echo $rowspan;?>"><?php echo $user['User']['notification'] ? $yes : $no;?></td>
<?php if ($links === 0):?>
<td>Superadmin</td>
<td colspan="3"></td>
<?php else:?>
<?php foreach ($user['Organisation'] as $uo):?>
<td><?php
if ($uo['User']['is_dpo'] === true) {
echo 'DPO';
}
?></td>
<td><?php echo $uo['raisonsociale']?></td>
<td><?php echo $uo['OrganisationUser']['OrganisationUserRole'][0]['Role']['libelle'];?></td>
<td>
<?php
$services = Hash::extract($uo, 'OrganisationUser.OrganisationUserService.Service.libelle');
if (empty($services) === false) {
echo sprintf('<ul><li>%s</li></ul>', implode('</li><li>', $services));
}
?>
</td>
</tr><tr>
<?php endforeach;?>
<?php endif;?>
<td><?php echo $uo['raisonsociale']?></td>
<td><?php echo $uo['OrganisationUser']['OrganisationUserRole'][0]['Role']['libelle'];?></td>
<td>
<?php
$services = Hash::extract($uo, 'OrganisationUser.OrganisationUserService.Service.libelle');
if (empty($services) === false) {
echo sprintf('<ul><li>%s</li></ul>', implode('</li><li>', $services));
}
?>
</td>
</tr><tr>
<?php endforeach;?>
<?php endif;?>
</tr>
<?php endforeach;?>
</tbody>
</table>
</tbody>
</table>
</div>
<h2>Formulaires</h2>
<?php /*debug($users);*/?>
<div class="table-responsive">
<table border="1" cellpadding="1" cellspacing="1" class="table">
<thead>
<tr>
<th>Entité</th>
<th>Formulaire</th>
<th>Registre</th>
<th>Actif</th>
</tr>
</thead>
<tbody>
<?php foreach ($formulaires as $formulaire):?>
<tr>
<td><?php echo $formulaire['Organisation']['raisonsociale'];?></td>
<td><?php echo $formulaire['Formulaire']['rt_externe'] ? 'Sous-traitance' : 'Activité';?></td>
<td><?php echo $formulaire['Formulaire']['libelle'];?></td>
<td><?php echo $formulaire['Formulaire']['active'] ? $yes : $no;?></td>
</tr>
<?php endforeach;?>
</tbody>
</table>
</div>
<?php /*debug($formulaires);*/?>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment