diff --git a/module/Application/config/modulateur.config.php b/module/Application/config/modulateur.config.php index 05d60c9311d550f813639ca08aff44563988b236..2c470bdf055b4061c314fd31f64cdea526565c71 100644 --- a/module/Application/config/modulateur.config.php +++ b/module/Application/config/modulateur.config.php @@ -73,6 +73,33 @@ return [ ], 'may_terminate' => true, ], + 'type-modulateur-structure-saisie' => [ + 'type' => 'Segment', + 'options' => [ + 'route' => '/type-modulateur-structure-saisie/:typeModulateur[/:typeModulateurStructure]', + 'constraints' => [ + 'typeModulateur' => '[0-9]*', + 'typeModulateurStructure' => '[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, + ], ], ], ], @@ -84,7 +111,8 @@ return [ 'administration' => [ 'pages' => [ 'modulateur' => [ - 'label' => 'Modulateurs des taux horaires', + 'label' => 'Modulateur', + 'title' => 'Modulateurs', 'icon' => 'fa fa-tachometer', 'route' => 'modulateur', 'resource' => PrivilegeController::getResourceId('Application\Controller\Modulateur', 'index'), @@ -99,14 +127,14 @@ return [ 'guards' => [ PrivilegeController::class => [ [ + 'controller' => 'Application\Controller\Modulateur', 'action' => ['index'], 'privileges' => [Privileges::MODULATEUR_VISUALISATION], - 'assertion' => Assertion\ModulateurAssertion::class, ], [ '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 +171,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..86493781832094c5fb36001c7a8e5c3428cf9221 100755 --- a/module/Application/src/Application/Controller/ModulateurController.php +++ b/module/Application/src/Application/Controller/ModulateurController.php @@ -1,8 +1,8 @@ <?php namespace Application\Controller; - use Application\Entity\Db\Modulateur; +use Application\Form\Modulateur\Traits\TypeModulateurStrctureSaisieFormAwareTrait; use Application\Service\Traits\ModulateurServiceAwareTrait; use Application\Entity\Db\TypeModulateurStructure; use Application\Service\Traits\TypeModulateurStructureServiceAwareTrait; @@ -12,7 +12,9 @@ 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; +use Application\Service\Traits\StructureServiceAwareTrait; class modulateurController extends AbstractController { @@ -20,8 +22,10 @@ class modulateurController extends AbstractController use TypeModulateurServiceAwareTrait; use ModulateurSaisieFormAwareTrait; use TypeModulateurSaisieFormAwareTrait; + use TypeModulateurStructureSaisieFormAwareTrait; use TypeModulateurStructureServiceAwareTrait; use ContextServiceAwareTrait; + use StructureServiceAwareTrait; @@ -48,7 +52,9 @@ class modulateurController extends AbstractController $role = $this->getServiceContext()->getSelectedIdentityRole(); $structure = $role->getStructure(); - return compact('modulateurs', 'typeModulateurs','typeModulateurStructures','structure'); + $annee=$this->getServiceContext()->getAnnee(); + + return compact('modulateurs', 'typeModulateurs','typeModulateurStructures','structure','annee'); } @@ -125,7 +131,44 @@ class modulateurController extends AbstractController return compact('form', 'title'); } + public function typeModulateurStructureSaisieAction(){ + /* @var $typeModulateur typeModulateur */ + /* @var $typeModulateurStructure typeModulateurStructure */ + $typeModulateur = $this->getEvent()->getParam('typeModulateur'); + $typeModulateurStructure = $this->getEvent()->getParam('typeModulateurStructure'); + + $form = $this->getFormTypeModulateurStructureSaisie(); + if (empty($typeModulateurStructure)) { + $title = 'Création d\'un nouveau Type de Modulateur'; + $typeModulateurStructure = $this->getServiceTypeModulateurStructure()->newEntity(); + $typeModulateurStructure->setTypeModulateur($typeModulateur); + } else { + $title = 'Édition d\'une structure d\'un Type de Modulateur'; + } + $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()); + } + }); + + return compact('form', 'title'); + } + + public function typeModulateurStructureDeleteAction(){ + $typeModulateurStructure = $this->getEvent()->getParam('typeModulateurStructure'); + try { + $this->getServiceTypeModulateurStructure()->delete($typeModulateurStructure); + $this->flashMessenger()->addSuccessMessage("Structure supprimée avec succès pour ce type de modulateur."); + } catch (\Exception $e) { + $this->flashMessenger()->addErrorMessage(DbException::translate($e)->getMessage()); + } + return new MessengerViewModel(compact('typeModulateurStructure')); + } public function typeModulateurDeleteAction() { 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..744a9079d23b5bfe5e7b4e77361697c83570c32f 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 @@ </unique-constraints> <id name="id" type="integer" column="ID"> <generator strategy="SEQUENCE"/> + <sequence-generator sequence-name="TYPE_MODULATEUR_STRUCTU_ID_SEQ"/> </id> <field name="histoCreation" type="datetime" column="HISTO_CREATION" nullable="false"/> <field name="histoDestruction" type="datetime" column="HISTO_DESTRUCTION" nullable="true"/> <field name="histoModification" type="datetime" column="HISTO_MODIFICATION" nullable="false"/> + <many-to-one field="anneeDebut" target-entity="Application\Entity\Db\Annee"> + <join-column name="ANNEE_DEBUT_ID" referenced-column-name="ID"/> + </many-to-one> + <many-to-one field="anneeFin" target-entity="Application\Entity\Db\Annee"> + <join-column name="ANNEE_FIN_ID" referenced-column-name="ID"/> + </many-to-one> <many-to-one field="histoModificateur" target-entity="Application\Entity\Db\Utilisateur"> <join-columns> <join-column name="HISTO_MODIFICATEUR_ID" referenced-column-name="ID"/> diff --git a/module/Application/src/Application/Entity/Db/TypeModulateurStructure.php b/module/Application/src/Application/Entity/Db/TypeModulateurStructure.php index e36a9c82350dd31093489fc103b64de75a82b8b3..6fe2686f91fc597385b591227cd0cf2b29eb264a 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,50 @@ class TypeModulateurStructure implements HistoriqueAwareInterface { return $this->structure; } + + /** + * @return Annee + */ + public function getAnneeDebut() + { + return $this->anneeDebut; + } + + + + /** + * @param Annee $anneeDebut + * + * @return TypePieceJointeStatut + */ + public function setAnneeDebut(Annee $anneeDebut = null) + { + $this->anneeDebut = $anneeDebut; + + return $this; + } + + + + /** + * @return Annee + */ + public function getAnneeFin() + { + return $this->anneeFin; + } + + + + /** + * @param Annee $anneeFin + * + * @return * TypePieceJointeStatut + */ + public function setAnneeFin(Annee $anneeFin = null) + { + $this->anneeFin = $anneeFin; + + return $this; + } } diff --git a/module/Application/src/Application/Service/ModulateurService.php b/module/Application/src/Application/Service/ModulateurService.php index 7b0db1113216c2004e63a32cbf95fb37b49eefce..58d724bf152c0aa764644b7a108eed8e17894741 100644 --- a/module/Application/src/Application/Service/ModulateurService.php +++ b/module/Application/src/Application/Service/ModulateurService.php @@ -4,6 +4,7 @@ namespace Application\Service; use Application\Entity\Db\Modulateur; use Application\Entity\Db\ElementPedagogique; +use Application\Entity\Db\TypeModulateurStructure; use Application\Service\Traits\ElementModulateurServiceAwareTrait; use Application\Service\Traits\ElementPedagogiqueServiceAwareTrait; use Doctrine\ORM\QueryBuilder; @@ -102,4 +103,5 @@ class ModulateurService 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..13c6be8f7d99d2be9bf9124c9c9bc7cf4ed47a14 100644 --- a/module/Application/view/application/modulateur/index.phtml +++ b/module/Application/view/application/modulateur/index.phtml @@ -1,34 +1,39 @@ <?php -/** - * @var $this \Application\View\Renderer\PhpRenderer - * @var $modulateurs \Application\Entity\Db\modulateur[] - * @var $typeModulateurs \Application\Entity\Db\typeModulateur[] - */ use Application\Provider\Privilege\Privileges; -use Application\Entity\Db\TypeModulateur; +use Application\Entity\Db\TypeModulateurStructure; use UnicaenApp\Util; +/** + * @var $this \Application\View\Renderer\PhpRenderer + * @var $modulateurs \Application\Entity\Db\modulateur[] + * @var $typeModulateurs \Application\Entity\Db\typeModulateur[] + * @var $typeModulateurStructures \Application\Entity\Db\typeModulateurStructure[] + */ + + function affBooleen($flg) { // affiche booléen avec des glypheIcon return ($flg ? '<span class="glyphicon glyphicon-ok text-success"></span>' : '<span class="glyphicon glyphicon-remove text-danger refuse"></span>'); } -$this->headTitle()->append("Modulateurs des taux horaires"); +$this->headTitle()->append("Gestion des modulateurs"); $canEdit = $this->isAllowed(Privileges::getResourceId(Privileges::MODULATEUR_EDITION)); +$anneeId=$annee->getId(); + ?> -<h1 class="page-header">Modulateurs des taux horaires</h1> +<h1 class="page-header">Gestion des modulateurs</h1> <?php foreach ($typeModulateurs as $tm) { - if ($this->isAllowed($tm,Privileges::MODULATEUR_VISUALISATION)) { ?> + if ($this->isAllowed($tm, Privileges::MODULATEUR_VISUALISATION)) { ?> <div class="panel panel-default"> <div class="panel-heading"> <div class="panel-title"><?= $tm->getCode() ?> <span style="position:absolute; left: 300px"><?= $tm->getLibelle() ?></span> - <span style="position:absolute; right: 50px;"> + <span style="position:absolute; right: 50px;"> <?php if ($canEdit): ?> <a class="ajax-modal" data-event="modulateur-saisie" @@ -36,10 +41,9 @@ foreach ($typeModulateurs as $tm) { title="Ajouter un modulateur"> <span class="glyphicon glyphicon-plus"></span> </a> - <?php endif ?> - <a class="ajax-modal" data-event="modulateur-saisie" - href="<?= $this->url('modulateur/type-modulateur-saisie', ['typeModulateur' => $tm->getId()]) ?>" - title="Modifier le type de modulateur"> + <a class="ajax-modal" data-event="modulateur-saisie" + href="<?= $this->url('modulateur/type-modulateur-saisie', ['typeModulateur' => $tm->getId()]) ?>" + title="Modifier le type de modulateur"> <span class="glyphicon glyphicon-edit"></span></a> <a class="pop-ajax" href="<?= $this->url('modulateur/type-modulateur-delete', ['typeModulateur' => $tm->getId()]) ?>" @@ -52,7 +56,8 @@ foreach ($typeModulateurs as $tm) { > <span class="glyphicon glyphicon-remove"></span> </a> - </span> + <?php endif ?> + </span> </div> </div> <div class="panel-body"> @@ -70,6 +75,58 @@ foreach ($typeModulateurs as $tm) { <div class="col-md-9">Saisie par ens:</div> <div class="col-md-3"><?= affBooleen($tm->getSaisieParEnseignant()) ?></div> </div> + <div class="row"> + <br> + </div> + <table class="table table-bordered table-condensed table-extra-condensed" style="margin-bottom:2px"> + <?php $existTMS=0; // 1 --> ajout d'une structure interdite + foreach ($typeModulateurStructures as $tms) { + $ok=($tms->getTypeModulateur() == $tm); + if ($ok && $tms->getAnneeDebut()){ + if ($tms->getAnneeDebut()->getId() > $anneeId) $ok=false; + } + if ($ok && $tms->getAnneeFin()){ + if ($tms->getAnneeFin()->getId() < $anneeId) $ok=false; + } + if ($ok) { + $existTMS=1; ?> + <tr> + <?php $title = ''; + if ($tms->getAnneeDebut()) $title = "À partir de " . $tms->getAnneeDebut() . " "; + if ($tms->getAnneeFin()) $title .= "jusqu'à " . $tms->getAnneeFin(); ?> + <td> + + <span <?= $title ? 'title="' . $title . '"' : '' ?>> + <?= $tms->getStructure()->getLibelleCourt() ?></span> + </td> + <?php if ($canEdit): ?> + <td style="width:1%; white-space:nowrap"><a class="ajax-modal" data-event="modulateur-saisie" + href="<?= $this->url('modulateur/type-modulateur-structure-saisie', ['typeModulateur' => $tm->getId(), 'typeModulateurStructure' => $tms->getId()]) ?>" + title="Modifier une structure d\'un type de modulateur "> + <span class="glyphicon glyphicon-edit"></span></a> + <a class="pop-ajax" + href="<?= $this->url('modulateur/type-modulateur-structure-delete', ['typeModulateurStructure' => $tms->getId()]) ?>" + title="Supprimer la structure d\'un type de modulateur" + data-content="<p class='lead text-danger'><strong>Attention!</strong> Confirmez-vous cette suppression ?</p>" + data-confirm="true" + data-confirm-button="Oui" + data-cancel-button="Non" + data-submit-reload="true" + > + <span class="glyphicon glyphicon-remove"></span> + </a> + <?php endif ?> + </tr> + <?php } + } ?> + </table> + <?php if (($canEdit) && !($existTMS)) : ?> + <a class="btn btn-xs btn-primary ajax-modal" style="width:100%" data-event="modulateur-saisie" + href="<?= $this->url('modulateur/type-modulateur-structure-saisie', ['typeModulateur' => $tm->getId()]) ?>" + title="Ajouter une structure au type de modulateur"> + <span class="glyphicon glyphicon-edit"></span> + Associer une composante</a> + <?php endif ?> </div> <div class="col-md-9"> <table class="table table-bordered"> @@ -123,12 +180,12 @@ foreach ($typeModulateurs as $tm) { <?php } } ?> - <?php if (($canEdit) && (!$structure)) : ?> -<a class="btn btn-primary ajax-modal" data-event="modulateur-saisie" - href="<?= $this->url('modulateur/type-modulateur-saisie', []) ?>" - title="Ajouter un type de modulateur"> - <span class="glyphicon glyphicon-edit"></span> - Ajouter un type de modulateur</a> +<?php if (($canEdit) && (!$structure)) : ?> + <a class="btn btn-primary ajax-modal" data-event="modulateur-saisie" + href="<?= $this->url('modulateur/type-modulateur-saisie', []) ?>" + title="Ajouter un type de modulateur"> + <span class="glyphicon glyphicon-edit"></span> + Ajouter un type de modulateur</a> <script type="text/javascript"> $(function () { $("body").on("modulateur-saisie", function (event, data) {