Loading module/Application/config/merged/activite.config.php +38 −5 Changes for module/Application/config/merged/activite.config.php: 38 added lines, 5 removed lines. Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ return [ 'controller' => ActiviteController::class, 'action' => [ 'index', 'afficher', ], 'privileges' => [ ActivitePrivileges::AFFICHER, Loading @@ -32,7 +33,9 @@ return [ 'action' => [ 'creer', 'editer', 'effacer', 'historiser', 'restaurer', 'detruire', ], 'privileges' => [ ActivitePrivileges::EDITER, Loading @@ -55,23 +58,53 @@ return [ ], 'may_terminate' => true, 'child_routes' => [ 'afficher' => [ 'type' => Segment::class, 'options' => [ 'route' => '/afficher/:activite', 'defaults' => [ 'controller' => ActiviteController::class, 'action' => 'afficher', ], ], ], 'editer' => [ 'type' => Segment::class, 'options' => [ 'route' => '/editer/:id', 'route' => '/editer/:activite', 'defaults' => [ 'controller' => ActiviteController::class, 'action' => 'editer', ], ], ], 'effacer' => [ 'historiser' => [ 'type' => Segment::class, 'options' => [ 'route' => '/historiser/:activite', 'defaults' => [ 'controller' => ActiviteController::class, 'action' => 'historiser', ], ], ], 'restaurer' => [ 'type' => Segment::class, 'options' => [ 'route' => '/restaurer/:activite', 'defaults' => [ 'controller' => ActiviteController::class, 'action' => 'restaurer', ], ], ], 'detruire' => [ 'type' => Segment::class, 'options' => [ 'route' => '/effacer/:id', 'route' => '/detruire/:activite', 'defaults' => [ 'controller' => ActiviteController::class, 'action' => 'effacer', 'action' => 'detruire', ], ], ], Loading module/Application/src/Application/Controller/Activite/ActiviteController.php +32 −5 Changes for module/Application/src/Application/Controller/Activite/ActiviteController.php: 32 added lines, 5 removed lines. Original line number Diff line number Diff line Loading @@ -60,8 +60,7 @@ class ActiviteController extends AbstractActionController { public function editerAction() { /** @var Activite $activite */ $activiteId = $this->params()->fromRoute('id'); $activite = $this->getActiviteService()->getActivite($activiteId); $activite = $this->getActiviteService()->getRequestedActivite($this, 'activite'); /** @var ActiviteForm $form */ $form = $this->getActiviteForm(); Loading @@ -88,13 +87,41 @@ class ActiviteController extends AbstractActionController { return $vm; } public function effacerAction() public function historiserAction() { /** @var Activite $activite */ $activiteId = $this->params()->fromRoute('id'); $activite = $this->getActiviteService()->getActivite($activiteId); $activite = $this->getActiviteService()->getRequestedActivite($this, 'activite'); $this->getActiviteService()->historise($activite); $this->redirect()->toRoute('activite'); } public function restaurerAction() { /** @var Activite $activite */ $activite = $this->getActiviteService()->getRequestedActivite($this, 'activite'); $this->getActiviteService()->restore($activite); $this->redirect()->toRoute('activite'); } public function detruireAction() { /** @var Activite $activite */ $activite = $this->getActiviteService()->getRequestedActivite($this, 'activite'); $this->getActiviteService()->delete($activite); $this->redirect()->toRoute('activite'); } public function afficherAction() { $activite = $this->getActiviteService()->getRequestedActivite($this, 'activite'); return new ViewModel([ 'title' => 'Visualisation d\'une activité', 'activite' => $activite, ]); } } No newline at end of file module/Application/src/Application/Service/Activite/ActiviteService.php +75 −7 Changes for module/Application/src/Application/Service/Activite/ActiviteService.php: 75 added lines, 7 removed lines. Original line number Diff line number Diff line Loading @@ -5,12 +5,14 @@ namespace Application\Service\Activite; use Application\Entity\Db\Activite; use Application\Entity\Db\FicheMetierType; use Application\Entity\Db\FicheMetierTypeActivite; use Exception; use Utilisateur\Service\User\UserServiceAwareTrait; use DateTime; use Doctrine\ORM\NonUniqueResultException; use Doctrine\ORM\OptimisticLockException; use UnicaenApp\Exception\RuntimeException; use UnicaenApp\Service\EntityManagerAwareTrait; use Zend\Mvc\Controller\AbstractActionController; class ActiviteService { use EntityManagerAwareTrait; Loading Loading @@ -49,17 +51,37 @@ class ActiviteService { return $result; } /** * @param AbstractActionController $controller * @param string $paramName * @return Activite */ public function getRequestedActivite($controller, $paramName) { $id = $controller->params()->fromRoute($paramName); $activite = $this->getActivite($id); return $activite; } /** * @param Activite $activite * @return Activite */ public function create($activite) { try { $date = new DateTime(); $user = $this->getUserService()->getConnectedUser(); } catch (Exception $e) { throw new RuntimeException("Un problème s'est produit lors de la récupération des informations d'historisation", $e); } $activite->setHistoCreation($date); $activite->setHistoCreateur($user); $activite->setHistoModification($date); $activite->setHistoModificateur($user); $this->getEntityManager()->persist($activite); $activite->setHistoCreation(new DateTime()); $activite->setHistoCreateur($this->getUserService()->getConnectedUser()); $activite->setHistoModification(new DateTime()); $activite->setHistoModificateur($this->getUserService()->getConnectedUser()); try { $this->getEntityManager()->flush($activite); } catch (OptimisticLockException $e) { Loading @@ -74,8 +96,55 @@ class ActiviteService { */ public function update($activite) { $activite->setHistoModification(new DateTime()); $activite->setHistoModificateur($this->getUserService()->getConnectedUser()); try { $date = new DateTime(); $user = $this->getUserService()->getConnectedUser(); } catch (Exception $e) { throw new RuntimeException("Un problème s'est produit lors de la récupération des informations d'historisation", $e); } $activite->setHistoModification($date); $activite->setHistoModificateur($user); try { $this->getEntityManager()->flush($activite); } catch (OptimisticLockException $e) { throw new RuntimeException('Un problème est survenu lors de la mise à jour en BD', $e); } return $activite; } /** * @param Activite $activite * @return Activite */ public function historise($activite) { try { $date = new DateTime(); $user = $this->getUserService()->getConnectedUser(); } catch (Exception $e) { throw new RuntimeException("Un problème s'est produit lors de la récupération des informations d'historisation", $e); } $activite->setHistoDestruction($date); $activite->setHistoDestructeur($user); try { $this->getEntityManager()->flush($activite); } catch (OptimisticLockException $e) { throw new RuntimeException('Un problème est survenu lors de la mise à jour en BD', $e); } return $activite; } /** * @param Activite $activite * @return Activite */ public function restore($activite) { $activite->setHistoDestruction(null); $activite->setHistoDestructeur(null); try { $this->getEntityManager()->flush($activite); } catch (OptimisticLockException $e) { Loading @@ -97,7 +166,6 @@ class ActiviteService { } } public function getFicheMetierTypeActivite($id) { $qb = $this->getEntityManager()->getRepository(FicheMetierTypeActivite::class)->createQueryBuilder('activite') Loading module/Application/view/application/activite/afficher.phtml +21 Changes for module/Application/view/application/activite/afficher.phtml: 21 added lines, 0 removed lines. Original line number Diff line number Diff line <?php use Application\Entity\Db\Activite; /** * @var Activite $activite */ ?> <div class="activite"> <h3> <?php echo $activite->getLibelle(); ?> </h3> <div> <?php echo $activite->getDescription(); ?> </div> </div> No newline at end of file module/Application/view/application/activite/index.phtml +31 −14 Changes for module/Application/view/application/activite/index.phtml: 31 added lines, 14 removed lines. Original line number Diff line number Diff line Loading @@ -9,8 +9,10 @@ use Application\Provider\Privilege\ActivitePrivileges; $this->headTitle('Index des activités'); $canVisualiser = $this->isAllowed(ActivitePrivileges::getResourceId(ActivitePrivileges::AFFICHER)); $canAjouter = $this->isAllowed(ActivitePrivileges::getResourceId(ActivitePrivileges::AJOUTER)); $canEditer = $this->isAllowed(ActivitePrivileges::getResourceId(ActivitePrivileges::EDITER)); $canHistoriser = $this->isAllowed(ActivitePrivileges::getResourceId(ActivitePrivileges::EDITER)); $canEffacer = $this->isAllowed(ActivitePrivileges::getResourceId(ActivitePrivileges::EFFACER)); ?> Loading @@ -26,7 +28,7 @@ $canEffacer = $this->isAllowed(ActivitePrivileges::getResourceId(ActivitePri class="btn btn-primary action ajax-modal" data-event="modification" > <i class="fas fa-plus-square"></i> <span class="icon ajouter"></span> Ajouter une activité </a> <br/><br/> Loading @@ -34,38 +36,53 @@ $canEffacer = $this->isAllowed(ActivitePrivileges::getResourceId(ActivitePri <table class="table table-condensed"> <thead> <th> Id </th> <!-- <th> Id </th>--> <th> Activité </th> <th> Dernière modification </th> <th> Modification </th> <th> Modificateur </th> <th> Action </th> </thead> <tbody> <?php foreach($activites as $activite) : ?> <tr> <td> <?php echo $activite->getId(); ?> </td> <!-- <td> --><?php //echo $activite->getId(); ?><!-- </td>--> <td> <?php echo $activite->getLibelle(); ?> <br/> <div class="alert alert-info"> <?php echo $activite->getDescription(); ?> </div> </td> <td> <?php echo $activite->getHistoModification()->format('H:i d/m/Y'); ?> <br/> <?php echo $activite->getHistoModification()->format('d/m/Y'); ?> </td> <td> <?php echo $activite->getHistoModificateur()->getDisplayName(); ?> </td> <td> <?php if ($canVisualiser) : ?> <a href="<?php echo $this->url('activite/afficher', ['activite' => $activite->getId()], [], true); ?>" class="ajax-modal" > <span class="icon voir" title="Voir l'activité"></span></a> <?php endif; ?> <?php if ($canEditer) : ?> <a href="<?php echo $this->url('activite/editer', ['id' => $activite->getId()], [], true); ?>" <a href="<?php echo $this->url('activite/editer', ['activite' => $activite->getId()], [], true); ?>" class="ajax-modal" data-event="modification" > <i class="fas fa-pencil-alt" title="Éditer l'activité"></i> </a> <span class="icon editer" title="Éditer l'activité"></span></a> <?php endif; ?> <?php if($canHistoriser) :?> <?php if($activite->estNonHistorise()): ?> <a href="<?php echo $this->url('activite/historiser', ['activite' => $activite->getId()], [], true); ?>" > <span class="icon historiser" title="Historiser l'activité"></span></a> <?php else : ?> <a href="<?php echo $this->url('activite/restaurer', ['activite' => $activite->getId()], [], true); ?>" > <span class="icon restaurer" title="Restaurer l'activité"></span></a> <?php endif; ?> <?php endif; ?> <?php if ($canEffacer) : ?> <a href="<?php echo $this->url('activite/effacer', ['id' => $activite->getId()], [], true); ?>"> <i class="fas fa-trash-alt" title="Supprimer l'activité"></i> </a> <a href="<?php echo $this->url('activite/detruire', ['activite' => $activite->getId()], [], true); ?>"> <span class="icon detruire" title="Supprimer l'activité"></span></a> <?php endif; ?> </td> </tr> Loading Loading
module/Application/config/merged/activite.config.php +38 −5 Changes for module/Application/config/merged/activite.config.php: 38 added lines, 5 removed lines. Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ return [ 'controller' => ActiviteController::class, 'action' => [ 'index', 'afficher', ], 'privileges' => [ ActivitePrivileges::AFFICHER, Loading @@ -32,7 +33,9 @@ return [ 'action' => [ 'creer', 'editer', 'effacer', 'historiser', 'restaurer', 'detruire', ], 'privileges' => [ ActivitePrivileges::EDITER, Loading @@ -55,23 +58,53 @@ return [ ], 'may_terminate' => true, 'child_routes' => [ 'afficher' => [ 'type' => Segment::class, 'options' => [ 'route' => '/afficher/:activite', 'defaults' => [ 'controller' => ActiviteController::class, 'action' => 'afficher', ], ], ], 'editer' => [ 'type' => Segment::class, 'options' => [ 'route' => '/editer/:id', 'route' => '/editer/:activite', 'defaults' => [ 'controller' => ActiviteController::class, 'action' => 'editer', ], ], ], 'effacer' => [ 'historiser' => [ 'type' => Segment::class, 'options' => [ 'route' => '/historiser/:activite', 'defaults' => [ 'controller' => ActiviteController::class, 'action' => 'historiser', ], ], ], 'restaurer' => [ 'type' => Segment::class, 'options' => [ 'route' => '/restaurer/:activite', 'defaults' => [ 'controller' => ActiviteController::class, 'action' => 'restaurer', ], ], ], 'detruire' => [ 'type' => Segment::class, 'options' => [ 'route' => '/effacer/:id', 'route' => '/detruire/:activite', 'defaults' => [ 'controller' => ActiviteController::class, 'action' => 'effacer', 'action' => 'detruire', ], ], ], Loading
module/Application/src/Application/Controller/Activite/ActiviteController.php +32 −5 Changes for module/Application/src/Application/Controller/Activite/ActiviteController.php: 32 added lines, 5 removed lines. Original line number Diff line number Diff line Loading @@ -60,8 +60,7 @@ class ActiviteController extends AbstractActionController { public function editerAction() { /** @var Activite $activite */ $activiteId = $this->params()->fromRoute('id'); $activite = $this->getActiviteService()->getActivite($activiteId); $activite = $this->getActiviteService()->getRequestedActivite($this, 'activite'); /** @var ActiviteForm $form */ $form = $this->getActiviteForm(); Loading @@ -88,13 +87,41 @@ class ActiviteController extends AbstractActionController { return $vm; } public function effacerAction() public function historiserAction() { /** @var Activite $activite */ $activiteId = $this->params()->fromRoute('id'); $activite = $this->getActiviteService()->getActivite($activiteId); $activite = $this->getActiviteService()->getRequestedActivite($this, 'activite'); $this->getActiviteService()->historise($activite); $this->redirect()->toRoute('activite'); } public function restaurerAction() { /** @var Activite $activite */ $activite = $this->getActiviteService()->getRequestedActivite($this, 'activite'); $this->getActiviteService()->restore($activite); $this->redirect()->toRoute('activite'); } public function detruireAction() { /** @var Activite $activite */ $activite = $this->getActiviteService()->getRequestedActivite($this, 'activite'); $this->getActiviteService()->delete($activite); $this->redirect()->toRoute('activite'); } public function afficherAction() { $activite = $this->getActiviteService()->getRequestedActivite($this, 'activite'); return new ViewModel([ 'title' => 'Visualisation d\'une activité', 'activite' => $activite, ]); } } No newline at end of file
module/Application/src/Application/Service/Activite/ActiviteService.php +75 −7 Changes for module/Application/src/Application/Service/Activite/ActiviteService.php: 75 added lines, 7 removed lines. Original line number Diff line number Diff line Loading @@ -5,12 +5,14 @@ namespace Application\Service\Activite; use Application\Entity\Db\Activite; use Application\Entity\Db\FicheMetierType; use Application\Entity\Db\FicheMetierTypeActivite; use Exception; use Utilisateur\Service\User\UserServiceAwareTrait; use DateTime; use Doctrine\ORM\NonUniqueResultException; use Doctrine\ORM\OptimisticLockException; use UnicaenApp\Exception\RuntimeException; use UnicaenApp\Service\EntityManagerAwareTrait; use Zend\Mvc\Controller\AbstractActionController; class ActiviteService { use EntityManagerAwareTrait; Loading Loading @@ -49,17 +51,37 @@ class ActiviteService { return $result; } /** * @param AbstractActionController $controller * @param string $paramName * @return Activite */ public function getRequestedActivite($controller, $paramName) { $id = $controller->params()->fromRoute($paramName); $activite = $this->getActivite($id); return $activite; } /** * @param Activite $activite * @return Activite */ public function create($activite) { try { $date = new DateTime(); $user = $this->getUserService()->getConnectedUser(); } catch (Exception $e) { throw new RuntimeException("Un problème s'est produit lors de la récupération des informations d'historisation", $e); } $activite->setHistoCreation($date); $activite->setHistoCreateur($user); $activite->setHistoModification($date); $activite->setHistoModificateur($user); $this->getEntityManager()->persist($activite); $activite->setHistoCreation(new DateTime()); $activite->setHistoCreateur($this->getUserService()->getConnectedUser()); $activite->setHistoModification(new DateTime()); $activite->setHistoModificateur($this->getUserService()->getConnectedUser()); try { $this->getEntityManager()->flush($activite); } catch (OptimisticLockException $e) { Loading @@ -74,8 +96,55 @@ class ActiviteService { */ public function update($activite) { $activite->setHistoModification(new DateTime()); $activite->setHistoModificateur($this->getUserService()->getConnectedUser()); try { $date = new DateTime(); $user = $this->getUserService()->getConnectedUser(); } catch (Exception $e) { throw new RuntimeException("Un problème s'est produit lors de la récupération des informations d'historisation", $e); } $activite->setHistoModification($date); $activite->setHistoModificateur($user); try { $this->getEntityManager()->flush($activite); } catch (OptimisticLockException $e) { throw new RuntimeException('Un problème est survenu lors de la mise à jour en BD', $e); } return $activite; } /** * @param Activite $activite * @return Activite */ public function historise($activite) { try { $date = new DateTime(); $user = $this->getUserService()->getConnectedUser(); } catch (Exception $e) { throw new RuntimeException("Un problème s'est produit lors de la récupération des informations d'historisation", $e); } $activite->setHistoDestruction($date); $activite->setHistoDestructeur($user); try { $this->getEntityManager()->flush($activite); } catch (OptimisticLockException $e) { throw new RuntimeException('Un problème est survenu lors de la mise à jour en BD', $e); } return $activite; } /** * @param Activite $activite * @return Activite */ public function restore($activite) { $activite->setHistoDestruction(null); $activite->setHistoDestructeur(null); try { $this->getEntityManager()->flush($activite); } catch (OptimisticLockException $e) { Loading @@ -97,7 +166,6 @@ class ActiviteService { } } public function getFicheMetierTypeActivite($id) { $qb = $this->getEntityManager()->getRepository(FicheMetierTypeActivite::class)->createQueryBuilder('activite') Loading
module/Application/view/application/activite/afficher.phtml +21 Changes for module/Application/view/application/activite/afficher.phtml: 21 added lines, 0 removed lines. Original line number Diff line number Diff line <?php use Application\Entity\Db\Activite; /** * @var Activite $activite */ ?> <div class="activite"> <h3> <?php echo $activite->getLibelle(); ?> </h3> <div> <?php echo $activite->getDescription(); ?> </div> </div> No newline at end of file
module/Application/view/application/activite/index.phtml +31 −14 Changes for module/Application/view/application/activite/index.phtml: 31 added lines, 14 removed lines. Original line number Diff line number Diff line Loading @@ -9,8 +9,10 @@ use Application\Provider\Privilege\ActivitePrivileges; $this->headTitle('Index des activités'); $canVisualiser = $this->isAllowed(ActivitePrivileges::getResourceId(ActivitePrivileges::AFFICHER)); $canAjouter = $this->isAllowed(ActivitePrivileges::getResourceId(ActivitePrivileges::AJOUTER)); $canEditer = $this->isAllowed(ActivitePrivileges::getResourceId(ActivitePrivileges::EDITER)); $canHistoriser = $this->isAllowed(ActivitePrivileges::getResourceId(ActivitePrivileges::EDITER)); $canEffacer = $this->isAllowed(ActivitePrivileges::getResourceId(ActivitePrivileges::EFFACER)); ?> Loading @@ -26,7 +28,7 @@ $canEffacer = $this->isAllowed(ActivitePrivileges::getResourceId(ActivitePri class="btn btn-primary action ajax-modal" data-event="modification" > <i class="fas fa-plus-square"></i> <span class="icon ajouter"></span> Ajouter une activité </a> <br/><br/> Loading @@ -34,38 +36,53 @@ $canEffacer = $this->isAllowed(ActivitePrivileges::getResourceId(ActivitePri <table class="table table-condensed"> <thead> <th> Id </th> <!-- <th> Id </th>--> <th> Activité </th> <th> Dernière modification </th> <th> Modification </th> <th> Modificateur </th> <th> Action </th> </thead> <tbody> <?php foreach($activites as $activite) : ?> <tr> <td> <?php echo $activite->getId(); ?> </td> <!-- <td> --><?php //echo $activite->getId(); ?><!-- </td>--> <td> <?php echo $activite->getLibelle(); ?> <br/> <div class="alert alert-info"> <?php echo $activite->getDescription(); ?> </div> </td> <td> <?php echo $activite->getHistoModification()->format('H:i d/m/Y'); ?> <br/> <?php echo $activite->getHistoModification()->format('d/m/Y'); ?> </td> <td> <?php echo $activite->getHistoModificateur()->getDisplayName(); ?> </td> <td> <?php if ($canVisualiser) : ?> <a href="<?php echo $this->url('activite/afficher', ['activite' => $activite->getId()], [], true); ?>" class="ajax-modal" > <span class="icon voir" title="Voir l'activité"></span></a> <?php endif; ?> <?php if ($canEditer) : ?> <a href="<?php echo $this->url('activite/editer', ['id' => $activite->getId()], [], true); ?>" <a href="<?php echo $this->url('activite/editer', ['activite' => $activite->getId()], [], true); ?>" class="ajax-modal" data-event="modification" > <i class="fas fa-pencil-alt" title="Éditer l'activité"></i> </a> <span class="icon editer" title="Éditer l'activité"></span></a> <?php endif; ?> <?php if($canHistoriser) :?> <?php if($activite->estNonHistorise()): ?> <a href="<?php echo $this->url('activite/historiser', ['activite' => $activite->getId()], [], true); ?>" > <span class="icon historiser" title="Historiser l'activité"></span></a> <?php else : ?> <a href="<?php echo $this->url('activite/restaurer', ['activite' => $activite->getId()], [], true); ?>" > <span class="icon restaurer" title="Restaurer l'activité"></span></a> <?php endif; ?> <?php endif; ?> <?php if ($canEffacer) : ?> <a href="<?php echo $this->url('activite/effacer', ['id' => $activite->getId()], [], true); ?>"> <i class="fas fa-trash-alt" title="Supprimer l'activité"></i> </a> <a href="<?php echo $this->url('activite/detruire', ['activite' => $activite->getId()], [], true); ?>"> <span class="icon detruire" title="Supprimer l'activité"></span></a> <?php endif; ?> </td> </tr> Loading