Commit 10b75788 authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Compatibilité multi-niveaux structures de la page formation de chargens

parent 1f4fde3f
Loading
Loading
Loading
Loading
+12 −2
Changes for module/Application/src/Assertion/ChargensAssertion.php: 12 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -111,11 +111,21 @@ class ChargensAssertion extends AbstractAssertion

    private function assertScenarioStructureEdition(Structure $structure = null)
    {
        /** @var Role $role */
        $role = $this->getRole();

        $asserts = [];

        if ($structure) {
            return $this->getAcl()->isAllowed($this->getRole(), Privileges::getResourceId(Privileges::CHARGENS_SCENARIO_COMPOSANTE_EDITION));
            $asserts[] = $this->getAcl()->isAllowed($this->getRole(), Privileges::getResourceId(Privileges::CHARGENS_SCENARIO_COMPOSANTE_EDITION));
            if ($role->getStructure()){
                $asserts[] = $structure->inStructure($role->getStructure());
            }
        } else {
            return $this->getAcl()->isAllowed($this->getRole(), Privileges::getResourceId(Privileges::CHARGENS_SCENARIO_ETABLISSEMENT_EDITION));
            $asserts[] = $this->getAcl()->isAllowed($this->getRole(), Privileges::getResourceId(Privileges::CHARGENS_SCENARIO_ETABLISSEMENT_EDITION));
        }

        return $this->asserts($asserts);
    }

}
 No newline at end of file
+14 −14
Changes for module/Application/src/Form/Chargens/FiltreForm.php: 14 added lines, 14 removed lines.
Original line number Diff line number Diff line
@@ -166,40 +166,33 @@ class FiltreForm extends AbstractForm
    {
        $cStructure = $this->getServiceContext()->getStructure();

        if ($cStructure) {
            $this->structures = [$cStructure];
        } else {
        $qb = $this->getServiceStructure()->finderByHistorique();
        $this->getServiceStructure()->finderByEnseignement($qb);
        $this->structures = $this->getServiceStructure()->getList($qb);
        }

        $etapesSql = '
        SELECT DISTINCT
            e.id,
            e.code,
            e.libelle,
            e.structure_id
            str.ids structure_ids
        FROM
          etape e
          JOIN noeud n ON n.etape_id = e.id
          JOIN lien l ON l.noeud_sup_id = n.id
          JOIN structure str ON str.id = e.structure_id
        WHERE
          e.histo_destruction IS NULL
          AND n.histo_destruction IS NULL
          AND l.histo_destruction IS NULL
          AND e.annee_id = ' . $this->getServiceContext()->getAnnee()->getId() . '
          ' . (($s = $this->getServiceContext()->getStructure()) ? 'AND e.structure_id = ' . $s->getId() : '') . ' 
          ' . (($s = $this->getServiceContext()->getStructure()) ? 'AND str.ids LIKE \'' . $s->idsFilter() . "'" : '') . ' 
        ORDER BY
            e.libelle, e.code
        ';
        $this->etapes = [];
        $dEtapes = $this->getServiceEtape()->getEntityManager()->getConnection()->fetchAllAssociative($etapesSql);

        /*$qb = $this->getServiceEtape()->finderByHistorique();
        $this->getServiceEtape()->finderByContext($qb);
        $this->etapes = $this->getServiceEtape()->getList($qb);*/

        $qb = $this->getServiceScenario()->finderByHistorique();
        $this->getServiceScenario()->finderByContext($qb);
        $this->scenarios = $this->getServiceScenario()->getList($qb);
@@ -210,16 +203,19 @@ class FiltreForm extends AbstractForm
        foreach ($dEtapes as $e) {
            $id = (int)$e['ID'];
            $label = $e['LIBELLE'] . ' (' . $e['CODE'] . ')';
            $sid   = (int)$e['STRUCTURE_ID'];
            $sids = explode('-', substr($e['STRUCTURE_IDS'], 1, -1));

            $this->etapes[$id] = $label;

            foreach ($sids as $sid) {
                $sid = (int)$sid;
                if (!isset($sEtapes[$sid])) {
                    $sEtapes[$sid] = [];
                }
                $sEtapes[$sid][] = $id;
                $eStructures[$id] = $sid;
            }
        }

        foreach ($this->scenarios as $scenario) {
            $sid = $scenario->getStructure() ? $scenario->getStructure()->getId() : 0;
@@ -231,10 +227,14 @@ class FiltreForm extends AbstractForm
            }

            foreach ($structures as $structure) {
                if (!isset($sScenarios[$structure->getId()])) {
                    $sScenarios[$structure->getId()] = [];
                $ids = $structure->getIdsArray();
                foreach ($ids as $sid) {
                    if (!isset($sScenarios[$sid])) {
                        $sScenarios[$sid] = [];
                    }
                    $sScenarios[$sid][] = $scenario->getId();
                }
                $sScenarios[$structure->getId()][] = $scenario->getId();

            }
        }

+2 −2
Changes for module/Application/src/Provider/Chargens/LienProvider.php: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -276,9 +276,9 @@ class LienProvider
        $cStructure = $this->chargens->getServiceContext()->getStructure();
        $canEdit    = false;
        if ($cStructure) {
            $structureId = $lien->getStructure(false);
            $lStructure = $lien->getStructure(true);

            if (!$structureId || $structureId == $cStructure->getId()) {
            if (!$lStructure || $lStructure->inStructure($cStructure)) {
                $canEdit = true;
            }
        } else {
+2 −2
Changes for module/Application/src/Provider/Chargens/NoeudProvider.php: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -440,9 +440,9 @@ class NoeudProvider
        $cStructure = $this->chargens->getServiceContext()->getStructure();
        $canEdit    = false;
        if ($cStructure) {
            $structureId = $noeud->getStructure(false);
            $nStructure = $noeud->getStructure(true);

            if (!$structureId || $structureId == $cStructure->getId()) {
            if (!$nStructure || $nStructure->inStructure($cStructure)) {
                $canEdit = true;
            }
        } else {
+2 −2
Changes for module/Application/src/Provider/Chargens/ScenarioNoeudProvider.php: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -88,12 +88,12 @@ class ScenarioNoeudProvider
            $scenarioNoeud = $scenarioNoeuds[$scenarioNoeudId];
            $typeHeures    = $this->chargens->getEntities()->get(TypeHeures::class, $typeHeuresId);
            $etape         = $this->chargens->getEntities()->get(Etape::class, $etapeId);

            if ($etape) {
                $scenarioNoeudEffectif = new ScenarioNoeudEffectif($scenarioNoeud, $typeHeures, $etape);
                $sneHydrator->hydrate($d, $scenarioNoeudEffectif);

                $scenarioNoeud->addEffectif($scenarioNoeudEffectif);
            }
        }

        $sns         = $this->getScenarioNoeudSeuilsData($noeudIds);
        $snsHydrator = new ScenarioNoeudSeuilDbHydrator();
Loading