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

Correction cloture siham sur multiannée (#52484)

parent a761fa2f
Loading
Loading
Loading
Loading
+1 −42
Changes for module/ExportRh/src/Connecteur/Siham/SihamConnecteur.php: 1 added line, 42 removed lines.
Original line number Diff line number Diff line
@@ -2,7 +2,6 @@

namespace ExportRh\Connecteur\Siham;


use Application\Entity\Db\Intervenant;
use Application\Service\Traits\AdresseNumeroComplServiceAwareTrait;
use Dossier\Service\Traits\DossierServiceAwareTrait;
@@ -16,7 +15,6 @@ use UnicaenSiham\Exception\SihamException;
use UnicaenSiham\Service\Siham;
use Laminas\Form\Fieldset;


class SihamConnecteur implements ConnecteurRhInterface
{
    use DossierServiceAwareTrait;
@@ -27,14 +25,12 @@ class SihamConnecteur implements ConnecteurRhInterface
    public Siham $siham;



    public function __construct (Siham $siham)
    {
        $this->siham = $siham;
    }



    public function rechercherIntervenantRh ($nomUsuel = '', $prenom = '', $insee = ''): array
    {
        $params = [
@@ -60,12 +56,10 @@ class SihamConnecteur implements ConnecteurRhInterface
            }
        }


        return $listIntervenantRh;
    }



    public function recupererIntervenantRh (\Application\Entity\Db\Intervenant $intervenant): ?IntervenantRh
    {
        $agent  = null;
@@ -90,7 +84,6 @@ class SihamConnecteur implements ConnecteurRhInterface
            }
        }


        if (!empty($agent)) {
            $intervenantRh = new IntervenantRH();
            $intervenantRh->setNomUsuel($agent->getNomUsuel());
@@ -117,7 +110,6 @@ class SihamConnecteur implements ConnecteurRhInterface
            $intervenantRh->setAdresseCommune($agent->getBureauDistributeurAdresse());
            $intervenantRh->setAdresseDateDebut($agent->getDateDebutAdresse());


            return $intervenantRh;
        }

