diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml new file mode 100644 index 0000000..08c0eb6 --- /dev/null +++ b/.idea/dataSources.xml @@ -0,0 +1,12 @@ + + + + + postgresql + true + org.postgresql.Driver + jdbc:postgresql://172.20.96.1:5432/chauffageproj + $ProjectFileDir$ + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml index d042e16..966b661 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -5,8 +5,18 @@ - + + + + + + + + + + + $PROJECT_DIR$/composer.json - + + + - + @@ -166,14 +178,20 @@ @@ -190,8 +208,8 @@ - @@ -206,6 +224,9 @@ + + + diff --git a/src/Controller/FaultController.php b/src/Controller/FaultController.php index 4267375..dc9d09a 100644 --- a/src/Controller/FaultController.php +++ b/src/Controller/FaultController.php @@ -2,17 +2,49 @@ namespace App\Controller; +use App\Entity\Fault; +use App\Form\FaultType; +use App\Repository\FaultRepository; +use Doctrine\ORM\EntityManagerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\Routing\Attribute\Route; - +use Symfony\Component\Routing\Annotation\Route; class FaultController extends AbstractController { - #[Route('/fault', name: 'app_fault')] - public function index(): Response + public function __construct( + private readonly EntityManagerInterface $entityManager, + private readonly FaultRepository $faultRepository + ) { - return $this->render('fault/index.html.twig', [ - 'controller_name' => 'FaultController', + } + #[Route('/fault/add', name: 'fault_add')] + public function add(Request $request): Response + { + $fault = new Fault(); + $form = $this->createForm(FaultType::class, $fault); + $form->handleRequest($request); + + if($form->isSubmitted() && $form->isValid()) + { + $this->entityManager->persist($fault); + $this->entityManager->flush(); + + return $this->redirectToRoute("app_fault_list"); + } + + return $this->render('fault/add.html.twig', [ + 'form' => $form, ]); } -} + + #[Route('/fault/list', name: 'fault_list')] + public function list(): Response + { + $fault = $this->faultRepository->findAll(); + + return $this->render('fault/list.html.twig', [ + 'fault' => $fault, + ]); + } +} \ No newline at end of file diff --git a/src/Controller/InterventionController.php b/src/Controller/InterventionController.php index 1f752e6..4c9b0c6 100644 --- a/src/Controller/InterventionController.php +++ b/src/Controller/InterventionController.php @@ -2,17 +2,50 @@ namespace App\Controller; +use App\Entity\Intervention; +use App\Form\InterventionType; +use App\Repository\InterventionRepository; +use Doctrine\ORM\EntityManagerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; class InterventionController extends AbstractController { - #[Route('/intervention', name: 'app_intervention')] - public function index(): Response + public function __construct( + private readonly EntityManagerInterface $entityManager, + private readonly InterventionRepository $interventionRepository + ) { - return $this->render('intervention/index.html.twig', [ - 'controller_name' => 'InterventionController', + } + #[\Symfony\Component\Routing\Annotation\Route('/intervention/add', name: 'fault_add')] + public function add(Request $request): Response + { + $fault = new Intervention(); + $form = $this->createForm(InterventionType::class, $fault); + $form->handleRequest($request); + + if($form->isSubmitted() && $form->isValid()) + { + $this->entityManager->persist($fault); + $this->entityManager->flush(); + + return $this->redirectToRoute("app_fault_list"); + } + + return $this->render('fault/add.html.twig', [ + 'form' => $form, ]); } -} + + #[Route('/fault/list', name: 'fault_list')] + public function list(): Response + { + $fault = $this->faultRepository->findAll(); + + return $this->render('fault/list.html.twig', [ + 'fault' => $fault, + ]); + } +} \ No newline at end of file diff --git a/src/Controller/LoginController.php b/src/Controller/LoginController.php deleted file mode 100644 index 4946695..0000000 --- a/src/Controller/LoginController.php +++ /dev/null @@ -1,18 +0,0 @@ -render('login/index.html.twig', [ - 'controller_name' => 'LoginController', - ]); - } -} diff --git a/src/Controller/SkillController.php b/src/Controller/SkillController.php index 810fb3c..c828d2a 100644 --- a/src/Controller/SkillController.php +++ b/src/Controller/SkillController.php @@ -11,7 +11,7 @@ class SkillController extends AbstractController #[Route('/skill', name: 'app_skill')] public function index(): Response { - return $this->render('skill/index.html.twig', [ + return $this->render('skill/add.html.twig', [ 'controller_name' => 'SkillController', ]); } diff --git a/src/Controller/StockController.php b/src/Controller/StockController.php index a0400ed..52df48c 100644 --- a/src/Controller/StockController.php +++ b/src/Controller/StockController.php @@ -2,17 +2,69 @@ namespace App\Controller; +use App\Entity\Stock; +use App\Form\StockType; +use App\Repository\StockRepository; +use Doctrine\ORM\EntityManagerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\Routing\Attribute\Route; +use Symfony\Component\Routing\Annotation\Route; class StockController extends AbstractController { - #[Route('/stock', name: 'app_stock')] - public function index(): Response + public function __construct( + private readonly EntityManagerInterface $entityManager, + private readonly StockRepository $stockRepository + ) { - return $this->render('stock/index.html.twig', [ - 'controller_name' => 'StockController', + } + + #[Route('/stock/add', name: 'stock_add')] + public function add(Request $request): Response + { + $stock = new Stock(); + $form = $this->createForm(StockType::class, $stock); + $form->handleRequest($request); + + if($form->isSubmitted() && $form->isValid()) + { + $this->entityManager->persist($stock); + $this->entityManager->flush(); + } + + return $this->render('stock/add.html.twig', [ + 'form' => $form, ]); } -} + + #[Route('/stock/list', name: 'stock_list')] + public function list(): Response + { + $stocks = $this->stockRepository->findAll(); + + return $this->render('stock/list.html.twig', [ + 'stocks' => $stocks, + ]); + } + + #[Route('/stock/update/{id}', name: 'stock_update')] + public function update(int $id, Request $request): Response + { + $stock = $this->stockRepository->find($id); + $form = $this->createForm(StockType::class, $stock); + $form->handleRequest($request); + + if($form->isSubmitted() && $form->isValid()) + { + $this->entityManager->persist($stock); + $this->entityManager->flush(); + } + + return $this->render('stock/add.html.twig', [ + 'form' => $form, + ]); + } + + +} \ No newline at end of file diff --git a/src/Controller/UserController.php b/src/Controller/UserController.php index 25942d8..70588d5 100644 --- a/src/Controller/UserController.php +++ b/src/Controller/UserController.php @@ -2,17 +2,77 @@ namespace App\Controller; +use App\Entity\User; +use App\Form\UserType; +use App\Repository\UserRepository; +use Doctrine\ORM\EntityManagerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\Routing\Attribute\Route; +use Symfony\Component\Routing\Annotation\Route; class UserController extends AbstractController { - #[Route('/user', name: 'app_user')] - public function index(): Response + public function __construct( + private readonly EntityManagerInterface $entityManager, + private readonly UserRepository $userRepository + ) { - return $this->render('user/index.html.twig', [ - 'controller_name' => 'UserController', + } + + #[Route('/user/add', name: 'user_add')] + public function add(Request $request): Response + { + $user = new User(); + $form = $this->createForm(UserType::class, $user); + $form->handleRequest($request); + + if($form->isSubmitted() && $form->isValid()) + { + $this->entityManager->persist($user); + $this->entityManager->flush(); + } + + return $this->render('user/add.html.twig', [ + 'form' => $form, ]); } + + #[Route('/user/list', name: 'user_list')] + public function list(): Response + { + $users = $this->userRepository->findAll(); + + return $this->render('user/list.html.twig', [ + 'users' => $users, + ]); + } + + #[Route('/user/update/{id}', name: 'user_update')] + public function update(int $id, Request $request): Response + { + $user = $this->userRepository->find($id); + $form = $this->createForm(UserType::class, $user); + $form->handleRequest($request); + + if($form->isSubmitted() && $form->isValid()) + { + $this->entityManager->persist($user); + $this->entityManager->flush(); + } + + return $this->render('user/add.html.twig', [ + 'form' => $form, + ]); + } + + #[Route('/user/delete/{id}', name: '_delete')] + public function delete(int $id): Response + { + $user = $this->userRepository->find($id); + $this->entityManager->remove($user); + $this->entityManager->flush(); + + return $this->redirectToRoute('app_user_list'); + } } diff --git a/src/Controller/VehicleController.php b/src/Controller/VehicleController.php index 80068bd..ffc6bf0 100644 --- a/src/Controller/VehicleController.php +++ b/src/Controller/VehicleController.php @@ -11,7 +11,7 @@ class VehicleController extends AbstractController #[Route('/vehicle', name: 'app_vehicle')] public function index(): Response { - return $this->render('vehicle/index.html.twig', [ + return $this->render('vehicle/add.html.twig', [ 'controller_name' => 'VehicleController', ]); } diff --git a/src/Form/FaultType.php b/src/Form/FaultType.php new file mode 100644 index 0000000..9960312 --- /dev/null +++ b/src/Form/FaultType.php @@ -0,0 +1,28 @@ +add('Wording', TextType::class) + ->add('save', SubmitType::class) + ; + } + + public function configureOptions(OptionsResolver $resolver): void + { + $resolver->setDefaults([ + // Configure your form options here + ]); + } +} diff --git a/src/Form/StockType.php b/src/Form/StockType.php new file mode 100644 index 0000000..a8480f7 --- /dev/null +++ b/src/Form/StockType.php @@ -0,0 +1,33 @@ +add('Wording', TextType::class) + ->add('Description', TextType::class) + ->add('Quantity', IntegerType::class) + ->add('save', SubmitType::class) + ; + } + + public function configureOptions(OptionsResolver $resolver): void + { + $resolver->setDefaults([ + 'data_class' => Stock::class, + ]); + } +} diff --git a/src/Form/UserType.php b/src/Form/UserType.php new file mode 100644 index 0000000..7bef9c4 --- /dev/null +++ b/src/Form/UserType.php @@ -0,0 +1,35 @@ +add('FirstName', TextType::class) + ->add('LastName', TextType::class) + ->add('BirthDate', DateType::class) + ->add('Email', EmailType::class) + ->add('Phone', TextType::class) + ->add('Type', TextType::class) + ->add('Save', SubmitType::class) + ; + } + + public function configureOptions(OptionsResolver $resolver): void + { + $resolver->setDefaults([ + 'data_class' => User::class, + ]); + } +} diff --git a/templates/fault/add.html.twig b/templates/fault/add.html.twig new file mode 100644 index 0000000..601e2ec --- /dev/null +++ b/templates/fault/add.html.twig @@ -0,0 +1,10 @@ +{% extends 'base.html.twig' %} + +{% block title %}Ajouter une panne{% endblock %} + +{% block body %} +

