Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
ee236ff74a | |||
aeb96e4b68 |
19
.idea/dataSources.xml
Normal file
19
.idea/dataSources.xml
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?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>
|
||||||
|
<data-source source="LOCAL" name="chauffageproj@172.20.96.1 [2]" uuid="a446f2ca-1dfc-459a-97f5-eda71fd74aa2">
|
||||||
|
<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>
|
@ -5,7 +5,6 @@
|
|||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="cf8b8ad0-a5ca-449a-93b5-e4441856adec" name="Changes" comment="">
|
<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 beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
@ -15,12 +14,14 @@
|
|||||||
</component>
|
</component>
|
||||||
<component name="ComposerSettings" synchronizationState="SYNCHRONIZE">
|
<component name="ComposerSettings" synchronizationState="SYNCHRONIZE">
|
||||||
<pharConfigPath>$PROJECT_DIR$/composer.json</pharConfigPath>
|
<pharConfigPath>$PROJECT_DIR$/composer.json</pharConfigPath>
|
||||||
<execution />
|
<execution>
|
||||||
|
<executable path="composer" />
|
||||||
|
</execution>
|
||||||
</component>
|
</component>
|
||||||
<component name="Git.Settings">
|
<component name="Git.Settings">
|
||||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||||
</component>
|
</component>
|
||||||
<component name="PhpWorkspaceProjectConfiguration" interpreter_name="C:\xampp\php\php.exe">
|
<component name="PhpWorkspaceProjectConfiguration" interpreter_name="/bin/php">
|
||||||
<include_path>
|
<include_path>
|
||||||
<path value="$PROJECT_DIR$/vendor/sebastian/exporter" />
|
<path value="$PROJECT_DIR$/vendor/sebastian/exporter" />
|
||||||
<path value="$PROJECT_DIR$/vendor/sebastian/cli-parser" />
|
<path value="$PROJECT_DIR$/vendor/sebastian/cli-parser" />
|
||||||
@ -163,19 +164,25 @@
|
|||||||
<option name="hideEmptyMiddlePackages" value="true" />
|
<option name="hideEmptyMiddlePackages" value="true" />
|
||||||
<option name="showLibraryContents" value="true" />
|
<option name="showLibraryContents" value="true" />
|
||||||
</component>
|
</component>
|
||||||
<component name="PropertiesComponent"><![CDATA[{
|
<component name="PropertiesComponent">{
|
||||||
"keyToString": {
|
"keyToString": {
|
||||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||||
"git-widget-placeholder": "develop",
|
"RunOnceActivity.git.unshallow": "true",
|
||||||
"last_opened_file_path": "C:/Users/serma/Desktop/HegreEtConfort",
|
"git-widget-placeholder": "develop",
|
||||||
"node.js.detected.package.eslint": "true",
|
"last_opened_file_path": "/home/ragueneaul@stsio.lan/Documents/DecoMaison_Lucas_Ragueneau",
|
||||||
"node.js.detected.package.tslint": "true",
|
"node.js.detected.package.eslint": "true",
|
||||||
"node.js.selected.package.eslint": "(autodetect)",
|
"node.js.detected.package.tslint": "true",
|
||||||
"node.js.selected.package.tslint": "(autodetect)",
|
"node.js.selected.package.eslint": "(autodetect)",
|
||||||
"nodejs_package_manager_path": "npm",
|
"node.js.selected.package.tslint": "(autodetect)",
|
||||||
"vue.rearranger.settings.migration": "true"
|
"nodejs_package_manager_path": "npm",
|
||||||
|
"vue.rearranger.settings.migration": "true"
|
||||||
|
},
|
||||||
|
"keyToStringList": {
|
||||||
|
"DatabaseDriversLRU": [
|
||||||
|
"postgresql"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}]]></component>
|
}</component>
|
||||||
<component name="RecentsManager">
|
<component name="RecentsManager">
|
||||||
<key name="CopyFile.RECENT_KEYS">
|
<key name="CopyFile.RECENT_KEYS">
|
||||||
<recent name="E:\BTS\PhpStorm\HegreEtConfort\src\Entity" />
|
<recent name="E:\BTS\PhpStorm\HegreEtConfort\src\Entity" />
|
||||||
@ -190,8 +197,8 @@
|
|||||||
<component name="SharedIndexes">
|
<component name="SharedIndexes">
|
||||||
<attachedChunks>
|
<attachedChunks>
|
||||||
<set>
|
<set>
|
||||||
<option value="bundled-js-predefined-d6986cc7102b-5c90d61e3bab-JavaScript-PS-242.23339.16" />
|
<option value="bundled-js-predefined-d6986cc7102b-e768b9ed790e-JavaScript-PS-243.21565.202" />
|
||||||
<option value="bundled-php-predefined-a98d8de5180a-90914f2295cb-com.jetbrains.php.sharedIndexes-PS-242.23339.16" />
|
<option value="bundled-php-predefined-a98d8de5180a-5fbe0c30323e-com.jetbrains.php.sharedIndexes-PS-243.21565.202" />
|
||||||
</set>
|
</set>
|
||||||
</attachedChunks>
|
</attachedChunks>
|
||||||
</component>
|
</component>
|
||||||
@ -206,6 +213,9 @@
|
|||||||
<workItem from="1728656379062" duration="1875000" />
|
<workItem from="1728656379062" duration="1875000" />
|
||||||
<workItem from="1728671983731" duration="846000" />
|
<workItem from="1728671983731" duration="846000" />
|
||||||
<workItem from="1729167245881" duration="2915000" />
|
<workItem from="1729167245881" duration="2915000" />
|
||||||
|
<workItem from="1729175702600" duration="1829000" />
|
||||||
|
<workItem from="1731589591731" duration="13398000" />
|
||||||
|
<workItem from="1732193975936" duration="8317000" />
|
||||||
</task>
|
</task>
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
|
70
migrations/Version20241121154657.php
Normal file
70
migrations/Version20241121154657.php
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace DoctrineMigrations;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auto-generated Migration: Please modify to your needs!
|
||||||
|
*/
|
||||||
|
final class Version20241121154657 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function getDescription(): string
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this up() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql('CREATE SEQUENCE fault_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
|
||||||
|
$this->addSql('CREATE SEQUENCE intervention_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
|
||||||
|
$this->addSql('CREATE SEQUENCE skill_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
|
||||||
|
$this->addSql('CREATE SEQUENCE stock_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
|
||||||
|
$this->addSql('CREATE SEQUENCE "user_id_seq" INCREMENT BY 1 MINVALUE 1 START 1');
|
||||||
|
$this->addSql('CREATE SEQUENCE vehicle_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
|
||||||
|
$this->addSql('CREATE TABLE fault (id INT NOT NULL, wording VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
|
||||||
|
$this->addSql('CREATE TABLE intervention (id INT NOT NULL, wording VARCHAR(255) NOT NULL, timestamp TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, description VARCHAR(255) NOT NULL, address VARCHAR(255) NOT NULL, status VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
|
||||||
|
$this->addSql('CREATE TABLE skill (id INT NOT NULL, wording VARCHAR(255) NOT NULL, description VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
|
||||||
|
$this->addSql('CREATE TABLE stock (id INT NOT NULL, wording VARCHAR(255) NOT NULL, description VARCHAR(255) NOT NULL, quantity VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
|
||||||
|
$this->addSql('CREATE TABLE "user" (id INT NOT NULL, first_name VARCHAR(255) NOT NULL, last_name VARCHAR(255) NOT NULL, birth_date DATE NOT NULL, email VARCHAR(255) NOT NULL, phone VARCHAR(255) NOT NULL, type VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
|
||||||
|
$this->addSql('CREATE TABLE vehicle (id INT NOT NULL, license_plate VARCHAR(255) NOT NULL, brand VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
|
||||||
|
$this->addSql('CREATE TABLE messenger_messages (id BIGSERIAL NOT NULL, body TEXT NOT NULL, headers TEXT NOT NULL, queue_name VARCHAR(190) NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, available_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, delivered_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, PRIMARY KEY(id))');
|
||||||
|
$this->addSql('CREATE INDEX IDX_75EA56E0FB7336F0 ON messenger_messages (queue_name)');
|
||||||
|
$this->addSql('CREATE INDEX IDX_75EA56E0E3BD61CE ON messenger_messages (available_at)');
|
||||||
|
$this->addSql('CREATE INDEX IDX_75EA56E016BA31DB ON messenger_messages (delivered_at)');
|
||||||
|
$this->addSql('COMMENT ON COLUMN messenger_messages.created_at IS \'(DC2Type:datetime_immutable)\'');
|
||||||
|
$this->addSql('COMMENT ON COLUMN messenger_messages.available_at IS \'(DC2Type:datetime_immutable)\'');
|
||||||
|
$this->addSql('COMMENT ON COLUMN messenger_messages.delivered_at IS \'(DC2Type:datetime_immutable)\'');
|
||||||
|
$this->addSql('CREATE OR REPLACE FUNCTION notify_messenger_messages() RETURNS TRIGGER AS $$
|
||||||
|
BEGIN
|
||||||
|
PERFORM pg_notify(\'messenger_messages\', NEW.queue_name::text);
|
||||||
|
RETURN NEW;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE plpgsql;');
|
||||||
|
$this->addSql('DROP TRIGGER IF EXISTS notify_trigger ON messenger_messages;');
|
||||||
|
$this->addSql('CREATE TRIGGER notify_trigger AFTER INSERT OR UPDATE ON messenger_messages FOR EACH ROW EXECUTE PROCEDURE notify_messenger_messages();');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this down() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql('CREATE SCHEMA public');
|
||||||
|
$this->addSql('DROP SEQUENCE fault_id_seq CASCADE');
|
||||||
|
$this->addSql('DROP SEQUENCE intervention_id_seq CASCADE');
|
||||||
|
$this->addSql('DROP SEQUENCE skill_id_seq CASCADE');
|
||||||
|
$this->addSql('DROP SEQUENCE stock_id_seq CASCADE');
|
||||||
|
$this->addSql('DROP SEQUENCE "user_id_seq" CASCADE');
|
||||||
|
$this->addSql('DROP SEQUENCE vehicle_id_seq CASCADE');
|
||||||
|
$this->addSql('DROP TABLE fault');
|
||||||
|
$this->addSql('DROP TABLE intervention');
|
||||||
|
$this->addSql('DROP TABLE skill');
|
||||||
|
$this->addSql('DROP TABLE stock');
|
||||||
|
$this->addSql('DROP TABLE "user"');
|
||||||
|
$this->addSql('DROP TABLE vehicle');
|
||||||
|
$this->addSql('DROP TABLE messenger_messages');
|
||||||
|
}
|
||||||
|
}
|
@ -2,17 +2,49 @@
|
|||||||
|
|
||||||
namespace App\Controller;
|
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\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Routing\Attribute\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
|
|
||||||
class FaultController extends AbstractController
|
class FaultController extends AbstractController
|
||||||
{
|
{
|
||||||
#[Route('/fault', name: 'app_fault')]
|
public function __construct(
|
||||||
public function index(): Response
|
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,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
@ -2,17 +2,50 @@
|
|||||||
|
|
||||||
namespace App\Controller;
|
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\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Routing\Attribute\Route;
|
use Symfony\Component\Routing\Attribute\Route;
|
||||||
|
|
||||||
class InterventionController extends AbstractController
|
class InterventionController extends AbstractController
|
||||||
{
|
{
|
||||||
#[Route('/intervention', name: 'app_intervention')]
|
public function __construct(
|
||||||
public function index(): Response
|
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,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
@ -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',
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
@ -11,7 +11,7 @@ class SkillController extends AbstractController
|
|||||||
#[Route('/skill', name: 'app_skill')]
|
#[Route('/skill', name: 'app_skill')]
|
||||||
public function index(): Response
|
public function index(): Response
|
||||||
{
|
{
|
||||||
return $this->render('skill/index.html.twig', [
|
return $this->render('skill/add.html.twig', [
|
||||||
'controller_name' => 'SkillController',
|
'controller_name' => 'SkillController',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@ -2,17 +2,69 @@
|
|||||||
|
|
||||||
namespace App\Controller;
|
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\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Routing\Attribute\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
|
|
||||||
class StockController extends AbstractController
|
class StockController extends AbstractController
|
||||||
{
|
{
|
||||||
#[Route('/stock', name: 'app_stock')]
|
public function __construct(
|
||||||
public function index(): Response
|
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,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -2,17 +2,77 @@
|
|||||||
|
|
||||||
namespace App\Controller;
|
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\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Routing\Attribute\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
|
|
||||||
class UserController extends AbstractController
|
class UserController extends AbstractController
|
||||||
{
|
{
|
||||||
#[Route('/user', name: 'app_user')]
|
public function __construct(
|
||||||
public function index(): Response
|
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');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ class VehicleController extends AbstractController
|
|||||||
#[Route('/vehicle', name: 'app_vehicle')]
|
#[Route('/vehicle', name: 'app_vehicle')]
|
||||||
public function index(): Response
|
public function index(): Response
|
||||||
{
|
{
|
||||||
return $this->render('vehicle/index.html.twig', [
|
return $this->render('vehicle/add.html.twig', [
|
||||||
'controller_name' => 'VehicleController',
|
'controller_name' => 'VehicleController',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
28
src/Form/FaultType.php
Normal file
28
src/Form/FaultType.php
Normal 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
33
src/Form/StockType.php
Normal 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
35
src/Form/UserType.php
Normal 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,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
10
templates/fault/add.html.twig
Normal file
10
templates/fault/add.html.twig
Normal 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 %}
|
@ -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 %}
|
|
9
templates/fault/list.html.twig
Normal file
9
templates/fault/list.html.twig
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{% extends 'base.html.twig' %}
|
||||||
|
|
||||||
|
{% block title %}Hello UserController!{% endblock %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
{% for user in users %}
|
||||||
|
{{ fault.Wording }}
|
||||||
|
{% endfor %}
|
||||||
|
{% endblock %}
|
10
templates/stock/add.html.twig
Normal file
10
templates/stock/add.html.twig
Normal 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 %}
|
@ -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 %}
|
|
11
templates/stock/list.html.twig
Normal file
11
templates/stock/list.html.twig
Normal 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 %}
|
10
templates/user/add.html.twig
Normal file
10
templates/user/add.html.twig
Normal 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 %}
|
@ -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 %}
|
|
14
templates/user/list.html.twig
Normal file
14
templates/user/list.html.twig
Normal 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.Email }}
|
||||||
|
{{ user.Phone }}
|
||||||
|
{{ user.Type }}
|
||||||
|
{% endfor %}
|
||||||
|
{% endblock %}
|
Loading…
Reference in New Issue
Block a user