diff --git a/Back_end/.gitignore b/Back_end/.gitignore index 463a42d16db149cac7ef548005e94027a05ddfc6..8013f810d5b50587e8a70323cd5b098642bd7be7 100644 --- a/Back_end/.gitignore +++ b/Back_end/.gitignore @@ -20,7 +20,6 @@ ###< symfony/phpunit-bridge ### ###> symfony/asset-mapper ### -/public/assets/ /assets/vendor ###< symfony/asset-mapper ### diff --git a/Back_end/public/assets/csv/adherent.csv b/Back_end/public/assets/csv/adherent.csv new file mode 100644 index 0000000000000000000000000000000000000000..112dc1db54b3bd27de789ac59a9e866501f8e9dc --- /dev/null +++ b/Back_end/public/assets/csv/adherent.csv @@ -0,0 +1,62 @@ +prenom,nom,mail +Adrien,Aubert,adrien.aubert9@etu.univ-lorraine.fr +William,Baland,william.baland5@etu.univ-lorraine.fr +Nathan,Berthaud,nathan.berthaud9@etu.univ-lorraine.fr +Maximilien,Bleeker,maximilien.bleeker9@etu.univ-lorraine.fr +Ahmed,Chokuev,ahmed.chokuev1@etu.univ-lorraine.fr +Maxime,Curtil,maxime.curtil1@etu.univ-lorraine.fr +Lucas,Edouard,lucas.edouard5@etu.univ-lorraine.fr +Victor,Gassmann,victor.gassmann5@etu.univ-lorraine.fr +Jules,Gouerec,jules.gouerec8@etu.univ-lorraine.fr +Baptiste,Lambey,baptiste.lambey8@etu.univ-lorraine.fr +Nam-Robert,Le,nam-robert.le4@etu.univ-lorraine.fr +Samy,Midouni,samy.midouni7@etu.univ-lorraine.fr +Lucas,Poirot,lucas.poirot8@etu.univ-lorraine.fr +Anna,Renaux,anna.renaux5@etu.univ-lorraine.fr +Gregory,Wittmann,gregory.wittmann4@etu.univ-lorraine.fr +Lucas,Marchal,lucas.marchal7@etu.univ-lorraine.fr +Amadou,Sow,amadou.sow5@etu.univ-lorraine.fr +Evan,Ferroli-Touiti,evan.ferroli-touiti1@etu.univ-lorraine.fr +Tom,Rouillon,tom.rouillon3@etu.univ-lorraine.fr +Flavien,Marck,flavien.marck7@etu.univ-lorraine.fr +Ugo,Claus,ugo.claus2@etu.univ-lorraine.fr +Dorian,George,dorian.george8@etu.univ-lorraine.fr +Loris,Belgeri,loris.belgeri9@etu.univ-lorraine.fr +Camille,Duchateau,camille.duchateau9@etu.univ-lorraine.fr +Gabriel,Atgie-Moro,gabriel.atgie-moro9@etu.univ-lorraine.fr +Tristan,Berger,tristan.berger9@etu.univ-lorraine.fr +Louise,Berrada-Gouzi,louise.berrada1@etu.univ-lorraine.fr +Rolf,Bileli,rolf.bileli1@etu.univ-lorraine.fr +Louis,Canova,louis.canova9@etu.univ-lorraine.fr +Noemy,Chevalier,noemy.chevalier7@etu.univ-lorraine.fr +Quentin,Courrier,quentin.courrier2@etu.univ-lorraine.fr +Antoine,Damien,antoine.damien6@etu.univ-lorraine.fr +Samuel,Dejoux,samuel.dejoux5@etu.univ-lorraine.fr +Charles,Dommange,charles.dommange8@etu.univ-lorraine.fr +Nicolas,Duwig,nicolas.duwig3@etu.univ-lorraine.fr +Jeremie,Gavin,jeremie.gavin7@etu.univ-lorraine.fr +Kevin,Grelin,kevin.grelin5@etu.univ-lorraine.fr +Louis,Guery,louis.guery9@etu.univ-lorraine.fr +Adame,Hayaf,adame.hayaf9@etu.univ-lorraine.fr +Rinor,Januzi,rinor.januzi7@etu.univ-lorraine.fr +Bastien,Kappler,bastien.kappler4@etu.univ-lorraine.fr +Nathan,Lantz,nathan.lantz1@etu.univ-lorraine.fr +Leon,Le-Berre,leon.le-berre5@etu.univ-lorraine.fr +Gwendal,Le-Hyoncour,gwendal.le-hyoncour6@etu.univ-lorraine.fr +Rayan,Mammeri,rayan.mammeri8@etu.univ-lorraine.fr +Thomas,Oppe,thomas.oppe5@etu.univ-lorraine.fr +Kyriann,Paille,kyriann.paille9@etu.univ-lorraine.fr +Jean-Baptiste,Paquin,jean-baptiste.paquin7@etu.univ-lorraine.fr +Luka,Perlato,luka.perlato8@etu.univ-lorraine.fr +Lucas,Plateau,lucas.plateau6@etu.univ-lorraine.fr +Lobsang,Rigard,lobsang.rigard1@etu.univ-lorraine.fr +Diego,Riviere-Jombart,diego.riviere-jombart9@etu.univ-lorraine.fr +Fatih,Tastan,fatih.tastan6@etu.univ-lorraine.fr +Kenzo,Tisselin,kenzo.tisselin3@etu.univ-lorraine.fr +Ewan,Urbanc,ewan.urbanc3@etu.univ-lorraine.fr +Emile,Haas,emile.haas8@etu.univ-lorraine.fr +Ethan,Anclin,ethan.anclin1@etu.univ-lorraine.fr +Julio,Soares,julio.soares2@etu.univ-lorraine.fr +Samuel,Binckly,samuel.binckly4@etu.univ-lorraine.fr +Owenn,Bigotte,owenn.bigotte6@etu.univ-lorraine.fr +Corentin,Piquerez,corentin.piquerez1@etu.univ-lorraine.fr diff --git a/Back_end/public/assets/csv/depot.csv b/Back_end/public/assets/csv/depot.csv new file mode 100644 index 0000000000000000000000000000000000000000..531119cdbb47d4a64117a46f9b251bb443bd60f1 --- /dev/null +++ b/Back_end/public/assets/csv/depot.csv @@ -0,0 +1,165 @@ +id_jardin,nom +1,IUT de Saint Dié des Vosges +1,Salle des fêtes de St Michel +1,Salle polyvalente d'Étival Clairefontaine +1,La Halle aux Blés +1,Collège de Baccarat +1,Village du livre +1,Lycée d'horticulture +1,Emmaüs Rambervillers +1,Four Grand-Mère +1,Fraispertuis City +1,Le Gaming 88 +1,Lycée Georges Baumont +1,Nouvelle Salaison des Hautes-Vosges +1,Brasserie de l'Abbaye +1,Château des princes de Salm +1,Château de Belval +1,Boulangerie Claulin +1,Hôtel Restaurant Julien +1,Biscuiterie du Col de Saales +1,CC de la Fave +1,Association Elan +1,Salle Multi-activités +1,INSIC +1,Salle Polyvalente +1,Le Domaine des Bans +1,Lycée Hôtellier +1,Fromagerie Gérard +1,Boucherie de la Place +1,AFPA Remiremont +1,Cabaret Bellecour +1,Le Foyer +1,Hôpital de Bruyères +1,Restaurant les Myrtilles +1,IFSI +1,Mairie de Neuvillers +1,Mairie Ban de Laveline17 +1,Centre d'Animation Municipal2037 +1,Musée des Eaux de Vie203831 +1,Evergreen Tomatoes09 +1,Hôtel au Tilleul0 +1,Office du Tourisme de Munster +1,Centre les Jonquilles +1,Gîte le Vic +1,Moulin Clefcy +1,Le grenier de Papy +1,Salle des fêtes de Saulcy +1,Lycée professionnel Notre-Dame de la Providence +1,Foyer rural +1,Fromagerie Gourmand’Art +1,Maison rurale Saulxures +1,Café Canton +1,ENSTIB +1,Assotiation AMI +1,Moustache Bikes +1,Moulin de Nomexy +1,Maison du Livre +1,Centre culturel +1,Mairie de Gerbéviller +1,Mairie de Badonviller +1,Hôtel des lacs +1,La chèvre vagabonde +1,Resto du coeur +1,Les jardins de Callunes +1,Mairie d'Hurbache +2,Eglise Saint Antoine +2,Ligue de l’enseignement +2,Centre Léo Lagrange +2,APF - Local extérieur – ESAT +2,Ecodenn’ergie +2,Botanic +2,Chambre d’Agriculture +2,Pharmacie Robert +2,Association GACI +2,Office du tourisme +2,Raon aux Bois +2,Mr et Mme Boulassel +2,Jardins de Cocagne0, +2,Madame Pierot +2,"3ème Rive Café Associatif", +2,Point Vert Mafra +2,Brico Marché +2,Pro & Cie +2,M. Lecomte François +2,Maison de l'Étudiant +2,La Tête à Toto +4,Jardins de Cocagne0 +4,Maison de Quartier du Vieux-Lille +4,La cave de Jules +4,Traiteur Veys +4,Polytech +4,Boucherie François +4,Un Ours et les Etoiles +4,Boulangerie Picavet +4,Bar Moulins d'Ascq +2,Secours Catholique +2,Conseil Départemental des Vosges +2,Association Rhyzome +2,Denninger +édit Agricole Épinal +2,Adinolfi +2,Papeterie Golbey Norske Skog +2,Vosgelis (Épinal) +2,Vosgelis (Remiremont) +2,Renouveau +2,DVIS +2,Maison de l'environnement +2,Peridon +2,Bouvier Emmanuel +2,La Quarterelle +2,Moustache Bikes +2,Biocoop Épinal +4,El Market +4,La Nature a du Génie +4,CCAS de Lambersart +4,Les Pieds sur Terre +4,Boucherie Ludovic Monchy +4,Le Caméléon Gourmand +4,Polygonum Fleuriste +4,Harmonie Nature +4,Boulangerie Aux Blés d'Or +4,Top Fleurs +4,Dépannage D. Buisine +4,Bio'tiful Nature +4,Allo Fleurs +4,Monsieur Vin +4,La Moulinette +4,Cuvelier & Fauvarque +4,Monsieur Vin (Lomme), +4,Biocoop HemHEM +4,Le Relais Gourmand +4,Biocoop Biovalys +4,Boucherie-Traiteur Dierickx +4,Ancolie Fleuriste +4,Monsieur Vin (Mouvaux), +4,La Maison Nouvelle +4,Biocoop Saveurs et Saisons +4,La Campusserie Pont de Bois +4,So végétal (Bondues), +4,L'olivier blanc +4,La maison du vin +4,Boulangerie Catrisse +4,Boulangerie Delmeulle +4,Boucherie Lamandin +4,L.S.I +4,Fred Réception +4,Le Trèfle à Quatre Fleurs +4,Boucherie Chez Florentin +4,Boucherie du Bourg +4,Biocoop Hénin Beaumont +4,Le Panier Fleuri +4,Ethique & Vrac +4,Biocoop Saveurs et Saisons Bouvines +4,La Chouette Librairie +4,Boulangerie Aux Délices de la Comtesse +4,Salon Cannelle +4,L'Atelier Vélo L.S.I. +4,Rêves de Mômes (Marquette-lez-Lille) +4,Artisans du Monde +4,Au Pain d'Antan +4,La Cave de Frédéric +4,Ceci n'est pas une boulangerie +4,Le bus magique +4,Le Polder +4,Boucherie du Bourg diff --git a/Back_end/public/assets/csv/structure.csv b/Back_end/public/assets/csv/structure.csv new file mode 100644 index 0000000000000000000000000000000000000000..0020eeb0233860088c18eb6460574e1e2756e349 --- /dev/null +++ b/Back_end/public/assets/csv/structure.csv @@ -0,0 +1,6 @@ +nom,adresse +SAÉ IUT Saint-Dié des Vosges,11 Rue de l'Université +Jardins de Cocagne Thaon les Vosges,Prairie Claudel +Oasis Jardin de Cocagne,19 chemin des Muats +Le Jardin de Cocagne de la Haute Borne,Europarc de la haute Borne +Les Jardins de Cocagne en Limousin,13 Allee de Coyol diff --git a/Back_end/src/Controller/AdherentController.php b/Back_end/src/Controller/AdherentController.php index 05afea7818ed41af72206e806d3f6721766c703a..950eff0d381977fd3657b09f338ff4a3e3571641 100644 --- a/Back_end/src/Controller/AdherentController.php +++ b/Back_end/src/Controller/AdherentController.php @@ -2,17 +2,38 @@ namespace App\Controller; +use App\Entity\Adherent; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; +use Doctrine\ORM\EntityManagerInterface; class AdherentController extends AbstractController { - #[Route('/adherent', name: 'app_adherent')] - public function index(): Response + #[Route('/adherent/import', name: 'app_adherent_import')] + public function importAdherents(EntityManagerInterface $entityManager): Response { - return $this->render('adherent/index.html.twig', [ - 'controller_name' => 'AdherentController', - ]); + $root = $this->getParameter('kernel.project_dir'); + + $csvFile = fopen($root.'/public/assets/csv/adherent.csv','r'); + + $firstline = true; + + while($row = fgetcsv($csvFile)) { + if($firstline) { + $firstline = false; + continue; + } + $adherent = new Adherent(); + $adherent + ->setPrenom($row[0]) + ->setNom($row[1]) + ->setMail($row[2]); + $entityManager->persist($adherent); + } + + $entityManager->flush(); + + return new Response('Fichier csv importé !!!'); } } diff --git a/Back_end/src/Controller/PointDeDepotController.php b/Back_end/src/Controller/PointDeDepotController.php new file mode 100644 index 0000000000000000000000000000000000000000..f3e0f1b2923c236933943b946757a4b87ef0b5d1 --- /dev/null +++ b/Back_end/src/Controller/PointDeDepotController.php @@ -0,0 +1,42 @@ +<?php + +namespace App\Controller; + +use App\Entity\PointDeDepot; +use App\Repository\PointDeDepotRepository; +use App\Repository\StructureRepository; +use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; +use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\Routing\Annotation\Route; +use Doctrine\ORM\EntityManagerInterface; + +class PointDeDepotController extends AbstractController +{ + #[Route('/depot/import', name: 'app_depot_import')] + public function importAdherents(EntityManagerInterface $entityManager, StructureRepository $structureRepository): Response + { + $root = $this->getParameter('kernel.project_dir'); + + $csvFile = fopen($root.'/public/assets/csv/depot.csv','r'); + + $firstline = true; + + while($row = fgetcsv($csvFile)) { + if($firstline) { + $firstline = false; + continue; + } + $pdd = new PointDeDepot(); + $pdd->setAdresse($row[1]); + $structure = $structureRepository->findById(intval($row[0])); + + $pdd->setStructureId($structure); + + $entityManager->persist($pdd); + } + + $entityManager->flush(); + + return new Response('Fichier csv importé !!!'); + } +} diff --git a/Back_end/src/Controller/StructureController.php b/Back_end/src/Controller/StructureController.php new file mode 100644 index 0000000000000000000000000000000000000000..885de045d0927da8d0692d3a02626bd19bf5a849 --- /dev/null +++ b/Back_end/src/Controller/StructureController.php @@ -0,0 +1,42 @@ +<?php + +namespace App\Controller; + +use App\Entity\Structure; +use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; +use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\Routing\Annotation\Route; +use Doctrine\ORM\EntityManagerInterface; + +class StructureController extends AbstractController +{ + #[Route('/structure/import', name: 'app_structure_import')] + public function importAdherents(EntityManagerInterface $entityManager): Response + { + $root = $this->getParameter('kernel.project_dir'); + + $csvFile = fopen($root.'/public/assets/csv/structure.csv','r'); + + $firstline = true; + + while($row = fgetcsv($csvFile)) { + if($firstline) { + $firstline = false; + continue; + } + $structure = new Structure(); + $structure + ->setNom($row[0]) + ->setAdresse($row[1]) + ->setVille('') + ->setRaisonSoc('') + ->setTelephone(''); + + $entityManager->persist($structure); + } + + $entityManager->flush(); + + return new Response('Fichier csv importé !!!'); + } +} diff --git a/Back_end/src/Entity/Adherent.php b/Back_end/src/Entity/Adherent.php index 31a0c172e6f6da2f4de31349b607e8ac8eaaff22..b7d2b5453f7707f7852ca5cee75bc2f623cef91b 100644 --- a/Back_end/src/Entity/Adherent.php +++ b/Back_end/src/Entity/Adherent.php @@ -18,10 +18,10 @@ class Adherent #[ORM\Column] private ?int $id = null; - #[ORM\Column(length: 100)] + #[ORM\Column(length: 100, nullable: true)] private ?string $raisonSociale = null; - #[ORM\Column(length: 10)] + #[ORM\Column(length: 10, nullable: true)] private ?string $civilite = null; #[ORM\Column(length: 45, nullable: true)] diff --git a/Back_end/src/Entity/Structure.php b/Back_end/src/Entity/Structure.php index 1b024380e0ef2369b473c891beba9b9dff2d7d9b..4d882cf0292df3caac470698aecf1ff9a2d6f9e0 100644 --- a/Back_end/src/Entity/Structure.php +++ b/Back_end/src/Entity/Structure.php @@ -17,9 +17,6 @@ class Structure #[ORM\Column] private ?int $id = null; - #[ORM\Column] - private ?int $idStructure = null; - #[ORM\Column(length: 45)] private ?string $nom = null; @@ -64,18 +61,6 @@ class Structure return $this->id; } - public function getIdStructure(): ?int - { - return $this->idStructure; - } - - public function setIdStructure(int $idStructure): static - { - $this->idStructure = $idStructure; - - return $this; - } - public function getNom(): ?string { return $this->nom; diff --git a/Back_end/src/Repository/StructureRepository.php b/Back_end/src/Repository/StructureRepository.php index 2e9c709fdd95f6409ffbc7b3689632ce56736f05..909957ba50b7743b158bb7906ed3aa2b1f4ded6f 100644 --- a/Back_end/src/Repository/StructureRepository.php +++ b/Back_end/src/Repository/StructureRepository.php @@ -5,6 +5,7 @@ namespace App\Repository; use App\Entity\Structure; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Persistence\ManagerRegistry; +use phpDocumentor\Reflection\Types\Integer; /** * @extends ServiceEntityRepository<Structure> @@ -21,6 +22,13 @@ class StructureRepository extends ServiceEntityRepository parent::__construct($registry, Structure::class); } + public function findById(int $id) { + $qb = $this->createQueryBuilder('s'); + $qb->andWhere('s.id = :id')->setParameter('id', $id); + + return $qb->getQuery()->getResult(); + } + // /** // * @return Structure[] Returns an array of Structure objects // */ diff --git a/Back_end/templates/adherent/index.html.twig b/Back_end/templates/adherent/index.html.twig deleted file mode 100644 index f27e696be830798b32f729e4d67ceca0fd1b6080..0000000000000000000000000000000000000000 --- a/Back_end/templates/adherent/index.html.twig +++ /dev/null @@ -1,20 +0,0 @@ -{% extends 'base.html.twig' %} - -{% block title %}Hello AdherentController!{% endblock %} - -{% block body %} -<style> - .example-wrapper { margin: 1em auto; max-width: 800px; width: 95%; font: 18px/1.5 sans-serif; } - .example-wrapper code { background: #F5F5F5; padding: 2px 6px; } -</style> - -<div class="example-wrapper"> - <h1>Hello {{ controller_name }}! ✅</h1> - - This friendly message is coming from: - <ul> - <li>Your controller at <code><a href="{{ '/var/www/symfony_docker/src/Controller/AdherentController.php'|file_link(0) }}">src/Controller/AdherentController.php</a></code></li> - <li>Your template at <code><a href="{{ '/var/www/symfony_docker/templates/adherent/index.html.twig'|file_link(0) }}">templates/adherent/index.html.twig</a></code></li> - </ul> -</div> -{% endblock %}