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

Merge branch 'feature_structure_export_indicateur_these' into develop

parents 92171941 cbd304d5
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -680,6 +680,30 @@ class StructureService extends BaseService
        return $result;
    }

    /**
     * @param string $type
     * @param int $structureId
     * @return StructureConcreteInterface
     */
    public function getStructuresConcreteByTypeAndStructureConcreteId($type, $structureId)
    {
        $qb = $this->getEntityManager()->getRepository($this->getEntityByType($type))->createQueryBuilder('structureConcrete')
            ->addSelect('structure')
            ->join('structureConcrete.structure', 'structure')
            ->andWhere('structureConcrete.id = :structureId')
            ->setParameter('structureId', $structureId)
        ;

        try {
            $result = $qb->getQuery()->getOneOrNullResult();
        } catch (NonUniqueResultException $e) {
            throw new RuntimeException("Plusieurs ".$type." partagent le même identifiant de structure [".$structureId."]");
        }

        if (!$result) throw new RuntimeException("Aucun(e) ".$type." de trouvé(e).");
        return $result;
    }

    /**
     * Identifie les structures substituables en utilisant le sourceCode.
     *
+4 −0
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ namespace Indicateur\Controller\Factory;
use Application\Service\AnomalieService;
use Application\Service\Etablissement\EtablissementService;
use Application\Service\Individu\IndividuService;
use Application\Service\Structure\StructureService;
use Application\Service\These\TheseService;
use Indicateur\Controller\IndicateurController;
use Indicateur\Service\IndicateurService;
@@ -23,6 +24,7 @@ class IndicateurControllerFactory
         * @var TheseService $theseService
         * @var AnomalieService $anomalieService
         * @var EtablissementService $etablissementService
         * @var StructureService $structureService
         * @var IndicateurService $indicateurService
         */
        $individuService = $controllerManager->getServiceLocator()->get('IndividuService');
@@ -30,6 +32,7 @@ class IndicateurControllerFactory
        $anomalieService = $controllerManager->getServiceLocator()->get(AnomalieService::class);
        $etablissementService = $controllerManager->getServiceLocator()->get('EtablissementService');
        $indicateurService = $controllerManager->getServiceLocator()->get(IndicateurService::class);
        $structureService = $controllerManager->getServiceLocator()->get(StructureService::class);

        $controller = new IndicateurController();
        $controller->setIndividuService($individuService);
@@ -37,6 +40,7 @@ class IndicateurControllerFactory
        $controller->setAnomalieService($anomalieService);
        $controller->setEtablissementService($etablissementService);
        $controller->setIndicateurService($indicateurService);
        $controller->setStructureService($structureService);

        return $controller;
    }
+39 −1
Original line number Diff line number Diff line
@@ -3,10 +3,15 @@
namespace Indicateur\Controller;

use Application\Entity\Db\Acteur;
use Application\Entity\Db\EcoleDoctorale;
use Application\Entity\Db\Etablissement;
use Application\Entity\Db\These;
use Application\Entity\Db\TypeStructure;
use Application\Entity\Db\UniteRecherche;
use Application\Service\AnomalieServiceAwareTrait;
use Application\Service\Etablissement\EtablissementServiceAwareTrait;
use Application\Service\Individu\IndividuServiceAwareTrait;
use Application\Service\Structure\StructureServiceAwareTrait;
use Application\Service\These\TheseServiceAwareTrait;
use DateTime;
use Indicateur\Form\IndicateurForm;
@@ -24,6 +29,7 @@ class IndicateurController extends AbstractActionController {
    use EtablissementServiceAwareTrait;
    use AnomalieServiceAwareTrait;
    use IndicateurServiceAwareTrait;
    use StructureServiceAwareTrait;

    /**
     * @return array|ViewModel
@@ -146,6 +152,7 @@ class IndicateurController extends AbstractActionController {
        return new ViewModel([
            'indicateur' => $indicateur,
            'data' => $data,
            'structureService' => $this->getStructureService(),
        ]);
    }

@@ -163,6 +170,9 @@ class IndicateurController extends AbstractActionController {
                'Titre'                 => 'TITRE',
                'Première inscription'  => 'DATE_PREM_INSC',
                'Date de soutenance'    => 'DATE_SOUTENANCE',
                'Établissement d\'inscription'         => 'ETABLISSEMENT_ID',
                'École doctorale'       => 'ECOLE_DOCT_ID',
                'Unité de recherche'    => 'UNITE_RECH_ID',
            ];
        }
        if ($indicateur->getDisplayAs() == Indicateur::INDIVIDU) {
@@ -191,7 +201,35 @@ class IndicateurController extends AbstractActionController {
        foreach ($data as $entry) {
            $record = [];
            foreach($headers as $key => $fct) {
                $record[] = $entry[$fct];
                $value = '';
                switch($key) {
                    case 'Établissement d\'inscription' :
                        if ($entry[$fct]) {
                            /** @var Etablissement $etablissement */
                            $etablissement = $this->getStructureService()->getStructuresConcreteByTypeAndStructureConcreteId(TypeStructure::CODE_ETABLISSEMENT, $entry[$fct]);
                            $value = $etablissement->getLibelle();
                        } else $value .= "";
                        break;
                    case 'École doctorale' :
                        if ($entry[$fct]) {
                            /** @var EcoleDoctorale $ecole */
                            $ecole = $this->getStructureService()->getStructuresConcreteByTypeAndStructureConcreteId(TypeStructure::CODE_ECOLE_DOCTORALE, $entry[$fct]);
                            $value = $ecole->getLibelle();
                        } else $value .= "";
                        break;
                    case 'Unité de recherche' :
                        if ($entry[$fct]) {
                            /** @var UniteRecherche $unite */
                            $unite = $this->getStructureService()->getStructuresConcreteByTypeAndStructureConcreteId(TypeStructure::CODE_UNITE_RECHERCHE, $entry[$fct]);
                            $value = $unite->getLibelle();
                        } else $value .= "";
                        break;
                    default:
                        $value = $entry[$fct];
                        break;
                }

                $record[] = $value;
            }
            $records[] = $record;
        }
