Commit 47f3c4ae authored by Johnny Leveneur's avatar Johnny Leveneur
Browse files

import des inscriptions administratives

parent 6f250725
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@ use Etudiant\Service\EtablissementIA\EtablissementIAService;
use Etudiant\Service\EtablissementIA\EtablissementIAServiceFactory;
use Etudiant\Service\Etudiant\EtudiantService;
use Etudiant\Service\Etudiant\EtudiantServiceFactory;
use Etudiant\Service\InscriptionAdministrative\InscriptionAdministrativeService;
use Etudiant\Service\InscriptionAdministrative\InscriptionAdministrativeServiceFactory;
use Etudiant\View\Helper\EtudiantInscriptionsAdministrativesViewHelper;
use Etudiant\View\Helper\EtudiantsViewHelper;
use Laminas\Router\Http\Literal;
@@ -174,7 +176,7 @@ return [
            EtablissementIAService::class => EtablissementIAServiceFactory::class,
            ComposanteIAService::class => ComposanteIAServiceFactory::class,
            CycleIAService::class => CycleIAServiceFactory::class,

            InscriptionAdministrativeService::class => InscriptionAdministrativeServiceFactory::class,
        ],
    ],
    'form_elements' => [
+2 −104
Original line number Diff line number Diff line
@@ -114,109 +114,6 @@ class EtudiantController extends AbstractActionController
        exit;
    }


