diff --git a/code/template/GenerateRubrique/champInput b/code/template/GenerateRubrique/champInput new file mode 100644 index 0000000000000000000000000000000000000000..9c1cc705d81824f777d15431d1d68d0dfa77ec1f --- /dev/null +++ b/code/template/GenerateRubrique/champInput @@ -0,0 +1,7 @@ +$this->add([ + 'name' => 'champtiret', + 'options' => [ + 'label' => "champphrase", + ], + 'type' => 'Text', + ]); diff --git a/code/template/GenerateRubrique/champListe b/code/template/GenerateRubrique/champListe new file mode 100644 index 0000000000000000000000000000000000000000..37e3d23bc37a96b7ef63cb042d3e17c67fc95ec9 --- /dev/null +++ b/code/template/GenerateRubrique/champListe @@ -0,0 +1,14 @@ +$this->add([ + 'name' => 'champtiret', + 'options' => [ + 'label' => 'champphrase', + ], + 'attributes' => [ + 'class' => 'selectpicker', + 'data-live-search' => 'true', + ], + 'type' => 'Select', + ]); + $this->get('champtiret') + ->setEmptyOption("(Aucun)") + ->setValueOptions(\UnicaenApp\Util::collectionAsOptions($this->getServicechampmaj()->getList())); diff --git a/code/template/GenerateRubrique/config_php b/code/template/GenerateRubrique/config_php new file mode 100644 index 0000000000000000000000000000000000000000..f61b144ded3d2470cfe961de598df799af80e797 --- /dev/null +++ b/code/template/GenerateRubrique/config_php @@ -0,0 +1,103 @@ + [ + 'routes' => [ + 'nomtiret' => [ + 'type' => 'Literal', + 'options' => [ + 'route' => '/nomtiret', + 'defaults' => [ + 'controller' => 'Application\Controller\nommaj', + 'action' => 'index', + ], + ], + 'may_terminate' => true, + 'child_routes' => [ + 'delete' => [ + 'type' => 'Segment', + 'options' => [ + 'route' => '/delete/:nomtiret', + 'constraints' => [ + 'nomtiret' => '[0-9]*', + ], + 'defaults' => [ + 'action' => 'delete', + ], + ], + ], + 'saisie' => [ + 'type' => 'Segment', + 'options' => [ + 'route' => '/saisie/[:nomtiret]', + 'constraints' => [ + 'nomtiret' => '[0-9]*', + ], + 'defaults' => [ + 'action' => 'saisie', + ], + ], + ], + ], + ], + ], + ], + 'navigation' => [ + 'default' => [ + 'home' => [ + 'pages' => [ + 'administration' => [ + 'pages' => [ + 'nomtiret' => [ + 'label' => 'nommaj', + 'icon' => 'fa fa-graduation-cap', + 'route' => 'nomtiret', + 'resource' => PrivilegeController::getResourceId('Application\Controller\nommaj', 'index'), + 'order' => 80, + 'border-color' => '#BBCF55', + ], + ], + ], + ], + ], + ], + ], + 'bjyauthorize' => [ + 'guards' => [ + PrivilegeController::class => [ + [ + 'controller' => 'Application\Controller\nommaj', + 'action' => ['index'], + 'privileges' => Privileges::droitvisualisation, + ], + [ + 'controller' => 'Application\Controller\nommaj', + 'action' => ['saisie','delete'], + 'privileges' => Privileges::droitedition, + ], + ], + ], + ], + 'controllers' => [ + 'invokables' => [ + 'Application\Controller\nommaj' => Controller\nommajController::class, + ], + ], + 'service_manager' => [ + 'invokables' => [ + Service\nommajService::class => Service\nommajService::class, + ], + ], + 'view_helpers' => [ + ], + 'form_elements' => [ + 'invokables' => [ + Form\nommaj\Saisie::class => Form\nommaj\Saisie::class, + ], + ], +]; diff --git a/code/template/GenerateRubrique/controller_php b/code/template/GenerateRubrique/controller_php new file mode 100644 index 0000000000000000000000000000000000000000..0d8f8ec9539b421764a9e4452cb0f3e8eb964b6d --- /dev/null +++ b/code/template/GenerateRubrique/controller_php @@ -0,0 +1,69 @@ +em()->getFilters()->enable('historique')->init([ + nommaj::class, + ]); + + $nomms = $this->getServicenommaj()->getList(); + + return compact('nomms'); + } + + + + public function saisieAction() + { + /* @var $nomm nommaj */ + + $nomm = $this->getEvent()->getParam('nomtiret'); + + $form = $this->getFormnommajSaisie(); + if (empty($nomm)) { + $title = 'Création d\'une nouvelle nommaj'; + $nomm = $this->getServicenommaj()->newEntity(); + } else { + $title = 'Édition d\'une nommaj'; + } + + $form->bindRequestSave($nomm, $this->getRequest(), function (nommaj $fr) { + try { + $this->getServicenommaj()->save($fr); + $this->flashMessenger()->addSuccessMessage('Enregistrement effectué'); + } catch (\Exception $e) { + $e = DbException::translate($e); + $this->flashMessenger()->addErrorMessage($e->getMessage() . ':' . $fr->getId()); + } + }); + + return compact('form', 'title'); + } + + public function deleteAction() + { + $nomm = $this->getEvent()->getParam('nomtiret'); + + try { + $this->getServicenommaj()->delete($nomm); + $this->flashMessenger()->addSuccessMessage("nommaj supprimée avec succès."); + } catch (\Exception $e) { + $this->flashMessenger()->addErrorMessage(DbException::translate($e)->getMessage()); + } + return new MessengerViewModel(compact('nomm')); + } +} diff --git a/code/template/GenerateRubrique/idx1 b/code/template/GenerateRubrique/idx1 new file mode 100644 index 0000000000000000000000000000000000000000..2486d51cf8e06dafe3cf49cbfb0b0b21f9d92a77 --- /dev/null +++ b/code/template/GenerateRubrique/idx1 @@ -0,0 +1,17 @@ +headTitle()->append("nomsouss"); + +$canEdit = $this->isAllowed(Privileges::getResourceId(Privileges::droitedition)); + +?> +

