Commit 17893ab6 authored by Théo GUILLON's avatar Théo GUILLON
Browse files

Modification : de la gestion de la co-responsabilité

parent b14e81bb
......@@ -213,4 +213,32 @@ INSERT INTO typages_organisations (typage_id, organisation_id)
ALTER TABLE fichiers ADD COLUMN typage_id INTEGER DEFAULT NULL REFERENCES typages(id) ON DELETE CASCADE ON UPDATE CASCADE;
CREATE TABLE valeurcoresponsables (
id serial NOT NULL PRIMARY KEY,
fiche_id INTEGER NOT NULL REFERENCES fiches(id) ON DELETE CASCADE ON UPDATE CASCADE,
responsable_id INTEGER NOT NULL,
nomresponsable VARCHAR(50) NOT NULL,
prenomresponsable VARCHAR(50) NOT NULL,
emailresponsable VARCHAR(75) NOT NULL,
telephoneresponsable VARCHAR(15) NOT NULL,
fonctionresponsable VARCHAR(75) NOT NULL,
raisonsocialestructure VARCHAR(75) NOT NULL,
siretstructure VARCHAR(14) NOT NULL,
apestructure VARCHAR(5) NOT NULL,
telephonestructure VARCHAR(15),
faxstructure VARCHAR(15),
adressestructure TEXT,
emailstructure VARCHAR(75),
created timestamp without time zone NOT NULL,
modified timestamp without time zone NOT NULL
);
CREATE UNIQUE INDEX coresponsables_siretstructure_idx ON coresponsables (siretstructure);
ALTER TABLE coresponsables ADD CONSTRAINT coresponsables_apestructure_alpha_numeric_chk CHECK ( cakephp_validate_alpha_numeric( apestructure ) );
ALTER TABLE coresponsables ADD CONSTRAINT coresponsables_telephonestructure_phone_chk CHECK ( cakephp_validate_phone( telephonestructure, NULL, 'fr' ) );
ALTER TABLE coresponsables ADD CONSTRAINT coresponsables_faxstructure_phone_chk CHECK ( cakephp_validate_phone( faxstructure, NULL, 'fr' ) );
ALTER TABLE coresponsables ADD CONSTRAINT coresponsables_emailstructure_email_chk CHECK ( cakephp_validate_email( emailstructure ) );
ALTER TABLE coresponsables ADD CONSTRAINT coresponsables_telephoneresponsable_phone_chk CHECK ( cakephp_validate_phone( telephoneresponsable, NULL, 'fr' ) );
ALTER TABLE coresponsables ADD CONSTRAINT coresponsables_emailresponsable_email_chk CHECK ( cakephp_validate_email( emailresponsable ) );
COMMIT;
......@@ -37,6 +37,7 @@ class FichesController extends AppController
public $uses = [
'Champ',
'Coresponsable',
'Responsable',
'ResponsableOrganisation',
'EtatFiche',
......@@ -408,7 +409,10 @@ class FichesController extends AppController
$typages = $this->_typages();
$this->set(compact('formulaire_id', 'formulaireOLD', 'typages'));
// On récupère les responsable
$responsables = $this->_responsables();
$this->set(compact('formulaire_id', 'formulaireOLD', 'typages', 'responsables'));
}
/**
......
<?php
/**
* Model Coresponsable
*
* web-DPO : Outil de gestion de vos traitements dans le cadre de la
* réglementation relative à la protection des données personnelles (RGPD)
*
* Copyright (c) Libriciel SCOP (https://www.libriciel.fr/)
*
* Licensed under The CeCiLL V2 License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Libriciel SCOP (https://www.libriciel.fr/)
* @link https://www.libriciel.fr/web-cil/
* @since web-DPO
* @license http://www.cecill.info/licences/Licence_CeCILL_V2-fr.html CeCiLL V2 License
* @version v1.2.0
* @package AppModel
*/
App::uses('AppModel', 'Model');
class Coresponsable extends AppModel {
public $name = 'Coresponsable';
public $validationDomain = 'validation';
public $actsAs = [
'Database.DatabaseFormattable' => [
'Database.DatabaseDefaultFormatter' => [
'formatTrim' => [
'NOT' => ['binary']
],
'formatNull' => true,
'formatNumeric' => [
'float',
'integer'
],
'formatSuffix' => '/_id$/',
'formatStripNotAlnum' => '/^(telephoneresponsable|telephonestructure|faxstructure|siretstructure)$/'
]
],
'LettercaseFormattable' => [
'upper_noaccents' => ['nomresponsable'],
'title' => ['prenomresponsable']
]
];
/**
* validate associations
*
* @var array
*
* @access public
* @created 12/04/2018
* @version v1.0.0
*/
public $validate = [
'siretstructure' => [
'luhn' => [
'rule' => [
'luhn',
true
],
'message' => 'validation.numeroSIRETNonValide'
],
[
'rule' => 'numeric',
'message' => 'validation.numeroSIRETUniquementComposeChiffre'
],
],
'emailresponsable' => [
[
'rule' => ['custom', REGEXP_EMAIL_FR],
'message' => 'validation.adresseMailNonValide'
]
],
];
/**
* hasMany associations
*
* @var array
*
* @access public
* @created 11/04/2018
* @version v1.0.0
*/
public $hasAndBelongsToMany = [
'Organisation' => [
'className' => 'Organisation',
'joinTable' => 'responsables_organisations',
'foreignKey' => 'responsable_id',
'associationForeignKey' => 'organisation_id',
'unique' => true,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'finderQuery' => '',
'with' => 'ResponsableOrganisation'
]
];
}
<!-- Onglet Co-responsable -->
<div id="ongletComplementaireCoresponsable" class="tab-pane">
<br>
<?php
if (!empty($responsables)) {
?>
<!-- Information sur le rédacteur -->
<div class="col-md-12">
<span class='labelFormulaire'>
<?php
echo __d('fiche', 'fiche.textInfoConcernantCoresponsable');
?>
</span>
<div class="row row35"></div>
</div>
<!-- Champs du formulaire -->
<div class="row">
<div class="col-md-6">
<?php
echo $this->WebcilForm->input('coresponsables', [
'id' => 'coresponsables',
'label' => [
'text' => __d('fiche', 'fiche.champCoresponsableid')
],
'class' => 'form-control',
'options' => Hash::combine($responsables, '{n}.Responsable.id', '{n}.Responsable.raisonsocialestructure'),
'empty' => true,
'multiple' => true,
'required' => true,
'data-placeholder' => __d('fiche', 'fiche.placeholderChampCoresponsable')
]);
?>
</div>
</div>
<div id="coresponsableCards"></div>
<?php
}
?>
</div>
<!-- Fin onglet Co-responsable -->
<script type="text/javascript">
$(document).ready(function () {
let eventSelect = $("#coresponsables");
$(eventSelect).select2({
width: '100%',
});
let infoCoresponsables = <?php echo json_encode(Hash::combine($responsables, '{n}.Responsable.id', '{n}.Responsable'))?>;
$(eventSelect).on("select2:select", function (e) {
let idSelect = e.params.data.id;
let coresponsable = infoCoresponsables[idSelect];
let colLeft = '';
<?php
if (isset($fields['coresponsable'])) {
$fields = $this->element('Fiches/tabs/formulaire', [
'champs' => $fields['coresponsable']
]);
}
?>
let fields = <?php echo json_encode($fields);?>;
let formCoreponsableFields = '';
if (fields) {
// formCoreponsableFields = '<div id="form-container-coresponsable" class="form-container col-md-12">';
// formCoreponsableFields = formCoreponsableFields + fields;
// formCoreponsableFields = formCoreponsableFields + '</div>';
formCoreponsableFields = '<div id="form-container-coresponsable">';
formCoreponsableFields = formCoreponsableFields + fields;
formCoreponsableFields = formCoreponsableFields + '</div>';
}
if (coresponsable['adressestructure'] != null) {
colLeft = colLeft + '<p>' +
'<u>Adresse :</u>' +
coresponsable['adressestructure'] +
'</p>';
}
if (coresponsable['telephonestructure'] != null) {
colLeft = colLeft + '<p>' +
'<u>Téléphone :</u>' +
coresponsable['telephonestructure'] +
'</p>';
}
if (coresponsable['faxstructure'] != null) {
colLeft = colLeft + '<p>' +
'<u>Fax :</u>' +
coresponsable['faxstructure'] +
'</p>';
}
if (coresponsable['emailstructure'] != null) {
colLeft = colLeft + '<p>' +
'<u>E-mail :</u>' +
coresponsable['emailstructure'] +
'</p>';
}
let nomComplet = coresponsable['prenomresponsable'] + ' ' + coresponsable['nomresponsable'];
$('#coresponsableCards').append(' <div id="card_'+idSelect+'" class="row">' +
'<div class="col-md-12">' +
' <div class="panel panel-default ">' +
' <div class="panel-body">' +
' <div class="col-md-6">' +
' <h4>' + coresponsable['raisonsocialestructure'] + '</h4>' +
' <p>' +
' <u>N° SIRET :</u>' +
coresponsable['siretstructure'] +
' </p>' +
' <p>' +
' <u>Code APE :</u>' +
coresponsable['apestructure'] +
' </p>' +
colLeft +
' </div>' +
' <div class="col-md-6">' +
' <h4>' + nomComplet + '</h4>' +
' <p>' +
' <u>Fonction :</u>' +
coresponsable['fonctionresponsable'] +
' </p>' +
' <p>' +
' <u>Téléphone :</u>' +
coresponsable['telephoneresponsable'] +
' </p>' +
' <p>' +
' <u>E-mail :</u>' +
coresponsable['emailresponsable'] +
' </p>' +
' </div>' +
formCoreponsableFields +
' </div>' +
' </div>' +
'</div>' +
'</div>');
});
$(eventSelect).on("select2:unselect", function (e) {
let idRemove = '#card_' + e.params.data.id;
$('#coresponsableCards').find(idRemove).remove();
});
});
</script>
\ No newline at end of file
......@@ -7,6 +7,188 @@
?>
</div>
<?php
echo $this->WebcilForm->create('informationCoresponsable', [
'autocomplete' => 'off',
'inputDefaults' => ['div' => false],
'class' => 'form-horizontal',
'novalidate' => 'novalidate'
]);
?>
<br/>
<!-- Information sur le rédacteur -->
<div class="col-md-12">
<span class='labelFormulaire'>
<?php
echo __d('fiche', 'fiche.textInfoConcernantCoresponsable');
?>
</span>
<div class="row row35"></div>
</div>
<!-- Champs du formulaire -->
<div class="row">
<div class="col-md-6">
<?php
echo $this->WebcilForm->input('Fiche.coresponsableid', [
'empty' => true,
'required' => true,
'readonly' => true,
'placeholder' => __d('fiche', 'fiche.placeholderChampCoresponsable')
]);
?>
</div>
</div>
<div class="col-md-12">
<span class='labelFormulaire'>
<?php
echo __d('responsable', 'responsable.titreResponsable');
?>
</span>
<div class="row row35"></div>
</div>
<div class="row">
<!-- Colonne de gauche -->
<div class="col-md-6">
<?php
echo $this->WebcilForm->inputs([
'Fiche.nomcoresponsable' => [
'id' => 'nomcoresponsable',
'required' => true,
'readonly' => true,
'value' => __d('default', 'default.valueChampRemplissageAuto')
],
'Fiche.prenomcoresponsable' => [
'id' => 'prenomcoresponsable',
'required' => true,
'readonly' => true,
'value' => __d('default', 'default.valueChampRemplissageAuto')
],
'Fiche.fonctioncoresponsable' => [
'id' => 'fonctioncoresponsable',
'required' => true,
'readonly' => true,
'value' => __d('default', 'default.valueChampRemplissageAuto')
]
]);
?>
</div>
<!-- Colonne de droite -->
<div class="col-md-6">
<?php
echo $this->WebcilForm->inputs([
'Fiche.emailcoresponsable' => [
'id' => 'emailcoresponsable',
'required' => true,
'readonly' => true,
'value' => __d('default', 'default.valueChampRemplissageAuto')
],
'Fiche.telephonecoresponsable' => [
'id' => 'telephonecoresponsable',
'required' => true,
'readonly' => true,
'value' => __d('default', 'default.valueChampRemplissageAuto')
]
]);
?>
</div>
</div>
<div class="col-md-12">
<span class='labelFormulaire'>
<?php
echo __d('responsable', 'responsable.titreStructureResponsable');
?>
</span>
<div class="row row35"></div>
</div>
<div class="row">
<!-- Colonne de gauche -->
<div class="col-md-6">
<?php
echo $this->WebcilForm->inputs([
'Fiche.raisonsocialestructure' => [
'id' => 'raisonsocialestructure',
'required' => true,
'readonly' => true,
'value' => __d('default', 'default.valueChampRemplissageAuto')
],
'Fiche.siretstructure' => [
'id' => 'siretstructure',
'required' => true,
'readonly' => true,
'value' => __d('default', 'default.valueChampRemplissageAuto')
],
'Fiche.apestructure' => [
'id' => 'apestructure',
'required' => true,
'readonly' => true,
'value' => __d('default', 'default.valueChampRemplissageAuto')
]
]);
?>
</div>
<!-- Colonne de droite -->
<div class="col-md-6">
<?php
echo $this->WebcilForm->inputs([
'Fiche.telephonestructure' => [
'id' => 'telephonestructure',
'readonly' => true,
'value' => __d('default', 'default.valueChampRemplissageAuto')
],
'Fiche.faxstructure' => [
'id' => 'faxstructure',
'readonly' => true,
'value' => __d('default', 'default.valueChampRemplissageAuto')
],
'Fiche.adressestructure' => [
'id' => 'adressestructure',
'type' => 'textarea',
'readonly' => true,
'value' => __d('default', 'default.valueChampRemplissageAuto')
],
'Fiche.emailstructure' => [
'id' => 'email',
'readonly' => true,
'value' => __d('default', 'default.valueChampRemplissageAuto')
]
]);
?>
</div>
</div>
<?php
echo $this->WebcilForm->end();
?>
<?php
echo $this->element(
'Formulaires/boutonsCreationChamp',
......
......@@ -125,19 +125,17 @@ if ($this->request->params['action'] === 'add' && $usePIA['Formulaire']['usepia'
</li>
<?php
} else {
if (!empty($fields['coresponsable'])) {
?>
<li id="information_coresponsable" class="disabled">
<a id="aOngletComplementaireCoresponsable" href="#ongletComplementaireCoresponsable" role=""
data-toggle="">
<i class="fa fa-pencil fa-fw"></i>
<?php
echo __d('fiche', 'fiche.ongletCoresponsable');
?>
</a>
</li>
<?php
}
?>
<li id="information_coresponsable" class="disabled">
<a id="aOngletComplementaireCoresponsable" href="#ongletComplementaireCoresponsable" role=""
data-toggle="">
<i class="fa fa-pencil fa-fw"></i>
<?php
echo __d('fiche', 'fiche.ongletCoresponsable');
?>
</a>
</li>
<?php
}
if ($formulaireOLD['Formulaire']['oldformulaire'] === true && $formulaireOLD['Formulaire']['soustraitant'] === true) {
......@@ -220,22 +218,11 @@ if ($this->request->params['action'] === 'add' && $usePIA['Formulaire']['usepia'
if ($formulaireOLD['Formulaire']['oldformulaire'] === true && isset($responsables) && !empty($responsables)) {
echo $this->element('Fiches/oldTabs/ongletCoresponsable');
} else {
if (!empty($fields['coresponsable'])) {
?>
<!-- Onglet Co-responsable -->
<div id="ongletComplementaireCoresponsable" class="tab-pane">
<br>
<div id="form-container-coresponsable" class="form-container col-md-12">
<?php
echo $this->element('Fiches/tabs/formulaire', [
'champs' => $fields['coresponsable']
]);
?>
</div>
</div>
<!-- Fin onglet Co-responsable -->
<?php
}
// Onglet Co-responsable
echo $this->element('Fiches/tabs/coresponsable', [
// 'champs' => $fields['coresponsable']
]);
// Fin onglet Co-responsable
}
// OLD sous-traitance
......
......@@ -704,6 +704,7 @@ let createForm = function(typeCreateForm) {
$('.multiSelect').select2({
placeholder: 'Sélectionnez une ou plusieurs options',
width: '100%',
allowClear: true
});
......
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