Skip to content
Snippets Groups Projects
Commit f0ed2264 authored by lecluse's avatar lecluse
Browse files

Gestion affinée des historiques (en cours)

Refactoring massif (nétoyage d'anciennes portions de code mort)
Optimisation du chargement des privilèges
parent 06bde528
Branches
Tags
No related merge requests found
Showing
with 131 additions and 536 deletions
......@@ -19,8 +19,7 @@ FROM
LEFT JOIN service s ON s.id = frs.service_id
LEFT JOIN element_pedagogique ep ON ep.id = s.element_pedagogique_id
WHERE
mep.histo_destruction IS NULL
AND i.nom_usuel = 'Chaillot'
mep.histo_destruction IS NOT NULL
;
......
SELECT
s.id,
i.id,
s.structure_aff_id,
i.structure_id,
s.structure_ens_id,
ep.structure_id
FROM
service s
JOIN intervenant i ON i.id = s.intervenant_id
JOIN element_pedagogique ep ON ep.id = s.element_pedagogique_id
WHERE
s.structure_aff_id <> i.structure_id
OR s.structure_ens_id <> ep.structure_id;
UPDATE service SET
structure_aff_id = (SELECT structure_id FROM intervenant WHERE intervenant.id = service.intervenant_id),
structure_ens_id = (SELECT structure_id FROM element_pedagogique ep WHERE ep.id = service.element_pedagogique_id)
WHERE
service.id IN (
SELECT
s.id
FROM
service s
JOIN intervenant i ON i.id = s.intervenant_id
JOIN element_pedagogique ep ON ep.id = s.element_pedagogique_id
WHERE
s.structure_aff_id <> i.structure_id
OR s.structure_ens_id <> ep.structure_id );
/
alter trigger "OSE"."SERVICE_HISTO_CK" disable;
alter trigger "OSE"."SERVICE_CK" disable;
/
alter trigger "OSE"."SERVICE_HISTO_CK" enable;
alter trigger "OSE"."SERVICE_CK" enable;
/
select * from intervenant where nom_usuel like '%Martin%';
\ No newline at end of file
......@@ -162,10 +162,6 @@ class Module implements ControllerPluginProviderInterface, ViewHelperProviderInt
'em' => 'Application\Controller\Plugin\Em',
'context' => 'Application\Controller\Plugin\Context',
),
'factories' => array(
'intervenant' => 'Application\Controller\Plugin\IntervenantFactory',
'serviceReferentiel' => 'Application\Controller\Plugin\ServiceReferentielFactory',
),
);
}
......
<?php
namespace Application;
return array(
'router' => array(
'routes' => array(
'demo' => array(
'type' => 'Segment',
'options' => array(
'route' => '/demo[/:action]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
),
'defaults' => array(
'controller' => 'Application\Controller\Demo',
'action' => 'index',
),
),
),
),
),
'navigation' => array(
'default' => array(
'home' => array(
'pages' => array(
// 'demo' => array(
// 'label' => 'Démo',
// 'route' => 'demo',
// 'params' => array(
// 'action' => 'index',
// ),
// 'pages' => array(
//// 'of' => array(
//// 'label' => "Offre de formation",
//// 'route' => 'demo',
//// 'params' => array(
//// 'action' => 'of',
//// ),
//// 'visible' => true,
//// 'pages' => array(),
//// ),
// 'intervenant' => array(
// 'label' => "Intervenants",
// 'route' => 'demo',
// 'params' => array(
// 'action' => 'intervenant',
// ),
// 'visible' => true,
// 'pages' => array(),
// ),
// 'service-ref' => array(
// 'label' => "Service référentiel",
// 'route' => 'demo',
// 'params' => array(
// 'action' => 'saisir-service-referentiel-intervenant',
// ),
// 'visible' => true,
// 'pages' => array(),
// ),
// ),
// ),
),
),
),
),
'bjyauthorize' => array(
'guards' => array(
'BjyAuthorize\Guard\Controller' => array(
array(
'controller' => 'Application\Controller\Demo',
'roles' => array('user')),
),
),
),
'controllers' => array(
'invokables' => array(
'Application\Controller\Demo' => 'Application\Controller\DemoController',
),
),
);
......@@ -257,7 +257,6 @@ return array_merge_recursive(
include 'piece-jointe.config.php',
include 'structure.config.php',
include 'etablissement.config.php',
include 'demo.config.php',
include 'recherche.config.php',
include 'service.config.php',
include 'volume-horaire.config.php',
......
<?php
namespace Application\Controller;
use Zend\Mvc\Controller\AbstractActionController;
/**
*
* @method \Doctrine\ORM\EntityManager em()
* @method \Application\Controller\Plugin\Context context()
* @method \Application\Controller\Plugin\Intervenant intervenant()
* @method \Application\Controller\Plugin\Structure structure()
* @method \UnicaenApp\Controller\Plugin\ModalInnerViewModel modalInnerViewModel()
*/
class DemoController extends AbstractActionController
{
/**
* @return \Application\Service\ServiceReferentiel
*/
public function getServiceReferentielService()
{
return $this->getServiceLocator()->get('ApplicationServiceReferentiel');
}
/**
*
* @return type
*/
public function indexAction()
{
$repo = $this->em()->getRepository('Application\Entity\Db\ElementPedagogique');
$structures = $repo->finderDistinctStructures()->getQuery()->execute();
$sl = $this->getServiceLocator();
$fs = $sl->get('FormElementManager')->get('FormElementPedagogiqueRechercheFieldset');
$fs
->setStructures(array($s = $structures[0]))
->setEtapes($repo->finderDistinctEtapes(array('structure' => $s))->getQuery()->execute())
->setStructuresSourceUrl(null)
->setEtapesSourceUrl(null)
;
$fs->get('structure')->setValue($s->getId());
return array('fs' => $fs);
}
/**
*
* @return \Zend\View\Model\ViewModel
*/
public function intervenantAction()
{
$url = $this->url()->fromRoute('recherche', array('action' => 'intervenantFind'));
$interv = new \UnicaenApp\Form\Element\SearchAndSelect('interv');
$interv->setAutocompleteSource($url)
->setLabel("Rechercher un intervenant :")
->setAttributes(array('title' => "Saisissez le nom suivi éventuellement du prénom (2 lettres au moins)"));
$form = new \Zend\Form\Form('search');
$form->setAttributes(array('class' => 'intervenant-rech'));
$form->add($interv);
$view = new \Zend\View\Model\ViewModel();
$view->setVariables(array('form' => $form, 'title' => "Intervenant..."));
return $view;
}
/**
*
* @return \Zend\View\Model\ViewModel
* @see IntervenantController
*/
public function voirIntervenantAction()
{
if (!($sourceCode = $this->params()->fromQuery('sourceCode', $this->params()->fromPost('sourceCode')))) {
if ($this->getRequest()->isXmlHttpRequest()) {
exit;
}
return $this->redirect()->toRoute('home');
}
$controller = 'Application\Controller\Intervenant';
$params = $this->getEvent()->getRouteMatch()->getParams();
// import si besoin
if (!($intervenant = $this->intervenant()->getRepo()->findOneBy(array('sourceCode' => $sourceCode)))) {
$params['action'] = 'importer';
$params['id'] = $sourceCode;
$viewModel = $this->forward()->dispatch($controller, $params); /* @var $viewModel \Zend\View\Model\ViewModel */
$intervenant = $viewModel->getVariable('intervenant');
}
$params['action'] = 'voir';
$params['id'] = $intervenant->getId();
$viewModel = $this->forward()->dispatch($controller, $params);
return $viewModel;
}
/**
*
* @return \Zend\View\Model\ViewModel
*/
public function saisirServiceReferentielIntervenantAction()
{
$controller = 'Application\Controller\Intervenant';
$params = $this->getEvent()->getRouteMatch()->getParams();
$params['action'] = 'saisirServiceReferentiel';
$viewModel = $this->forward()->dispatch($controller, $params);
return $viewModel;
}
}
\ No newline at end of file
......@@ -60,6 +60,11 @@ class EtablissementController extends AbstractActionController
public function rechercheAction()
{
$this->em()->getFilters()->enable('historique')->init(
'Application\Entity\Db\Etablissement',
$this->context()->getGlobalContext()->getDateObservation()
);
if (!($term = $this->params()->fromQuery('term'))) {
return new JsonModel(array());
}
......
......@@ -133,6 +133,7 @@ class IntervenantController extends AbstractActionController implements ContextP
public function voirAction()
{
// \Test\Util::sqlLog($this->em());
$role = $this->getContextProvider()->getSelectedIdentityRole();
$this->em()->getFilters()->enable('historique');
......@@ -144,36 +145,6 @@ class IntervenantController extends AbstractActionController implements ContextP
$intervenant = $this->context()->mandatory()->intervenantFromRoute();
}
// fetch avec jointures
$entityClass = $intervenant instanceof IntervenantExterieur ?
'Application\Entity\Db\IntervenantExterieur' :
'Application\Entity\Db\IntervenantPermanent';
$qb = $this->em()->getRepository($entityClass)->createQueryBuilder("i")
->addSelect("ti, si, c, src, a, aff, affr, d")
->join("i.type", "ti")
->join("i.statut", "si")
->join("i.civilite", "c")
->join("i.source", "src")
->leftJoin("i.utilisateur", "u")
->leftJoin("i.adresse", "a")
->leftJoin("i.structure", "aff")
->leftJoin("i.affectation", "affr")
->leftJoin("i.discipline", "d")
->where("i = :intervenant")->setParameter('intervenant', $intervenant);
if ($intervenant instanceof IntervenantExterieur) {
$qb
->addSelect("sf, rs, tp")
->leftJoin("i.situationFamiliale", "sf")
->leftJoin("i.regimeSecu", "rs")
->leftJoin("i.typePoste", "tp");
}
else {
$qb
->addSelect("co")
->leftJoin("i.corps", "co");
}
$intervenant = $qb->getQuery()->getSingleResult();
$import = $this->getServiceLocator()->get('ImportProcessusImport');
$changements = $import->intervenantGetDifferentiel($intervenant);
$short = $this->params()->fromQuery('short', false);
......@@ -202,10 +173,6 @@ class IntervenantController extends AbstractActionController implements ContextP
public function voirHeuresCompAction()
{
$this->em()->getFilters()->enable('historique')
->disableForEntity('Application\Entity\Db\ElementPedagogique')
->disableForEntity('Application\Entity\Db\Etablissement');
$intervenant = $this->context()->mandatory()->intervenantFromRoute();
/* @var $intervenant \Application\Entity\Db\Intervenant */
$form = $this->getFormHeuresComp();
......@@ -363,8 +330,6 @@ class IntervenantController extends AbstractActionController implements ContextP
{
$role = $this->getContextProvider()->getSelectedIdentityRole();
$this->em()->getFilters()->enable('historique');
if ($role instanceof \Application\Acl\IntervenantRole) {
$intervenant = $role->getIntervenant();
}
......@@ -391,40 +356,6 @@ class IntervenantController extends AbstractActionController implements ContextP
return $view;
}
public function modifierAction()
{
if (!($id = $this->params()->fromRoute('id'))) {
throw new LogicException("Aucun identifiant d'intervenant spécifié.");
}
if (!($intervenant = $this->intervenant()->getRepo()->find($id))) {
throw new RuntimeException("Intervenant '$id' spécifié introuvable.");
}
$form = $this->getFormModifier();
$form->bind($intervenant);
if (($data = $this->params()->fromPost())) {
$form->setData($data);
if ($form->isValid()) {
$em = $this->intervenant()->getEntityManager();
$em->flush($form->getObject());
}
}
$view = new \Zend\View\Model\ViewModel();
$view->setVariables(array('form' => $form, 'intervenant' => $intervenant));
return $view;
}
protected function getFormModifier()
{
$builder = new AnnotationBuilder();
$form = $builder->createForm('Application\Entity\Db\Intervenant');
$form->getHydrator()->setUnderscoreSeparatedKeys(false);
return $form;
}
/**
* @return \Application\Service\Intervenant
*/
......
......@@ -27,6 +27,11 @@ class ModificationServiceDuController extends AbstractActionController implement
*/
public function saisirAction()
{
$this->em()->getFilters()->enable('historique')->init(
'Application\Entity\Db\ModificationServiceDu',
$this->context()->getGlobalContext()->getDateObservation()
);
$context = $this->getContextProvider()->getGlobalContext();
$isAjax = $this->getRequest()->isXmlHttpRequest();
$intervenant = $this->context()->mandatory()->intervenantFromRoute(); /* @var $intervenant IntervenantPermanent */
......@@ -39,8 +44,6 @@ class ModificationServiceDuController extends AbstractActionController implement
throw new MessageException("La modification de service dû n'est pas possible. ", null, new \Exception($rule->getMessage()));
}
$this->em()->getFilters()->enable("historique");
// fetch intervenant avec jointure sur les modifs de service dû
$qb = $this->getServiceIntervenant()->getFinderIntervenantPermanentWithModificationServiceDu();
$qb->setIntervenant($intervenant);
......@@ -109,73 +112,6 @@ class ModificationServiceDuController extends AbstractActionController implement
return $viewModel;
}
/**
*
* @param bool $import Importer l'intervenant si besoin ?
* @return \Application\Entity\Db\Intervenant
* @throws RuntimeException Intervenant spécifié par son code source introuvable
*/
// protected function getIntervenant($import = true)
// {
// $sourceCode = $this->params()->fromQuery('sourceCode', $this->params('id'));
// $intervenant = null;
//
// if ($sourceCode) {
// // test d'existence de l'intervenant et import éventuel
// $intervenant = $this->em()->getRepository('Application\Entity\Db\Intervenant')->findOneBySourceCode($sourceCode);
// if (!$intervenant) {
// if (!$import) {
// throw new RuntimeException("Intervenant spécifié introuvable (sourceCode = $sourceCode).");
// }
// // import de l'intervenant
// $intervenant = $this->getServiceLocator()->get('ApplicationIntervenant')->importer($sourceCode);
// }
//
// return $intervenant;
// }
//
// $context = $this->getContextProvider()->getLocalContext();
// $role = $this->getContextProvider()->getSelectedIdentityRole();
//
// if ($role instanceof \Application\Acl\IntervenantRole) {
// $intervenant = $role->getIntervenant();
// }
//
// if ($role instanceof \Application\Acl\DbRole) {
// // récupère l'éventuel intervenant du contexte local
// $intervenant = $context->getIntervenant();
// }
//
// return $intervenant;
// }
//
// /**
// * Redirection vers le choix d'un intervenant (action qui redirigera vers l'action
// * courante une fois l'intervenant choisi).
// *
// * @param \Application\Entity\Db\Intervenant $intervenant Intervenant pré-choisi
// * @return \Zend\Http\Response
// * @see IntervenantController
// */
// protected function redirectToChoisirIntervenant(\Application\Entity\Db\Intervenant $intervenant = null)
// {
// $modal = $this->params()->fromQuery('modal');
// $redirect = $this->url()->fromRoute(
// null,
// array(),
// array('query' => array('sourceCode' => '__sourceCode__', 'modal' => $modal)),
// true);
//
// if ($intervenant) {
// $intervenant = $intervenant->getSourceCode();
// }
//
// return $this->redirect()->toRoute(
// 'intervenant/default',
// array('action' => 'choisir'),
// array('query' => array('intervenant' => $intervenant, 'redirect' => $redirect, 'modal' => $modal)));
// }
/**
* @return \Application\Service\Intervenant
*/
......
......@@ -32,7 +32,13 @@ class OffreFormationController extends AbstractActionController implements Conte
*/
public function indexAction()
{
$this->em()->getFilters()->enable('historique');
$this->em()->getFilters()->enable('historique')->init(
[
'Application\Entity\Db\ElementPedagogique',
'Application\Entity\Db\Etape'
],
$this->context()->getGlobalContext()->getDateObservation()
);
$serviceEp = $this->getServiceLocator()->get('applicationElementPedagogique'); /* @var $serviceEp ElementPedagogiqueService */
$serviceEtape = $this->getServiceLocator()->get('applicationEtape'); /* @var $serviceEtape EtapeService */
......@@ -131,7 +137,13 @@ class OffreFormationController extends AbstractActionController implements Conte
$serviceEp = $this->getServiceLocator()->get('applicationElementPedagogique'); /* @var $serviceEp ElementPedagogiqueService */
$role = $this->getContextProvider()->getSelectedIdentityRole();
$em->getFilters()->enable('historique');
$this->em()->getFilters()->enable('historique')->init(
[
'Application\Entity\Db\ElementPedagogique',
'Application\Entity\Db\Etape'
],
$this->context()->getGlobalContext()->getDateObservation()
);
// extraction des filtres spécifiés dans la requête
$structure = $this->context()->structureFromQuery();
......@@ -188,6 +200,11 @@ class OffreFormationController extends AbstractActionController implements Conte
*/
public function searchStructuresAction()
{
$this->em()->getFilters()->enable('historique')->init(
'Application\Entity\Db\Structure',
$this->context()->getGlobalContext()->getDateObservation()
);
$serviceStructure = $this->getServiceLocator()->get('applicationStructure'); /* @var $serviceStructure \Application\Service\Structure */
$result = $serviceStructure->getList( $serviceStructure->finderByEnseignement() );
......@@ -202,6 +219,14 @@ class OffreFormationController extends AbstractActionController implements Conte
*/
public function searchNiveauxAction()
{
$this->em()->getFilters()->enable('historique')->init(
[
'Application\Entity\Db\Etape',
'Application\Entity\Db\CheminPedagogique',
],
$this->context()->getGlobalContext()->getDateObservation()
);
$structure = $this->context()->structureFromQuery();
$params = array();
......
......@@ -25,11 +25,10 @@ class PaiementController extends AbstractActionController implements ContextProv
*/
protected function initFilters()
{
$this->em()->getFilters()->enable('historique')
->disableForEntity('Application\Entity\Db\ElementPedagogique')
->disableForEntity('Application\Entity\Db\Etape')
->disableForEntity('Application\Entity\Db\Etablissement')
->disableForEntity('Application\Entity\Db\FonctionReferentiel');
$this->em()->getFilters()->enable('historique')->init(
'Application\Entity\Db\MiseEnPaiement',
$this->context()->getGlobalContext()->getDateObservation()
);
}
public function indexAction()
......@@ -46,7 +45,6 @@ class PaiementController extends AbstractActionController implements ContextProv
if ($this->getRequest()->isPost()) {
$changements = $this->params()->fromPost('changements', '{}');
$changements = Json::decode($changements, Json::TYPE_ARRAY);
//var_dump($changements);
$this->getServiceMiseEnPaiement()->saveChangements($changements);
$saved = true;
}
......@@ -124,6 +122,7 @@ class PaiementController extends AbstractActionController implements ContextProv
public function misesEnPaiementCsvAction()
{
$this->initFilters();
$role = $this->getContextProvider()->getSelectedIdentityRole();
$recherche = new MiseEnPaiementRecherche;
......@@ -221,6 +220,7 @@ class PaiementController extends AbstractActionController implements ContextProv
public function extractionWinpaieAction()
{
$this->initFilters();
$periode = $this->params()->fromRoute('periode');
$periode = $this->getServicePeriode()->getRepo()->findOneBy(['code' => $periode]);
......@@ -256,6 +256,7 @@ class PaiementController extends AbstractActionController implements ContextProv
public function miseEnPaiementAction()
{
$this->initFilters();
$title = 'Mise en paiement';
$structure = $this->context()->mandatory()->structureFromRoute();
$intervenants = $this->params('intervenants');
......
......@@ -4,7 +4,7 @@ namespace Application\Controller\Plugin;
use Zend\Mvc\Controller\Plugin\Params;
use Zend\ServiceManager\ServiceLocatorAwareInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
use Zend\ServiceManager\ServiceLocatorAwareTrait;
use Zend\Session\Container;
use Application\Service\LocalContext;
use Application\Service\GlobalContext;
......@@ -27,6 +27,8 @@ use Common\Exception\RuntimeException;
*/
class Context extends Params implements ServiceLocatorAwareInterface
{
use ServiceLocatorAwareTrait;
/**
* @var ServiceLocatorInterface
*/
......@@ -135,13 +137,13 @@ class Context extends Params implements ServiceLocatorAwareInterface
}
}
$em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
$em = $this->getServiceLocator()->getServiceLocator()->get('doctrine.entitymanager.orm_default');
/* Cas particulier pour les intervenants : import implicite */
if ('intervenant' === $target && (int)$value){
$sourceCode = (string)(int)$value;
if (!($intervenant = $em->getRepository('Application\Entity\Db\Intervenant')->findOneBySourceCode($sourceCode))) {
$this->getServiceLocator()->get('importProcessusImport')->intervenant($sourceCode); // Import
$this->getServiceLocator()->getServiceLocator()->get('importProcessusImport')->intervenant($sourceCode); // Import
if (!($intervenant = $em->getRepository('Application\Entity\Db\Intervenant')->findOneBySourceCode($sourceCode))) {
throw new RuntimeException("L'intervenant suivant est introuvable après import : sourceCode = $sourceCode.");
}
......@@ -258,7 +260,7 @@ class Context extends Params implements ServiceLocatorAwareInterface
public function getGlobalContext()
{
if (null === $this->globalContext) {
$this->globalContext = $this->sl->get('ApplicationContextProvider')->getGlobalContext();
$this->globalContext = $this->getServiceLocator()->getServiceLocator()->get('ApplicationContextProvider')->getGlobalContext();
}
return $this->globalContext;
}
......@@ -269,7 +271,7 @@ class Context extends Params implements ServiceLocatorAwareInterface
public function getLocalContext()
{
if (null === $this->localContext) {
$this->localContext = $this->sl->get('ApplicationContextProvider')->getLocalContext();
$this->localContext = $this->getServiceLocator()->getServiceLocator()->get('ApplicationContextProvider')->getLocalContext();
}
return $this->localContext;
}
......@@ -284,26 +286,4 @@ class Context extends Params implements ServiceLocatorAwareInterface
}
return $this->sessionContainer;
}
/**
* Set service locator
*
* @param ServiceLocatorInterface $serviceLocator
*/
public function setServiceLocator(ServiceLocatorInterface $serviceLocator)
{
$this->sl = $serviceLocator->getServiceLocator();
return $this;
}
/**
* Get service locator
*
* @return ServiceLocatorInterface
*/
public function getServiceLocator()
{
return $this->sl;
}
}
\ No newline at end of file
......@@ -4,7 +4,7 @@ namespace Application\Controller\Plugin;
use Zend\Mvc\Controller\Plugin\AbstractPlugin;
use Zend\ServiceManager\ServiceLocatorAwareInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
use Zend\ServiceManager\ServiceLocatorAwareTrait;
use Doctrine\ORM\EntityManager;
/**
......@@ -14,10 +14,7 @@ use Doctrine\ORM\EntityManager;
*/
class Em extends AbstractPlugin implements ServiceLocatorAwareInterface
{
/**
* @var ServiceLocatorInterface
*/
protected $sl;
use ServiceLocatorAwareTrait;
/**
* @var EntityManager
......@@ -44,31 +41,9 @@ class Em extends AbstractPlugin implements ServiceLocatorAwareInterface
protected function getEntityManager($name)
{
if (null === $this->em) {
$this->em = $this->sl->get("doctrine.entitymanager.$name");
$this->em = $this->getServiceLocator()->getServiceLocator()->get("doctrine.entitymanager.$name");
}
return $this->em;
}
/**
* Set service locator
*
* @param ServiceLocatorInterface $serviceLocator
*/
public function setServiceLocator(ServiceLocatorInterface $serviceLocator)
{
$this->sl = $serviceLocator->getServiceLocator();
return $this;
}
/**
* Get service locator
*
* @return ServiceLocatorInterface
*/
public function getServiceLocator()
{
return $this->sl;
}
}
\ No newline at end of file
<?php
namespace Application\Controller\Plugin;
use Common\Controller\Plugin\BasePlugin;
/**
* Description of Intervenant
*
* @author Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr>
*/
class Intervenant extends BasePlugin
{
public function __invoke()
{
return $this;
}
/**
* Retourne le repository.
*
* @return \Application\Entity\Db\Repository\IntervenantRepository
*/
public function getRepo()
{
return $this->getEntityManager()->getRepository('Application\Entity\Db\Intervenant');
}
}
\ No newline at end of file
<?php
namespace Application\Controller\Plugin;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
/**
* Description of IntervenantFactory
*
* @author Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr>
*/
class IntervenantFactory implements FactoryInterface
{
/**
* Create service
*
* @param ServiceLocatorInterface $serviceLocator
* @return mixed
*/
public function createService(ServiceLocatorInterface $serviceLocator) /* @var $serviceLocator \Zend\Mvc\Controller\PluginManager */
{
$em = $serviceLocator->getServiceLocator()->get('doctrine.entitymanager.orm_default');
return new Intervenant($em);
}
}
\ No newline at end of file
<?php
namespace Application\Controller\Plugin;
use Common\Controller\Plugin\BasePlugin;
/**
* Description of ServiceReferentiel
*
* @author Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr>
*/
class ServiceReferentiel extends BasePlugin
{
public function __invoke()
{
return $this;
}
/**
* Retourne le repository.
*
* @return \Application\Entity\Db\Repository\IntervenantRepository
*/
public function getRepo()
{
return $this->getEntityManager()->getRepository('Application\Entity\Db\ServiceReferentiel');
}
}
\ No newline at end of file
<?php
namespace Application\Controller\Plugin;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
/**
* Description of IntervenantFactory
*
* @author Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr>
*/
class ServiceReferentielFactoryFactory implements FactoryInterface
{
/**
* Create service
*
* @param ServiceLocatorInterface $serviceLocator
* @return mixed
*/
public function createService(ServiceLocatorInterface $serviceLocator) /* @var $serviceLocator \Zend\Mvc\Controller\PluginManager */
{
$em = $serviceLocator->getServiceLocator()->get('doctrine.entitymanager.orm_default');
return new ServiceReferentiel($em);
}
}
\ No newline at end of file
......@@ -37,6 +37,11 @@ class RechercheController extends AbstractActionController
public function intervenantFindAction()
{
$this->em()->getFilters()->enable('historique')->init(
'Application\Entity\Db\Intervenant',
$this->context()->getGlobalContext()->getDateObservation()
);
if (!($term = $this->params()->fromQuery('term'))) {
return new JsonModel(array());
}
......
......@@ -27,10 +27,13 @@ class ServiceController extends AbstractActionController
*/
protected function initFilters()
{
$this->em()->getFilters()->enable('historique')
->disableForEntity('Application\Entity\Db\ElementPedagogique')
->disableForEntity('Application\Entity\Db\Etape')
->disableForEntity('Application\Entity\Db\Etablissement');
$this->em()->getFilters()->enable('historique')->init(
[
'Application\Entity\Db\Service',
'Application\Entity\Db\VolumeHoraire'
],
$this->context()->getGlobalContext()->getDateObservation()
);
}
/**
......@@ -214,7 +217,6 @@ class ServiceController extends AbstractActionController
throw new \BjyAuthorize\Exception\UnAuthorizedException();
}
$this->initFilters();
if ($intervenant){
$this->getContextProvider()->getLocalContext()->setIntervenant($intervenant);
}
......@@ -256,8 +258,6 @@ class ServiceController extends AbstractActionController
public function resumeRefreshAction()
{
$this->initFilters();
$filter = $this->getFormRecherche()->hydrateFromSession();
return compact('filter');
......@@ -345,6 +345,7 @@ class ServiceController extends AbstractActionController
public function constatationAction()
{
$this->initFilters();
$errors = [];
$typeVolumeHoraire = $this->getServiceTypeVolumehoraire()->getRealise();
$services = $this->params()->fromQuery('services');
......
......@@ -30,8 +30,13 @@ class ServiceReferentielController extends AbstractActionController implements C
protected function initFilters()
{
$this->em()->getFilters()->enable('historique')
->disableForEntity('Application\Entity\Db\FonctionReferentiel');
$this->em()->getFilters()->enable('historique')->init(
[
'Application\Entity\Db\ServiceReferentiel',
'Application\Entity\Db\VolumeHoraireReferentiel'
],
$this->context()->getGlobalContext()->getDateObservation()
);
}
/**
......@@ -206,6 +211,7 @@ class ServiceReferentielController extends AbstractActionController implements C
public function constatationAction()
{
$this->initFilters();
$services = $this->params()->fromQuery('services');
if ($services){
$services = explode( ',', $services );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment