Skip to content
Snippets Groups Projects
Commit 01608459 authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

Ajout des fonctions

parent 632acc87
No related branches found
No related tags found
No related merge requests found
Showing
with 625 additions and 1 deletion
...@@ -6,6 +6,8 @@ use Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain; ...@@ -6,6 +6,8 @@ use Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain;
use Doctrine\ORM\Mapping\Driver\XmlDriver; use Doctrine\ORM\Mapping\Driver\XmlDriver;
use Octopus\Controller\OctopusController; use Octopus\Controller\OctopusController;
use Octopus\Controller\OctopusControllerFactory; use Octopus\Controller\OctopusControllerFactory;
use Octopus\Service\Fonction\FonctionService;
use Octopus\Service\Fonction\FonctionServiceFactory;
use Octopus\Service\Geographie\GeographieService; use Octopus\Service\Geographie\GeographieService;
use Octopus\Service\Geographie\GeographieServiceFactory; use Octopus\Service\Geographie\GeographieServiceFactory;
use Octopus\Service\Immobilier\ImmobilierService; use Octopus\Service\Immobilier\ImmobilierService;
...@@ -76,6 +78,7 @@ return [ ...@@ -76,6 +78,7 @@ return [
ImmobilierService::class => ImmobilierServiceFactory::class, ImmobilierService::class => ImmobilierServiceFactory::class,
IndividuService::class => IndividuServiceFactory::class, IndividuService::class => IndividuServiceFactory::class,
GeographieService::class => GeographieServiceFactory::class, GeographieService::class => GeographieServiceFactory::class,
FonctionService::class => FonctionServiceFactory::class,
], ],
], ],
'controllers' => [ 'controllers' => [
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace Octopus\Controller; namespace Octopus\Controller;
use Octopus\Service\Fonction\FonctionServiceAwareTrait;
use Octopus\Service\Geographie\GeographieServiceAwareTrait; use Octopus\Service\Geographie\GeographieServiceAwareTrait;
use Octopus\Service\Immobilier\ImmobilierServiceAwareTrait; use Octopus\Service\Immobilier\ImmobilierServiceAwareTrait;
use Octopus\Service\Individu\IndividuServiceAwareTrait; use Octopus\Service\Individu\IndividuServiceAwareTrait;
...@@ -10,6 +11,7 @@ use Zend\Mvc\Controller\AbstractActionController; ...@@ -10,6 +11,7 @@ use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel; use Zend\View\Model\ViewModel;
class OctopusController extends AbstractActionController { class OctopusController extends AbstractActionController {
use FonctionServiceAwareTrait;
use GeographieServiceAwareTrait; use GeographieServiceAwareTrait;
use ImmobilierServiceAwareTrait; use ImmobilierServiceAwareTrait;
use IndividuServiceAwareTrait; use IndividuServiceAwareTrait;
...@@ -27,6 +29,10 @@ class OctopusController extends AbstractActionController { ...@@ -27,6 +29,10 @@ class OctopusController extends AbstractActionController {
$individus = $this->getIndividuService()->getIndividus(); $individus = $this->getIndividuService()->getIndividus();
$fonctions = $this->getFonctionService()->getFonctions();
$fonctionsLibelles = $this->getFonctionService()->getFonctionsLibelles();
$fonctionsTypes = $this->getFonctionService()->getFonctionsTypes();
$pays = $this->getGeographieService()->getPays('libelleCourt'); $pays = $this->getGeographieService()->getPays('libelleCourt');
return new ViewModel([ return new ViewModel([
...@@ -40,6 +46,10 @@ class OctopusController extends AbstractActionController { ...@@ -40,6 +46,10 @@ class OctopusController extends AbstractActionController {
'individus' => $individus, 'individus' => $individus,
'fonctions' => $fonctions,
'fonctionsLibelles' => $fonctionsLibelles,
'fonctionsTypes' => $fonctionsTypes,
'pays' => $pays, 'pays' => $pays,
]); ]);
} }
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace Octopus\Controller; namespace Octopus\Controller;
use Octopus\Service\Fonction\FonctionService;
use Octopus\Service\Geographie\GeographieService; use Octopus\Service\Geographie\GeographieService;
use Octopus\Service\Immobilier\ImmobilierService; use Octopus\Service\Immobilier\ImmobilierService;
use Octopus\Service\Individu\IndividuService; use Octopus\Service\Individu\IndividuService;
...@@ -17,11 +18,13 @@ class OctopusControllerFactory { ...@@ -17,11 +18,13 @@ class OctopusControllerFactory {
* @var ImmobilierService $immobilierService * @var ImmobilierService $immobilierService
* @var IndividuService $individuService * @var IndividuService $individuService
* @var GeographieService $geographieService * @var GeographieService $geographieService
* @var FonctionService $fonctionService
*/ */
$structureService = $manager->getServiceLocator()->get(StructureService::class); $structureService = $manager->getServiceLocator()->get(StructureService::class);
$immobilierService = $manager->getServiceLocator()->get(ImmobilierService::class); $immobilierService = $manager->getServiceLocator()->get(ImmobilierService::class);
$individuService = $manager->getServiceLocator()->get(IndividuService::class); $individuService = $manager->getServiceLocator()->get(IndividuService::class);
$geographieService = $manager->getServiceLocator()->get(GeographieService::class); $geographieService = $manager->getServiceLocator()->get(GeographieService::class);
$fonctionService = $manager->getServiceLocator()->get(FonctionService::class);
/** @var OctopusController $controller */ /** @var OctopusController $controller */
$controller = new OctopusController(); $controller = new OctopusController();
...@@ -29,6 +32,7 @@ class OctopusControllerFactory { ...@@ -29,6 +32,7 @@ class OctopusControllerFactory {
$controller->setImmobiliserService($immobilierService); $controller->setImmobiliserService($immobilierService);
$controller->setIndividuService($individuService); $controller->setIndividuService($individuService);
$controller->setGeographieService($geographieService); $controller->setGeographieService($geographieService);
$controller->setFonctionService($fonctionService);
return $controller; return $controller;
} }
} }
\ No newline at end of file
<?php
namespace Octopus\Entity\Db;
use Doctrine\Common\Collections\ArrayCollection;
class Fonction {
/** @var integer */
private $id;
/** @var Fonction */
private $parent;
/** @var ArrayCollection */
private $enfants;
/** @var FonctionType */
private $type;
/** @var string */
private $code;
/** @var string */
private $codeSource;
/** @var integer */
private $niveau;
/** @var ArrayCollection */
private $libelles;
public function __construct()
{
$this->enfants = new ArrayCollection();
$this->libelles = new ArrayCollection();
}
/**
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* @return Fonction
*/
public function getParent()
{
return $this->parent;
}
/**
* @return Fonction[]
*/
public function getEnfants()
{
return $this->enfants->toArray();
}
/**
* @return FonctionType
*/
public function getType()
{
return $this->type;
}
/**
* @return string
*/
public function getCode()
{
return $this->code;
}
/**
* @return string
*/
public function getCodeSource()
{
return $this->codeSource;
}
/**
* @return int
*/
public function getNiveau()
{
return $this->niveau;
}
/**
* @return FonctionLibelle[]
*/
public function getLibelles()
{
return $this->libelles->toArray();
}
}
\ No newline at end of file
<?php
namespace Octopus\Entity\Db;
class FonctionLibelle {
/** @var integer */
private $id;
/** @var Fonction */
private $fonction;
/** @var string */
private $libelle;
/** @var string */
private $genre;
/** @var string */
private $default;
/**
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* @return Fonction
*/
public function getFonction()
{
return $this->fonction;
}
/**
* @return string
*/
public function getLibelle()
{
return $this->libelle;
}
/**
* @return string
*/
public function getGenre()
{
return $this->genre;
}
/**
* @return boolean
*/
public function getDefault()
{
return ($this->default === 'O');
}
}
\ No newline at end of file
<?php
namespace Octopus\Entity\Db;
class FonctionType {
/** @var integer */
private $id;
/** @var string */
private $nom;
/** @var string */
private $libelle;
/** @var string */
private $description;
/**
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* @return string
*/
public function getNom()
{
return $this->nom;
}
/**
* @return string
*/
public function getLibelle()
{
return $this->libelle;
}
/**
* @return string
*/
public function getDescription()
{
return $this->description;
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<entity name="Octopus\Entity\Db\Fonction" table="FONCTION">
<id name="id" type="integer" column="ID">
<generator strategy="IDENTITY"/>
</id>
<many-to-one target-entity="Octopus\Entity\Db\Fonction" field="parent">
<join-column name="PARENT_ID" referenced-column-name="ID" />
</many-to-one>
<one-to-many target-entity="Octopus\Entity\Db\Fonction" mapped-by="parent" field="enfants"/>
<many-to-one target-entity="Octopus\Entity\Db\FonctionType" field="type">
<join-column name="TYPE_ID" referenced-column-name="ID" />
</many-to-one>
<one-to-many target-entity="Octopus\Entity\Db\FonctionLibelle" mapped-by="fonction" field="libelles"/>
<field name="code" type="string" length="20" column="CODE" nullable="false"/>
<field name="codeSource" type="string" length="4" column="CODE_SRC" nullable="false"/>
<field name="niveau" type="integer" column="NIVEAU" nullable="false"/>
</entity>
</doctrine-mapping>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<entity name="Octopus\Entity\Db\FonctionLibelle" table="FONCTION_LIBELLE">
<id name="id" type="integer" column="ID">
<generator strategy="IDENTITY"/>
</id>
<many-to-one target-entity="Octopus\Entity\Db\Fonction" field="fonction">
<join-column name="FONCTION_ID" referenced-column-name="ID" />
</many-to-one>
<field name="libelle" type="string" length="255" column="LIBELLE" nullable="false"/>
<field name="genre" type="string" length="1" column="GENRE" nullable="false"/>
<field name="default" type="string" length="1" column="T_DEFAUT" nullable="false"/>
</entity>
</doctrine-mapping>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<entity name="Octopus\Entity\Db\FonctionType" table="FONCTION_TYPE">
<id name="id" type="integer" column="ID">
<generator strategy="IDENTITY"/>
</id>
<field name="nom" type="string" length="20" column="NOM" nullable="false"/>
<field name="libelle" type="string" length="255" column="LIBELLE" nullable="false"/>
<field name="description" type="string" length="1024" column="DESCRIPTION" nullable="false"/>
</entity>
</doctrine-mapping>
\ No newline at end of file
<?php
namespace Octopus\Service\Fonction;
use Doctrine\ORM\NonUniqueResultException;
use Octopus\Entity\Db\Fonction;
use Octopus\Entity\Db\FonctionLibelle;
use Octopus\Entity\Db\FonctionType;
use UnicaenApp\Exception\RuntimeException;
use UnicaenApp\Service\EntityManagerAwareTrait;
class FonctionService {
use EntityManagerAwareTrait;
/** FONCTION ******************************************************************************************************/
/**
* @param string $order
* @return Fonction[]
*/
public function getFonctions($order = null)
{
$qb = $this->getEntityManager()->getRepository(Fonction::class)->createQueryBuilder('fonction')
->addSelect('libelle')->join('fonction.libelles', 'libelle')
->addSelect('type')->join('fonction.type', 'type')
;
if($order) $qb = $qb->orderBy('fonction.' . $order);
$qb = $qb->setMaxResults(501);
$result = $qb->getQuery()->getResult();
return $result;
}
/**
* @param integer $id
* @return Fonction
*/
public function getFonction($id)
{
$qb = $this->getEntityManager()->getRepository(Fonction::class)->createQueryBuilder('fonction')
->addSelect('libelle')->join('fonction.libelles', 'libelle')
->addSelect('type')->join('fonction.type', 'type')
->andWhere('fonction.id = :id')
->setParameter('id', $id)
;
try {
$result = $qb->getQuery()->getOneOrNullResult();
} catch (NonUniqueResultException $e) {
throw new RuntimeException("Plusieurs Fonction partagent le même identifiant [".$id."].");
}
return $result;
}
/**
* @param string $term
* @return Fonction[]
*/
public function getFonctionsByTerm($term)
{
$qb = $this->getEntityManager()->getRepository(Fonction::class)->createQueryBuilder('fonction')
->addSelect('libelle')->join('fonction.libelles', 'libelle')
->addSelect('type')->join('fonction.type', 'type')
->andWhere('libelle.libelle LIKE :search')
->setParameter('search', '%'.$term.'%')
->orderBy('fonction.libelle')
;
$result = $qb->getQuery()->getResult();
return $result;
}
/** FONCTION_LIBELLE **********************************************************************************************/
/**
* @param string $order
* @return Fonction[]
*/
public function getFonctionsLibelles($order = null)
{
$qb = $this->getEntityManager()->getRepository(FonctionLibelle::class)->createQueryBuilder('libelle')
->addSelect('fonction')->join('libelle.fonction', 'fonction')
;
if($order) $qb = $qb->orderBy('libelle.' . $order);
$qb = $qb->setMaxResults(501);
$result = $qb->getQuery()->getResult();
return $result;
}
/**
* @param integer $id
* @return Fonction
*/
public function getFonctionLibelle($id)
{
$qb = $this->getEntityManager()->getRepository(FonctionLibelle::class)->createQueryBuilder('libelle')
->addSelect('fonction')->join('libelle.fonction', 'fonction')
->andWhere('libelle.id = :id')
->setParameter('id', $id)
;
try {
$result = $qb->getQuery()->getOneOrNullResult();
} catch (NonUniqueResultException $e) {
throw new RuntimeException("Plusieurs FonctionLibelle partagent le même identifiant [".$id."].");
}
return $result;
}
/**
* @param string $term
* @return Fonction[]
*/
public function getFonctionsLibellesByTerm($term)
{
$qb = $this->getEntityManager()->getRepository(FonctionLibelle::class)->createQueryBuilder('libelle')
->addSelect('fonction')->join('libelle.fonction', 'fonction')
->andWhere('libelle.libelle LIKE :search')
->setParameter('search', '%'.$term.'%')
->orderBy('libelle.libelle')
;
$result = $qb->getQuery()->getResult();
return $result;
}
/** FONCTION_TYPE *************************************************************************************************/
/**
* @param string $order
* @return Fonction[]
*/
public function getFonctionsTypes($order = null)
{
$qb = $this->getEntityManager()->getRepository(FonctionType::class)->createQueryBuilder('type')
;
if($order) $qb = $qb->orderBy('type.' . $order);
$qb = $qb->setMaxResults(501);
$result = $qb->getQuery()->getResult();
return $result;
}
/**
* @param integer $id
* @return Fonction
*/
public function getFonctionType($id)
{
$qb = $this->getEntityManager()->getRepository(FonctionType::class)->createQueryBuilder('type')
->andWhere('type.id = :id')
->setParameter('id', $id)
;
try {
$result = $qb->getQuery()->getOneOrNullResult();
} catch (NonUniqueResultException $e) {
throw new RuntimeException("Plusieurs FonctionType partagent le même identifiant [".$id."].");
}
return $result;
}
/**
* @param string $term
* @return Fonction[]
*/
public function getFonctionsTypesByTerm($term)
{
$qb = $this->getEntityManager()->getRepository(FonctionType::class)->createQueryBuilder('type')
->andWhere('type.libelle LIKE :search')
->setParameter('search', '%'.$term.'%')
->orderBy('type.libelle')
;
$result = $qb->getQuery()->getResult();
return $result;
}
}
\ No newline at end of file
<?php
namespace Octopus\Service\Fonction;
trait FonctionServiceAwareTrait {
/** @var FonctionService */
private $fonctionService;
/**
* @return FonctionService
*/
public function getFonctionService()
{
return $this->fonctionService;
}
/**
* @param FonctionService $fonctionService
* @return FonctionService
*/
public function setFonctionService($fonctionService)
{
$this->fonctionService = $fonctionService;
return $this->fonctionService;
}
}
\ No newline at end of file
<?php
namespace Octopus\Service\Fonction;
use Doctrine\ORM\EntityManager;
use Zend\ServiceManager\ServiceLocatorInterface;
class FonctionServiceFactory {
public function __invoke(ServiceLocatorInterface $serviceLocator)
{
/** @var EntityManager $entityManager */
$entityManager = $serviceLocator->get('doctrine.entitymanager.orm_octopus');
/** @var FonctionService $service */
$service = new FonctionService();
$service->setEntityManager($entityManager);
return $service;
}
}
\ No newline at end of file
...@@ -16,7 +16,7 @@ trait GeographieServiceAwareTrait { ...@@ -16,7 +16,7 @@ trait GeographieServiceAwareTrait {
} }
/** /**
* @param GeopgraphieService $geographieService * @param GeographieService $geographieService
* @return GeographieService * @return GeographieService
*/ */
public function setGeographieService($geographieService) public function setGeographieService($geographieService)
......
...@@ -11,6 +11,10 @@ ...@@ -11,6 +11,10 @@
* *
* @var \Octopus\Entity\Db\Individu[] $individus * @var \Octopus\Entity\Db\Individu[] $individus
* *
* @var \Octopus\Entity\Db\Fonction[] $fonctions
* @var \Octopus\Entity\Db\FonctionLibelle[] $fonctionsLibelles
* @var \Octopus\Entity\Db\FonctionType[] $fonctionsTypes
*
* @var \Octopus\Entity\Db\Pays[] $pays * @var \Octopus\Entity\Db\Pays[] $pays
*/ */
...@@ -82,6 +86,117 @@ use UnicaenApp\Form\Element\SearchAndSelect; ...@@ -82,6 +86,117 @@ use UnicaenApp\Form\Element\SearchAndSelect;
</table> </table>
</div> </div>
<div class="main">
<h2> FonctionService</h2>
<h3>
Fonction
<span class="badge">
<?php echo (count($fonctions) > 500)?"500+":count($fonctions); ?>
</span>
</h3>
<table class="table table-condensed">
<thead>
<tr>
<th> Code </th>
<th> Type </th>
<th> Niveau </th>
<th> Parent</th>
<th> Enfants</th>
<th> Libellés </th>
</tr>
</thead>
<tbody>
<?php foreach ($fonctions as $fonction) :?>
<tr>
<td> <?php echo $fonction->getCode(); ?></td>
<td> <?php echo $fonction->getType()->getLibelle(); ?></td>
<td> <?php echo $fonction->getNiveau(); ?></td>
<td>
<?php echo ($fonction->getParent())?$fonction->getParent()->getCode():"---"; ?> </td>
<td>
<ul>
<?php foreach ($fonction->getEnfants() as $enfant) : ?>
<li> <?php echo $enfant->getCode(); ?> </li>
<?php endforeach; ?>
</ul>
</td>
<td>
<ul>
<?php foreach ($fonction->getLibelles() as $libelle) : ?>
<li>
<span class="badge" style="width:2em;background-color: <?php echo ($libelle->getDefault())?"green":"stalegray"; ?>;">
<?php echo $libelle->getGenre(); ?>
</span>
<?php echo $libelle->getLibelle(); ?>
</li>
<?php endforeach; ?>
</ul>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<h3>
FonctionLibelle
<span class="badge">
<?php echo (count($fonctionsLibelles) > 500)?"500+":count($fonctionsLibelles); ?>
</span>
</h3>
<table class="table table-condensed">
<thead>
<tr>
<th> Libelle </th>
<th> Fonction </th>
<th> Genre </th>
<th> Defaut</th>
</tr>
</thead>
<tbody>
<?php foreach ($fonctionsLibelles as $fonctionLibelle) :?>
<tr>
<td> <?php echo $fonctionLibelle->getLibelle(); ?></td>
<td> <?php echo $fonctionLibelle->getFonction()->getCode(); ?></td>
<td> <?php echo $fonctionLibelle->getGenre(); ?></td>
<td> <?php echo $fonctionLibelle->getDefault(); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<h3>
FonctionType
<span class="badge">
<?php echo (count($fonctionsTypes) > 500)?"500+":count($fonctionsTypes); ?>
</span>
</h3>
<table class="table table-condensed">
<thead>
<tr>
<th> Nom </th>
<th> Libelle </th>
<th> Description </th>
</tr>
</thead>
<tbody>
<?php foreach ($fonctionsTypes as $fonctionType) :?>
<tr>
<td> <?php echo $fonctionType->getNom(); ?></td>
<td> <?php echo $fonctionType->getLibelle(); ?></td>
<td> <?php echo $fonctionType->getDescription(); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<div class="main"> <div class="main">
<h2> StructureService </h2> <h2> StructureService </h2>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment