Commit 80acfce4 authored by tguillon's avatar tguillon
Browse files

Ajout: information complementaire

parent 7f1e0617
......@@ -27,9 +27,10 @@ class FormulairesController extends AppController {
//ATTENTION VOIR app/Plugin/FormGenerator/Model/Formulaire.php
public $uses = [
'FormGenerator.Formulaire',
'FormGenerator.Champ',
'FormGeneric',
// 'FormGenerator.Formulaire',
// 'FormGenerator.Champ',
// 'FormGeneric',
'Formulaire',
'Fiche',
'Organisation'
];
......@@ -787,4 +788,120 @@ class FormulairesController extends AppController {
}
}
public function new()
{
if (true !== $this->Droits->authorized([ListeDroit::GESTION_FORMULAIRE])) {
throw new ForbiddenException(__d('default', 'default.flasherrorPasDroitPage'));
}
$this->set('title', 'Ajout new formulaire');
if ($this->request->is('POST')) {
$success = true;
$this->Formulaire->begin();
$data = $this->request->data;
$data['soustraitant'] = false;
$this->Formulaire->create($data);
$success = false !== $this->Formulaire->save() && $success;
$id = $this->Formulaire->getLastInsertId();
if ($id == null) {
$success = false;
}
if ($success == true) {
$array = json_decode($data['Formulaire']['json'], true);
foreach ($array as $value) {
$sortie = array();
foreach ($value as $clef => $valeur) {
switch ($clef) {
case 'onglet':
$ongletChampCoresponsable = false;
$ongletChampSoustraitant = false;
if ($valeur === 'form-container-coresponsable') {
$ongletChampCoresponsable = true;
}
if ($valeur === 'form-container-soustraitant') {
$ongletChampSoustraitant = true;
}
break;
case 'type':
$type = $valeur;
break;
case 'ligne':
$ligne = (int)round($valeur, 0);
break;
case 'colonne':
$colonne = (int)round($valeur, 0);
break;
case 'name':
$sortie[$clef] = LettercaseFormattableBehavior::formatageVariable($valeur);
break;
case 'options':
$options = [];
foreach ($valeur as $key => $option) {
$options[$key] = trim($option);
}
$sortie[$clef] = $options;
break;
case 'default':
if (!is_array($valeur)) {
$sortie[$clef] = trim($valeur);
} else {
$options = [];
foreach ($valeur as $key => $option) {
$options[$key] = trim($option);
}
$sortie[$clef] = $options;
}
break;
default:
$sortie[$clef] = $valeur;
break;
}
}
$this->Champ->create([
'formulaires_id' => $id,
'type' => $type,
'ligne' => $ligne,
'colonne' => $colonne,
'details' => json_encode($sortie),
'champ_coresponsable' => $ongletChampCoresponsable,
'champ_soustraitant' => $ongletChampSoustraitant,
]);
$success = false !== $this->Champ->save() && $success;
}
}
if ($success == true) {
$this->Formulaire->commit();
$this->Session->setFlash(__d('formulaire', 'formulaire.flashsuccessFormulaireEnregistrer'), 'flashsuccess');
$this->redirect([
'controller' => 'formulaires',
'action' => 'index'
]);
} else {
$this->Formulaire->rollback();
$this->Session->setFlash(__d('default', 'default.flasherrorEnregistrementErreur'), 'flasherror');
}
}
}
}
......@@ -365,6 +365,9 @@ msgstr "Sous-traitance sur le traitement :"
msgid "fiche.textInfoSousTraitanceComplementaire"
msgstr "Information complémentaire concernant la sous-traitance(s) :"
msgid "fiche.champSoustraitance"
msgstr "Sous-traitance ?"
###############################################################################
......
......@@ -28,6 +28,43 @@ class Formulaire extends AppModel {
public $displayField = 'libelle';
/**
* validate associations
*
* @var array
*
* @access public
* @created 24/02/2020
* @version V1.2.0
*/
public $validate = [
'useSousFinalite' => [
'notBlank' => [
'rule' => ['notBlank']
]
],
'useBaseLegale' => [
'notBlank' => [
'rule' => ['notBlank']
]
],
'useDecisionAutomatisee' => [
'notBlank' => [
'rule' => ['notBlank']
]
],
'useTransfertHorsUe' => [
'notBlank' => [
'rule' => ['notBlank']
]
],
'useDonneesSensible' => [
'notBlank' => [
'rule' => ['notBlank']
]
],
];
/**
* hasOne associations
*
......
<?php
echo $this->Html->script('scroll');
$typeCreateForm = isset($typeCreateForm) === true ? $typeCreateForm : '';
?>
<div class="col-md-12" id="forScroll" style="padding: 0;">
<div class="btn-group-<?php echo $typeCreateForm;?>" role="group">
<!-- Bouton Petit champ texte -->
<button type="button" class="btn btn-default-default btn-sm btn-input-<?php echo $typeCreateForm;?>" id="btn-small-text-<?php echo $typeCreateForm;?>"">
<i class="fa fa-font fa-lg fa-fw"></i>
<?php echo __d ('formulaire','formulaire.btnPetitChamp');?>
</button>
<!-- Bouton Grand champ texte -->
<button type="button" class="btn btn-default-default btn-sm btn-input-<?php echo $typeCreateForm;?>" id="btn-long-text-<?php echo $typeCreateForm;?>"">
<i class="fa fa-text-height fa-lg fa-fw"></i>
<?php echo __d ('formulaire','formulaire.btnGrandChamp');?>
</button>
<!-- Bouton Champ date -->
<button type="button" class="btn btn-default-default btn-sm btn-input-<?php echo $typeCreateForm;?>" id="btn-date-<?php echo $typeCreateForm;?>"">
<i class="fa fa-calendar fa-lg fa-fw"></i>
<?php echo __d ('formulaire','formulaire.btnChampDate');?>
</button>
<!-- Bouton Cases à cocher -->
<button type="button" class="btn btn-default-default btn-sm btn-input-<?php echo $typeCreateForm;?>" id="btn-checkbox-<?php echo $typeCreateForm;?>"">
<i class="fa fa-check-square-o fa-lg fa-fw"></i>
<?php echo __d ('formulaire','formulaire.btnCheckbox');?>
</button>
<!-- Bouton Choix unique -->
<button type="button" class="btn btn-default-default btn-sm btn-input-<?php echo $typeCreateForm;?>" id="btn-radio-<?php echo $typeCreateForm;?>"">
<i class="fa fa-dot-circle-o fa-lg fa-fw"></i>
<?php echo __d ('formulaire','formulaire.btnRadio');?>
</button>
<!-- Bouton Menu deroulant -->
<button type="button" class="btn btn-default-default btn-sm btn-input-<?php echo $typeCreateForm;?>" id="btn-deroulant-<?php echo $typeCreateForm;?>"">
<i class="fa fa-list-alt fa-lg fa-fw"></i>
<?php echo __d ('formulaire','formulaire.btnDeroulant');?>
</button>
<!-- Bouton Menu multi-select-->
<button type="button" class="btn btn-default-default btn-sm btn-input-<?php echo $typeCreateForm;?>" id="btn-multi-select-<?php echo $typeCreateForm;?>"">
<i class="fa fa-list-alt fa-lg fa-fw"></i>
<?php echo __d ('formulaire','formulaire.btnMultiSelect');?>
</button>
<!-- Bouton Titre de catégorie -->
<button type="button" class="btn btn-default-default btn-sm btn-input-<?php echo $typeCreateForm;?>" id="btn-title-<?php echo $typeCreateForm;?>"">
<i class="fa fa-tag fa-lg fa-fw"></i>
<?php echo __d ('formulaire','formulaire.btnTitreCategorie');?>
</button>
<!-- Bouton Champ d'information -->
<button type="button" type="button" class="btn btn-default-default btn-sm btn-input-<?php echo $typeCreateForm;?>" id="btn-help-<?php echo $typeCreateForm;?>"">
<i class="fa fa-info-circle fa-lg fa-fw"></i>
<?php echo __d ('formulaire','formulaire.btnChampInfo');?>
</button>
<!-- Bouton Label -->
<button type="button" class="btn btn-default-default btn-sm btn-input-<?php echo $typeCreateForm;?>" id="btn-texte-<?php echo $typeCreateForm;?>"">
<i class="fa fa-pencil fa-lg fa-fw"></i>
<?php echo __d ('formulaire','formulaire.btnLabel');?>
</button>
</div>
<div class="col-md-12" style="padding: 0;">
<div class="panel panel-default panel-affix">
<div class="panel-heading">
<h3 class="panel-title">
<?php
echo __d('formulaire','formulaire.textOptionChamp');
?>
</h3>
</div>
<div class="panel-body field-options" id="field-options-<?php echo $typeCreateForm;?>"></div>
</div>
</div>
</div>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
\ No newline at end of file
<div id="ongletComplementaireCoresponsable" class="tab-pane">
<br/>
<div class="alert alert-danger" role="alert">
<?php
echo "Cette onget sera actif uniquement lorsque le déclaration du traitement aura indiqué 'Oui' sur le champ 'Co-responsable ?' dans l'onget 'Information générale'";
?>
</div>
<?php
echo $this->element(
'new/boutonsCreationChamp',
[
'typeCreateForm' => 'coresponsable'
]
);
?>
<!-- Corps du formulaire -->
<div id="form-container-coresponsable" class="form-container col-md-12"></div>
</div>
<script type="text/javascript">
$(document).ready(function () {
createForm('coresponsable');
});
</script>
\ No newline at end of file
<div id="ongletComplementaireSousTraitant" class="tab-pane">
<br/>
<div class="alert alert-danger" role="alert">
<?php
echo "Cette onget sera actif uniquement lorsque le déclaration du traitement aura indiqué 'Oui' sur le champ 'Sous-traitance ?' dans l'onget 'Information générale'";
?>
</div>
<?php
echo $this->element(
'new/boutonsCreationChamp',
[
'typeCreateForm' => 'soustraitant'
]
);
?>
<!-- Corps du formulaire -->
<div id="form-container-soustraitant" class="form-container col-md-12"></div>
</div>
<script type="text/javascript">
$(document).ready(function () {
createForm('soustraitant');
});
</script>
\ No newline at end of file
<!-- Onglet Formulaire -->
<div id="info_formulaire" class="tab-pane">
<br/>
<div class="alert alert-warning" role="alert">
<?php echo __d('fiche', 'fiche.textInfoChampsCommuns'); ?>
</div>
<?php
echo $this->element(
'new/boutonsCreationChamp',
[
'typeCreateForm' => 'formulaire'
]
);
?>
<!-- Corps du formulaire -->
<div id="form-container-formulaire" class="form-container col-md-12"></div>
<?php
// echo $this->WebcilForm->hidden('json', ['id' => 'hiddenForm']);
?>
</div>
<!-- Fin onglet Formulaire -->
<script type="text/javascript">
$(document).ready(function () {
createForm('formulaire');
});
</script>
\ No newline at end of file
<!-- Onglet Information complémentaire -->
<div id="info_complementaire" class="tab-pane active">
<br>
<!-- Information concernant la sous-finalité -->
<div class="col-md-12">
<span class='labelFormulaire'>
<?php
echo __d('fiche', 'fiche.textInfoTraitementComplementaire');
?>
</span>
<div class="row row35"></div>
</div>
<div class="row">
<!-- Colonne de gauche -->
<div class="col-md-8">
<?php
echo $this->WebcilForm->input('useSousFinalite', [
'id' => 'useSousFinalite',
'options' => [
true => 'Oui',
false => 'Non'
],
'default' => true,
'class' => 'transformSelect form-control',
'placeholder' => false,
'required' => true,
'data-placeholder' => ' '
]);
?>
</div>
<div class="col-md-4"></div>
</div>
<hr>
<div class="row">
<!-- Colonne de gauche -->
<div class="col-md-8">
<?php
echo $this->WebcilForm->input('useBaseLegale', [
'id' => 'useBaseLegale',
'options' => [
true => 'Oui',
false => 'Non'
],
'class' => 'transformSelect form-control',
'empty' => true,
'placeholder' => false,
'required' => true,
'data-placeholder' => ' '
]);
?>
</div>
<div class="col-md-4"></div>
</div>
<div class="row">
<div class="col-md-12" style="background-color: #f5f3f3;">
<!-- Colonne de gauche -->
<div class="col-md-6">
<?php
echo $this->WebcilForm->input('Fiche.baselegale', [
'multiple' => 'checkbox',
'class' => 'checkbox',
'options' => Fiche::LISTE_BASE_LEGALE,
'div' => "input select"
]);
?>
</div>
</div>
<div class="col-md-6"></div>
</div>
<hr>
<div class="row">
<!-- Colonne de gauche -->
<div class="col-md-8">
<?php
echo $this->WebcilForm->input('useDecisionAutomatisee', [
'id' => 'useDecisionAutomatisee',
'options' => [
true => 'Oui',
false => 'Non'
],
'class' => 'transformSelect form-control',
'placeholder' => false,
'empty' => true,
'required' => true,
'data-placeholder' => ' '
]);
?>
</div>
<div class="col-md-4"></div>
</div>
<br>
<div class="row">
<div class="col-md-12" style="background-color: #f5f3f3;">
<!-- Colonne de gauche -->
<div class="col-md-6">
<?php
echo $this->WebcilForm->input('Fiche.decisionAutomatisee', [
'options' => [
'Oui' => 'Oui',
'Non' => 'Non'
],
'class' => 'transformSelect form-control',
'empty' => true,
'placeholder' => false,
'data-placeholder' => ' '
]);
?>
</div>
<!-- Colonne de droite -->
<div class="col-md-6">
<?php
echo $this->WebcilForm->input('Fiche.descriptionDecisionAutomatisee', [
'type' => 'textarea',
'required' => true,
'placeholder' => false
]);
?>
</div>
</div>
</div>
<hr>
<div class="row">
<!-- Colonne de gauche -->
<div class="col-md-8">
<?php
echo $this->WebcilForm->input('useTransfertHorsUe', [
'id' => 'useTransfertHorsUe',
'options' => [
true => 'Oui',
false => 'Non'
],
'class' => 'transformSelect form-control',
'placeholder' => false,
'empty' => true,
'required' => true,
'data-placeholder' => ' '
]);
?>
</div>
<div class="col-md-4"></div>
</div>
<div class="alert alert-warning" role="alert">
<?php echo "Les champs ci-dessous concernant les données sensibles sera visible par le déclarant du traitement uniquement lorsque celui-ci aura indiqué 'Oui' sur le champ 'Transfert hors UE' dans l'onget 'Information générale' "; ?>
</div>
<div class="row">
<!-- Information concernant le transfert hors UE -->
<div class="col-md-12" style="background-color: #f5f3f3;">
<div class="col-md-12">
<span class='labelFormulaire'>
<?php
echo __d('fiche', 'fiche.textInfoTransfereHorsUEComplementaire');
?>
</span>
<div class="row row35"></div>
</div>
<div class="col-md-6">
<?php
echo $this->WebcilForm->inputs([
'Fiche.typeDonneeSensible' => [
'options' => Fiche::LISTE_DONNEES_SENSIBLES,
'class' => 'transformSelect form-control',
'placeholder' => false,
'empty' => true,
'required' => true,
'data-placeholder' => ' '
],
'Fiche.dureeConservation' => [
'type' => 'textarea',
'required' => true,
'placeholder' => false
]
]);
?>
</div>
<div class="col-md-6">
<?php
echo $this->WebcilForm->input('Fiche.descriptionDonneSensible', [
'type' => 'textarea',
'required' => true,
'placeholder' => false
]);
?>
</div>
<!-- <div id="AddOrganismeHorsUE">-->
<!-- <a id="AddOrganismeHorsUEFileBox" class="btn btn-info">Ajouter un organisme hors de l'UE</a>-->
<!-- <br><br>-->
<!-- </div>-->
</div>
</div>
<hr>
<div class="row">
<!-- Colonne de gauche -->
<div class="col-md-8">
<?php
echo $this->WebcilForm->input('useDonneesSensible', [
'id' => 'useDonneesSensible',
'options' => [
true => 'Oui',
false => 'Non'
],
'class' => 'transformSelect form-control',
'placeholder' => false,
'empty' => true,
'required' => true,
'data-placeholder' => ' '
]);