+44 −3
Original line number Diff line number Diff line
@@ -2,6 +2,11 @@

namespace Indicateur\View\Helper;

use Application\Entity\Db\EcoleDoctorale;
use Application\Entity\Db\Etablissement;
use Application\Entity\Db\TypeStructure;
use Application\Entity\Db\UniteRecherche;
use Application\Service\Structure\StructureService;
use Indicateur\Model\Indicateur;
use Zend\Form\View\Helper\AbstractHelper;

@@ -10,9 +15,10 @@ class CompletIndicateurTheseHelper extends AbstractHelper
    /**
     * @param Indicateur $indicateur
     * @param array $data
     * @param StructureService $structureService
     * @return string
     */
    public function render($indicateur, $data) {
    public function render($indicateur, $data, $structureService) {

        $rubriques = [
            'id'                    => 'ID',
@@ -20,6 +26,9 @@ class CompletIndicateurTheseHelper extends AbstractHelper
            'Titre'                 => 'TITRE',
            'Première inscription'  => 'DATE_PREM_INSC',
            'Date de soutenance'    => 'DATE_SOUTENANCE',
            'Établissement d\'inscription'         => 'ETABLISSEMENT_ID',
            'École doctorale'       => 'ECOLE_DOCT_ID',
            'Unité de recherche'       => 'UNITE_RECH_ID',
        ];

        $html  = '';
@@ -36,9 +45,41 @@ class CompletIndicateurTheseHelper extends AbstractHelper
                $html .= '<tr>';
                foreach ($rubriques as $clef => $valeur) {
                    $html .= '<td>';
                    if ($clef === 'Titre') $html .= '<a href="'.$this->getView()->url('these/identite', ['these' => $entry['ID']], [], true).'">';
                    switch($clef) {
                        case 'Titre':
                            $html .= '<a href="' . $this->getView()->url('these/identite', ['these' => $entry['ID']], [], true) . '">';
                            $html .= $entry[$valeur];
                    if ($clef === 'Titre') $html .= '</a>';
                            $html .= '</a>';
                            break;
                        case 'Établissement d\'inscription':
                            if ($entry[$valeur]) {
                                /** @var Etablissement $etablissement */
                                $etablissement = $structureService->getStructuresConcreteByTypeAndStructureConcreteId(TypeStructure::CODE_ETABLISSEMENT, $entry[$valeur]);
                                $html .= '<abbr title="' . $etablissement->getLibelle() . '">' . $etablissement->getSigle() . '</abbr>';
                            } else $html .= "---";
                            break;
                        case 'École doctorale':
                            if ($entry[$valeur]) {
                                /** @var EcoleDoctorale $ecole */
                                $ecole = $structureService->getStructuresConcreteByTypeAndStructureConcreteId(TypeStructure::CODE_ECOLE_DOCTORALE, $entry[$valeur]);
                                $html .= '<abbr title="' . $ecole->getLibelle() . '">' . $ecole->getSigle() . '</abbr>';
                            } else {
                                $html .= "---";
                            }
                            break;
                        case 'Unité de recherche':
                            if ($entry[$valeur]) {
                                /** @var UniteRecherche $unite */
                                $unite = $structureService->getStructuresConcreteByTypeAndStructureConcreteId(TypeStructure::CODE_UNITE_RECHERCHE, $entry[$valeur]);
                                $html .= '<abbr title="' . $unite->getLibelle() . '">' . $unite->getSigle() . '</abbr>';
                            } else {
                                $html .= "---";
                            }
                            break;
                        default:
                            $html .= $entry[$valeur];
                            break;
                    }
                    $html .= '</td>';
                }
                $html .= '</tr>';
+4 −1
Original line number Diff line number Diff line
@@ -6,6 +6,9 @@ use Indicateur\Provider\Privilege\IndicateurPrivileges;
/**
 * @var Indicateur $indicateur
 * @var array $data
 * @var \Application\Service\Structure\StructureService $structureService
 *
 * @see \Indicateur\Controller\IndicateurController::viewAction()
 */

?>
@@ -33,7 +36,7 @@ use Indicateur\Provider\Privilege\IndicateurPrivileges;
</p>

<?php if ($indicateur->getDisplayAs() === Indicateur::THESE): ?>
    <?php echo $this->completIndicateurThese()->render($indicateur, $data); ?>
    <?php echo $this->completIndicateurThese()->render($indicateur, $data, $structureService); ?>
<?php endif; ?>

<?php if ($indicateur->getDisplayAs() === Indicateur::INDIVIDU): ?>