Commit 06a74af1 authored by Thomas Hamel's avatar Thomas Hamel
Browse files

FIX: filtre par défaut des écrans formations/sessions qui s'activait même...

FIX: filtre par défaut des écrans formations/sessions qui s'activait même lorsqu'il n'était pas sélectionné, chgt dans l'appel des sessions pour le doctorant
parent f697248b
Loading
Loading
Loading
Loading
+1 −1
Changes for doc/release-notes/8.2.0/01_formation.sql: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@
--Ajout d'un paramètre pour spécifier le délai pour une annulation d'inscription
INSERT INTO public.unicaen_parametre_parametre (id, categorie_id, code, libelle, description, valeurs_possibles, valeur,
                                                ordre)
VALUES (20, 2, 'DELAI_ANNULATION_INSCRIPTION', 'Delai annulation', null, 'Number', '21', 20) ON CONFLICT DO NOTHING;
VALUES (20, 2, 'DELAI_ANNULATION_INSCRIPTION', 'Délai avant le blocage de l''annulation d''une inscription (en jours)', null, 'Number', '3', 20) ON CONFLICT DO NOTHING;


--Ajout d'un privilège pour voir le lieu des séances d'une session
+8 −6
Changes for module/Formation/src/Formation/Controller/IndexController.php: 8 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -3,8 +3,10 @@
namespace Formation\Controller;

use Application\Controller\AbstractController;
use Application\Service\AnneeUniv\AnneeUnivServiceAwareTrait;
use Doctorant\Entity\Db\Doctorant;
use Doctorant\Service\DoctorantServiceAwareTrait;
use Formation\Entity\Db\Etat;
use Formation\Entity\Db\Inscription;
use Formation\Entity\Db\Session;
use Formation\Provider\Parametre\FormationParametres;
@@ -18,6 +20,7 @@ class IndexController extends AbstractController
    use EntityManagerAwareTrait;
    use DoctorantServiceAwareTrait;
    use ParametreServiceAwareTrait;
    use AnneeUnivServiceAwareTrait;

    public function indexAction() : ViewModel
    {
@@ -36,12 +39,11 @@ class IndexController extends AbstractController
        }

        if($doctorant) {
            $anneeScolaire = Session::getAnneeScolaireCourante();
            /** @var Session[] $session */
            $sessions = $this->getEntityManager()->getRepository(Session::class)->findSessionsDisponiblesByDoctorant($doctorant);
            $sessions = array_filter($sessions, function (Session $s) use ($anneeScolaire) { return $s->getAnneeScolaire() === $anneeScolaire;});
            $ouvertes = array_filter($sessions, function(Session $a) { return $a->getEtat()->getCode() === Session::ETAT_INSCRIPTION;});
            $preparations = array_filter($sessions, function(Session $a) { return $a->getEtat()->getCode() === Session::ETAT_PREPARATION;});
            $anneeScolaire = $this->anneeUnivService->courante();
            $debut = $this->anneeUnivService->computeDateDebut($anneeScolaire);
            $fin = $this->anneeUnivService->computeDateFin($anneeScolaire);
            $ouvertes = $this->getEntityManager()->getRepository(Session::class)->findSessionsByDoctorant($doctorant, Etat::CODE_OUVERTE, $debut, $fin);
            $preparations = $this->getEntityManager()->getRepository(Session::class)->findSessionsByDoctorant($doctorant, Etat::CODE_PREPARATION);
            /** @var Inscription[] $inscription */
            $inscriptions = $this->getEntityManager()->getRepository(Inscription::class)->findInscriptionsByDoctorant($doctorant);
        } else {
+5 −0
Changes for module/Formation/src/Formation/Controller/IndexControllerFactory.php: 5 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@

namespace Formation\Controller;

use Application\Service\AnneeUniv\AnneeUnivService;
use Doctorant\Service\DoctorantService;
use Doctrine\ORM\EntityManager;
use Interop\Container\ContainerInterface;
@@ -23,15 +24,19 @@ class IndexControllerFactory {
         * @var EntityManager $entityManager
         * @var DoctorantService $doctorantService
         * @var ParametreService $parametreService
         * @var AnneeUnivService $anneeUnivService
        */
        $entityManager = $container->get('doctrine.entitymanager.orm_default');
        $doctorantService = $container->get(DoctorantService::class);
        $parametreService = $container->get(ParametreService::class);
        $anneeUnivService = $container->get(AnneeUnivService::class);

        $controller = new IndexController();
        $controller->setEntityManager($entityManager);
        $controller->setDoctorantService($doctorantService);
        $controller->setParametreService($parametreService);
        $controller->setAnneeUnivService($anneeUnivService);

        return $controller;
    }

+12 −10
Changes for module/Formation/src/Formation/Entity/Db/Repository/SessionRepository.php: 12 added lines, 10 removed lines.
Original line number Diff line number Diff line
@@ -56,9 +56,12 @@ class SessionRepository extends DefaultEntityRepository

    /**
     * @param Doctorant $doctorant
     * @param string $etat
     * @param DateTime|null $debut
     * @param DateTime|null $fin
     * @return Session[]
     */
    public function findSessionsDisponiblesByDoctorant(Doctorant $doctorant) : array
    public function findSessionsByDoctorant(Doctorant $doctorant, string $etat, DateTime $debut = null, DateTime $fin = null) : array
    {
        $structures = [];
        foreach ($doctorant->getTheses() as $these) {
@@ -80,21 +83,20 @@ class SessionRepository extends DefaultEntityRepository

        $qb = $this->createQueryBuilder('session')
            ->andWhere('complement.structure in (:structures)')
            ->andWhere('etat.code = :ouverte OR etat.code = :preparation')
            ->andWhere('etat.code = :etat')
            ->setParameter('structures', array_unique($structures))
            ->setParameter('ouverte', Etat::CODE_OUVERTE)
            ->setParameter('preparation', Etat::CODE_PREPARATION)
            ->setParameter('etat', $etat)
            ->orderBy("seance.debut", "DESC");
        ;

        /** TODO SOMETHING WITH IT*/
        $now = new DateTime();
        $mois = ((int) $now->format('m'));
        $annee =  ((int) $now->format('Y'));
        if ($mois < 9) $annee -= 1;
        if ($debut !== null && $fin !== null) {
            $qb->andWhere('seance.debut >= :debut')->setParameter('debut', $debut)
                ->andWhere('seance.fin <= :fin')->setParameter('fin', $fin);

            $annee = $debut->format('Y');
            if (! $doctorant->hasMissionEnseignementFor($annee)) {
                $qb = $qb->andWhere('module.requireMissionEnseignement = :false')->setParameter('false', false);
            }
        }

        $result =  $qb->getQuery()->getResult();
        return $result;
+1 −10
Changes for module/Formation/src/Formation/Entity/Db/Session.php: 1 added line, 10 removed lines.
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@

namespace Formation\Entity\Db;

use Application\Entity\AnneeUniv;
use Doctorant\Entity\Db\Doctorant;
use Individu\Entity\Db\Individu;
use DateInterval;
@@ -288,16 +289,6 @@ class Session implements HistoriqueAwareInterface,
        return $annee;
    }

    static public function getAnneeScolaireCourante() : int
    {
        $debut = new DateTime();

        $mois = ((int) $debut->format('m'));
        $annee =  ((int) $debut->format('Y'));
        if ($mois < 9) $annee -= 1;
        return $annee;
    }

    /**
     * @return SessionEtatHeurodatage[]
     */
Loading