Commit a48eac12 authored by Antony Le Courtes's avatar Antony Le Courtes
Browse files

Correction sur la reconduction de l'offre complémentaire suite à la bascule...

Correction sur la reconduction de l'offre complémentaire suite à la bascule Apogee vers Pégase : rattachement des enseignements à l'étape Pégase équivalente (VET-) en N+1
parent 9bd640e5
Loading
Loading
Loading
Loading
Loading
+1 −3
Changes for module/OffreFormation/src/Processus/ReconductionProcessus.php: 1 added line, 3 removed lines.
Original line number Diff line number Diff line
@@ -9,7 +9,6 @@ use Application\Service\Traits\ContextServiceAwareTrait;
use Application\Service\Traits\SourceServiceAwareTrait;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\ParameterType;
use OffreFormation\Service\ElementModulateurService;
use OffreFormation\Service\Traits\CheminPedagogiqueServiceAwareTrait;
use OffreFormation\Service\Traits\ElementModulateurServiceAwareTrait;
use OffreFormation\Service\Traits\ElementPedagogiqueServiceAwareTrait;
@@ -50,8 +49,7 @@ class ReconductionProcessus extends AbstractProcessus

    protected $centreCoutEpService;

    protected ?ElementModulateurService $elementModulateurService = null;

    protected $elementModulateurService;


    public function __construct()
