From f4f64892740126cc1a3c963257653dabc3c9edb2 Mon Sep 17 00:00:00 2001 From: Joshua Date: Mon, 24 Mar 2025 15:54:35 +0100 Subject: [PATCH] Suppression Modals, rajout et essaie de base.html.twig sur tout les page --- public/js/GestionMenu/GestionMenu.js | 77 ++++++++ templates/base.html.twig | 123 ++++++++++++- templates/index/admin.html.twig | 13 +- templates/plats/index.html.twig | 181 +++++++++++++++---- templates/reductions/index.html.twig | 185 ++++++++++++++++---- templates/tables/index.html.twig | 169 ++++++++++++++---- templates/user/list.html.twig | 86 ++------- templates/user/update.html.twig | 252 +++++++++++++++++++-------- 8 files changed, 843 insertions(+), 243 deletions(-) create mode 100644 public/js/GestionMenu/GestionMenu.js diff --git a/public/js/GestionMenu/GestionMenu.js b/public/js/GestionMenu/GestionMenu.js new file mode 100644 index 0000000..679f140 --- /dev/null +++ b/public/js/GestionMenu/GestionMenu.js @@ -0,0 +1,77 @@ +document.querySelector('.btn-gestion-menu').addEventListener('click', function(event) { + event.preventDefault(); + + document.getElementById('container_modal'); + + fetch('/plats') + .then(response => { + if (!response.ok) { + throw new Error('Erreur de chargement de la section Promotions'); + } + return response.text(); + }) + .then(html => { + // Insérer le HTML dans le conteneur et l'afficher + container_modal.innerHTML = html; + container_modal.style.display = 'block'; + }) + .catch(error => { + console.error('Erreur:', error); + }); +}); + +function addPlats (event) { + document.getElementById('container_modal'); + + fetch(`/plats/new`) + .then(response => { + return response.text(); + }) + .then(html => { + // Insérer le HTML dans le conteneur et l'afficher + container_modal.innerHTML = html; + container_modal.style.display = 'block'; + }) + .catch(error => { + console.error('Erreur:', error); + }); +} + + +function updatePromotion (event) { + document.getElementById('container_modal'); + const reductionsIdString = event.getAttribute('data-id'); + let reductionsId = parseInt(reductionsIdString); + + fetch(`/plats/${platsId}/edit`) + .then(response => { + return response.text(); + }) + .then(html => { + // Insérer le HTML dans le conteneur et l'afficher + container_modal.innerHTML = html; + container_modal.style.display = 'block'; + }) + .catch(error => { + console.error('Erreur:', error); + }); +} + +function deletePromotion (event) { + document.getElementById('container_modal'); + const reductionsIdString = event.getAttribute('data-id'); + let reductionsId = parseInt(reductionsIdString); + + fetch(`/reductions/${reductionsId}`) + .then(response => { + return response.text(); + }) + .then(html => { + // Insérer le HTML dans le conteneur et l'afficher + container_modal.innerHTML = html; + container_modal.style.display = 'block'; + }) + .catch(error => { + console.error('Erreur:', error); + }); +} \ No newline at end of file diff --git a/templates/base.html.twig b/templates/base.html.twig index abbbe3c..88ca0eb 100644 --- a/templates/base.html.twig +++ b/templates/base.html.twig @@ -11,14 +11,135 @@ {# #} {% block stylesheets %} + + + {% endblock %} {% block javascripts %} + + + + + {% block importmap %}{{ importmap('app') }}{% endblock %} {% endblock %} - {% block body %}{% endblock %} + {% block body %} + + + +
+
+ Bonjour, {{ app.user.prenom }} +
+
+ + +
+ + {% if is_granted('ROLE_ADMIN') %} + + {% elseif is_granted('ROLE_CUISINIER') %} + + {% elseif is_granted('ROLE_SERVEUR') %} + + {% endif %} + +
+ +
+ +
+ + + + + + {% endblock %} {# bootstrap#} {# #} {# #} diff --git a/templates/index/admin.html.twig b/templates/index/admin.html.twig index b6ee974..8a7f8ef 100644 --- a/templates/index/admin.html.twig +++ b/templates/index/admin.html.twig @@ -36,9 +36,9 @@