Loading module/Application/config/merged/agent.config.php +26 −1 Changes for module/Application/config/merged/agent.config.php: 26 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -8,6 +8,8 @@ use Application\Form\Agent\AgentForm; use Application\Form\Agent\AgentFormFactory; use Application\Form\Agent\AgentHydrator; use Application\Form\Agent\AgentHydratorFactory; use Application\Form\Agent\AgentImportForm; use Application\Form\Agent\AgentImportFormFactory; use Application\Provider\Privilege\AgentPrivileges; use Application\Service\Agent\AgentService; use Application\Service\Agent\AgentServiceFactory; Loading @@ -34,6 +36,8 @@ return [ 'controller' => AgentController::class, 'action' => [ 'ajouter', 'importer', 'rechercher-individu', ], 'privileges' => [ AgentPrivileges::AJOUTER, Loading Loading @@ -113,7 +117,27 @@ return [ 'action' => 'ajouter', ], ], ] ], 'importer' => [ 'type' => Literal::class, 'options' => [ 'route' => '/importer', 'defaults' => [ 'controller' => AgentController::class, 'action' => 'importer', ], ], ], 'rechercher-individu' => [ 'type' => Literal::class, 'options' => [ 'route' => '/rechercher-individu', 'defaults' => [ 'controller' => AgentController::class, 'action' => 'rechercher-individu', ], ], ], ], ], ], Loading @@ -134,6 +158,7 @@ return [ 'form_elements' => [ 'factories' => [ AgentForm::class => AgentFormFactory::class, AgentImportForm::class => AgentImportFormFactory::class, ], ], 'hydrators' => [ Loading module/Application/src/Application/Controller/Agent/AgentController.php +48 Changes for module/Application/src/Application/Controller/Agent/AgentController.php: 48 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -5,17 +5,23 @@ namespace Application\Controller\Agent; use Application\Entity\Db\Agent; use Application\Form\Agent\AgentForm; use Application\Form\Agent\AgentFormAwareTrait; use Application\Form\Agent\AgentImportFormAwareTrait; use Application\Service\Agent\AgentServiceAwareTrait; use Octopus\Entity\Db\Individu; use Octopus\Service\Individu\IndividuServiceAwareTrait; use Zend\Http\Request; use Zend\Mvc\Controller\AbstractActionController; use Zend\View\Model\JsonModel; use Zend\View\Model\ViewModel; class AgentController extends AbstractActionController { /** Trait utilisés pour les services */ use AgentServiceAwareTrait; use IndividuServiceAwareTrait; /** Trait utilisés pour les formulaires */ use AgentFormAwareTrait; use AgentImportFormAwareTrait; public function indexAction() { Loading Loading @@ -105,4 +111,46 @@ class AgentController extends AbstractActionController $this->redirect()->toRoute('agent', [], [], true); } public function importerAction() { $form = $this->getAgentImportForm(); $form->setAttribute('method','post'); /** @var Request $request */ $request = $this->getRequest(); if ($request->isPost()) { $data = $request->getPost(); var_dump($data); //$this->redirect()->toRoute('agent/importer'); } return new ViewModel([ 'form' => $form, ]); } /** * @return JsonModel */ public function rechercherIndividuAction() { if (($term = $this->params()->fromQuery('term'))) { $individus = $this->getIndividuService()->getIndividusByTerm($term); $result = []; /** @var Individu[] $individus */ foreach ($individus as $individu) { $result[] = array( 'id' => $individu->getCIndividuChaine(), 'label' => $individu->getPrenom()." ".$individu->getNomUsage(), 'extra' => "<span class='badge' style='background-color: slategray;'>".$individu->getCSource()."</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/Agent/AgentControllerFactory.php +17 −2 Changes for module/Application/src/Application/Controller/Agent/AgentControllerFactory.php: 17 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -3,23 +3,38 @@ namespace Application\Controller\Agent; use Application\Form\Agent\AgentForm; use Application\Form\Agent\AgentImportForm; use Application\Service\Agent\AgentService; use Octopus\Service\Individu\IndividuService; use Zend\Mvc\Controller\ControllerManager; class AgentControllerFactory { public function __invoke(ControllerManager $manager) { /** @var AgentService $agentService */ /** * @var AgentService $agentService * @var IndividuService $individuService */ $agentService = $manager->getServiceLocator()->get(AgentService::class); $individuService = $manager->getServiceLocator()->get(IndividuService::class); /** @var AgentForm $agentForm */ /** * @var AgentForm $agentForm * @var AgentImportForm $agentImportForm */ $agentForm = $manager->getServiceLocator()->get('FormElementManager')->get(AgentForm::class); $agentImportForm = $manager->getServiceLocator()->get('FormElementManager')->get(AgentImportForm::class); /** @var AgentController $controller */ $controller = new AgentController(); $controller->setAgentService($agentService); $controller->setIndividuService($individuService); $controller->setAgentForm($agentForm); $controller->setAgentImportForm($agentImportForm); return $controller; } } No newline at end of file module/Application/src/Application/Form/Agent/AgentImportForm.php +42 Changes for module/Application/src/Application/Form/Agent/AgentImportForm.php: 42 added lines, 0 removed lines. Original line number Diff line number Diff line <?php namespace Application\Form\Agent; use Application\Form\AutocompleteAwareTrait; use UnicaenApp\Form\Element\SearchAndSelect; use Zend\Form\Element\Button; use Zend\Form\Form; class AgentImportForm extends Form { use AutocompleteAwareTrait; public function init() { $sas = new SearchAndSelect('agent'); $sas->setLabel('Agent provenant d\'Octopus'); $sas->setAttribute('placeholder','Recherchez un agent'); $sas->setAttribute('class', 'individu-finder'); $sas->setLabelOption('disable_html_escape', false); $sas->setAutocompleteSource($this->getAutocomplete()); $this->add($sas); // button $this->add([ 'type' => Button::class, 'name' => 'creer', 'options' => [ 'label' => '<i class="fas fa-user-cog"></i> Importer l\'agent', 'label_options' => [ 'disable_html_escape' => true, ], ], 'attributes' => [ 'type' => 'submit', 'class' => 'btn btn-primary', ], ]); } } No newline at end of file module/Application/src/Application/Form/Agent/AgentImportFormAwareTrait.php +29 Changes for module/Application/src/Application/Form/Agent/AgentImportFormAwareTrait.php: 29 added lines, 0 removed lines. Original line number Diff line number Diff line <?php namespace Application\Form\Agent; trait AgentImportFormAwareTrait { /** @var AgentImportForm $agentImportForm */ private $agentImportForm; /** * @return AgentImportForm */ public function getAgentImportForm() { return $this->agentImportForm; } /** * @param AgentImportForm $agentImportForm * @return AgentImportForm */ public function setAgentImportForm($agentImportForm) { $this->agentImportForm = $agentImportForm; return $this->agentImportForm; } } No newline at end of file Loading
module/Application/config/merged/agent.config.php +26 −1 Changes for module/Application/config/merged/agent.config.php: 26 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -8,6 +8,8 @@ use Application\Form\Agent\AgentForm; use Application\Form\Agent\AgentFormFactory; use Application\Form\Agent\AgentHydrator; use Application\Form\Agent\AgentHydratorFactory; use Application\Form\Agent\AgentImportForm; use Application\Form\Agent\AgentImportFormFactory; use Application\Provider\Privilege\AgentPrivileges; use Application\Service\Agent\AgentService; use Application\Service\Agent\AgentServiceFactory; Loading @@ -34,6 +36,8 @@ return [ 'controller' => AgentController::class, 'action' => [ 'ajouter', 'importer', 'rechercher-individu', ], 'privileges' => [ AgentPrivileges::AJOUTER, Loading Loading @@ -113,7 +117,27 @@ return [ 'action' => 'ajouter', ], ], ] ], 'importer' => [ 'type' => Literal::class, 'options' => [ 'route' => '/importer', 'defaults' => [ 'controller' => AgentController::class, 'action' => 'importer', ], ], ], 'rechercher-individu' => [ 'type' => Literal::class, 'options' => [ 'route' => '/rechercher-individu', 'defaults' => [ 'controller' => AgentController::class, 'action' => 'rechercher-individu', ], ], ], ], ], ], Loading @@ -134,6 +158,7 @@ return [ 'form_elements' => [ 'factories' => [ AgentForm::class => AgentFormFactory::class, AgentImportForm::class => AgentImportFormFactory::class, ], ], 'hydrators' => [ Loading
module/Application/src/Application/Controller/Agent/AgentController.php +48 Changes for module/Application/src/Application/Controller/Agent/AgentController.php: 48 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -5,17 +5,23 @@ namespace Application\Controller\Agent; use Application\Entity\Db\Agent; use Application\Form\Agent\AgentForm; use Application\Form\Agent\AgentFormAwareTrait; use Application\Form\Agent\AgentImportFormAwareTrait; use Application\Service\Agent\AgentServiceAwareTrait; use Octopus\Entity\Db\Individu; use Octopus\Service\Individu\IndividuServiceAwareTrait; use Zend\Http\Request; use Zend\Mvc\Controller\AbstractActionController; use Zend\View\Model\JsonModel; use Zend\View\Model\ViewModel; class AgentController extends AbstractActionController { /** Trait utilisés pour les services */ use AgentServiceAwareTrait; use IndividuServiceAwareTrait; /** Trait utilisés pour les formulaires */ use AgentFormAwareTrait; use AgentImportFormAwareTrait; public function indexAction() { Loading Loading @@ -105,4 +111,46 @@ class AgentController extends AbstractActionController $this->redirect()->toRoute('agent', [], [], true); } public function importerAction() { $form = $this->getAgentImportForm(); $form->setAttribute('method','post'); /** @var Request $request */ $request = $this->getRequest(); if ($request->isPost()) { $data = $request->getPost(); var_dump($data); //$this->redirect()->toRoute('agent/importer'); } return new ViewModel([ 'form' => $form, ]); } /** * @return JsonModel */ public function rechercherIndividuAction() { if (($term = $this->params()->fromQuery('term'))) { $individus = $this->getIndividuService()->getIndividusByTerm($term); $result = []; /** @var Individu[] $individus */ foreach ($individus as $individu) { $result[] = array( 'id' => $individu->getCIndividuChaine(), 'label' => $individu->getPrenom()." ".$individu->getNomUsage(), 'extra' => "<span class='badge' style='background-color: slategray;'>".$individu->getCSource()."</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/Agent/AgentControllerFactory.php +17 −2 Changes for module/Application/src/Application/Controller/Agent/AgentControllerFactory.php: 17 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -3,23 +3,38 @@ namespace Application\Controller\Agent; use Application\Form\Agent\AgentForm; use Application\Form\Agent\AgentImportForm; use Application\Service\Agent\AgentService; use Octopus\Service\Individu\IndividuService; use Zend\Mvc\Controller\ControllerManager; class AgentControllerFactory { public function __invoke(ControllerManager $manager) { /** @var AgentService $agentService */ /** * @var AgentService $agentService * @var IndividuService $individuService */ $agentService = $manager->getServiceLocator()->get(AgentService::class); $individuService = $manager->getServiceLocator()->get(IndividuService::class); /** @var AgentForm $agentForm */ /** * @var AgentForm $agentForm * @var AgentImportForm $agentImportForm */ $agentForm = $manager->getServiceLocator()->get('FormElementManager')->get(AgentForm::class); $agentImportForm = $manager->getServiceLocator()->get('FormElementManager')->get(AgentImportForm::class); /** @var AgentController $controller */ $controller = new AgentController(); $controller->setAgentService($agentService); $controller->setIndividuService($individuService); $controller->setAgentForm($agentForm); $controller->setAgentImportForm($agentImportForm); return $controller; } } No newline at end of file
module/Application/src/Application/Form/Agent/AgentImportForm.php +42 Changes for module/Application/src/Application/Form/Agent/AgentImportForm.php: 42 added lines, 0 removed lines. Original line number Diff line number Diff line <?php namespace Application\Form\Agent; use Application\Form\AutocompleteAwareTrait; use UnicaenApp\Form\Element\SearchAndSelect; use Zend\Form\Element\Button; use Zend\Form\Form; class AgentImportForm extends Form { use AutocompleteAwareTrait; public function init() { $sas = new SearchAndSelect('agent'); $sas->setLabel('Agent provenant d\'Octopus'); $sas->setAttribute('placeholder','Recherchez un agent'); $sas->setAttribute('class', 'individu-finder'); $sas->setLabelOption('disable_html_escape', false); $sas->setAutocompleteSource($this->getAutocomplete()); $this->add($sas); // button $this->add([ 'type' => Button::class, 'name' => 'creer', 'options' => [ 'label' => '<i class="fas fa-user-cog"></i> Importer l\'agent', 'label_options' => [ 'disable_html_escape' => true, ], ], 'attributes' => [ 'type' => 'submit', 'class' => 'btn btn-primary', ], ]); } } No newline at end of file
module/Application/src/Application/Form/Agent/AgentImportFormAwareTrait.php +29 Changes for module/Application/src/Application/Form/Agent/AgentImportFormAwareTrait.php: 29 added lines, 0 removed lines. Original line number Diff line number Diff line <?php namespace Application\Form\Agent; trait AgentImportFormAwareTrait { /** @var AgentImportForm $agentImportForm */ private $agentImportForm; /** * @return AgentImportForm */ public function getAgentImportForm() { return $this->agentImportForm; } /** * @param AgentImportForm $agentImportForm * @return AgentImportForm */ public function setAgentImportForm($agentImportForm) { $this->agentImportForm = $agentImportForm; return $this->agentImportForm; } } No newline at end of file