Commit aebac72d authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

Ajustement de l'import pour une personne

parent 70d70327
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -28,8 +28,8 @@ return [
                        'element',
                        'theme',
                    ],
                    'privileges' => [
                        LagafPrivileges::IMPORT_LAGAF,
                    'roles' => [
                       // LagafPrivileges::IMPORT_LAGAF,
                    ],
                ],
            ],
@@ -38,7 +38,7 @@ return [

    'router'          => [
        'routes' => [
            'formation' => [
//            'formation' => [
//                'type'  => Literal::class,
//                'options' => [
//                    'route'    => '/formation',
@@ -48,7 +48,7 @@ return [
//                    ],
//                ],
//                'may_terminate' => true,
                'child_routes' => [
//                'child_routes' => [
                    'import-lagaf' => [
                        'type' => Literal::class,
                        'options' => [
@@ -143,8 +143,8 @@ return [
                        ],
                    ],
                ],
            ],
        ],
//            ],
//        ],
    ],

    'service_manager' => [
+94 −64
Original line number Diff line number Diff line
@@ -403,6 +403,8 @@ class ImportationLagafController extends AbstractActionController {

    public function inscriptionAction()
    {
        $id = $this->params()->fromRoute('id');

        $report = "";
        $inscriptions = [];
        $problemes = [];
@@ -432,27 +434,39 @@ class ImportationLagafController extends AbstractActionController {
            }
        }

        $stagiaires = [];
        $agents = [];
        $agents_tmp = $this->getStagiaireService()->getAgentService()->getAgents();
        foreach ($agents_tmp as $agent) $agents[$agent->getId()] = $agent;

        if ($id) {
            $stagiaire = $this->getStagiaireService()->getStagiaire($id);
            $stagiaires[$id] = $stagiaire;
            $agents[$stagiaire->getOctopusId()] = $this->getStagiaireService()->getAgentService()->getAgent($stagiaire->getOctopusId());
        } else {
            $stagiaires_tmp = $this->getStagiaireService()->getStagiaires();
        $stagiaires = [];
            foreach ($stagiaires_tmp as $stagiaire) {
                $stagiaires[$stagiaire->getNStagiaire()] = $stagiaire;
            }
            $agents_tmp = $this->getStagiaireService()->getAgentService()->getAgents();
            foreach ($agents_tmp as $agent) $agents[$agent->getId()] = $agent;
        }

        $lagaf = $this->sourceLagaf;

        if ($id) {
            $inscrits_tmp = $this->getFormationInstanceInscritService()->getFormationsByInscrit(current($agents));
        } else {
            $inscrits_tmp = $this->getFormationInstanceInscritService()->getFormationsInstancesInscrits();
        $inscrits_tmp = array_filter($inscrits_tmp, function (FormationInstance $a) use ($lagaf) { return $a->getSource() === $lagaf; });
        }
        $inscrits_tmp = array_filter($inscrits_tmp, function (FormationInstanceInscrit $a) use ($lagaf) { return $a->getSource() === $lagaf; });
        $inscrits = []; foreach ($inscrits_tmp as $inscrit) $inscrits[$inscrit->getId()] = $inscrit;

        $etat_ok = $this->getEtatService()->getEtatByCode(InscriptionEtats::ETAT_VALIDER_DRH);
        $validee = $this->getEtatService()->getEtatByCode('VALIDATION_INSCRIPTION');

        $report .= "<table class='table table-condensed'>";
        $report .= "<thead><tr><th>Stagiaire </th><th>Session</th><th>FRepas</th><th>FTransport</th><th>FHebergement</th></tr></thead>";
        $report .= "<tbody>";

        $etat_ok = $this->getEtatService()->getEtatByCode(InscriptionEtats::ETAT_VALIDER_DRH);

        for($position = 1 ; $position < $nbLine; $position++) {

@@ -462,12 +476,14 @@ class ImportationLagafController extends AbstractActionController {

            $instance = (isset($instances[$st_instance])) ? $instances[$st_instance] : null;
            $stagiaire = (isset($stagiaires[$st_nstagiaire])) ? $stagiaires[$st_nstagiaire] : null;
            $agent = ($stagiaire !== null AND isset($agents[$stagiaire->getOctopusId()]))?$agents[$stagiaire->getOctopusId()]:null;

            $agent = ($stagiaire !== null and isset($agents[$stagiaire->getOctopusId()])) ? $agents[$stagiaire->getOctopusId()] : null;
            $st_iscrit_id = $st_instance . "-" . $st_nstagiaire;

            if ($id === null or $st_nstagiaire == $id) {

                //            $inscrit = $this->getFormationInstanceInscritService()->getFormationInstanceInscritBySource(null, $st_instance . "-" . $st_nstagiaire);
            if ($agent !== null AND $instance !== null AND $inscrits[$st_iscrit_id] === null) {
                if ($agent !== null and $instance !== null and $inscrits[$st_iscrit_id] === null) {
                    $inscription = new FormationInstanceInscrit();
                    $inscription->setInstance($instance);
                    $inscription->setAgent($agent);
@@ -483,7 +499,7 @@ class ImportationLagafController extends AbstractActionController {
                    $st_ftransport = trim($data[$position_FTransport]);
                    $st_fhebergement = trim($data[$position_FHebergement]);

                if ($st_frepas !== "" OR $st_ftransport !== "" OR $st_fhebergement !== "") {
                    if ($st_frepas !== "" or $st_ftransport !== "" or $st_fhebergement !== "") {
                        $frais = new FormationInstanceFrais();
                        if ($st_frepas !== "") $frais->setFraisRepas($st_frepas);
                        if ($st_ftransport !== "") $frais->setFraisTransport($st_ftransport);
@@ -493,11 +509,18 @@ class ImportationLagafController extends AbstractActionController {
                        $frais->setIdSource($st_instance . "-" . $st_nstagiaire);
                        $this->getFormationInstanceFraisService()->create($frais);
                    }

                    if ($id !== null) {
                        $report .= "<tr>";
                        $report .= "<td>".$agent->getDenomination() ."</td>";
                        $report .= "<td>".$instance->getFormation()->getLibelle() ."</td>";
                        $report .= "</tr>";
                    }
                } else {
                    $problemes[] = $data;
                }
            }

        }
        $report .= "</tbody></table>";


@@ -510,6 +533,9 @@ class ImportationLagafController extends AbstractActionController {

    public function presenceAction()
    {

        $id = $this->params()->fromRoute('id');

        $report = "";
        $presences = [];
        $problemes = [];
@@ -561,13 +587,16 @@ class ImportationLagafController extends AbstractActionController {
        for($position = 1 ; $position < $nbLine; $position++) {

            $data = $array[$position];


            if ($id === null OR $data[$position_stagiaire_id] == $id) {

                $st_journee = $data[$position_action_id] . "-" . $data[$position_session_id] . "-" . $data[$position_seance_id] . "-" . $data[$position_plage_id];
                $st_inscrit = $data[$position_action_id] . "-" . $data[$position_session_id] . "-" . $data[$position_stagiaire_id];

                $journee = (isset($journees[$st_journee])) ? $journees[$st_journee] : null;
                $inscrit = (isset($inscrits[$st_inscrit])) ? $inscrits[$st_inscrit] : null;

            if ($journee !== null AND $inscrit !== null) {
                if ($journee !== null and $inscrit !== null) {
                    if (!isset($olds[$st_journee . "-" . $st_inscrit])) {
                        $presence = new Presence();
                        $presence->setJournee($journee);
@@ -584,6 +613,7 @@ class ImportationLagafController extends AbstractActionController {
                    $problemes[] = $data;
                }
            }
        }

        $report .= "</tbody></table>";

+9 −1
Original line number Diff line number Diff line
@@ -47,10 +47,18 @@ class StagiaireService {
    /**
     * @return LAGAFStagiaire[]
     */
    public function getStagiaires()
    public function getStagiaires() : array
    {
        $qb = $this->getEntityManager()->getRepository(LAGAFStagiaire::class)->createQueryBuilder('stagiaires');
        $result = $qb->getQuery()->getResult();
        return $result;
    }

    public function getStagiaire(int $id) : LAGAFStagiaire
    {
        $qb = $this->getEntityManager()->getRepository(LAGAFStagiaire::class)->createQueryBuilder('stagiaire')
            ->andWhere('stagiaire.nStagiaire = :id')->setParameter('id', $id);
        $result = $qb->getQuery()->getOneOrNullResult();
        return $result;
    }
}
 No newline at end of file