nomsouss

+ + + diff --git a/code/template/GenerateRubrique/idx20 b/code/template/GenerateRubrique/idx20 new file mode 100644 index 0000000000000000000000000000000000000000..f436f2d9e7404b1a663c0c3b9dfb294dd291bdc1 --- /dev/null +++ b/code/template/GenerateRubrique/idx20 @@ -0,0 +1,5 @@ +Actions' ?> + + + + diff --git a/code/template/GenerateRubrique/idx3 b/code/template/GenerateRubrique/idx3 new file mode 100644 index 0000000000000000000000000000000000000000..03107a477361aa81927412ddda01b044b0b5e723 --- /dev/null +++ b/code/template/GenerateRubrique/idx3 @@ -0,0 +1,38 @@ + + + + + + +
+ + + + + +
+ + + + Ajouter une nomsous + + + diff --git a/code/template/GenerateRubrique/saisieFormAwareTrait_php b/code/template/GenerateRubrique/saisieFormAwareTrait_php new file mode 100644 index 0000000000000000000000000000000000000000..c8ada69ba438eeee6c0c4cb0badd418407f3452b --- /dev/null +++ b/code/template/GenerateRubrique/saisieFormAwareTrait_php @@ -0,0 +1,48 @@ +formnommajSaisie = $formnommajSaisie; + + return $this; + } + + + + /** + * Retourne un nouveau formulaire ou fieldset systématiquement, sauf si ce dernier a été fourni manuellement. + * + * @return nommajSaisieForm + */ + public function getFormnommajSaisie() + { + if (!empty($this->formnommajSaisie)) { + return $this->formnommajSaisie; + } + + return \Application::$container->get('FormElementManager')->get(nommajSaisieForm::class); + } +} diff --git a/code/template/GenerateRubrique/saisie_phtml b/code/template/GenerateRubrique/saisie_phtml new file mode 100644 index 0000000000000000000000000000000000000000..3f25fc91b0575916110e586b6deed9ef66f79f35 --- /dev/null +++ b/code/template/GenerateRubrique/saisie_phtml @@ -0,0 +1,8 @@ +messenger()->addCurrentMessagesFromFlashMessenger(); +echo $this->form($form); diff --git a/code/template/GenerateRubrique/serviceTrait_php b/code/template/GenerateRubrique/serviceTrait_php new file mode 100644 index 0000000000000000000000000000000000000000..1c4de1dfd4f3059e90ae920c4f5276ae5fda4bfb --- /dev/null +++ b/code/template/GenerateRubrique/serviceTrait_php @@ -0,0 +1,46 @@ +servicenommaj = $servicenommaj; + + return $this; + } + + + + /** + * @return nommajService + */ + public function getServicenommaj() + { + if (empty($this->servicenommaj)) { + $this->servicenommaj = \Application::$container->get(nommajService::class); + } + + return $this->servicenommaj; + } +} diff --git a/code/template/GenerateRubrique/service_php b/code/template/GenerateRubrique/service_php new file mode 100644 index 0000000000000000000000000000000000000000..ed37814c30cd1326f2883eb298466b26051c709f --- /dev/null +++ b/code/template/GenerateRubrique/service_php @@ -0,0 +1,38 @@ +initQuery(); + return parent::getList($qb, $alias); + } +} diff --git a/composer.lock b/composer.lock index 7313900540e071eb38c1916cb38f523641cdec36..ca1c072378a5b19f7391cf1f25687551d7deffad 100644 --- a/composer.lock +++ b/composer.lock @@ -147,37 +147,33 @@ }, { "name": "doctrine/cache", - "version": "v1.7.1", + "version": "v1.6.2", "source": { "type": "git", "url": "https://github.com/doctrine/cache.git", - "reference": "b3217d58609e9c8e661cd41357a54d926c4a2a1a" + "reference": "eb152c5100571c7a45470ff2a35095ab3f3b900b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/cache/zipball/b3217d58609e9c8e661cd41357a54d926c4a2a1a", - "reference": "b3217d58609e9c8e661cd41357a54d926c4a2a1a", + "url": "https://api.github.com/repos/doctrine/cache/zipball/eb152c5100571c7a45470ff2a35095ab3f3b900b", + "reference": "eb152c5100571c7a45470ff2a35095ab3f3b900b", "shasum": "" }, "require": { - "php": "~7.1" + "php": "~5.5|~7.0" }, "conflict": { "doctrine/common": ">2.2,<2.4" }, "require-dev": { - "alcaeus/mongo-php-adapter": "^1.1", - "mongodb/mongodb": "^1.1", - "phpunit/phpunit": "^5.7", - "predis/predis": "~1.0" - }, - "suggest": { - "alcaeus/mongo-php-adapter": "Required to use legacy MongoDB driver" + "phpunit/phpunit": "~4.8|~5.0", + "predis/predis": "~1.0", + "satooshi/php-coveralls": "~0.6" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.7.x-dev" + "dev-master": "1.6.x-dev" } }, "autoload": { @@ -217,24 +213,24 @@ "cache", "caching" ], - "time": "2017-08-25T07:02:50+00:00" + "time": "2017-07-22T12:49:21+00:00" }, { "name": "doctrine/collections", - "version": "v1.5.0", + "version": "v1.4.0", "source": { "type": "git", "url": "https://github.com/doctrine/collections.git", - "reference": "a01ee38fcd999f34d9bfbcee59dbda5105449cbf" + "reference": "1a4fb7e902202c33cce8c55989b945612943c2ba" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/collections/zipball/a01ee38fcd999f34d9bfbcee59dbda5105449cbf", - "reference": "a01ee38fcd999f34d9bfbcee59dbda5105449cbf", + "url": "https://api.github.com/repos/doctrine/collections/zipball/1a4fb7e902202c33cce8c55989b945612943c2ba", + "reference": "1a4fb7e902202c33cce8c55989b945612943c2ba", "shasum": "" }, "require": { - "php": "^7.1" + "php": "^5.6 || ^7.0" }, "require-dev": { "doctrine/coding-standard": "~0.1@dev", @@ -284,7 +280,7 @@ "collections", "iterator" ], - "time": "2017-07-22T10:37:32+00:00" + "time": "2017-01-03T10:49:41+00:00" }, { "name": "doctrine/common", @@ -361,26 +357,24 @@ }, { "name": "doctrine/dbal", - "version": "v2.6.3", + "version": "v2.5.13", "source": { "type": "git", "url": "https://github.com/doctrine/dbal.git", - "reference": "e3eed9b1facbb0ced3a0995244843a189e7d1b13" + "reference": "729340d8d1eec8f01bff708e12e449a3415af873" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/dbal/zipball/e3eed9b1facbb0ced3a0995244843a189e7d1b13", - "reference": "e3eed9b1facbb0ced3a0995244843a189e7d1b13", + "url": "https://api.github.com/repos/doctrine/dbal/zipball/729340d8d1eec8f01bff708e12e449a3415af873", + "reference": "729340d8d1eec8f01bff708e12e449a3415af873", "shasum": "" }, "require": { - "doctrine/common": "^2.7.1", - "ext-pdo": "*", - "php": "^7.1" + "doctrine/common": ">=2.4,<2.8-dev", + "php": ">=5.3.2" }, "require-dev": { - "phpunit/phpunit": "^5.4.6", - "phpunit/phpunit-mock-objects": "!=3.2.4,!=3.2.5", + "phpunit/phpunit": "4.*", "symfony/console": "2.*||^3.0" }, "suggest": { @@ -392,7 +386,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.6.x-dev" + "dev-master": "2.5.x-dev" } }, "autoload": { @@ -430,7 +424,7 @@ "persistence", "queryobject" ], - "time": "2017-11-19T13:38:54+00:00" + "time": "2017-07-22T20:44:48+00:00" }, { "name": "doctrine/doctrine-module", @@ -590,20 +584,20 @@ }, { "name": "doctrine/inflector", - "version": "v1.3.0", + "version": "v1.2.0", "source": { "type": "git", "url": "https://github.com/doctrine/inflector.git", - "reference": "5527a48b7313d15261292c149e55e26eae771b0a" + "reference": "e11d84c6e018beedd929cff5220969a3c6d1d462" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/inflector/zipball/5527a48b7313d15261292c149e55e26eae771b0a", - "reference": "5527a48b7313d15261292c149e55e26eae771b0a", + "url": "https://api.github.com/repos/doctrine/inflector/zipball/e11d84c6e018beedd929cff5220969a3c6d1d462", + "reference": "e11d84c6e018beedd929cff5220969a3c6d1d462", "shasum": "" }, "require": { - "php": "^7.1" + "php": "^7.0" }, "require-dev": { "phpunit/phpunit": "^6.2" @@ -611,7 +605,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.3.x-dev" + "dev-master": "1.2.x-dev" } }, "autoload": { @@ -653,36 +647,36 @@ "singularize", "string" ], - "time": "2018-01-09T20:05:19+00:00" + "time": "2017-07-22T12:18:28+00:00" }, { "name": "doctrine/instantiator", - "version": "1.1.0", + "version": "1.0.5", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda" + "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", - "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d", + "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d", "shasum": "" }, "require": { - "php": "^7.1" + "php": ">=5.3,<8.0-DEV" }, "require-dev": { "athletic/athletic": "~0.1.8", "ext-pdo": "*", "ext-phar": "*", - "phpunit/phpunit": "^6.2.3", - "squizlabs/php_codesniffer": "^3.0.2" + "phpunit/phpunit": "~4.0", + "squizlabs/php_codesniffer": "~2.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.2.x-dev" + "dev-master": "1.0.x-dev" } }, "autoload": { @@ -707,7 +701,7 @@ "constructor", "instantiate" ], - "time": "2017-07-22T11:58:36+00:00" + "time": "2015-06-14T21:17:01+00:00" }, { "name": "doctrine/lexer", diff --git a/module/Application/config/modulateur.config.php b/module/Application/config/modulateur.config.php index 05d60c9311d550f813639ca08aff44563988b236..bcd95aec5098bf8367962a3430f517dc49f13f6f 100644 --- a/module/Application/config/modulateur.config.php +++ b/module/Application/config/modulateur.config.php @@ -73,6 +73,32 @@ return [ ], 'may_terminate' => true, ], + 'type-modulateur-structure-saisie' => [ + 'type' => 'Segment', + 'options' => [ + 'route' => '/type-modulateur-structure-saisie/:typeModulateur', + 'constraints' => [ + 'typeModulateur' => '[0-9]*', + ], + 'defaults' => [ + 'action' => 'type-modulateur-structure-saisie', + ], + ], + 'may_terminate' => true, + ], + 'type-modulateur-structure-delete' => [ + 'type' => 'Segment', + 'options' => [ + 'route' => '/type-modulateur-structure-delete/:typeModulateurStructure', + 'constraints' => [ + 'typeModulateurStructure' => '[0-9]*', + ], + 'defaults' => [ + 'action' => 'type-modulateur-structure-delete', + ], + ], + 'may_terminate' => true, + ], ], ], ], @@ -106,7 +132,7 @@ return [ ], [ 'controller' => 'Application\Controller\Modulateur', - 'action' => ['saisie', 'delete', 'type-modulateur-saisie', 'type-modulateur-delete'], + 'action' => ['saisie', 'delete', 'type-modulateur-saisie', 'type-modulateur-delete','type-modulateur-structure-saisie','type-modulateur-structure-delete'], 'privileges' => [Privileges::MODULATEUR_EDITION], ], ], @@ -143,6 +169,7 @@ return [ 'invokables' => [ Form\Modulateur\ModulateurSaisieForm::class => Form\Modulateur\ModulateurSaisieForm::class, Form\Modulateur\TypeModulateurSaisieForm::class => Form\Modulateur\TypeModulateurSaisieForm::class, + Form\Modulateur\TypeModulateurStructureSaisieForm::class => Form\Modulateur\TypeModulateurStructureSaisieForm::class, ], ], ]; diff --git a/module/Application/src/Application/Controller/ModulateurController.php b/module/Application/src/Application/Controller/ModulateurController.php index 116b6d25f8ab18b2bd2ba02b978cef2707e2cfb1..b2d800cf3cce800c4dd5c79cb07a36802b327773 100755 --- a/module/Application/src/Application/Controller/ModulateurController.php +++ b/module/Application/src/Application/Controller/ModulateurController.php @@ -12,6 +12,7 @@ use Application\Form\Modulateur\Traits\ModulateurSaisieFormAwareTrait; use UnicaenApp\View\Model\MessengerViewModel; use Application\Service\Traits\TypeModulateurServiceAwareTrait; use Application\Form\Modulateur\Traits\TypeModulateurSaisieFormAwareTrait; +use Application\Form\Modulateur\Traits\TypeModulateurStructureSaisieFormAwareTrait; use Application\Service\Traits\ContextServiceAwareTrait; class modulateurController extends AbstractController @@ -21,6 +22,7 @@ class modulateurController extends AbstractController use ModulateurSaisieFormAwareTrait; use TypeModulateurSaisieFormAwareTrait; use TypeModulateurStructureServiceAwareTrait; + use TypeModulateurStructureSaisieFormAwareTrait; use ContextServiceAwareTrait; @@ -138,6 +140,49 @@ class modulateurController extends AbstractController $this->flashMessenger()->addErrorMessage(DbException::translate($e)->getMessage()); } + return new MessengerViewModel(compact('typeModulateur')); + } + public function typeModulateurStructureSaisieAction() + { + /* @var $typeModulateurStructure typeModulateurStructure */ + /* @var $typeModulateur typeModulateur */ + $typeModulateur = $this->getEvent()->getParam('typeModulateur'); + + $form = $this->getFormTypeModulateurStructureSaisie(); + // if (empty($typeModulateurStructure)) { + $title = 'Création d\'un nouveau Type de Modulateur de Structure'; + $typeModulateurStructure = $this->getServiceTypeModulateurStructure()->newEntity() + ->setTypeModulateur($typeModulateur); + // } else { + //$title = 'Édition d\'un Type de Modulateur pour une structure'; + //} + + $form->bindRequestSave($typeModulateurStructure, $this->getRequest(), function (typeModulateurStructure $tms) { + try { + $this->getServiceTypeModulateurStructure()->save($tms); + $this->flashMessenger()->addSuccessMessage('Enregistrement effectué'); + } catch (\Exception $e) { + $e = DbException::translate($e); + $this->flashMessenger()->addErrorMessage($e->getMessage() . ':' . $tms->getId().':'.$tms->getTypeModulateur()); + } + }); + + return compact('form', 'title'); + } + + + + public function typeModulateurStructureDeleteAction() + { + /* @var $typeModulateurStructure typeModulateurStructure */ + $typeModulateurStructure = $this->getEvent()->getParam('typeModulateurStructure'); + try { + $this->getServiceTypeModulateurStructure()->delete($typeModulateurStructure); + $this->flashMessenger()->addSuccessMessage("Type de Modulateur de structure supprimé avec succès."); + } catch (\Exception $e) { + $this->flashMessenger()->addErrorMessage(DbException::translate($e)->getMessage()); + } + return new MessengerViewModel(compact('typeModulateur')); } } \ No newline at end of file diff --git a/module/Application/src/Application/Entity/Db/Mapping/Application.Entity.Db.TypeModulateurStructure.dcm.xml b/module/Application/src/Application/Entity/Db/Mapping/Application.Entity.Db.TypeModulateurStructure.dcm.xml index 518fc5bd6e1cbad7a3f66f24a6a8433b96785790..baa16aaaa9a4a6a7d9b314cb39ce7708e53fde5f 100644 --- a/module/Application/src/Application/Entity/Db/Mapping/Application.Entity.Db.TypeModulateurStructure.dcm.xml +++ b/module/Application/src/Application/Entity/Db/Mapping/Application.Entity.Db.TypeModulateurStructure.dcm.xml @@ -13,10 +13,17 @@ + + + + + + + diff --git a/module/Application/src/Application/Entity/Db/TypeModulateurStructure.php b/module/Application/src/Application/Entity/Db/TypeModulateurStructure.php index e36a9c82350dd31093489fc103b64de75a82b8b3..b5edd8d39ee9696ff43983a5d36c6bba5ad92a97 100644 --- a/module/Application/src/Application/Entity/Db/TypeModulateurStructure.php +++ b/module/Application/src/Application/Entity/Db/TypeModulateurStructure.php @@ -26,6 +26,15 @@ class TypeModulateurStructure implements HistoriqueAwareInterface */ protected $structure; + /** + * @var Annee + */ + private $anneeDebut; + + /** + * @var Annee + */ + private $anneeFin; /** @@ -93,4 +102,51 @@ class TypeModulateurStructure implements HistoriqueAwareInterface { return $this->structure; } + + /** + * @return Annee + */ + public function getAnneeDebut() + { + return $this->anneeDebut; + } + + + + /** + * @param Annee $anneeDebut + * + * @return TypeInterventionStructure + */ + public function setAnneeDebut(Annee $anneeDebut = null) + { + $this->anneeDebut = $anneeDebut; + + return $this; + } + + + + /** + * @return Annee + */ + public function getAnneeFin() + { + return $this->anneeFin; + } + + + + /** + * @param Annee $anneeFin + * + * @return TypeInterventionStructure + */ + public function setAnneeFin(Annee $anneeFin = null) + { + $this->anneeFin = $anneeFin; + + return $this; + } + } diff --git a/module/Application/src/Application/Form/Modulateur/Traits/TypeModulateurStructureSaisieFormAwareTrait.php b/module/Application/src/Application/Form/Modulateur/Traits/TypeModulateurStructureSaisieFormAwareTrait.php new file mode 100755 index 0000000000000000000000000000000000000000..4a72c2a711c66e812b56598d95db027cf622d111 --- /dev/null +++ b/module/Application/src/Application/Form/Modulateur/Traits/TypeModulateurStructureSaisieFormAwareTrait.php @@ -0,0 +1,49 @@ +formTypeModulateurStrucureSaisie = $formTypeModulateurStructureSaisie; + + return $this; + } + + + + /** + * Retourne un nouveau formulaire ou fieldset systématiquement, sauf si ce dernier a été fourni manuellement. + * + * @return TypeModulateurStructureSaisieForm + */ + public function getFormTypeModulateurStructureSaisie() + { + if (!empty($this->formTypeModulateurStructureSaisie)) { + return $this->formTypeModulateurStructureSaisie; + } + + return \Application::$container->get('FormElementManager')->get(TypeModulateurStructureSaisieForm::class); + } +} + diff --git a/module/Application/src/Application/Form/Modulateur/TypeModulateurStructureSaisieForm.php b/module/Application/src/Application/Form/Modulateur/TypeModulateurStructureSaisieForm.php new file mode 100644 index 0000000000000000000000000000000000000000..fe0f3dbe137df7d0ab1118647435962f53ac51bd --- /dev/null +++ b/module/Application/src/Application/Form/Modulateur/TypeModulateurStructureSaisieForm.php @@ -0,0 +1,187 @@ + + */ +class typeModulateurStructureSaisieForm extends AbstractForm +{ + use ContextServiceAwareTrait; + use TypeModulateurStructureServiceAwareTrait; + use StructureServiceAwareTrait; + use AnneeServiceAwareTrait; + use TypeModulateurServiceAwareTrait; + + + + public function init() + { + $hydrator = new typeModulateurStructureHydrator(); + /** + * @var $typesModu \Application\Entity\Db\typeModulateurStructure[] + */ + $this->setHydrator($hydrator); + + $this->setAttribute('action', $this->getCurrentUrl()); + $this->add([ + 'name' => 'type-modulateur', + 'type' => 'Hidden', + ] + ); + + $this->add([ + 'name' => 'structure', + 'options' => [ + 'label' => 'Structure', + ], + 'attributes' => [ + 'class' => 'selectpicker', + 'data-live-search' => 'true', + ], + 'type' => 'Select', + ]); + + $this->add([ + 'type' => 'Select', + 'name' => 'annee-debut', + 'options' => [ + 'empty_option' => 'Aucune', + 'value_options' => Util::collectionAsOptions($this->getServiceAnnee()->getChoixAnnees()), + 'label' => 'année de début', + ], + 'attributes' => [ + 'class' => 'selectpicker', + 'data-live-search' => 'true', + ], + ]); + $this->add([ + 'type' => 'Select', + 'name' => 'annee-fin', + 'options' => [ + 'empty_option' => 'Aucune', + 'value_options' => Util::collectionAsOptions($this->getServiceAnnee()->getChoixAnnees()), + 'label' => 'année de fin', + ], + 'attributes' => [ + 'class' => 'selectpicker', + 'data-live-search' => 'true', + ], + ]); + + + $this->add(new Csrf('security')); + $this->add([ + 'name' => 'submit', + 'type' => 'Submit', + 'attributes' => [ + 'value' => "Enregistrer", + 'class' => 'btn btn-primary', + ], + ]); + + $role = $this->getServiceContext()->getSelectedIdentityRole(); + $serviceStructure = $this->getServiceStructure(); + $qb = $serviceStructure->finderByEnseignement(); + if ($role->getStructure()) { + $serviceStructure->finderById($role->getStructure()->getId(), $qb); // Filtre + } + $this->get('structure') + ->setValueOptions(\UnicaenApp\Util::collectionAsOptions($serviceStructure->getList($qb))); + + return $this; + } + + + + /** + * Should return an array specification compatible with + * {@link Zend\InputFilter\Factory::createInputFilter()}. + * + * @return array + */ + public function getInputFilterSpecification() + { + return [ + 'annee-debut' => [ + 'required' => false, + ], + 'annee-fin' => [ + 'required' => false, + ], + ]; + } + +} + + + + + +class typeModulateurStructureHydrator implements HydratorInterface +{ + use TypeModulateurStructureServiceAwareTrait; + use StructureServiceAwareTrait; + use AnneeServiceAwareTrait; + use TypeModulateurServiceAwareTrait; + + + /** + * Hydrate $object with the provided $data. + * + * @param array $data + * @param \Application\Entity\Db\typeModulateurStructure $object + * + * @return object + */ + public function hydrate(array $data, $object) + { + $object->setTypeModulateur($this->getServiceTypeModulateur()->getById($data['type-modulateur'])); + if (array_key_exists('structure', $data)) { + $object->setStructure($this->getServiceStructure()->get($data['structure'])); + } + if (array_key_exists('annee-debut', $data)) { + $object->setAnneeDebut($this->getServiceAnnee()->get($data['annee-debut'])); + } + if (array_key_exists('annee-fin', $data)) { + $object->setAnneeFin($this->getServiceAnnee()->get($data['annee-fin'])); + } + + return $object; + } + + + + /** + * Extract values from an object + * + * @param \Application\Entity\Db\typeModulateurStructure $object + * + * @return array + */ + public function extract($object) + { + $data = [ + 'id' => $object->getId(), + 'type-modulateur' => $object->getTypeModulateur()->getId(), + 'structure' => ($s = $object->getStructure()) ? $s->getId() : null, + 'annee-debut' => $object->getAnneeDebut() ? $object->getAnneeDebut()->getId() : null, + 'annee-fin' => $object->getAnneeFin() ? $object->getAnneeFin()->getId() : null, + ]; + + return $data; + } +} \ No newline at end of file diff --git a/module/Application/src/Application/Service/TypeModulateurService.php b/module/Application/src/Application/Service/TypeModulateurService.php index a79370791108bec4c0d0cf7e1ca4f5bd797b9a7e..61032631da520b99fd0e56f47b39fa97cc56033c 100644 --- a/module/Application/src/Application/Service/TypeModulateurService.php +++ b/module/Application/src/Application/Service/TypeModulateurService.php @@ -5,6 +5,7 @@ namespace Application\Service; use Application\Entity\Db\TypeModulateur; use Application\Entity\Db\Structure; use Application\Entity\Db\ElementPedagogique; +use Application\Entity\Db\TypeModulateurStructure; use Doctrine\ORM\QueryBuilder; @@ -89,6 +90,25 @@ class TypeModulateurService extends AbstractEntityService } } + /** + * Retourne une entité à partir de son code + * Retourne null si le code est null + * + * @param string|string[] $code + * @return mixed|null + */ + public function getById($id) + { + if(is_array($id)){ + list($qb,$alias) = $this->initQuery(); + $qb->andWhere($alias.'.id IN (:'.$alias.'_id)')->setParameter($alias.'_id', $id); + return $this->getList( $qb ); + }elseif ($id){ + return $this->getRepo()->findOneBy(['id' => $id]); + }else{ + return null; + } + } /** * Ne récupère que les types de modulateurs associés à un élément pédagogique donné * @@ -143,4 +163,5 @@ class TypeModulateurService extends AbstractEntityService } return $this->all; } + } \ No newline at end of file diff --git a/module/Application/view/application/modulateur/index.phtml b/module/Application/view/application/modulateur/index.phtml index 3e475f6529303d86a7a47029355a68319aa3d094..40a921fd53d0cb1184b54b6551c40db94886de97 100644 --- a/module/Application/view/application/modulateur/index.phtml +++ b/module/Application/view/application/modulateur/index.phtml @@ -1,12 +1,12 @@ isAllowed(Privileges::getResourceId(Privileges::MODULATEUR_EDI

Modulateurs des taux horaires

isAllowed($tm,Privileges::MODULATEUR_VISUALISATION)) { ?> + if ($this->isAllowed($tm, Privileges::MODULATEUR_VISUALISATION)) { ?>
@@ -123,12 +165,12 @@ foreach ($typeModulateurs as $tm) { - - - - Ajouter un type de modulateur + + + + Ajouter un type de modulateur