diff --git a/module/ExportRh/config/module.config.php b/module/ExportRh/config/module.config.php index 51ffc8fab7d0eb854fa77d8785627f5112c982d6..bc0eea02340dbce14d0c3dd2732ea7ac8e4ccafa 100644 --- a/module/ExportRh/config/module.config.php +++ b/module/ExportRh/config/module.config.php @@ -6,6 +6,8 @@ use Application\Provider\Privilege\Privileges; use ExportRh\Assertion\ExportRhAssertion; use ExportRh\Connecteur\Siham\SihamConnecteur; use ExportRh\Connecteur\Siham\SihamConnecteurFactory; +use ExportRh\Form\ExportRhForm; +use ExportRh\Form\Factory\ExportRhFormFactory; use UnicaenAuth\Guard\PrivilegeController; use UnicaenAuth\Provider\Rule\PrivilegeRuleProvider; @@ -32,6 +34,17 @@ return [ ], ], ], + 'pec' => [ + 'type' => 'Segment', + 'may_terminate' => false, + 'options' => [ + 'route' => '/:intervenant/pec', + 'defaults' => [ + 'controller' => Controller\ExportRhController::class, + 'action' => 'prise-en-charge', + ], + ], + ], 'administration' => [ 'type' => 'Literal', 'may_terminate' => true, @@ -107,7 +120,7 @@ return [ ], [ 'controller' => Controller\ExportRhController::class, - 'action' => ['exporter'], + 'action' => ['exporter', 'prise-en-charge'], 'privileges' => [Privileges::EXPORT_RH_SYNC], 'assertion' => ExportRhAssertion::class, @@ -150,4 +163,9 @@ return [ __DIR__ . '/../view', ], ], + 'form_elements' => [ + 'factories' => [ + ExportRhForm::class => ExportRhFormFactory::class, + ], + ], ]; diff --git a/module/ExportRh/src/Connecteur/ConnecteurRhInterface.php b/module/ExportRh/src/Connecteur/ConnecteurRhInterface.php index 23c4db78e1bcbffcf26cc4ddb64ec59b612ccd0f..bda2dddc10e9d23b2fc3549c4988a90bb128a381 100644 --- a/module/ExportRh/src/Connecteur/ConnecteurRhInterface.php +++ b/module/ExportRh/src/Connecteur/ConnecteurRhInterface.php @@ -4,16 +4,11 @@ namespace ExportRh\Connecteur; use ExportRh\Entity\IntervenantRh; +use Zend\Form\Fieldset; interface ConnecteurRhInterface { - /** - * Recherche dans le SIRH la liste des fiches intervenant qui peuvent correspondre à l'intervenant fourni - * - * @param Intervenant $intervenant - * - * @return array - */ + public function rechercherIntervenantRh($nomUsuel = '', $prenom = '', $insee = ''): array; @@ -22,14 +17,14 @@ interface ConnecteurRhInterface - public function prendreEnChargeIntervenantRh(\Application\Entity\Db\Intervenant $intervenant): ?IntervenantRh; + public function prendreEnChargeIntervenantRh(\Application\Entity\Db\Intervenant $intervenant, array $postData): ?string; - public function recupererListeUO(): ?array; + public function getConnecteurName(): string; - public function recupererListePositions(): ?array; + public function recupererFieldsetConnecteur(): ?Fieldset; } \ 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 d3c274a34ecf9fb781a6b40dc45398fc20780a42..9ce02bf2ec1ebab6a8e3a1c3b1d2889d16abce35 100644 --- a/module/ExportRh/src/Connecteur/Siham/SihamConnecteur.php +++ b/module/ExportRh/src/Connecteur/Siham/SihamConnecteur.php @@ -3,13 +3,19 @@ namespace ExportRh\Connecteur\Siham; +use Application\Entity\Db\Intervenant; +use Application\Service\Traits\DossierServiceAwareTrait; use ExportRh\Connecteur\ConnecteurRhInterface; use ExportRh\Entity\IntervenantRh; +use ExportRh\Form\Fieldset\SihamFieldset; +use UnicaenSiham\Exception\SihamException; use UnicaenSiham\Service\Siham; +use Zend\Form\Fieldset; class SihamConnecteur implements ConnecteurRhInterface { + use DossierServiceAwareTrait; public Siham $siham; @@ -57,10 +63,9 @@ class SihamConnecteur implements ConnecteurRhInterface public function trouverIntervenantRh(\Application\Entity\Db\Intervenant $intervenant): ?IntervenantRh { - $intervenantRh = null; if (!empty($intervenant->getCodeRh())) { $codeRh = $intervenant->getCodeRh(); - //Si code RH + //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); } @@ -90,9 +95,127 @@ class SihamConnecteur implements ConnecteurRhInterface - public function prendreEnChargeIntervenantRh(\Application\Entity\Db\Intervenant $intervenant): ?IntervenantRh + public function prendreEnChargeIntervenantRh(\Application\Entity\Db\Intervenant $intervenant, $datas): ?string { + try { + /* Récupération du dossier de l'intervenant */ + $dossierIntervenant = $this->getServiceDossier()->getByIntervenant($intervenant); + + /* Récupération du dossier de l'intervenant */ + $dossierIntervenant = $this->getServiceDossier()->getByIntervenant($intervenant); + + /*POSITION ADMINISTRATIVE*/ + $position[] = + ['dateEffetPosition' => $datas['connecteurForm']['anneeUniversitaire'], + 'position' => $datas['connecteurForm']['position']]; + + /*STATUT*/ + $statut[] = + ['dateEffetStatut' => $datas['connecteurForm']['anneeUniversitaire'], + 'statut' => $datas['connecteurForm']['statut']]; + + /*MODALITE SERVICE*/ + $service[] = + ['dateEffetModalite' => $datas['connecteurForm']['anneeUniversitaire'], + 'modalite' => $datas['connecteurForm']['modaliteService']]; + + /*COORDONNEES POSTALES*/ + $adresse = ''; + $adresse .= (!empty($dossierIntervenant->getAdresseNumero())) ? $dossierIntervenant->getAdresseNumero() . ' ' : ''; + $adresse .= (!empty($dossierIntervenant->getAdresseNumeroCompl())) ? $dossierIntervenant->getAdresseNumeroCompl() . ' ' : ''; + $adresse .= (!empty($dossierIntervenant->getAdresseVoirie())) ? $dossierIntervenant->getAdresseVoirie() . ' ' : ''; + $adresse .= (!empty($dossierIntervenant->getAdresseVoie())) ? $dossierIntervenant->getAdresseVoie() . ' ' : ''; + $adresse .= (!empty($dossierIntervenant->getAdressePrecisions())) ? $dossierIntervenant->getAdressePrecisions() . ' ' : ''; + + $coordonneesPostales[] = [ + 'bureauDistributeur' => $dossierIntervenant->getAdresseCommune(), + 'complementAdresse' => $adresse, + 'commune' => $dossierIntervenant->getAdresseCommune(), + 'codePostal' => $dossierIntervenant->getAdresseCodePostal(), + 'codePays' => $dossierIntervenant->getAdressePays()->getCode(), + 'debutAdresse' => $datas['connecteurForm']['anneeUniversitaire'], + ]; + + /*COORDONNEES BANCAIRES + $coordonnees = $this->siham->formatCoordoonneesBancairesForSiham($dossierIntervenant->getIBAN(), $dossierIntervenant->getBIC()); + $coordonnees['dateDebBanque'] = $this->getRequest()->getPost('anneeUniversitaire'); + $coordonnees['temoinValidite'] = '1'; + $coordonnees['modePaiement'] = '25'; + $coordonneesBancaires[] = $coordonnees;*/ + + /*COORDONNEES TELEPHONIQUES ET MAIL*/ + /*'dateDebutTel' => (isset($numero['dateDebutTel'])) ? strtoupper($numero['dateDebutTel']) : '', + 'numero' => (isset($numero['numero'])) ? strtoupper($numero['numero']) : '', + 'typeNumero'*/ + $coordonneesTelMail[] = ''; + if ($dossierIntervenant->getTelPro()) { + $coordonneesTelMail[] = [ + 'dateDebutTel' => $datas['connecteurForm']['anneeUniversitaire'], + 'numero' => $dossierIntervenant->getTelPro(), + 'typeNumero' => Siham::SIHAM_CODE_TYPOLOGIE_FIXE_PRO, + ]; + } + if ($dossierIntervenant->getTelPerso()) { + $coordonneesTelMail[] = [ + 'dateDebutTel' => $datas['connecteurForm']['anneeUniversitaire'], + 'numero' => $dossierIntervenant->getTelPerso(), + 'typeNumero' => Siham::SIHAM_CODE_TYPOLOGIE_PORTABLE_PERSO, + ]; + } + if ($dossierIntervenant->getEmailPro()) { + $coordonneesTelMail[] = [ + 'dateDebutTel' => $datas['connecteurForm']['anneeUniversitaire'], + 'numero' => $dossierIntervenant->getEmailPro(), + 'typeNumero' => Siham::SIHAM_CODE_TYPOLOGIE_EMAIL_PRO, + ]; + } + if ($dossierIntervenant->getEmailPerso()) { + $coordonneesTelMail[] = [ + 'dateDebutTel' => $datas['connecteurForm']['anneeUniversitaire'], + 'numero' => $dossierIntervenant->getEmailPerso(), + 'typeNumero' => Siham::SIHAM_CODE_TYPOLOGIE_EMAIL_PERSO, + ]; + } + /*NATIONALITES*/ + $nationalites[] = [ + 'nationalite' => 'FRA',//$dossierIntervenant->getPaysNationalite()->getCode(), + 'temPrincipale' => 1, + ]; + + $params = [ + 'categorieEntree' => 'ACTIVE', + 'civilite' => ($dossierIntervenant->getCivilite() == 'M.') ? '1' : '2', + 'dateEmbauche' => $datas['connecteurForm']['anneeUniversitaire'], + 'dateNaissance' => $dossierIntervenant->getDateNaissance()->format('Y-m-d'), + 'villeNaissance' => $dossierIntervenant->getCommuneNaissance(), + 'departementNaissance' => (!empty($dossierIntervenant->getDepartementNaissance())) ? substr(1, 2, $dossierIntervenant->getDepartementNaissance()->getCode()) : '', + 'emploi' => $datas['connecteurForm']['emploi'], + 'listeCoordonneesPostales' => $coordonneesPostales, + 'listeCoordonneesBancaires' => '',//$coordonneesBancaires, + 'listeModalitesServices' => $service, + 'listeStatuts' => $statut, + 'listeNationalites' => $nationalites, + 'listeNumerosTelephoneFax' => $coordonneesTelMail, + 'listePositions' => $position, + 'motifEntree' => 'PEC', + 'nomPatronymique' => $dossierIntervenant->getNomPatronymique(), + 'nomUsuel' => $dossierIntervenant->getNomUsuel(), + 'numeroInsee' => $dossierIntervenant->getNumeroInsee(), + 'paysNaissance' => '', + 'prenom' => $dossierIntervenant->getPrenom(), + 'sexe' => ($dossierIntervenant->getCivilite() == 'M.') ? '1' : '2', + 'temoinValidite' => '1', + 'UO' => $datas['connecteurForm']['affectation'], + ]; + + $matricule = $this->siham->priseEnChargeAgent($params); + + + return $matricule; + } catch (SihamException $e) { + throw new \Exception($e->getMessage()); + } } @@ -126,4 +249,34 @@ class SihamConnecteur implements ConnecteurRhInterface return $this->siham->recupererListeEmplois(); } + + + public function recupererListeStatuts(): array + { + return $this->siham->recupererListeStatuts(); + } + + + + public function recupererListeModalites(): array + { + return $this->siham->recupererListeModalites(); + } + + + + public function getConnecteurName(): string + { + return 'siham'; + } + + + + public function recupererFieldsetConnecteur(): Fieldset + { + $fieldset = new SihamFieldset('connecteurForm', []); + + return $fieldset; + } + } \ No newline at end of file diff --git a/module/ExportRh/src/Controller/ExportRhController.php b/module/ExportRh/src/Controller/ExportRhController.php index 04d25908092eca166a5b56212866713e6cef326b..adb0f6f31dcc47cfbd5b85c8ef3e60dd7c4329cb 100644 --- a/module/ExportRh/src/Controller/ExportRhController.php +++ b/module/ExportRh/src/Controller/ExportRhController.php @@ -6,8 +6,11 @@ namespace ExportRh\Controller; use Application\Controller\AbstractController; use Application\Service\Traits\ContextServiceAwareTrait; use Application\Service\Traits\DossierServiceAwareTrait; +use ExportRh\Form\ExportRhForm; +use ExportRh\Form\Traits\ExportRhFormAwareTrait; use ExportRh\Service\ExportRhService; use ExportRh\Service\ExportRhServiceAwareTrait; +use UnicaenSiham\Exception\SihamException; class ExportRhController extends AbstractController { @@ -15,6 +18,7 @@ class ExportRhController extends AbstractController use ExportRhServiceAwareTrait; use ContextServiceAwareTrait; use DossierServiceAwareTrait; + use ExportRhFormAwareTrait; /** * @var ExportRhService $exportRhService @@ -81,20 +85,53 @@ 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); + /*Scénario 1 : Intervenant non présent dans le SI RH*/ + $form = $this->getExportRhForm(); - $intervenantRh = $this->exportRhService->getIntervenantRh($intervenant); - if (!$intervenantRh) { - $this->flashMessenger()->addErrorMessage("Aucun intervenant n'a été trouvé dans le SIRH"); - } - //Récupération des unités organisationnelles SIHAM dans le cadre d'une prise en charge - $uo = $this->exportRhService->getListeUO(); - $positions = $this->exportRhService->getListePositions(); - $emplois = $this->exportRhService->getListeEmplois(); + /*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(); + + + return compact('typeIntervenant', + 'intervenant', + 'intervenantRh', + 'intervenantDossier', + 'intervenantDossierValidation', + 'form', + 'nameConnecteur'); + } + + + + public function priseEnChargeAction() + { + try { + if ($this->getRequest()->isPost()) { + $intervenant = $this->getEvent()->getParam('intervenant'); + + if (!$intervenant) { + throw new \LogicException('Intervenant non précisé ou inexistant'); + } + + $posts = $this->getRequest()->getPost(); - return compact('typeIntervenant', 'intervenant', 'intervenantRh', 'intervenantDossier', 'intervenantDossierValidation', 'uo', 'positions', 'emplois'); + $result = $this->exportRhService->priseEnChargeIntrervenantRh($intervenant, $posts); + if ($result !== false) { + $this->flashMessenger()->addSuccessMessage('succes matricule : ' . $result); + } else { + $this->flashMessenger()->addErrorMessage('Probleme prise en charge'); + } + } + } catch (\Exception $e) { + $this->flashMessenger()->addErrorMessage($e->getMessage()); + } + + return $this->redirect()->toRoute('intervenant/exporter', [], [], true); } } diff --git a/module/ExportRh/src/Form/ExportRhForm.php b/module/ExportRh/src/Form/ExportRhForm.php new file mode 100644 index 0000000000000000000000000000000000000000..1bab9a666b84ecedfedd879d49c7451de62a06f2 --- /dev/null +++ b/module/ExportRh/src/Form/ExportRhForm.php @@ -0,0 +1,57 @@ +<?php + +namespace ExportRh\Form; + +use Application\Form\AbstractForm; +use ExportRh\Form\Fieldset\GeneriqueFieldset; +use Zend\Form\Fieldset; + +class ExportRhForm extends AbstractForm +{ + + protected $fieldsetConnecteur = null; + + + + public function __construct(?Fieldset $fieldsetConnecteur) + { + $this->fieldsetConnecteur = $fieldsetConnecteur; + parent::__construct('ExportRhForm', []); + } + + + + public function init() + { + $this->setAttribute('action', $this->getCurrentUrl()); + //Partie générique du formulaire + $generiqueFieldset = new GeneriqueFieldset('generiqueFieldset', []); + $this->add($generiqueFieldset->init()); + //Partie sépcifique au connecteur SI RH + $this->add($this->fieldsetConnecteur->init()); + + + $this->add([ + 'name' => 'submit - button', + 'type' => 'Submit', + 'attributes' => [ + 'value' => "Enregistrer", + 'class' => 'btn btn - primary', + ], + ]); + } + + + + /** + * Should return an array specification compatible with + * {@link Zend\InputFilter\Factory::createInputFilter()}. + * + * @return array + */ + public function getInputFilterSpecification() + { + return []; + } +} + diff --git a/module/ExportRh/src/Form/Factory/ExportRhFormFactory.php b/module/ExportRh/src/Form/Factory/ExportRhFormFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..1eb7e0666e9152d3c57355ec6535a2abb8b77829 --- /dev/null +++ b/module/ExportRh/src/Form/Factory/ExportRhFormFactory.php @@ -0,0 +1,35 @@ +<?php + +namespace ExportRh\Form\Factory; + + +use ExportRh\Connecteur\Siham\SihamConnecteur; +use ExportRh\Form\ExportRhForm; +use Psr\Container\ContainerInterface; + +/** + * Description of ExportRhFormFactory + * + * @author LE COURTES Antony <antony.lecourtes at unicaen.fr> + */ +class ExportRhFormFactory +{ + + public function __invoke(ContainerInterface $container, $requestedName, $options = null) + { + $config = $container->get('Config'); + + switch ($config['export-rh']['connecteur']) { + case 'siham': + $connecteur = $container->get(SihamConnecteur::class); + break; + } + + $fieldset = $connecteur->recupererFieldsetConnecteur(); + + $form = new ExportRhForm($fieldset); + + return $form; + } + +} \ No newline at end of file diff --git a/module/ExportRh/src/Form/Fieldset/GeneriqueFieldset.php b/module/ExportRh/src/Form/Fieldset/GeneriqueFieldset.php new file mode 100644 index 0000000000000000000000000000000000000000..8351c86b08753354a7bcc925631bbd1fc133c543 --- /dev/null +++ b/module/ExportRh/src/Form/Fieldset/GeneriqueFieldset.php @@ -0,0 +1,172 @@ +<?php + +namespace ExportRh\Form\Fieldset; + +use Application\Form\AbstractFieldset; + +class GeneriqueFieldset extends AbstractFieldset +{ + + public function init() + { + //Nom usuel + $this->add([ + 'name' => 'nomUsuel', + 'type' => 'Checkbox', + 'options' => [ + 'label' => "Nom usuel", + ], + 'attributes' => [ + 'value' => 1, + ], + ]); + + //Prénom + $this->add([ + 'name' => 'prenom', + 'type' => 'Checkbox', + 'options' => [ + 'label' => "Prénom", + ], + 'attributes' => [ + 'value' => 1, + ], + ]); + + //Date de naissance + $this->add([ + 'name' => 'dateNaissance', + 'type' => 'Checkbox', + 'options' => [ + 'label' => "Date de naissance", + ], + 'attributes' => [ + 'value' => 1, + ], + ]); + + //Nationalité + $this->add([ + 'name' => 'nationalite', + 'type' => 'Checkbox', + 'options' => [ + 'label' => "Nationalité", + ], + 'attributes' => [ + 'value' => 1, + ], + ]); + + //Adresse principale + $this->add([ + 'name' => 'adressePrincipale', + 'type' => 'Checkbox', + 'options' => [ + 'label' => "Adresse principale", + ], + 'attributes' => [ + 'value' => 1, + ], + ]); + + //Téléphone pro + $this->add([ + 'name' => 'telPro', + 'type' => 'Checkbox', + 'options' => [ + 'label' => "Téléphone pro", + ], + 'attributes' => [ + 'value' => 1, + ], + ]); + + //Téléphone perso + $this->add([ + 'name' => 'telPerso', + 'type' => 'Checkbox', + 'options' => [ + 'label' => "Téléphone perso", + ], + 'attributes' => [ + 'value' => 1, + ], + ]); + + //Email pro + $this->add([ + 'name' => 'emailPro', + 'type' => 'Checkbox', + 'options' => [ + 'label' => "Email pro", + ], + 'attributes' => [ + 'value' => 1, + ], + ]); + + //Email perso + $this->add([ + 'name' => 'emailPerso', + 'type' => 'Checkbox', + 'options' => [ + 'label' => "Email perso", + ], + 'attributes' => [ + 'value' => 1, + ], + ]); + + //numero INSEE + $this->add([ + 'name' => 'numeroInsee', + 'type' => 'Checkbox', + 'options' => [ + 'label' => "Numéro INSEE", + ], + 'attributes' => [ + 'value' => 1, + ], + ]); + + //IBAN + $this->add([ + 'name' => 'iban', + 'type' => 'Checkbox', + 'options' => [ + 'label' => "IBAN", + ], + 'attributes' => [ + 'value' => 1, + ], + ]); + + //BIC + $this->add([ + 'name' => 'bic', + 'type' => 'Checkbox', + 'options' => [ + 'label' => "BIC", + ], + 'attributes' => [ + 'value' => 1, + ], + ]); + + + return $this; + } + + + + public function getInputFilterSpecification() + { + + $spec = [ + + + ]; + + return $spec; + } +} \ No newline at end of file diff --git a/module/ExportRh/src/Form/Fieldset/SihamFieldset.php b/module/ExportRh/src/Form/Fieldset/SihamFieldset.php new file mode 100644 index 0000000000000000000000000000000000000000..fbfb4421fa7ecca1cd2ffdcb107174291a8181de --- /dev/null +++ b/module/ExportRh/src/Form/Fieldset/SihamFieldset.php @@ -0,0 +1,152 @@ +<?php + +namespace ExportRh\Form\Fieldset; + +use Application\Form\AbstractFieldset; +use ExportRh\Connecteur\Siham\SihamConnecteurAwareTrait; + +class SihamFieldset extends AbstractFieldset +{ + use SihamConnecteurAwareTrait; + + public function init() + { + /** + * Année universitaire + */ + $this->add([ + 'name' => 'anneeUniversitaire', + 'options' => [ + 'label' => 'Année universitaire de prise en charge', + 'label_options' => [ + 'disable_html_escape' => true, + ],], + 'attributes' => [ + 'class' => 'form-control anneeUniversitaire', + //'data-live-search' => 'true', + ], + 'type' => 'Select', + ]); + + + $this->get('anneeUniversitaire') + ->setValueOptions(['' => '(Sélectionnez une année de prise en charge)', + '2020-09-01' => '2020/2021', + '2021-09-01' => '2021/2022',]); + + + /** + * Modalite de service + */ + $this->add([ + 'name' => 'modaliteService', + 'options' => [ + 'label' => 'Modalités', + 'label_options' => [ + 'disable_html_escape' => true, + ],], + 'attributes' => [ + 'class' => 'form-control modaliteService', + //'data-live-search' => 'true', + ], + 'type' => 'Select', + ]); + + + $this->get('modaliteService') + ->setValueOptions(['' => '(Sélectionnez une modalité de service)'] + \UnicaenApp\Util::collectionAsOptions($this->getSihamConnecteur()->recupererListeModalites())); + + //Statut + $this->add([ + 'name' => 'statut', + 'options' => [ + 'label' => 'Statut', + 'label_options' => [ + 'disable_html_escape' => true, + ],], + 'attributes' => [ + 'class' => 'form-control statut', + //'data-live-search' => 'true', + ], + 'type' => 'Select', + ]); + + + $this->get('statut') + ->setValueOptions(['' => '(Sélectionnez un statut)'] + \UnicaenApp\Util::collectionAsOptions($this->getSihamConnecteur()->recupererListeStatuts())); + + //Position administrative + $this->add([ + 'name' => 'position', + 'options' => [ + 'label' => 'Position administrative', + 'label_options' => [ + 'disable_html_escape' => true, + ],], + 'attributes' => [ + 'class' => 'form-control position', + //'data-live-search' => 'true', + ], + 'type' => 'Select', + ]); + + + $this->get('position') + ->setValueOptions(['' => '(Sélectionnez une position administrative)'] + \UnicaenApp\Util::collectionAsOptions($this->getSihamConnecteur()->recupererListePositions())); + + //Affectation + $this->add([ + 'name' => 'affectation', + 'options' => [ + 'label' => 'Affectation', + 'label_options' => [ + 'disable_html_escape' => true, + ],], + 'attributes' => [ + 'class' => 'form-control affectation', + //'data-live-search' => 'true', + ], + 'type' => 'Select', + ]); + + + $this->get('affectation') + ->setValueOptions(['' => '(Sélectionnez une affectation)'] + \UnicaenApp\Util::collectionAsOptions($this->getSihamConnecteur()->recupererListeUO())); + + //Type d'emploi + $this->add([ + 'name' => 'emploi', + 'options' => [ + 'label' => 'Type d\'emploi', + 'label_options' => [ + 'disable_html_escape' => true, + ],], + 'attributes' => [ + 'class' => 'form-control emploi', + //'data-live-search' => 'true', + ], + 'type' => 'Select', + ]); + + + $this->get('emploi') + ->setValueOptions(['' => '(Sélectionnez un type d\'emploi)'] + \UnicaenApp\Util::collectionAsOptions($this->getSihamConnecteur()->recupererListeEmplois())); + + return $this; + } + + + + public function getInputFilterSpecification() + { + + $spec = [ + 'nomUsuel' => [ + 'required' => true, + ], + + ]; + + return $spec; + } +} \ No newline at end of file diff --git a/module/ExportRh/src/Form/Traits/ExportRhFormAwareTrait.php b/module/ExportRh/src/Form/Traits/ExportRhFormAwareTrait.php new file mode 100644 index 0000000000000000000000000000000000000000..691c9a6f4feac3c0ad6215dce20286f15dcd9d5e --- /dev/null +++ b/module/ExportRh/src/Form/Traits/ExportRhFormAwareTrait.php @@ -0,0 +1,20 @@ +<?php + +namespace ExportRh\Form\Traits; + + +use ExportRh\Form\ExportRhForm; + +trait ExportRhFormAwareTrait +{ + + /** + * Retourne un nouveau formulaire ou fieldset systématiquement, sauf si ce dernier a été fourni manuellement. + * + * @return ExportRhForm + */ + public function getExportRhForm() + { + return \Application::$container->get('FormElementManager')->get(ExportRhForm::class, []); + } +} \ No newline at end of file diff --git a/module/ExportRh/src/Service/ExportRhService.php b/module/ExportRh/src/Service/ExportRhService.php index 7b108f27d8c6ddd9beb52bb93e7f0c4433b9d0f3..2eb167a3ff6f0efaab2f7714b5708e4b3eae6508 100644 --- a/module/ExportRh/src/Service/ExportRhService.php +++ b/module/ExportRh/src/Service/ExportRhService.php @@ -2,10 +2,12 @@ namespace ExportRh\Service; +use Application\Entity\Db\Intervenant; use Application\Service\AbstractService; use Application\Service\Traits\IntervenantServiceAwareTrait; use Application\Service\Traits\ParametresServiceAwareTrait; use ExportRh\Entity\IntervenantRHExportParams; +use Zend\Form\Fieldset; /** * Description of FonctionReferentiel @@ -98,6 +100,27 @@ class ExportRhService extends AbstractService + public function getListeStatuts() + { + return $this->connecteur->recupererListeStatuts(); + } + + + + public function getListeModalites() + { + return $this->connecteur->recupererListeModalites(); + } + + + + public function priseEnChargeIntrervenantRh(Intervenant $intervenant, $datas) + { + return $this->connecteur->prendreEnChargeIntervenantRh($intervenant, $datas); + } + + + public function getIntervenantRHParamsDescription(): array { $desc = [ @@ -185,4 +208,18 @@ class ExportRhService extends AbstractService return $this; } + + + public function getFieldsetConnecteur(): Fieldset + { + return $this->connecteur->recupererFormulairePriseEnCharge(); + } + + + + public function getConnecteurName(): string + { + return $this->connecteur->getConnecteurName(); + } + } \ No newline at end of file diff --git a/module/ExportRh/src/Service/ExportRhServiceFactory.php b/module/ExportRh/src/Service/ExportRhServiceFactory.php index 1eaeac0848b08ec06778d92f7a4063029d1f144e..396dd491aff5477ce621cbe56904bc06598b60c7 100644 --- a/module/ExportRh/src/Service/ExportRhServiceFactory.php +++ b/module/ExportRh/src/Service/ExportRhServiceFactory.php @@ -26,7 +26,7 @@ class ExportRhServiceFactory $config = $container->get('Config'); switch ($config['export-rh']['connecteur']) { - case 'siham': + default: $connecteur = $container->get(SihamConnecteur::class); break; } diff --git a/module/ExportRh/view/export-rh/export-rh/exporter.phtml b/module/ExportRh/view/export-rh/export-rh/exporter.phtml index fe31f303227a41d13ce4a6e1d7cfed1c0833f333..a8820877684f4e57b86a0109fd347d0419382754 100755 --- a/module/ExportRh/view/export-rh/export-rh/exporter.phtml +++ b/module/ExportRh/view/export-rh/export-rh/exporter.phtml @@ -5,7 +5,10 @@ * @var \Application\Entity\Db\IntervenantDossier $intervenantDossier */ -$intervenant->getNomUsuel() +$form->prepare(); +$generiqueFieldset = $form->get('generiqueFieldset'); +$connecteurFieldset = $form->get('connecteurForm'); + ?> <br/> @@ -18,15 +21,16 @@ $intervenant->getNomUsuel() <?php elseif (empty($intervenantRh)): ?> <?php endif; ?> </div> +<?php echo $this->messenger()->addCurrentMessagesFromFlashMessenger()->addMessagesFromFlashMessenger(); ?> <?php if (empty($intervenantRh)): ?> -<form action="" method="post"> - +<form class="no-intranavigation" action="<?= $this->url('intervenant/pec', ['intervenant' => $intervenant->getId()]) ?>" method="post"> + <!--Partie générique du formulaire--> <div class="panel panel-default"> <div class="panel-heading">Récapitulatif des données personnelles</div> <div class="panel-body"> <? if (empty($intervenantRh)): ?> - <p>L'intervenant XXXX XXXX n'a pas été trouvé dans le SI RH. Vous pouvez si vous le souhaiter prendre en charge cette intervenant avec les données de son dossier, résumées ci-dessous :</p> + <p>L'intervenant <?= $intervenantDossier->getPrenom() . ' ' . $intervenantDossier->getNomUsuel() ?> n'a pas été trouvé dans le SI RH. Vous pouvez si vous le souhaiter prendre en charge cette intervenant avec les données de son dossier, résumées ci-dessous :</p> <table class="table"> <thead> <tr> @@ -37,102 +41,120 @@ $intervenant->getNomUsuel() </thead> <tbody> <tr> - <td><input type="checkbox" checked="checked" name="nomUsuel"/> Nom usuel :</td> + <td> + <?= $this->formCheckbox($generiqueFieldset->get('nomUsuel')); ?> + <?= $this->formLabel($generiqueFieldset->get('nomUsuel')) ?> : + </td> <td><?= $intervenantDossier->getNomUsuel() ?></td> </tr> <tr> - <td><input type="checkbox" checked="checked" name="nomUsuel"/> Prénom :</td> + <td> + <?= $this->formCheckbox($generiqueFieldset->get('prenom')); ?> + <?= $this->formLabel($generiqueFieldset->get('prenom')) ?> : + </td> <td><?= $intervenantDossier->getPrenom() ?></td> </tr> <tr> - <td><input type="checkbox" checked="checked" name="nomUsuel"/> Date de naissance :</td> + <td> + <?= $this->formCheckbox($generiqueFieldset->get('dateNaissance')); ?> + <?= $this->formLabel($generiqueFieldset->get('dateNaissance')) ?> : + </td> <td><?= $intervenantDossier->getDateNaissance()->format('d/m/Y') ?></td> </tr> <tr> - <td><input type="checkbox" checked="checked" name="nomUsuel"/> Numéro INSEE</td> - <td><?= $intervenantDossier->getNumeroInsee() ?></td> + <td> + <?= $this->formCheckbox($generiqueFieldset->get('nationalite')); ?> + <?= $this->formLabel($generiqueFieldset->get('nationalite')) ?> : + </td> + <td><?= $intervenantDossier->getPaysNationalite()->getLibelle() ?></td> + </tr> + <tr> + <td> + <?= $this->formCheckbox($generiqueFieldset->get('adressePrincipale')); ?> + <?= $this->formLabel($generiqueFieldset->get('adressePrincipale')) ?> : + </td> + <td> + <?php + $adresse = ''; + $adresse .= (!empty($intervenantDossier->getAdresseNumero())) ? $intervenantDossier->getAdresseNumero() . ' ' : ''; + $adresse .= (!empty($intervenantDossier->getAdresseNumeroCompl())) ? $intervenantDossier->getAdresseNumeroCompl() . ' ' : ''; + $adresse .= (!empty($intervenantDossier->getAdresseVoirie())) ? $intervenantDossier->getAdresseVoirie() . ' ' : ''; + $adresse .= (!empty($intervenantDossier->getAdresseVoie())) ? $intervenantDossier->getAdresseVoie() . ' ' : ''; + $adresse .= (!empty($intervenantDossier->getAdressePrecisions())) ? '<br/>' . $intervenantDossier->getAdressePrecisions() . ' ' : ''; + $adresse .= '<br/>'; + $adresse .= $intervenantDossier->getAdresseCodePostal() . ' ' . $intervenantDossier->getAdresseCommune(); + echo $adresse; + ?> + </td> </tr> <tr> - <td><input type="checkbox" checked="checked" name="nomUsuel"/> Tel pro :</td> + <td> + <?= $this->formCheckbox($generiqueFieldset->get('telPro')); ?> + <?= $this->formLabel($generiqueFieldset->get('telPro')) ?> : + </td> <td><?= $intervenantDossier->getTelPro() ?></td> </tr> <tr> - <td><input type="checkbox" checked="checked" name="nomUsuel"/> Tel perso :</td> + <td> + <?= $this->formCheckbox($generiqueFieldset->get('telPerso')); ?> + <?= $this->formLabel($generiqueFieldset->get('telPerso')) ?> : + </td> <td><?= $intervenantDossier->getTelPerso() ?></td> </tr> - - </tbody> - </table> - - </div> - </div> - <div class="panel panel-default"> - <div class="panel-heading">Configuration de la prise en charge</div> - <div class="panel-body"> - <p>Veuillez paramétrer la prise en charge de l'agent : </p> - <table class="table"> - <thead> <tr> - <th>Paramètres</th> - <th>Choix</th> - + <td> + <?= $this->formCheckbox($generiqueFieldset->get('emailPro')); ?> + <?= $this->formLabel($generiqueFieldset->get('emailPro')) ?> : + </td> + <td><?= $intervenantDossier->getEmailPro() ?></td> </tr> - </thead> - <tbody> <tr> - <td>Année universitaire de prise en charge :</td> <td> - <select name="anneeUniversitaire" class="form-control"> - <option value="2020-09-01">2020/2021</option> - <option value="2021-09-01">2021/2022</option> - </select> + <?= $this->formCheckbox($generiqueFieldset->get('emailPerso')); ?> + <?= $this->formLabel($generiqueFieldset->get('emailPerso')) ?> : </td> + <td><?= $intervenantDossier->getEmailPerso() ?></td> </tr> <tr> - <td>Type d'emploi :</td> <td> - <select name="emploi" class="form-control"> - <?php foreach ($emplois as $code => $libelle): ?> - <option value="<?= $code ?>"> <?= $libelle ?></option> - <?php endforeach; ?> - </select> + <?= $this->formCheckbox($generiqueFieldset->get('numeroInsee')); ?> + <?= $this->formLabel($generiqueFieldset->get('numeroInsee')) ?> : </td> - </tr> + <td><?= $intervenantDossier->getNumeroInsee() ?></td> + </tr> <tr> - <td>Affectation :</td> <td> - <select name="uo" class="form-control"> - <?php foreach ($uo as $value): ?> - <option value="<?= $value->codeUO ?>"> <?= $value->libLongUO ?></option> - <?php endforeach; ?> - </select> + <?= $this->formCheckbox($generiqueFieldset->get('iban')); ?> + <?= $this->formLabel($generiqueFieldset->get('iban')) ?> : </td> - + <td><?= $intervenantDossier->getIBAN() ?></td> </tr> <tr> - <td>Position administrative :</td> <td> - <select name="position-administrative" class="form-control"> - <?php foreach ($positions as $code => $libelle): ?> - <option value="<?= $code ?>"> <?= $libelle ?></option> - <?php endforeach; ?> - </select> + <?= $this->formCheckbox($generiqueFieldset->get('bic')); ?> + <?= $this->formLabel($generiqueFieldset->get('bic')) ?> : </td> + <td><?= $intervenantDossier->getBIC() ?></td> </tr> - - </tbody> </table> - <p> - <input type="submit" value="Prendre en charge l'agent"/> - </p> + </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 endif; ?> diff --git a/module/ExportRh/view/export-rh/export-rh/siham/connecteurForm.phtml b/module/ExportRh/view/export-rh/export-rh/siham/connecteurForm.phtml new file mode 100644 index 0000000000000000000000000000000000000000..15aebff492e2113b099722002e49070df22f750b --- /dev/null +++ b/module/ExportRh/view/export-rh/export-rh/siham/connecteurForm.phtml @@ -0,0 +1,45 @@ +<div class="panel panel-default"> + <div class="panel-heading">Configuration de la prise en charge</div> + <div class="panel-body"> + <p>Veuillez paramétrer la prise en charge de l'agent : </p> + <table class="table"> + <thead> + <tr> + <th>Paramètres</th> + <th>Choix</th> + + </tr> + </thead> + <tbody> + <tr> + <td><?= $this->formLabel($connecteurFieldset->get('anneeUniversitaire')) ?> :</td> + <td><?= $this->formSelect($connecteurFieldset->get('anneeUniversitaire')); ?></td> + </tr> + <tr> + <td><?= $this->formLabel($connecteurFieldset->get('emploi')) ?> :</td> + <td><?= $this->formSelect($connecteurFieldset->get('emploi')); ?></td> + </tr> + + <tr> + <td><?= $this->formLabel($connecteurFieldset->get('affectation')) ?> :</td> + <td><?= $this->formSelect($connecteurFieldset->get('affectation')); ?></td> + </tr> + <tr> + <td><?= $this->formLabel($connecteurFieldset->get('position')) ?> :</td> + <td><?= $this->formSelect($connecteurFieldset->get('position')); ?></td> + </tr> + <tr> + <td><?= $this->formLabel($connecteurFieldset->get('statut')) ?> :</td> + <td><?= $this->formSelect($connecteurFieldset->get('statut')); ?></td> + </tr> + <tr> + <td><?= $this->formLabel($connecteurFieldset->get('modaliteService')) ?> :</td> + <td><?= $this->formSelect($connecteurFieldset->get('modaliteService')); ?></td> + </tr> + + + </tbody> + </table> + + </div> +</div> \ No newline at end of file diff --git a/module/UnicaenSiham/src/UnicaenSiham/Service/Siham.php b/module/UnicaenSiham/src/UnicaenSiham/Service/Siham.php index 27d466704a18fa9ab7f505897242c135411c3311..8a2712a4ac329da5228502abc561dc8de509ae3a 100644 --- a/module/UnicaenSiham/src/UnicaenSiham/Service/Siham.php +++ b/module/UnicaenSiham/src/UnicaenSiham/Service/Siham.php @@ -22,7 +22,6 @@ class Siham const SIHAM_CODE_TYPOLOGIE_PORTABLE_PERSO = "PPE"; const SIHAM_CODE_TYPOLOGIE_EMAIL_PRO = "MPR"; const SIHAM_CODE_TYPOLOGIE_EMAIL_PERSO = "MPE"; - public const SIHAM_CODE_NOMENCLATURE_STATUT = ""; protected $sihamClient; @@ -75,8 +74,8 @@ class Siham $this->codeNomenclatureFamillesProfessionnelles = (isset($config['code-nomenclature']['familles-professionnelles'])) ? $config['code-nomenclature']['familles-professionnelles'] : ''; $this->codeNomenclatureQualitesStatutaires = (isset($config['code-nomenclature']['qualites-statutaires'])) ? $config['code-nomenclature']['qualites-statutaires'] : ''; $this->codeNomenclatureCategories = (isset($config['code-nomenclature']['categories'])) ? $config['code-nomenclature']['categories'] : ''; - $this->codeNomenclatureContrats = (isset($config['code-nomenclature']['contrats'])) ? $config['code-nomenclature']['contrats'] : ''; - $this->codeNomenclatureStatuts = (isset($config['code-nomenclature']['statut'])) ? $config['code-nomenclature']['statut'] : ''; + $this->codeNomenclatureContrats = (isset($config['code-nomenclature']['type-contrats'])) ? $config['code-nomenclature']['type-contrats'] : ''; + $this->codeNomenclatureStatuts = (isset($config['code-nomenclature']['statuts'])) ? $config['code-nomenclature']['statuts'] : ''; $this->codeNomenclatureModalites = (isset($config['code-nomenclature']['modalites'])) ? $config['code-nomenclature']['modalites'] : ''; $this->codeNomenclaturePositions = (isset($config['code-nomenclature']['positions'])) ? $config['code-nomenclature']['positions'] : ''; $this->codeNomenclatureEchelons = (isset($config['code-nomenclature']['echelons'])) ? $config['code-nomenclature']['echelons'] : ''; @@ -743,6 +742,10 @@ class Siham public function recupererListeStatuts($from = '') { + if (!empty($this->sihamConfig['filters'][$this->codeNomenclatureStatuts])) { + return $this->sihamConfig['filters'][$this->codeNomenclatureStatuts]; + } + $params = ['codeAdministration' => $this->codeAdministration, 'dateObservation' => (!empty($from)) ? $from : date('Y-m-d'), 'listeNomenclatures' => [$this->codeNomenclatureStatuts],]; @@ -767,6 +770,10 @@ class Siham public function recupererListeModalites($from = '') { + if (!empty($this->sihamConfig['filters'][$this->codeNomenclatureModalites])) { + return $this->sihamConfig['filters'][$this->codeNomenclatureModalites]; + } + $params = [ 'codeAdministration' => $this->codeAdministration, 'dateObservation' => $from, @@ -943,7 +950,12 @@ class Siham $result = $client->RecupStructures($paramsWS); if (isset($result->return)) { - return $result->return; + $unitesOrganisationnelles = []; + foreach ($result->return as $value) { + $unitesOrganisationnelles[$value->codeUO] = $value->libLongUO; + } + + return $unitesOrganisationnelles; } } catch (\SoapFault $e) { throw new SihamException($e->faultstring, 0, $e);