diff --git a/module/Application/src/Application/Controller/IntervenantController.php b/module/Application/src/Application/Controller/IntervenantController.php index bd67c003c1b20d358b649aa671f512590bdfe44c..75d59dbfdeb744feb40b2637b54eddfbd26d91a9 100755 --- a/module/Application/src/Application/Controller/IntervenantController.php +++ b/module/Application/src/Application/Controller/IntervenantController.php @@ -520,13 +520,13 @@ class IntervenantController extends AbstractController $typeIntervenant = $intervenant->getStatut()->getTypeIntervenant()->getCode(); $sihamConnecteur = $this->getSihamConnecteur(); - $intervenantRH = $sihamConnecteur->rechercherIntervenant($intervenant); + $intervenantRh = $sihamConnecteur->trouverIntervenantRh($intervenant); if (!$intervenant) { $this->flashMessenger()->addErrorMessage("Aucun intervenant n'a été trouvé dans le SIRH"); } - return compact('typeIntervenant', 'intervenant', 'intervenantRH', 'intervenantDossier', 'intervenantDossierValidation'); + return compact('typeIntervenant', 'intervenant', 'intervenantRh', 'intervenantDossier', 'intervenantDossierValidation'); } diff --git a/module/Application/src/Application/Service/IntervenantService.php b/module/Application/src/Application/Service/IntervenantService.php index c81a3c3915044f9ccf83ba1abeae160edee28fb3..097b1ca12fad1a681c133bcb1445601afc3155f2 100755 --- a/module/Application/src/Application/Service/IntervenantService.php +++ b/module/Application/src/Application/Service/IntervenantService.php @@ -124,6 +124,20 @@ class IntervenantService extends AbstractEntityService + public function getByCodeRh(string $codeRh): ?Intervenant + { + $anneeId = $this->getServiceContext()->getAnnee()->getId(); + $statutId = null; + $structureId = $this->getServiceContext()->getStructure(); + if ($structureId) $structureId = $structureId->getId(); + + $bones = $this->getBones(['CODE_RH' => $codeRh, 'ANNEE_ID' => $anneeId]); + + return $this->bestIntervenantByBones($bones, $codeRh, $anneeId, null, null); + } + + + /** * * @param string $sourceCode diff --git a/module/Application/view/application/intervenant/exporter.phtml b/module/Application/view/application/intervenant/exporter.phtml new file mode 100755 index 0000000000000000000000000000000000000000..25f706e55cb96caef89098e466766be61efd1903 --- /dev/null +++ b/module/Application/view/application/intervenant/exporter.phtml @@ -0,0 +1,61 @@ +<?php +/** + * @var \Application\Entity\Db\Intervenant $intervenant + * @var \ExportRh\Entity\IntervenantRh $intervenantRh + */ + +$intervenant->getNomUsuel() +?> +<br/> + + +<div class="messenger alert alert-warning"> + <?php if ($typeIntervenant == 'P'): ?> + L'export des données intervenants vers le SIRH n'est disponible que pour les vacataires. + <?php elseif (empty($intervenantDossierValidation)): ?> + Vous devez d'abord valider les données personnelles de <?= $intervenant; ?> pour pouvoir les synchroniser avec le SIRH + <?php endif; ?> +</div> +<table class="table"> + <thead> + <tr> + <th>Champs</th> + <th>Intervenant OSE</th> + <th>Intervenant SI RH</th> + </tr> + </thead> + <tbody> + <tr> + <td><input type="checkbox" checked="checked" name="nomUsuel"/> Nom usuel :</td> + <td><?= $intervenant->getNomUsuel() ?></td> + <td><?= $intervenantRh->getNomUsuel() ?></td> + </tr> + <tr> + <td><input type="checkbox" checked="checked" name="nomUsuel"/> Prénom :</td> + <td><?= $intervenant->getPrenom() ?></td> + <td><?= $intervenantRh->getPrenom() ?></td> + </tr> + <tr> + <td><input type="checkbox" checked="checked" name="nomUsuel"/> Date de naissance :</td> + <td><?= $intervenant->getDateNaissance()->format('d/m/Y') ?></td> + <td><?= $intervenantRh->getDateNaissance()->format('d/m/Y') ?></td> + </tr> + <tr> + <td><input type="checkbox" checked="checked" name="nomUsuel"/> Numéro INSEE</td> + <td><?= $intervenant->getNumeroInsee() ?></td> + <td><?= $intervenantRh->getNumeroInsee() ?></td> + </tr> + <tr> + <td><input type="checkbox" checked="checked" name="nomUsuel"/> Tel pro :</td> + <td><?= $intervenant->getTelPro() ?></td> + <td><?= $intervenantRh->getTelPro() ?></td> + </tr> + <tr> + <td><input type="checkbox" checked="checked" name="nomUsuel"/> Tel perso :</td> + <td><?= $intervenant->getTelPerso() ?></td> + <td><?= $intervenantRh->getTelPerso() ?></td> + </tr> + + </tbody> +</table> + diff --git a/module/ExportRh/src/Connecteur/ConnecteurRhInterface.php b/module/ExportRh/src/Connecteur/ConnecteurRhInterface.php index f33a7a1d0cd85591df5065f9767b04331795788b..4a1e67186f0fa486e066eeb0b18b02f290c51415 100644 --- a/module/ExportRh/src/Connecteur/ConnecteurRhInterface.php +++ b/module/ExportRh/src/Connecteur/ConnecteurRhInterface.php @@ -3,8 +3,7 @@ namespace ExportRh\Connecteur; -use ExportRh\Entity\Intervenant; -use ExportRh\Entity\IntervenantRH; +use ExportRh\Entity\IntervenantRh; interface ConnecteurRhInterface { @@ -15,18 +14,14 @@ interface ConnecteurRhInterface * * @return array */ - public function rechercherIntervenant($nomUsuel, $prenom, $insee, $dateNaissance): ?IntervenantRH; + public function rechercherIntervenantRh($nomUsuel = '', $prenom = '', $insee = ''): array; - public function trouverIntervenant(\Application\Entity\Db\Intervenant $intervenant): ?IntervenantRH; + public function trouverIntervenantRh(\Application\Entity\Db\Intervenant $intervenant): ?IntervenantRh; - /** - * @param Intervenant $intervenant - * - * @return bool - */ - public function exporterIntervenant(Intervenant $intervenant): bool; + public function prendreEnChargeIntervenantRh(\Application\Entity\Db\Intervenant $intervenant): ?IntervenantRh; + } \ No newline at end of file diff --git a/module/ExportRh/src/Connecteur/Siham/SihamConnecteur.php b/module/ExportRh/src/Connecteur/Siham/SihamConnecteur.php index e4b318e255a88803102833426cfc96b7dd2bec8a..89332134f3e9f570dd0d1335febf227ca7a870ef 100644 --- a/module/ExportRh/src/Connecteur/Siham/SihamConnecteur.php +++ b/module/ExportRh/src/Connecteur/Siham/SihamConnecteur.php @@ -4,10 +4,10 @@ namespace ExportRh\Connecteur\Siham; use ExportRh\Connecteur\ConnecteurRhInterface; -use ExportRh\Entity\Intervenant; -use ExportRh\Entity\IntervenantRH; +use ExportRh\Entity\IntervenantRh; use UnicaenSiham\Service\Siham; + class SihamConnecteur implements ConnecteurRhInterface { @@ -22,61 +22,65 @@ class SihamConnecteur implements ConnecteurRhInterface - public function rechercherIntervenant($nom, $prenom, $insee, $dateNaissance): ?IntervenantRH + public function rechercherIntervenantRh($nomUsuel = '', $prenom = '', $insee = ''): array { - $params = [ - 'nomUsuel' => $nom, + $params = [ + 'nomUsuel' => $nomUsuel, + 'prenom' => $prenom, + 'numeroInsee' => $insee, + ]; - $result = $this->siham->rechercherAgent($params); - $intervenantRH = new IntervenantRH(); - $intervenantRH->setNomUsuel($result->getNomUsuel()); - return $intervenantRH; + $listIntervenantRh = []; + //$result = $this->siham->rechercherAgent($params); + $result = $this->siham->recupererListeAgents($params); + + if (!empty($result)) { + foreach ($result as $v) { + $intervenantRh = new IntervenantRh(); + $intervenantRh->setNomUsuel($v->getNomUsuel()); + $intervenantRh->setPrenom($v->getPrenom()); + $intervenantRh->setCodeRh($v->getMatricule()); + $dateNaissance = new \DateTime($v->getDateNaissance()); + $intervenantRh->setDateNaissance($dateNaissance); + $intervenantRh->setNumeroInsee($v->getNumeroInsee()); + $listIntervenantRh[] = $intervenantRh; + } + } + + + return $listIntervenantRh; } - public function trouverIntervenant(\Application\Entity\Db\Intervenant $intervenant): ?IntervenantRH + public function trouverIntervenantRh(\Application\Entity\Db\Intervenant $intervenant): ?IntervenantRh { - $intervenantRH = null; + $intervenantRh = null; if (!empty($intervenant->getCodeRh())) { $params = [ 'listeMatricules' => [$intervenant->getCodeRh()], ]; $agent = $this->siham->recupererDonneesPersonnellesAgent($params); - $intervenantRH = new IntervenantRH(); - $intervenantRH->setNomUsuel($agent->getNomUsuel()); - $intervenantRH->setPrenom($agent->getPrenom()); - $intervenantRH->setTelPerso($agent->getTelephonePerso()); - $intervenantRH->setTelPro($agent->getTelephonePro()); + $intervenantRh = new IntervenantRH(); + $intervenantRh->setNomUsuel($agent->getNomUsuel()); + $intervenantRh->setPrenom($agent->getPrenom()); + $intervenantRh->setDateNaissance(new \DateTime($agent->getDateNaissance())); + $intervenantRh->setTelPerso($agent->getTelephonePerso()); + $intervenantRh->setTelPro($agent->getTelephonePro()); + $intervenantRh->setNumeroInsee($agent->getNumeroInsee()); } - return $intervenantRH; + return $intervenantRh; } - public - function prendreEnChargeIntervenant(\Application\Entity\Db\Intervenant $intervenant): Intervenant + public function prendreEnChargeIntervenantRh(\Application\Entity\Db\Intervenant $intervenant): ?IntervenantRh { } - - - public - function exporterIntervenant(Intervenant $intervenant): bool - { - // TODO: Implement intervenantExport() method. - } - - - - public - function test() - { - echo 'test réussi'; - } } \ No newline at end of file diff --git a/module/ExportRh/src/Controller/AdministrationController.php b/module/ExportRh/src/Controller/AdministrationController.php index 0a481959682cf2f02258d24ead00faab302e4c1e..7891c74ca9a46b3cba173c2b78c59a60f8e12cd0 100644 --- a/module/ExportRh/src/Controller/AdministrationController.php +++ b/module/ExportRh/src/Controller/AdministrationController.php @@ -33,27 +33,28 @@ class AdministrationController extends AbstractController public function chercherIntervenantRhAction(): array { $connecteurRh = $this->getExportRhService(); - $connecteurRh->getIntervenantRh([]); $params = [ 'nomUsuel' => '', 'prenom' => '', ]; - $agents = []; + $listIntervenantRh = []; + try { if ($this->getRequest()->isPost()) { - $params['nomUsuel'] = $this->getRequest()->getPost('nomUsuel'); - $params['prenom'] = $this->getRequest()->getPost('prenom'); - //$agents = $this->siham->rechercherAgent($params); + $nomUsuel = $this->getRequest()->getPost('nomUsuel'); + $prenom = $this->getRequest()->getPost('prenom'); + $insee = $this->getRequest()->getPost('insee'); + $listIntervenantRh = $connecteurRh->getListIntervenantRh($nomUsuel, $prenom, $insee); } } catch (SihamException $e) { $this->flashMessenger()->addErrorMessage($e->getMessage()); } - return compact('agents'); + return compact('listIntervenantRh'); } } diff --git a/module/ExportRh/src/Entity/IntervenantRH.php b/module/ExportRh/src/Entity/IntervenantRh.php similarity index 97% rename from module/ExportRh/src/Entity/IntervenantRH.php rename to module/ExportRh/src/Entity/IntervenantRh.php index 06bf8f20a4912aaba7ef4f3b77b29538cb6f7d1e..32acea61d3dbaeb82d9f38fdfb469c0e5cc4cffb 100644 --- a/module/ExportRh/src/Entity/IntervenantRH.php +++ b/module/ExportRh/src/Entity/IntervenantRh.php @@ -7,12 +7,13 @@ use Application\Entity\Db\Civilite; use Application\Entity\Db\Departement; use Application\Entity\Db\Discipline; use Application\Entity\Db\Grade; +use Application\Entity\Db\Intervenant; use Application\Entity\Db\Pays; use Application\Entity\Db\StatutIntervenant; use Application\Entity\Db\Structure; use Application\Entity\Db\Voirie; -class IntervenantRH +class IntervenantRh { public ?string $code; @@ -98,6 +99,32 @@ class IntervenantRH public ?string $sourceCode; + public ?Intervenant $intervenant; + + + + /** + * @return Intervenant|null + */ + public function getIntervenant(): ?Intervenant + { + return $this->intervenant; + } + + + + /** + * @param Intervenant|null $intervenant + * + * @return IntervenantRh + */ + public function setIntervenant(?Intervenant $intervenant): IntervenantRh + { + $this->intervenant = $intervenant; + + return $this; + } + /** diff --git a/module/ExportRh/src/Service/ExportRhService.php b/module/ExportRh/src/Service/ExportRhService.php index 59718afa5a0c9999f2198a0de82165349d67377a..5ecb388d4b14e751e9bcebc6df2355ee91d7efdf 100644 --- a/module/ExportRh/src/Service/ExportRhService.php +++ b/module/ExportRh/src/Service/ExportRhService.php @@ -3,6 +3,7 @@ namespace ExportRh\Service; use Application\Service\AbstractService; +use Application\Service\Traits\IntervenantServiceAwareTrait; use Application\Service\Traits\ParametresServiceAwareTrait; use ExportRh\Entity\IntervenantRHExportParams; @@ -14,6 +15,7 @@ use ExportRh\Entity\IntervenantRHExportParams; class ExportRhService extends AbstractService { use ParametresServiceAwareTrait; + use IntervenantServiceAwareTrait; /** * @var IntervenantRHExportParams @@ -31,11 +33,31 @@ class ExportRhService extends AbstractService - public function getIntervenantRh($params) + public function getListIntervenantRh($nomUsuel, $prenom, $insee) { - $this->connecteur->rechercherIntervenantRH($params); - return true; + $listIntervenantRh = $this->connecteur->rechercherIntervenantRH($nomUsuel, $prenom, $insee); + $intervenantService = $this->getServiceIntervenant(); + if (!empty($listIntervenantRh)) { + foreach ($listIntervenantRh as $key => $intervenantRh) { + $intervenant = $intervenantService->getByCodeRh($intervenantRh->getCodeRh()); + if ($intervenant) { + $intervenantRh->setIntervenant($intervenant); + $listIntervenantRh[$key] = $intervenantRh; + } + } + } + + return $listIntervenantRh; + } + + + + public function getIntervenantRh($intervenant) + { + $intervenantRh = $this->connecteur->trouverIntervenantRh($intervenant); + + return $intervenantRh; } diff --git a/module/UnicaenSiham/src/UnicaenSiham/Service/Factory/SihamClientFactory.php b/module/UnicaenSiham/src/UnicaenSiham/Service/Factory/SihamClientFactory.php index 55bc00de6d38dfdb2337ca6d5ee93cd061ece5bb..77b8692e1cb802c6a8cc54b856e4afa2627cb220 100644 --- a/module/UnicaenSiham/src/UnicaenSiham/Service/Factory/SihamClientFactory.php +++ b/module/UnicaenSiham/src/UnicaenSiham/Service/Factory/SihamClientFactory.php @@ -17,19 +17,4 @@ class SihamClientFactory return new SihamClient($wsdl, $soapParams); } - /* public function __invoke(ContainerInterface $container): SoapClient - { - - $moduleConfig = $container->get(ModuleConfig::class); - - $soapClientConfig = $moduleConfig->getSoapClientConfig(); - - return new SoapClient($soapClientConfig); - } - - - - - - */ } diff --git a/module/UnicaenSiham/src/UnicaenSiham/Service/Siham.php b/module/UnicaenSiham/src/UnicaenSiham/Service/Siham.php index b5a44a0375beb05227d6bd0b059ec6884b561cb8..2708277c3d345863c0d446180555eabe3a408a7b 100644 --- a/module/UnicaenSiham/src/UnicaenSiham/Service/Siham.php +++ b/module/UnicaenSiham/src/UnicaenSiham/Service/Siham.php @@ -162,7 +162,7 @@ class Siham $agents = []; $paramsWS = ['ParamRecupListeAgents' => [ - 'codeEtablissement' => (isset($params['codeEtablissement'])) ? $params['codeEtablissement'] : '', + 'codeEtablissement' => $this->codeEtablissement, 'nomUsuel' => (isset($params['nomUsuel'])) ? strtoupper($params['nomUsuel']) : '', 'nomPatronymique' => (isset($params['nomPatronymique'])) ? strtoupper($params['nomPatronymique']) : '', 'prenom' => (isset($params['prenom'])) ? strtoupper($params['prenom']) : '', @@ -177,6 +177,7 @@ class Siham try { $client = $this->sihamClient->getClient('ListeAgentsWebService'); $result = $client->recupListeAgents($paramsWS); + if (isset($result->return)) { if (is_array($result->return)) { foreach ($result->return as $values) {