Commit 1b786666 authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

Ajout d'un filtre sur l'année sur l'écran des formations pour masquer/afficher les sessions

parent 5310d591
Loading
Loading
Loading
Loading
+1 −0
Changes for CHANGELOG.md: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ Journal des modifications
6.0.6
-----
- Passage dans UnicaenRenderer du template des historiques de co-encadrements
- Ajout d'un filtre sur l'année sur l'écran des formations pour masquer/afficher les sessions

6.0.5
-----
+14 −3
Changes for module/Formation/src/Formation/Service/Session/SessionService.php: 14 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -5,7 +5,8 @@ namespace Formation\Service\Session;
use Application\Entity\Db\Utilisateur;
use Application\Service\UserContextServiceAwareTrait;
use DateTime;
use Doctrine\ORM\ORMException;
use Doctrine\ORM\Exception\NotSupported;
use Doctrine\ORM\Exception\ORMException;
use Doctrine\ORM\Query\Expr;
use Doctrine\ORM\Query\Expr\Join;
use Formation\Entity\Db\Etat;
@@ -15,7 +16,7 @@ use Formation\Entity\Db\Seance;
use Formation\Entity\Db\Session;
use Formation\Entity\Db\SessionEtatHeurodatage;
use Formation\Service\Formation\FormationServiceAwareTrait;
use UnicaenApp\Exception\RuntimeException;
use RuntimeException;
use UnicaenApp\Service\EntityManagerAwareTrait;

class SessionService {
@@ -29,7 +30,11 @@ class SessionService {
    public function getRepository() : SessionRepository
    {
        /** @var SessionRepository $repo */
        try {
            $repo = $this->entityManager->getRepository(Session::class);
        } catch (NotSupported $e) {
            throw new RuntimeException("Un problème est survenu lors de la création du QueryBuilder de [".Session::class."]",0,$e);
        }
        return $repo;
    }

@@ -181,7 +186,13 @@ class SessionService {
        $heurodatage->setEtat($etat);
        $heurodatage->setHeurodatage(new DateTime());
        $user = $this->userContextService->getIdentityDb();
        if ($user === null) $user = $this->getEntityManager()->getRepository(Utilisateur::class)->find(1);
        if ($user === null) {
            try {
                $user = $this->getEntityManager()->getRepository(Utilisateur::class)->find(1);
            } catch (NotSupported $e) {
                throw new RuntimeException("Un erreur est survenu lors de la récupération de l'utilisateur d'id 1 (sygal-app)",0,$e);
            }
        }
        $heurodatage->setUtilisateur($user);

        try {
+38 −1
Changes for module/Formation/view/formation/formation/afficher.phtml: 38 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -115,6 +115,9 @@ $canSupprimerSession = $this->isAllowed(SessionPrivileges::getResourceId(Sess

<h2> Liste des sessions </h2>

<div class="row">
    <div class="col-md-12">

        <?php if ($canAjouterSession) : ?>
            <?php /** @see \Formation\Controller\SessionController::ajouterAction() */ ?>
            <a href="<?php echo $this->url('formation/session/ajouter', ['formation' => $formation->getId()], [], true); ?>"
@@ -126,6 +129,29 @@ $canSupprimerSession = $this->isAllowed(SessionPrivileges::getResourceId(Sess
            </a>
        <?php endif; ?>

        <?php
            $mois = (new DateTime())->format('m');
            $anneeCourante = (new DateTime())->format('Y');
            if ($mois < 9) $anneeCourante--;
            $anneeMin = null;
            foreach ($sessions as $session) {
                $anneeMin = ($anneeMin === null || $anneeMin > $session->getAnneeScolaire())?$session->getAnneeScolaire():$anneeMin;
            }
        ?>

        <div class="float-end">
        <label for="annee"> Filtre sur l'année :</label>
        <select id="annee" name="annee">
            <?php for($annee=$anneeMin; $annee<=$anneeCourante; $annee++) : ?>
                <option value="<?php echo $annee; ?>" <?php if ($annee == $anneeCourante) echo " selected "; ?> ><?php echo $annee; ?>/<?php echo ($annee+1); ?></option>
            <?php endfor; ?>
        </select>
        </div>


    </div>
</div>

<div class="index-result">
    <?php if (empty($sessions)) : ?>
    Aucune session d'associée à cette formation.
@@ -145,7 +171,7 @@ $canSupprimerSession = $this->isAllowed(SessionPrivileges::getResourceId(Sess
    </thead>
    <tbody>
    <?php foreach ($sessions as $session) : ?>
        <tr>
        <tr class="<?php echo $session->getAnneeScolaire(); ?>">
            <td>
                <span class=" <?php if ($session->estHistorise()) echo "historise text-danger"; ?> ">
                <?php echo $session->getIndex(); ?>
@@ -226,11 +252,22 @@ $canSupprimerSession = $this->isAllowed(SessionPrivileges::getResourceId(Sess


<script>
    function toggleAnnee() {
        let anneeSelected = $('#annee option:selected').val();
        // alert(anneeSelected);
        $('tbody tr').hide();
        $('tbody tr.' + anneeSelected).show();
    }

    $(function() {
        toggleAnnee();
        $("body").on("modification", function (event) {
            event.div.modal('hide');
            window.location.reload();
        });

        $("select#annee").on("change", toggleAnnee);
        $("select#annee").selectpicker();
    });
</script>