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

Justificatif de co-encadrements

parent e3dee3fe
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ return [
                        'index',
                        'historique',
                        'rechercher-co-encadrant',
                        'generer-justificatif-coencadrements',
                    ],
                    'privileges' => [
                        CoEncadrantPrivileges::COENCADRANT_AFFICHER,
@@ -65,6 +66,16 @@ return [
                            ],
                        ],
                    ],
                    'generer-justificatif-coencadrements' => [
                        'type'          => Segment::class,
                        'options'       => [
                            'route'    => '/generer-justificatif-coencadrements/:co-encadrant',
                            'defaults' => [
                                'controller'    => CoEncadrantController::class,
                                'action'        => 'generer-justificatif-coencadrements',
                            ],
                        ],
                    ],
                    'rechercher-co-encadrant' => [
                        'type'          => Literal::class,
                        'options'       => [
+54 −22
Original line number Diff line number Diff line
@@ -8,19 +8,34 @@ use Application\Entity\Db\These;
use Application\Form\RechercherCoEncadrantFormAwareTrait;
use Application\Service\Acteur\ActeurServiceAwareTrait;
use Application\Service\CoEncadrant\CoEncadrantServiceAwareTrait;
use Application\Service\CoEncadrant\Exporter\JustificatifCoencadrements\JustificatifCoencadrementPdfExporter;
use Application\Service\File\FileServiceAwareTrait;
use Application\Service\Individu\IndividuServiceAwareTrait;
use Application\Service\These\TheseServiceAwareTrait;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\JsonModel;
use Zend\View\Model\ViewModel;
use Zend\View\Renderer\PhpRenderer;

class CoEncadrantController extends AbstractActionController {
    use ActeurServiceAwareTrait;
    use CoEncadrantServiceAwareTrait;
    use IndividuServiceAwareTrait;
    use FileServiceAwareTrait;
    use TheseServiceAwareTrait;
    use RechercherCoEncadrantFormAwareTrait;

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

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

    public function indexAction()
    {
        $form = $this->getRechercherCoEncadrantForm();
@@ -66,27 +81,6 @@ class CoEncadrantController extends AbstractActionController {
        exit;
    }

    public function historiqueAction()
    {
        $coencadrant = $this->getCoEncadrantService()->getRequestedCoEncadrant($this);
        $theses = $this->getTheseService()->getRepository()->fetchThesesByCoEncadrant($coencadrant->getIndividu());

        $encours = []; $closes = [];
        foreach ($theses as $these) {
            if ($these->getEtatThese() === These::ETAT_EN_COURS) {
                $encours[] = $these;
            } else {
                $closes[] = $these;
            }
        }

        return new ViewModel([
            'coencadrant' => $coencadrant,
            'encours' => $encours,
            'closes' => $closes,
        ]);
    }

    public function ajouterCoEncadrantAction()
    {
        /** @var These $these */
@@ -94,7 +88,7 @@ class CoEncadrantController extends AbstractActionController {
        $these = $this->getTheseService()->getRepository()->find($theseId);

        $form = $this->getRechercherCoEncadrantForm();
        $form->setAttribute('action', $this->url()->fromRoute('these/ajouter-co-encadrant', [], [], true));
        $form->setAttribute('action', $this->url()->fromRoute('co-encadrant/ajouter-co-encadrant', [], [], true));
        $form->setUrlCoEncadrant($this->url()->fromRoute('utilisateur/rechercher-individu', [], [], true));

        $request = $this->getRequest();
@@ -126,6 +120,44 @@ class CoEncadrantController extends AbstractActionController {
        if ($acteur !== null AND $acteur->getThese() === $these) $this->getActeurService()->delete($acteur);

        $this->redirect()->toRoute('these/identite', ['these' => $these->getId()], [], true);
    }

    public function historiqueAction()
    {
        $coencadrant = $this->getCoEncadrantService()->getRequestedCoEncadrant($this);
        $theses = $this->getTheseService()->getRepository()->fetchThesesByCoEncadrant($coencadrant->getIndividu());

        $encours = []; $closes = [];
        foreach ($theses as $these) {
            if ($these->getEtatThese() === These::ETAT_EN_COURS) {
                $encours[] = $these;
            } else {
                $closes[] = $these;
            }
        }

        return new ViewModel([
            'coencadrant' => $coencadrant,
            'encours' => $encours,
            'closes' => $closes,
        ]);
    }

    public function genererJustificatifCoencadrementsAction()
    {
        $coencadrant = $this->getCoEncadrantService()->getRequestedCoEncadrant($this);
        $theses = $this->getTheseService()->getRepository()->fetchThesesByCoEncadrant($coencadrant->getIndividu());

        $logos = [];
        $logos['etablissement'] = $this->fileService->computeLogoFilePathForStructure($coencadrant->getEtablissement());

        //exporter
        $export = new JustificatifCoencadrementPdfExporter($this->renderer, 'A4');
        $export->setVars([
            'coencadrant' => $coencadrant,
            'theses' => $theses,
            'logos' => $logos,
        ]);
        $export->export('justificatif_coencadrement_' . $coencadrant->getIndividu()->getId() . ".pdf");
    }
}
 No newline at end of file
+10 −1
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
namespace Application\Controller;

use Application\Entity\Db\TypeStructure;
use Application\Service\CoEncadrant\CoEncadrantServiceAwareTrait;
use Application\Service\EcoleDoctorale\EcoleDoctoraleService;
use Application\Service\EcoleDoctorale\EcoleDoctoraleServiceAwareTrait;
use Zend\Http\Response;
@@ -10,6 +11,7 @@ use Zend\View\Model\ViewModel;

class EcoleDoctoraleController extends StructureConcreteController
{
    use CoEncadrantServiceAwareTrait;
    use EcoleDoctoraleServiceAwareTrait;

    protected $codeTypeStructure = TypeStructure::CODE_ECOLE_DOCTORALE;
@@ -44,9 +46,16 @@ class EcoleDoctoraleController extends StructureConcreteController
     */
    public function informationAction()
    {
        $id = $this->params()->fromRoute('structure');
        $structureConcrete = $this->getStructureConcreteService()->getRepository()->findByStructureId($id);
        $coencadrants = $this->getCoEncadrantService()->getCoEncadrantsByEcodeDoctorale($structureConcrete);

        $viewModel = parent::informationAction();

        $viewModel->setVariable('ecole', $viewModel->getVariable('structure'));
        $viewModel->setVariables([
            'ecole' => $viewModel->getVariable('structure'),
            'coencadrants' => $coencadrants,
        ]);

        return $viewModel;
    }
+9 −0
Original line number Diff line number Diff line
@@ -6,9 +6,11 @@ use Application\Controller\CoEncadrantController;
use Application\Form\RechercherCoEncadrantForm;
use Application\Service\Acteur\ActeurService;
use Application\Service\CoEncadrant\CoEncadrantService;
use Application\Service\File\FileService;
use Application\Service\Individu\IndividuService;
use Application\Service\These\TheseService;
use Interop\Container\ContainerInterface;
use Zend\View\Renderer\PhpRenderer;

class CoEncadrantControllerFactory {

@@ -22,11 +24,13 @@ class CoEncadrantControllerFactory {
         * @var ActeurService $acteurService
         * @var CoEncadrantService $coEncadrantService
         * @var IndividuService $individuService
         * @var FileService $fileService
         * @var TheseService $theseService
         */
        $acteurService = $container->get(ActeurService::class);
        $coEncadrantService = $container->get(CoEncadrantService::class);
        $individuService = $container->get('IndividuService');
        $fileService = $container->get(FileService::class);
        $theseService = $container->get('TheseService');

        /**
@@ -34,12 +38,17 @@ class CoEncadrantControllerFactory {
         */
        $rechercheCoEncadrantForm = $container->get('FormElementManager')->get(RechercherCoEncadrantForm::class);

        /* @var $renderer PhpRenderer */
        $renderer = $container->get('ViewRenderer');

        $controller = new CoEncadrantController();
        $controller->setActeurService($acteurService);
        $controller->setCoEncadrantService($coEncadrantService);
        $controller->setIndividuService($individuService);
        $controller->setFileService($fileService);
        $controller->setTheseService($theseService);
        $controller->setRechercherCoEncadrantForm($rechercheCoEncadrantForm);
        $controller->setRenderer($renderer);
        return $controller;
    }
}
 No newline at end of file
+4 −0
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ namespace Application\Controller\Factory;

use Application\Controller\EcoleDoctoraleController;
use Application\Form\EcoleDoctoraleForm;
use Application\Service\CoEncadrant\CoEncadrantService;
use Application\Service\EcoleDoctorale\EcoleDoctoraleService;
use Application\Service\Etablissement\EtablissementServiceLocateTrait;
use Application\Service\Individu\IndividuService;
@@ -28,16 +29,19 @@ class EcoleDoctoraleControllerFactory
        $form = $container->get('FormElementManager')->get('EcoleDoctoraleForm');

        /**
         * @var CoEncadrantService $coEncadrantService
         * @var EcoleDoctoraleService $ecoleDoctoralService
         * @var IndividuService $individuService
         * @var RoleService $roleService
         * @var StructureService $structureService
         */
        $coEncadrantService = $container->get(CoEncadrantService::class);
        $ecoleDoctoralService = $container->get('EcoleDoctoraleService');
        $structureService = $container->get(StructureService::class);
        $roleService = $container->get('RoleService');

        $controller = new EcoleDoctoraleController();
        $controller->setCoEncadrantService($coEncadrantService);
        $controller->setEcoleDoctoraleService($ecoleDoctoralService);
        $controller->setRoleService($roleService);
        $controller->setStructureForm($form);
Loading