Commit 5b33e89a authored by Thomas Hamel's avatar Thomas Hamel
Browse files

Utilisation de AnneeUnivService dès que possible pour déterminer l'année...

Utilisation de AnneeUnivService dès que possible pour déterminer l'année universitaire d'une formation/session/seance
parent 06a74af1
Loading
Loading
Loading
Loading
+2 −1
Changes for module/Application/src/Application/Service/AnneeUniv/AnneeUnivService.php: 2 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -74,7 +74,8 @@ class AnneeUnivService
     */
    protected function computePremiereAnneeFromDate(DateTime $date): int
    {
        return (int)$date->modify($this->specDateBascule)->format('Y');
        $modifiedDate = clone $date;
        return (int)$modifiedDate->modify($this->specDateBascule)->format('Y');
    }

    public function computeDateDebut(AnneeUniv $anneeUniv): DateTime
+20 −1
Changes for module/Formation/src/Formation/Controller/FormationController.php: 20 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -3,6 +3,10 @@
namespace Formation\Controller;

use Application\Controller\AbstractController;
use Application\Entity\AnneeUniv;
use Application\Service\AnneeUniv\AnneeUnivServiceAwareTrait;
use Formation\Entity\Db\Seance;
use Formation\Entity\Db\Session;
use Formation\Service\Module\ModuleServiceAwareTrait;
use Formation\Service\Notification\FormationNotificationFactoryAwareTrait;
use Formation\Service\Session\SessionServiceAwareTrait;
@@ -25,6 +29,7 @@ class FormationController extends AbstractController
    use FormationFormAwareTrait;
    use NotifierServiceAwareTrait;
    use FormationNotificationFactoryAwareTrait;
    use AnneeUnivServiceAwareTrait;

    use EtablissementServiceAwareTrait;

@@ -32,10 +37,24 @@ class FormationController extends AbstractController
    {
        $formation = $this->getFormationService()->getRepository()->getRequestedFormation($this);
        $sessions = $this->getSessionService()->getRepository()->fetchSessionsByFormation($formation, 'id', 'asc', true);
        $anneeUnivCourante = $this->anneeUnivService->courante();

        $sessionsAvecAnneeUniv = [];
        /** @var Session $session */
        foreach($sessions as $session){
            $premiereAnnee = null;
            if($session->getDateDebut()){
                $anneeUniv = $this->anneeUnivService->fromDate($session->getDateDebut());
                $premiereAnnee = $anneeUniv->getPremiereAnnee();
            }
            $sessionsAvecAnneeUniv[] = array("session" => $session, "anneeUniv" => $premiereAnnee ?? $anneeUnivCourante->getPremiereAnnee());
        }

        return new ViewModel([
            'formation' => $formation,
            'sessions' => $sessions,
            'sessions' => $sessionsAvecAnneeUniv,
            'anneeUnivCourante' => $anneeUnivCourante,
            'anneesUniv' => $this->formationService->getAnneesUnivAsOptions($sessions)
        ]);
    }

+3 −0
Changes for module/Formation/src/Formation/Controller/FormationControllerFactory.php: 3 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 Formation\Service\Module\ModuleService;
use Formation\Service\Notification\FormationNotificationFactory;
use Formation\Service\Session\SessionService;
@@ -39,6 +40,7 @@ class FormationControllerFactory {
        $notificationService = $container->get(NotifierService::class);
        /** @var FormationNotificationFactory $formationNotificationFactory */
        $formationNotificationFactory = $container->get(FormationNotificationFactory::class);
        $anneeUnivService = $container->get(AnneeUnivService::class);

        /**
         * @var FormationForm $formationForm
@@ -54,6 +56,7 @@ class FormationControllerFactory {
        $controller->setFormationForm($formationForm);
        $controller->setNotifierService($notificationService);
        $controller->setFormationNotificationFactory($formationNotificationFactory);
        $controller->setAnneeUnivService($anneeUnivService);

        return $controller;
    }
+6 −0
Changes for module/Formation/src/Formation/Controller/SeanceController.php: 6 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
namespace Formation\Controller;

use Application\Controller\AbstractController;
use Application\Service\AnneeUniv\AnneeUnivServiceAwareTrait;
use Fichier\Service\Fichier\FichierStorageServiceAwareTrait;
use Fichier\Service\Storage\Adapter\Exception\StorageAdapterException;
use Formation\Entity\Db\Seance;
@@ -25,6 +26,7 @@ class SeanceController extends AbstractController
    use SeanceServiceAwareTrait;
    use SessionServiceAwareTrait;
    use SeanceFormAwareTrait;
    use AnneeUnivServiceAwareTrait;

    private ?PhpRenderer $renderer = null;
    public function setRenderer(PhpRenderer $renderer) { $this->renderer = $renderer; }
@@ -170,6 +172,9 @@ class SeanceController extends AbstractController
        $seance = $this->getSeanceService()->getRepository()->getRequestedSeance($this);
        $session = $seance->getSession();

        $annee = $session->getDateDebut() ? $this->anneeUnivService->fromDate($session->getDateDebut())->getPremiereAnnee() :
            $this->anneeUnivService->courante()->getPremiereAnnee();

        $logos = [];
        try {
            $logos['site'] = $this->fichierStorageService->getFileForLogoStructure($session->getSite()->getStructure());
@@ -189,6 +194,7 @@ class SeanceController extends AbstractController
        $export->setVars([
            'seance' => $seance,
            'logos' => $logos,
            'annee' => $annee
        ]);
        $export->export('SYGAL_emargement_' . $session->getId() . "_" . $seance->getId() . ".pdf");
    }
+4 −0
Changes for module/Formation/src/Formation/Controller/SeanceControllerFactory.php: 4 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 Fichier\Service\Fichier\FichierStorageService;
use Formation\Service\Session\SessionService;
use Psr\Container\ContainerExceptionInterface;
@@ -29,12 +30,14 @@ class SeanceControllerFactory {
         * @var \Fichier\Service\Fichier\FichierStorageService $fichierStorageService
         * @var SeanceService $seanceService
         * @var SessionService $sessionService
         * @var AnneeUnivService $anneeUnivService
         */
        $entityManager = $container->get('doctrine.entitymanager.orm_default');
        $etablissementService = $container->get(EtablissementService::class);
        $fichierStorageService = $container->get(FichierStorageService::class);
        $seanceService = $container->get(SeanceService::class);
        $sessionService = $container->get(SessionService::class);
        $anneeUnivService = $container->get(AnneeUnivService::class);

        /**
         * @var SeanceForm $seanceForm
@@ -51,6 +54,7 @@ class SeanceControllerFactory {
        $controller->setFichierStorageService($fichierStorageService);
        $controller->setSeanceService($seanceService);
        $controller->setSessionService($sessionService);
        $controller->setAnneeUnivService($anneeUnivService);
        /** forms *****************************************************************************************************/
        $controller->setSeanceForm($seanceForm);
        /** autre *****************************************************************************************************/
Loading