+35 −3
Changes for module/OffreFormation/src/Service/OffreFormationService.php: 35 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -234,6 +234,8 @@ class OffreFormationService extends AbstractEntityService
            $codesEtapeN1[] = $v->getCode();
        }

        $mappingEtape = $this->createMappingEtapeNEtapeN1($etapes, $etapesN1, $anneeSuivante);

        foreach ($etapes as $v) {
            if ($v->getHistoDestruction() != null) {
                continue;
@@ -241,6 +243,9 @@ class OffreFormationService extends AbstractEntityService
            $offresComplementaires[$v->getId()]['reconduction_partiel'] = 'non';
            $offresComplementaires[$v->getId()]['elements_pedagogique'] = [];
            $offresComplementaires[$v->getId()]['etape']                = $v;
            $offresComplementaires[$v->getId()]['etapeN1']              = isset($mappingEtape[$v->getId()])
                ? $this->getEntityManager()->find(Etape::class, $mappingEtape[$v->getId()])
                : null;
            if ($v->getSource() == $source) {
                $offresComplementaires[$v->getId()]['reconduction']     = (in_array($v->getCode(), $codesEtapeN1)) ? 'oui' : 'non';
                $offresComplementaires[$v->getId()]['reconductionFait'] = (in_array($v->getCode(), $codesEtapeN1)) ? 'oui' : 'non';
@@ -265,14 +270,12 @@ class OffreFormationService extends AbstractEntityService
            $offresComplementaires[$etapeId]['elements_pedagogique'][$v->getId()]['element']      = $v;
        }

        $mappingEtape = $this->createMappingEtapeNEtapeN1($etapes, $etapesN1);

        return [$offresComplementaires, $mappingEtape, $reconductionTotale];
    }



    public function createMappingEtapeNEtapeN1($etapesN, $etapesN1)
    public function createMappingEtapeNEtapeN1($etapesN, $etapesN1, $anneeSuivante)
    {
        $codesEtapeN  = [];
        $codesEtapeN1 = [];
@@ -290,12 +293,41 @@ class OffreFormationService extends AbstractEntityService
        foreach ($codesEtapeN as $k => $v) {
            if (array_key_exists($k, $codesEtapeN1)) {
                $mappingEtape[$v] = $codesEtapeN1[$k];
                continue;
            }
            //Passage Apogée => Pégase : l'étape N+1 peut porter le code Pégase (ex : PHYSL1_201 => VET-PHYSL1-201)
            $etapeN1 = $this->getEtapePegaseCorrespondante($k, $anneeSuivante);
            if ($etapeN1) {
                $mappingEtape[$v] = $etapeN1->getId();
            }
        }

        return $mappingEtape;
    }



    /**
     * Recherche l'étape de source Pégase de l'année suivante correspondant à un code Apogée selon la convention de codage Pégase
     * (préfixe "VET-" et "_" remplacés par "-", ex : PHYSL1_201 => VET-PHYSL1-201)
     */
    private function getEtapePegaseCorrespondante(string $code, $annee): ?Etape
    {
        $sourcePegase = $this->getServiceSource()->getByCode('Pegase');
        if (!$sourcePegase) {
            return null;
        }

        $codePegase = 'VET-' . str_replace('_', '-', $code);

        return $this->getEntityManager()->getRepository(Etape::class)->findOneBy([
            'code'             => $codePegase,
            'annee'            => $annee,
            'source'           => $sourcePegase,
            'histoDestruction' => null,
        ]);
    }

    public function generateCsvExport(?Structure $structure, ?NiveauEtape $niveau, ?Etape $etape): CsvModel
    {
        /* Préparation et affichage */
+8 −13
Changes for module/OffreFormation/view/offre-formation/offre-formation/reconduction.phtml: 8 added lines, 13 removed lines.
Original line number Diff line number Diff line
@@ -94,19 +94,17 @@ $this->headScript()->offsetSetFile(100, $this->basePath('/js/reconduction-offre.
                                } ?>">
                                    <?php if ($ec['reconduction'] == 'oui'): ?>
                                        <?php if ($ec['reconductionFait'] == 'oui'): ?>
                                            <th><input title="Formation déjà reconduite pour l'année prochaine"
                                                       type="checkbox"
                                                       class="checkbox-formation" disabled="disabled" name="etape[]"
                                                       value="<?= $ec['etape']->getId(); ?>"/> <span
                                            <th><span title="Formation déjà reconduite pour l'année prochaine"
                                                      class="badge bg-warning text-dark"
                                                      style="margin:0 auto;">Reconduit</span>
                                            </th>
                                        <?php else: ?>
                                            <th><input title="Formation non reconductible" type="checkbox"
                                                       class="checkbox-formation" disabled="disabled" name="etape[]"
                                                       value="<?= $ec['etape']->getId(); ?>"/> <span
                                            <?php $etapePegaseN1 = $ec['etapeN1'] && $ec['etapeN1']->getCode() != $ec['etape']->getCode() ? $ec['etapeN1'] : null; ?>
                                            <th class="text-nowrap">
                                                <span
                                                        class="badge bg-warning text-dark"
                                                        style="margin:0 auto;">Non reconductible</span>
                                                        style="margin:0 auto;"
                                                        <?php if ($etapePegaseN1): ?>title="Etape non trouvée en N+1, les enseignements seront rattachés à l'étape équivalente provenant de PEGASE"<?php endif; ?>><?= $etapePegaseN1 ? 'N+1 Pégase : ' . $etapePegaseN1->getCode() : 'Non reconductible' ?></span>
                                            </th>
                                        <?php endif; ?>
                                    <?php else: ?>
@@ -141,11 +139,8 @@ $this->headScript()->offsetSetFile(100, $this->basePath('/js/reconduction-offre.
                                        } ?>">
                                        <?php if ($ep['reconduction'] == 'oui'): ?>
                                            <td>
                                                <input title="Elément pédagogique déjà reconduit pour l'année prochaine"
                                                       class="checkbox-element" disabled="disabled" type="checkbox"
                                                       name="element[<?php echo $ec['etape']->getId(); ?>][]"
                                                       value="<?= $ep['element']->getId(); ?>"/>
                                                <span class="badge bg-warning text-dark">Reconduit</span>
                                                <span title="Elément pédagogique déjà reconduit pour l'année prochaine"
                                                      class="badge bg-warning text-dark">Reconduit</span>
                                            </td>
                                        <?php else: ?>
                                            <td><input class="checkbox-element" type="checkbox" checked="checked"