@@ -125,7 +117,6 @@ class SihamConnecteur implements ConnecteurRhInterface
    }



    public function recupererDonneesAdministrativesIntervenantRh (\Application\Entity\Db\Intervenant $intervenant): ?array
    {
        try {
@@ -147,7 +138,6 @@ class SihamConnecteur implements ConnecteurRhInterface
                        'dateFinObservation' => $intervenant->getAnnee()->getDateFin()->format('Y-m-d'),
                    ];


                $donneesAdministratives = $this->siham->recupererDonneesAdministrativeAgent($params);

                return (array)$donneesAdministratives;
@@ -160,14 +150,12 @@ class SihamConnecteur implements ConnecteurRhInterface
    }



    public function recupererAffectationEnCoursIntervenantRh (\Application\Entity\Db\Intervenant $intervenant): ?array
    {
        $typeAffectation        = (isset($this->siham->getConfig()['type-affectation'])) ? $this->siham->getConfig()['type-affectation'] : ['FUN'];
        $affectations           = [];
        $donneesAdministratives = $this->recupererDonneesAdministrativesIntervenantRh($intervenant);


        if (!empty($donneesAdministratives['listeAffectations']) || !empty($donneesAdministratives->listeAffectations)) {
            $listeAffectations = $donneesAdministratives['listeAffectations'];
            if (is_array($listeAffectations)) {
@@ -198,17 +186,14 @@ class SihamConnecteur implements ConnecteurRhInterface
    }



    public function recupererContratEnCoursIntervenantRh (Intervenant $intervenant): ?array
    {
        $contrats               = [];
        $donneesAdministratives = $this->recupererDonneesAdministrativesIntervenantRh($intervenant);


        if (!empty($donneesAdministratives['listeContrats']) || !empty($donneesAdministratives->listeContrats)) {
            $listeContrats = (isset($donneesAdministratives['listeContrats']) && is_array($donneesAdministratives['listeContrats'])) ? $donneesAdministratives['listeContrats'] : [$donneesAdministratives['listeContrats']];


            foreach ($listeContrats as $contrat) {

                $dateDebutContrat = new \DateTime($contrat->dateDebutContrat);
@@ -224,12 +209,10 @@ class SihamConnecteur implements ConnecteurRhInterface
    }



    public function synchroniserDonneesPersonnellesIntervenantRh (\Application\Entity\Db\Intervenant $intervenant, $datas): bool
    {
        try {


            $intervenantRh      = $this->recupererIntervenantRh($intervenant);
            $dossierIntervenant = $this->getServiceDossier()->getByIntervenant($intervenant);

@@ -306,7 +289,6 @@ class SihamConnecteur implements ConnecteurRhInterface

                ];


                $this->siham->modifierAdressePrincipaleAgent($params);
            }

@@ -333,7 +315,6 @@ class SihamConnecteur implements ConnecteurRhInterface
                $this->siham->modifierCoordonnéesBancairesAgent($params);
            }*/


            return true;
        } catch
        (SihamException $e) {
@@ -342,7 +323,6 @@ class SihamConnecteur implements ConnecteurRhInterface
    }



    public function trouverCodeRhByInsee (\Application\Entity\Db\Intervenant $intervenant): ?string
    {
        $intervenantDossier = $this->getServiceDossier()->getByIntervenant($intervenant);
@@ -356,7 +336,6 @@ class SihamConnecteur implements ConnecteurRhInterface
        $listeAgents = $this->siham->recupererListeAgents($params);
        $agent       = current($listeAgents);


        if (!empty($agent)) {
            return $agent->getMatricule();
        }
@@ -365,7 +344,6 @@ class SihamConnecteur implements ConnecteurRhInterface
    }



    public function prendreEnChargeIntervenantRh (\Application\Entity\Db\Intervenant $intervenant, $datas): ?string
    {
        try {
@@ -461,7 +439,6 @@ class SihamConnecteur implements ConnecteurRhInterface
                $coordonneesBancaires[] = $coordonnees;
            }


            $coordonneesTelMail[] = '';
            if ($datas['generiqueFieldset']['telPro'] && !empty($dossierIntervenant->getTelPro())) {
                $coordonneesTelMail[] = [
@@ -518,7 +495,6 @@ class SihamConnecteur implements ConnecteurRhInterface
                }
            }


            $params = [
                'categorieEntree'           => 'ACTIVE',
                'civilite'                  => ($dossierIntervenant->getCivilite() == 'M.') ? '1' : '2',
@@ -549,19 +525,16 @@ class SihamConnecteur implements ConnecteurRhInterface
                'UO'                        => $datas['connecteurForm']['affectation'],
            ];


            $matricule = $this->siham->priseEnChargeAgent($params);

            return $matricule;
        } catch (SihamException $e) {


            throw new \Exception($e->getMessage());
        }
    }



    public function renouvellerIntervenantRH (\Application\Entity\Db\Intervenant $intervenant, $datas): ?string
    {
        try {
@@ -589,7 +562,6 @@ class SihamConnecteur implements ConnecteurRhInterface
                $matricule = $this->siham->getCodeAdministration() . str_pad($matricule, 9, '0', STR_PAD_LEFT);
            }/*/


            /*POSITION ADMINISTRATIVE*/
            $position[] =
                ['dateEffetPosition' => $dateEffet,
@@ -599,7 +571,6 @@ class SihamConnecteur implements ConnecteurRhInterface
                 'temoinValidite'    => 1,
                ];


            /*STATUT*/
            $statut[] =
                ['dateEffetStatut' => $dateEffet,
@@ -632,7 +603,6 @@ class SihamConnecteur implements ConnecteurRhInterface
                 'typeLienJuridique' => 'TL01',
                ];


            $params = [
                'categorieEntree'        => 'ACTIVE',
                'dateRenouvellement'     => $dateEffet,
@@ -648,7 +618,6 @@ class SihamConnecteur implements ConnecteurRhInterface
                'UO'                     => $datas['connecteurForm']['affectation'],
            ];


            $matricule = $this->siham->renouvellementAgent($params);

            //Mise à jour des données personnelles de l'agent
@@ -661,12 +630,11 @@ class SihamConnecteur implements ConnecteurRhInterface
    }



    public function cloreDossier (Intervenant $intervenant): ?bool
    {

        try {
            $anneeUniversitaire = $this->getServiceExportRh()->getAnneeUniversitaireEnCours();
            $anneeUniversitaire = $intervenant->getAnnee();
            $dateSortie         = $anneeUniversitaire->getDateFin()->format('Y-m-d');

            $matricule = '';
@@ -691,7 +659,6 @@ class SihamConnecteur implements ConnecteurRhInterface
    }



    public function recupererListeUO (): ?array
    {
        /*On récupére les UO avec le type paramétré*/
@@ -716,49 +683,42 @@ class SihamConnecteur implements ConnecteurRhInterface
    }



    public function recupererListePositions (): ?array
    {
        return $this->siham->recupererListePositions();
    }



    public function recupererListeEmplois (): ?array
    {
        return $this->siham->recupererListeEmplois();
    }



    public function recupererListeStatuts (): ?array
    {
        return $this->siham->recupererListeStatuts();
    }



    public function recupererListeModalites (): ?array
    {
        return $this->siham->recupererListeModalites();
    }



    public function recupererListeContrats (): ?array
    {
        return $this->siham->recupererListeContrats();
    }



    public function getConnecteurName (): string
    {
        return 'siham';
    }



    public function recupererFieldsetConnecteur (): Fieldset
    {
        $fieldset = new SihamFieldset('connecteurForm', []);
@@ -767,7 +727,6 @@ class SihamConnecteur implements ConnecteurRhInterface
    }



    public static function cleanDatas ($str, $strict = false, $encoding = 'UTF-8')
    {
        $from = 'ÀÁÂÃÄÅÇÐÈÉÊËÌÍÎÏÒÓÔÕÖØÙÚÛÜŸÑàáâãäåçðèéêëìíîïòóôõöøùúûüÿñ()…,<> /?€%!":’\'+.';