Commit dc15887e authored by root's avatar root
Browse files

Merge branch 'master' of https://git.unicaen.fr/dsi/preecog

parents 83997b94 27e0dc66
Loading
Loading
Loading
Loading
+3
Changes for module/Structure/src/Structure/Controller/StructureController.php: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ use Structure\Form\AjouterResponsable\AjouterResponsableFormAwareTrait;
use Structure\Service\Structure\StructureServiceAwareTrait;
use Structure\Service\StructureAgentForce\StructureAgentForceServiceAwareTrait;
use UnicaenApp\Exception\RuntimeException;
use UnicaenApp\Form\Element\Date;
use UnicaenApp\View\Model\CsvModel;
use UnicaenPdf\Exporter\PdfExporter;
use UnicaenUtilisateur\Service\User\UserServiceAwareTrait;
@@ -123,6 +124,8 @@ class StructureController extends AbstractActionController {
            'selecteur' => $selecteur,

            'structure' => $structure,
            'responsables' => $this->getStructureService()->getResponsables($structure, new DateTime()),
            'gestionnaires' => $this->getStructureService()->getGestionnaires($structure, new DateTime()),
            'filles' =>   $structure->getEnfants(),

            'missions' => $missionsSpecifiques,
+40
Changes for module/Structure/src/Structure/Service/Structure/StructureService.php: 40 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -532,4 +532,44 @@ EOS;
        }
        return $listing;
    }

    //TODO RESPONSABLE_SERVICE ???

    /**
     * @param Structure|null $structure
     * @param DateTime|null $date
     * @return StructureResponsable[]
     */
    public function getResponsables(?Structure $structure, ?DateTime $date = null) : array
    {
        $qb = $this->getEntityManager()->getRepository(StructureResponsable::class)->createQueryBuilder('responsable')
            ->join('responsable.agent', 'agent')->addSelect('agent')
            ->andWhere('responsable.structure = :structure')
            ->setParameter('structure', $structure)
            ->orderBy('agent.nomUsuel, agent.prenom')
        ;
        if ($date !== null) $qb = StructureResponsable::decorateWithActif($qb, 'responsable', $date);

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

    /**
     * @param Structure|null $structure
     * @param DateTime|null $date
     * @return StructureGestionnaire[]
     */
    public function getGestionnaires(?Structure $structure, ?DateTime $date = null) : array
    {
        $qb = $this->getEntityManager()->getRepository(StructureGestionnaire::class)->createQueryBuilder('gestionnaire')
            ->join('gestionnaire.agent', 'agent')->addSelect('agent')
            ->andWhere('gestionnaire.structure = :structure')
            ->setParameter('structure', $structure)
            ->orderBy('agent.nomUsuel, agent.prenom')
        ;
        if ($date !== null) $qb = StructureGestionnaire::decorateWithActif($qb, 'gestionnaire', $date);

        $result = $qb->getQuery()->getResult();
        return $result;
    }
}
+5 −1
Changes for module/Structure/view/structure/structure/afficher.phtml: 5 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -4,6 +4,8 @@
 * @see StructureController::afficherAction()
 * @var Structure[] $selecteur
 * @var Structure $structure
 * @var StructureResponsable[] $responsables
 * @var StructureGestionnaire[] $gestionnaires
 * @var Structure[] $filles
 * @var AgentMissionSpecifique[] $missions
 * @var FichePoste[] $fiches
@@ -30,6 +32,8 @@ use EntretienProfessionnel\Entity\Db\Campagne;
use EntretienProfessionnel\Entity\Db\Delegue;
use Formation\Entity\Db\FormationInstanceInscrit;
use Structure\Entity\Db\Structure;
use Structure\Entity\Db\StructureGestionnaire;
use Structure\Entity\Db\StructureResponsable;
use Structure\Provider\Privilege\StructurePrivileges;

$this->headTitle($structure->getLibelleLong());
@@ -77,7 +81,7 @@ $canAfficherStructure = $this->isAllowed($structure, StructurePrivileges::STRU

    <div class="main">

        <?php echo $this->partial('partial/resume', ['structure' => $structure, 'filles' => $filles]); ?>
        <?php echo $this->partial('partial/resume', ['structure' => $structure, 'filles' => $filles, 'responsables' => $responsables, 'gestionnaires' => $gestionnaires]); ?>

        <div role="tabpanel">
            <ul class="nav nav-tabs" role="tablist">
+2 −3
Changes for module/Structure/view/structure/structure/partial/resume.phtml: 2 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -3,6 +3,8 @@
/**
 * @var Structure $structure
 * @var Structure[] $filles
 * @var StructureResponsable[] $responsables
 * @var StructureGestionnaire[] $gestionnaires
 */

use Structure\Entity\Db\Structure;
@@ -14,10 +16,7 @@ $canEditerDescription = $this->isAllowed($structure, StructurePrivileges::STRU
$canEditerGestionnaire  = $this->isAllowed($structure, StructurePrivileges::STRUCTURE_GESTIONNAIRE);
$canEditerResponsable  = $this->isAllowed($structure, StructurePrivileges::STRUCTURE_GESTIONNAIRE);

$responsables = $structure->getResponsables();
$responsables = array_filter($responsables, function (StructureResponsable $r) { return !$r->isDeleted() OR !$r->isImported(); });

$gestionnaires = $structure->getGestionnaires();
$gestionnaires = array_filter($gestionnaires, function (StructureGestionnaire $r) { return !$r->isDeleted() OR !$r->isImported(); });

$date = new DateTime();