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

[MesFormations] Ajout de colonnes dans l'import depuis un csv

parent 5748e922
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ Version 4.2.2 (XX/12/2023)
- [EMC2] Correction de l'ajout de fiche de métier qui échouait si vide
- [EMC2] Nouveau jalon dans l'affichage de l'avancement des campagnes et utilisation de l'affichage sur le recap de la campagne
- [Autoform] Filtrage des balises qui ne sont pas utilisés directement pour la mise en form
- [MesFormations] Ajout de colonnes dans l'import depuis un csv

Modification en BD
---
+24 −0
Original line number Diff line number Diff line
@@ -362,11 +362,19 @@ class PlanDeFormationController extends AbstractActionController
                $themeColumn = array_search("Theme", $header);
                $formationColumn = array_search("Action", $header);
                $domaineColumn = array_search("Domaine", $header);
                $descriptionColumn = array_search("Description", $header);
                $objectifColumn = array_search("Objectif", $header);
                $programmeColumn = array_search("Programme", $header);
                $modaliteColumn = array_search("Modalite", $header);

                if ($axeColumn === false) $error[] = "La colonne [Axe] n'a pas été trouvée dans le fichier csv !";
                if ($themeColumn === false) $error[] = "La colonne [Theme] n'a pas été trouvée dans le fichier csv !";
                if ($formationColumn === false) $error[] = "La colonne [Action] n'a pas été trouvée dans le fichier csv !";
                if ($domaineColumn === false) $error[] = "La colonne [Domaine] n'a pas été trouvée dans le fichier csv !";
                if ($descriptionColumn === false) $error[] = "La colonne [Description] n'a pas été trouvée dans le fichier csv !";
                if ($objectifColumn === false) $error[] = "La colonne [Objectif] n'a pas été trouvée dans le fichier csv !";
                if ($programmeColumn === false) $error[] = "La colonne [Programme] n'a pas été trouvée dans le fichier csv !";
                if ($modaliteColumn === false) $error[] = "La colonne [Modalite] n'a pas été trouvée dans le fichier csv !";

                $array = array_slice($array, 1);
                $axes = [];
@@ -411,6 +419,10 @@ class PlanDeFormationController extends AbstractActionController
                            $domaines[$domaineLibelle] = $domaine;
                        }
                    }

                    if (!in_array($line[$modaliteColumn], ['Présentiel', 'Distanciel', 'Mixte'])) {
                        $error[] = "Modalité [".$line[$modaliteColumn]."] non reconnue !";
                    }
                }

                //Création & ajout
@@ -456,6 +468,18 @@ class PlanDeFormationController extends AbstractActionController
                            $this->getFormationService()->update($formation);
                        }

                        $description = $line[$descriptionColumn];
                        $objectif = $line[$descriptionColumn];
                        $programme = $line[$programmeColumn];
                        $modalite = $line[$modaliteColumn];

                        $formation->setDescription($description);
                        $formation->setObjectifs($objectif);
                        $formation->setProgramme($programme);
                        $formation->setType($modalite);
                        $this->getFormationService()->update($formation);


                        if (!$formation->hasPlanDeFormation($plan)) {
                            $formation->addPlanDeForamtion($plan);
                            $this->getFormationService()->update($formation);
+11 −1
Original line number Diff line number Diff line
@@ -15,12 +15,15 @@ use Formation\Entity\Db\Axe;
use Formation\Entity\Db\Formation;
use Formation\Entity\Db\FormationGroupe;
use Formation\Entity\Db\PlanDeFormation;
use Formation\Provider\Privilege\FormationPrivileges;
use Formation\Provider\Privilege\PlanformationPrivileges;

$canIndex = $this->isAllowed(PlanformationPrivileges::getResourceId(PlanformationPrivileges::PLANFORMATION_INDEX));
$canAjouterFormation = $this->isAllowed(PlanformationPrivileges::getResourceId(PlanformationPrivileges::PLANFORMATION_MODIFIER));
$canReprendre = $this->isAllowed(PlanformationPrivileges::getResourceId(PlanformationPrivileges::PLANFORMATION_MODIFIER));

$canAfficherAction = $this->isAllowed(FormationPrivileges::getResourceId(FormationPrivileges::FORMATION_AFFICHER));

usort($axes, function (Axe $a, Axe $b) { return $a->getOrdre() > $b->getOrdre();});
?>

@@ -82,7 +85,14 @@ usort($axes, function (Axe $a, Axe $b) { return $a->getOrdre() > $b->getOrdre();
                    <?php /** @var Formation $formation */ ?>
                    <?php foreach ($formationsArrayByGroupe[$groupe->getId()] as $formation) : ?>
                        <li>
                            <?php if ($canAfficherAction) : ?>
                                <?php /** @see \Formation\Controller\FormationController::editerAction() */ ?>
                                <a href="<?php echo $this->url("formation/editer", ["formation" => $formation->getId()], [], true); ?>" class="ajax-modal">
                                    <span class="formation"> <?php echo $formation->getLibelle(); ?> </span>
                                </a>
                            <?php else : ?>
                                <span class="formation"> <?php echo $formation->getLibelle(); ?> </span>
                            <?php endif; ?>
                            <?php foreach ($formation->getDomaines() as $domaine) : ?>
                                <span class="badge" style="background: <?php echo $domaine->getCouleur(); ?>" title="<?php echo $domaine->getLibelle(); ?>">&nbsp;</span>
                            <?php endforeach; ?>
+11 −2
Original line number Diff line number Diff line
@@ -19,7 +19,9 @@ use Formation\Form\PlanDeFormationImportation\PlanDeFormationImportationForm;
<div class="alert alert-info">
    <span class="icon icon-information"></span>
    Attention les axes, thèmes, actions et domaines sont identifiant grâce à la première ligne du fichier.
    Assurez vous d'avoir correctement rempli cette première ligne avec les termes <code>Axe</code>, <code>Theme</code>, <code>Action</code> et <code>Domaine</code>.
    Assurez vous d'avoir correctement rempli cette première ligne avec les termes :
    <code>Axe</code>, <code>Theme</code>, <code>Action</code>, <code>Domaine</code>, <code>Description</code>, <code>Objectif</code>, <code>Programme</code> et <code>Modalite</code>.
    Les valeurs pour la colonne <code>Modalite</code> sont <code>Présentiel</code>, <code>Distanciel</code> ou <code>Mixte</code>.

</div>

@@ -50,7 +52,10 @@ use Formation\Form\PlanDeFormationImportation\PlanDeFormationImportationForm;
                <th> Thème </th>
                <th> Domaine </th>
                <th> Action </th>
                <th> Complèment </th>
                <th> Description </th>
                <th> Objectif </th>
                <th> Programme </th>
                <th> Modalité </th>
            </tr>
            </thead>
            <tbody>
@@ -60,6 +65,10 @@ use Formation\Form\PlanDeFormationImportation\PlanDeFormationImportationForm;
                    <td> <?php echo $line[1]; ?> </td>
                    <td> <?php echo $line[2]; ?> </td>
                    <td> <?php echo $line[3]; ?> </td>
                    <td> <?php echo $line[4]; ?> </td>
                    <td> <?php echo $line[5]; ?> </td>
                    <td> <?php echo $line[6]; ?> </td>
                    <td> <?php echo $line[7]; ?> </td>
                    <td>  </td>
                </tr>
            <?php endforeach; ?>