Loading module/Application/config/merged/poste.config.php +11 Changes for module/Application/config/merged/poste.config.php: 11 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ return [ 'action' => [ 'index', 'afficher', 'rechercher-batiment', ], 'privileges' => [ PostePrivileges::AFFICHER, Loading Loading @@ -84,6 +85,16 @@ return [ ], ], ], 'rechercher-batiment' => [ 'type' => Literal::class, 'options' => [ 'route' => '/rechercher-batiment', 'defaults' => [ 'controller' => PosteController::class, 'action' => 'rechercher-batiment', ], ], ], 'supprimer' => [ 'type' => Segment::class, 'options' => [ Loading module/Application/src/Application/Controller/Poste/PosteController.php +28 Changes for module/Application/src/Application/Controller/Poste/PosteController.php: 28 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -5,12 +5,16 @@ namespace Application\Controller\Poste; use Application\Entity\Db\Poste; use Application\Form\Poste\PosteForm; use Application\Service\Poste\PosteServiceAwareTrait; use Octopus\Entity\Db\ImmobilierBatiment; use Octopus\Service\Immobilier\ImmobilierServiceAwareTrait; use Zend\Http\Request; use Zend\Mvc\Controller\AbstractActionController; use Zend\View\Model\JsonModel; use Zend\View\Model\ViewModel; class PosteController extends AbstractActionController { use PosteServiceAwareTrait; use ImmobilierServiceAwareTrait; public function indexAction() { Loading Loading @@ -103,4 +107,28 @@ class PosteController extends AbstractActionController { $this->redirect()->toRoute('poste', [], [], true); } /** * @return JsonModel */ public function rechercherBatimentAction() { if (($term = $this->params()->fromQuery('term'))) { $batiments = $this->getImmobiliserService()->getImmobilierBatimentsByTerm($term); $result = []; /** @var ImmobilierBatiment[] $batiments */ foreach ($batiments as $batiment) { $result[] = array( 'id' => $batiment->getId(), 'label' => $batiment->getLibelle(), 'extra' => "<span class='badge' style='background-color: slategray;'>".$batiment->getSite()->getLibelle()."</span>", ); } usort($result, function($a, $b) { return strcmp($a['label'], $b['label']); }); return new JsonModel($result); } exit; } } No newline at end of file module/Application/src/Application/Controller/Poste/PosteControllerFactory.php +4 Changes for module/Application/src/Application/Controller/Poste/PosteControllerFactory.php: 4 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ namespace Application\Controller\Poste; use Application\Service\Poste\PosteService; use Octopus\Service\Immobilier\ImmobilierService; use Zend\Mvc\Controller\ControllerManager; class PosteControllerFactory { Loading @@ -11,12 +12,15 @@ class PosteControllerFactory { { /** * @var PosteService $posteService * @var ImmobilierService $immobilierService */ $posteService = $controllerManager->getServiceLocator()->get(PosteService::class); $immobilierService = $controllerManager->getServiceLocator()->get(ImmobilierService::class); /** @var PosteController $controller */ $controller = new PosteController(); $controller->setPosteService($posteService); $controller->setImmobiliserService($immobilierService); return $controller; } } No newline at end of file module/Application/src/Application/Form/Poste/PosteForm.php +13 −10 Changes for module/Application/src/Application/Form/Poste/PosteForm.php: 13 added lines, 10 removed lines. Original line number Diff line number Diff line Loading @@ -8,16 +8,20 @@ use Application\Entity\Db\Fonction; use Application\Service\Agent\AgentServiceAwareTrait; use Application\Service\RessourceRh\RessourceRhServiceAwareTrait; use DoctrineModule\Form\Element\ObjectSelect; use UnicaenApp\Form\Element\SearchAndSelect; use UnicaenApp\Service\EntityManagerAwareTrait; use Zend\Form\Element\Button; use Zend\Form\Element\Select; use Zend\Form\Element\Text; use Zend\Form\Form; use Zend\ServiceManager\ServiceLocatorAwareTrait; class PosteForm extends Form { use AgentServiceAwareTrait; use RessourceRhServiceAwareTrait; use EntityManagerAwareTrait; use ServiceLocatorAwareTrait; public function init() { Loading Loading @@ -57,16 +61,15 @@ class PosteForm extends Form { ]); // localisation $this->add([ 'type' => Text::class, 'name' => 'localisation', 'options' => [ 'label' => "Localisation :", ], 'attributes' => [ 'id' => 'localisation', ], ]); $sas = new SearchAndSelect('localisation'); $sas->setLabel('Localisation du poste'); $sas->setAttribute('placeholder','Recherchez un batiment'); $sas->setAttribute('class', 'individu-finder'); $sas->setLabelOption('disable_html_escape', false); // $sas->setAutocompleteSource($this->getUrl('poste-form/rechercher-batiment')); $sas->setAutocompleteSource('/poste/rechercher-batiment'); $this->add($sas); // correspondance $this->add([ 'type' => Select::class, Loading module/Application/src/Application/Form/Poste/PosteFormFactory.php +10 Changes for module/Application/src/Application/Form/Poste/PosteFormFactory.php: 10 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -9,6 +9,15 @@ use Zend\Form\FormElementManager; class PosteFormFactory { protected function getUrl(FormElementManager $manager, $name = null, $params = [], $options = [], $reuseMatchedParams = false) { $url = $manager->getServiceLocator()->get('viewhelpermanager')->get('url'); /* @var $url \Zend\View\Helper\Url */ return $url->__invoke($name, $params, $options, $reuseMatchedParams); } public function __invoke(FormElementManager $manager) { /** Loading @@ -27,6 +36,7 @@ class PosteFormFactory { $form->setEntityManager($entityManager); $form->setAgentService($agentService); $form->setRessourceRhService($ressourceService); //$url = $this->getUrl($manager,'poste/rechercher-batiment', [], [], true); $form->init(); $form->setHydrator($hydrator); Loading Loading
module/Application/config/merged/poste.config.php +11 Changes for module/Application/config/merged/poste.config.php: 11 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ return [ 'action' => [ 'index', 'afficher', 'rechercher-batiment', ], 'privileges' => [ PostePrivileges::AFFICHER, Loading Loading @@ -84,6 +85,16 @@ return [ ], ], ], 'rechercher-batiment' => [ 'type' => Literal::class, 'options' => [ 'route' => '/rechercher-batiment', 'defaults' => [ 'controller' => PosteController::class, 'action' => 'rechercher-batiment', ], ], ], 'supprimer' => [ 'type' => Segment::class, 'options' => [ Loading
module/Application/src/Application/Controller/Poste/PosteController.php +28 Changes for module/Application/src/Application/Controller/Poste/PosteController.php: 28 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -5,12 +5,16 @@ namespace Application\Controller\Poste; use Application\Entity\Db\Poste; use Application\Form\Poste\PosteForm; use Application\Service\Poste\PosteServiceAwareTrait; use Octopus\Entity\Db\ImmobilierBatiment; use Octopus\Service\Immobilier\ImmobilierServiceAwareTrait; use Zend\Http\Request; use Zend\Mvc\Controller\AbstractActionController; use Zend\View\Model\JsonModel; use Zend\View\Model\ViewModel; class PosteController extends AbstractActionController { use PosteServiceAwareTrait; use ImmobilierServiceAwareTrait; public function indexAction() { Loading Loading @@ -103,4 +107,28 @@ class PosteController extends AbstractActionController { $this->redirect()->toRoute('poste', [], [], true); } /** * @return JsonModel */ public function rechercherBatimentAction() { if (($term = $this->params()->fromQuery('term'))) { $batiments = $this->getImmobiliserService()->getImmobilierBatimentsByTerm($term); $result = []; /** @var ImmobilierBatiment[] $batiments */ foreach ($batiments as $batiment) { $result[] = array( 'id' => $batiment->getId(), 'label' => $batiment->getLibelle(), 'extra' => "<span class='badge' style='background-color: slategray;'>".$batiment->getSite()->getLibelle()."</span>", ); } usort($result, function($a, $b) { return strcmp($a['label'], $b['label']); }); return new JsonModel($result); } exit; } } No newline at end of file
module/Application/src/Application/Controller/Poste/PosteControllerFactory.php +4 Changes for module/Application/src/Application/Controller/Poste/PosteControllerFactory.php: 4 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ namespace Application\Controller\Poste; use Application\Service\Poste\PosteService; use Octopus\Service\Immobilier\ImmobilierService; use Zend\Mvc\Controller\ControllerManager; class PosteControllerFactory { Loading @@ -11,12 +12,15 @@ class PosteControllerFactory { { /** * @var PosteService $posteService * @var ImmobilierService $immobilierService */ $posteService = $controllerManager->getServiceLocator()->get(PosteService::class); $immobilierService = $controllerManager->getServiceLocator()->get(ImmobilierService::class); /** @var PosteController $controller */ $controller = new PosteController(); $controller->setPosteService($posteService); $controller->setImmobiliserService($immobilierService); return $controller; } } No newline at end of file
module/Application/src/Application/Form/Poste/PosteForm.php +13 −10 Changes for module/Application/src/Application/Form/Poste/PosteForm.php: 13 added lines, 10 removed lines. Original line number Diff line number Diff line Loading @@ -8,16 +8,20 @@ use Application\Entity\Db\Fonction; use Application\Service\Agent\AgentServiceAwareTrait; use Application\Service\RessourceRh\RessourceRhServiceAwareTrait; use DoctrineModule\Form\Element\ObjectSelect; use UnicaenApp\Form\Element\SearchAndSelect; use UnicaenApp\Service\EntityManagerAwareTrait; use Zend\Form\Element\Button; use Zend\Form\Element\Select; use Zend\Form\Element\Text; use Zend\Form\Form; use Zend\ServiceManager\ServiceLocatorAwareTrait; class PosteForm extends Form { use AgentServiceAwareTrait; use RessourceRhServiceAwareTrait; use EntityManagerAwareTrait; use ServiceLocatorAwareTrait; public function init() { Loading Loading @@ -57,16 +61,15 @@ class PosteForm extends Form { ]); // localisation $this->add([ 'type' => Text::class, 'name' => 'localisation', 'options' => [ 'label' => "Localisation :", ], 'attributes' => [ 'id' => 'localisation', ], ]); $sas = new SearchAndSelect('localisation'); $sas->setLabel('Localisation du poste'); $sas->setAttribute('placeholder','Recherchez un batiment'); $sas->setAttribute('class', 'individu-finder'); $sas->setLabelOption('disable_html_escape', false); // $sas->setAutocompleteSource($this->getUrl('poste-form/rechercher-batiment')); $sas->setAutocompleteSource('/poste/rechercher-batiment'); $this->add($sas); // correspondance $this->add([ 'type' => Select::class, Loading
module/Application/src/Application/Form/Poste/PosteFormFactory.php +10 Changes for module/Application/src/Application/Form/Poste/PosteFormFactory.php: 10 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -9,6 +9,15 @@ use Zend\Form\FormElementManager; class PosteFormFactory { protected function getUrl(FormElementManager $manager, $name = null, $params = [], $options = [], $reuseMatchedParams = false) { $url = $manager->getServiceLocator()->get('viewhelpermanager')->get('url'); /* @var $url \Zend\View\Helper\Url */ return $url->__invoke($name, $params, $options, $reuseMatchedParams); } public function __invoke(FormElementManager $manager) { /** Loading @@ -27,6 +36,7 @@ class PosteFormFactory { $form->setEntityManager($entityManager); $form->setAgentService($agentService); $form->setRessourceRhService($ressourceService); //$url = $this->getUrl($manager,'poste/rechercher-batiment', [], [], true); $form->init(); $form->setHydrator($hydrator); Loading