//    public function importerAction(): ViewModel
//    {
//        $form = $this->getCompetenceImportationForm();
//        $form->setAttribute('action', $this->url()->fromRoute('competence-import', ['mode' => 'preview', 'path' => null], [], true));
//
//
//        $request = $this->getRequest();
//        if ($request->isPost()) {
//            $error = [];
//            $data = $request->getPost();
//            $file = $request->getFiles();
//
//            $fichier_path = $file['fichier']['tmp_name'];
//            $mode = $data['mode'];
//            if (!isset($data['referentiel']) || $data['referentiel'] === "") { throw new RuntimeException("Aucun référentiel de sélectionné.");}
//            $referentiel = $this->getCompetenceReferentielService()->getCompetenceReferentiel($data['referentiel']);
//            if ($referentiel === null) { throw new RuntimeException("Aucun référentiel [".$data['referentiel']."] de trouvé .");}
//
//            $all = file_get_contents($fichier_path);
//            $encoding = mb_detect_encoding($all, 'UTF-8, ISO-8859-1');
//
//            //reading
//            $array = [];
//            if ($fichier_path === null or $fichier_path === '') {
//                $error[] = "Aucun fichier !";
//            } else {
//                $handle = fopen($fichier_path, "r");
//
//                while ($content = fgetcsv($handle, 0, ";")) {
//                    $array[] = array_map(function (string $a) use ($encoding) {
////                        for ($i = 0 ; $i < strlen($a) ; $i++) {
////                            var_dump($a[$i]);
////                            var_dump(ord($a[$i]));
////                        }
//                        //Note les backquote ne passe pas dans la fonction de convertion ...
//                        $a = str_replace(chr(63),'\'', $a);
//                        $a = mb_convert_encoding($a, 'UTF-8', $encoding);
//                        return $a;
//                    }, $content);
//                }
//            }
//            $warning = [];
//            if ($mode === 'import' and empty($error)) {
//
//                $typesLibelle = [];
//                $themesLibelle = [];
//                foreach (array_slice($array, 1) as $line) {
//                    $typesLibelle[$line[1]] = $line[1];
//                    $themesLibelle[$line[0]] = $line[0];
//                }
//                $types = [];
//                foreach ($typesLibelle as $typeLibelle) {
//                    $type = $this->getCompetenceTypeService()->getCompetenceTypeByLibelle($typeLibelle);
//                    if ($type === null) {
//                        $type = $this->getCompetenceTypeService()->createWith($typeLibelle);
//                    }
//                    $types[$typeLibelle] = $type;
//                }
//
//                $themes = [];
//                foreach ($themesLibelle as $themeLibelle) {
//                    $theme = $this->getCompetenceThemeService()->getCompetenceThemeByLibelle($themeLibelle);
//                    if ($theme === null) {
//                        $theme = $this->getCompetenceThemeService()->createWith($themeLibelle);
//                    }
//                    $themes[$themeLibelle] = $theme;
//                }
//
//                foreach (array_slice($array, 1) as $line) {
//                    $competence = $this->getCompetenceService()->getCompetenceByRefentiel($referentiel, $line[4]);
//                    if ($competence === null) {
//                        $this->getCompetenceService()->createWith($line[2], $line[3], $types[$line[1]], $themes[$line[0]], $referentiel, $line[4]);
//                    } else {
//                        $this->getCompetenceService()->updateWith($competence, $line[2], $line[3], $types[$line[1]], $themes[$line[0]]);
//                    }
//                }
//            }
//
//            if ($mode !== 'import') {
//                $title = "Importation d'un référentiel de compétences (Prévisualisation)";
//            }
//            if ($mode === 'import') {
//                $title = "Importation d'un référentiel de compétences (Importation)";
//            }
//            return new ViewModel([
//                'title' => $title,
//                'fichier_path' => $fichier_path,
//                'form' => $form,
//                'mode' => $mode,
//                'error' => $error,
//                'warning' => $warning,
//                'array' => array_slice($array, 1),
//            ]);
//        }
//
//        $vm = new ViewModel([
//            'title' => "Importation d'un référentiel de compétences",
//            'form' => $form,
//        ]);
//        return $vm;
//    }

    public function importerEtudiantAction(): ViewModel
    {
        $url = $this->url()->fromRoute('etudiant/importer-etudiant', [], [],);
@@ -260,7 +157,8 @@ class EtudiantController extends AbstractActionController
                    $error[] = "Le fichier ne contient pas de données.";
                } else {

                    $champs = ['source_id', 'nom', 'prenom', 'numero_etudiant', 'email', 'login'];
                    $champs = ['source_id', 'nom', 'prenom', 'numero_etudiant', 'email', 'login',
                                'annee', 'etablissement', 'composante', 'cycle', 'diplome', 'Formation' ];
                    $champs = array_map('strtolower', $champs);
                    $array[0] = array_map('strtolower', $array[0]);
                    $ind_champs = [];
+1 −0
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ use Etudiant\Service\ComposanteIA\ComposanteIAService;
use Etudiant\Service\CycleIA\CycleIAService;
use Etudiant\Service\EtablissementIA\EtablissementIAService;
use Etudiant\Service\Etudiant\EtudiantService;
use Etudiant\Service\InscriptionAdministrative\InscriptionAdministrativeService;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\ContainerInterface;
use Psr\Container\NotFoundExceptionInterface;
+42 −2
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@ class InscriptionAdministrative implements IsSynchronisableInterface
{
    use IsSynchronisableTrait;

    private ?int $id = null;
    private ?string $id = null;

    private ?string $annee_univ = null;

@@ -26,7 +26,7 @@ class InscriptionAdministrative implements IsSynchronisableInterface
    private ?Etudiant $etudiant;


    public function getId(): ?int
    public function getId(): ?string
    {
        return $this->id;
    }
@@ -66,6 +66,46 @@ class InscriptionAdministrative implements IsSynchronisableInterface
        return $this->etudiant;
    }

    public function setId(?string $id): void
    {
        $this->id = $id;
    }

    public function setAnneeUniv(?string $annee_univ): void
    {
        $this->annee_univ = $annee_univ;
    }

    public function setFormation(?string $formation): void
    {
        $this->formation = $formation;
    }

    public function setDiplome(?string $diplome): void
    {
        $this->diplome = $diplome;
    }

    public function setCycle(?string $cycle): void
    {
        $this->cycle = $cycle;
    }

    public function setComposante(?string $composante): void
    {
        $this->composante = $composante;
    }

    public function setEtablissement(?string $etablissement): void
    {
        $this->etablissement = $etablissement;
    }

    public function setEtudiant(?Etudiant $etudiant): void
    {
        $this->etudiant = $etudiant;
    }

    public function getAttribute($attribute): ?string
    {
        if (property_exists($this, $attribute)) {
+2 −3
Original line number Diff line number Diff line
@@ -3,9 +3,7 @@
                  xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping https://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
    <entity name="Etudiant\Entity\Db\InscriptionAdministrative" table="etudiant_inscription_administrative">

        <id name="id" type="integer" column="id">
            <generator strategy="IDENTITY"/>
        </id>
        <id name="id" type="string" length="256" column="id"/>

        <field name="annee_univ" type="string" length="4" column="annee_univ" nullable="true"/>
        <field name="formation" type="string" length="1024" column="formation" nullable="true"/>
@@ -22,5 +20,6 @@
        <field name="createdOn"               column="created_on"       type="datetime"/>
        <field name="updatedOn"               column="updated_on"       type="datetime"/>
        <field name="deletedOn"               column="deleted_on"       type="datetime"/>
        <field name="sourceId"               column="source_id"        type="string" length="128" nullable="true"/>
    </entity>
</doctrine-mapping>
Loading