Ajouter une panne

+ + {{ form(form) }} + +{% endblock %} diff --git a/templates/fault/index.html.twig b/templates/fault/index.html.twig deleted file mode 100644 index d3b62c1..0000000 --- a/templates/fault/index.html.twig +++ /dev/null @@ -1,20 +0,0 @@ -{% extends 'base.html.twig' %} - -{% block title %}Hello FaultController!{% endblock %} - -{% block body %} - - -
-

Hello {{ controller_name }}! ✅

- - This friendly message is coming from: -
    -
  • Your controller at E:/BTS/PhpStorm/HegreEtConfort/src/Controller/FaultController.php
  • -
  • Your template at E:/BTS/PhpStorm/HegreEtConfort/templates/fault/index.html.twig
  • -
-
-{% endblock %} diff --git a/templates/fault/list.html.twig b/templates/fault/list.html.twig new file mode 100644 index 0000000..1a84c39 --- /dev/null +++ b/templates/fault/list.html.twig @@ -0,0 +1,9 @@ +{% extends 'base.html.twig' %} + +{% block title %}Hello UserController!{% endblock %} + +{% block body %} + {% for user in users %} + {{ fault.Wording }} + {% endfor %} +{% endblock %} \ No newline at end of file diff --git a/templates/stock/add.html.twig b/templates/stock/add.html.twig new file mode 100644 index 0000000..0f684e5 --- /dev/null +++ b/templates/stock/add.html.twig @@ -0,0 +1,10 @@ +{% extends 'base.html.twig' %} + +{% block title %}Ajouter un utilisateur{% endblock %} + +{% block body %} +

