Commit 3e14d568 authored by Antony Le Courtes's avatar Antony Le Courtes
Browse files

WIP module export RH

parent 1aed81d1
......@@ -19,11 +19,18 @@
"unicaen/import" : "3.1.5",
"unicaen/tbl" : "4.1",
"unicaen/open-document" : "3.0.2",
"ocramius/proxy-manager" : "2.2.3"
"ocramius/proxy-manager" : "2.2.3",
"unicaen/siham" : "dev-master"
},
"require-dev" : {
"zendframework/zend-test" : "3.3.0",
"zendframework/zend-developer-tools": "1.2.3",
"unicaen/php-compat" : "dev-master"
}
},
"repositories": [
{
"type": "vcs",
"url" : "https://git.unicaen.fr/lib/unicaen/siham.git"
}
]
}
This diff is collapsed.
......@@ -519,11 +519,14 @@ class IntervenantController extends AbstractController
$intervenantDossierValidation = $this->getServiceDossier()->getValidation($intervenant);
$typeIntervenant = $intervenant->getStatut()->getTypeIntervenant()->getCode();
$test = $this->getSihamConnecteur();
$test->test();
$sihamConnecteur = $this->getSihamConnecteur();
$intervenantRH = $sihamConnecteur->rechercherIntervenant($intervenant);
if (!$intervenant) {
$this->flashMessenger()->addErrorMessage("Aucun intervenant n'a été trouvé dans le SIRH");
}
return compact('typeIntervenant', 'intervenant', 'intervenantDossier', 'intervenantDossierValidation');
return compact('typeIntervenant', 'intervenant', 'intervenantRH', 'intervenantDossier', 'intervenantDossierValidation');
}
......
......@@ -34,7 +34,7 @@ if ($this->isAllowed(Privileges::getResourceId(Privileges::INTERVENANT_EDITION))
];
}
if ($this->isAllowed(Privileges::getResourceId(Privileges::INTERVENANT_EDITION))) {
if ($this->isAllowed(Privileges::getResourceId(Privileges::INTERVENANT_EXPORTER))) {
$tabs[] = [
'id' => 'export-rh',
'label' => '<span class="glyphicon glyphicon-export"></span> Export RH',
......
......@@ -3,14 +3,12 @@
namespace ExportRh;
use Application\Provider\Privilege\Privileges;
use ExportRh\Connecteur\Siham\SihamConnecteur;
use ExportRh\Connecteur\Siham\SihamConnecteurFactory;
use UnicaenAuth\Guard\PrivilegeController;
return [
'export-rh' => [
'siham-ws' => [],
],
'router' => [
'routes' => [
'export-rh' => [
......@@ -31,6 +29,18 @@ return [
],
],
'child_routes' => [
'chercher-intervenant-rh' => [
'type' => 'Literal',
'may_terminate' => true,
'options' => [
'route' => '/chercher-intervenant-rh',
'defaults' => [
'controller' => Controller\AdministrationController::class,
'action' => 'chercher-intervenant-rh',
],
],
],
],
],
......@@ -53,6 +63,14 @@ return [
'order' => 82,
'border - color' => '#111',
'pages' => [
'chercher-intervenant-rh' => [
'label' => 'Rechercher un intervenant dans le SI RH',
'icon' => 'fa fa-graduation-cap',
'route' => 'export-rh/administration/chercher-intervenant-rh',
'resource' => PrivilegeController::getResourceId(Controller\AdministrationController::class, 'chercher-intervenant-rh'),
'order' => 800,
'border-color' => '#BBCF55',
],
],
],
],
......@@ -67,7 +85,7 @@ return [
PrivilegeController::class => [
[
'controller' => Controller\AdministrationController::class,
'action' => ['index'],
'action' => ['index', 'chercher-intervenant-rh'],
'privileges' => [Privileges::INTERVENANT_STATUT_VISUALISATION],
],
],
......@@ -76,8 +94,8 @@ return [
'service_manager' => [
'factories' => [
Service\ExportRhService::class => Service\ExportRhServiceFactory::class,
Connecteur\Siham\SihamConnecteur::class => Connecteur\Siham\SihamConnecteurFactory::class,
Service\ExportRhService::class => Service\ExportRhServiceFactory::class,
SihamConnecteur::class => SihamConnecteurFactory::class,
],
],
'view_helpers' => [
......@@ -86,7 +104,6 @@ return [
],
'controllers' => [
'factories' => [
//'ExportRh\Controller\Index' => Controller\IndexControllerFactory::class,
Controller\AdministrationController::class => Controller\AdministrationControllerFactory::class,
],
],
......
......@@ -4,8 +4,9 @@ namespace ExportRh\Connecteur;
use ExportRh\Entity\Intervenant;
use ExportRh\Entity\IntervenantRH;
interface ExportRhInterface
interface ConnecteurRhInterface
{
/**
* Recherche dans le SIRH la liste des fiches intervenant qui peuvent correspondre à l'intervenant fourni
......@@ -14,7 +15,11 @@ interface ExportRhInterface
*
* @return array
*/
public function intervenantEquivalents(\Application\Entity\Db\Intervenant $intervenant): Intervenant;
public function rechercherIntervenant($nomUsuel, $prenom, $insee, $dateNaissance): ?IntervenantRH;
public function trouverIntervenant(\Application\Entity\Db\Intervenant $intervenant): ?IntervenantRH;
......@@ -23,5 +28,5 @@ interface ExportRhInterface
*
* @return bool
*/
public function intervenantExport(Intervenant $intervenant): bool;
public function exporterIntervenant(Intervenant $intervenant): bool;
}
\ No newline at end of file
......@@ -3,42 +3,80 @@
namespace ExportRh\Connecteur\Siham;
use ExportRh\Connecteur\ExportRhInterface;
use ExportRh\Connecteur\ConnecteurRhInterface;
use ExportRh\Entity\Intervenant;
use ExportRh\Entity\IntervenantRH;
use UnicaenSiham\Service\Siham;
class SihamConnecteur implements ExportRhInterface
class SihamConnecteur implements ConnecteurRhInterface
{
/**
* @var array
*/
private $config = [];
public Siham $siham;
public function __construct(array $config)
public function __construct(Siham $siham)
{
$this->config = $config;
$this->siham = $siham;
}
public function intervenantEquivalents(\Application\Entity\Db\Intervenant $intervenant): Intervenant
public function rechercherIntervenant($nom, $prenom, $insee, $dateNaissance): ?IntervenantRH
{
$params = [
'nomUsuel' => $nom,
];
$result = $this->siham->rechercherAgent($params);
$intervenantRH = new IntervenantRH();
$intervenantRH->setNomUsuel($result->getNomUsuel());
return $intervenantRH;
}
public function trouverIntervenant(\Application\Entity\Db\Intervenant $intervenant): ?IntervenantRH
{
$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());
}
return $intervenantRH;
}
public
function prendreEnChargeIntervenant(\Application\Entity\Db\Intervenant $intervenant): Intervenant
{
}
public function intervenantExport(Intervenant $intervenant): bool
public
function exporterIntervenant(Intervenant $intervenant): bool
{
// TODO: Implement intervenantExport() method.
}
public function test()
public
function test()
{
echo 'test réussi';
var_dump($this->config);
}
}
\ No newline at end of file
......@@ -4,7 +4,6 @@ namespace ExportRh\Connecteur\Siham;
use Psr\Container\ContainerInterface;
use UnicaenSiham\Service\Siham;
use UnicaenSiham\Service\SihamClient;
class SihamConnecteurFactory
{
......@@ -13,24 +12,14 @@ class SihamConnecteurFactory
* @param string $requestedName
* @param array|null $options
*
* @return LdapConnecteur
* @return SihamConnecteur
*/
public function __invoke(ContainerInterface $container, $requestedName, $options = null)
{
$config = $container->get('Config');
$client = new Siham();
var_dump($client);
$siham = $container->get(Siham::class);
$sihamConnecteur = new SihamConnecteur($siham);
$configSiham = [];
if (isset($config['export-rh']['siham-ws'])) {
$configSiham = $config['export-rh']['siham-ws'];
}
$service = new SihamConnecteur(
$configSiham,
);
return $service;
return $sihamConnecteur;
}
}
\ No newline at end of file
......@@ -5,18 +5,55 @@ namespace ExportRh\Controller;
use Application\Controller\AbstractController;
use ExportRh\Service\ExportRhServiceAwareTrait;
class AdministrationController extends AbstractController
{
use ExportRhServiceAwareTrait;
public function __construct()
{
}
public function indexAction()
{
$erhs = $this->getExportRhService();
$intervenantParams = $erhs->getIntervenantExportParams();
$champs = $erhs->getIntervenantParamsDescription();
$intervenantParams = $erhs->getIntervenantRHExportParams();
$champs = $erhs->getIntervenantRHParamsDescription();
return compact('intervenantParams', 'champs');
}
public function chercherIntervenantRhAction(): array
{
$connecteurRh = $this->getExportRhService();
$connecteurRh->getIntervenantRh([]);
$params = [
'nomUsuel' => '',
'prenom' => '',
];
$agents = [];
try {
if ($this->getRequest()->isPost()) {
$params['nomUsuel'] = $this->getRequest()->getPost('nomUsuel');
$params['prenom'] = $this->getRequest()->getPost('prenom');
//$agents = $this->siham->rechercherAgent($params);
}
} catch (SihamException $e) {
$this->flashMessenger()->addErrorMessage($e->getMessage());
}
return compact('agents');
}
}
......@@ -3,6 +3,7 @@
namespace ExportRh\Controller;
use Psr\Container\ContainerInterface;
use UnicaenSiham\Service\Siham;
/**
......@@ -22,7 +23,9 @@ class AdministrationControllerFactory
*/
public function __invoke(ContainerInterface $container, $requestedName, $options = null)
{
$controller = new AdministrationController();
$siham = $container->get(Siham::class);
$controller = new AdministrationController($siham);
return $controller;
}
......
<?php
namespace ExportRh\Entity;
use Application\Entity\Db\AdresseNumeroCompl;
use Application\Entity\Db\Civilite;
use Application\Entity\Db\Departement;
use Application\Entity\Db\Discipline;
use Application\Entity\Db\Grade;
use Application\Entity\Db\Pays;
use Application\Entity\Db\StatutIntervenant;
use Application\Entity\Db\Structure;
use Application\Entity\Db\Voirie;
class Intervenant
{
public string $code;
public ?string $codeRh;
public ?string $utilisateurCode;
public ?Structure $structure;
public StatutIntervenant $statut;
public ?Grade $grade;
public ?Discipline $discipline;
public ?Civilite $civilite;
public string $nomUsuel;
public string $prenom;
public \DateTime $dateNaissance;
public ?string $nomPatronymique;
public ?string $communeNaissance;
public ?Pays $paysNaissance;
public ?Departement $departementNaissance;
public ?Pays $paysNationalite;
public ?string $telPro;
public ?string $telPerso;
public ?string $emailPro;
public ?string $emailPerso;
public ?string $adressePrecisions;
public ?string $adresseNumero;
public ?AdresseNumeroCompl $adresseNumeroCompl;
public ?Voirie $adresseVoirie;
public ?string $adresseVoie;
public ?string $adresseLieuDit;
public ?string $adresseCodePostal;
public ?string $adresseCommune;
public ?Pays $adressePays;
public ?string $numeroInsee;
public bool $numeroInseeProvisoire = false;
public ?string $IBAN;
public ?string $BIC;
public bool $ribHorsSepa = false;
public ?string $autre1;
public ?string $autre2;
public ?string $autre3;
public ?string $autre4;
public ?string $autre5;
public ?Employeur $employeur;
public ?\DateTime $validiteDebut;
public ?\DateTime $validiteFin;
public ?string $sourceCode;
/**
* Retourne la représentation littérale de cet objet.
*
* @return string
*/
public function __toString()
{
return strtoupper($this->nomUsuel) . ' ' . ucfirst($this->prenom);
}
public function toArray(): array
{
$array = [];
$vars = get_class_vars(__CLASS__);
foreach ($vars as $var => $null) {
$array[$var] = $this->$var;
}
return $array;
}
public function fromArray(array $array): self
{
$vars = get_class_vars(__CLASS__);
foreach ($vars as $var => $default) {
if (array_key_exists($var, $array)) {
$this->$var = $array[$var];
} else {
$this->$var = $default;
}
}
return $this;
}
public function fromIntervenant(\Application\Entity\Db\Intervenant $intervenant): self
{
$vars = get_class_vars(__CLASS__);
foreach ($vars as $var => $null) {
$this->$var = $intervenant->{'get' . ucfirst($var)}();
}
return $this;
}
}
\ No newline at end of file
<?php
namespace ExportRh\Entity;
use Application\Entity\Db\AdresseNumeroCompl;
use Application\Entity\Db\Civilite;
use Application\Entity\Db\Departement;
use Application\Entity\Db\Discipline;
use Application\Entity\Db\Grade;
use Application\Entity\Db\Pays;
use Application\Entity\Db\StatutIntervenant;
use Application\Entity\Db\Structure;
use Application\Entity\Db\Voirie;
class IntervenantRH
{
public ?string $code;
public ?string $codeRh;
public ?string $utilisateurCode;
public ?Structure $structure;
public StatutIntervenant $statut;
public ?Grade $grade;
public ?Discipline $discipline;
public ?Civilite $civilite;
public string $nomUsuel;
public string $prenom;
public \DateTime $dateNaissance;
public ?string $nomPatronymique;
public ?string $communeNaissance;
public ?Pays $paysNaissance;
public ?Departement $departementNaissance;
public ?Pays $paysNationalite;
public ?string $telPro;
public ?string $telPerso;
public ?string $emailPro;
public ?string $emailPerso;
public ?string $adressePrecisions;
public ?string $adresseNumero;
public ?AdresseNumeroCompl $adresseNumeroCompl;
public ?Voirie $adresseVoirie;
public ?string $adresseVoie;
public ?string $adresseLieuDit;
public ?string $adresseCodePostal;
public ?string $adresseCommune;
public ?Pays $adressePays;
public ?string $numeroInsee;
public bool $numeroInseeProvisoire = false;
public ?string $IBAN;
public ?string $BIC;