diff --git a/module/ExportRh/src/Connecteur/Siham/SihamConnecteur.php b/module/ExportRh/src/Connecteur/Siham/SihamConnecteur.php index 9ce02bf2ec1ebab6a8e3a1c3b1d2889d16abce35..4e3ea1e9064669af4f109ed7292003b569512931 100644 --- a/module/ExportRh/src/Connecteur/Siham/SihamConnecteur.php +++ b/module/ExportRh/src/Connecteur/Siham/SihamConnecteur.php @@ -95,6 +95,52 @@ class SihamConnecteur implements ConnecteurRhInterface + public function recupererDonneesAdministrativesIntervenantRh(\Application\Entity\Db\Intervenant $intervenant) + { + try { + if (!empty($intervenant->getCodeRh())) { + $codeRh = $intervenant->getCodeRh(); + //Si code RH ne contient pas UCN alors on le reformate + if (!strstr($codeRh, 'UCN')) { + $codeRh = $this->siham->getCodeAdministration() . str_pad($codeRh, 9, '0', STR_PAD_LEFT); + } + + + $dateObservation = $intervenant->getAnnee()->getDateDebut(); + $params = + [ + 'listeMatricules' => [$codeRh], + 'dateObservation' => $intervenant->getAnnee()->getDateDebut()->format('Y-m-d'), + ]; + + + $donneesAdministratives = $this->siham->recupererDonneesAdministrativeAgent($params); + + return $donneesAdministratives; + } + + return null; + } catch (SihamException $e) { + throw new \Exception($e->getMessage()); + } + } + + + + public function recupererAffectationEnCours($intervenant) + { + $affectation = []; + $donneesAdministratives = $this->recupererDonneesAdministrativesIntervenantRh($intervenant); + + if (!empty($donneesAdministratives->listeAffectations)) { + $affectation = $donneesAdministratives->listeAffectations; + } + + return $affectation; + } + + + public function prendreEnChargeIntervenantRh(\Application\Entity\Db\Intervenant $intervenant, $datas): ?string { try { diff --git a/module/ExportRh/src/Controller/ExportRhController.php b/module/ExportRh/src/Controller/ExportRhController.php index adb0f6f31dcc47cfbd5b85c8ef3e60dd7c4329cb..97ecd0875d50acafd8990057a2783219b8841890 100644 --- a/module/ExportRh/src/Controller/ExportRhController.php +++ b/module/ExportRh/src/Controller/ExportRhController.php @@ -85,14 +85,35 @@ class ExportRhController extends AbstractController /* Récupération de la validation du dossier si elle existe */ $intervenantDossierValidation = $this->getServiceDossier()->getValidation($intervenant); $typeIntervenant = $intervenant->getStatut()->getTypeIntervenant()->getCode(); - $intervenantRh = $this->exportRhService->getIntervenantRh($intervenant); + $renouvellement = false; + $priseEnCharge = false; + + /** + * Etape 1 : On cherche si l'intervenant est déjà dans le SI RH + * Etape 2 : Si pas dans le SI RH alors c'est une prise en charge + * Etape 3 : Si il est déjà dans le SI RH alors on regarde si il a une affectation en cours pour l'année en cours + * Etape 4 : Si il a une affectation en cours alors on propose uniquement la mise à jour des données personnelles + * Etape 5 : Si il n'a pas encore d'affectation on propose alors un renouvellement de l'intervenant + */ + + $intervenantRh = $this->exportRhService->getIntervenantRh($intervenant); + + if ($intervenantRh) { + //On a trouvé un intervenant dans le SI RH + $affectationEnCours = $this->exportRhService->getAffectationEnCours($intervenant); + //On regarde si il a une affectation en cours pour l'année courante si oui alors on propose uniquement une synchronisation des données personnelles + $renouvellement = true; + if (!empty($affectationEnCours)) { + //Si non on propose un renouvellement de l'intervenant SI RH + $renouvellement = false; + } + } else { + $priseEnCharge = true; + } - /*Scénario 1 : Intervenant non présent dans le SI RH*/ $form = $this->getExportRhForm(); - /*Scénario 2 : Intervenant présent dans le SI RH donc uniquement mis à jour des données*/ - /*Scénario 3 : Intervenant présent dans le SI RH avec une affectation*/ $nameConnecteur = $this->exportRhService->getConnecteurName(); @@ -102,6 +123,8 @@ class ExportRhController extends AbstractController 'intervenantDossier', 'intervenantDossierValidation', 'form', + 'renouvellement', + 'priseEnCharge', 'nameConnecteur'); } diff --git a/module/ExportRh/src/Service/ExportRhService.php b/module/ExportRh/src/Service/ExportRhService.php index 2eb167a3ff6f0efaab2f7714b5708e4b3eae6508..9e4916ffe97d6f3e12c9c0b77752c31819310a52 100644 --- a/module/ExportRh/src/Service/ExportRhService.php +++ b/module/ExportRh/src/Service/ExportRhService.php @@ -79,6 +79,26 @@ class ExportRhService extends AbstractService + public function getDonneesAdministrativeIntervenantRh($intervenant) + { + $donneesAdministratives = $this->connecteur->recupererDonneesAdministrativesIntervenantRh($intervenant); + + return $donneesAdministratives; + } + + + + public function getAffectationEnCours($intervenant) + { + $affectation = $this->connecteur->recupererAffectationEnCours($intervenant); + var_dump($affectation); + die; + + return $affectation; + } + + + public function getListeUO() { return $this->connecteur->recupererListeUO(); diff --git a/module/ExportRh/view/export-rh/export-rh/exporter.phtml b/module/ExportRh/view/export-rh/export-rh/exporter.phtml index a8820877684f4e57b86a0109fd347d0419382754..9f4036eee57f3e05503f1f7603e69fe90706b8a4 100755 --- a/module/ExportRh/view/export-rh/export-rh/exporter.phtml +++ b/module/ExportRh/view/export-rh/export-rh/exporter.phtml @@ -22,7 +22,6 @@ $connecteurFieldset = $form->get('connecteurForm'); <?php endif; ?> </div> <?php echo $this->messenger()->addCurrentMessagesFromFlashMessenger()->addMessagesFromFlashMessenger(); ?> -<?php if (empty($intervenantRh)): ?> <form class="no-intranavigation" action="<?= $this->url('intervenant/pec', ['intervenant' => $intervenant->getId()]) ?>" method="post"> <!--Partie générique du formulaire--> @@ -145,16 +144,20 @@ $connecteurFieldset = $form->get('connecteurForm'); </div> </div> - <!-- Formulaire spécifique au connecteur--> - <?php - echo $this->partial('export-rh/export-rh/' . $nameConnecteur . '/connecteurForm', compact('connecteurFieldset')); - ?> - - <p> - <input type="submit" value="Prendre en charge l'agent"/> - </p> -</form> + <?php if ($priseEnCharge): ?> + + <!-- Formulaire spécifique au connecteur--> + <?php + echo $this->partial('export-rh/export-rh/' . $nameConnecteur . '/connecteurForm', compact('connecteurFieldset')); + ?> -<?php endif; ?> + <p> + <input type="submit" value="Prendre en charge l'agent"/> + </p> + <?php elseif ($renouvellement): ?> + renouvellement + <?php endif; ?> + +</form> diff --git a/module/UnicaenSiham/src/UnicaenSiham/Service/Siham.php b/module/UnicaenSiham/src/UnicaenSiham/Service/Siham.php index 8a2712a4ac329da5228502abc561dc8de509ae3a..0804cc65db92bd5e2034e95eda086ef7b4ff0068 100644 --- a/module/UnicaenSiham/src/UnicaenSiham/Service/Siham.php +++ b/module/UnicaenSiham/src/UnicaenSiham/Service/Siham.php @@ -240,6 +240,38 @@ class Siham + public function recupererDonneesAdministrativeAgent(array $params) + { + $listMatricules = []; + foreach ($params['listeMatricules'] as $matricule) { + $listeMatricules[] = ['matricule' => $matricule]; + } + + + $paramsWS = ['ParamListAgent' => [ + 'codeEtablissement' => $this->codeEtablissement, + 'dateFinObservation' => (isset($params['dateFinObservation'])) ? $params['dateFinObservation'] : '', + 'dateObservation' => '',//(isset($params['dateObservation'])) ? $params['dateObservation'] : '', + 'listeMatricules' => $listeMatricules, + ]]; + + + try { + $client = $this->sihamClient->getClient('DossierAgentWebService'); + $result = $client->RecupDonneesAdministratives($paramsWS); + + if (isset($result->return)) { + + return $result->return; + } + } catch (\SoapFault $e) { + + throw new SihamException($e->faultstring, 0, $e); + } + } + + + /** * @param $params array Paramètres du webservice : bisTer, codePostal, complementAdresse,dateDebut, matricule, * natureVoie, noVoie, nomVoie, ville