Commit 4cca2c2e authored by Laurent Lécluse's avatar Laurent Lécluse
Browse files

Possibilité de saisir des RIB hors SEPA dans le dossier de l'intervenant

parent 4ecd8b2f
......@@ -69,6 +69,11 @@ class Dossier implements HistoriqueAwareInterface
*/
protected $rib;
/**
* @var bool
*/
protected $ribHorsSepa = false;
/**
* @var StatutIntervenant
*/
......@@ -429,6 +434,30 @@ class Dossier implements HistoriqueAwareInterface
/**
* @return bool
*/
public function isRibHorsSepa(): bool
{
return $this->ribHorsSepa;
}
/**
* @param bool $ribHorsSepa
*
* @return Dossier
*/
public function setRibHorsSepa(bool $ribHorsSepa): Dossier
{
$this->ribHorsSepa = $ribHorsSepa;
return $this;
}
/**
* Set statut
*
......
......@@ -173,6 +173,11 @@ class Intervenant implements HistoriqueAwareInterface, ResourceInterface, AnneeA
*/
protected $IBAN;
/**
* @var bool
*/
protected $ribHorsSepa = false;
/**
* @var \Doctrine\Common\Collections\Collection
*/
......@@ -1017,6 +1022,30 @@ class Intervenant implements HistoriqueAwareInterface, ResourceInterface, AnneeA
/**
* @return bool
*/
public function isRibHorsSepa(): bool
{
return $this->ribHorsSepa;
}
/**
* @param bool $ribHorsSepa
*
* @return Intervenant
*/
public function setRibHorsSepa(bool $ribHorsSepa): Intervenant
{
$this->ribHorsSepa = $ribHorsSepa;
return $this;
}
/**
* Set structure
*
......
......@@ -17,6 +17,7 @@
<field name="numeroInseeEstProvisoire" type="boolean" column="NUMERO_INSEE_EST_PROVISOIRE" nullable="false"/>
<field name="prenom" type="string" column="PRENOM" length="128" nullable="false"/>
<field name="rib" type="string" column="RIB" length="50" nullable="false"/>
<field name="ribHorsSepa" type="boolean" column="RIB_HORS_SEPA"/>
<field name="dateNaissance" type="datetime" column="DATE_NAISSANCE" nullable="true"/>
<field name="villeNaissance" type="string" column="VILLE_NAISSANCE" length="128" nullable="true"/>
<field name="premierRecrutement" type="boolean" column="PREMIER_RECRUTEMENT" nullable="false"/>
......
......@@ -40,6 +40,7 @@
<field name="villeNaissanceLibelle" type="string" column="VILLE_NAISSANCE_LIBELLE" length="26" nullable="true"/>
<field name="BIC" type="string" column="BIC" length="255" nullable="true"/>
<field name="IBAN" type="string" column="IBAN" length="255" nullable="true"/>
<field name="ribHorsSepa" type="boolean" column="RIB_HORS_SEPA"/>
<field name="premierRecrutement" type="boolean" column="PREMIER_RECRUTEMENT" nullable="true"/>
<field name="montantIndemniteFc" type="float" column="MONTANT_INDEMNITE_FC" nullable="true" />
......
......@@ -153,8 +153,9 @@ class Dossier extends AbstractForm
'emailPerso' => 'readonly',
'telephone' => 'readonly',
'premierRecrutement' => 'disabled',
'rib/bic' => 'readonly',
'rib/iban' => 'readonly',
'ribBic' => 'readonly',
'ribIban' => 'readonly',
'ribHorsSepa' => 'readonly',
];
foreach( $roElements as $roe => $attr ){
......
......@@ -14,6 +14,7 @@ use Application\Validator\DepartementNaissanceValidator;
use Application\Validator\NumeroINSEEValidator;
use Application\Validator\PaysNaissanceValidator;
use Application\Constants;
use Application\Validator\RIBValidator;
use DoctrineModule\Form\Element\Proxy;
use DoctrineORMModule\Form\Element\EntitySelect;
use Zend\Validator\Date as DateValidator;
......@@ -21,7 +22,6 @@ use Zend\Validator\Date as DateValidator;
/**
* Description of DossierFieldset
*
* @author Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr>
*/
class DossierFieldset extends AbstractFieldset
{
......@@ -268,17 +268,37 @@ class DossierFieldset extends AbstractFieldset
'type' => 'Text',
]);
/**
* RIB
*/
$this->add([
'name' => 'ribBic',
'options' => [
'label' => 'BIC',
],
'attributes' => [
'size' => 11,
'maxlength' => 11,
],
'type' => 'Text',
]);
$this->add([
'name' => 'rib',
'name' => 'ribIban',
'options' => [
'label' => 'RIB du <em>compte personnel</em>',
'label' => 'IBAN',
],
'attributes' => [
'size' => 34,
'maxlength' => 34,
],
'type' => 'Text',
]);
$this->add([
'name' => 'ribHorsSepa',
'options' => [
'label' => 'RIB hors zone SEPA',
],
'type' => 'UnicaenApp\Form\Element\RIBFieldset',
'type' => 'Checkbox',
]);
/**
......@@ -407,18 +427,41 @@ class DossierFieldset extends AbstractFieldset
],
],
'telephone' => [
'required' => true,
'filters' => [
['name' => 'StringTrim'],
],
],
'ribBic' => [
'required' => true,
'filters' => [
['name' => 'StringTrim'],
['name' => 'StringToUpper'],
],
'validators' => [
new \Zend\Validator\Regex([
'pattern' => "/[0-9a-zA-Z]{8,11}/",
'messages' => [\Zend\Validator\Regex::NOT_MATCH => "Le BIC doit contenir 8 à 11 caractères"],
]),
],
],
'ribIban' => [
'required' => true,
'filters' => [
['name' => 'StringTrim'],
['name' => 'StringToUpper'],
],
'validators' => [
// new \Zend\I18n\Validator\PhoneNumber(), // les formats de numéros ne tolèrent pas le 0 de tête!!
new RIBValidator(),
],
],
'premierRecrutement' => [
'premierRecrutement' => [
'required' => $this->has('premierRecrutement'),
],
'statut' => [
'statut' => [
'required' => true,
],
];
......
......@@ -21,7 +21,7 @@ class DossierFieldsetDoctrineHydrator extends DoctrineObject
*/
public function hydrate(array $data, $dossier)
{
$data['rib'] = implode('-', $data['rib']);
$data['rib'] = $data['ribBic'].'-'.$data['ribIban'];
if (isset($data['dateNaissance'])) {
$data['dateNaissance'] = DateTime::createFromFormat(Constants::DATE_FORMAT, $data['dateNaissance']);
......@@ -49,7 +49,9 @@ class DossierFieldsetDoctrineHydrator extends DoctrineObject
$data['dateNaissance'] = $dossier->getDateNaissance()->format(Constants::DATE_FORMAT);
}
if ($dossier->getRib()) {
$data['rib'] = array_combine(['bic', 'iban'], explode('-', $dossier->getRib()));
$rib = explode('-', $dossier->getRib());
$data['ribBic'] = isset($rib[0]) ? $rib[0] : null;
$data['ribIban'] = isset($rib[1]) ? $rib[1] : null;
}
$this->processPremierRecrutement($data);
......
<?php
namespace Application\Validator;
use Zend\Validator\Iban;
class RIBValidator extends Iban
{
/**
* Sets validator options
*
* @param array|Traversable $options OPTIONAL
*/
public function __construct($options = [])
{
$options['messages'] = [
\Zend\Validator\Iban::FALSEFORMAT => $message = "L'IBAN saisi n'est pas valide",
\Zend\Validator\Iban::CHECKFAILED => $message,
\Zend\Validator\Iban::NOTSUPPORTED => $message,
];
parent::__construct($options);
}
public function isValid($value, $context = null)
{
$horsSepa = isset($context['ribHorsSepa']) ? (bool)$context['ribHorsSepa'] : false;
if ($horsSepa) return true; // pas de contrôle si hors SEPA!!
parent::isValid($value, $context);
}
}
\ No newline at end of file
......@@ -50,10 +50,10 @@ $dossier = $form->get('dossier'); /* @var $dossier \Application\Form\Intervenant
</div>
<div class="col-md-5">
<fieldset class="rib">
<legend><?= $dossier->get('rib')->getLabel() ?></legend>
<div class="rib-part"><?= $this->formControlGroup($dossier->get('rib')->get('bic')); ?></div>
<div class="rib-part"><?= $this->formControlGroup($dossier->get('rib')->get('iban')); ?></div>
<?= $this->formControlGroup($dossier->get('rib')->get('hidden')); ?>
<legend>Coordonnées bancaires</legend>
<div class="rib-part"><?= $this->formControlGroup($dossier->get('ribBic')); ?></div>
<div class="rib-part"><?= $this->formControlGroup($dossier->get('ribIban')); ?></div>
<div class="rib-part"><?= $this->formControlGroup($dossier->get('ribHorsSepa')); ?></div>
</fieldset>
<?php if ($dossier->has('premierRecrutement')) {
echo $this->formControlGroup($dossier->get('premierRecrutement'));
......
Supports Markdown
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