Commit bc216199 authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files
parent 248d6efe
Loading
Loading
Loading
Loading
−1
Changes for module/Application/src/Application/Controller/OffreFormationController.php: 0 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@ use Application\Service\Traits\NiveauEtapeServiceAwareTrait;
use Application\Service\Traits\OffreFormationServiceAwareTrait;
use Application\Service\Traits\StructureServiceAwareTrait;
use UnicaenApp\View\Model\CsvModel;
use Zend\Session\Container;


/**
+55 −1
Changes for module/Application/src/Application/Service/OffreFormationService.php: 55 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
namespace Application\Service;


use Application\Entity\Db\CheminPedagogique;
use Application\Entity\Db\ElementPedagogique;
use Application\Entity\Db\Etape;
use Application\Entity\NiveauEtape;
@@ -38,7 +39,10 @@ class OffreFormationService extends AbstractEntityService

    public function getNeep($structure, $niveau, $etape, $annee = null, $source = null)
    {

        if ($etape) {
            /* workaroud pour parser les chemins pédagogiques si on fournit une étape spécifique */
            return $this->getNeepEtape($etape);
        }

        if (is_null($annee)) {
            $annee = $this->getServiceContext()->getAnnee();
@@ -123,6 +127,56 @@ class OffreFormationService extends AbstractEntityService



    public function getNeepEtape($etape)
    {
        $niveaux  = [];
        $etapes   = [];
        $elements = [];

        $sql = 'SELECT
                cp,
                partial e.{id,code,annee,libelle,sourceCode,niveau,histoDestruction},
                partial ep.{id,code,libelle,sourceCode,etape,periode,tauxFoad,fi,fc,fa,tauxFi,tauxFc,tauxFa},
                partial vme.{id,heures, groupes}
            FROM
              Application\Entity\Db\CheminPedagogique cp
              JOIN cp.etape e
              JOIN cp.elementPedagogique ep
              LEFT JOIN ep.volumeHoraireEns vme
            WHERE
              cp.etape = :etape';

        $query = $this->getEntityManager()->createQuery($sql);

        $query->setParameter('etape', $etape);

        $result = $query->getResult();
        foreach ($result as $object) {
            /** @var CheminPedagogique $object */
            if ($object->estHistorise()) continue;

            $etape   = $object->getEtape();
            $element = $object->getElementPedagogique();

            $n                           = NiveauEtape::getInstanceFromEtape($etape);
            $niveaux[$n->getId()]        = $n;
            $etapes[$etape->getId()]     = $etape;
            $elements[$element->getId()] = $element;
        }

        /* Tri */
        uasort($elements, function (ElementPedagogique $e1, ElementPedagogique $e2) {
            $e1Lib = strtolower(trim($e1->getEtape()->getLibelle() . ' ' . $e1->getLibelle()));
            $e2Lib = strtolower(trim($e2->getEtape()->getLibelle() . ' ' . $e2->getLibelle()));

            return $e1Lib > $e2Lib;
        });

        return [$niveaux, $etapes, $elements];
    }



    /**
     * @return array
     */