templates

This commit is contained in:
ragueneaul 2024-11-21 16:31:49 +01:00
parent 8c960b5cbe
commit aeb96e4b68
21 changed files with 401 additions and 109 deletions

12
.idea/dataSources.xml Normal file
View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
<data-source source="LOCAL" name="chauffageproj@172.20.96.1" uuid="6554e332-842b-41d7-a021-08782c7b72bb">
<driver-ref>postgresql</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>org.postgresql.Driver</jdbc-driver>
<jdbc-url>jdbc:postgresql://172.20.96.1:5432/chauffageproj</jdbc-url>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
</component>
</project>

View File

@ -5,8 +5,18 @@
</component>
<component name="ChangeListManager">
<list default="true" id="cf8b8ad0-a5ca-449a-93b5-e4441856adec" name="Changes" comment="">
<change beforePath="$PROJECT_DIR$/.idea/vcs.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/templates/user/add.html.twig" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Controller/FaultController.php" beforeDir="false" afterPath="$PROJECT_DIR$/src/Controller/FaultController.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Controller/InterventionController.php" beforeDir="false" afterPath="$PROJECT_DIR$/src/Controller/InterventionController.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Controller/LoginController.php" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/Controller/SkillController.php" beforeDir="false" afterPath="$PROJECT_DIR$/src/Controller/SkillController.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Controller/StockController.php" beforeDir="false" afterPath="$PROJECT_DIR$/src/Controller/StockController.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Controller/UserController.php" beforeDir="false" afterPath="$PROJECT_DIR$/src/Controller/UserController.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Controller/VehicleController.php" beforeDir="false" afterPath="$PROJECT_DIR$/src/Controller/VehicleController.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/templates/fault/index.html.twig" beforeDir="false" afterPath="$PROJECT_DIR$/templates/fault/add.html.twig" afterDir="false" />
<change beforePath="$PROJECT_DIR$/templates/stock/index.html.twig" beforeDir="false" afterPath="$PROJECT_DIR$/templates/stock/add.html.twig" afterDir="false" />
<change beforePath="$PROJECT_DIR$/templates/user/index.html.twig" beforeDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -15,12 +25,14 @@
</component>
<component name="ComposerSettings" synchronizationState="SYNCHRONIZE">
<pharConfigPath>$PROJECT_DIR$/composer.json</pharConfigPath>
<execution />
<execution>
<executable path="composer" />
</execution>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="PhpWorkspaceProjectConfiguration" interpreter_name="C:\xampp\php\php.exe">
<component name="PhpWorkspaceProjectConfiguration" interpreter_name="/bin/php">
<include_path>
<path value="$PROJECT_DIR$/vendor/sebastian/exporter" />
<path value="$PROJECT_DIR$/vendor/sebastian/cli-parser" />
@ -166,14 +178,20 @@
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"RunOnceActivity.ShowReadmeOnStart": "true",
"RunOnceActivity.git.unshallow": "true",
"git-widget-placeholder": "develop",
"last_opened_file_path": "C:/Users/serma/Desktop/HegreEtConfort",
"last_opened_file_path": "/home/ragueneaul@stsio.lan/Documents/DecoMaison_Lucas_Ragueneau",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
"node.js.selected.package.tslint": "(autodetect)",
"nodejs_package_manager_path": "npm",
"vue.rearranger.settings.migration": "true"
},
"keyToStringList": {
"DatabaseDriversLRU": [
"postgresql"
]
}
}]]></component>
<component name="RecentsManager">
@ -190,8 +208,8 @@
<component name="SharedIndexes">
<attachedChunks>
<set>
<option value="bundled-js-predefined-d6986cc7102b-5c90d61e3bab-JavaScript-PS-242.23339.16" />
<option value="bundled-php-predefined-a98d8de5180a-90914f2295cb-com.jetbrains.php.sharedIndexes-PS-242.23339.16" />
<option value="bundled-js-predefined-d6986cc7102b-e768b9ed790e-JavaScript-PS-243.21565.202" />
<option value="bundled-php-predefined-a98d8de5180a-5fbe0c30323e-com.jetbrains.php.sharedIndexes-PS-243.21565.202" />
</set>
</attachedChunks>
</component>
@ -206,6 +224,9 @@
<workItem from="1728656379062" duration="1875000" />
<workItem from="1728671983731" duration="846000" />
<workItem from="1729167245881" duration="2915000" />
<workItem from="1729175702600" duration="1829000" />
<workItem from="1731589591731" duration="13398000" />
<workItem from="1732193975936" duration="8317000" />
</task>
<servers />
</component>

