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

Ajout des export csv

parent 92e6c90b
Loading
Loading
Loading
Loading
+26
Changes for module/Indicateur/config/module.config.php: 26 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -13,7 +13,9 @@ return array(
                    'action'     => [
                        'index',
                        'soutenance-depassee',
                        'export-soutenance-depassee',
                        'acteurs-sans-mail',
                        'export-acteurs-sans-mail',
                ],
                    'roles' => [
                        'Administrateur technique',
@@ -46,6 +48,18 @@ return array(
                                '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,
@@ -56,6 +70,18 @@ return array(
                                'action' => 'acteurs-sans-mail',
                            ],
                        ],
                        'child_routes'  => [
                            'export' => [
                                'type'          => Segment::class,
                                'may_terminate' => true,
                                'options'       => [
                                    'route'       => '/export',
                                    'defaults'    => [
                                        'action' => 'export-acteurs-sans-mail',
                                    ],
                                ],
                            ],
                        ],
                    ],
                ],
            ],
+73
Changes for module/Indicateur/src/Indicateur/Controller/IndicateurController.php: 73 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -2,10 +2,13 @@

namespace Indicateur\Controller;

use Application\Entity\Db\Acteur;
use Application\Entity\Db\These;
use Application\Service\AnomalieServiceAwareTrait;
use Application\Service\Etablissement\EtablissementServiceAwareTrait;
use Application\Service\Individu\IndividuServiceAwareTrait;
use Application\Service\These\TheseServiceAwareTrait;
use UnicaenApp\View\Model\CsvModel;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

@@ -56,6 +59,41 @@ class IndicateurController extends AbstractActionController {
        );
    }

    public function exportSoutenanceDepasseeAction()
    {
        $data = $this->getTheseService()->getTheseEnCoursPostSoutenance();
        $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 acteursSansMailAction()
    {
        $acteursSansMail = $this->getIndividuService()->getActeurSansMail();
@@ -65,5 +103,40 @@ class IndicateurController extends AbstractActionController {
            ]
        );
    }

    public function exportActeursSansMailAction()
    {
        $acteursSansMail = $this->getIndividuService()->getActeurSansMail();

        $headers = [
            'Thèse Identitfiant'                    => function(Acteur $acteur) {return $acteur->getThese()->getId();},
            'Thèse SourceCode'                      => function(Acteur $acteur) {return $acteur->getThese()->getSourceCode();},
            'Thèse Titre'                           => function(Acteur $acteur) {return $acteur->getThese()->getTitre();},
            'Thèse Établissement'                   => function(Acteur $acteur) {return ($acteur->getThese()->getEtablissement())?$acteur->getThese()->getEtablissement()->getStructure()->getCode():"";},
            'Thèse École doctorale'                 => function(Acteur $acteur) {return ($acteur->getThese()->getEcoleDoctorale())?$acteur->getThese()->getEcoleDoctorale()->getStructure()->getCode():"";},
            'Thèse Unité de recherche'              => function(Acteur $acteur) {return ($acteur->getThese()->getUniteRecherche())?$acteur->getThese()->getUniteRecherche()->getStructure()->getCode():"";},
            'Acteur Identifiant'                    => function(Acteur $acteur) {return $acteur->getId();},
            'Acteur Nom'                            => function(Acteur $acteur) {return $acteur->getIndividu()->getNomComplet();},
            'Acteur Role'                           => function(Acteur $acteur) {return $acteur->getRole()->getLibelle();},
        ];

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

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

        return $CSV;
    }
}
+11 −3
Changes for module/Indicateur/view/indicateur/indicateur/acteurs-sans-mail.phtml: 11 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -12,11 +12,15 @@ use Application\Entity\Db\Acteur;
    <span class="badge"> <?php echo count($sansMail); ?> </span>
</h1>

<a class="btn btn-success" href="<?php echo $this->url('indicateur/acteurs-sans-mail/export',[],[], true); ?>">
    <span class="glyphicon glyphicon-download-alt"></span> Exporter au format CSV
</a>

<table class="table table-extra-condensed">
    <thead>
    <tr>
        <th> These SourceCode </th>
        <th> These Titre </th>
        <th> These</th>
        <th> Titre </th>
        <th> Acteur </th>
        <th> Rôle </th>
        <th> État</th>
@@ -29,7 +33,11 @@ use Application\Entity\Db\Acteur;
    <?php foreach ($sansMail as $acteur) : ?>
        <?php $these = $acteur->getThese(); ?>
        <tr>
            <td> <?php echo $these->getSourceCode(); ?>  </td>
            <td>
                <a href="<?php echo $this->url('these/identite', ['these'=>$these->getId()], [], true); ?>">
                    <?php echo $these->getSourceCode(); ?>
                </a>
            </td>
            <td> <?php echo $these->getTitre(); ?>  </td>
            <td> <?php echo $acteur->getIndividu()->getNomComplet(); ?>  </td>
            <td> <?php echo $acteur->getRole()->getLibelle(); ?>  </td>
+1 −1
Changes for module/Indicateur/view/indicateur/indicateur/index.phtml: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -177,7 +177,7 @@ use Application\Entity\Db\These;
                    </tbody>
                </table>
                <div class="pull-right">
                    <a class="btn btn-success" href="">
                    <a class="btn btn-success" href="<?php echo $this->url('tableau-de-bord/anomalie', [], [], true);?>">
                        <span class="glyphicon glyphicon-eye-open"></span> Visualiser les données
                    </a>
                </div>
+9 −1
Changes for module/Indicateur/view/indicateur/indicateur/soutenance-depassee.phtml: 9 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -12,6 +12,10 @@ use Application\Entity\Db\These;
    <span class="badge"> <?php echo count($theses); ?> </span>
</h1>

<a class="btn btn-success" href="<?php echo $this->url('indicateur/soutenance-depassee/export',[],[], true); ?>">
    <span class="glyphicon glyphicon-download-alt"></span> Exporter au format CSV
</a>

<table class="table table-extra-condensed">
    <thead>
        <tr>
@@ -28,7 +32,11 @@ use Application\Entity\Db\These;
    <tbody>
    <?php foreach ($theses as $these) : ?>
    <tr>
        <td> <?php echo $these->getSourceCode(); ?>  </td>
        <td>
            <a href="<?php echo $this->url('these/identite', ['these'=>$these->getId()], [], true); ?>">
                <?php echo $these->getSourceCode(); ?>
            </a>
        </td>
        <td> <?php echo $these->getTitre(); ?>  </td>
        <td> <?php echo $these->getDoctorant()->getIndividu()->getNomComplet(); ?>  </td>
        <td> <?php echo $these->getEtatThese(); ?>  </td>