Ajout calendrier + modif controller / css sur plats pour ressembler a un menu

This commit is contained in:
Joshua 2025-04-04 14:18:09 +02:00
parent 41798397d3
commit 8626387473
11 changed files with 241 additions and 39 deletions

120
public/css/Plats/plats.css Normal file

@ -0,0 +1,120 @@
/* Table styles */
table {
width: 100%;
border-collapse: collapse;
margin-bottom: 20px;
background-color: #fafafa;
font-family: 'Arial', sans-serif;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
border-radius: 10px;
overflow: hidden;
}
/* Table headers */
table th, table td {
padding: 15px;
text-align: left;
border: 1px solid #e1e1e1;
}
table th {
background-color: #d9534f;
color: white;
font-weight: bold;
text-transform: uppercase;
letter-spacing: 1px;
}
/* Even rows */
table tr:nth-child(even) {
background-color: #f8f8f8;
}
/* Row hover effect */
table tr:hover {
background-color: #f1f1f1;
cursor: pointer;
}
/* Action links */
a {
text-decoration: none;
color: #d9534f;
font-weight: bold;
transition: color 0.3s ease;
}
a:hover {
color: #fff;
text-decoration: underline;
}
/* New client button */
a[href*="app_clients_new"] {
display: inline-block;
margin-top: 20px;
padding: 12px 25px;
background-color: #28a745;
color: white;
border-radius: 8px;
font-size: 16px;
text-align: center;
transition: background-color 0.3s ease, transform 0.2s ease;
}
a[href*="app_clients_new"]:hover {
background-color: #218838;
transform: scale(1.05);
}
/* Empty table row message */
table td[colspan="6"] {
text-align: center;
font-style: italic;
color: #999;
padding: 20px;
font-size: 18px;
}
/* Button container */
.btn-container {
display: flex;
justify-content: center;
margin-bottom: 20px;
}
/* Button styles */
.btn {
padding: 10px 20px;
text-decoration: none;
color: white;
background-color: #d9534f;
border-radius: 8px;
font-weight: bold;
margin-top: 25px;
text-transform: uppercase;
letter-spacing: 1px;
transition: background-color 0.3s ease, transform 0.2s ease;
}
.btn:hover {
background-color: #c9302c;
transform: scale(1.05);
}
/* For card-like container around the table */
.card {
background-color: #fff;
padding: 20px;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
border-radius: 15px;
margin-bottom: 30px;
}
/* Card title */
.card h2 {
font-size: 24px;
color: #333;
margin-bottom: 15px;
font-family: 'Roboto', sans-serif;
}

@ -0,0 +1,36 @@
.calendar {
display: flex;
flex-direction: column;
}
.calendar-header {
display: flex;
}
.calendar-day {
flex: 1;
text-align: center;
font-weight: bold;
padding: 10px;
border: 1px solid #ddd;
}
.calendar-body {
display: flex;
}
.calendar-column {
flex: 1;
min-height: 400px;
border: 1px solid #ddd;
padding: 5px;
position: relative;
}
.reservation {
margin: 5px 0;
padding: 5px;
border-radius: 5px;
font-size: 14px;
text-align: center;
}

@ -33,7 +33,7 @@ final class ReservationsController extends AbstractController
$entityManager->persist($reservation);
$entityManager->flush();
return $this->redirectToRoute('app_reservations_index', [], Response::HTTP_SEE_OTHER);
return $this->redirectToRoute('calendar_week', [], Response::HTTP_SEE_OTHER);
}
return $this->render('reservations/new.html.twig', [
@ -71,4 +71,29 @@ final class ReservationsController extends AbstractController
return $this->redirectToRoute('app_reservations_index', [], Response::HTTP_SEE_OTHER);
}
#[Route('/calendar/{year}/{week}', name: 'calendar_week', requirements: ['year' => '\d+', 'week' => '\d+'])]
public function calendar(ReservationsRepository $reservationsRepository, int $year = null, int $week = null): Response
{
if ($year === null || $week === null) {
$currentDate = new \DateTime();
$year = (int) $currentDate->format('Y');
$week = (int) $currentDate->format('W');
}
setlocale(LC_TIME, 'fr_FR.UTF-8');
$startDate = new \DateTime();
$startDate->setISODate($year, $week);
$endDate = (clone $startDate)->modify('+6 days');
$reservations = $reservationsRepository->findByDateRange($startDate, $endDate);
// dd($reservations);
return $this->render('reservations/index.html.twig', [
'reservations' => $reservations,
'startDate' => $startDate, // Passe startDate
'endDate' => $endDate, // Passe endDate
]);
}
}