Ajouter du stock

+ + {{ form(form) }} + +{% endblock %} diff --git a/templates/stock/index.html.twig b/templates/stock/index.html.twig deleted file mode 100644 index 72d4681..0000000 --- a/templates/stock/index.html.twig +++ /dev/null @@ -1,20 +0,0 @@ -{% extends 'base.html.twig' %} - -{% block title %}Hello StockController!{% endblock %} - -{% block body %} - - -
-

Hello {{ controller_name }}! ✅

- - This friendly message is coming from: -
    -
  • Your controller at E:/BTS/PhpStorm/HegreEtConfort/src/Controller/StockController.php
  • -
  • Your template at E:/BTS/PhpStorm/HegreEtConfort/templates/stock/index.html.twig
  • -
-
-{% endblock %} diff --git a/templates/stock/list.html.twig b/templates/stock/list.html.twig new file mode 100644 index 0000000..4cd9c76 --- /dev/null +++ b/templates/stock/list.html.twig @@ -0,0 +1,11 @@ +{% extends 'base.html.twig' %} + +{% block title %}Hello StockController!{% endblock %} + +{% block body %} + {% for stock in stocks %} + {{ stock.Wording }} + {{ stock.Description }} + {{ stock.Quantity }} + {% endfor %} +{% endblock %} \ No newline at end of file diff --git a/templates/user/add.html.twig b/templates/user/add.html.twig new file mode 100644 index 0000000..3440b9d --- /dev/null +++ b/templates/user/add.html.twig @@ -0,0 +1,10 @@ +{# templates/user/add.html.twig #} +{% extends 'base.html.twig' %} + +{% block title %}Ajouter un utilisateur{% endblock %} + +{% block body %} +

Ajouter un utilisateur

+ + {{ form(form) }} +{% endblock %} diff --git a/templates/user/index.html.twig b/templates/user/index.html.twig deleted file mode 100644 index 1f43753..0000000 --- a/templates/user/index.html.twig +++ /dev/null @@ -1,20 +0,0 @@ -{% extends 'base.html.twig' %} - -{% block title %}Hello UserController!{% endblock %} - -{% block body %} - - -
-

Hello {{ controller_name }}! ✅

- - This friendly message is coming from: -
    -
  • Your controller at E:/BTS/PhpStorm/HegreEtConfort/src/Controller/UserController.php
  • -
  • Your template at E:/BTS/PhpStorm/HegreEtConfort/templates/user/index.html.twig
  • -
-
-{% endblock %} diff --git a/templates/user/list.html.twig b/templates/user/list.html.twig new file mode 100644 index 0000000..7477b1e --- /dev/null +++ b/templates/user/list.html.twig @@ -0,0 +1,14 @@ +{% extends 'base.html.twig' %} + +{% block title %}Hello UserController!{% endblock %} + +{% block body %} + {% for user in users %} + {{ user.FirstName }} + {{ user.LastName }} + {{ user.BirthDate|date("Y-m-d") }} + {{ user.Mail }} + {{ user.Phone }} + {{ user.Type }} + {% endfor %} +{% endblock %} \ No newline at end of file