diff --git a/composer.json b/composer.json index fc4788a..01e8e80 100644 --- a/composer.json +++ b/composer.json @@ -39,7 +39,7 @@ "symfony/string": "7.1.*", "symfony/translation": "7.1.*", "symfony/twig-bundle": "7.1.*", - "symfony/ux-icons": "^2.21", + "symfony/ux-icons": "^2.24", "symfony/ux-turbo": "^2.20", "symfony/validator": "7.1.*", "symfony/web-link": "7.1.*", diff --git a/composer.lock b/composer.lock index c0e03e7..7ef7ff5 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "7fff997f78db4185bb53c4543a245c74", + "content-hash": "d1751dd70a356412dfadda645c7118ec", "packages": [ { "name": "amphp/amp", @@ -8164,16 +8164,16 @@ }, { "name": "symfony/ux-icons", - "version": "v2.21.0", + "version": "v2.24.0", "source": { "type": "git", "url": "https://github.com/symfony/ux-icons.git", - "reference": "c3b3fd29b3f90e977b267251ef15ea06f3cec553" + "reference": "39f689b41081f7788ee9c4a188817599d546bfb2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/ux-icons/zipball/c3b3fd29b3f90e977b267251ef15ea06f3cec553", - "reference": "c3b3fd29b3f90e977b267251ef15ea06f3cec553", + "url": "https://api.github.com/repos/symfony/ux-icons/zipball/39f689b41081f7788ee9c4a188817599d546bfb2", + "reference": "39f689b41081f7788ee9c4a188817599d546bfb2", "shasum": "" }, "require": { @@ -8197,8 +8197,8 @@ "type": "symfony-bundle", "extra": { "thanks": { - "name": "symfony/ux", - "url": "https://github.com/symfony/ux" + "url": "https://github.com/symfony/ux", + "name": "symfony/ux" } }, "autoload": { @@ -8233,7 +8233,7 @@ "twig" ], "support": { - "source": "https://github.com/symfony/ux-icons/tree/v2.21.0" + "source": "https://github.com/symfony/ux-icons/tree/v2.24.0" }, "funding": [ { @@ -8249,7 +8249,7 @@ "type": "tidelift" } ], - "time": "2024-10-21T19:01:22+00:00" + "time": "2025-04-04T17:32:18+00:00" }, { "name": "symfony/ux-turbo", @@ -11242,7 +11242,7 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": {}, "prefer-stable": true, "prefer-lowest": false, "platform": { @@ -11250,6 +11250,6 @@ "ext-ctype": "*", "ext-iconv": "*" }, - "platform-dev": [], - "plugin-api-version": "2.3.0" + "platform-dev": {}, + "plugin-api-version": "2.6.0" } diff --git a/migrations/Version20241114160014.php b/migrations/Version20241114160014.php deleted file mode 100644 index c219157..0000000 --- a/migrations/Version20241114160014.php +++ /dev/null @@ -1,52 +0,0 @@ -addSql('ALTER TABLE reservations DROP CONSTRAINT fk_4da2394de1870d'); - $this->addSql('DROP INDEX idx_4da2394de1870d'); - $this->addSql('ALTER TABLE reservations RENAME COLUMN tabl_id TO table_id'); - $this->addSql('ALTER TABLE reservations ADD CONSTRAINT FK_4DA239ECFF285C FOREIGN KEY (table_id) REFERENCES tables (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); - $this->addSql('CREATE INDEX IDX_4DA239ECFF285C ON reservations (table_id)'); - $this->addSql('ALTER TABLE statut_tables DROP CONSTRAINT fk_33c8a3754de1870d'); - $this->addSql('DROP INDEX idx_33c8a3754de1870d'); - $this->addSql('ALTER TABLE statut_tables RENAME COLUMN tabl_id TO table_id'); - $this->addSql('ALTER TABLE statut_tables ADD CONSTRAINT FK_33C8A375ECFF285C FOREIGN KEY (table_id) REFERENCES tables (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); - $this->addSql('CREATE INDEX IDX_33C8A375ECFF285C ON statut_tables (table_id)'); - $this->addSql('CREATE UNIQUE INDEX UNIQ_497B315E5126AC48 ON utilisateurs (mail)'); - } - - 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 INDEX UNIQ_497B315E5126AC48'); - $this->addSql('ALTER TABLE statut_tables DROP CONSTRAINT FK_33C8A375ECFF285C'); - $this->addSql('DROP INDEX IDX_33C8A375ECFF285C'); - $this->addSql('ALTER TABLE statut_tables RENAME COLUMN table_id TO tabl_id'); - $this->addSql('ALTER TABLE statut_tables ADD CONSTRAINT fk_33c8a3754de1870d FOREIGN KEY (tabl_id) REFERENCES tables (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); - $this->addSql('CREATE INDEX idx_33c8a3754de1870d ON statut_tables (tabl_id)'); - $this->addSql('ALTER TABLE reservations DROP CONSTRAINT FK_4DA239ECFF285C'); - $this->addSql('DROP INDEX IDX_4DA239ECFF285C'); - $this->addSql('ALTER TABLE reservations RENAME COLUMN table_id TO tabl_id'); - $this->addSql('ALTER TABLE reservations ADD CONSTRAINT fk_4da2394de1870d FOREIGN KEY (tabl_id) REFERENCES tables (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); - $this->addSql('CREATE INDEX idx_4da2394de1870d ON reservations (tabl_id)'); - } -} diff --git a/migrations/Version20241114160729.php b/migrations/Version20241114160729.php deleted file mode 100644 index 8011f79..0000000 --- a/migrations/Version20241114160729.php +++ /dev/null @@ -1,50 +0,0 @@ -addSql('ALTER TABLE reservations DROP CONSTRAINT fk_4da239ecff285c'); - $this->addSql('DROP INDEX idx_4da239ecff285c'); - $this->addSql('ALTER TABLE reservations RENAME COLUMN table_id TO tables_id'); - $this->addSql('ALTER TABLE reservations ADD CONSTRAINT FK_4DA23985405FD2 FOREIGN KEY (tables_id) REFERENCES tables (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); - $this->addSql('CREATE INDEX IDX_4DA23985405FD2 ON reservations (tables_id)'); - $this->addSql('ALTER TABLE statut_tables DROP CONSTRAINT fk_33c8a375ecff285c'); - $this->addSql('DROP INDEX idx_33c8a375ecff285c'); - $this->addSql('ALTER TABLE statut_tables RENAME COLUMN table_id TO tables_id'); - $this->addSql('ALTER TABLE statut_tables ADD CONSTRAINT FK_33C8A37585405FD2 FOREIGN KEY (tables_id) REFERENCES tables (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); - $this->addSql('CREATE INDEX IDX_33C8A37585405FD2 ON statut_tables (tables_id)'); - } - - 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('ALTER TABLE statut_tables DROP CONSTRAINT FK_33C8A37585405FD2'); - $this->addSql('DROP INDEX IDX_33C8A37585405FD2'); - $this->addSql('ALTER TABLE statut_tables RENAME COLUMN tables_id TO table_id'); - $this->addSql('ALTER TABLE statut_tables ADD CONSTRAINT fk_33c8a375ecff285c FOREIGN KEY (table_id) REFERENCES tables (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); - $this->addSql('CREATE INDEX idx_33c8a375ecff285c ON statut_tables (table_id)'); - $this->addSql('ALTER TABLE reservations DROP CONSTRAINT FK_4DA23985405FD2'); - $this->addSql('DROP INDEX IDX_4DA23985405FD2'); - $this->addSql('ALTER TABLE reservations RENAME COLUMN tables_id TO table_id'); - $this->addSql('ALTER TABLE reservations ADD CONSTRAINT fk_4da239ecff285c FOREIGN KEY (table_id) REFERENCES tables (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); - $this->addSql('CREATE INDEX idx_4da239ecff285c ON reservations (table_id)'); - } -} diff --git a/migrations/Version20241114164216.php b/migrations/Version20241114164216.php deleted file mode 100644 index 65df11e..0000000 --- a/migrations/Version20241114164216.php +++ /dev/null @@ -1,46 +0,0 @@ -addSql('CREATE TABLE tables_clients (tables_id INT NOT NULL, clients_id INT NOT NULL, PRIMARY KEY(tables_id, clients_id))'); - $this->addSql('CREATE INDEX IDX_80F8906E85405FD2 ON tables_clients (tables_id)'); - $this->addSql('CREATE INDEX IDX_80F8906EAB014612 ON tables_clients (clients_id)'); - $this->addSql('ALTER TABLE tables_clients ADD CONSTRAINT FK_80F8906E85405FD2 FOREIGN KEY (tables_id) REFERENCES tables (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); - $this->addSql('ALTER TABLE tables_clients ADD CONSTRAINT FK_80F8906EAB014612 FOREIGN KEY (clients_id) REFERENCES clients (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); - $this->addSql('ALTER TABLE clients_tables DROP CONSTRAINT fk_8190d6c6ab014612'); - $this->addSql('ALTER TABLE clients_tables DROP CONSTRAINT fk_8190d6c685405fd2'); - $this->addSql('DROP TABLE clients_tables'); - } - - 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('CREATE TABLE clients_tables (clients_id INT NOT NULL, tables_id INT NOT NULL, PRIMARY KEY(clients_id, tables_id))'); - $this->addSql('CREATE INDEX idx_8190d6c685405fd2 ON clients_tables (tables_id)'); - $this->addSql('CREATE INDEX idx_8190d6c6ab014612 ON clients_tables (clients_id)'); - $this->addSql('ALTER TABLE clients_tables ADD CONSTRAINT fk_8190d6c6ab014612 FOREIGN KEY (clients_id) REFERENCES clients (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); - $this->addSql('ALTER TABLE clients_tables ADD CONSTRAINT fk_8190d6c685405fd2 FOREIGN KEY (tables_id) REFERENCES tables (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); - $this->addSql('ALTER TABLE tables_clients DROP CONSTRAINT FK_80F8906E85405FD2'); - $this->addSql('ALTER TABLE tables_clients DROP CONSTRAINT FK_80F8906EAB014612'); - $this->addSql('DROP TABLE tables_clients'); - } -} diff --git a/public/css/ControllerVues/new.css b/public/css/ControllerVues/new.css index 0ce956f..f5a9080 100644 --- a/public/css/ControllerVues/new.css +++ b/public/css/ControllerVues/new.css @@ -1,105 +1,107 @@ -html{ - font-family: "Quicksand Light"; !important; -} -/* Page container */ -.page-container { - width: 100%; - max-width: 600px; - margin: 20px auto; - padding: 20px; - background-color: #fff; - border-radius: 10px; - box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1); - border: 2px solid #ff4d4d; +/* Appliquer une police moderne */ +html { + font-family: "Quicksand", sans-serif !important; } -/* Title */ -.page-title { - text-align: center; - font-size: 28px; - color: #ff4d4d; + +/* Titre du formulaire */ +h1 { + font-size: 26px; + color: #db5559; margin-bottom: 20px; font-weight: bold; text-transform: uppercase; - letter-spacing: 1px; + letter-spacing: 1.2px; } -/* Form styles */ +/* Formulaire */ form { display: flex; flex-direction: column; gap: 15px; + align-items: center; } +/* Groupes de champs */ .form-group { display: flex; flex-direction: column; + align-items: flex-start; + width: 100%; } +/* Labels */ label { font-weight: bold; - color: #ff4d4d; - margin-bottom: 5px; + color: #db5559; + margin-bottom: 6px; + font-size: 14px; } +/* Champs de saisie */ input[type="text"], input[type="email"], input[type="number"], textarea, select { - padding: 10px; - border: 1px solid #ccc; - border-radius: 5px; - font-size: 14px; + width: 100%; + padding: 12px; + border: 2px solid #ddd; + border-radius: 6px; + font-size: 16px; color: #333; - transition: border-color 0.3s ease-in-out; + transition: all 0.3s ease-in-out; + background-color: #fff; } -input[type="text"]:focus, -input[type="email"]:focus, -input[type="number"]:focus, +input:focus, textarea:focus, select:focus { - border-color: #ff4d4d; + border-color: #db5559; outline: none; + box-shadow: 0 0 5px rgba(219, 85, 89, 0.5); } -/* Submit button */ +/* Bouton d'envoi */ button { - background-color: #ff4d4d; + background-color: #db5559; color: white; font-weight: bold; - padding: 12px 20px; + padding: 14px; border: none; - border-radius: 5px; - font-size: 16px; + border-radius: 8px; + font-size: 18px; cursor: pointer; text-transform: uppercase; - transition: background-color 0.3s ease-in-out; + transition: all 0.3s ease-in-out; + width: 100%; } button:hover { - background-color: #e60000; + background-color: #b52b31; } -/* Links */ -.actions { +/* Bouton de retour */ +#container_modal a { + display: inline-block; + margin-top: 20px; + padding: 12px 20px; + background-color: transparent; + color: #db5559; + border: 2px solid #db5559; + border-radius: 6px; + font-size: 16px; text-align: center; - margin-top: 15px; -} - -.actions a { text-decoration: none; - color: #ff4d4d; - font-weight: bold; - transition: color 0.3s ease-in-out; + transition: all 0.3s ease-in-out; } -.actions a:hover { - color: #e60000; +#container_modal a:hover { + background-color: #db5559; + color: white; } -/* Error messages */ +/* Messages d'erreur */ .error-message { color: #d9534f; font-size: 14px; @@ -107,10 +109,9 @@ button:hover { font-style: italic; } -/* Empty space below */ +/* Espacement supplémentaire */ body::after { content: ''; height: 20px; display: block; } - diff --git a/public/css/Index/index.css b/public/css/Index/index.css index 7b2c784..11de2c1 100644 --- a/public/css/Index/index.css +++ b/public/css/Index/index.css @@ -43,7 +43,7 @@ ul { } li { - padding-bottom: 20px; + padding-bottom: 4%; } .btn-custom { diff --git a/public/css/Plats/plats.css b/public/css/Plats/plats.css new file mode 100644 index 0000000..090e9be --- /dev/null +++ b/public/css/Plats/plats.css @@ -0,0 +1,127 @@ +/* Title */ +h1 { + text-align: center; + font-size: 42px; + color: #b03a2e; + margin-bottom: 20px; +} + +/* Menu Grid */ +.menu-container { + display: grid; + grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); /* 3 max par ligne */ + gap: 20px; + justify-content: center; +} + +/* Menu Card */ +.menu-card { + background: white; + padding: 20px; + border-radius: 15px; + box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15); + text-align: center; + transition: transform 0.3s ease, box-shadow 0.3s ease; +} + +/* Plat Name */ +.menu-card h2 { + font-size: 28px; + color: #b03a2e; + margin-bottom: 10px; +} + +/* Description */ +.menu-card p { + font-size: 18px; + color: #555; + margin-bottom: 10px; +} + +/* Price */ +.menu-card .price { + font-size: 22px; + font-weight: bold; + color: #388E3C; + margin-bottom: 15px; +} + +/* Buttons */ +.menu-card .actions { + display: flex; + justify-content: center; + gap: 10px; +} + +/* Styles des boutons Modifier et Supprimer */ +.menu-card .actions a, +.menu-card .actions button { + text-decoration: none; + font-size: 16px; + font-weight: bold; + padding: 10px 15px; + border-radius: 8px; + transition: all 0.3s ease-in-out; + border: none; + cursor: pointer; + display: inline-block; /* Pour que le bouton suppr ait le même comportement qu'un lien */ + text-align: center; +} + +/* Modifier */ +.menu-card .edit { + background-color: #ffb74d; + color: white; +} + +.menu-card .edit:hover { + background-color: #ffa726; +} + +/* Supprimer */ +.menu-card .delete { + background-color: #d32f2f; + color: white; +} + +.menu-card .delete:hover { + background-color: #c62828; +} + + +.menu-card .edit { + background-color: #ffb74d; + color: white; +} + +.menu-card .edit:hover { + background-color: #ffa726; +} + +.menu-card .delete { + background-color: #d32f2f; + color: white; +} + +.menu-card .delete:hover { + background-color: #c62828; +} + +/* Button for Adding New Dish */ +.add-menu { + display: block; + text-align: center; + background-color: #b03a2e; + color: white; + padding: 15px; + font-size: 20px; + margin-top: 30px; + border-radius: 10px; + width: 300px; + margin-left: auto; + margin-right: auto; +} + +.add-menu:hover { + background-color: #922b21; +} \ No newline at end of file diff --git a/public/css/Reservations/reservationCalendar.css b/public/css/Reservations/reservationCalendar.css new file mode 100644 index 0000000..88bb5f4 --- /dev/null +++ b/public/css/Reservations/reservationCalendar.css @@ -0,0 +1,84 @@ +.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; +} + +/* Conteneur pour les boutons de navigation */ +.calendar-nav { + display: flex; + justify-content: space-between; + align-items: center; + margin-bottom: 20px; +} + +/* Boutons de navigation (Semaine précédente / Semaine suivante) */ +.calendar-nav a { + padding: 10px 15px; + text-decoration: none; + font-size: 16px; + font-weight: bold; + color: white; + background-color: #db5559; + border-radius: 5px; + transition: background-color 0.3s ease-in-out; +} + +.calendar-nav a:hover { + background-color: #b52b31; +} + +/* Conteneur pour le bouton d'ajout */ +.add-reservation { + display: flex; + justify-content: center; + margin-top: 20px; +} + +/* Bouton pour créer une réservation */ +.add-reservation a { + padding: 12px 20px; + text-decoration: none; + font-size: 18px; + font-weight: bold; + color: white; + background-color: #4CAF50; + border-radius: 8px; + transition: background-color 0.3s ease-in-out; +} + +.add-reservation a:hover { + background-color: #388E3C; +} + diff --git a/src/Controller/ClientsController.php b/src/Controller/ClientsController.php index 2c41873..15d2f2d 100644 --- a/src/Controller/ClientsController.php +++ b/src/Controller/ClientsController.php @@ -1,19 +1,22 @@ handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { + + $montantTotal = $client->getTotalDepense(); + if($montantTotal > 1000){ + $this->appliquerReductionEtCreerSiNecessaire($client, $entityManager); + } + $entityManager->persist($client); $entityManager->flush(); @@ -42,7 +51,6 @@ final class ClientsController extends AbstractController ]); } - #[Route('/{id}/edit', name: 'app_clients_edit', methods: ['GET', 'POST'])] public function edit(Request $request, Clients $client, EntityManagerInterface $entityManager): Response { @@ -50,6 +58,13 @@ final class ClientsController extends AbstractController $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { + + $montantTotal = $client->getTotalDepense(); + if($montantTotal > 1000){ + $this->appliquerReductionEtCreerSiNecessaire($client, $entityManager); + } + + $entityManager->flush(); return $this->redirectToRoute('app_clients_index', [], Response::HTTP_SEE_OTHER); @@ -62,13 +77,62 @@ final class ClientsController extends AbstractController } #[Route('/{id}', name: 'app_clients_delete', methods: ['POST'])] - public function delete(Request $request, Clients $client, EntityManagerInterface $entityManager, int $id, ): Response + public function delete(Request $request, Clients $client, EntityManagerInterface $entityManager): Response { - if ($this->isCsrfTokenValid('delete'.$client->getId(), $request->getPayload()->getString('_token'))) { + if ($this->isCsrfTokenValid('delete'.$client->getId(), $request->request->get('_token'))) { $entityManager->remove($client); $entityManager->flush(); } return $this->redirectToRoute('app_clients_index', [], Response::HTTP_SEE_OTHER); } + + // Méthode pour appliquer ou créer une réduction pour un client + // src/Controller/ClientsController.php + + private function appliquerReductionEtCreerSiNecessaire(Clients $client, EntityManagerInterface $entityManager) + { + $montantTotal = $client->getTotalDepense(); + $entityManager->persist($client); + + $reductions = $entityManager->getRepository(Reductions::class) + ->createQueryBuilder('r') + ->where('r.montant_min <= :montantTotal') + ->andWhere('r.actif = :actif') + ->andWhere('r.DateDebut <= :currentDate') + ->andWhere('r.DateFin >= :currentDate') + ->setParameter('montantTotal', $montantTotal) + ->setParameter('actif', true) + ->setParameter('currentDate', new \DateTime()) + ->getQuery() + ->getResult(); + + $newReduction = new Reductions(); + + if ($montantTotal >= 2000) { + $montantMin = 2000; + $pourcentage = 10; + } elseif ($montantTotal >= 1000) { + $montantMin = 1000; + $pourcentage = 5; + } + + $newReduction->setPourcentage($pourcentage) + ->setMontantMin($montantMin) + ->setDateDebut(new \DateTime()) + ->setDateFin((new \DateTime())->modify('+1 year')) + ->setActif(true) + ->setClient($client); + + $entityManager->persist($newReduction); + $entityManager->flush(); + + if (!$client->getReductions()->contains($newReduction)) { + $client->addReduction($newReduction); + } + + $entityManager->flush(); + } + + } diff --git a/src/Controller/PlatsController.php b/src/Controller/PlatsController.php index 498590a..373a0ce 100644 --- a/src/Controller/PlatsController.php +++ b/src/Controller/PlatsController.php @@ -72,4 +72,14 @@ final class PlatsController extends AbstractController return $this->redirectToRoute('app_plats_index', [], Response::HTTP_SEE_OTHER); } + + #[Route('/bestplats', name: 'app_plats_best', methods: ['GET'])] + public function getBest(PlatsRepository $platsRepository): Response + { + $bestplats = $platsRepository->findBestPlats(); +// dd($bestplats); + return $this->render('plats/best.html.twig', [ + 'plat' => $bestplats, + ]); + } } diff --git a/src/Controller/ReservationsController.php b/src/Controller/ReservationsController.php index b0287fd..8a9ec8b 100644 --- a/src/Controller/ReservationsController.php +++ b/src/Controller/ReservationsController.php @@ -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 + ]); + } } diff --git a/src/Controller/TablesController.php b/src/Controller/TablesController.php index c1c834b..d22febe 100644 --- a/src/Controller/TablesController.php +++ b/src/Controller/TablesController.php @@ -72,4 +72,22 @@ final class TablesController extends AbstractController return $this->redirectToRoute('app_tables_index', [], Response::HTTP_SEE_OTHER); } + + #[Route('/update/statut/{id}', name: 'app_tables_update_statut', methods: ['POST'])] + public function update(Request $request, EntityManagerInterface $entityManager, $id): Response + { + $table = $entityManager->getRepository(Tables::class)->find($id); + + if (!$table) { + throw $this->createNotFoundException('Table not found'); + } + + $libre = $request->request->get('libre') === '1'; + $table->setLibre($libre); + + $entityManager->persist($table); + $entityManager->flush(); + + return $this->redirectToRoute('app_tables_index'); + } } diff --git a/src/Entity/Clients.php b/src/Entity/Clients.php index 7367507..0c34287 100644 --- a/src/Entity/Clients.php +++ b/src/Entity/Clients.php @@ -40,10 +40,17 @@ class Clients #[ORM\ManyToMany(targetEntity: Commandes::class, mappedBy: 'Client')] private Collection $commandes; + #[ORM\Column] + private ?float $totalDepense = null; + + #[ORM\OneToMany(targetEntity: Reductions::class, mappedBy: 'client', cascade: ['persist', 'remove'])] + private Collection $reductions; + public function __construct() { $this->tables = new ArrayCollection(); $this->commandes = new ArrayCollection(); + $this->reductions = new ArrayCollection(); } public function getId(): ?int @@ -149,4 +156,60 @@ class Clients return $this; } + + + public function getTotalDepense(): ?float + { + return $this->totalDepense; + } + + public function setTotalDepense(float $totalDepense): static + { + $this->totalDepense = $totalDepense; + + return $this; + } + + // Dans l'entité Clients + public function appliquerReduction(): void + { + $montantTotal = $this->getTotalDepense(); + + // Vérifie s'il y a des réductions valides disponibles + $reductions = $this->getReductions(); // Récupérer toutes les réductions du client + + foreach ($reductions as $reduction) { + // Vérifie si la réduction est valide (date de validité et montant minimum) + if ($reduction->getDateDebut() <= new \DateTime() && $reduction->getDateFin() >= new \DateTime()) { + if ($montantTotal >= $reduction->getMontantMin()) { + // Applique la réduction en pourcentage au total des dépenses + $reductionMontant = ($montantTotal * $reduction->getPourcentage()) / 100; + $nouveauTotal = $montantTotal - $reductionMontant; // Nouveau montant après réduction + $this->setTotalDepense($nouveauTotal); // Mise à jour du total des dépenses du client + + // Met à jour l'objet client avec la réduction + break; // Si une réduction a été appliquée, on arrête + } + } + } + } + + public function getReductions(): Collection + { + return $this->reductions; + } + + public function addReduction(Reductions $reduction): static + { + if (!$this->reductions->contains($reduction)) { + $this->reductions->add($reduction); + } + return $this; + } + + public function removeReduction(Reductions $reduction): static + { + $this->reductions->removeElement($reduction); + return $this; + } } diff --git a/src/Entity/Plats.php b/src/Entity/Plats.php index 5515a14..34424c8 100644 --- a/src/Entity/Plats.php +++ b/src/Entity/Plats.php @@ -39,9 +39,6 @@ class Plats #[ORM\ManyToMany(targetEntity: Commandes::class, inversedBy: 'plats')] private Collection $Commande; - #[ORM\ManyToOne(inversedBy: 'plats')] - private ?Reductions $Reduction = null; - public function __construct() { $this->Commande = new ArrayCollection(); @@ -147,16 +144,4 @@ class Plats return $this; } - - public function getReduction(): ?Reductions - { - return $this->Reduction; - } - - public function setReduction(?Reductions $Reduction): static - { - $this->Reduction = $Reduction; - - return $this; - } } diff --git a/src/Entity/Reductions.php b/src/Entity/Reductions.php index ed93d26..509f1b2 100644 --- a/src/Entity/Reductions.php +++ b/src/Entity/Reductions.php @@ -16,88 +16,30 @@ class Reductions #[ORM\Column] private ?int $id = null; - #[ORM\Column(length: 255)] - private ?string $Description = null; + #[ORM\Column] + private ?int $pourcentage = null; #[ORM\Column] - private ?float $Prix = null; + private ?int $montant_min = null; #[ORM\Column] - private ?int $Pourcentage = null; - - #[ORM\Column(length: 255)] - private ?string $MontantFixe = null; - + private ?bool $actif = null; #[ORM\Column(type: Types::DATETIME_MUTABLE)] private ?\DateTimeInterface $DateDebut = null; #[ORM\Column(type: Types::DATETIME_MUTABLE)] private ?\DateTimeInterface $DateFin = null; - /** - * @var Collection - */ - #[ORM\OneToMany(targetEntity: Plats::class, mappedBy: 'Reduction')] - private Collection $plats; - public function __construct() - { - $this->plats = new ArrayCollection(); - } + #[ORM\ManyToOne(targetEntity: Clients::class, inversedBy: 'reductions')] + #[ORM\JoinColumn(nullable: false)] + private ?Clients $client = null; public function getId(): ?int { return $this->id; } - - public function getDescription(): ?string - { - return $this->Description; - } - - public function setDescription(string $Description): static - { - $this->Description = $Description; - - return $this; - } - - public function getPrix(): ?float - { - return $this->Prix; - } - - public function setPrix(float $Prix): static - { - $this->Prix = $Prix; - - return $this; - } - - public function getPourcentage(): ?int - { - return $this->Pourcentage; - } - - public function setPourcentage(int $Pourcentage): static - { - $this->Pourcentage = $Pourcentage; - - return $this; - } - - public function getMontantFixe(): ?string - { - return $this->MontantFixe; - } - - public function setMontantFixe(string $MontantFixe): static - { - $this->MontantFixe = $MontantFixe; - - return $this; - } - + public function getDateDebut(): ?\DateTimeInterface { return $this->DateDebut; @@ -122,33 +64,50 @@ class Reductions return $this; } - /** - * @return Collection - */ - public function getPlats(): Collection + public function getPourcentage(): ?int { - return $this->plats; + return $this->pourcentage; } - public function addPlat(Plats $plat): static + public function setPourcentage(int $pourcentage): static { - if (!$this->plats->contains($plat)) { - $this->plats->add($plat); - $plat->setReduction($this); - } + $this->pourcentage = $pourcentage; return $this; } - public function removePlat(Plats $plat): static + public function getMontantMin(): ?int { - if ($this->plats->removeElement($plat)) { - // set the owning side to null (unless already changed) - if ($plat->getReduction() === $this) { - $plat->setReduction(null); - } - } + return $this->montant_min; + } + public function setMontantMin(int $montant_min): static + { + $this->montant_min = $montant_min; + + return $this; + } + + public function isActif(): ?bool + { + return $this->actif; + } + + public function setActif(bool $actif): static + { + $this->actif = $actif; + + return $this; + } + + public function getClient(): ?Clients + { + return $this->client; + } + + public function setClient(?Clients $client): static + { + $this->client = $client; return $this; } } diff --git a/src/Entity/Reservations.php b/src/Entity/Reservations.php index 757d358..9dbc8e2 100644 --- a/src/Entity/Reservations.php +++ b/src/Entity/Reservations.php @@ -70,7 +70,7 @@ class Reservations return $this->tables; } - public function setTable(?Tables $tables): static + public function setTables(?Tables $tables): static { $this->tables = $tables; diff --git a/src/Entity/Tables.php b/src/Entity/Tables.php index 1d1820a..ce68a84 100644 --- a/src/Entity/Tables.php +++ b/src/Entity/Tables.php @@ -36,9 +36,12 @@ class Tables /** * @var Collection */ - #[ORM\ManyToMany(targetEntity: Utilisateurs::class, mappedBy: 'tables')] + #[ORM\ManyToMany(targetEntity: Utilisateurs::class, inversedBy: 'tables')] private Collection $utilisateurs; + #[ORM\Column(type: 'boolean', options: ['default' => true])] + private ?bool $libre = null; + public function __construct() { $this->Clients = new ArrayCollection(); @@ -91,7 +94,7 @@ class Tables { if (!$this->reservations->contains($reservation)) { $this->reservations->add($reservation); - $reservation->setTable($this); + $reservation->setTables($this); } return $this; @@ -102,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); } } @@ -165,4 +168,16 @@ class Tables return $this; } + + public function isLibre(): ?bool + { + return $this->libre; + } + + public function setLibre(bool $libre): static + { + $this->libre = $libre; + + return $this; + } } diff --git a/src/Entity/Utilisateurs.php b/src/Entity/Utilisateurs.php index c9a6ead..987c637 100644 --- a/src/Entity/Utilisateurs.php +++ b/src/Entity/Utilisateurs.php @@ -41,7 +41,7 @@ class Utilisateurs implements UserInterface, PasswordAuthenticatedUserInterface /** * @var Collection */ - #[ORM\ManyToMany(targetEntity: Tables::class, inversedBy: 'utilisateurs')] + #[ORM\ManyToMany(targetEntity: Tables::class, mappedBy: 'utilisateurs')] private Collection $tables; public function __construct() diff --git a/src/Form/AddUserFormType.php b/src/Form/AddUserFormType.php index c017c3c..4c8b2bd 100644 --- a/src/Form/AddUserFormType.php +++ b/src/Form/AddUserFormType.php @@ -17,6 +17,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\Form\CallbackTransformer; use Symfony\Component\Validator\Constraints\Length; use Symfony\Component\Validator\Constraints\NotBlank; +use function Sodium\add; class AddUserFormType extends AbstractType { @@ -48,6 +49,12 @@ class AddUserFormType extends AbstractType 'expanded' => true, 'multiple' => true, ]) + ->add('Tables', EntityType::class, [ + 'class' => Tables::class, + 'choice_label' => 'id', + 'multiple' => true, + 'expanded' => true, + ]) ->add('Enregistrer', SubmitType::class); } diff --git a/src/Form/ClientsType.php b/src/Form/ClientsType.php index 4444b85..1dcf24c 100644 --- a/src/Form/ClientsType.php +++ b/src/Form/ClientsType.php @@ -4,6 +4,7 @@ namespace App\Form; use App\Entity\Clients; use App\Entity\Commandes; +use App\Entity\Reductions; use App\Entity\Tables; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractType; @@ -25,7 +26,7 @@ class ClientsType extends AbstractType 'multiple' => true, 'expanded' => true, ]) - + ->add('totalDepense') ; } diff --git a/src/Form/PlatsType.php b/src/Form/PlatsType.php index 068fa54..a5d3e9d 100644 --- a/src/Form/PlatsType.php +++ b/src/Form/PlatsType.php @@ -27,10 +27,6 @@ class PlatsType extends AbstractType 'multiple' => true, 'expanded' => true, ]) - ->add('Reduction', EntityType::class, [ - 'class' => Reductions::class, - 'choice_label' => 'description', - ]) ; } diff --git a/src/Form/ReductionsType.php b/src/Form/ReductionsType.php index ff5957e..9cccbfc 100644 --- a/src/Form/ReductionsType.php +++ b/src/Form/ReductionsType.php @@ -2,7 +2,10 @@ namespace App\Form; +use App\Entity\Clients; use App\Entity\Reductions; +use http\Client; +use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -12,16 +15,19 @@ class ReductionsType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options): void { $builder - ->add('Description') - ->add('Prix') - ->add('Pourcentage') - ->add('MontantFixe') + ->add('Taux') ->add('DateDebut', null, [ 'widget' => 'single_text', ]) ->add('DateFin', null, [ 'widget' => 'single_text', ]) + ->add('client', EntityType::class, [ + 'class' => Clients::class, + 'choice_label' => 'nom', + 'multiple' => false, + 'expanded' => true, + ]) ; } diff --git a/src/Form/ReservationsType.php b/src/Form/ReservationsType.php index d6b4e99..4a2bc09 100644 --- a/src/Form/ReservationsType.php +++ b/src/Form/ReservationsType.php @@ -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, ]) diff --git a/src/Form/TablesType.php b/src/Form/TablesType.php index f4a3d05..5f8e941 100644 --- a/src/Form/TablesType.php +++ b/src/Form/TablesType.php @@ -3,10 +3,12 @@ namespace App\Form; use App\Entity\Clients; +use App\Entity\StatutTables; use App\Entity\Tables; use App\Entity\Utilisateurs; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\Extension\Core\Type\HiddenType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -21,12 +23,15 @@ class TablesType extends AbstractType 'multiple' => true, 'expanded' => true, ]) - ->add('utilisateurs', EntityType::class, [ + ->add('Utilisateurs', EntityType::class, [ 'class' => Utilisateurs::class, 'choice_label' => 'id', 'multiple' => true, 'expanded' => true, ]) + ->add('libre', HiddenType::class, [ + 'data' => true, + ]) ; } diff --git a/src/Repository/PlatsRepository.php b/src/Repository/PlatsRepository.php index a4d8cad..bb0aa7d 100644 --- a/src/Repository/PlatsRepository.php +++ b/src/Repository/PlatsRepository.php @@ -40,4 +40,14 @@ class PlatsRepository extends ServiceEntityRepository // ->getOneOrNullResult() // ; // } + + public function findBestPlats(): ?Plats + { + return $this->createQueryBuilder('p') + ->orderBy('p.Nb_de_commande', 'DESC') + ->setMaxResults(1) + ->getQuery() + ->getOneOrNullResult(); + } + } diff --git a/src/Repository/ReservationsRepository.php b/src/Repository/ReservationsRepository.php index 67fb065..237c8af 100644 --- a/src/Repository/ReservationsRepository.php +++ b/src/Repository/ReservationsRepository.php @@ -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(); + } + + } diff --git a/templates/base.html.twig b/templates/base.html.twig index baf9c01..d310bfe 100644 --- a/templates/base.html.twig +++ b/templates/base.html.twig @@ -12,9 +12,11 @@ {% block stylesheets %} + + {% endblock %} {# {% block javascripts %}#} @@ -88,7 +90,7 @@
  • - + {{ ux_icon('fluent-emoji-high-contrast:ten-oclock') }} Voir tendances @@ -100,7 +102,7 @@
  • - + {{ ux_icon('fluent-mdl2:reservation-orders') }} Réservation diff --git a/templates/clients/index.html.twig b/templates/clients/index.html.twig index e78988b..9c14936 100644 --- a/templates/clients/index.html.twig +++ b/templates/clients/index.html.twig @@ -2,60 +2,59 @@ {% block title %}Client index{% endblock %} -{% block head %} - - - - - -{% endblock %} - -{% block stylesheets %} - - - - -{% endblock %} - {% block container_modal %} -
    -

    Clients index

    +
    +

    Clients index

    - - +
    + - + + + - - - {% for client in clients %} - - - - - - - - - {% else %} - - - - {% endfor %} - -
    Id Prenom Nom Email TelephoneactionsDepenseRéduction Appliquée Actions
    {{ client.id }}{{ client.Prenom }}{{ client.Nom }}{{ client.Email }}{{ client.Telephone }} -
    - - {{ include('clients/_delete_form.html.twig') }} -
    - Modifier -
    no records found
    + + + {% for client in clients %} + + {{ client.id }} + {{ client.Prenom }} + {{ client.Nom }} + {{ client.Email }} + {{ client.Telephone }} + {{ client.totalDepense }} - Créer un nouveau client -
    + + {% if client.reductions|length > 0 %} + {% for reduction in client.reductions %} + Réduction de {{ reduction.pourcentage }}% - Valide jusqu'à {{ reduction.DateFin|date('d/m/Y') }}
    + {% endfor %} + {% else %} + Aucune réduction + {% endif %} + + + +
    + + {{ include('clients/_delete_form.html.twig') }} +
    + Modifier + + + {% else %} + + Aucun client trouvé + + {% endfor %} + + + + Créer un nouveau client +
    {% endblock %} diff --git a/templates/plats/best.html.twig b/templates/plats/best.html.twig new file mode 100644 index 0000000..6373253 --- /dev/null +++ b/templates/plats/best.html.twig @@ -0,0 +1,59 @@ +{% extends 'base.html.twig' %} + +{% block head %} + + + + + +{% endblock %} + +{% block stylesheets %} + + + + + +{% endblock %} + +{% block container_modal %} + +
    +

    Tendance

    + + + + + + + + + + + + + + + {% if plat %} + + + + + + + + + + {% else %} + + + + {% endif %} + +
    IdNomDescriptionPrixCategorieStatutNb_de_commande
    {{ plat.id }}{{ plat.Nom }}{{ plat.Description }}{{ plat.Prix }}{{ plat.Categorie }}{{ plat.Statut ? 'Yes' : 'No' }}{{ plat.NbDeCommande }}
    Aucun enregistrement trouvé
    +
    + +{% endblock %} + + + diff --git a/templates/plats/index.html.twig b/templates/plats/index.html.twig index 9ca141c..c298fe7 100644 --- a/templates/plats/index.html.twig +++ b/templates/plats/index.html.twig @@ -13,6 +13,7 @@ {% block stylesheets %} + @@ -21,48 +22,28 @@ {% block container_modal %}
    -

    Plats index

    - - - - - - - - - - - - - - - + - - - - - - - - - - {% else %} - - - - {% endfor %} - -
    IdNomDescriptionPrixCategorieStatutNb_de_commandeactions
    {{ plat.id }}{{ plat.Nom }}{{ plat.Description }}{{ plat.Prix }}{{ plat.Categorie }}{{ plat.Statut ? 'Yes' : 'No' }}{{ plat.NbDeCommande }} -
    - - {{ include('plats/_delete_form.html.twig') }} -
    - Modifier -
    Aucun enregistrement trouvé
    + + {% else %} +

    Aucun plat disponible.

    + {% endfor %} +
    + + Créer un menu - Créer un menu {% endblock %} diff --git a/templates/reductions/index.html.twig b/templates/reductions/index.html.twig index ee999f6..7d27cf1 100644 --- a/templates/reductions/index.html.twig +++ b/templates/reductions/index.html.twig @@ -27,12 +27,11 @@ Id - Description - Prix Pourcentage - MontantFixe + Montant Minimum DateDebut DateFin + Client actions @@ -40,18 +39,16 @@ {% for reduction in reductions %} {{ reduction.id }} - {{ reduction.Description }} - {{ reduction.Prix }} - {{ reduction.Pourcentage }} - {{ reduction.MontantFixe }} - {{ reduction.DateDebut ? reduction.DateDebut|date('Y-m-d H:i:s') : '' }} - {{ reduction.DateFin ? reduction.DateFin|date('Y-m-d H:i:s') : '' }} + {{ reduction.pourcentage }}% + {{ reduction.montantMin }} € + {{ reduction.DateDebut ? reduction.DateDebut|date('d/m/Y H:i:s') : 'Non spécifié' }} + {{ reduction.DateFin ? reduction.DateFin|date('d/m/Y H:i:s') : 'Non spécifié' }} + {{ reduction.client.nom }} -
    + - {{ include('reductions/_delete_form.html.twig') }} +
    - Modifier {% else %} @@ -61,8 +58,6 @@ {% endfor %} - - Créer une réduction {% endblock %} diff --git a/templates/reservations/index.html.twig b/templates/reservations/index.html.twig index b0ac723..ceefc1d 100644 --- a/templates/reservations/index.html.twig +++ b/templates/reservations/index.html.twig @@ -13,45 +13,50 @@ {% block stylesheets %} + {% endblock %} {% block container_modal %}
    -

    Reservations index

    + + +
    +
    + {% for i in 0..6 %} +
    + {{ (startDate|date_modify("+" ~ i ~ " days"))|date('D d/m') }} +
    + {% endfor %} +
    +
    + {% for i in 0..6 %} +
    + {% 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') %} +
    + {{ res_time }} - {{ reservation.nbdeprsn }} pers. +
    + {% endif %} + {% endfor %} +
    + {% endfor %} +
    +
    + + - - - - - - - - - - - {% for reservation in reservations %} - - - - - - - {% else %} - - - - {% endfor %} - -
    IdDateHeureNb_de_prsnactions
    {{ reservation.id }}{{ reservation.DateHeure ? reservation.DateHeure|date('Y-m-d H:i:s') : '' }}{{ reservation.NbDePrsn }} -
    - - {{ include('reservations/_delete_form.html.twig') }} -
    - Modifier -
    Aucun enregistrement trouvé
    - Créer une réservation
    {% endblock %} diff --git a/templates/reservations/new.html.twig b/templates/reservations/new.html.twig index 3a8a5b7..b1f6e39 100644 --- a/templates/reservations/new.html.twig +++ b/templates/reservations/new.html.twig @@ -24,6 +24,6 @@ {{ include('reservations/_form.html.twig') }} - Retour à la liste + Retour à la liste {% endblock %} diff --git a/templates/tables/index.html.twig b/templates/tables/index.html.twig index a0af7b4..8d3e42a 100644 --- a/templates/tables/index.html.twig +++ b/templates/tables/index.html.twig @@ -22,33 +22,62 @@

    Tables index

    - +
    - - + + + + + {% for table in tables %} + + + + + + + {% else %} - + {% endfor %}
    IdactionsNuméro de TableClient AssignéUtilisateur AssignéLibre ?Actions
    {{ table.id }} -
    - - {{ include('tables/_delete_form.html.twig') }} + {% for client in table.Clients %} + {{ client.nom }}{% if not loop.last %}, {% endif %} + {% else %} + Aucun + {% endfor %} +
    + {% for utilisateur in table.utilisateurs %} + {{ utilisateur.nom }}{% if not loop.last %}, {% endif %} + {% else %} + Aucun + {% endfor %} + + + + + Modifier + +
    + + +
    Aucun enregistrement trouvéAucun enregistrement trouvé
    + Créer une tables