Commit b2b306dd authored by Antony Le Courtes's avatar Antony Le Courtes
Browse files

admin gestion agrement / duree de vie

- Modification contrainte unicité
- Mise en place formulaire dans admin
parent 0163e260
Loading
Loading
Loading
Loading
+26 −36
Original line number Diff line number Diff line
@@ -13382,6 +13382,17 @@
          'default' => '0',
          'commentaire' => NULL,
        ),
        'ANNEE_AGREMENT' => 
        array (
          'name' => 'ANNEE_AGREMENT',
          'type' => 'NUMBER',
          'length' => 0,
          'scale' => NULL,
          'precision' => NULL,
          'nullable' => true,
          'default' => NULL,
          'commentaire' => NULL,
        ),
        'DUREE_VIE' => 
        array (
          'name' => 'DUREE_VIE',
@@ -13404,17 +13415,6 @@
          'default' => NULL,
          'commentaire' => NULL,
        ),
        'ANNEE_AGREMENT' =>
        array (
          'name' => 'ANNEE_AGREMENT',
          'type' => 'NUMBER',
          'length' => 0,
          'scale' => NULL,
          'precision' => NULL,
          'nullable' => true,
          'default' => NULL,
          'commentaire' => NULL,
        ),
      ),
    ),
    'TBL_CHARGENS' => 
@@ -44842,11 +44842,12 @@ WHERE
    array (
      'name' => 'TYPE_AGREMENT_STATUT__UN',
      'table' => 'TYPE_AGREMENT_STATUT',
      'index' => 'TYPE_AGREMENT_STATUT__UN1',
      'index' => 'TYPE_AGREMENT_STATUT__UN',
      'columns' => 
      array (
        0 => 'TYPE_AGREMENT_ID',
        1 => 'STATUT_INTERVENANT_ID',
        2 => 'HISTO_DESTRUCTION',
      ),
    ),
    'TYPE_AGREMENT__UN' => 
@@ -52970,18 +52971,7 @@ END;',
      array (
        0 => 'TYPE_AGREMENT_ID',
        1 => 'STATUT_INTERVENANT_ID',
        2 => 'PREMIER_RECRUTEMENT',
      ),
    ),
    'TYPE_AGREMENT_STATUT__UN1' => 
    array (
      'name' => 'TYPE_AGREMENT_STATUT__UN1',
      'unique' => true,
      'table' => 'TYPE_AGREMENT_STATUT',
      'columns' => 
      array (
        0 => 'TYPE_AGREMENT_ID',
        1 => 'STATUT_INTERVENANT_ID',
        2 => 'HISTO_DESTRUCTION',
      ),
    ),
    'TYPE_AGREMENT__UN' => 
+33 −26
Original line number Diff line number Diff line
@@ -37,6 +37,8 @@ class StatutIntervenantController extends AbstractController
    public function saisieAction()
    {
        /* @var $statutIntervenant StatutIntervenant */
        try {


            $statutIntervenant = $this->getEvent()->getParam('statutIntervenant');
            $form              = $this->getFormStatutIntervenantSaisie();
@@ -67,6 +69,11 @@ class StatutIntervenantController extends AbstractController
                $form->bind($statutIntervenant);
                $form->readOnly();
            }
        }
        catch(\Exception $e)
        {
            var_dump($e);
        }


        return compact('form', 'title');
+1 −2
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@
      <index name="IDX_52F2ED3963F06898" columns="HISTO_MODIFICATEUR_ID"/>
    </indexes>
    <unique-constraints>
      <unique-constraint name="type_agrement_statut__un" columns="TYPE_AGREMENT_ID,STATUT_INTERVENANT_ID"/>
      <unique-constraint name="type_agrement_statut__un" columns="TYPE_AGREMENT_ID,STATUT_INTERVENANT_ID,HISTO_DESTRUCTION"/>
    </unique-constraints>
    <id name="id" type="integer" column="ID">
      <generator strategy="SEQUENCE"/>
