Skip to content
Snippets Groups Projects
Commit 9ddeefd8 authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

Création de l'entité SessionType et des service/form/controller

parent 6327b72d
No related branches found
No related tags found
No related merge requests found
Showing
with 10473 additions and 52 deletions
......@@ -81,15 +81,4 @@ $nbAgent = count($agents)
</tbody>
</table>
<script>
$(document).ready(function () {
$('.datatable#listing').DataTable({
// sorting: false,
paging: false,
language: {
url: '/js/datatables_fr.json'
}
});
});
</script>
\ No newline at end of file
œ
\ No newline at end of file
......@@ -45,7 +45,7 @@ $canValider = $this->isAllowed(DemandeexternePrivileges::getResourceId(Demandeex
<tr class=" <?php if ($demande->estHistorise()) echo " historise "; ?> ">
<td> <?php echo $demande->getAgent()->getDenomination(); ?> </td>
<td> <?php echo $demande->getSession()->getFormation()->getLibelle(); ?> </td>
<td> <?php echo $demande->getSession()->getType(); ?> </td>
<td> <?php echo $demande->getSession()->getType()?->getLibelle(); ?> </td>
<td> <?php
echo $this->etatinstance($demande->getEtatActif(), ['display-categorie' => false]);
?> </td>
......
......@@ -12,6 +12,7 @@ use Formation\Provider\Privilege\SessiontypePrivileges;
use Formation\Service\SessionType\SessionTypeService;
use Formation\Service\SessionType\SessionTypeServiceFactory;
use Laminas\Router\Http\Literal;
use Laminas\Router\Http\Segment;
use UnicaenPrivilege\Guard\PrivilegeController;
return [
......@@ -27,29 +28,75 @@ return [
SessiontypePrivileges::SESSIONTYPE_INDEX
],
],
[
'controller' => SessionTypeController::class,
'action' => [
'afficher',
],
'privileges' => [
SessiontypePrivileges::SESSIONTYPE_AFFICHER
],
],
[
'controller' => SessionTypeController::class,
'action' => [
'ajouter',
],
'privileges' => [
SessiontypePrivileges::SESSIONTYPE_AJOUTER
],
],
[
'controller' => SessionTypeController::class,
'action' => [
'modifier',
],
'privileges' => [
SessiontypePrivileges::SESSIONTYPE_MODIFIER
],
],
[
'controller' => SessionTypeController::class,
'action' => [
'historiser',
'restaurer',
],
'privileges' => [
SessiontypePrivileges::SESSIONTYPE_HISTORISER
],
],
[
'controller' => SessionTypeController::class,
'action' => [
'supprimer',
],
'privileges' => [
SessiontypePrivileges::SESSIONTYPE_SUPPRIMER
],
],
],
],
],
// 'navigation' => [
// 'default' => [
// 'home' => [
// 'pages' => [
// 'gestion' => [
// 'pages' => [
// 'session' => [
// 'label' => 'Sessions',
// 'route' => 'session',
// 'resource' => PrivilegeController::getResourceId(SessionController::class, 'index'),
// 'order' => 1100,
// 'icon' => 'fas fa-angle-right',
// ],
// ],
// ],
// ],
// ],
// ],
// ],
'navigation' => [
'default' => [
'home' => [
'pages' => [
'gestion' => [
'pages' => [
'session' => [
'label' => 'Types de sessions',
'route' => 'session/type',
'resource' => PrivilegeController::getResourceId(SessionTypeController::class, 'index'),
'order' => 1110,
'icon' => 'fas fa-angle-right',
],
],
],
],
],
],
],
'router' => [
'routes' => [
......@@ -67,17 +114,78 @@ return [
'route' => '/type',
'defaults' => [
/** @see SessionTypeController::indexAction() */
'controller' => SessionTypeController::class,
'action' => 'index',
],
],
'may_terminate' => true,
'child_routes' => [],
'child_routes' => [
'afficher' => [
'type' => Segment::class,
'options' => [
'route' => '/afficher/:session-type',
'defaults' => [
/** @see SessionTypeController::afficherAction() */
'action' => 'afficher',
],
],
],
'ajouter' => [
'type' => Literal::class,
'options' => [
'route' => '/ajouter',
'defaults' => [
/** @see SessionTypeController::ajouterAction() */
'action' => 'ajouter',
],
],
],
'modifier' => [
'type' => Segment::class,
'options' => [
'route' => '/modifier/:session-type',
'defaults' => [
/** @see SessionTypeController::modifierAction() */
'action' => 'modifier',
],
],
],
'historiser' => [
'type' => Segment::class,
'options' => [
'route' => '/historiser/:session-type',
'defaults' => [
/** @see SessionTypeController::historiserAction() */
'action' => 'historiser',
],
],
],
'restaurer' => [
'type' => Segment::class,
'options' => [
'route' => '/restaurer/:session-type',
'defaults' => [
/** @see SessionTypeController::restaurerAction() */
'action' => 'restaurer',
],
],
],
'supprimer' => [
'type' => Segment::class,
'options' => [
'route' => '/supprimer/:session-type',
'defaults' => [
/** @see SessionTypeController::supprimerAction() */
'action' => 'supprimer',
],
],
],
],
],
],
],
],
],
'service_manager' => [
'factories' => [
......
......@@ -2,8 +2,10 @@
namespace Formation\Controller;
use Formation\Entity\Db\SessionType;
use Formation\Form\SessionType\SessionTypeFormAwareTrait;
use Formation\Service\SessionType\SessionTypeServiceAwareTrait;
use Laminas\Http\Response;
use Laminas\Mvc\Controller\AbstractActionController;
use Laminas\View\Model\ViewModel;
......@@ -21,4 +23,109 @@ class SessionTypeController extends AbstractActionController
'sessionsTypes' => $sessionsTypes,
]);
}
public function afficherAction(): ViewModel
{
$sessionType = $this->getSessionTypeService()->getRequestedSessionType($this);
return new ViewModel([
'title' => "Affichage du type de sessions",
'sessionType' => $sessionType,
]);
}
public function ajouterAction(): ViewModel
{
$sessiontype = new SessionType();
$form = $this->getSessionTypeForm();
$form->setAttribute('action', $this->url()->fromRoute('session/type/ajouter', [], [], true));
$form->bind($sessiontype);
$request = $this->getRequest();
if ($request->isPost()) {
$data = $request->getPost();
$form->setData($data);
if ($form->isValid()) {
$this->getSessionTypeService()->create($sessiontype);
exit();
}
}
$vm = new ViewModel([
'title' => "Ajout d'un type de session",
'form' => $form,
]);
$vm->setTemplate('default/default-form');
return $vm;
}
public function modifierAction(): ViewModel
{
$sessiontype = $this->getSessionTypeService()->getRequestedSessionType($this);
$form = $this->getSessionTypeForm();
$form->setAttribute('action', $this->url()->fromRoute('session/type/modifier', ['session-type' => $sessiontype->getId()], [], true));
$form->bind($sessiontype);
$request = $this->getRequest();
if ($request->isPost()) {
$data = $request->getPost();
$form->setData($data);
if ($form->isValid()) {
$this->getSessionTypeService()->update($sessiontype);
exit();
}
}
$vm = new ViewModel([
'title' => "Modification d'un type de session",
'form' => $form,
]);
$vm->setTemplate('default/default-form');
return $vm;
}
public function historiserAction(): Response
{
$sessionType = $this->getSessionTypeService()->getRequestedSessionType($this);
$this->getSessionTypeService()->historise($sessionType);
$retour = $this->params()->fromQuery('retour');
if ($retour) return $this->redirect()->toUrl($retour);
return $this->redirect()->toRoute('session/type', [], [], true);
}
public function restaurerAction(): Response
{
$sessionType = $this->getSessionTypeService()->getRequestedSessionType($this);
$this->getSessionTypeService()->restore($sessionType);
$retour = $this->params()->fromQuery('retour');
if ($retour) return $this->redirect()->toUrl($retour);
return $this->redirect()->toRoute('session/type', [], [], true);
}
public function supprimerAction(): ViewModel
{
$sessionType = $this->getSessionTypeService()->getRequestedSessionType($this);
$request = $this->getRequest();
if ($request->isPost()) {
$data = $request->getPost();
if ($data["reponse"] === "oui") $this->getSessionTypeService()->delete($sessionType);
exit();
}
$vm = new ViewModel();
if ($sessionType !== null) {
$vm->setTemplate('default/confirmation');
$vm->setVariables([
'title' => "Suppression du type de session " . $sessionType->getLibelle(),
'text' => "La suppression est définitive êtes-vous sûr&middot;e de vouloir continuer ?",
'action' => $this->url()->fromRoute('session/type/supprimer', ["session-type" => $sessionType->getId()], [], true),
]);
}
return $vm;
}
}
\ No newline at end of file
......@@ -14,11 +14,14 @@
<field name="nbPlaceComplementaire" type="integer" column="nb_place_complementaire" nullable="false"/>
<field name="dateClotureInscription" type="datetime" column="date_cloture_inscription" nullable="true"/>
<field name="lieu" type="string" length="256" column="lieu" nullable="true"/>
<field name="type" type="string" length="256" column="type" nullable="true"/>
<field name="autoInscription" type="boolean" column="auto_inscription" nullable="true"/>
<field name="complement" type="text" column="complement" nullable="true"/>
<field name="motifAnnulation" type="text" column="motif_annulation" nullable="true"/>
<many-to-one target-entity="Formation\Entity\Db\SessionType" field="type">
<join-column name="type_id" referenced-column-name="id"/>
</many-to-one>
<one-to-many field="journees" target-entity="Formation\Entity\Db\Seance" mapped-by="instance"/>
<one-to-many field="inscriptions" target-entity="Formation\Entity\Db\Inscription" mapped-by="session"/>
......
<?xml version="1.0" encoding="utf-8"?>
<doctrine-mapping>
<entity name="Formation\Entity\Db\SessionType" table="formation_session_type">
<id name="id" type="integer" column="id">
<generator strategy="IDENTITY"/>
</id>
<field name="libelle" column="libelle" length="1024" nullable="false"/>
<field name="description" column="description" type="text" nullable="true"/>
<one-to-many field="sessions" target-entity="Formation\Entity\Db\Session" mapped-by="type"/>
<!-- HISTORISATION ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<field name="histoCreation" type="datetime" column="histo_creation" nullable="false"/>
<field name="histoModification" type="datetime" column="histo_modification" nullable="false"/>
<field name="histoDestruction" type="datetime" column="histo_destruction" nullable="true"/>
<many-to-one target-entity="UnicaenUtilisateur\Entity\Db\User" field="histoCreateur">
<join-column name="histo_createur_id" referenced-column-name="ID"/>
</many-to-one>
<many-to-one target-entity="UnicaenUtilisateur\Entity\Db\User" field="histoModificateur">
<join-column name="histo_modificateur_id" referenced-column-name="ID"/>
</many-to-one>
<many-to-one target-entity="UnicaenUtilisateur\Entity\Db\User" field="histoDestructeur">
<join-column name="histo_destructeur_id" referenced-column-name="ID"/>
</many-to-one>
</entity>
</doctrine-mapping>
......@@ -41,10 +41,6 @@ class Session implements
return 'Session';
}
const TYPE_INTERNE = "formation interne";
const TYPE_EXTERNE = "formation externe";
const TYPE_REGIONALE = "formation régionale";
private ?int $id = null;
private ?Formation $formation = null;
private ?string $complement = null;
......@@ -54,7 +50,7 @@ class Session implements
private int $nbPlaceComplementaire = -1;
private ?DateTime $dateClotureInscription = null;
private ?string $lieu = null;
private ?string $type = null;
private ?SessionType $type = null;
private bool $affichage = true;
private ?float $coutHt = null;
......@@ -221,7 +217,7 @@ class Session implements
}
/**
* @return string|null
* @return ?SessionType
*/
public function getType(): ?string
{
......@@ -229,10 +225,10 @@ class Session implements
}
/**
* @param string|null $type
* @param ?SessionType $type
* @return Session
*/
public function setType(?string $type): Session
public function setType(?SessionType $type): Session
{
$this->type = $type;
return $this;
......
......@@ -20,7 +20,7 @@ class SessionHydrator implements HydratorInterface
'complementaire' => ($object AND $object->getNbPlaceComplementaire()) ?$object->getNbPlaceComplementaire(): 0,
'date_cloture_inscription' => $dateClotureInscription,
'lieu' => ($object AND $object->getLieu()) ? $object->getLieu() : null,
'type' => ($object AND $object->getType()) ? $object->getType() : null,
'type' => ($object AND $object->getType()) ? $object->getType()->getId() : null,
'inscription' => ($object) ? $object->isAutoInscription() : null,
'cout_ht' => ($object) ? $object->getCoutHt() : null,
'cout_ttc' => ($object) ? $object->getCoutTtc() : null,
......
......@@ -15,13 +15,13 @@ class SessionTypeForm extends Form {
//libelle
$this->add([
'type' => Text::class,
'name' => 'etiquette',
'name' => 'libelle',
'options' => [
'label' => "Etiquette <span title='Champ obligatoire'></span>:",
'label' => "Libellé <span class='icon icon-obligatoire' title='Champ obligatoire'></span>:",
'label_options' => ['disable_html_escape' => true,],
],
'attributes' => [
'id' => 'etiquette',
'id' => 'libelle',
],
]);
//description
......
......@@ -54,7 +54,7 @@ class SessionTypeService
public function createQueryBuilder(): QueryBuilder
{
$qb = $this->getObjectManager()->getRepository(SessionType::class)->createQueryBuilder('sessiontype')
->leftJoin('sessiontype.session', 'session')
->leftJoin('sessiontype.sessions', 'session')->addSelect('session')
;
return $qb;
}
......@@ -85,7 +85,7 @@ class SessionTypeService
public function getSessionType(?int $id): ?SessionType
{
$qb = $this->getObjectManager()->createQueryBuilder()
$qb = $this->createQueryBuilder()
->andWhere('sessiontype.id = :id')->setParameter('id', $id);
try {
$result = $qb->getQuery()->getOneOrNullResult();
......
......@@ -70,7 +70,7 @@ $displayListe = (!isset($options['display-liste']) OR $options['display-liste']
<dd class="col-md-9"> <?php echo ($session->getLieu()) ?: "Non communiqué"; ?> </dd>
<?php if ($session->getType() !== null) : ?>
<dt class="col-md-3"> Type</dt>
<dd class="col-md-9"> <?php echo $session->getType(); ?> </dd>
<dd class="col-md-9"> <?php echo $session->getType()->getLibelle(); ?> </dd>
<?php endif; ?>
<dt class="col-md-3"> Auto-inscription</dt>
<dd class="col-md-9">
......@@ -120,7 +120,7 @@ $displayListe = (!isset($options['display-liste']) OR $options['display-liste']
Session <?php echo $session->getId(); ?> du <?php echo $session->getDebut(); ?> au <?php echo $session->getFin(); ?>
<br/>
<?php if ($session->getSource() !== HasSourceInterface::SOURCE_LAGAF) : ?>
<?php echo $session->getType(); ?> - <?php echo $session->getDuree(); ?> -
<?php echo $session->getType()?->getLibelle(); ?> - <?php echo $session->getDuree(); ?> -
<?php endif; ?>
<?php if ($displayListe) : ?>
......
......@@ -63,7 +63,7 @@ $formation = $session->getFormation();
<dt class="col-md-4"> Libellé de l'action de formation:</dt>
<dd class="col-md-8"> <?php echo $formation->getLibelle(); ?> </dd>
<dt class="col-md-4"> Type :</dt>
<dd class="col-md-8"> <?php echo $session->getType(); ?> </dd>
<dd class="col-md-8"> <?php echo $session->getType()?->getLibelle(); ?> </dd>
</dl>
......
<?php
/**
* @see \Formation\Controller\SessionTypeController::afficherAction()
* @var \Formation\Entity\Db\SessionType $sessionType
*/
?>
<dl class="row">
<dt class="col-md-4">
Libellé
</dt>
<dd class="col-md-8">
<?php echo $sessionType->getLibelle(); ?>
</dd>
<dt class="col-md-4">
Description
</dt>
<dd class="col-md-8">
<?php if ($sessionType->getDescription()) : ?>
<?php echo $sessionType->getDescription(); ?>
<?php else : ?>
<span class="text-warning">
Aucune description
</span>
<?php endif;?>
</dd>
<dt class="col-md-4">
Sessions associées
</dt>
<dd class="col-md-8">
<?php echo count($sessionType->getSessions()); ?>
<ul>
<?php foreach ($sessionType->getSessions() as $session) : ?>
<li>
<?php echo $session->getFormation()->getLibelle(); ?>
<?php echo $session->getPeriode(); ?>
</li>
<?php endforeach; ?>
</ul>
</dd>
</dl>
<?php
use Formation\Entity\Db\SessionType;
use Formation\Provider\Privilege\SessiontypePrivileges;
/**
* @see \Formation\Controller\SessionTypeController::indexAction()
* @var string $title
* @var SessionType[] $sessionsTypes
*/
$this->headTitle($title);
$canAfficher = $this->isAllowed(SessiontypePrivileges::getResourceId(SessiontypePrivileges::SESSIONTYPE_AFFICHER));
$canAjouter = $this->isAllowed(SessiontypePrivileges::getResourceId(SessiontypePrivileges::SESSIONTYPE_AJOUTER));
$canModifier = $this->isAllowed(SessiontypePrivileges::getResourceId(SessiontypePrivileges::SESSIONTYPE_MODIFIER));
$canHistoriser = $this->isAllowed(SessiontypePrivileges::getResourceId(SessiontypePrivileges::SESSIONTYPE_HISTORISER));
$canSupprimer = $this->isAllowed(SessiontypePrivileges::getResourceId(SessiontypePrivileges::SESSIONTYPE_SUPPRIMER));
?>
<h1 class="page-header">
<?php echo $title; ?>
</h1>
<?php if ($canAjouter) : ?>
<?php /** @see \Formation\Controller\SessionTypeController::ajouterAction() */ ?>
<a href="<?php echo $this->url('session/type/ajouter', [], [], true); ?>"
class="btn btn-primary ajax-modal" data-event="modification">
<span class="icon icon-ajouter"></span>
Ajouter un type de session
</a>
<?php endif; ?>
<table class="table text-condensed datatable" id="sessionstypes">
<thead>
<tr>
<th>Libellé</th>
<th>#Session</th>
<th class="action">
Action
</th>
</tr>
</thead>
<tbody>
<?php foreach ($sessionsTypes as $sessionType): ?>
<tr>
<td>
<?php echo $sessionType->getLibelle(); ?>
<?php if ($sessionType->getDescription()) : ?>
<span class="icon icon-information" title="<?php echo $sessionType->getDescription(); ?>"></span>
<?php endif; ?>
</td>
<td>
<?php echo count($sessionType->getSessions()); ?>
</td>
<td class="action">
<?php if ($canAfficher) : ?>
<?php /** @see \Formation\Controller\SessionTypeController::afficherAction() */ ?>
<a href="<?php echo $this->url('session/type/afficher', ['session-type' => $sessionType->getId()], [], true); ?>"
class="action secondary ajax-modal"
>
<span class="icon icon-voir"></span>
Afficher
</a>
<?php endif; ?>
<?php if ($canModifier) : ?>
<br>
<?php /** @see \Formation\Controller\SessionTypeController::modifierAction() */ ?>
<a href="<?php echo $this->url('session/type/modifier', ['session-type' => $sessionType->getId()], [], true); ?>"
class="action primary ajax-modal" data-event="modification"
>
<span class="icon icon-editer"></span>
Modifier
</a>
<?php endif; ?>
<?php if ($canHistoriser) : ?>
<br>
<?php if ($sessionType->estNonHistorise()) : ?>
<?php /** @see \Formation\Controller\SessionTypeController::historiserAction() */ ?>
<a href="<?php echo $this->url('session/type/historiser', ['session-type' => $sessionType->getId()], [], true); ?>"
class="action warning"
>
<span class="icon icon-historiser"></span>
Historiser
</a>
<?php else : ?>
<?php /** @see \Formation\Controller\SessionTypeController::restaurerAction() */ ?>
<a href="<?php echo $this->url('session/type/restaurer', ['session-type' => $sessionType->getId()], [], true); ?>"
class="action warning"
>
<span class="icon icon-restaurer"></span>
Restaurer
</a>
<?php endif; ?>
<?php endif; ?>
<?php if ($canSupprimer) : ?>
<br>
<?php /** @see \Formation\Controller\SessionTypeController::supprimerAction() */ ?>
<a href="<?php echo $this->url('session/type/supprimer', ['session-type' => $sessionType->getId()], [], true); ?>"
class="action danger ajax-modal" data-event="modification"
>
<span class="icon icon-unchecked"></span>
Supprimer
</a>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<script>
$(document).ready(function () {
$('.datatable#sessionstypes').DataTable({
// sorting: false,
paging: false,
autoWidth: false,
language: {
url: '/js/datatables_fr.json'
},
columnDefs: [
{targets: [2], orderable: false}
]
});
$("body").on("modification", function (event) {
event.div.modal('hide');
window.location.reload();
});
});
</script>
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment