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

Merge branch 'ModuleIndicateur#15478'

parents d492e071 cd3d096b
Loading
Loading
Loading
Loading
+28
Changes for module/Application/src/Application/Service/Individu/IndividuService.php: 28 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -150,8 +150,22 @@ class IndividuService extends BaseService
    public function getActeurSansMail()
    {
        $qb = $this->getEntityManager()->getRepository(Acteur::class)->createQueryBuilder("acteur")
            ->addSelect("these")
            ->addSelect("individu")
            ->addSelect("etablissement")
            ->addSelect("ecoleDoctorale")
            ->addSelect("uniteRecherche")
            ->addSelect("structure_etab")
            ->addSelect("structure_ed")
            ->addSelect("structure_ur")
            ->leftJoin("acteur.individu", "individu")
            ->leftJoin("acteur.these", "these")
            ->leftJoin("these.etablissement", "etablissement")
            ->leftJoin("etablissement.structure", "structure_etab")
            ->leftJoin("these.ecoleDoctorale", "ecoleDoctorale")
            ->leftJoin("ecoleDoctorale.structure", "structure_ed")
            ->leftJoin("these.uniteRecherche", "uniteRecherche")
            ->leftJoin("uniteRecherche.structure", "structure_ur")
            ->andWhere("individu.email is NULL")
            ->andWhere("these.etatThese = 'E'")
            ->orderBy("these.sourceCode")
@@ -164,8 +178,22 @@ class IndividuService extends BaseService
    public function getDoctorantSansMail()
    {
        $qb = $this->getEntityManager()->getRepository(These::class)->createQueryBuilder("these")
            ->addSelect("doctorant")
            ->addSelect("individu")
            ->leftJoin("these.doctorant", "doctorant")
            ->leftJoin("doctorant.individu", "individu")
            ->addSelect("etablissement")
            ->addSelect("ecoleDoctorale")
            ->addSelect("uniteRecherche")
            ->addSelect("structure_etab")
            ->addSelect("structure_ed")
            ->addSelect("structure_ur")
            ->leftJoin("these.etablissement", "etablissement")
            ->leftJoin("etablissement.structure", "structure_etab")
            ->leftJoin("these.ecoleDoctorale", "ecoleDoctorale")
            ->leftJoin("ecoleDoctorale.structure", "structure_ed")
            ->leftJoin("these.uniteRecherche", "uniteRecherche")
            ->leftJoin("uniteRecherche.structure", "structure_ur")
            ->andWhere("individu.email is NULL")
            ->andWhere("these.etatThese = 'E'")
            ->orderBy("these.sourceCode")
+161
Changes for module/Application/src/Application/Service/These/TheseService.php: 161 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -10,6 +10,8 @@ use Application\Entity\Db\NatureFichier;
use Application\Entity\Db\RdvBu;
use Application\Entity\Db\Repository\TheseRepository;
use Application\Entity\Db\These;
use Application\Entity\Db\TypeValidation;
use Application\Entity\Db\Validation;
use Application\Entity\Db\VersionFichier;
use Application\Notification\ValidationRdvBuNotification;
use Application\Service\BaseService;
@@ -18,10 +20,12 @@ use Application\Service\Notification\NotifierServiceAwareTrait;
use Application\Service\UserContextServiceAwareTrait;
use Application\Service\Validation\ValidationServiceAwareTrait;
use Application\Service\Variable\VariableServiceAwareTrait;
use DateInterval;
use Doctrine\ORM\OptimisticLockException;
use UnicaenApp\Exception\RuntimeException;
use UnicaenApp\Traits\MessageAwareInterface;
use UnicaenAuth\Entity\Db\UserInterface;
use Zend\Validator\Date;

class TheseService extends BaseService
{
@@ -233,6 +237,22 @@ class TheseService extends BaseService
    public function getTheseEnCoursPostSoutenance()
    {
        $qb = $this->getEntityManager()->getRepository(These::class)->createQueryBuilder("these")
            ->addSelect("doctorant")
            ->addSelect("individu")
            ->leftJoin("these.doctorant", "doctorant")
            ->leftJoin("doctorant.individu", "individu")
            ->addSelect("etablissement")
            ->addSelect("ecoleDoctorale")
            ->addSelect("uniteRecherche")
            ->addSelect("structure_etab")
            ->addSelect("structure_ed")
            ->addSelect("structure_ur")
            ->leftJoin("these.etablissement", "etablissement")
            ->leftJoin("etablissement.structure", "structure_etab")
            ->leftJoin("these.ecoleDoctorale", "ecoleDoctorale")
            ->leftJoin("ecoleDoctorale.structure", "structure_ed")
            ->leftJoin("these.uniteRecherche", "uniteRecherche")
            ->leftJoin("uniteRecherche.structure", "structure_ur")
            ->andWhere("these.etatThese = :encours")
            ->andWhere("these.dateSoutenance < :today")
            ->setParameter("encours", These::ETAT_EN_COURS)
@@ -283,6 +303,22 @@ class TheseService extends BaseService
        $dateLimite = \DateTime::createFromFormat('d/m/Y', "01/".$mois."/".$annee);

        $qb = $this->getEntityManager()->getRepository(These::class)->createQueryBuilder("these")
            ->addSelect("doctorant")
            ->addSelect("individu")
            ->leftJoin("these.doctorant", "doctorant")
            ->leftJoin("doctorant.individu", "individu")
            ->addSelect("etablissement")
            ->addSelect("ecoleDoctorale")
            ->addSelect("uniteRecherche")
            ->addSelect("structure_etab")
            ->addSelect("structure_ed")
            ->addSelect("structure_ur")
            ->leftJoin("these.etablissement", "etablissement")
            ->leftJoin("etablissement.structure", "structure_etab")
            ->leftJoin("these.ecoleDoctorale", "ecoleDoctorale")
            ->leftJoin("ecoleDoctorale.structure", "structure_ed")
            ->leftJoin("these.uniteRecherche", "uniteRecherche")
            ->leftJoin("uniteRecherche.structure", "structure_ur")
            ->andWhere("these.etatThese = :encours")
            ->andWhere("these.datePremiereInscription <= :date")
            ->setParameter("encours", These::ETAT_EN_COURS)
@@ -293,4 +329,129 @@ class TheseService extends BaseService

        return $result;
    }

    public function getTheseASoutenir()
    {
        $aujourdhui = new \DateTime();
        $anneeCourante = ((int) (new \DateTime())->format("Y"));
        $anneeProchaine = $anneeCourante + 1;
        $dateMin = \DateTime::createFromFormat("d/m/Y", "01/01/".$anneeCourante);
        $dateMax = \DateTime::createFromFormat("d/m/Y", "01/01/".$anneeProchaine);
        $qb = $this->getEntityManager()->getRepository(These::class)->createQueryBuilder("these")
                ->addSelect("doctorant")
                ->addSelect("individu")
                ->leftJoin("these.doctorant", "doctorant")
                ->leftJoin("doctorant.individu", "individu")
                ->addSelect("etablissement")
                ->addSelect("ecoleDoctorale")
                ->addSelect("uniteRecherche")
                ->addSelect("structure_etab")
                ->addSelect("structure_ed")
                ->addSelect("structure_ur")
                ->leftJoin("these.etablissement", "etablissement")
                ->leftJoin("etablissement.structure", "structure_etab")
                ->leftJoin("these.ecoleDoctorale", "ecoleDoctorale")
                ->leftJoin("ecoleDoctorale.structure", "structure_ed")
                ->leftJoin("these.uniteRecherche", "uniteRecherche")
                ->leftJoin("uniteRecherche.structure", "structure_ur")
            ->andWhere("these.dateSoutenance IS NOT NULL")
            ->andWhere("these.dateSoutenance < :dateN")
            ->andWhere("these.dateSoutenance >= :dateC")
            ->andWhere("these.etatThese = :encours")
            ->setParameter("dateN", $dateMax)
            ->setParameter("dateC", $aujourdhui)
            ->setParameter("encours",These::ETAT_EN_COURS)
            ->orderBy("these.dateSoutenance", "ASC");
            ;

        $result = $qb->getQuery()->getResult();
        return $result;
    }

    /**
     * @param $nbMois
     * @return array
     * @throws \Exception
     */
    public function getTheseSansCouverture($nbMois)
    {
        $dateCourante = new \DateTime();
        $dateLimite = (new \DateTime())->add(new DateInterval("P".$nbMois."M"));

        $qb = $this->getEntityManager()->getRepository(These::class)->createQueryBuilder("these")
            ->addSelect("doctorant")
            ->addSelect("individu")
            ->leftJoin("these.doctorant", "doctorant")
            ->leftJoin("doctorant.individu", "individu")
            ->addSelect("etablissement")
            ->addSelect("ecoleDoctorale")
            ->addSelect("uniteRecherche")
            ->addSelect("structure_etab")
            ->addSelect("structure_ed")
            ->addSelect("structure_ur")
            ->leftJoin("these.etablissement", "etablissement")
            ->leftJoin("etablissement.structure", "structure_etab")
            ->leftJoin("these.ecoleDoctorale", "ecoleDoctorale")
            ->leftJoin("ecoleDoctorale.structure", "structure_ed")
            ->leftJoin("these.uniteRecherche", "uniteRecherche")
            ->leftJoin("uniteRecherche.structure", "structure_ur")
            ->andWhere("these.etatThese = :encours")
            ->andWhere("these.dateSoutenance IS NOT NULL")
            ->andWhere("these.dateSoutenance >= :dateCourante")
            ->andWhere("these.dateSoutenance < :dateLimite")
            ->setParameter("encours", These::ETAT_EN_COURS)
            ->setParameter("dateCourante", $dateCourante)
            ->setParameter("dateLimite", $dateLimite)

            ->leftJoin("these.validations", "validation")
            ->andWhere("validation.id IS NULL")

            ->leftjoin("validation.typeValidation", "typeValidation", "WITH", "typeValidation.code = :PDC")
            ->setParameter("PDC", TypeValidation::CODE_PAGE_DE_COUVERTURE)

        ;
        $result = $qb->getQuery()->getResult();
        return $result;
    }

    public function getTheseSansDepot($nbMois)
    {
        $dateCourante = new \DateTime();
        $dateLimite = (new \DateTime())->add(new DateInterval("P".$nbMois."M"));

        $qb = $this->getEntityManager()->getRepository(These::class)->createQueryBuilder("these")
            ->addSelect("doctorant")
            ->addSelect("individu")
            ->leftJoin("these.doctorant", "doctorant")
            ->leftJoin("doctorant.individu", "individu")
            ->addSelect("etablissement")
            ->addSelect("ecoleDoctorale")
            ->addSelect("uniteRecherche")
            ->addSelect("structure_etab")
            ->addSelect("structure_ed")
            ->addSelect("structure_ur")
            ->leftJoin("these.etablissement", "etablissement")
            ->leftJoin("etablissement.structure", "structure_etab")
            ->leftJoin("these.ecoleDoctorale", "ecoleDoctorale")
            ->leftJoin("ecoleDoctorale.structure", "structure_ed")
            ->leftJoin("these.uniteRecherche", "uniteRecherche")
            ->leftJoin("uniteRecherche.structure", "structure_ur")
            ->andWhere("these.etatThese = :encours")
            ->andWhere("these.dateSoutenance IS NOT NULL")
            ->andWhere("these.dateSoutenance >= :dateCourante")
            ->andWhere("these.dateSoutenance < :dateLimite")
            ->setParameter("encours", These::ETAT_EN_COURS)
            ->setParameter("dateCourante", $dateCourante)
            ->setParameter("dateLimite", $dateLimite)

            ->leftJoin("these.fichiers", "fichier")
            ->andWhere("fichier.id IS NULL")

            ->leftJoin("fichier.nature", "nature", "WITH", "nature.code = :nature")
            ->setParameter("nature", NatureFichier::CODE_THESE_PDF)
        ;

        $result = $qb->getQuery()->getResult();
        return $result;
    }
}
 No newline at end of file
+95
Changes for module/Indicateur/config/module.config.php: 95 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -20,6 +20,12 @@ return array(
                        'export-doctorants-sans-mail',
                        'theses-anciennes',
                        'export-theses-anciennes',
                        'theses-a-soutenir',
                        'export-theses-a-soutenir',
                        'theses-sans-pdc',
                        'export-theses-sans-pdc',
                        'theses-sans-depot',
                        'export-theses-sans-depot',
                ],
                    'roles' => [
                        'Administrateur technique',
@@ -30,6 +36,29 @@ return array(
    ],
    'doctrine'     => [],

    'navigation'      => [
        'default' => [
            'home' => [
                'pages' => [
                    'admin' => [
                        'pages' => [
                            'indicateur' => [
                                'label'    => 'Indicateurs',
                                'route'    => 'indicateur',
                                //'resource' => PrivilegeController::getResourceId('Application\Controller\EcoleDoctorale', 'index'),
                                'roles' => [
                                    'Administrateur technique',
                                ],

                                'order'    => 1,
                            ],
                        ],
                    ],
                ],
            ],
        ],
    ],

    'router' => [
        'routes' => [
            'indicateur' => [
@@ -87,6 +116,72 @@ return array(
                            ],
                        ],
                    ],
                    'theses-a-soutenir' => [
                        'type'          => Segment::class,
                        'may_terminate' => true,
                        'options'       => [
                            'route'       => '/theses-a-soutenir',
                            'defaults'    => [
                                'action' => 'theses-a-soutenir',
                            ],
                        ],
                        'child_routes'  => [
                            'export' => [
                                'type'          => Segment::class,
                                'may_terminate' => true,
                                'options'       => [
                                    'route'       => '/export',
                                    'defaults'    => [
                                        'action' => 'export-theses-a-soutenir',
                                    ],
                                ],
                            ],
                        ],
                    ],
                    'theses-sans-pdc' => [
                        'type'          => Segment::class,
                        'may_terminate' => true,
                        'options'       => [
                            'route'       => '/theses-sans-pdc',
                            'defaults'    => [
                                'action' => 'theses-sans-pdc',
                            ],
                        ],
                        'child_routes'  => [
                            'export' => [
                                'type'          => Segment::class,
                                'may_terminate' => true,
                                'options'       => [
                                    'route'       => '/export',
                                    'defaults'    => [
                                        'action' => 'export-theses-sans-pdc',
                                    ],
                                ],
                            ],
                        ],
                    ],
                    'theses-sans-depot' => [
                        'type'          => Segment::class,
                        'may_terminate' => true,
                        'options'       => [
                            'route'       => '/theses-sans-depot',
                            'defaults'    => [
                                'action' => 'theses-sans-depot',
                            ],
                        ],
                        'child_routes'  => [
                            'export' => [
                                'type'          => Segment::class,
                                'may_terminate' => true,
                                'options'       => [
                                    'route'       => '/export',
                                    'defaults'    => [
                                        'action' => 'export-theses-sans-depot',
                                    ],
                                ],
                            ],
                        ],
                    ],
                    'doctorants-sans-mail' => [
                        'type'          => Segment::class,
                        'may_terminate' => true,
+155
Changes for module/Indicateur/src/Indicateur/Controller/IndicateurController.php: 155 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ namespace Indicateur\Controller;

use Application\Entity\Db\Acteur;
use Application\Entity\Db\These;
use Application\Entity\Db\TypeValidation;
use Application\Service\AnomalieServiceAwareTrait;
use Application\Service\Etablissement\EtablissementServiceAwareTrait;
use Application\Service\Individu\IndividuServiceAwareTrait;
@@ -18,14 +19,23 @@ class IndicateurController extends AbstractActionController {
    use EtablissementServiceAwareTrait;
    use AnomalieServiceAwareTrait;

    /**
     * @return array|ViewModel
     * @throws \Exception
     */
    public function indexAction()
    {
        $acteursSansMail = $this->getIndividuService()->getActeurSansMail();
        $doctorantsSansMail = $this->getIndividuService()->getDoctorantSansMail();
        $theses = $this->getTheseService()->getTheseEnCoursPostSoutenance();
        $thesesAnciennes = $this->getTheseService()->getThesesAnciennes(6);
        $thesesASoutenir = $this->getTheseService()->getTheseASoutenir();
        $pasPDC = $this->getTheseService()->getTheseSansCouverture(2);
        $pasDepot = $this->getTheseService()->getTheseSansDepot(1);

        $anomalies = $this->getAnomalieService()->getAnomalies();


        $etablissements = [];
        $etablissements[] = $this->getEtablissementService()->getEtablissementById(2);
        $etablissements[] = $this->getEtablissementService()->getEtablissementById(3);
@@ -42,14 +52,110 @@ class IndicateurController extends AbstractActionController {
        return new ViewModel([
                "effectifs" => $effectifs,
                "theses" => $theses,
                "thesesASoutenir" => $thesesASoutenir,
                "anciennes" => $thesesAnciennes,
                "acteursSansMail" => $acteursSansMail,
                "doctorantsSansMail" => $doctorantsSansMail,
                "anomalies" => $anomalies,
                "pasPDC" => $pasPDC,
                "pasDepot" => $pasDepot,
            ]
        );
    }

    /**
     * faire remonter les thèses ayant en cours ayant une date de soutenance dépassée
     * @return ViewModel
     */
    public function thesesASoutenirAction()
    {
        $theses = $this->getTheseService()->getTheseASoutenir();
        return new ViewModel([
                'theses' => $theses,
            ]
        );
    }

    public function exportThesesASoutenirAction()
    {
        $data = $this->getTheseService()->getTheseASoutenir();
        $headers = [
            'Identitfiant'                    => function(These $these) {return $these->getId();},
            'SourceCode'                      => function(These $these) {return $these->getSourceCode();},
            'Titre'                           => function(These $these) {return $these->getTitre();},
            'Doctorant'                       => function(These $these) {return $these->getDoctorant()->getIndividu()->getNomComplet();},
            'État'                            => function(These $these) {return $these->getEtatThese();},
            'Date de soutenace'               => function(These $these) {return $these->getDateSoutenance()->format("d/m/Y");},
            'Établissement'                   => function(These $these) {return ($these->getEtablissement())?$these->getEtablissement()->getStructure()->getCode():"";},
            'École doctorale'                 => function(These $these) {return ($these->getEcoleDoctorale())?$these->getEcoleDoctorale()->getStructure()->getCode():"";},
            'Unité de recherche'              => function(These $these) {return ($these->getUniteRecherche())?$these->getUniteRecherche()->getStructure()->getCode():"";},

        ];

        $records = [];
        foreach ($data as $entry) {
            $record = [];
            foreach($headers as $key => $fct) {
                $record[] = $fct($entry);
            }
            $records[] = $record;
        }

        $CSV = new CsvModel();
        $CSV->setDelimiter(';');
        $CSV->setEnclosure('"');
        $CSV->setHeader(array_keys($headers));
        $CSV->setData($records);
        $CSV->setFilename('export_soutenanceDepassee.csv');

        return $CSV;
    }

    public function thesesSansPdcAction()
    {
        $theses = $this->getTheseService()->getTheseSansDepot(2);
        return new ViewModel([
                'theses' => $theses,
            ]
        );
    }

    public function exportThesesSansPdcAction()
    {
        $data = $this->getTheseService()->getTheseASoutenir();
        $headers = [
            'Identitfiant'                    => function(These $these) {return $these->getId();},
            'SourceCode'                      => function(These $these) {return $these->getSourceCode();},
            'Titre'                           => function(These $these) {return $these->getTitre();},
            'Doctorant'                       => function(These $these) {return $these->getDoctorant()->getIndividu()->getNomComplet();},
            'État'                            => function(These $these) {return $these->getEtatThese();},
            'Date de soutenace'               => function(These $these) {return $these->getDateSoutenance()->format("d/m/Y");},
            'Établissement'                   => function(These $these) {return ($these->getEtablissement())?$these->getEtablissement()->getStructure()->getCode():"";},
            'École doctorale'                 => function(These $these) {return ($these->getEcoleDoctorale())?$these->getEcoleDoctorale()->getStructure()->getCode():"";},
            'Unité de recherche'              => function(These $these) {return ($these->getUniteRecherche())?$these->getUniteRecherche()->getStructure()->getCode():"";},

        ];

        $records = [];
        foreach ($data as $entry) {
            $record = [];
            foreach($headers as $key => $fct) {
                $record[] = $fct($entry);
            }
            $records[] = $record;
        }

        $CSV = new CsvModel();
        $CSV->setDelimiter(';');
        $CSV->setEnclosure('"');
        $CSV->setHeader(array_keys($headers));
        $CSV->setData($records);
        $CSV->setFilename('export_pasPDC.csv');

        return $CSV;
    }


    /**
     * faire remonter les thèses ayant en cours ayant une date de soutenance dépassée
     * @return ViewModel
@@ -98,6 +204,55 @@ class IndicateurController extends AbstractActionController {
        return $CSV;
    }

    /**
     * faire remonter les thèses ayant en cours ayant une date de soutenance dépassée
     * @return ViewModel
     */
    public function thesesSansDepotAction()
    {
        $theses = $this->getTheseService()->getTheseSansDepot(1);
        return new ViewModel([
                'theses' => $theses,
            ]
        );
    }

    public function exportThesesSansDepotAction()
    {
        $data = $this->getTheseService()->getTheseSansDepot(1);
        $headers = [
            'Identitfiant'                    => function(These $these) {return $these->getId();},
            'SourceCode'                      => function(These $these) {return $these->getSourceCode();},
            'Titre'                           => function(These $these) {return $these->getTitre();},
            'Doctorant'                       => function(These $these) {return $these->getDoctorant()->getIndividu()->getNomComplet();},
            'État'                            => function(These $these) {return $these->getEtatThese();},
            'Date de soutenace'               => function(These $these) {return $these->getDateSoutenance()->format("d/m/Y");},
            'Établissement'                   => function(These $these) {return ($these->getEtablissement())?$these->getEtablissement()->getStructure()->getCode():"";},
            'École doctorale'                 => function(These $these) {return ($these->getEcoleDoctorale())?$these->getEcoleDoctorale()->getStructure()->getCode():"";},
            'Unité de recherche'              => function(These $these) {return ($these->getUniteRecherche())?$these->getUniteRecherche()->getStructure()->getCode():"";},

        ];

        $records = [];
        foreach ($data as $entry) {
            $record = [];
            foreach($headers as $key => $fct) {
                $record[] = $fct($entry);
            }
            $records[] = $record;
        }

        $CSV = new CsvModel();
        $CSV->setDelimiter(';');
        $CSV->setEnclosure('"');
        $CSV->setHeader(array_keys($headers));
        $CSV->setData($records);
        $CSV->setFilename('export_sansDepot.csv');

        return $CSV;
    }


    public function doctorantsSansMailAction()
    {
        $doctorantsSansMail = $this->getIndividuService()->getDoctorantSansMail();
+149 −17

File changed.

Preview size limit exceeded, changes collapsed.

Loading