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

Finalisation reconduction offre complémentaire pour la prochaine année universitaire.

parent 392df1c1
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -372,6 +372,9 @@ return [
            Service\DomaineFonctionnelService::class   => Service\DomaineFonctionnelService::class,
            Assertion\OffreDeFormationAssertion::class => Assertion\OffreDeFormationAssertion::class,
        ],
        'factories'  => [
            Processus\ReconductionProcessus::class => Processus\Factory\ReconductionProcessusFactory::class,
        ],
    ],
    'form_elements'   => [
        'invokables' => [
@@ -387,6 +390,7 @@ return [
        ],
        'factories'  => [
            Form\OffreFormation\VolumeHoraireEns::class => Form\OffreFormation\Factory\VolumeHoraireEnsFormFactory::class,
            Processus\ReconductionProcessusFactory::class => Processus\Factory\ReconductionProcessusFactory::class,
        ],
    ],
    'view_helpers'    => [
+29 −54
Original line number Diff line number Diff line
@@ -5,10 +5,11 @@ namespace Application\Controller;
use Application\Entity\Db\ElementPedagogique;
use Application\Entity\Db\Etape;
use Application\Entity\Db\GroupeTypeFormation;
use Application\Entity\Db\Traits\CheminPedagogiqueAwareTrait;
use Application\Entity\Db\TypeFormation;
use Application\Entity\Db\TypeModulateur;
use Application\Entity\NiveauEtape;
use Application\Processus\Traits\ReconductionProcessusAwareTrait;
use Application\Service\Traits\AnneeServiceAwareTrait;
use Application\Service\Traits\ContextServiceAwareTrait;
use Application\Service\Traits\ElementPedagogiqueServiceAwareTrait;
use Application\Service\Traits\EtapeServiceAwareTrait;
@@ -16,7 +17,6 @@ use Application\Service\Traits\LocalContextServiceAwareTrait;
use Application\Service\Traits\NiveauEtapeServiceAwareTrait;
use Application\Service\Traits\StructureServiceAwareTrait;
use UnicaenApp\View\Model\CsvModel;
use Zend\Debug\Debug;
use Zend\Session\Container;


@@ -33,6 +33,8 @@ class OffreFormationController extends AbstractController
    use ElementPedagogiqueServiceAwareTrait;
    use EtapeServiceAwareTrait;
    use NiveauEtapeServiceAwareTrait;
    use AnneeServiceAwareTrait;
    use ReconductionProcessusAwareTrait;

    /**
     * @var Container
@@ -234,94 +236,67 @@ class OffreFormationController extends AbstractController
    public function reconductionAction()
    {


        $this->initFilters();
        $structures = $this->getServiceStructure()->getList($this->getServiceStructure()->finderByEnseignement());
        $anneeEnCours = $this->getServiceContext()->getAnnee();
        $anneeSuivante = $this->getServiceContext()->getAnneeSuivante();
        $this->getServiceMiseEnPaiementIntervenantStructure()
        /*$serviceAnnee = $this->getServiceAnnee();
        $selectedAnnee = $this->getServiceAnnee()->get('2020');
        Debug::dump($selectedAnnee);*/

        $reconductionStep = '';
        $messageStep = '';

        //Récupération des paramètres GET
        list($structure, $niveau, $etape) = $this->getParams();

        //Reconduction oc selectionnée
        $request = $this->getRequest();
        if ($request->isPost()) {
            $datas = $request->getPost();
            //Duplicate formation
            //TODO : faire un service pour déporter le code du controlleur
            if(!empty($datas['etape']))
            {
                foreach($datas['etape'] as $v)
            $reconductionProcessus = $this->getProcessusReconduction();
            try{
                if($reconductionProcessus->reconduction($datas))
                {
                    $etapeEnCours = $this->getServiceEtape()->get($v);
                    $reconductionEtape = clone $etapeEnCours;
                    $reconductionEtape->setAnnee($anneeSuivante);
                    $reconductionEtape->setSourceCode(md5(microtime()));
                    // $this->em()->persist($reconductionEtape);
                    //$this->em()->flush();
                    unset($etapeEnCours, $reconductionEtape);

                    $reconductionStep = true;
                }
                else{
                    $reconductionStep = false;
                }

            //duplicate element pédagogique
            if(!empty($datas['element']))
            {
                foreach($datas['element'] as $v)
                {
                    $elementEnCours = $this->getServiceElementPedagogique()->get($v);
                    $reconductionElement = clone $elementEnCours;
                    $reconductionElement->setAnnee($anneeSuivante);
                    $reconductionElement->setSourceCode(md5(microtime()));
                    //$this->em()->persist($reconductionElement);
                   // $this->em()->flush();
                    unset($etapeEnCours, $reconductionEtape);

            }
            catch(\Exception $e){
                $reconductionStep = false;
                $messageStep = $e->getMessage();
            }

        }


        $this->getServiceLocalContext()
            ->setStructure($structure)
            ->setNiveau($niveau)
            ->setEtape($etape);

        list($niveaux, $etapes, $elements) = $this->getNeep($structure, $niveau, $etape);
        //Order ETAPE > ELEMENT PEDAGOGIQUE
        $etapesComplementaires = [];
        //Organisation pour traitement dans la vue
        $offresComplementaires = [];
        foreach ($etapes as $v)
        {
            $etapesComplementaires[$v->getId()]['etape'] = $v;
            $etapesComplementaires[$v->getId()]['elements_pedagogique'] = [];
            $offresComplementaires[$v->getId()]['etape'] = $v;
            $offresComplementaires[$v->getId()]['elements_pedagogique'] = [];

        }
        foreach ($elements as $v)
        {
            $structureId = $v->getStructure()->getId();
            $etapesComplementaires[$structureId]['elements_pedagogique'][] = $v;
            $etapeId = $v->getEtape()->getId();
            $offresComplementaires[$etapeId]['elements_pedagogique'][] = $v;
        }

        //Load specific JS
        //TODO : A mettre dans un plugin générique
        //Chargement JS nécessaire uniquement sur cette page
        $viewHelperManager = $this->getServiceLocator()->get('ViewHelperManager');
        $headScript = $viewHelperManager->get('headScript');
        $headScript->appendFile('/js/reconduction-offre.js');
        $headScript->offsetSetFile(100, '/js/reconduction-offre.js');

        return [
            'etapesComplementaires' => $etapesComplementaires,
            'anneeEnCours' => $anneeEnCours,
            'offresComplementaires' => $offresComplementaires,
            'structure'        => $structure,
            'structures'       => $structures,
            'niveau'     => $niveau,
            'niveaux'    => $niveaux,
            'etape'  => $etape,
            'etapes' => $etapes,
            'elements' => $elements
            'anneeEnCours'     => $anneeEnCours,
            'reconductionStep' => $reconductionStep,
            'messageStep'      => $messageStep
        ];


+13 −0
Original line number Diff line number Diff line
@@ -35,6 +35,19 @@ class CheminPedagogique implements HistoriqueAwareInterface, ImportAwareInterfac
    protected $etape;


    public function __clone()
    {
        if($this->id)
        {
            $this->id = null;
        }
        $this->etape = null;
        $this->elementPedagogique = null;

        return $this;
    }



    /**
     * Set ordre
+3 −2
Original line number Diff line number Diff line
@@ -160,13 +160,14 @@ class ElementPedagogique implements HistoriqueAwareInterface, AnneeAwareInterfac
        {
            $this->id = null;
        }
        $this->cheminPedagogique = new ArrayCollection();
        $this->elementModulateur = new ArrayCollection();
        $this->etape = null;
        $this->elementModulateur = null;
        $this->effectifs = null;
        $this->centreCoutEp = null;
        $this->volumeHoraireEns = null;
        $this->service = null;
        $this->typeHeures = null;
        $this->cheminPedagogique = null;


        return $this;
+1 −0
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ namespace Application\Entity\Db;

use Application\Entity\Db\Interfaces\AnneeAwareInterface;
use Application\Entity\Db\Traits\AnneeAwareTrait;
use Doctrine\Common\Collections\ArrayCollection;
use UnicaenApp\Entity\HistoriqueAwareInterface;
use UnicaenApp\Entity\HistoriqueAwareTrait;
use UnicaenImport\Entity\Db\Interfaces\ImportAwareInterface;
Loading