Commit 9b0bb550 authored by THEO GUILLON's avatar THEO GUILLON
Browse files

Merge branch '379-amelioration-initialisation-d-un-traitement' into '1.2.0'

Resolve "Amélioration initialisation d'un traitement"

See merge request libriciel/pole-citoyens/web-DPO/web-DPO!349
parents b7a28de9 87c85f5a
......@@ -757,8 +757,9 @@ class FormulairesController extends AppController
'soustraitant' => $soustraitantFields,
];
if (empty($this->request->data)) {
if ($formulaireOLD === false && $this->request->params['action'] === 'edit') {
if ($formulaireOLD === false && $this->request->params['action'] === 'edit' || $this->request->params['action'] === 'show') {
$this->request->data = $this->Formulaire->find('first', [
'conditions' => [
'id' => $formulaire_id
......
......@@ -375,4 +375,4 @@ msgid "Validate::checkNotBlankIfCountOptionsChecked"
msgstr "Champ obligatoire"
msgid "Validate::checkMultipleIf"
msgstr "Champ obligatoire"
msgstr "Champ obligatoire"
\ No newline at end of file
......@@ -663,4 +663,34 @@ msgid "fiche.champRt_dpo_fix"
msgstr "Téléphone fixe du DPO au sein de l'entité du responsable de traitement"
msgid "fiche.champRealisation_pia"
msgstr "Avez-vous réalisé l'analyse d'impact (AIPD) ?"
\ No newline at end of file
msgstr "Avez-vous réalisé l'analyse d'impact (AIPD) ?"
msgid "fiche.champRt_externe_raisonsociale"
msgstr "Raison sociale de l'entité du responsable de traitement"
msgid "fiche.champRt_externe_adresse"
msgstr "Adresse de l'entité du responsable de traitement"
msgid "fiche.champRt_externe_civiliteresponsable"
msgstr "Civilité du responsable de traitement"
msgid "fiche.champRt_externe_prenomresponsable"
msgstr "Prénom du responsable de traitement"
msgid "fiche.champRt_externe_nomresponsable"
msgstr "Nom du responsable de traitement"
msgid "fiche.champRt_externe_fonctionresponsable"
msgstr "Fonction du responsable de traitement"
msgid "fiche.champRt_externe_siret"
msgstr "N° SIRET de l'entité du responsable de traitement"
msgid "fiche.champRt_externe_ape"
msgstr "Code APE de l'entité du responsable de traitement"
msgid "fiche.champRt_externe_emailresponsable"
msgstr "E-mail du responsable de traitement"
msgid "fiche.champRessources_humaines"
msgstr "Définition de l'utilisation de l'AIPD"
\ No newline at end of file
......@@ -21,16 +21,115 @@
*/
App::uses('AppModel', 'Model');
App::uses('DatabaseDefaultFormatter', 'Database.Utility');
class WebdpoFiche extends AppModel {
public $name = 'WebdpoFiche';
public $useTable = false;
protected $_schema = [];
public $validate = [
// ------------------RT EXTERNE------------------------------------------
'rt_externe_telephone' => [
'maxLength' => [
'rule' => ['maxLength', 15],
'allowEmpty' => true
],
'phone' => [
'rule' => ['phone', null, 'fr'],
'allowEmpty' => true
]
],
'rt_externe_fax' => [
'maxLength' => [
'rule' => ['maxLength', 15],
'allowEmpty' => true
],
'phone' => [
'rule' => ['phone', null, 'fr'],
'allowEmpty' => true
]
],
'rt_externe_email' => [
[
'rule' => ['email'],
'allowEmpty' => true,
'message' => 'validation.adresseMailNonValide'
]
],
'rt_externe_siret' => [
'luhn' => [
'rule' => [
'luhn',
true
],
'allowEmpty' => true,
'message' => 'validation.numeroSIRETNonValide'
],
[
'rule' => 'numeric',
'allowEmpty' => true,
'message' => 'validation.numeroSIRETUniquementComposeChiffre'
],
],
'rt_externe_ape' => [
'minLength' => [
'rule' => ['minLength', 5],
'allowEmpty' => true
],
'maxLength' => [
'rule' => ['maxLength', 5],
'allowEmpty' => true
],
],
'rt_externe_emailresponsable' => [
'email' => [
'rule' => ['email'],
'allowEmpty' => true,
'message' => 'validation.adresseMailNonValide'
]
],
'rt_externe_telephoneresponsable' => [
'maxLength' => [
'rule' => ['maxLength', 15],
'allowEmpty' => true
],
'phone' => [
'rule' => ['phone', null, 'fr'],
'allowEmpty' => true
]
],
'rt_externe_email_dpo' => [
[
'rule' => ['email'],
'allowEmpty' => true,
'message' => 'validation.adresseMailNonValide'
]
],
'rt_externe_telephonefixe_dpo' => [
'maxLength' => [
'rule' => ['maxLength', 15],
'allowEmpty' => true
],
'phone' => [
'rule' => ['phone', null, 'fr'],
'allowEmpty' => true
]
],
'rt_externe_telephoneportable_dpo' => [
'maxLength' => [
'rule' => ['maxLength', 15],
'allowEmpty' => true
],
'phone' => [
'rule' => ['phone', null, 'fr'],
'allowEmpty' => true
]
],
// ---------------------------------------------------------------------
// ------------------REDACTEUR------------------------------------------
'declarantpersonnenom' => [
'notBlank' => [
......@@ -280,17 +379,6 @@ class WebdpoFiche extends AppModel {
]
],
// ---------------------------------------------------------------------
// 'criteres' => [
// 'checkNotBlankIfMultiple' => [
// 'rule' => ['checkMultipleIf', 'localisation_large_echelle', true, ['Non'], ['min' => 1]]
// ],
// 'checkNotBlankIf' => [
// 'rule' => ['checkNotBlankIf', 'localisation_large_echelle', true, ['Non']]
// ],
// 'checkBlankIf' => [
// 'rule' => ['checkBlankIf', 'localisation_large_echelle', true, ['Oui']]
// ]
// ],
'traitement_considere_risque' => [
'checkBlankIfCountOptionsChecked' => [
'rule' => ['checkBlankIfCountOptionsChecked', 'criteres', 0]
......@@ -316,6 +404,10 @@ class WebdpoFiche extends AppModel {
$data['Fiche']['usepia'] = $formulaireOptions['Formulaire']['usepia'];
$data['Fiche']['formulaireOLD'] = $formulaireOLD;
if ($initialisationMode === true) {
unset($this->validate['ressources_humaines']['checkNotBlankIf']);
}
// Sauvegarde BDD Fiches
$Fiche->create($data['Fiche']);
$success = false !== $Fiche->save(null, ['atomic' => false]) && $success;
......@@ -327,7 +419,7 @@ class WebdpoFiche extends AppModel {
$data = $this->cleanAndCheckDataDonneesSensibles($data, $initialisationMode);
// RT
$data = $this->cleanAndCheckDataRT($data);
$data = $this->cleanAndCheckDataRT($data, $initialisationMode);
// Co-responsable
$WebdpoCoresponsable = ClassRegistry::init('WebdpoCoresponsable');
......@@ -446,6 +538,21 @@ class WebdpoFiche extends AppModel {
}
$this->data = $originalData;
$this->validationErrors = $originalValidationErrors;
$virtualFieldsValidates = [
'rt_externe_telephone',
'rt_externe_fax',
'rt_externe_siret',
'rt_externe_telephoneresponsable',
'rt_externe_telephonefixe_dpo',
'rt_externe_telephoneportable_dpo'
];
foreach ($virtualFieldsValidates as $fieldname) {
if (isset($this->data[$this->alias][$fieldname]) === true) {
$this->data[$this->alias][$fieldname] = DatabaseDefaultFormatter::formatStripNotAlnum($this->data[$this->alias][$fieldname]);
}
}
$this->create([$this->alias => $this->data[$this->alias]]);
$success = $this->validates() && $success && empty($dynamicValidationErrors) === true;
......@@ -650,7 +757,7 @@ class WebdpoFiche extends AppModel {
return ($newDataChamps);
}
protected function cleanAndCheckDataRT($data)
protected function cleanAndCheckDataRT($data, $initialisationMode)
{
$valuesRequiredRT = [
'rt_externe_raisonsociale',
......@@ -678,17 +785,17 @@ class WebdpoFiche extends AppModel {
'rt_externe_telephoneportable_dpo',
];
if ($data['Fiche']['rt_externe'] === true) {
if ($data['Fiche']['rt_externe'] === true && $initialisationMode === false) {
foreach ($valuesRequiredRT as $valueRequiredRT) {
if (!isset($data['WebdpoFiche'][$valueRequiredRT]) || empty($data['WebdpoFiche'][$valueRequiredRT])) {
$this->validate[$valueRequiredRT]['notBlank'] = ['rule' => ['notBlank']];
}
//if (!isset($data['WebdpoFiche'][$valueRequiredRT]) || empty($data['WebdpoFiche'][$valueRequiredRT])) {
$this->validate[$valueRequiredRT] = ['notBlank' => ['rule' => ['notBlank']]] + (isset($this->validate[$valueRequiredRT]) ? $this->validate[$valueRequiredRT] : []);
//}
}
} else {
$valueRT = array_merge($valueRT, $valuesRequiredRT);
foreach ($valueRT as $value) {
if (array_key_exists($value, $data['WebdpoFiche']) === true) {
if (array_key_exists($value, $data['WebdpoFiche']) === true && $initialisationMode === false) {
unset($data['WebdpoFiche'][$value]);
}
}
......
......@@ -85,7 +85,7 @@
<!-- Fin onglet -->
<?php
if (!empty($formulaires_soustraitance)) {
if (!empty($formulaires_soustraitances)) {
?>
<!-- Onglet Information concernant le formulaire de soustraitance -->
<div id="formulaire_soustraitance" class="tab-pane">
......@@ -114,7 +114,7 @@
<tbody>
<?php
foreach ($formulaires_soustraitance as $key => $value) {
foreach ($formulaires_soustraitances as $key => $value) {
echo '<tr>
<td>' . $value['Formulaire']['libelle'] . '</td>
<td>' . $value['Formulaire']['description'] . '</td>
......
......@@ -6,6 +6,10 @@ if (in_array($this->request->params['action'], ['edit', 'show']) === true) {
$empty = false;
$keySubmit = 'Trash.';
}
if (!isset($fieldsIsRequired)){
$fieldsIsRequired = true;
}
?>
<!-- Onglet Information concernant le traitement -->
......@@ -37,7 +41,7 @@ if (in_array($this->request->params['action'], ['edit', 'show']) === true) {
$countService = count($this->Session->read('User.service'));
// Champ Service *
if ($countService >= 2) {
if ($countService >= 2 && $fieldsIsRequired === true) {
foreach ($this->Session->read('User.service') as $service) {
$listeUserService[$service] = $service;
}
......@@ -52,7 +56,7 @@ if (in_array($this->request->params['action'], ['edit', 'show']) === true) {
'required' => true,
'placeholder' => false
]);
} else if ($countService == 0) {
} else if ($countService == 0 || $fieldsIsRequired === false) {
echo $this->WebcilForm->input($keySubmit.'declarantservice', [
'id' => 'declarantservice',
'label' => [
......
<?php
echo $this->Html->script('Fiches/pia');
if (!isset($fieldsIsRequired)){
$fieldsIsRequired = true;
}
?>
<div id="info_pia" class="tab-pane <?php echo $classActivePia; ?>">
......@@ -40,7 +44,7 @@ echo $this->Html->script('Fiches/pia');
'Non' => 'Non'
],
'class' => 'transformSelect form-control '.$classDisplayInput,
'required' => true,
'required' => $fieldsIsRequired,
'empty' => true,
'placeholder' => false,
'data-placeholder' => ' ',
......@@ -90,7 +94,7 @@ echo $this->Html->script('Fiches/pia');
'Non' => 'Non'
],
'class' => 'fieldRequiredPia transformSelect form-control '.$classDisplayInput,
'required' => true,
'required' => $fieldsIsRequired,
'empty' => true,
'placeholder' => false,
'data-placeholder' => ' ',
......@@ -123,7 +127,6 @@ echo $this->Html->script('Fiches/pia');
'text' => __d('fiche', 'fiche.champCriteres')
],
'multiple' => 'checkbox',
// 'required' => true,
'class' => 'checkbox',
'options' => Fiche::LISTE_CRITERES,
'div' => "input select"
......@@ -143,7 +146,7 @@ echo $this->Html->script('Fiches/pia');
'Non' => 'Non'
],
'class' => 'transformSelect form-control displayInput',
'required' => true,
'required' => $fieldsIsRequired,
'empty' => true,
'placeholder' => false,
'data-placeholder' => ' '
......
......@@ -2,6 +2,10 @@
echo $this->Html->script([
'jquery-mask-plugin/dist/jquery.mask.min.js'
]);
if (!isset($fieldsIsRequired)){
$fieldsIsRequired = true;
}
?>
<!-- Onglet Information sur l'entité -->
......@@ -266,6 +270,7 @@ echo $this->Html->script([
$('#rt_externe_telephone').mask("00 00 00 00 00", {placeholder: "__ __ __ __ __"});
$('#rt_externe_fax').mask("00 00 00 00 00", {placeholder: "__ __ __ __ __"});
$('#rt_externe_siret').mask("000 000 000 00000", {placeholder: "___ ___ ___ _____"});
$('#rt_externe_ape').mask("AAAAA", {placeholder: "_____"});
// Responsable de l'entité
$('#rt_externe_telephoneresponsable').mask("00 00 00 00 00", {placeholder: "__ __ __ __ __"});
......
......@@ -283,7 +283,8 @@ if ($initialisationMode === true) {
if ($formulaireOLD['Formulaire']['oldformulaire'] === false) {
if ($usePIA['Formulaire']['usepia'] === true) {
echo $this->element("Fiches/tabs/pia", [
'classActivePia' => $classActivePia
'classActivePia' => $classActivePia,
'fieldsIsRequired' => $fieldsIsRequired
]);
}
}
......
......@@ -11,6 +11,9 @@ $(document).ready(function () {
$('#siret').mask('000 000 000 00000', {
placeholder: '___ ___ ___ _____'
});
$('#ape').mask("AAAAA", {
placeholder: "_____"
});
$('#telephoneresponsable').mask('00 00 00 00 00', {
placeholder: '__ __ __ __ __'
});
......
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