@ -70,7 +70,7 @@ class Reservations
return $this->tables;
}
public function setTable(?Tables $tables): static
public function setTables(?Tables $tables): static
{
$this->tables = $tables;

@ -94,7 +94,7 @@ class Tables
{
if (!$this->reservations->contains($reservation)) {
$this->reservations->add($reservation);
$reservation->setTable($this);
$reservation->setTables($this);
}
return $this;
@ -105,7 +105,7 @@ class Tables
if ($this->reservations->removeElement($reservation)) {
// set the owning side to null (unless already changed)
if ($reservation->getTables() === $this) {
$reservation->setTable(null);
$reservation->setTables(null);
}
}

@ -25,7 +25,7 @@ class ReservationsType extends AbstractType
])
->add('utilisateurs', EntityType::class, [
'class' => Utilisateurs::class,
'choice_label' => 'id',
'choice_label' => 'prenom',
'multiple' => true,
'expanded' => true,
])

@ -40,4 +40,19 @@ class ReservationsRepository extends ServiceEntityRepository
// ->getOneOrNullResult()
// ;
// }
// src/Repository/ReservationRepository.php
public function findByDateRange(\DateTime $startDate, \DateTime $endDate): array
{
return $this->createQueryBuilder('r')
->where('r.DateHeure BETWEEN :start AND :end')
->setParameter('start', $startDate->format('Y-m-d 00:00:00'))
->setParameter('end', $endDate->format('Y-m-d 23:59:59'))
->orderBy('r.DateHeure', 'ASC')
->getQuery()
->getResult();
}
}

