From a6419de9d80805e2232228ea7c38a5b34d594906 Mon Sep 17 00:00:00 2001 From: karapuce Date: Fri, 15 May 2020 11:14:47 +0200 Subject: [PATCH] admin recap --- src/Controller/UserController.php | 33 ++++++++++++++- src/View/User/index.html.twig | 8 ++-- src/View/User/showAdmin.html.twig | 68 +++++++++++++++++++++++++++++++ 3 files changed, 103 insertions(+), 6 deletions(-) create mode 100644 src/View/User/showAdmin.html.twig diff --git a/src/Controller/UserController.php b/src/Controller/UserController.php index 17f7a7f..f86a8f2 100644 --- a/src/Controller/UserController.php +++ b/src/Controller/UserController.php @@ -51,7 +51,7 @@ public function add() $user = [ 'firstname' => ucfirst($_POST['firstname']), 'lastname' => strtoupper($_POST['lastname']), - 'password' => password_hash($_POST['password'], PASSWORD_BCRYPT), + 'password' => $_POST['password'], 'mail' => strtolower($_POST['mail']), 'tel' => $_POST['tel'], ]; @@ -99,7 +99,7 @@ public function update(int $id) et contenir au moins une majuscule et un chiffre"; return $this->twig->render('User/update.html.twig', ['user' => $user, 'message' => $message]); } else { - $user['password'] = password_hash($_POST['password'], PASSWORD_BCRYPT); + $user['password'] =$_POST['password']; $userManager->update($user); $user = $userManager->selectOneById($id); $cartid = $cartManager->historiqueID($id); @@ -175,6 +175,35 @@ public function show(int $id) } } + public function showAd($id) + { + if ($_SESSION["role"] == "admin") { + $userManager = new UserManager(); + $cartManager = new CartManager(); + + $user = $userManager->selectOneById($id); + $cartid = $cartManager->historiqueID($id); + if ($cartid) { + $cartid = $cartid['id']; + $cart = $cartManager->showCartContent($cartid); + $concepts = $cartManager->conceptInCart($cartid); + $recap = $cartManager->showPriceCart($cartid); + return $this->twig->render('User/showAdmin.html.twig', [ + 'user' => $user, + "cart" => $cart, + "concepts"=>$concepts, + "recap"=>$recap, + ]); + } else { + return $this->twig->render('User/showAdmin.html.twig', [ + 'user' => $user, + ]); + } + } else { + header('location:/Account/login/'); + } + } + /** * @param int $id */ diff --git a/src/View/User/index.html.twig b/src/View/User/index.html.twig index 34650b9..1934f64 100644 --- a/src/View/User/index.html.twig +++ b/src/View/User/index.html.twig @@ -17,8 +17,7 @@ Prénom Mail Téléphone - Dernière commande - + Actions @@ -42,8 +41,9 @@ {{ user.firstname }} {{ user.mail }} {{ user.num_Tel }} - {{ user.historique }} - + + + diff --git a/src/View/User/showAdmin.html.twig b/src/View/User/showAdmin.html.twig new file mode 100644 index 0000000..5b5e6ff --- /dev/null +++ b/src/View/User/showAdmin.html.twig @@ -0,0 +1,68 @@ +{% extends 'layout.html.twig' %} +{% block title %} + {{ parent()}} Profil +{% endblock %} +{% block content %} +
+

Profil de {{ user.firstname }} {{ user.lastname }}

+
+
+
+
+

Adresse mail: {{ user.mail }}

+

Numéro de téléphone: {{ user.num_Tel }}

+ +
+
+
+
+

Commande la plus récente

+ + {% if recap == null %} + Aucune commande récente + {% else %} + + + + + + + + + + + + + + + {% for item in cart %} + + + + {% endfor %} + {% if concepts != null %} + + + + {% for concept in concepts %} + + + + + + {% endfor %} + {% endif %} + {% endif %} +
DATEPRIX
{{ recap.date }}{{ recap.prix_total }}
CONTENU
{{ item.quantite }} * {{ item.nom }}
Bouquet personnalisé
1 + {{ concept.produit }} +
+
+ +
+
+ + + +{% endblock %} \ No newline at end of file