Commit f30ca39f authored by THEO GUILLON's avatar THEO GUILLON
Browse files

Merge branch '372-ajout-d-une-page-destinee-a-la-recette-corrections-mineures' into '1.2.0'

Resolve "Ajout d'une page destinée à la recette, corrections mineures"

See merge request libriciel/pole-citoyens/web-DPO/web-DPO!334
parents 231fce46 19695905
<?php
class RecettesController extends AppController {
public $uses = [
'Organisation'
];
/**
* Vérification de l'accès aux actions en fonction du profil de l'utilisateur connecté.
*/
public function beforeFilter() {
parent::beforeFilter();
// Seul le rôle Superutilisateur peut accéder à ce contrôleur, uniquement en mode debug et sur une instance de recette
$recette = preg_match('/^https{0,1}:\/\/(localhost|.*\.recette\.libriciel\.fr)[:\/]/', Router::url( $this->here, true )) === 1;
if ($this->Droits->isSu() !== true || (int)Configure::read('debug') < 1 || $recette === false) {
throw new ForbiddenException(__d('default', 'default.flasherrorPasDroitPage'));
}
}
protected function _getOrganisations() {
$query = [
'fields' => [
'Organisation.id',
'Organisation.raisonsociale'
],
'contain' => [
'Responsable' => [
'fields' => ['Responsable.nom_complet'],
'order' => ['Responsable.nom_complet']
],
'Role' => [
'fields' => ['Role.libelle'],
'order' => ['Role.libelle']
],
'Service' => [
'fields' => ['Service.libelle'],
'order' => ['Service.libelle']
],
'Soustraitant' => [
'fields' => ['Soustraitant.raisonsociale'],
'order' => ['Soustraitant.raisonsociale']
],
'Typage' => [
'fields' => ['Typage.libelle'],
'order' => ['Typage.libelle']
],
'User' => [
'fields' => ['User.username'],
'order' => ['User.username']
],
],
'order' => [
'Organisation.raisonsociale'
]
];
return $this->Organisation->find('all', $query);
}
protected function _getUsers() {
$query = [
'fields' => array_merge(
[
'User.username',
'User.nom_complet',
'User.email',
'("Admin"."id" IS NOT NULL) AS "User__is_superadmin"',
'(CASE
WHEN "User"."username" = \'superadmin\' THEN \'admin\'
WHEN "Admin"."id" IS NOT NULL THEN \'Voitures2ColoSoupersos\'
ELSE \'bateauavionmotovoiture\'
END) AS "User__pwd"',
],
$this->Organisation->User->Admin->fields()
),
'contain' => [
'Organisation' => [
'fields' => [
'Organisation.raisonsociale',
'("Organisation"."dpo" = "OrganisationUser"."user_id") AS "User__is_dpo"',
],
'order' => [
'Organisation.raisonsociale'
],
],
],
'joins' => [
$this->Organisation->User->join('Admin', ['type' => 'LEFT OUTER'])
],
'conditions' => [],
'order' => [
'User.username'
]
];
$users = $this->Organisation->User->find('all', $query);
foreach ($users as $idx => $user) {
foreach ((array)Hash::extract($user, 'Organisation.{n}.OrganisationUser') as $i => $ou) {
$query = [
'conditions' => [
'OrganisationUser.id' => $ou['id']
],
'contain' => [
'OrganisationUserRole' => [
'Role' => [
'fields' => 'Role.libelle',
'order' => 'Role.libelle',
]
],
'OrganisationUserService' => [
'Service' => [
'fields' => 'Service.libelle',
'order' => 'Service.libelle',
]
],
]
];
$users[$idx]['Organisation'][$i]['OrganisationUser'] = array_merge(
$users[$idx]['Organisation'][$i],
$this->Organisation->OrganisationUser->find('first', $query)
);
}
}
return $users;
}
public function index() {
$organisations = $this->_getOrganisations();
$users = $this->_getUsers();
$this->set(compact('organisations', 'users'));
}
}
......@@ -217,6 +217,20 @@ class Organisation extends AppModel {
'finderQuery' => '',
'with' => 'ArticleOrganisation'
],
'Typage' => [
'className' => 'Typage',
'joinTable' => 'typages_organisations',
'foreignKey' => 'organisation_id',
'associationForeignKey' => 'typage_id',
'unique' => true,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'finderQuery' => '',
'with' => 'TypageOrganisation'
],
];
/**
......
<h1>Données actuelles pour la recette</h1>
<h2>Liste des 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
$colums = [
'Role.{n}.libelle',
'Responsable.{n}.nom_complet',
'Service.{n}.libelle',
'Soustraitant.{n}.raisonsociale',
'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 /*debug($organisations);*/?>
<h2>Liste des utilisateurs</h2>
<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>Spécial</th>
<th>Entité</th>
<th>Profil</th>
<th>Services</th>
</tr>
</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 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><?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>
<?php /*debug($users);*/?>
......@@ -306,6 +306,12 @@ __symlinks__()
&& ln -s ${__DATA_DIR__}/app/tmp ${__APP_DIR__}/app/tmp
fi
# Création du lien symbolique pour les logos de entités
rm -rf ${__APP_DIR__}/app/webroot/img/logos/logo_organisation \
&& mkdir -p ${__APP_DIR__}/app/webroot/img/logos \
&& chown -R www-data: ${__APP_DIR__}/app/webroot/img/logos \
&& ln -s ${__DATA_DIR__}/workspace/files/logos ${__APP_DIR__}/app/webroot/img/logos/logo_organisation
${__APP_DIR__}/cake_utils.sh clear
# @fixme
......
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