Loading module/Application/config/others/co-encadrant.config.php +11 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ return [ 'historique', 'rechercher-co-encadrant', 'generer-justificatif-coencadrements', 'generer-export-csv', ], 'privileges' => [ CoEncadrantPrivileges::COENCADRANT_AFFICHER, Loading Loading @@ -76,6 +77,16 @@ return [ ], ], ], 'generer-export-csv' => [ 'type' => Segment::class, 'options' => [ 'route' => '/generer-export-csv/:structure-type/:structure-id', 'defaults' => [ 'controller' => CoEncadrantController::class, 'action' => 'generer-export-csv', ], ], ], 'rechercher-co-encadrant' => [ 'type' => Literal::class, 'options' => [ Loading module/Application/src/Application/Controller/CoEncadrantController.php +44 −0 Original line number Diff line number Diff line Loading @@ -3,15 +3,21 @@ namespace Application\Controller; use Application\Entity\Db\Acteur; use Application\Entity\Db\EcoleDoctorale; use Application\Entity\Db\Individu; use Application\Entity\Db\These; use Application\Entity\Db\UniteRecherche; use Application\Form\RechercherCoEncadrantFormAwareTrait; use Application\Service\Acteur\ActeurServiceAwareTrait; use Application\Service\CoEncadrant\CoEncadrantServiceAwareTrait; use Application\Service\CoEncadrant\Exporter\JustificatifCoencadrements\JustificatifCoencadrementPdfExporter; use Application\Service\EcoleDoctorale\EcoleDoctoraleServiceAwareTrait; use Application\Service\File\FileServiceAwareTrait; use Application\Service\Individu\IndividuServiceAwareTrait; use Application\Service\These\TheseServiceAwareTrait; use Application\Service\UniteRecherche\UniteRechercheServiceAwareTrait; use DateTime; use UnicaenApp\View\Model\CsvModel; use Zend\Mvc\Controller\AbstractActionController; use Zend\View\Model\JsonModel; use Zend\View\Model\ViewModel; Loading @@ -24,6 +30,9 @@ class CoEncadrantController extends AbstractActionController { use FileServiceAwareTrait; use TheseServiceAwareTrait; use RechercherCoEncadrantFormAwareTrait; use EcoleDoctoraleServiceAwareTrait; use UniteRechercheServiceAwareTrait; /** @var PhpRenderer */ private $renderer; Loading Loading @@ -160,4 +169,39 @@ class CoEncadrantController extends AbstractActionController { ]); $export->export('justificatif_coencadrement_' . $coencadrant->getIndividu()->getId() . ".pdf"); } public function genererExportCsvAction() { $structureType = $this->params()->fromRoute('structure-type'); $structureId = $this->params()->fromRoute('structure-id'); /** @var EcoleDoctorale|UniteRecherche $structure */ $structure = null; if ($structureType === 'ecole-doctorale') $structure = $this->getEcoleDoctoraleService()->getRepository()->find($structureId); if ($structureType === 'unite-recherche') $structure = $this->getUniteRechercheService()->getRepository()->find($structureId); $listing = $this->getCoEncadrantService()->getCoEncadrantsByStructureConcrete($structure); //export $headers = ['Co-endrants', 'Nombre d\'encadrements actuels', 'Listing']; $records = []; foreach ($listing as $item) { $entry = []; $entry['Co-endrants'] = $item['co-encadrant']->getIndividu()->getPrenom1() . " " . $item['co-encadrant']->getIndividu()->getNomUsuel(); $entry['Nombre d\'encadrements actuels'] = count($item['theses']); $entry['Listing'] = implode(';', array_map(function(These $t) {return $t->getDoctorant()->getIndividu()->getPrenom1() . " " . $t->getDoctorant()->getIndividu()->getNomUsuel();}, $item['theses']) ); $records[] = $entry; } $filename = (new DateTime())->format('Ymd-His') . '_coencadrants-' . $structure->getSigle() . 'csv'; $CSV = new CsvModel(); $CSV->setDelimiter(';'); $CSV->setEnclosure('"'); $CSV->setHeader($headers); $CSV->setData($records); $CSV->setFilename($filename); return $CSV; } } No newline at end of file module/Application/src/Application/Controller/EcoleDoctoraleController.php +1 −1 Original line number Diff line number Diff line Loading @@ -48,7 +48,7 @@ class EcoleDoctoraleController extends StructureConcreteController { $id = $this->params()->fromRoute('structure'); $structureConcrete = $this->getStructureConcreteService()->getRepository()->findByStructureId($id); $coencadrants = $this->getCoEncadrantService()->getCoEncadrantsByEcodeDoctorale($structureConcrete); $coencadrants = $this->getCoEncadrantService()->getCoEncadrantsByStructureConcrete($structureConcrete); $viewModel = parent::informationAction(); Loading module/Application/src/Application/Controller/Factory/CoEncadrantControllerFactory.php +8 −0 Original line number Diff line number Diff line Loading @@ -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\EcoleDoctorale\EcoleDoctoraleService; use Application\Service\File\FileService; use Application\Service\Individu\IndividuService; use Application\Service\These\TheseService; use Application\Service\UniteRecherche\UniteRechercheService; use Interop\Container\ContainerInterface; use Zend\View\Renderer\PhpRenderer; Loading @@ -23,15 +25,19 @@ class CoEncadrantControllerFactory { /** * @var ActeurService $acteurService * @var CoEncadrantService $coEncadrantService * @var EcoleDoctoraleService $ecoleDoctoraleService * @var IndividuService $individuService * @var FileService $fileService * @var TheseService $theseService * @var UniteRechercheService $uniteRechercheService */ $acteurService = $container->get(ActeurService::class); $coEncadrantService = $container->get(CoEncadrantService::class); $ecoleDoctoraleService = $container->get(EcoleDoctoraleService::class); $individuService = $container->get('IndividuService'); $fileService = $container->get(FileService::class); $theseService = $container->get('TheseService'); $uniteRechercheService = $container->get(UniteRechercheService::class); /** * @var RechercherCoEncadrantForm $rechercheCoEncadrantForm Loading @@ -44,9 +50,11 @@ class CoEncadrantControllerFactory { $controller = new CoEncadrantController(); $controller->setActeurService($acteurService); $controller->setCoEncadrantService($coEncadrantService); $controller->setEcoleDoctoraleService($ecoleDoctoraleService); $controller->setIndividuService($individuService); $controller->setFileService($fileService); $controller->setTheseService($theseService); $controller->setUniteRechercheService($uniteRechercheService); $controller->setRechercherCoEncadrantForm($rechercheCoEncadrantForm); $controller->setRenderer($renderer); return $controller; Loading module/Application/src/Application/Service/CoEncadrant/CoEncadrantService.php +17 −33 Original line number Diff line number Diff line Loading @@ -73,49 +73,33 @@ class CoEncadrantService { } /** * @param EcoleDoctorale $ecole * @param boolean $encours * @return Acteur[] * @param EcoleDoctorale|UniteRecherche $structure * @param bool $encours * @return array */ public function getCoEncadrantsByEcodeDoctorale(EcoleDoctorale $ecole, $encours = true) public function getCoEncadrantsByStructureConcrete($structure, $encours = true) { $qb = $this->createQueryBuilder() ->addSelect('these')->join('acteur.these', 'these') ->andWhere('these.ecoleDoctorale = :ecole') ->setParameter('ecole', $ecole) ->andWhere('1 = pasHistorise(these)') ->andWhere('1 = pasHistorise(acteur)') ; if ($encours) { $qb = $qb->andWhere('these.etatThese = :encours') ->setParameter('encours', These::ETAT_EN_COURS) ; } $result = $qb->getQuery()->getResult(); //todo integer dans la requete $grouped = []; foreach ($result as $acteur) { $grouped[$acteur->getIndividu()->getId()]['co-encadrant'] = $acteur; $grouped[$acteur->getIndividu()->getId()]['count']++; $structureOk = false; if ($structure instanceof EcoleDoctorale) { $qb = $qb->andWhere('these.ecoleDoctorale = :structure'); $structureOk = true; } return $grouped; if ($structure instanceof UniteRecherche) { $qb = $qb->andWhere('these.uniteRecherche = :structure'); $structureOk = true; } /** * @param UniteRecherche $unite * @param boolean $encours * @return Acteur[] */ public function getCoEncadrantsByUniteRecherche(UniteRecherche $unite, $encours = true) { $qb = $this->createQueryBuilder() ->addSelect('these')->join('acteur.these', 'these') ->andWhere('these.uniteRecherche = :unite') ->setParameter('unite', $unite) ->andWhere('1 = pasHistorise(these)') ->andWhere('1 = pasHistorise(acteur)') ; if ($structureOk === false OR $structure === null) { throw new RuntimeException('Pas de structure concrete de trouvée'); } $qb = $qb->setParameter('structure', $structure); if ($encours) { $qb = $qb->andWhere('these.etatThese = :encours') ->setParameter('encours', These::ETAT_EN_COURS) Loading @@ -127,7 +111,7 @@ class CoEncadrantService { $grouped = []; foreach ($result as $acteur) { $grouped[$acteur->getIndividu()->getId()]['co-encadrant'] = $acteur; $grouped[$acteur->getIndividu()->getId()]['count']++; $grouped[$acteur->getIndividu()->getId()]['theses'][] = $acteur->getThese(); } return $grouped; } Loading Loading
module/Application/config/others/co-encadrant.config.php +11 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ return [ 'historique', 'rechercher-co-encadrant', 'generer-justificatif-coencadrements', 'generer-export-csv', ], 'privileges' => [ CoEncadrantPrivileges::COENCADRANT_AFFICHER, Loading Loading @@ -76,6 +77,16 @@ return [ ], ], ], 'generer-export-csv' => [ 'type' => Segment::class, 'options' => [ 'route' => '/generer-export-csv/:structure-type/:structure-id', 'defaults' => [ 'controller' => CoEncadrantController::class, 'action' => 'generer-export-csv', ], ], ], 'rechercher-co-encadrant' => [ 'type' => Literal::class, 'options' => [ Loading
module/Application/src/Application/Controller/CoEncadrantController.php +44 −0 Original line number Diff line number Diff line Loading @@ -3,15 +3,21 @@ namespace Application\Controller; use Application\Entity\Db\Acteur; use Application\Entity\Db\EcoleDoctorale; use Application\Entity\Db\Individu; use Application\Entity\Db\These; use Application\Entity\Db\UniteRecherche; use Application\Form\RechercherCoEncadrantFormAwareTrait; use Application\Service\Acteur\ActeurServiceAwareTrait; use Application\Service\CoEncadrant\CoEncadrantServiceAwareTrait; use Application\Service\CoEncadrant\Exporter\JustificatifCoencadrements\JustificatifCoencadrementPdfExporter; use Application\Service\EcoleDoctorale\EcoleDoctoraleServiceAwareTrait; use Application\Service\File\FileServiceAwareTrait; use Application\Service\Individu\IndividuServiceAwareTrait; use Application\Service\These\TheseServiceAwareTrait; use Application\Service\UniteRecherche\UniteRechercheServiceAwareTrait; use DateTime; use UnicaenApp\View\Model\CsvModel; use Zend\Mvc\Controller\AbstractActionController; use Zend\View\Model\JsonModel; use Zend\View\Model\ViewModel; Loading @@ -24,6 +30,9 @@ class CoEncadrantController extends AbstractActionController { use FileServiceAwareTrait; use TheseServiceAwareTrait; use RechercherCoEncadrantFormAwareTrait; use EcoleDoctoraleServiceAwareTrait; use UniteRechercheServiceAwareTrait; /** @var PhpRenderer */ private $renderer; Loading Loading @@ -160,4 +169,39 @@ class CoEncadrantController extends AbstractActionController { ]); $export->export('justificatif_coencadrement_' . $coencadrant->getIndividu()->getId() . ".pdf"); } public function genererExportCsvAction() { $structureType = $this->params()->fromRoute('structure-type'); $structureId = $this->params()->fromRoute('structure-id'); /** @var EcoleDoctorale|UniteRecherche $structure */ $structure = null; if ($structureType === 'ecole-doctorale') $structure = $this->getEcoleDoctoraleService()->getRepository()->find($structureId); if ($structureType === 'unite-recherche') $structure = $this->getUniteRechercheService()->getRepository()->find($structureId); $listing = $this->getCoEncadrantService()->getCoEncadrantsByStructureConcrete($structure); //export $headers = ['Co-endrants', 'Nombre d\'encadrements actuels', 'Listing']; $records = []; foreach ($listing as $item) { $entry = []; $entry['Co-endrants'] = $item['co-encadrant']->getIndividu()->getPrenom1() . " " . $item['co-encadrant']->getIndividu()->getNomUsuel(); $entry['Nombre d\'encadrements actuels'] = count($item['theses']); $entry['Listing'] = implode(';', array_map(function(These $t) {return $t->getDoctorant()->getIndividu()->getPrenom1() . " " . $t->getDoctorant()->getIndividu()->getNomUsuel();}, $item['theses']) ); $records[] = $entry; } $filename = (new DateTime())->format('Ymd-His') . '_coencadrants-' . $structure->getSigle() . 'csv'; $CSV = new CsvModel(); $CSV->setDelimiter(';'); $CSV->setEnclosure('"'); $CSV->setHeader($headers); $CSV->setData($records); $CSV->setFilename($filename); return $CSV; } } No newline at end of file
module/Application/src/Application/Controller/EcoleDoctoraleController.php +1 −1 Original line number Diff line number Diff line Loading @@ -48,7 +48,7 @@ class EcoleDoctoraleController extends StructureConcreteController { $id = $this->params()->fromRoute('structure'); $structureConcrete = $this->getStructureConcreteService()->getRepository()->findByStructureId($id); $coencadrants = $this->getCoEncadrantService()->getCoEncadrantsByEcodeDoctorale($structureConcrete); $coencadrants = $this->getCoEncadrantService()->getCoEncadrantsByStructureConcrete($structureConcrete); $viewModel = parent::informationAction(); Loading
module/Application/src/Application/Controller/Factory/CoEncadrantControllerFactory.php +8 −0 Original line number Diff line number Diff line Loading @@ -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\EcoleDoctorale\EcoleDoctoraleService; use Application\Service\File\FileService; use Application\Service\Individu\IndividuService; use Application\Service\These\TheseService; use Application\Service\UniteRecherche\UniteRechercheService; use Interop\Container\ContainerInterface; use Zend\View\Renderer\PhpRenderer; Loading @@ -23,15 +25,19 @@ class CoEncadrantControllerFactory { /** * @var ActeurService $acteurService * @var CoEncadrantService $coEncadrantService * @var EcoleDoctoraleService $ecoleDoctoraleService * @var IndividuService $individuService * @var FileService $fileService * @var TheseService $theseService * @var UniteRechercheService $uniteRechercheService */ $acteurService = $container->get(ActeurService::class); $coEncadrantService = $container->get(CoEncadrantService::class); $ecoleDoctoraleService = $container->get(EcoleDoctoraleService::class); $individuService = $container->get('IndividuService'); $fileService = $container->get(FileService::class); $theseService = $container->get('TheseService'); $uniteRechercheService = $container->get(UniteRechercheService::class); /** * @var RechercherCoEncadrantForm $rechercheCoEncadrantForm Loading @@ -44,9 +50,11 @@ class CoEncadrantControllerFactory { $controller = new CoEncadrantController(); $controller->setActeurService($acteurService); $controller->setCoEncadrantService($coEncadrantService); $controller->setEcoleDoctoraleService($ecoleDoctoraleService); $controller->setIndividuService($individuService); $controller->setFileService($fileService); $controller->setTheseService($theseService); $controller->setUniteRechercheService($uniteRechercheService); $controller->setRechercherCoEncadrantForm($rechercheCoEncadrantForm); $controller->setRenderer($renderer); return $controller; Loading
module/Application/src/Application/Service/CoEncadrant/CoEncadrantService.php +17 −33 Original line number Diff line number Diff line Loading @@ -73,49 +73,33 @@ class CoEncadrantService { } /** * @param EcoleDoctorale $ecole * @param boolean $encours * @return Acteur[] * @param EcoleDoctorale|UniteRecherche $structure * @param bool $encours * @return array */ public function getCoEncadrantsByEcodeDoctorale(EcoleDoctorale $ecole, $encours = true) public function getCoEncadrantsByStructureConcrete($structure, $encours = true) { $qb = $this->createQueryBuilder() ->addSelect('these')->join('acteur.these', 'these') ->andWhere('these.ecoleDoctorale = :ecole') ->setParameter('ecole', $ecole) ->andWhere('1 = pasHistorise(these)') ->andWhere('1 = pasHistorise(acteur)') ; if ($encours) { $qb = $qb->andWhere('these.etatThese = :encours') ->setParameter('encours', These::ETAT_EN_COURS) ; } $result = $qb->getQuery()->getResult(); //todo integer dans la requete $grouped = []; foreach ($result as $acteur) { $grouped[$acteur->getIndividu()->getId()]['co-encadrant'] = $acteur; $grouped[$acteur->getIndividu()->getId()]['count']++; $structureOk = false; if ($structure instanceof EcoleDoctorale) { $qb = $qb->andWhere('these.ecoleDoctorale = :structure'); $structureOk = true; } return $grouped; if ($structure instanceof UniteRecherche) { $qb = $qb->andWhere('these.uniteRecherche = :structure'); $structureOk = true; } /** * @param UniteRecherche $unite * @param boolean $encours * @return Acteur[] */ public function getCoEncadrantsByUniteRecherche(UniteRecherche $unite, $encours = true) { $qb = $this->createQueryBuilder() ->addSelect('these')->join('acteur.these', 'these') ->andWhere('these.uniteRecherche = :unite') ->setParameter('unite', $unite) ->andWhere('1 = pasHistorise(these)') ->andWhere('1 = pasHistorise(acteur)') ; if ($structureOk === false OR $structure === null) { throw new RuntimeException('Pas de structure concrete de trouvée'); } $qb = $qb->setParameter('structure', $structure); if ($encours) { $qb = $qb->andWhere('these.etatThese = :encours') ->setParameter('encours', These::ETAT_EN_COURS) Loading @@ -127,7 +111,7 @@ class CoEncadrantService { $grouped = []; foreach ($result as $acteur) { $grouped[$acteur->getIndividu()->getId()]['co-encadrant'] = $acteur; $grouped[$acteur->getIndividu()->getId()]['count']++; $grouped[$acteur->getIndividu()->getId()]['theses'][] = $acteur->getThese(); } return $grouped; } Loading