Commit 171eab52 authored by THEO GUILLON's avatar THEO GUILLON
Browse files

Ajout de la civilité du responsable de traitement.

Ajout de la civilité sur les champs affichant le DPO
parent dcb96a6d
......@@ -46,8 +46,26 @@ Icon?
ehthumbs.db
Thumbs.db
# netbeans
nbproject
nbproject/private/private.xml
# Tool specific files #
#######################
# vim
*~
*.swp
*.swo
*.lock
# sublime text & textmate
*.sublime-*
*.stTheme.cache
*.tmlanguage.cache
*.tmPreferences.cache
# Eclipse
.settings/*
# JetBrains, aka PHPStorm, IntelliJ IDEA
.idea/*
# NetBeans
nbproject/*
node_modules/
# Visual Studio Code
.vscode
# Sass preprocessor
.sass-cache/
BEGIN;
ALTER TABLE organisations ADD COLUMN civiliteresponsable VARCHAR(4) NOT NULL DEFAULT 'M.';
ALTER TABLE organisations ALTER COLUMN civiliteresponsable drop default;
ALTER TABLE organisations ADD CONSTRAINT organisations_civiliteresponsable_in_list_chk CHECK (cakephp_validate_in_list(civiliteresponsable, ARRAY['M.', 'Mme.']));
COMMIT;
......@@ -139,7 +139,7 @@
/**
* Turn off all caching application-wide.
*/
Configure::write('Cache.disable', false);
Configure::write('Cache.disable', true);
/**
* Enable cache checking.
......
......@@ -23,6 +23,9 @@
App::uses('ListeDroit', 'Model');
App::uses('File', 'Utility');
/**
* @property mixed ResponsableOrganisation
*/
class FichesController extends AppController {
public $helpers = [
......@@ -63,14 +66,16 @@ class FichesController extends AppController {
* @created 17/06/2015
* @version V1.0.0
*/
public function index() {
public function index()
{
$this->redirect([
'controller' => 'pannel',
'action' => 'index'
]);
}
public function saveFileTmp() {
public function saveFileTmp()
{
if (!empty($this->request->params['form']['fichiers'])) {
if (empty($this->Session->read('Auth.User.uuid'))) {
......@@ -111,7 +116,8 @@ class FichesController extends AppController {
}
}
public function deleteFile() {
public function deleteFile()
{
$this->autoRender = false;
$file = new File(CHEMIN_PIECE_JOINT_TMP . $this->Session->read('Auth.User.id') . DS . $this->Session->read('Auth.User.uuid') . DS . $this->request->data('filename') );
......@@ -127,7 +133,8 @@ class FichesController extends AppController {
* @created 19/10/2018
* @version V1.0.1²
*/
public function deleteRecordingFile() {
public function deleteRecordingFile()
{
$this->autoRender = false;
$success = true;
......@@ -184,20 +191,18 @@ class FichesController extends AppController {
* @created 17/06/2015
* @version V1.0.0
*/
public function add($id) {
public function add($id)
{
if (true !== $this->Droits->authorized(ListeDroit::REDIGER_TRAITEMENT)) {
throw new ForbiddenException(__d('default', 'default.flasherrorPasDroitPage'));
}
$this->set('title', __d('fiche', 'fiche.titreCrationFiche'));
if (empty($this->Session->read($this->Session->read('Auth.User.uuid')))) {
$files = array_diff(scandir(CHEMIN_PIECE_JOINT_TMP . $this->Session->read('Auth.User.id') . DS . $this->Session->read('Auth.User.uuid')), array('..', '.'));
$this->set('files', $files);
}
//On récupére le DPO de la collectivité
$this->set('userDPO', $this->_dpoOrganisation());
$this->set('title', __d('fiche', 'fiche.titreCrationFiche'));
$champs = $this->Champ->find('all', [
'conditions' => [
......@@ -208,57 +213,10 @@ class FichesController extends AppController {
'ligne ASC'
]
]);
$this->set(compact('champs'));
$this->set('formulaireid', $id);
$query = [
'conditions' => [
'abroger' => false
],
'fields' => ['id', 'norme', 'numero', 'libelle', 'description'],
'order' => ['norme', 'numero']
];
$normes = $this->Norme->find('all', $query);
$options_normes = Hash::combine(
$normes,
'{n}.Norme.id',
[
'%s-%s : %s',
'{n}.Norme.norme',
'{n}.Norme.numero',
'{n}.Norme.libelle'
]
);
$this->set(compact('options_normes'));
$descriptions_normes = Hash::combine(
$normes,
'{n}.Norme.id',
'{n}.Norme.description'
);
$this->set(compact('descriptions_normes'));
$soustraitance = $this->Formulaire->find('first', [
'conditions' => [
'id' => $id
],
'fields' => [
'soustraitant'
]
]);
$this->set(compact('soustraitance'));
$soustraitants = $this->_soustraitants();
$this->set(compact('soustraitants'));
$responsables = $this->_responsables();
$this->set(compact('responsables'));
if ($this->request->is('POST')) {
if('Cancel' === Hash::get($this->request->data, 'submit')) {
if(!empty($this->Session->read('Auth.User.uuid'))){
if ('Cancel' === Hash::get($this->request->data, 'submit')) {
if (!empty($this->Session->read('Auth.User.uuid'))) {
$this->Session->delete('Auth.User.uuid');
}
......@@ -319,6 +277,84 @@ class FichesController extends AppController {
$this->Session->setFlash(__d('default', 'default.flasherrorEnregistrementErreur'), 'flasherror');
}
}
$this->set('formulaireid', $id);
$query = [
'conditions' => [
'abroger' => false
],
'fields' => [
'id',
'norme',
'numero',
'libelle',
'description'
],
'order' => [
'norme',
'numero'
]
];
$normes = $this->Norme->find('all', $query);
$options_normes = Hash::combine(
$normes,
'{n}.Norme.id',
[
'%s-%s : %s',
'{n}.Norme.norme',
'{n}.Norme.numero',
'{n}.Norme.libelle'
]
);
$descriptions_normes = Hash::combine(
$normes,
'{n}.Norme.id',
'{n}.Norme.description'
);
$soustraitance = $this->Formulaire->find('first', [
'conditions' => [
'id' => $id
],
'fields' => [
'soustraitant'
]
]);
$soustraitants = $this->_soustraitants();
$responsables = $this->_responsables();
$organisation = $this->Organisation->find('first', [
'conditions' => [
'id' => 1
],
'fields' => [
'raisonsociale',
'telephone',
'fax',
'adresse',
'email',
'sigle',
'siret',
'ape',
'civiliteresponsable',
'nomresponsable',
'prenomresponsable',
'emailresponsable',
'telephoneresponsable',
'fonctionresponsable',
'dpo',
'numerodpo',
],
]);
//On récupére le DPO de la collectivité
$userDPO = $this->_dpoOrganisation($organisation['Organisation']['dpo']);
$this->set(compact('champs', 'options_normes', 'descriptions_normes', 'soustraitance', 'soustraitants', 'responsables', 'organisation', 'userDPO'));
}
protected function _responsables() {
......@@ -385,7 +421,8 @@ class FichesController extends AppController {
* @created 17/06/2015
* @version V1.0.0
*/
public function delete($id = null) {
public function delete($id = null)
{
if ($this->Droits->authorized(ListeDroit::REDIGER_TRAITEMENT) && $this->Droits->isOwner($id)) {
if (!$this->Droits->isDeletable($id)) {
$this->Session->setFlash(__d('fiche', 'fiche.flasherrorPasAccesTraitement'), 'flasherror');
......@@ -436,7 +473,8 @@ class FichesController extends AppController {
* @created 17/06/2015
* @version V1.0.0
*/
public function edit($id = null) {
public function edit($id = null)
{
if (!$id && !$this->request->data['Fiche']['id']) {
$this->Session->setFlash(__d('default', 'default.flasherrorTraitementInexistant'), 'flasherror');
$this->redirect($this->Referers->get());
......@@ -646,29 +684,29 @@ class FichesController extends AppController {
* @param int $id
*
* @access public
*
* @created 17/06/2015
* @version V1.0.0
*
* @author Théo GUILLON <theo.guillon@libriciel.coop>
* @edit 25/02/2019
* @version v1.0.2
*/
public function show($id) {
$nameTraiment = $this->Valeur->find('first', [
'conditions' => [
'fiche_id' => $id,
'champ_name' => 'outilnom']
]);
$this->set('title', __d('fiche', 'fiche.titreApercuFiche') . $nameTraiment['Valeur']['valeur']);
public function show($id)
{
if (!$id) {
$this->Session->setFlash(__d('default', 'default.flasherrorTraitementInexistant'), 'flasherror');
$this->redirect($this->Referers->get());
}
// if (!$this->Droits->isReadable($id)) {
// $this->Session->setFlash(__d('fiche', 'fiche.flasherrorPasAccesTraitement'), 'flasherror');
// $this->redirect($this->Referers->get());
// }
$nameTraiment = $this->Valeur->find('first', [
'conditions' => [
'fiche_id' => $id,
'champ_name' => 'outilnom'
]
]);
//On récupére le DPO de la collectivité
$this->set('userDPO', $this->_dpoOrganisation());
$this->set('title', __d('fiche', 'fiche.titreApercuFiche') . $nameTraiment['Valeur']['valeur']);
$idForm = $this->Fiche->find('first', ['conditions' => ['id' => $id]]);
$champs = $this->Champ->find('all', [
......@@ -688,7 +726,11 @@ class FichesController extends AppController {
$this->set(compact('normeTraitement'));
}
$valeurs = $this->Valeur->find('all', ['conditions' => ['fiche_id' => $id]]);
$valeurs = $this->Valeur->find('all', [
'conditions' => [
'fiche_id' => $id
]
]);
foreach ($valeurs as $key => $value) {
if ($this->Fiche->isJson($value['Valeur']['valeur'])) {
......@@ -697,7 +739,7 @@ class FichesController extends AppController {
$this->request->data['Fiche'][$value['Valeur']['champ_name']] = $value['Valeur']['valeur'];
}
}
$soustraitance = $this->Formulaire->find('first', [
'conditions' => [
'id' => $idForm['Fiche']['form_id']
......@@ -706,29 +748,24 @@ class FichesController extends AppController {
'soustraitant'
]
]);
$this->set(compact('soustraitance'));
$this->requestAction([
'controller' => 'pannel',
'action' => 'supprimerLaNotif',
$id
]);
$this->set(compact('valeurs'));
$this->set(compact('champs'));
$this->set('id', $id);
$files = $this->Fichier->find('all', [
'conditions' => [
'fiche_id' => $id
]
]);
$this->set(compact('files'));
$this->set('coresponsable', $idForm['Fiche']['coresponsable']);
$responsables = $this->_responsables();
$this->set(compact('responsables'));
$this->set(compact('soustraitance', 'valeurs', 'champs', 'id', 'files', 'responsables'));
}
/**
......@@ -740,7 +777,8 @@ class FichesController extends AppController {
* @created 17/06/2015
* @version V1.0.0
*/
public function download($url = null, $nomFile = 'file.odt') {
public function download($url = null, $nomFile = 'file.odt')
{
$this->response->file(CHEMIN_PIECE_JOINT . $url, [
'download' => true,
'name' => $nomFile
......@@ -759,7 +797,8 @@ class FichesController extends AppController {
* @created 04/01/2016
* @version V1.0.0
*/
public function downloadFileTraitement($fiche_id) {
public function downloadFileTraitement($fiche_id)
{
$fiche = $this->Fiche->find('first', [
'conditions' => ['id' => $fiche_id]
]);
......@@ -802,7 +841,8 @@ class FichesController extends AppController {
* @version V1.0.0
* @author Théo GUILLON <theo.guillon@libriciel.coop>
*/
public function downloadFileExtrait($fiche_id) {
public function downloadFileExtrait($fiche_id)
{
// On vérifie que $fiche_id n'est pas vide
if (empty($fiche_id)) {
$this->Session->setFlash(__d('registre', 'registre.flasherrorAucunTraitementSelectionner'), 'flasherror');
......@@ -926,19 +966,27 @@ class FichesController extends AppController {
/**
* On récupére le DPO de la collectivité
*
* @param int $idUserDPO : id de l'utilisateur DPO dans l'organisation
* @return array()
*
* @access public
*
* @author Théo GUILLON <theo.guillon@libriciel.coop>
* @created 17/05/2017
* @version V1.0.0
*
* @author Théo GUILLON <theo.guillon@libriciel.coop>
* @edit 25/02/2019
* @version V1.0.2
*/
protected function _dpoOrganisation() {
protected function _dpoOrganisation($idUserDPO)
{
$userDPO = $this->User->find('first', [
'conditions' => [
'id' => $this->Session->read('Organisation.dpo')
'id' => $idUserDPO
],
'fields' => [
'civilite',
'nom',
'prenom',
'email',
......@@ -961,7 +1009,8 @@ class FichesController extends AppController {
* @version V1.0.0
* @author Théo GUILLON <theo.guillon@libriciel.coop>
*/
public function genereTraitement($tabId) {
public function genereTraitement($tabId)
{
if (true !== $this->Droits->authorized(ListeDroit::TELECHARGER_TRAITEMENT_REGISTRE)) {
throw new ForbiddenException(__d('default', 'default.flasherrorPasDroitPage'));
}
......@@ -987,7 +1036,8 @@ class FichesController extends AppController {
* @version V1.0.0
* @author Théo GUILLON <theo.guillon@libriciel.coop>
*/
public function genereTraitementNonVerrouiller($tabId) {
public function genereTraitementNonVerrouiller($tabId)
{
if (true !== $this->Droits->authorized(ListeDroit::TELECHARGER_TRAITEMENT_REGISTRE)) {
throw new ForbiddenException(__d('default', 'default.flasherrorPasDroitPage'));
}
......@@ -1110,7 +1160,8 @@ class FichesController extends AppController {
* @version V1.0.0
* @author Théo GUILLON <theo.guillon@libriciel.coop>
*/
public function genereExtraitRegistre($tabId) {
public function genereExtraitRegistre($tabId)
{
if (true !== $this->Droits->authorized(ListeDroit::TELECHARGER_TRAITEMENT_REGISTRE)) {
throw new ForbiddenException(__d('default', 'default.flasherrorPasDroitPage'));
}
......@@ -1134,7 +1185,8 @@ class FichesController extends AppController {
* @created 29/04/2015
* @version V1.0.0
*/
public function archive($id) {
public function archive($id)
{
if (empty($id)) {
$this->Session->setFlash(__d('default', 'default.flasherrorTraitementInexistant'), 'flasherror');
......@@ -1216,7 +1268,8 @@ class FichesController extends AppController {
$this->redirect($this->Referers->get());
}
public function export($tabId) {
public function export($tabId)
{
$ids = json_decode($tabId);
// On vérifie que $tadId n'est pas vide
......
......@@ -43,7 +43,8 @@ class OrganisationsController extends AppController {
* @created 17/06/2015
* @version V1.0.0
*/
public function index() {
public function index()
{
if (true !== ($this->Droits->authorized($this->Droits->isSu()))) {
throw new ForbiddenException(__d('default', 'default.flasherrorPasDroitPage'));
}
......@@ -68,8 +69,13 @@ class OrganisationsController extends AppController {
* @access public
* @created 17/06/2015
* @version V1.0.0
*
* @author Théo GUILLON <theo.guillon@libriciel.coop>
* @created 25/02/2019
* @version v1.0.2
*/
public function add() {
public function add()
{
if (true !== ($this->Droits->authorized($this->Droits->isSu()))) {
throw new ForbiddenException(__d('default', 'default.flasherrorPasDroitPage'));
}
......@@ -117,10 +123,11 @@ class OrganisationsController extends AppController {
} else {
$this->Organisation->rollback();
$this->Session->setFlash(__d('organisation', 'organisation.flasherrorErreurEnregistrementSEF'), 'flasherror');
$this->set('error', $recup);
}
}
$options = $this->Organisation->enums();
$this->set(compact('options'));
}
/**
......@@ -131,7 +138,8 @@ class OrganisationsController extends AppController {
* @created 17/06/2015
* @version V1.0.0
*/
public function delete($id) {
public function delete($id)
{
if (true !== ($this->Droits->authorized($this->Droits->isSu()))) {
throw new ForbiddenException(__d('default', 'default.flasherrorPasDroitPage'));
}
......@@ -159,7 +167,8 @@ class OrganisationsController extends AppController {
* @created 17/06/2015
* @version V1.0.0
*/
public function show($id) {
public function show($id)
{
if (true !== ($this->Droits->authorized($this->Droits->isSu()))) {
throw new ForbiddenException(__d('default', 'default.flasherrorPasDroitPage'));
}
......@@ -229,7 +238,8 @@ class OrganisationsController extends AppController {
* @created 17/06/2015
* @version V1.0.0
*/
public function edit($id) {
public function edit($id)
{
if (true !== ($this->Droits->authorized(ListeDroit::MODIFIER_ORGANISATION) || $this->Droits->isSu())) {
throw new ForbiddenException(__d('default', 'default.flasherrorPasDroitPage'));
}
......@@ -278,7 +288,10 @@ class OrganisationsController extends AppController {
// @info: nom original de l'organisation + id et extension pour le logo
$organisation = $this->Organisation->findById($id);
$this->set('title', __d('organisation', 'organisation.titreModifiactionEntite') . $organisation['Organisation']['raisonsociale']);
$this->set(compact('organisation'));
$options = $this->Organisation->enums();
$this->set(compact('organisation', 'options'));
$users = $this->OrganisationUser->find('all', [
'conditions' => [
......@@ -287,6 +300,7 @@ class OrganisationsController extends AppController {
'contain' => [
'User' => [
'id',
'civilite',
'nom',
'prenom',
'email'
......@@ -299,7 +313,7 @@ class OrganisationsController extends AppController {
$array_users = [];
$idUsers = [];
foreach ($users as $key => $value) {
$array_users[$value['User']['id']] = $value['User']['prenom'] . " " . $value['User']['nom'];
$array_users[$value['User']['id']] = $value['User']['civilite'] . " " . $value['User']['prenom'] . " " . $value['User']['nom'];
$idUsers[] = $value['User']['id'];
}
......@@ -328,7 +342,8 @@ class OrganisationsController extends AppController {
$this->set('array_users', $array_users);
}
private function _attributionRoleDPO($idDPO, $idOrganisation) {
private function _attributionRoleDPO($idDPO, $idOrganisation)
{
$droitsDPO = [
ListeDroit::REDIGER_TRAITEMENT,
ListeDroit::VALIDER_TRAITEMENT,
......@@ -403,7 +418,8 @@ class OrganisationsController extends AppController {
* @created 08/01/2016
* @version V1.0.0
*/
public function changenotification($id = null, $controller = null, $action = null, $idFicheNotification = 0) {
public function changenotification($id = null, $controller = null, $action = null, $idFicheNotification = 0)
{
$success = true;
$this->Notification->begin();
......@@ -459,7 +475,8 @@ class OrganisationsController extends AppController {
* @created 17/06/2015
* @version V1.0.0
*/
public function selectorganisation() {
public function selectorganisation()
{
$this->layout = 'login';
if ($this->request->is('post')) {
......@@ -514,7 +531,8 @@ class OrganisationsController extends AppController {