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

in progress

parent c40e854b
Loading
Loading
Loading
Loading
+14 −153
Changes for module/Indicateur/config/module.config.php: 14 added lines, 153 removed lines.
Original line number Diff line number Diff line
@@ -8,6 +8,8 @@ use Indicateur\Controller\Factory\IndicateurControllerFactory;
use Indicateur\Controller\IndicateurController;
use Indicateur\Service\Factory\IndicateurServiceFactory;
use Indicateur\Service\IndicateurService;
use Indicateur\View\Helper\CompletIndicateurIndividuHelper;
use Indicateur\View\Helper\CompletIndicateurTheseHelper;
use Indicateur\View\Helper\ResumeIndicateurIndividuHelper;
use Indicateur\View\Helper\ResumeIndicateurTheseHelper;
use Zend\Mvc\Router\Http\Segment;
@@ -20,13 +22,7 @@ return array(
                    'controller' => IndicateurController::class,
                    'action'     => [
                        'index',
                        'soutenance-depassee',
                        'acteurs-sans-mail',
                        'doctorants-sans-mail',
                        'theses-anciennes',
                        'theses-a-soutenir',
                        'theses-sans-pdc',
                        'theses-sans-depot',
                        'view',
                    ],
                    'privileges' => [
                        IndicateurPrivileges::INDICATEUR_CONSULTATION,
@@ -36,13 +32,7 @@ return array(
                [
                    'controller' => IndicateurController::class,
                    'action'     => [
                        'export-soutenance-depassee',
                        'export-acteurs-sans-mail',
                        'export-doctorants-sans-mail',
                        'export-theses-anciennes',
                        'export-theses-a-soutenir',
                        'export-theses-sans-pdc',
                        'export-theses-sans-depot',
                        'export',
                    ],
                    'privileges' => [
                        IndicateurPrivileges::INDICATEUR_EXPORTATION,
@@ -106,157 +96,25 @@ return array(
                    ],
                ],
                'child_routes'  => [
                    'soutenance-depassee' => [
                    'view' => [
                        'type' => Segment::class,
                        'may_terminate' => true,
                        'options' => [
                            'route'       => '/soutenance-depassee',
                            'route'    => '/view/:indicateur',
                            'defaults' => [
                                'action' => 'soutenance-depassee',
                            ],
                        ],
                        'child_routes'  => [
                            'export' => [
                                'type'          => Segment::class,
                                'may_terminate' => true,
                                'options'       => [
                                    'route'       => '/export',
                                    'defaults'    => [
                                        'action' => 'export-soutenance-depassee',
                                    ],
                                ],
                            ],
                        ],
                    ],
                    'acteurs-sans-mail' => [
                        'type'          => Segment::class,
                        'may_terminate' => true,
                        'options'       => [
                            'route'       => '/acteurs-sans-mail',
                            'defaults'    => [
                                'action' => 'acteurs-sans-mail',
                            ],
                        ],
                        'child_routes'  => [
                            'export' => [
                                'type'          => Segment::class,
                                'may_terminate' => true,
                                'options'       => [
                                    'route'       => '/export',
                                    'defaults'    => [
                                        'action' => 'export-acteurs-sans-mail',
                                    ],
                                ],
                            ],
                        ],
                    ],
                    '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,
                        'options'       => [
                            'route'       => '/doctorants-sans-mail',
                            'defaults'    => [
                                'action' => 'doctorants-sans-mail',
                            ],
                        ],
                        'child_routes'  => [
                            'export' => [
                                'type'          => Segment::class,
                                'may_terminate' => true,
                                'options'       => [
                                    'route'       => '/export',
                                    'defaults'    => [
                                        'action' => 'export-doctorants-sans-mail',
                                    ],
                                ],
                            ],
                                'controller' => IndicateurController::class,
                                'action'     => 'view',
                            ],
                        ],
                    'theses-anciennes' => [
                        'type'          => Segment::class,
                        'may_terminate' => true,
                        'options'       => [
                            'route'       => '/theses-anciennes',
                            'defaults'    => [
                                'action' => 'theses-anciennes',
                    ],
                        ],
                        'child_routes'  => [
                    'export' => [
                        'type' => Segment::class,
                        'may_terminate' => true,
                        'options' => [
                                    'route'       => '/export',
                            'route'    => '/export/:indicateur',
                            'defaults' => [
                                        'action' => 'export-theses-anciennes',
                                    ],
                                ],
                                'controller' => IndicateurController::class,
                                'action'     => 'export',
                            ],
                        ],
                    ],
@@ -264,6 +122,7 @@ return array(
            ],
        ],
    ],

    'service_manager' => [
        'factories' => [
            IndicateurService::class => IndicateurServiceFactory::class,
@@ -277,6 +136,8 @@ return array(
    ],
    'view_helpers' => [
        'invokables' => [
            'completIndicateurThese'    => CompletIndicateurTheseHelper::class,
            'completIndicateurIndividu' => CompletIndicateurIndividuHelper::class,
            'resumeIndicateurThese'     => ResumeIndicateurTheseHelper::class,
            'resumeIndicateurIndividu'  => ResumeIndicateurIndividuHelper::class,
        ],
+41 −98
Changes for module/Indicateur/src/Indicateur/Controller/IndicateurController.php: 41 added lines, 98 removed lines.
Original line number Diff line number Diff line
@@ -8,6 +8,8 @@ use Application\Service\AnomalieServiceAwareTrait;
use Application\Service\Etablissement\EtablissementServiceAwareTrait;
use Application\Service\Individu\IndividuServiceAwareTrait;
use Application\Service\These\TheseServiceAwareTrait;
use DateTime;
use Indicateur\Model\Indicateur;
use Indicateur\Service\IndicateurServiceAwareTrait;
use UnicaenApp\View\Model\CsvModel;
use Zend\Mvc\Controller\AbstractActionController;
@@ -26,36 +28,14 @@ class IndicateurController extends AbstractActionController {
     */
    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()->getRepository()->find(2);
//        $etablissements[] = $this->getEtablissementService()->getRepository()->find(3);
//        $etablissements[] = $this->getEtablissementService()->getRepository()->find(4);
//        $etablissements[] = $this->getEtablissementService()->getRepository()->find(5);
//
//        $effectifs = [];
//        $effectifs["COMUE"] = $this->getTheseService()->getEffectifs();
//        foreach($etablissements as $etablissement) {
//            $result = $this->getTheseService()->getEffectifs($etablissement);
//            $effectifs[$etablissement->getStructure()->getCode()] = $result;
//        }

        $indicateurs = $this->getIndicateurService()->findAll();
        $result_ind0 = $this->getIndicateurService()->fetch(1);
        $result_ind1 = $this->getIndicateurService()->fetch(2);
        $result_ind2 = $this->getIndicateurService()->fetch(3);
        $result_ind3 = $this->getIndicateurService()->fetch(4);
        $result_ind4 = $this->getIndicateurService()->fetch(5);
        $result_ind5 = $this->getIndicateurService()->fetch(6);
        $result_ind6 = $this->getIndicateurService()->fetch(7);


        return new ViewModel([
@@ -65,113 +45,76 @@ class IndicateurController extends AbstractActionController {
                'result_ind2' => $result_ind2,
                'result_ind3' => $result_ind3,
                'result_ind4' => $result_ind4,
                'result_ind5' => $result_ind5,
                'result_ind6' => $result_ind6,


//                "effectifs" => $effectifs,

//                "thesesASoutenir" => $thesesASoutenir,
//                "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()
    public function viewAction()
    {
        $theses = $this->getTheseService()->getTheseASoutenir();
        $idIndicateur = $this->params()->fromRoute('indicateur');
        $indicateur = $this->getIndicateurService()->find($idIndicateur);
        $data = $this->getIndicateurService()->fetch($idIndicateur);

        return new ViewModel([
                'theses' => $theses,
            ]
        );
            'indicateur' => $indicateur,
            'data' => $data,
        ]);
    }

    public function exportThesesASoutenirAction()
    public function exportAction()
    {
        $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():"";},
        $idIndicateur = $this->params()->fromRoute('indicateur');
        $indicateur = $this->getIndicateurService()->find($idIndicateur);
        $data = $this->getIndicateurService()->fetch($idIndicateur);

        $headers = [];
        if ($indicateur->getDisplayAs() == Indicateur::THESE) {
            $headers = [
                'id'                    => 'ID',
                'Source Code'           => 'SOURCE_CODE',
                'Titre'                 => 'TITRE',
                'Première inscription'  => 'DATE_PREM_INSC',
                'Date de soutenance'    => 'DATE_SOUTENANCE',
            ];

        $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();
        if ($indicateur->getDisplayAs() == Indicateur::INDIVIDU) {
            $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():"";},

                'id'                    => 'ID',
                'Source Code'           => 'SOURCE_CODE',
                'Nom usuel'             => 'NOM_USUEL',
                'Nom Patronymique'      => 'NOM_PATRONYMIQUE',
                'Prénom 1'              => 'PRENOM1',
                'Prénom 2'              => 'PRENOM2',
                'Prénom 3'              => 'PRENOM3',
                'Email'                 => 'EMAIL',
            ];
        }


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

        $filename = (new DateTime('now'))->format("Ymd-His").'_'.str_replace(" ","-",$indicateur->getLibelle()).'.csv';

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

        return $CSV;
    }


    /**
     * faire remonter les thèses ayant en cours ayant une date de soutenance dépassée
     * @return ViewModel
+3
Changes for module/Indicateur/src/Indicateur/Model/Indicateur.php: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -4,6 +4,9 @@ namespace Indicateur\Model;

class Indicateur {

    const THESE = 'THESE';
    const INDIVIDU = 'INDIVIDU';

    /** @var int */
    private $id;
    /** @var string */
+49
Changes for module/Indicateur/src/Indicateur/View/Helper/CompletIndicateurIndividuHelper.php: 49 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

namespace Indicateur\View\Helper;

use Indicateur\Model\Indicateur;
use Zend\Form\View\Helper\AbstractHelper;

class CompletIndicateurIndividuHelper extends AbstractHelper
{
    /**
     * @param Indicateur $indicateur
     * @param array $data
     * @return string
     */
    public function render($indicateur, $data) {

        $rubriques = [
            'id'                    => 'ID',
            'Source Code'           => 'SOURCE_CODE',
            'Nom usuel'             => 'NOM_USUEL',
            'Nom Patronymique'      => 'NOM_PATRONYMIQUE',
            'Prénom 1'              => 'PRENOM1',
            'Prénom 2'              => 'PRENOM2',
            'Prénom 3'              => 'PRENOM3',
            'Email'                 => 'EMAIL',
        ];

        $html  = '';
        $html .= '<table class="table table-extra-condensed">';
        $html .= '<thead>';
        $html .= '<tr>';
        foreach ($rubriques as $clef => $valeur) {
            $html .= '<th> '.$clef.' </th>';
        }
        $html .= '</tr>';
        $html .= '</thead>';
        $html .= '<tbody>';
        foreach($data as $entry) {
            $html .= '<tr>';
            foreach ($rubriques as $clef => $valeur) {
                $html .= '<td>' . $entry[$valeur] . '</td>';
            }
            $html .= '</tr>';
        }
        $html .= '</tbody>';
        $html .= '</table>';
        return $html;
    }
}
 No newline at end of file
+46
Changes for module/Indicateur/src/Indicateur/View/Helper/CompletIndicateurTheseHelper.php: 46 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

namespace Indicateur\View\Helper;

use Indicateur\Model\Indicateur;
use Zend\Form\View\Helper\AbstractHelper;

class CompletIndicateurTheseHelper extends AbstractHelper
{
    /**
     * @param Indicateur $indicateur
     * @param array $data
     * @return string
     */
    public function render($indicateur, $data) {

        $rubriques = [
            'id'                    => 'ID',
            'Source Code'           => 'SOURCE_CODE',
            'Titre'                 => 'TITRE',
            'Première inscription'  => 'DATE_PREM_INSC',
            'Date de soutenance'    => 'DATE_SOUTENANCE',
        ];

        $html  = '';
        $html .= '<table class="table table-extra-condensed">';
            $html .= '<thead>';
            $html .= '<tr>';
            foreach ($rubriques as $clef => $valeur) {
                $html .= '<th> '.$clef.' </th>';
            }
            $html .= '</tr>';
            $html .= '</thead>';
            $html .= '<tbody>';
            foreach($data as $entry) {
                $html .= '<tr>';
                foreach ($rubriques as $clef => $valeur) {
                    $html .= '<td>' . $entry[$valeur] . '</td>';
                }
                $html .= '</tr>';
            }
            $html .= '</tbody>';
        $html .= '</table>';
        return $html;
    }
}
 No newline at end of file
Loading