add
This commit is contained in:
parent
4efbc3c680
commit
755b6c2ccb
34 changed files with 986 additions and 13 deletions
|
|
@ -33,6 +33,7 @@ security:
|
|||
access_control:
|
||||
- { path: ^/admin, roles: ROLE_Root }
|
||||
- { path: ^/chef, roles: "ROLE_Root, ROLE_Chef" }
|
||||
- { path: ^/service, roles: "ROLE_Root, ROLE_Chef, ROLE_Waiter" }
|
||||
# - { path: ^/profile, roles: ROLE_USER }
|
||||
|
||||
when@test:
|
||||
|
|
|
|||
31
migrations/Version20231127080747.php
Normal file
31
migrations/Version20231127080747.php
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<?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 Version20231127080747 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 TABLE resa (id INT AUTO_INCREMENT NOT NULL, id_resto INT NOT NULL, nb_user INT NOT NULL, date_heur DATETIME NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('DROP TABLE resa');
|
||||
}
|
||||
}
|
||||
122
src/Controller/AvisController.php
Normal file
122
src/Controller/AvisController.php
Normal file
|
|
@ -0,0 +1,122 @@
|
|||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Entity\Avis;
|
||||
use App\Form\AvisType;
|
||||
use App\Repository\AvisRepository;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use App\Repository\UserRepository;
|
||||
use App\Repository\TicketRepository;
|
||||
use App\Entity\Ticket;
|
||||
|
||||
#[Route('/avis')]
|
||||
class AvisController extends AbstractController
|
||||
{
|
||||
private $id_resto;
|
||||
private $id_user;
|
||||
private $userRepository;
|
||||
private $restoRepository;
|
||||
private $role_user;
|
||||
|
||||
public function __construct(userRepository $userRepository, Security $security)
|
||||
{
|
||||
$utilisateur = $security->getUser();
|
||||
$email_user = $utilisateur->getUserIdentifier();
|
||||
|
||||
$user = $userRepository->findOneBy(['email' => $email_user]);
|
||||
|
||||
$role_user = $user->getGrade();
|
||||
$id_resto = $user->getIdResto();
|
||||
$id_user = $user->getId();
|
||||
|
||||
$this->role_user = $role_user;
|
||||
$this->id_resto = $id_resto;
|
||||
$this->id_user = $id_user;
|
||||
}
|
||||
#[Route('/', name: 'app_avis_index', methods: ['GET'])]
|
||||
public function index(AvisRepository $avisRepository, TicketRepository $ticketRepository): Response
|
||||
{
|
||||
$tickets = $ticketRepository->findBy(['id_users' => $this->id_user]);
|
||||
|
||||
$ticketvalide = 0;
|
||||
foreach ($tickets as $ticket) {
|
||||
$verif = $ticket->getPayement();
|
||||
if ($verif === 'oui') {
|
||||
$ticketvalide++;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->render('avis/index.html.twig', [
|
||||
'avis' => $avisRepository->findBy([], ['id' => 'DESC']),
|
||||
'ticket' => $ticketvalide,
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/new', name: 'app_avis_new', methods: ['GET', 'POST'])]
|
||||
public function new(Request $request, EntityManagerInterface $entityManager, TicketRepository $ticketRepository): Response
|
||||
{
|
||||
$tickets_one = $ticketRepository->findOneBy(['id_users' => $this->id_user], ['id' => 'DESC']);
|
||||
$tickets_one_id = $tickets_one->getId();
|
||||
|
||||
$avi = new Avis();
|
||||
$avi->setIdTicket($tickets_one_id);
|
||||
|
||||
$form = $this->createForm(AvisType::class, $avi);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$entityManager->persist($avi);
|
||||
$entityManager->flush();
|
||||
|
||||
return $this->redirectToRoute('app_avis_index', [], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
|
||||
return $this->renderForm('avis/new.html.twig', [
|
||||
'avi' => $avi,
|
||||
'form' => $form,
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/{id}', name: 'app_avis_show', methods: ['GET'])]
|
||||
public function show(Avis $avi): Response
|
||||
{
|
||||
return $this->render('avis/show.html.twig', [
|
||||
'avi' => $avi,
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/{id}/edit', name: 'app_avis_edit', methods: ['GET', 'POST'])]
|
||||
public function edit(Request $request, Avis $avi, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
$form = $this->createForm(AvisType::class, $avi);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$entityManager->flush();
|
||||
|
||||
return $this->redirectToRoute('app_avis_index', [], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
|
||||
return $this->renderForm('avis/edit.html.twig', [
|
||||
'avi' => $avi,
|
||||
'form' => $form,
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/{id}', name: 'app_avis_delete', methods: ['POST'])]
|
||||
public function delete(Request $request, Avis $avi, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
if ($this->isCsrfTokenValid('delete' . $avi->getId(), $request->request->get('_token'))) {
|
||||
$entityManager->remove($avi);
|
||||
$entityManager->flush();
|
||||
}
|
||||
|
||||
return $this->redirectToRoute('app_avis_index', [], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
}
|
||||
|
|
@ -2,17 +2,93 @@
|
|||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Entity\Ticket;
|
||||
use App\Form\Ticket2Type;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use App\Repository\UserRepository;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use App\Repository\RestoRepository;
|
||||
use App\Repository\MenuRepository;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
|
||||
class HomeController extends AbstractController
|
||||
{
|
||||
private $id_resto;
|
||||
private $id_user;
|
||||
private $userRepository;
|
||||
private $restoRepository;
|
||||
private $menuRepository;
|
||||
private $role_user;
|
||||
public function __construct(userRepository $userRepository, restoRepository $restoRepository, menuRepository $menuRepository, Security $security)
|
||||
{
|
||||
$utilisateur = $security->getUser();
|
||||
$email_user = $utilisateur->getUserIdentifier();
|
||||
|
||||
$user = $userRepository->findOneBy(['email' => $email_user]);
|
||||
|
||||
$role_user = $user->getGrade();
|
||||
$id_resto = $user->getIdResto();
|
||||
$id_user = $user->getId();
|
||||
|
||||
$this->role_user = $role_user;
|
||||
$this->id_resto = $id_resto;
|
||||
$this->id_user = $id_user;
|
||||
$this->userRepository = $userRepository;
|
||||
$this->restoRepository = $restoRepository;
|
||||
$this->menuRepository = $menuRepository;
|
||||
}
|
||||
|
||||
#[Route('/', name: 'app_home')]
|
||||
public function index(): Response
|
||||
{
|
||||
$resto = $this->restoRepository->findAll();
|
||||
|
||||
return $this->render('home/index.html.twig', [
|
||||
'controller_name' => 'Home',
|
||||
'restos' => $resto,
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/{idresto}', name: 'app_home_choice')]
|
||||
public function choice($idresto): Response
|
||||
{
|
||||
$resto = $this->restoRepository->find($idresto);
|
||||
$menus = $this->menuRepository->findBy(['id_resto' => $idresto]);
|
||||
|
||||
return $this->render('home/choice.html.twig', [
|
||||
'controller_name' => 'Home',
|
||||
'resto' => $resto,
|
||||
'menus' => $menus,
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/{idresto}/resa', name: 'app_home_resa')]
|
||||
public function resa(): Response
|
||||
{
|
||||
return $this->render('home/resa.html.twig', [
|
||||
'controller_name' => 'Home',
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/{idresto}/{idmenu}', name: 'app_home_ticket')]
|
||||
public function ticket($idresto, $idmenu, Request $request, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
$ticket = new Ticket();
|
||||
$ticket->setIdResto($idresto);
|
||||
$ticket->setIdUsers($this->id_user);
|
||||
$ticket->setIdMenu($idmenu);
|
||||
$ticket->setPayement('non');
|
||||
|
||||
$form = $this->createForm(Ticket2Type::class, $ticket);
|
||||
|
||||
$form->handleRequest($request);
|
||||
|
||||
$entityManager->persist($ticket);
|
||||
$entityManager->flush();
|
||||
|
||||
return $this->redirectToRoute('app_home', [], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ class MenuChefController extends AbstractController
|
|||
private $id_user;
|
||||
private $userRepository;
|
||||
private $restoRepository;
|
||||
private $role_user;
|
||||
|
||||
public function __construct(userRepository $userRepository, restoRepository $restoRepository, Security $security)
|
||||
{
|
||||
|
|
@ -30,8 +31,11 @@ class MenuChefController extends AbstractController
|
|||
|
||||
$user = $userRepository->findOneBy(['email' => $email_user]);
|
||||
|
||||
$role_user = $user->getGrade();
|
||||
$id_resto = $user->getIdResto();
|
||||
$id_user = $user->getId();
|
||||
|
||||
$this->role_user = $role_user;
|
||||
$this->id_resto = $id_resto;
|
||||
$this->id_user = $id_user;
|
||||
$this->userRepository = $userRepository;
|
||||
|
|
@ -40,10 +44,9 @@ class MenuChefController extends AbstractController
|
|||
#[Route('/', name: 'app_menu_chef_index', methods: ['GET'])]
|
||||
public function index(MenuRepository $menuRepository): Response
|
||||
{
|
||||
if ($this->id_resto != '') {
|
||||
if ($this->role_user != 'Root') {
|
||||
$menus = $menuRepository->findBy(['id_resto' => $this->id_resto]);
|
||||
} else {
|
||||
$this->id_resto = 0;
|
||||
$menus = $menuRepository->findAll();
|
||||
}
|
||||
|
||||
|
|
@ -69,7 +72,6 @@ class MenuChefController extends AbstractController
|
|||
'menus' => $menus,
|
||||
'users' => $users,
|
||||
'restos' => $restos,
|
||||
'id_resto' => $this->id_resto,
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
|||
61
src/Controller/ResaServiceController.php
Normal file
61
src/Controller/ResaServiceController.php
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Entity\Resa;
|
||||
use App\Form\ResaType;
|
||||
use App\Repository\ResaRepository;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
|
||||
#[Route('/service/resa')]
|
||||
class ResaServiceController extends AbstractController
|
||||
{
|
||||
#[Route('/', name: 'app_resa_service_index', methods: ['GET'])]
|
||||
public function index(ResaRepository $resaRepository): Response
|
||||
{
|
||||
return $this->render('resa_service/index.html.twig', [
|
||||
'resas' => $resaRepository->findAll(),
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/{id}', name: 'app_resa_service_show', methods: ['GET'])]
|
||||
public function show(Resa $resa): Response
|
||||
{
|
||||
return $this->render('resa_service/show.html.twig', [
|
||||
'resa' => $resa,
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/{id}/edit', name: 'app_resa_service_edit', methods: ['GET', 'POST'])]
|
||||
public function edit(Request $request, Resa $resa, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
$form = $this->createForm(ResaType::class, $resa);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$entityManager->flush();
|
||||
|
||||
return $this->redirectToRoute('app_resa_service_index', [], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
|
||||
return $this->renderForm('resa_service/edit.html.twig', [
|
||||
'resa' => $resa,
|
||||
'form' => $form,
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/{id}', name: 'app_resa_service_delete', methods: ['POST'])]
|
||||
public function delete(Request $request, Resa $resa, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
if ($this->isCsrfTokenValid('delete' . $resa->getId(), $request->request->get('_token'))) {
|
||||
$entityManager->remove($resa);
|
||||
$entityManager->flush();
|
||||
}
|
||||
|
||||
return $this->redirectToRoute('app_resa_service_index', [], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
}
|
||||
81
src/Controller/TicketServiceController.php
Normal file
81
src/Controller/TicketServiceController.php
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Entity\Ticket;
|
||||
use App\Form\TicketType;
|
||||
use App\Repository\TicketRepository;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
|
||||
#[Route('/service/ticket')]
|
||||
class TicketServiceController extends AbstractController
|
||||
{
|
||||
#[Route('/', name: 'app_ticket_service_index', methods: ['GET'])]
|
||||
public function index(TicketRepository $ticketRepository): Response
|
||||
{
|
||||
return $this->render('ticket_service/index.html.twig', [
|
||||
'tickets' => $ticketRepository->findBy([], ['id' => 'DESC']),
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/new', name: 'app_ticket_service_new', methods: ['GET', 'POST'])]
|
||||
public function new(Request $request, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
$ticket = new Ticket();
|
||||
$form = $this->createForm(TicketType::class, $ticket);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$entityManager->persist($ticket);
|
||||
$entityManager->flush();
|
||||
|
||||
return $this->redirectToRoute('app_ticket_service_index', [], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
|
||||
return $this->renderForm('ticket_service/new.html.twig', [
|
||||
'ticket' => $ticket,
|
||||
'form' => $form,
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/{id}', name: 'app_ticket_service_show', methods: ['GET'])]
|
||||
public function show(Ticket $ticket): Response
|
||||
{
|
||||
return $this->render('ticket_service/show.html.twig', [
|
||||
'ticket' => $ticket,
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/{id}/edit', name: 'app_ticket_service_edit', methods: ['GET', 'POST'])]
|
||||
public function edit(Request $request, Ticket $ticket, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
$form = $this->createForm(TicketType::class, $ticket);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$entityManager->flush();
|
||||
|
||||
return $this->redirectToRoute('app_ticket_service_index', [], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
|
||||
return $this->renderForm('ticket_service/edit.html.twig', [
|
||||
'ticket' => $ticket,
|
||||
'form' => $form,
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/{id}', name: 'app_ticket_service_delete', methods: ['POST'])]
|
||||
public function delete(Request $request, Ticket $ticket, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
if ($this->isCsrfTokenValid('delete' . $ticket->getId(), $request->request->get('_token'))) {
|
||||
$entityManager->remove($ticket);
|
||||
$entityManager->flush();
|
||||
}
|
||||
|
||||
return $this->redirectToRoute('app_ticket_service_index', [], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
}
|
||||
66
src/Entity/Resa.php
Normal file
66
src/Entity/Resa.php
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Repository\ResaRepository;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: ResaRepository::class)]
|
||||
class Resa
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column]
|
||||
private ?int $id_resto = null;
|
||||
|
||||
#[ORM\Column]
|
||||
private ?int $nb_user = null;
|
||||
|
||||
#[ORM\Column(type: Types::DATETIME_MUTABLE)]
|
||||
private ?\DateTimeInterface $date_heur = null;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getIdResto(): ?int
|
||||
{
|
||||
return $this->id_resto;
|
||||
}
|
||||
|
||||
public function setIdResto(int $id_resto): static
|
||||
{
|
||||
$this->id_resto = $id_resto;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getNbUser(): ?int
|
||||
{
|
||||
return $this->nb_user;
|
||||
}
|
||||
|
||||
public function setNbUser(int $nb_user): static
|
||||
{
|
||||
$this->nb_user = $nb_user;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDateHeur(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->date_heur;
|
||||
}
|
||||
|
||||
public function setDateHeur(\DateTimeInterface $date_heur): static
|
||||
{
|
||||
$this->date_heur = $date_heur;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
49
src/Form/AvisType.php
Normal file
49
src/Form/AvisType.php
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Entity\Avis;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Validator\Constraints\Range;
|
||||
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
||||
|
||||
class AvisType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$builder
|
||||
->add(
|
||||
'note',
|
||||
IntegerType::class,
|
||||
[
|
||||
'attr' => [
|
||||
'min' => 1, // Valeur minimale autorisée
|
||||
'max' => 10, // Valeur maximale autorisée
|
||||
],
|
||||
'data' => 1, // Valeur par défaut
|
||||
'constraints' => [
|
||||
new Range([
|
||||
'min' => 1,
|
||||
'max' => 10,
|
||||
'notInRangeMessage' => 'La note doit être entre {{ min }} et {{ max }}.',
|
||||
]),
|
||||
],
|
||||
]
|
||||
)
|
||||
->add('com')
|
||||
->add('id_ticket', HiddenType::class, [
|
||||
'disabled' => true, // Désactive le champ
|
||||
'data' => $options['data']->getIdTicket() // Remplacez $valeurSpecifique par la valeur souhaitée
|
||||
]);
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => Avis::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
26
src/Form/ResaType.php
Normal file
26
src/Form/ResaType.php
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Entity\Resa;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class ResaType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$builder
|
||||
->add('id_resto')
|
||||
->add('nb_user')
|
||||
->add('date_heur');
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => Resa::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
40
src/Form/Ticket2Type.php
Normal file
40
src/Form/Ticket2Type.php
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Entity\Ticket;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
||||
|
||||
class Ticket2Type extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$builder
|
||||
->add('id_resto', HiddenType::class, [
|
||||
'disabled' => true, // Désactive le champ
|
||||
'data' => $options['data']->getIdResto()
|
||||
])
|
||||
->add('id_users', HiddenType::class, [
|
||||
'disabled' => true, // Désactive le champ
|
||||
'data' => $options['data']->getIdUsers()
|
||||
])
|
||||
->add('payement', HiddenType::class, [
|
||||
'disabled' => true, // Désactive le champ
|
||||
'data' => $options['data']->getPayement()
|
||||
])
|
||||
->add('id_menu', HiddenType::class, [
|
||||
'disabled' => true, // Désactive le champ
|
||||
'data' => $options['data']->getIdMenu()
|
||||
]);
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => Ticket::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
28
src/Form/TicketType.php
Normal file
28
src/Form/TicketType.php
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Entity\Ticket;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class TicketType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$builder
|
||||
->add('id_resto')
|
||||
->add('id_users')
|
||||
->add('payement')
|
||||
->add('id_menu')
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => Ticket::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
48
src/Repository/ResaRepository.php
Normal file
48
src/Repository/ResaRepository.php
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Resa;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<Resa>
|
||||
*
|
||||
* @method Resa|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method Resa|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method Resa[] findAll()
|
||||
* @method Resa[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class ResaRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Resa::class);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return Resa[] Returns an array of Resa objects
|
||||
// */
|
||||
// public function findByExampleField($value): array
|
||||
// {
|
||||
// return $this->createQueryBuilder('r')
|
||||
// ->andWhere('r.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->orderBy('r.id', 'ASC')
|
||||
// ->setMaxResults(10)
|
||||
// ->getQuery()
|
||||
// ->getResult()
|
||||
// ;
|
||||
// }
|
||||
|
||||
// public function findOneBySomeField($value): ?Resa
|
||||
// {
|
||||
// return $this->createQueryBuilder('r')
|
||||
// ->andWhere('r.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->getQuery()
|
||||
// ->getOneOrNullResult()
|
||||
// ;
|
||||
// }
|
||||
}
|
||||
4
templates/avis/_delete_form.html.twig
Normal file
4
templates/avis/_delete_form.html.twig
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<form method="post" action="{{ path('app_avis_delete', {'id': avi.id}) }}" onsubmit="return confirm('Are you sure you want to delete this item?');">
|
||||
<input type="hidden" name="_token" value="{{ csrf_token('delete' ~ avi.id) }}">
|
||||
<button class="btn">Delete</button>
|
||||
</form>
|
||||
4
templates/avis/_form.html.twig
Normal file
4
templates/avis/_form.html.twig
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
{{ form_start(form) }}
|
||||
{{ form_widget(form) }}
|
||||
<button class="btn">{{ button_label|default('Save') }}</button>
|
||||
{{ form_end(form) }}
|
||||
13
templates/avis/edit.html.twig
Normal file
13
templates/avis/edit.html.twig
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block title %}Edit Avis{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<h1>Edit Avis</h1>
|
||||
|
||||
{{ include('avis/_form.html.twig', {'button_label': 'Update'}) }}
|
||||
|
||||
<a href="{{ path('app_avis_index') }}">back to list</a>
|
||||
|
||||
{{ include('avis/_delete_form.html.twig') }}
|
||||
{% endblock %}
|
||||
40
templates/avis/index.html.twig
Normal file
40
templates/avis/index.html.twig
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block title %}Avis index{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<h1>Avis index</h1>
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Id</th>
|
||||
<th>Note</th>
|
||||
<th>Com</th>
|
||||
<th>Id_ticket</th>
|
||||
<th>actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for avi in avis %}
|
||||
<tr>
|
||||
<td>{{ avi.id }}</td>
|
||||
<td>{{ avi.note }}</td>
|
||||
<td>{{ avi.com }}</td>
|
||||
<td>{{ avi.idTicket }}</td>
|
||||
<td>
|
||||
<a href="{{ path('app_avis_show', {'id': avi.id}) }}">show</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr>
|
||||
<td colspan="5">no records found</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
{% if ticket != 0 %}
|
||||
<a href="{{ path('app_avis_new') }}">Create new</a>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
11
templates/avis/new.html.twig
Normal file
11
templates/avis/new.html.twig
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block title %}New Avis{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<h1>Create new Avis</h1>
|
||||
|
||||
{{ include('avis/_form.html.twig') }}
|
||||
|
||||
<a href="{{ path('app_avis_index') }}">back to list</a>
|
||||
{% endblock %}
|
||||
30
templates/avis/show.html.twig
Normal file
30
templates/avis/show.html.twig
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block title %}Avis{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<h1>Avis</h1>
|
||||
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>Id</th>
|
||||
<td>{{ avi.id }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Note</th>
|
||||
<td>{{ avi.note }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Com</th>
|
||||
<td>{{ avi.com }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Id_ticket</th>
|
||||
<td>{{ avi.idTicket }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<a href="{{ path('app_avis_index') }}">back to list</a>
|
||||
{% endblock %}
|
||||
26
templates/home/choice.html.twig
Normal file
26
templates/home/choice.html.twig
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block title %}Home{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
|
||||
<div class="center">
|
||||
<h1>Commande/Resa</h1>
|
||||
<h5>{{ resto.address }}</h5>
|
||||
|
||||
<p>Vous souhaitez reserver au restaurant : <code><a href="{{ path('app_home_resa', {'idresto': resto.id}) }}">C'est par ici !</a></code>
|
||||
|
||||
{% for menu in menus %}
|
||||
<article>
|
||||
<h3>Menu {{ menu.id }}</h3>
|
||||
<ul>
|
||||
<li><code>Entrée :</code> {{ menu.entre }}</li>
|
||||
<li><code>Plat :</code> {{ menu.plat }}</li>
|
||||
<li><code>Dessert :</code> {{ menu.dessert }}</li>
|
||||
</ul>
|
||||
<code><a href="{{ path('app_home_ticket', {'idresto': resto.id, 'idmenu': menu.id}) }}">Commandez en ligne ce menu !</a></code>
|
||||
</article>
|
||||
{% endfor %}
|
||||
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
|
@ -8,15 +8,15 @@
|
|||
<h1>Bienvenue chez McDoPlus !</h1>
|
||||
|
||||
{% if not app.user %}
|
||||
compte utilisateur c'est <code><a href="/user">ici</a></code>
|
||||
<p>compte utilisateur c'est <code><a href="/user">ici</a></code></p>
|
||||
{% else %}
|
||||
<p>Laisser un avis <code><a href="/avis">ici</a></code></p>
|
||||
<h5>Réserver/Commander :</h5>
|
||||
<ul>
|
||||
{% for resto in restos %}
|
||||
<li><code><a href="{{ path('app_home_choice', {'idresto': resto.id}) }}">{{ resto.address }}</a></code></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
{% if app.user and ('Waiter' in app.user.grade or 'Chef' in app.user.grade or 'Root' in app.user.grade) %}
|
||||
User roles: {{ app.user.grade }}
|
||||
{% endif %}
|
||||
|
||||
<article>
|
||||
<h3>test</h3>
|
||||
<p>coucou</p>
|
||||
</article>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
{% block title %}Menu index{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<h1>Menu du resto {{ id_resto }}</h1>
|
||||
<h1>Menu du resto</h1>
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
|
|
|
|||
4
templates/resa_service/_delete_form.html.twig
Normal file
4
templates/resa_service/_delete_form.html.twig
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<form method="post" action="{{ path('app_resa_service_delete', {'id': resa.id}) }}" onsubmit="return confirm('Are you sure you want to delete this item?');">
|
||||
<input type="hidden" name="_token" value="{{ csrf_token('delete' ~ resa.id) }}">
|
||||
<button class="btn">Delete</button>
|
||||
</form>
|
||||
4
templates/resa_service/_form.html.twig
Normal file
4
templates/resa_service/_form.html.twig
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
{{ form_start(form) }}
|
||||
{{ form_widget(form) }}
|
||||
<button class="btn">{{ button_label|default('Save') }}</button>
|
||||
{{ form_end(form) }}
|
||||
13
templates/resa_service/edit.html.twig
Normal file
13
templates/resa_service/edit.html.twig
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block title %}Edit Resa{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<h1>Edit Resa</h1>
|
||||
|
||||
{{ include('resa_service/_form.html.twig', {'button_label': 'Update'}) }}
|
||||
|
||||
<a href="{{ path('app_resa_service_index') }}">back to list</a>
|
||||
|
||||
{{ include('resa_service/_delete_form.html.twig') }}
|
||||
{% endblock %}
|
||||
37
templates/resa_service/index.html.twig
Normal file
37
templates/resa_service/index.html.twig
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block title %}Resa index{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<h1>Resa index</h1>
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Id</th>
|
||||
<th>Id_resto</th>
|
||||
<th>Nb_user</th>
|
||||
<th>Date_heur</th>
|
||||
<th>actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for resa in resas %}
|
||||
<tr>
|
||||
<td>{{ resa.id }}</td>
|
||||
<td>{{ resa.idResto }}</td>
|
||||
<td>{{ resa.nbUser }}</td>
|
||||
<td>{{ resa.dateHeur ? resa.dateHeur|date('Y-m-d H:i:s') : '' }}</td>
|
||||
<td>
|
||||
<a href="{{ path('app_resa_service_show', {'id': resa.id}) }}">show</a>
|
||||
<a href="{{ path('app_resa_service_edit', {'id': resa.id}) }}">edit</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr>
|
||||
<td colspan="5">no records found</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% endblock %}
|
||||
11
templates/resa_service/new.html.twig
Normal file
11
templates/resa_service/new.html.twig
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block title %}New Resa{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<h1>Create new Resa</h1>
|
||||
|
||||
{{ include('resa_service/_form.html.twig') }}
|
||||
|
||||
<a href="{{ path('app_resa_service_index') }}">back to list</a>
|
||||
{% endblock %}
|
||||
34
templates/resa_service/show.html.twig
Normal file
34
templates/resa_service/show.html.twig
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block title %}Resa{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<h1>Resa</h1>
|
||||
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>Id</th>
|
||||
<td>{{ resa.id }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Id_resto</th>
|
||||
<td>{{ resa.idResto }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Nb_user</th>
|
||||
<td>{{ resa.nbUser }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Date_heur</th>
|
||||
<td>{{ resa.dateHeur ? resa.dateHeur|date('Y-m-d H:i:s') : '' }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<a href="{{ path('app_resa_service_index') }}">back to list</a>
|
||||
|
||||
<a href="{{ path('app_resa_service_edit', {'id': resa.id}) }}">edit</a>
|
||||
|
||||
{{ include('resa_service/_delete_form.html.twig') }}
|
||||
{% endblock %}
|
||||
4
templates/ticket_service/_delete_form.html.twig
Normal file
4
templates/ticket_service/_delete_form.html.twig
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<form method="post" action="{{ path('app_ticket_service_delete', {'id': ticket.id}) }}" onsubmit="return confirm('Are you sure you want to delete this item?');">
|
||||
<input type="hidden" name="_token" value="{{ csrf_token('delete' ~ ticket.id) }}">
|
||||
<button class="btn">Delete</button>
|
||||
</form>
|
||||
4
templates/ticket_service/_form.html.twig
Normal file
4
templates/ticket_service/_form.html.twig
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
{{ form_start(form) }}
|
||||
{{ form_widget(form) }}
|
||||
<button class="btn">{{ button_label|default('Save') }}</button>
|
||||
{{ form_end(form) }}
|
||||
13
templates/ticket_service/edit.html.twig
Normal file
13
templates/ticket_service/edit.html.twig
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block title %}Edit Ticket{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<h1>Edit Ticket</h1>
|
||||
|
||||
{{ include('ticket_service/_form.html.twig', {'button_label': 'Update'}) }}
|
||||
|
||||
<a href="{{ path('app_ticket_service_index') }}">back to list</a>
|
||||
|
||||
{{ include('ticket_service/_delete_form.html.twig') }}
|
||||
{% endblock %}
|
||||
41
templates/ticket_service/index.html.twig
Normal file
41
templates/ticket_service/index.html.twig
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block title %}Ticket index{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<h1>Ticket index</h1>
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Id</th>
|
||||
<th>Id_resto</th>
|
||||
<th>Id_users</th>
|
||||
<th>Payement</th>
|
||||
<th>Id_menu</th>
|
||||
<th>actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for ticket in tickets %}
|
||||
<tr>
|
||||
<td>{{ ticket.id }}</td>
|
||||
<td>{{ ticket.idResto }}</td>
|
||||
<td>{{ ticket.idUsers }}</td>
|
||||
<td>{{ ticket.payement }}</td>
|
||||
<td>{{ ticket.idMenu }}</td>
|
||||
<td>
|
||||
<a href="{{ path('app_ticket_service_show', {'id': ticket.id}) }}">show</a>
|
||||
<a href="{{ path('app_ticket_service_edit', {'id': ticket.id}) }}">edit</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr>
|
||||
<td colspan="6">no records found</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<a href="{{ path('app_ticket_service_new') }}">Create new</a>
|
||||
{% endblock %}
|
||||
11
templates/ticket_service/new.html.twig
Normal file
11
templates/ticket_service/new.html.twig
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block title %}New Ticket{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<h1>Create new Ticket</h1>
|
||||
|
||||
{{ include('ticket_service/_form.html.twig') }}
|
||||
|
||||
<a href="{{ path('app_ticket_service_index') }}">back to list</a>
|
||||
{% endblock %}
|
||||
38
templates/ticket_service/show.html.twig
Normal file
38
templates/ticket_service/show.html.twig
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block title %}Ticket{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<h1>Ticket</h1>
|
||||
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>Id</th>
|
||||
<td>{{ ticket.id }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Id_resto</th>
|
||||
<td>{{ ticket.idResto }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Id_users</th>
|
||||
<td>{{ ticket.idUsers }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Payement</th>
|
||||
<td>{{ ticket.payement }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Id_menu</th>
|
||||
<td>{{ ticket.idMenu }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<a href="{{ path('app_ticket_service_index') }}">back to list</a>
|
||||
|
||||
<a href="{{ path('app_ticket_service_edit', {'id': ticket.id}) }}">edit</a>
|
||||
|
||||
{{ include('ticket_service/_delete_form.html.twig') }}
|
||||
{% endblock %}
|
||||
Loading…
Add table
Reference in a new issue