Commit e012b238 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Merge branch 'ModuleFormation_4.0.0' of git.unicaen.fr:open-source/sygal into ModuleFormation_4.0.0

parents a1228ebd 9fe60959
Loading
Loading
Loading
Loading
+5 −1
Changes for module/Formation/src/Formation/Controller/FormationController.php: 5 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ namespace Formation\Controller;

use Application\Controller\AbstractController;
use Formation\Service\Module\ModuleServiceAwareTrait;
use Formation\Service\Session\SessionServiceAwareTrait;
use Laminas\Http\Response;
use Structure\Service\Etablissement\EtablissementServiceAwareTrait;
use Formation\Entity\Db\Formation;
@@ -17,16 +18,19 @@ class FormationController extends AbstractController
    use EntityManagerAwareTrait;
    use FormationServiceAwareTrait;
    use ModuleServiceAwareTrait;
    use SessionServiceAwareTrait;
    use FormationFormAwareTrait;

    use EtablissementServiceAwareTrait;

    public function afficherAction()
    public function afficherAction() : ViewModel
    {
        $formation = $this->getFormationService()->getRepository()->getRequestedFormation($this);
        $sessions = $this->getSessionService()->getRepository()->fetchSessionsByFormation($formation, 'id', 'asc', true);

        return new ViewModel([
            'formation' => $formation,
            'sessions' => $sessions,
        ]);
    }

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

use Formation\Service\Module\ModuleService;
use Formation\Service\Session\SessionService;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Structure\Service\Etablissement\EtablissementService;
@@ -26,11 +27,13 @@ class FormationControllerFactory {
         * @var EtablissementService $etablissementService
         * @var FormationService $formationService
         * @var ModuleService $moduleService
         * @var SessionService $sessionService
         */
        $entityManager = $container->get('doctrine.entitymanager.orm_default');
        $etablissementService = $container->get(EtablissementService::class);
        $formationService = $container->get(FormationService::class);
        $moduleService = $container->get(ModuleService::class);
        $sessionService = $container->get(SessionService::class);

        /**
         * @var FormationForm $formationForm
@@ -42,6 +45,7 @@ class FormationControllerFactory {
        $controller->setEtablissementService($etablissementService);
        $controller->setFormationService($formationService);
        $controller->setModuleService($moduleService);
        $controller->setSessionService($sessionService);
        $controller->setFormationForm($formationForm);
        return $controller;
    }
+3 −0
Changes for module/Formation/src/Formation/Controller/SessionController.php: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -81,6 +81,9 @@ class SessionController extends AbstractController
            $form->setData($data);
            if ($form->isValid()) {
                $this->getSessionService()->create($session);
                $enPrepration = $this->getEntityManager()->getRepository(Etat::class)->findOneBy(["code" => Etat::CODE_PREPARATION]);
                $session->setEtat($enPrepration);
                $this->getSessionService()->update($session);
            }
        }

+11 −0
Changes for module/Formation/src/Formation/Entity/Db/Formation.php: 11 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -172,5 +172,16 @@ class Formation implements HistoriqueAwareInterface,
        return $this;
    }

    /** FONCTION POUR MACRO *******************************************************************************************/

    /**
     * @return string
     */
    public function toStringResponsable() : string
    {
        if ($this->getResponsable() === null) return "Aucun responsable de nommé·e pour cette formation";
        return $this->getResponsable()->getNomComplet();
    }


}
 No newline at end of file
+22 −0
Changes for module/Formation/src/Formation/Entity/Db/Repository/SessionRepository.php: 22 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ use Doctorant\Entity\Db\Doctorant;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\QueryBuilder;
use Formation\Entity\Db\Etat;
use Formation\Entity\Db\Formation;
use Formation\Entity\Db\Interfaces\HasTypeInterface;
use Formation\Entity\Db\Session;
use Individu\Entity\Db\Individu;
@@ -163,4 +164,25 @@ class SessionRepository extends EntityRepository
        $result = $qb->getQuery()->getResult();
        return $result;
    }

    /**
     * @param Formation|null $formation
     * @param string $champ
     * @param string $ordre
     * @param bool $keep_histo
     * @return array
     */
    public function fetchSessionsByFormation(?Formation $formation, string $champ='id', string $ordre='ASC', bool $keep_histo = false) : array
    {
        $qb = $this->createQB('session')
            ->orderBy('session.' . $champ, $ordre);

        if ($formation !== null)  $qb = $qb->andWhere('session.formation = :formation')->setParameter('formation', $formation);
        else                      $qb = $qb->andWhere('session.formation IS NULL');

        if (!$keep_histo) $qb = $qb->andWhere('session.histoDestruction IS NULL');

        $result = $qb->getQuery()->getResult();
        return $result;
    }
}
 No newline at end of file
Loading