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

Amélioration + page dédiée aux formateurs

parent d7ed0336
Loading
Loading
Loading
Loading
+4
Changes for module/Formation/config/module.config.php: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -12,6 +12,8 @@ use Formation\View\Helper\EtatViewHelper;
use Formation\View\Helper\FormateursViewHelper;
use Formation\View\Helper\ModaliteViewHelper;
use Formation\View\Helper\SeancesViewHelper;
use Formation\View\Helper\SessionInscriptionViewHelper;
use Formation\View\Helper\SessionLibelleViewHelper;
use Formation\View\Helper\SiteViewHelper;
use Formation\View\Helper\TypeViewHelper;
use Soutenance\Controller\AvisController;
@@ -88,6 +90,8 @@ return array(
            'etat' => EtatViewHelper::class,
            'seances' => SeancesViewHelper::class,
            'formateurs' => FormateursViewHelper::class,
            'sessionInscription' => SessionInscriptionViewHelper::class,
            'sessionLibelle' => SessionLibelleViewHelper::class,
        ]
    ],

+26
Changes for module/Formation/config/others/index.config.php: 26 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -31,6 +31,15 @@ return [
                        IndexPrivileges::INDEX_DOCTORANT,
                    ],
                ],
                [
                    'controller' => IndexController::class,
                    'action' => [
                        'index-formateur',
                    ],
                    'privileges' => [
                        IndexPrivileges::INDEX_FORMATEUR,
                    ],
                ],
            ],
        ],
    ],
@@ -51,6 +60,12 @@ return [
                        'resource' => PrivilegeController::getResourceId(IndexController::class, 'index-doctorant') ,
                        'order'    => 9999,
                    ],
                    'formation-formateur' => [
                        'label'    => 'Mes formations',
                        'route'    => 'formation/index-formateur',
                        'resource' => PrivilegeController::getResourceId(IndexController::class, 'index-formateur') ,
                        'order'    => 9999,
                    ],
                ],
            ],
        ],
@@ -80,6 +95,17 @@ return [
                            ],
                        ],
                    ],
                    'index-formateur' => [
                        'type'  => Segment::class,
                        'may_terminate' => true,
                        'options' => [
                            'route'    => '/index-formateur[/:formateur]',
                            'defaults' => [
                                'controller' => IndexController::class,
                                'action'     => 'index-formateur',
                            ],
                        ],
                    ],
                ],
            ],
        ],
+29
Changes for module/Formation/src/Formation/Controller/IndexController.php: 29 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ namespace Formation\Controller;

use Application\Controller\AbstractController;
use Application\Entity\Db\Doctorant;
use Application\Entity\Db\Individu;
use Formation\Entity\Db\EnqueteReponse;
use Formation\Entity\Db\Inscription;
use Formation\Entity\Db\Session;
@@ -59,4 +60,32 @@ class IndexController extends AbstractController
        ]);
    }

    public function indexFormateurAction()
    {
        /** @var Individu $individu */
        $individuId = $this->params()->fromRoute('formateur');
        if ($individuId !== null) {
            $individu = $this->getEntityManager()->getRepository(Individu::class)->find($individuId);
        } else {
            $individu = null;
        }

        if($individu) {
            $passees    = $this->getEntityManager()->getRepository(Session::class)->findSessionsPasseesByFormateur($individu);
            $courantes  = $this->getEntityManager()->getRepository(Session::class)->findSessionsCourantesByFormateur($individu);
            $futures    = $this->getEntityManager()->getRepository(Session::class)->findSessionsFuturesByFormateur($individu);
        } else {
            $passees = [];
            $courantes = [];
            $futures = [];
        }

        return new ViewModel([
            'individu' => $individu,
            'passees' => $passees,
            'courantes' => $courantes,
            'futures' => $futures,
        ]);
    }

}
 No newline at end of file
+69
Changes for module/Formation/src/Formation/Entity/Db/Repository/SessionRepository.php: 69 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
namespace Formation\Entity\Db\Repository;

use Application\Entity\Db\Doctorant;
use Application\Entity\Db\Individu;
use Application\Entity\Db\These;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\QueryBuilder;
@@ -118,4 +119,72 @@ class SessionRepository extends EntityRepository
        return $result;
    }

    /**
     * @param Individu $individu
     * @return array
     */
    public function findSessionsPasseesByFormateur(Individu $individu) : array
    {
        $etats = [ Etat::CODE_CLOTURER ];

        $qb = $this->createQB('session')
            ->leftJoin('session.formateurs', 'formateur')
            ->leftJoin('session.formateurs', 'aformateur')->addSelect('aformateur')
            ->andWhere('formateur.individu = :individu')
            ->setParameter('individu', $individu)
            ->andWhere('session.etat in (:etats)')
            ->andWhere('session.histoDestruction IS NULL')
            ->andWhere('formateur.histoDestruction IS NULL')
            ->setParameter('etats', $etats)
            ->orderBy('session.id', 'ASC')
        ;
        $result = $qb->getQuery()->getResult();
        return $result;
    }

    /**
     * @param Individu $individu
     * @return array
     */
    public function findSessionsCourantesByFormateur(Individu $individu) : array
    {
        $etats = [ Etat::CODE_FERME ];

        $qb = $this->createQB('session')
            ->leftJoin('session.formateurs', 'formateur')
            ->leftJoin('session.formateurs', 'aformateur')->addSelect('aformateur')
            ->andWhere('formateur.individu = :individu')
            ->setParameter('individu', $individu)
            ->andWhere('session.etat in (:etats)')
            ->andWhere('session.histoDestruction IS NULL')
            ->andWhere('formateur.histoDestruction IS NULL')
            ->setParameter('etats', $etats)
            ->orderBy('session.id', 'ASC')
        ;
        $result = $qb->getQuery()->getResult();
        return $result;
    }

    /**
     * @param Individu $individu
     * @return array
     */
    public function findSessionsFuturesByFormateur(Individu $individu) : array
    {
        $etats = [ Etat::CODE_OUVERTE, Etat::CODE_PREPARATION ];

        $qb = $this->createQB('session')
            ->leftJoin('session.formateurs', 'formateur')
            ->leftJoin('session.formateurs', 'aformateur')->addSelect('aformateur')
            ->andWhere('formateur.individu = :individu')
            ->setParameter('individu', $individu)
            ->andWhere('session.etat in (:etats)')
            ->andWhere('session.histoDestruction IS NULL')
            ->andWhere('formateur.histoDestruction IS NULL')
            ->setParameter('etats', $etats)
            ->orderBy('session.id', 'ASC')
        ;
        $result = $qb->getQuery()->getResult();
        return $result;
    }
}
 No newline at end of file
+1
Changes for module/Formation/src/Formation/Provider/Privilege/IndexPrivileges.php: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -9,4 +9,5 @@ class IndexPrivileges extends Privileges {

    const INDEX_AFFICHER = 'formation-index';
    const INDEX_DOCTORANT = 'formation-index_doctorant';
    const INDEX_FORMATEUR = 'formation-index_formateur';
}
 No newline at end of file
Loading