Commit 9a956675 authored by Antony Le Courtes's avatar Antony Le Courtes
Browse files

Column wrapping pour les blocs fiedlset / Choix des fieldsets dynamiques

parent 48cd3e13
......@@ -75,8 +75,6 @@ class IntervenantDossierAssertion extends AbstractAssertion
switch (true) {
case $entity instanceof Intervenant:
switch ($privilege) {
case self::PRIV_VIEW_IBAN:
return $this->assertViewIban($entity);
case self::PRIV_EDIT_IDENTITE:
return $this->assertEditIdentite($entity);
case self::PRIV_VIEW_IDENTITE:
......
......@@ -71,7 +71,16 @@ class IntervenantDossierController extends AbstractController
/* Récupération du dossier de l'intervenant */
$intervenantDossier = $this->getServiceDossier()->getByIntervenant($intervenant);
$intervenantDossierValidation = $this->getServiceDossier()->getValidation($intervenant);
/* Priviliege */
/* Règles pour afficher ou non les fieldsets */
$fieldsetRules = [
'fieldset-identite' => $intervenant->getStatut()->getDossierIdentite(),
'fiedlset-adresse' => $intervenant->getStatut()->getDossierAdresse(),
'fiedlset-contact' => $intervenant->getStatut()->getDossierContact(),
'fiedlset-iban' => $intervenant->getStatut()->getDossierIban(),
'fiedlset-insee' => $intervenant->getStatut()->getDossierInsee(),
'fiedlset-employeur' => $intervenant->getStatut()->getDossierEmployeur(),
];
$privileges['edit'] = $this->isAllowed(Privileges::getResourceId(Privileges::DOSSIER_EDITION));
$privileges['valider'] = $this->isAllowed($intervenant, IntervenantDossierAssertion::PRIV_CAN_VALIDE);
$privileges['devalider'] = $this->isAllowed($intervenant, IntervenantDossierAssertion::PRIV_CAN_DEVALIDE);
......@@ -110,7 +119,7 @@ class IntervenantDossierController extends AbstractController
);
}
return compact('form', 'role', 'intervenant', 'intervenantDossier', 'intervenantDossierValidation', 'privileges', 'champsAutres');
return compact('form', 'role', 'intervenant', 'intervenantDossier', 'intervenantDossierValidation', 'privileges', 'champsAutres', 'fieldsetRules');
}
......
......@@ -87,8 +87,9 @@ class StatutIntervenantController extends AbstractController
$statutIntervenant = $this->getEvent()->getParam('statutIntervenant');
$newStatutIntervenant = $statutIntervenant->dupliquer();
$newStatutIntervenant->setOrdre($this->getServiceStatutIntervenant()->fetchMaxOrdre() + 1);
$form = $this->getFormStatutIntervenantSaisie();
$title = 'Duplication d\'un statut d\'intervenant';
$form = $this->getFormStatutIntervenantSaisie();
$title = 'Duplication d\'un statut d\'intervenant';
$champsAutres = $this->getServiceDossierAutre()->getList();
$form->bindRequestSave($newStatutIntervenant, $this->getRequest(), function (StatutIntervenant $si) {
try {
......@@ -101,7 +102,7 @@ class StatutIntervenantController extends AbstractController
});
$viewModel = new ViewModel();
$viewModel->setVariables(compact('form', 'title'));
$viewModel->setVariables(compact('form', 'title', 'champsAutres'));
$viewModel->setTemplate('application/statut-intervenant/saisie');
return $viewModel;
......
......@@ -45,7 +45,6 @@
<field name="dossierInsee" type="boolean" column="DOSSIER_INSEE" nullable="false"/>
<field name="dossierIban" type="boolean" column="DOSSIER_IBAN" nullable="false"/>
<field name="dossierEmployeur" type="boolean" column="DOSSIER_EMPLOYEUR" nullable="false"/>
<field name="dossierAutre" type="boolean" column="DOSSIER_AUTRE" nullable="false"/>
<many-to-many field="champsAutres" target-entity="Application\Entity\Db\DossierAutre" fetch="EXTRA_LAZY">
<join-table name="DOSSIER_CHAMP_AUTRE_PAR_STATUT">
<join-columns>
......
......@@ -210,12 +210,7 @@ class StatutIntervenant implements HistoriqueAwareInterface, RoleInterface
*/
protected $dossierEmployeur;
/**
* @var boolean
*/
protected $dossierAutre;
/**
*
......@@ -1272,30 +1267,6 @@ class StatutIntervenant implements HistoriqueAwareInterface, RoleInterface
/**
* @return boolean
*/
public function getDossierAutre()
{
return $this->dossierAutre;
}
/**
* @param integer $dossierAutre
*
* @return StatutIntervenant
*/
public function setDossierAutre(int $dossierAutre): StatutIntervenant
{
$this->dossierAutre = $dossierAutre;
return $this;
}
/**
* Indique si ce statut correspond à un intervenant permanent.
*
......
......@@ -75,11 +75,14 @@ class IntervenantDossierForm extends AbstractForm
public function init()
{
$statutIntervenant = $this->intervenant->getStatut();
$haveContact = $statutIntervenant->getDossierContact();
$serviceAuthorize = $this->getServiceContext()->getAuthorize();
$role = $this->getServiceContext()->getUtilisateur()->getRoles();
$hydrator = new IntervenantDossierHydrator();
$this->setHydrator($hydrator);
$this->dossierIdentiteFieldset = new DossierIdentiteFieldset('DossierIdentite');
$this->dossierIdentiteFieldset->init();
......
......@@ -54,7 +54,6 @@ class StatutIntervenantSaisieForm extends AbstractForm
'dossier-insee' => "Information INSEE",
'dossier-iban' => "Information bancaire (IBAN, BIC)",
'dossier-employeur' => "Information employeur",
'dossier-autre' => "Information personnalisée (champs autres)",
];
foreach ($cases as $key => $label) {
......
......@@ -60,16 +60,24 @@ class StatutIntervenantHydrator implements HydratorInterface
$object->setMaximumHETD(FloatFromString::run($data['maximum-HETD']));
$object->setDepassementSDSHC($data['depassement-sdshc']);
$object->setChargesPatronales(FloatFromString::run($data['charges-patronales']) / 100);
$champsAutres = [];
/* Gestion des champs autres */
foreach ($data as $key => $value) {
if (strpos($key, 'champ-autre-') !== false) {
$id = str_replace('champ-autre-', '', $key);
if ($data[$key]) {
$object->addChampAutre($this->getServiceDossierAutre()->get($id));
} else {
$object->removeChampAutre($this->getServiceDossierAutre()->get($id));
$object->setDossierIdentite($data['dossier-identite']);
$object->setDossierAdresse($data['dossier-adresse']);
$object->setDossierContact($data['dossier-contact']);
$object->setDossierInsee($data['dossier-insee']);
$object->setDossierIban($data['dossier-iban']);
$object->setDossierEmployeur($data['dossier-employeur']);
if (!empty($data['id'])) {
$champsAutres = [];
/* Gestion des champs autres */
foreach ($data as $key => $value) {
if (strpos($key, 'champ-autre-') !== false) {
$id = str_replace('champ-autre-', '', $key);
if ($data[$key]) {
$object->addChampAutre($this->getServiceDossierAutre()->get($id));
} else {
$object->removeChampAutre($this->getServiceDossierAutre()->get($id));
}
}
}
}
......@@ -161,17 +169,15 @@ class StatutIntervenantHydrator implements HydratorInterface
'dossier-insee' => $object->getDossierInsee(),
'dossier-iban' => $object->getDossierIban(),
'dossier-employeur' => $object->getDossierEmployeur(),
'dossier-autre' => $object->getDossierAutre(),
];
/*Gestion des champs autres*/
$champsAutres = $object->getChampsAutres();
foreach ($champsAutres as $champ) {
$key = 'champ-autre-' . $champ->getId();
$data[$key] = 1;
if (!empty($champsAutres)) {
foreach ($champsAutres as $champ) {
$key = 'champ-autre-' . $champ->getId();
$data[$key] = 1;
}
}
$typesAgrementsStatuts = $object->getTypeAgrementStatut();
......
......@@ -16,6 +16,19 @@ $nextEtape = '';
$this->headTitle()->append("Nom intervenant XXX")->append("Données personnelles");
$fieldsets = $form->getFieldsets();
?>
<style>
.row.display-flex {
display: flex;
flex-wrap: wrap;
}
.row.display-flex > [class*='col-'] {
display: flex;
flex-direction: column;
}
</style>
<h1 class="page-header">Données personnelles
<small><?= $intervenant; ?></small>
</h1>
......@@ -51,18 +64,22 @@ $fieldsets = $form->getFieldsets();
?>
</div>
</div>
<div class="row display-flex">
<?php if ($fieldsetRules['fieldset-identite']): ?>
<?php
if ($editIdentite) {
echo $this->partial('application/intervenant-dossier/partial/formIdentite', compact('form', 'intervenant', 'intervenantDossier'));
} else {
echo $this->partial('application/intervenant-dossier/partial/formIdentiteView', compact('form', 'intervenant', 'intervenantDossier'));
}
?>
<?php endif; ?>
<h3>Identité</h3>
<div class="row">
<?php
if ($editIdentite) {
echo $this->partial('application/intervenant-dossier/partial/formIdentite', compact('form', 'intervenant', 'intervenantDossier'));
} else {
echo $this->partial('application/intervenant-dossier/partial/formIdentiteView', compact('form', 'intervenant', 'intervenantDossier'));
}
?>
</div>
<div class="row">
<?php
if ($editAdresse) {
echo $this->partial('application/intervenant-dossier/partial/formAdresse', compact('form', 'intervenant', 'intervenantDossier'));
......@@ -75,8 +92,8 @@ $fieldsets = $form->getFieldsets();
echo $this->partial('application/intervenant-dossier/partial/formContactView', compact('form', 'intervenant', 'intervenantDossier'));
}
?>
</div>
<div class="row">
<?php
if ($editInsee) {
echo $this->partial('application/intervenant-dossier/partial/formInsee', compact('form', 'intervenant', 'intervenantDossier'));
......@@ -89,13 +106,14 @@ $fieldsets = $form->getFieldsets();
echo $this->partial('application/intervenant-dossier/partial/formBancaireView', compact('form', 'intervenant', 'intervenantDossier'));
}
?>
</div>
<div class="row">
<?php
echo $this->partial('application/intervenant-dossier/partial/formEmployeur', compact('form', 'intervenant', 'intervenantDossier'));
echo $this->partial('application/intervenant-dossier/partial/formAutres', compact('form', 'intervenant', 'intervenantDossier', 'champsAutres'));
?>
</div>
<div class="row">
<div class="col-md-12">
<?php
......@@ -135,6 +153,7 @@ $fieldsets = $form->getFieldsets();
</div>
</div>
<?php
echo $this->form()->closeTag();
echo $this->feuilleDeRoute($intervenant)->renderNav($nextEtape);
......
......@@ -5,7 +5,7 @@ $form->prepare();
$dossierAdresse = $form->get('DossierAdresse');
?>
<!-- Fiedlset Adresse -->
<div class="col-md-6">
<h3>Adresse</h3>
<?= $this->formControlGroup($dossierAdresse->get('precisions')); ?>
......
......@@ -22,149 +22,131 @@ $dossierAdresse = $form->get('DossierAdresse'); /* @var $dossier \Application\Fo
}
</style>
<!-- Fiedlset Adresse -->
<div class="col-md-6">
<h3>Adresse</h3>
<div class="form-group">
<?= $this->formLabel($dossierAdresse->get('precisions')); ?>
<div class="input-group cold-md-6" style="display:block;background-color:#eee;padding:5px;">
<?php
if (!empty($intervenantDossier->getAdressePrecisions())) {
echo ($viewAdresse) ? $intervenantDossier->getAdressePrecisions() : '*******************';
} else {
echo 'NON RENSEIGNE';
}
?>
</div>
</div>
<div class="form-group">
<?= $this->formLabel($dossierAdresse->get('lieuDit')); ?>
<div class="input-group cold-md-6" style="display:block;background-color:#eee;padding:5px;">
<?php
if (!empty($intervenantDossier->getAdresseLieuDit())) {
echo ($viewAdresse) ? $intervenantDossier->getAdresseLieuDit() : '*******************';
} else {
echo 'NON RENSEIGNE';
}
?>
</div>
</div>
<div class="col-md-6">
<h3>Adresse</h3>
<div class="form-group">
<?= $this->formLabel($dossierAdresse->get('precisions')); ?>
<div class="input-group cold-md-6" style="display:block;background-color:#eee;padding:5px;">
<div class="row">
<div class="col-md-2">
<?= $this->formLabel($dossierAdresse->get('numero')); ?>
<div style="display:block;background-color:#eee;padding:5px;">
<?php
if(!empty($intervenantDossier->getAdressePrecisions()))
{
echo ($viewAdresse)?$intervenantDossier->getAdressePrecisions():'*******************';
}
else{
echo 'NON RENSEIGNE';
}
if (!empty($intervenantDossier->getAdresseNumero())) {
echo ($viewAdresse) ? $intervenantDossier->getAdresseNumero() : '***';
} else {
echo 'NR';
}
?>
</div>
</div>
<div class="form-group">
<?= $this->formLabel($dossierAdresse->get('lieuDit')); ?>
<div class="input-group cold-md-6" style="display:block;background-color:#eee;padding:5px;">
<div class="col-md-2">
<?= $this->formLabel($dossierAdresse->get('numeroComplement')); ?>
<div style="display:block;background-color:#eee;padding:5px;">
<?php
if(!empty($intervenantDossier->getAdresseLieuDit()))
{
echo ($viewAdresse)?$intervenantDossier->getAdresseLieuDit():'*******************';
}
else{
echo 'NON RENSEIGNE';
if (!empty($intervenantDossier->getAdresseNumeroCompl())) {
echo ($viewAdresse) ? $intervenantDossier->getAdresseNumeroCompl()->getLibelle() : '***';
} else {
echo 'NR';
}
?>
</div>
</div>
<div class="col-md-4">
<?= $this->formLabel($dossierAdresse->get('voirie')); ?>
<div class="row">
<div class="col-md-2">
<?= $this->formLabel($dossierAdresse->get('numero')); ?>
<div style="display:block;background-color:#eee;padding:5px;">
<?php
if(!empty($intervenantDossier->getAdresseNumero()))
{
echo ($viewAdresse)?$intervenantDossier->getAdresseNumero():'***';
}
else{
echo 'NR';
}
?>
</div>
<div style="display:block;background-color:#eee;padding:5px;">
<?php
if (!empty($intervenantDossier->getAdresseVoirie())) {
echo ($viewAdresse) ? $intervenantDossier->getAdresseVoirie()->getLibelle() : '***';
} else {
echo 'NR';
}
?>
</div>
</div>
<div class="col-md-4">
<?= $this->formLabel($dossierAdresse->get('voie')); ?>
<div class="col-md-2">
<?= $this->formLabel($dossierAdresse->get('numeroComplement')); ?>
<div style="display:block;background-color:#eee;padding:5px;">
<?php
if(!empty($intervenantDossier->getAdresseNumeroCompl()))
{
echo ($viewAdresse)?$intervenantDossier->getAdresseNumeroCompl()->getLibelle():'***';
}
else{
echo 'NR';
}
?>
</div>
</div>
<div class="col-md-4">
<?= $this->formLabel($dossierAdresse->get('voirie')); ?>
<div style="display:block;background-color:#eee;padding:5px;">
<?php
if(!empty($intervenantDossier->getAdresseVoirie()))
{
echo ($viewAdresse)?$intervenantDossier->getAdresseVoirie()->getLibelle():'***';
}
else{
echo 'NR';
}
?>
</div>
</div>
<div class="col-md-4">
<?= $this->formLabel($dossierAdresse->get('voie')); ?>
<div style="display:block;background-color:#eee;padding:5px;">
<?php
if(!empty($intervenantDossier->getAdresseVoie()))
{
echo ($viewAdresse)?$intervenantDossier->getAdresseVoie():'***';
}
else{
echo 'NR';
}
?>
</div>
<div style="display:block;background-color:#eee;padding:5px;">
<?php
if (!empty($intervenantDossier->getAdresseVoie())) {
echo ($viewAdresse) ? $intervenantDossier->getAdresseVoie() : '***';
} else {
echo 'NR';
}
?>
</div>
</div>
<div class="row">
<div class="col-md-4">
<?= $this->formLabel($dossierAdresse->get('codePostal')); ?>
<div style="display:block;background-color:#eee;padding:5px;">
<?php
if(!empty($intervenantDossier->getAdresseCodePostal()))
{
echo ($viewAdresse)?$intervenantDossier->getAdresseCodePostal():'***';
}
else{
echo 'NR';
}
?>
</div>
</div>
<div class="col-md-8">
<?= $this->formLabel($dossierAdresse->get('ville')); ?>
<div style="display:block;background-color:#eee;padding:5px;">
<?php
if(!empty($intervenantDossier->getAdresseCommune()))
{
echo ($viewAdresse)?$intervenantDossier->getAdresseCommune():'***';
}
else{
echo 'NON RENSEIGNE';
}
?>
</div>
</div>
<div class="row">
<div class="col-md-4">
<?= $this->formLabel($dossierAdresse->get('codePostal')); ?>
<div style="display:block;background-color:#eee;padding:5px;">
<?php
if (!empty($intervenantDossier->getAdresseCodePostal())) {
echo ($viewAdresse) ? $intervenantDossier->getAdresseCodePostal() : '***';
} else {
echo 'NR';
}
?>
</div>
</div>
<div class="form-group">
<?= $this->formLabel($dossierAdresse->get('pays')); ?>
<div class="input-group cold-md-6" style="display:block;background-color:#eee;padding:5px;">
<div class="col-md-8">
<?= $this->formLabel($dossierAdresse->get('ville')); ?>
<div style="display:block;background-color:#eee;padding:5px;">
<?php
if(!empty($intervenantDossier->getAdressePays()))
{
echo ($viewAdresse)?$intervenantDossier->getAdressePays()->getLibelle():'*******************';
}
else{
if (!empty($intervenantDossier->getAdresseCommune())) {
echo ($viewAdresse) ? $intervenantDossier->getAdresseCommune() : '***';
} else {
echo 'NON RENSEIGNE';
}
?>
</div>
</div>
</div>
<div class="form-group">
<?= $this->formLabel($dossierAdresse->get('pays')); ?>
<div class="input-group cold-md-6" style="display:block;background-color:#eee;padding:5px;">
<?php
if (!empty($intervenantDossier->getAdressePays())) {
echo ($viewAdresse) ? $intervenantDossier->getAdressePays()->getLibelle() : '*******************';
} else {
echo 'NON RENSEIGNE';
}
?>
</div>
</div>
</div>
......
......@@ -26,13 +26,13 @@ $dossierInsee = $form->get('DossierAutres');
}
</style>
<!-- Fiedlset Autres -->
<div class="col-md-6">
<h3>Autres</h3>
<?php foreach ($champsAutres as $champ): ?>
<?= $this->formControlGroup($dossierInsee->get('champ-autre-' . $champ->getId())); ?>
<?php endforeach; ?>
</div>
......
......@@ -15,22 +15,22 @@ $dossierBancaire = $form->get('DossierBancaire');
}
</style>