@ -15,6 +15,7 @@
<link rel="stylesheet" href="{{ asset('css/Index/index.css') }}"> <!-- Ajout du fichier CSS -->
<link rel="stylesheet" href="{{ asset('css/Compte/index.css') }}"> <!-- Ajout du fichier CSS -->
<link rel="stylesheet" href="{{ asset('css/GestionUtilisateurs/GestionUtilisateurs.css') }}"> <!-- Ajout du fichier CSS -->
<link rel="stylesheet" href="{{ asset('css/Reservations/reservationCalendar.css') }}"> <!-- Ajout du fichier CSS -->
{% endblock %}
{# {% block javascripts %}#}
@ -100,7 +101,7 @@
</a>
</li>
<li>
<a href="/reservations" class="btn-custom icon-container">
<a href="/reservations/calendar" class="btn-custom icon-container">
<i class="icon-medium"> {{ ux_icon('fluent-mdl2:reservation-orders') }}</i>
<span>Réservation</span>
</a>

@ -13,7 +13,7 @@
{% block stylesheets %}
<link rel="stylesheet" href="{{ asset('css/ControllerVues/list.css') }}"> <!-- Ajout du fichier CSS -->
<link rel="stylesheet" href="{{ asset('css/ControllerVues/edit.css') }}"> <!-- Ajout du fichier CSS -->
<link rel="stylesheet" href="{{ asset('css/Index/index.css') }}"> <!-- Ajout du fichier CSS -->
<link rel="stylesheet" href="{{ asset('css/Plats/plats.css') }}"> <!-- Ajout du fichier CSS -->
<link rel="stylesheet" href="{{ asset('css/Compte/index.css') }}"> <!-- Ajout du fichier CSS -->
<link rel="stylesheet" href="{{ asset('css/GestionUtilisateurs/GestionUtilisateurs.css') }}"> <!-- Ajout du fichier CSS -->
{% endblock %}

@ -13,45 +13,50 @@
{% block stylesheets %}
<link rel="stylesheet" href="{{ asset('css/ControllerVues/list.css') }}"> <!-- Ajout du fichier CSS -->
<link rel="stylesheet" href="{{ asset('css/Index/index.css') }}"> <!-- Ajout du fichier CSS -->
<link rel="stylesheet" href="{{ asset('css/Reservations/reservationCalendar.css') }}"> <!-- Ajout du fichier CSS -->
<link rel="stylesheet" href="{{ asset('css/Compte/index.css') }}"> <!-- Ajout du fichier CSS -->
<link rel="stylesheet" href="{{ asset('css/GestionUtilisateurs/GestionUtilisateurs.css') }}"> <!-- Ajout du fichier CSS -->
{% endblock %}
{% block container_modal %}
<div id="container_modal">
<h1>Reservations index</h1>
<h1>Calendrier de la semaine du {{ startDate|date('d/m/Y') }} au {{ endDate|date('d/m/Y') }}</h1>
<table class="table">
<thead>
<tr>
<th>Id</th>
<th>DateHeure</th>
<th>Nb_de_prsn</th>
<th>actions</th>
</tr>
</thead>
<tbody>
{% for reservation in reservations %}
<tr>
<td>{{ reservation.id }}</td>
<td>{{ reservation.DateHeure ? reservation.DateHeure|date('Y-m-d H:i:s') : '' }}</td>
<td>{{ reservation.NbDePrsn }}</td>
<td>
<form method="post" action="{{ path('app_reservations_delete', {'id': reservation.id}) }}" onsubmit="return confirm('Es-tu sur de vouloir le supprimer ?');">
<input type="hidden" name="_token" value="{{ csrf_token('delete' ~ reservation.id) }}">
{{ include('reservations/_delete_form.html.twig') }}
</form>
<a href="{{ path('app_reservations_edit', {'id': reservation.id}) }}">Modifier</a>
</td>
</tr>
{% else %}
<tr>
<td colspan="4">Aucun enregistrement trouvé</td>
</tr>
{% endfor %}
</tbody>
</table>
<!-- Navigation vers la semaine précédente -->
<a href="{{ path('calendar_week', { year: startDate|date('Y'), week: startDate|date('W') - 1 }) }}">Semaine précédente</a>
<!-- Navigation vers la semaine suivante -->
<a href="{{ path('calendar_week', { year: startDate|date('Y'), week: startDate|date('W') + 1 }) }}">Semaine suivante</a>
<div class="calendar">
<div class="calendar-header">
{% for i in 0..6 %}
<div class="calendar-day">
{{ (startDate|date_modify("+" ~ i ~ " days"))|date('D d/m') }}
</div>
{% endfor %}
</div>
<div class="calendar-body">
{% for i in 0..6 %}
<div class="calendar-column">
{% set currentDate = startDate|date_modify("+" ~ i ~ " days") %}
{% for reservation in reservations %}
{% set res_date = reservation.dateHeure|date('Y-m-d') %}
{% set res_time = reservation.dateHeure|date('H:i') %}
{% if res_date == currentDate|date('Y-m-d') %}
<div class="reservation" style="background-color: lightblue;">
{{ res_time }} - {{ reservation.nbdeprsn }} pers.
</div>
{% endif %}
{% endfor %}
</div>
{% endfor %}
</div>
</div>
<a href="{{ path('app_reservations_new') }}">Créer une réservation</a>
</div>
{% endblock %}

@ -24,6 +24,6 @@
{{ include('reservations/_form.html.twig') }}
<a href="{{ path('app_reservations_index') }}">Retour à la liste</a>
<a href="{{ path('calendar_week') }}">Retour à la liste</a>
</div>
{% endblock %}