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

WIP

parent 17bfd722
Loading
Loading
Loading
Loading
+35 −51
Changes for module/Formation/src/Formation/Controller/SessionController.php: 35 added lines, 51 removed lines.
Original line number Diff line number Diff line
@@ -4,13 +4,14 @@ namespace Formation\Controller;

use Application\Controller\AbstractController;
use Application\Entity\Db\These;
use Formation\Service\Formation\FormationServiceAwareTrait;
use Formation\Service\Presence\PresenceServiceAwareTrait;
use Laminas\Http\Response;
use Structure\Service\Etablissement\EtablissementServiceAwareTrait;
use Application\Service\File\FileServiceAwareTrait;
use DateTime;
use Formation\Entity\Db\Etat;
use Formation\Entity\Db\Inscription;
use Formation\Entity\Db\Formation;
use Formation\Entity\Db\Presence;
use Formation\Entity\Db\Seance;
use Formation\Entity\Db\Session;
use Formation\Form\Session\SessionFormAwareTrait;
@@ -28,24 +29,25 @@ class SessionController extends AbstractController
    use EntityManagerAwareTrait;
    use EtablissementServiceAwareTrait;
    use FileServiceAwareTrait;
    use FormationServiceAwareTrait;
    use InscriptionServiceAwareTrait;
    use NotificationServiceAwareTrait;
    use PresenceServiceAwareTrait;
    use SessionServiceAwareTrait;

    use SessionFormAwareTrait;

    /** @var PhpRenderer */
    private $renderer;
    private PhpRenderer $renderer;

    /**
     * @param PhpRenderer $renderer
     */
    public function setRenderer($renderer)
    public function setRenderer(PhpRenderer $renderer)
    {
        $this->renderer = $renderer;
    }

    public function indexAction()
    public function indexAction() : ViewModel
    {
        $filtres = [
            'site' => $this->params()->fromQuery('site'),
@@ -57,13 +59,11 @@ class SessionController extends AbstractController
        ];
        $listings = [
            'sites' => $this->getEtablissementService()->getRepository()->findAllEtablissementsInscriptions(),
            'responsables' => $this->getEntityManager()->getRepository(Formation::class)->fetchListeResponsable(),
            'structures' => $this->getEntityManager()->getRepository(Formation::class)->fetchListeStructures(),
            'responsables' => $this->getFormationService()->getRepository()->fetchListeResponsable(),
            'structures' => $this->getFormationService()->getRepository()->fetchListeStructures(),
            'etats' => $this->getEntityManager()->getRepository(Etat::class)->findAll(),
        ];

        /** @var Session[] $sessions */
        $sessions = $this->getEntityManager()->getRepository(Session::class)->fetchSessionsWithFiltres($filtres);
        $sessions = $this->getSessionService()->getRepository()->fetchSessionsWithFiltres($filtres);

        return new ViewModel([
            'sessions' => $sessions,
@@ -72,12 +72,11 @@ class SessionController extends AbstractController
        ]);
    }

    public function afficherAction()
    public function afficherAction() : ViewModel
    {
        /**@var Session $session */
        $session = $this->getEntityManager()->getRepository(Session::class)->getRequestedSession($this);
        $session = $this->getSessionService()->getRepository()->getRequestedSession($this);

        $presences = $this->getEntityManager()->getRepository(Presence::class)->findPresencesBySession($session);
        $presences = $this->getPresenceService()->getRepository()->findPresencesBySession($session);
        $dictionnaire = [];
        foreach ($presences as $presence) {
            $dictionnaire[$presence->getSeance()->getId()][$presence->getInscription()->getId()] = $presence;
@@ -89,10 +88,9 @@ class SessionController extends AbstractController
        ]);
    }

    public function ajouterAction()
    public function ajouterAction() : ViewModel
    {
        /** @var Formation $formation */
        $formation = $this->getEntityManager()->getRepository(Formation::class)->getRequestedFormation($this);
        $formation = $this->getFormationService()->getRepository()->getRequestedFormation($this);

        $session = new Session();
        $session->setFormation($formation);
@@ -119,10 +117,9 @@ class SessionController extends AbstractController
        return $vm;
    }

    public function modifierAction()
    public function modifierAction() : ViewModel
    {
        /**@var Session $session */
        $session = $this->getEntityManager()->getRepository(Session::class)->getRequestedSession($this);
        $session = $this->getSessionService()->getRepository()->getRequestedSession($this);

        $form = $this->getSessionForm();
        $form->setAttribute('action', $this->url()->fromRoute('formation/session/modifier', ['session' => $session->getId()], [], true));
@@ -145,34 +142,29 @@ class SessionController extends AbstractController
        return $vm;
    }

    public function historiserAction()
    public function historiserAction() : Response
    {
        /**@var Session $session */
        $session = $this->getEntityManager()->getRepository(Session::class)->getRequestedSession($this);
        $retour = $this->params()->fromQuery('retour');

        $session = $this->getSessionService()->getRepository()->getRequestedSession($this);
        $this->getSessionService()->historise($session);

        $retour = $this->params()->fromQuery('retour');
        if ($retour) return $this->redirect()->toUrl($retour);
        return $this->redirect()->toRoute('formation/session');
    }

    public function restaurerAction()
    public function restaurerAction() : Response
    {
        /**@var Session $session */
        $session = $this->getEntityManager()->getRepository(Session::class)->getRequestedSession($this);
        $retour = $this->params()->fromQuery('retour');

        $session = $this->getSessionService()->getRepository()->getRequestedSession($this);
        $this->getSessionService()->restore($session);

        $retour = $this->params()->fromQuery('retour');
        if ($retour) return $this->redirect()->toUrl($retour);
        return $this->redirect()->toRoute('formation/session');
    }

    public function supprimerAction()
    public function supprimerAction() : ViewModel
    {
        /**@var Session $session */
        $session = $this->getEntityManager()->getRepository(Session::class)->getRequestedSession($this);
        $session = $this->getSessionService()->getRepository()->getRequestedSession($this);

        $request = $this->getRequest();
        if ($request->isPost()) {
@@ -195,8 +187,7 @@ class SessionController extends AbstractController

    public function changerEtatAction()
    {
        /**@var Session $session */
        $session = $this->getEntityManager()->getRepository(Session::class)->getRequestedSession($this);
        $session = $this->getSessionService()->getRepository()->getRequestedSession($this);
        /**@var Etat $etat */
        $etat = $this->getEntityManager()->getRepository(Etat::class)->getRequestedEtat($this);

@@ -236,11 +227,9 @@ class SessionController extends AbstractController
        ]);
    }

    public function classerInscriptionsAction()
    public function classerInscriptionsAction() : Response
    {
        /**@var Session $session */
        $session = $this->getEntityManager()->getRepository(Session::class)->getRequestedSession($this);
        $retour = $this->params()->fromQuery('retour');
        $session = $this->getSessionService()->getRepository()->getRequestedSession($this);

        $inscriptions = $session->getInscriptions();
        $classements = [Inscription::LISTE_PRINCIPALE => [],  Inscription::LISTE_COMPLEMENTAIRE => [], 'N' => []];
@@ -274,15 +263,14 @@ class SessionController extends AbstractController
            }
        }

        $retour = $this->params()->fromQuery('retour');
        if ($retour) return $this->redirect()->toUrl($retour);
        return $this->redirect()->toRoute('formation/session/afficher', ['session' => $session->getId()], [], true);
    }

    public function declasserInscriptionsAction()
    public function declasserInscriptionsAction() : Response
    {
        /**@var Session $session */
        $session = $this->getEntityManager()->getRepository(Session::class)->getRequestedSession($this);
        $retour = $this->params()->fromQuery('retour');
        $session = $this->getSessionService()->getRepository()->getRequestedSession($this);

        /** @var Inscription $inscription */
        foreach ($session->getInscriptions() as $inscription) {
@@ -290,21 +278,18 @@ class SessionController extends AbstractController
            $this->getInscriptionService()->update($inscription);
        }

        $retour = $this->params()->fromQuery('retour');
        if ($retour) return $this->redirect()->toUrl($retour);
        return $this->redirect()->toRoute('formation/session/afficher', ['session' => $session->getId()], [], true);
    }

    public function genererExportAction() : CsvModel
    {
        /**@var Session $session */
        $session = $this->getEntityManager()->getRepository(Session::class)->getRequestedSession($this);
        $session = $this->getSessionService()->getRepository()->getRequestedSession($this);

        $headers = ['Liste', 'Dénomination étudiant', 'Adresse électronique', 'Établissement', 'École doctorale', 'Unité de recherche'];

        $inscriptions = $session->getInscriptions()->toArray();
        usort($inscriptions, function (Inscription $a, Inscription $b) {

        });
        $records = [];
        /** @var Inscription $inscription */
        foreach ($inscriptions as $inscription) {
@@ -336,8 +321,7 @@ class SessionController extends AbstractController

    public function genererEmargementsAction()
    {
        /**@var Session $session */
        $session = $this->getEntityManager()->getRepository(Session::class)->getRequestedSession($this);
        $session = $this->getSessionService()->getRepository()->getRequestedSession($this);
        $seances = $session->getSeances()->toArray();
        $seances = array_filter($seances, function ($a) { return $a->estNonHistorise();});
        usort($seances, function (Seance $a, Seance $b) { return $a->getDebut() > $b->getDebut();});
+17 −33
Changes for module/Formation/src/Formation/Entity/Db/Session.php: 17 added lines, 33 removed lines.
Original line number Diff line number Diff line
@@ -34,38 +34,22 @@ class Session implements HistoriqueAwareInterface,
    const MODALITE_PRESENTIELLE = 'Présentielle';
    const MODALITE_DISTANCIELLE = 'Distancielle';

    /** @var int */
    private $id;

    /** @var int */
    private $index;
    /** @var Formation|null */
    private $formation;

    /** Informations générale sur la session **************************************************************************/
    /** @var Etablissement|null */
    private $site;
    /** @var Utilisateur|null */
    private $responsable;
    /** @var Etat|null */
    private $etat;
    /** @var string|null */
    private $description;

    /** Liste des scéances ********************************************************************************************/
    /** @var Collection (Seance) */
    private $seances;
    /** Liste des formateurs ******************************************************************************************/
    /** @var Collection (Formateur) */
    private $formateurs;

    /** Liste des insscriptions et listes associées *******************************************************************/
    /** @var int */
    private $tailleListePrincipale;
    /** @var int */
    private $tailleListeComplementaire;
    /** @var Collection (Inscription) */
    private $inscriptions;
    private int $id;
    private ?int $index = null;
    private ?Formation $formation = null;

    /** TODO COLLECTION ? */
    //private ?Etablissement $site = null;
    private ?Utilisateur $responsable = null;
    private ?Etat $etat = null;
    private ?string $description;

    private Collection $seances;
    private Collection $formateurs;
    private Collection $inscriptions;

    private ?int $tailleListePrincipale = null;
    private ?int $tailleListeComplementaire = null;

    /**
     * @return int
@@ -102,7 +86,7 @@ class Session implements HistoriqueAwareInterface,
    }

    /**
     * @param Formation|null $module
     * @param Formation|null $formation
     * @return Session
     */
    public function setFormation(?Formation $formation): Session
+9 −7
Changes for module/Formation/src/Formation/Form/Session/SessionForm.php: 9 added lines, 7 removed lines.
Original line number Diff line number Diff line
@@ -2,7 +2,6 @@

namespace Formation\Form\Session;

use Structure\Entity\Db\TypeStructure;
use Structure\Service\Etablissement\EtablissementServiceAwareTrait;
use Structure\Service\Structure\StructureServiceAwareTrait;
use UnicaenApp\Form\Element\SearchAndSelect;
@@ -18,8 +17,7 @@ class SessionForm extends Form {
    use EtablissementServiceAwareTrait;
    use StructureServiceAwareTrait;

    /** @var string */
    private $urlResponsable;
    private ?string $urlResponsable = null;

    /**
     * @param string $urlResponsable
@@ -39,7 +37,8 @@ class SessionForm extends Form {
            'type' => Text::class,
            'name' => 'libelle',
            'options' => [
                'label' => "Libellé de la formation :",
                'label' => "Libellé de la formation <span class='icon icon-star' style='color: darkred;' title='Obligatoire'></span> :",
                'label_options' => [ 'disable_html_escape' => true, ],
            ],
            'attributes' => [
                'id' => 'libelle',
@@ -65,7 +64,8 @@ class SessionForm extends Form {
            'type' => Select::class,
            'name' => 'site',
            'options' => [
                'label' => "Site de la formation :",
                'label' => "Site de la formation <span class='icon icon-star' style='color: darkred;' title='Obligatoire'></span> :",
                'label_options' => [ 'disable_html_escape' => true, ],
                'empty_option' => "Aucun établissement",
                'value_options' => $this->getEtablissementService()->getEtablissementInscriptionAsOption(),
            ],
@@ -76,7 +76,7 @@ class SessionForm extends Form {
            ],
        ]);
        //responsable
        $responsable = new SearchAndSelect('responsable', ['label' => "Responsable de la formation :"]);
        $responsable = new SearchAndSelect('responsable', ['label' => "Responsable de la formation <span class='icon icon-star' style='color: darkred;' title='Obligatoire'></span> :"]);
        $responsable
            ->setAutocompleteSource($this->urlResponsable)
            ->setSelectionRequired(true)
@@ -84,13 +84,15 @@ class SessionForm extends Form {
                'id' => 'responsable',
                'placeholder' => "Nom du responsable ...",
            ]);
        $responsable->setLabelOption('disable_html_escape', true);
        $this->add($responsable);
        //modalité
        $this->add([
            'type' => Select::class,
            'name' => 'modalite',
            'options' => [
                'label' => "Modalité :",
                'label' => "Modalité <span class='icon icon-star' style='color: darkred;' title='Obligatoire'></span> :",
                'label_options' => [ 'disable_html_escape' => true, ],
                'empty_option' => "Non précisée",
                'value_options' => ['P' => 'Présentielle', 'D' => 'Distancielle'],
            ],
+11 −0
Changes for module/Formation/src/Formation/Service/Presence/PresenceService.php: 11 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -6,12 +6,23 @@ use DateTime;
use Doctrine\ORM\ORMException;
use Formation\Entity\Db\Inscription;
use Formation\Entity\Db\Presence;
use Formation\Entity\Db\Repository\PresenceRepository;
use UnicaenApp\Exception\RuntimeException;
use UnicaenApp\Service\EntityManagerAwareTrait;

class PresenceService {
    use EntityManagerAwareTrait;

    /**
     * @return PresenceRepository
     */
    public function getRepository() : PresenceRepository
    {
        /** @var PresenceRepository $repo */
        $repo = $this->entityManager->getRepository(Presence::class);
        return $repo;
    }

    /** GESTION DES ENTITES *******************************************************************************************/

    /**
+12 −0
Changes for module/Formation/src/Formation/Service/Session/SessionService.php: 12 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -5,6 +5,8 @@ namespace Formation\Service\Session;
use DateTime;
use Doctrine\ORM\ORMException;
use Formation\Entity\Db\Formation;
use Formation\Entity\Db\Repository\FormationRepository;
use Formation\Entity\Db\Repository\SessionRepository;
use Formation\Entity\Db\Session;
use UnicaenApp\Exception\RuntimeException;
use UnicaenApp\Service\EntityManagerAwareTrait;
@@ -12,6 +14,16 @@ use UnicaenApp\Service\EntityManagerAwareTrait;
class SessionService {
    use EntityManagerAwareTrait;

    /**
     * @return SessionRepository
     */
    public function getRepository() : SessionRepository
    {
        /** @var SessionRepository $repo */
        $repo = $this->entityManager->getRepository(Session::class);
        return $repo;
    }

    /** GESTION DES ENTITES *******************************************************************************************/

    /**
Loading