@@ -17,7 +17,6 @@
    <field name="histoCreation" type="datetime" column="HISTO_CREATION" nullable="false"/>
    <field name="histoDestruction" type="datetime" column="HISTO_DESTRUCTION" nullable="true"/>
    <field name="histoModification" type="datetime" column="HISTO_MODIFICATION" nullable="false"/>
    <field name="premierRecrutement" type="boolean" column="PREMIER_RECRUTEMENT" nullable="true"/>
    <field name="obligatoire" type="boolean" column="OBLIGATOIRE" nullable="false"/>
    <many-to-one field="histoModificateur" target-entity="Application\Entity\Db\Utilisateur">
      <join-columns>
+4 −35
Original line number Diff line number Diff line
@@ -28,11 +28,9 @@ class TypeAgrementStatut implements HistoriqueAwareInterface
    private $statut;

    /**
     * @var boolean
     * @var integer
     */
    private $premierRecrutement;


    private $obligatoire;

    /**
     * @var dureeVie
@@ -51,8 +49,6 @@ class TypeAgrementStatut implements HistoriqueAwareInterface
            $this->getId(),
            sprintf("%s (%s)", $this->getStatut(), $this->getStatut()->getId()),
            sprintf("%s (%s)", $this->getType(), $this->getType()->getId()),
            $this->getObligatoire(),
            $this->getPremierRecrutement()
        );
    }

@@ -113,6 +109,7 @@ class TypeAgrementStatut implements HistoriqueAwareInterface




    /**
     * Set statutIntervenant
     *
@@ -139,34 +136,6 @@ class TypeAgrementStatut implements HistoriqueAwareInterface
        return $this->statut;
    }

    /**
     * Set premierRecrutement
     *
     * @param boolean $premierRecrutement
     *
     * @return TypeAgrementStatut
     */
    public function setPremierRecrutement($premierRecrutement)
    {
        $this->premierRecrutement = $premierRecrutement;

        return $this;
    }



    /**
     * Get premierRecrutement
     *
     * @return boolean
     */
    public function getPremierRecrutement()
    {
        return $this->premierRecrutement;
    }



     /**
     * Get dureeVie
     *
+122 −2
Original line number Diff line number Diff line
@@ -2,7 +2,10 @@

namespace Application\Form\StatutIntervenant;

use Application\Entity\Db\TypeAgrementStatut;
use Application\Form\AbstractForm;
use Application\Service\Traits\TypeAgrementServiceAwareTrait;
use Application\Service\Traits\TypeAgrementStatutServiceAwareTrait;
use Zend\Form\Element\Checkbox;
use Zend\Form\Element\Csrf;
use Zend\Form\Element\Number;
@@ -21,6 +24,8 @@ use Application\Filter\StringFromFloat;
class StatutIntervenantSaisieForm extends AbstractForm
{
    use TypeIntervenantServiceAwareTrait;
    use TypeAgrementServiceAwareTrait;
    use TypeAgrementStatutServiceAwareTrait;



@@ -126,6 +131,46 @@ class StatutIntervenantSaisieForm extends AbstractForm
            'type'       => 'Text',
        ]);

        //Gestion des agréments
        $qb = $this->getServiceTypeAgrement()->finderByHistorique();
        $typesAgrement = $this->getServiceTypeAgrement()->getList($qb);

        foreach($typesAgrement as $type)
        {
            $this->add([
                'name'    => $type->getCode(),
                'options' => [
                    'label'          => $type->getLibelle(),
                    'value_options' => [
                        0 => 'Non',
                        1 => 'Oui'
                    ]
                ],
                'attributes' => [
                    'value' => 0,
                ],
                'type'    => 'Zend\Form\Element\Radio'
            ]);

            $this->add([
                'name'       => $type->getCode() . '-DUREE_VIE',
                'options'    => [
                    'suffix' => 'an(s)'
                ],
                'attributes' => [
                    'title' => "Nombre d'annnée de validité de l'agrément",
                    'value' => '1'
                ],
                'type'       => 'Text',

            ]);
        }






        $this->add([
            'name'       => 'service-statutaire',
            'options'    => [
@@ -348,6 +393,8 @@ class StatutIntervenantHydrator implements HydratorInterface
{

    use TypeIntervenantServiceAwareTrait;
    use TypeAgrementServiceAwareTrait;
    use TypeAgrementStatutServiceAwareTrait;



@@ -387,11 +434,73 @@ class StatutIntervenantHydrator implements HydratorInterface
        $object->setDepassementSDSHC($data['depassement-sdshc']);
        $object->setChargesPatronales(FloatFromString::run($data['charges-patronales']) / 100);

        return $object;
        //Récupération des types d'agrément possible
        $qb = $this->getServiceTypeAgrement()->finderByHistorique();
        $typesAgrements = $this->getServiceTypeAgrement()->getList($qb);
        //Type agrement par statut d'intervenant
        $qb = $this->getServiceTypeAgrementStatut()->finderByStatutIntervenant($object);
        $this->getServiceTypeAgrementStatut()->finderByHistorique($qb);
        $typesAgrementsStatuts = $this->getServiceTypeAgrementStatut()->getList($qb);
        $typesAgrementsStatusByCode = [];
        foreach($typesAgrementsStatuts as $tas)
        {
            $typesAgrementsStatusByCode[$tas->getType()->getCode()] = $tas;
        }

        foreach($typesAgrements as $ta)
        {
            if(array_key_exists($ta->getCode(), $data))
            {
                //update
                if(!$data[$ta->getCode()] && array_key_exists($ta->getCode(), $typesAgrementsStatusByCode))
                {
                    $object->removeTypeAgrementStatut($tas);
                    $this->getServiceTypeAgrementStatut()->delete($tas);
                }
                elseif($data[$ta->getCode()] && array_key_exists($ta->getCode(), $typesAgrementsStatusByCode)){
                    $tas = $typesAgrementsStatusByCode[$ta->getCode()];
                    $dureeVie = $data[$ta->getCode().'-DUREE_VIE'];
                    $tas->setDureeVie($dureeVie);
                    $this->getServiceTypeAgrementStatut()->save($tas);
                }
                elseif($data[$ta->getCode()] && !array_key_exists($ta->getCode(), $typesAgrementsStatusByCode)){
                    $dureeVie = $data[$ta->getCode().'-DUREE_VIE'];
                    $tas = new TypeAgrementStatut();
                    $tas->setDureeVie($dureeVie);
                    $tas->setObligatoire(1);
                    $tas->setType($ta);
                    $tas->setStatut($object);
                    $this->getServiceTypeAgrementStatut()->save($tas);

                }
            }
        }

        //Delete or update existing agrement statut
        /*foreach($typesAgrementsStatuts as $tas)
        {
            if(in_array($tas->getType()->getCode(), $typeAgrementCodeToDesactivate))
            {
                $object->removeTypeAgrementStatut($tas);
                $this->getServiceTypeAgrementStatut()->delete($tas);
            }
            elseif(in_array($tas->getType()->getCode(), $typeAgrementCodeToActivate))
            {
                $dureeVie = $data[$tas->getType()->getCode().'-DUREE_VIE'];
                $tas->setDureeVie($dureeVie);
                $this->getServiceTypeAgrementStatut()->save($tas);

            }
            else{
                $newTas = new TypeAgrementStatut();
                $newTas->setDureeVie();
            }
        }*/


        return $object;
    }

    /**
     * Extract values from an object
     *
@@ -426,8 +535,19 @@ class StatutIntervenantHydrator implements HydratorInterface
            'maximum-HETD'                   => StringFromFloat::run($object->getMaximumHETD()),
            'charges-patronales'             => StringFromFloat::run($object->getChargesPatronales() * 100),
            'depassement-sdshc'              => $object->getDepassementSDSHC(),

        ];

        $typesAgrementsStatuts = $object->getTypeAgrementStatut();
        foreach($typesAgrementsStatuts  as $tas)
        {
            if(!$tas->getHistoDestruction())
            {
                $data[$tas->getType()->getCode()] = 1;
                $data[$tas->getType()->getCode().'-DUREE_VIE'] = $tas->getDureeVie();
            }
        }

        return $data;
    }
}
 No newline at end of file
Loading