View File

@ -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,
]);
}
}

View File

@ -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,
]);
}
}

View File

@ -1,18 +0,0 @@
<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
class LoginController extends AbstractController
{
#[Route('/login', name: 'app_login')]
public function index(): Response
{
return $this->render('login/index.html.twig', [
'controller_name' => 'LoginController',
]);
}
}

View File

@ -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',
]);
}

View File

@ -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,
]);
}
}

View File

@ -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');
}
}

View File

@ -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',
]);
}

28
src/Form/FaultType.php Normal file
View File

@ -0,0 +1,28 @@
<?php
namespace App\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class FaultType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('Wording', TextType::class)
->add('save', SubmitType::class)
;
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
// Configure your form options here
]);
}
}

33
src/Form/StockType.php Normal file
View File

@ -0,0 +1,33 @@
<?php
namespace App\Form;
use App\Entity\Stock;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class StockType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->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,
]);
}
}

35
src/Form/UserType.php Normal file
View File

@ -0,0 +1,35 @@
<?php
namespace App\Form;
use App\Entity\User;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class UserType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->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,
]);
}
}

View File

@ -0,0 +1,10 @@
{% extends 'base.html.twig' %}
{% block title %}Ajouter une panne{% endblock %}
{% block body %}
<h1>Ajouter une panne</h1>
{{ form(form) }}
{% endblock %}

View File

@ -1,20 +0,0 @@
{% extends 'base.html.twig' %}
{% block title %}Hello FaultController!{% 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>E:/BTS/PhpStorm/HegreEtConfort/src/Controller/FaultController.php</code></li>
<li>Your template at <code>E:/BTS/PhpStorm/HegreEtConfort/templates/fault/index.html.twig</code></li>
</ul>
</div>
{% endblock %}

View File

@ -0,0 +1,9 @@
{% extends 'base.html.twig' %}
{% block title %}Hello UserController!{% endblock %}
{% block body %}
{% for user in users %}
{{ fault.Wording }}
{% endfor %}
{% endblock %}

View File

@ -0,0 +1,10 @@
{% extends 'base.html.twig' %}
{% block title %}Ajouter un utilisateur{% endblock %}
{% block body %}
<h1>Ajouter du stock</h1>
{{ form(form) }}
{% endblock %}

View File

@ -1,20 +0,0 @@
{% extends 'base.html.twig' %}
{% block title %}Hello StockController!{% 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>E:/BTS/PhpStorm/HegreEtConfort/src/Controller/StockController.php</code></li>
<li>Your template at <code>E:/BTS/PhpStorm/HegreEtConfort/templates/stock/index.html.twig</code></li>
</ul>
</div>
{% endblock %}

View File

@ -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 %}

View File

@ -0,0 +1,10 @@
{# templates/user/add.html.twig #}
{% extends 'base.html.twig' %}
{% block title %}Ajouter un utilisateur{% endblock %}
{% block body %}
<h1>Ajouter un utilisateur</h1>
{{ form(form) }}
{% endblock %}

View File

@ -1,20 +0,0 @@
{% extends 'base.html.twig' %}
{% block title %}Hello UserController!{% 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>E:/BTS/PhpStorm/HegreEtConfort/src/Controller/UserController.php</code></li>
<li>Your template at <code>E:/BTS/PhpStorm/HegreEtConfort/templates/user/index.html.twig</code></li>
</ul>
</div>
{% endblock %}

View File

@ -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 %}