Skip to content

Commit

Permalink
admin recap
Browse files Browse the repository at this point in the history
  • Loading branch information
typhained committed May 15, 2020
1 parent b983fab commit a6419de
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 6 deletions.
33 changes: 31 additions & 2 deletions src/Controller/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
];
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
*/
Expand Down
8 changes: 4 additions & 4 deletions src/View/User/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
<th>Prénom</th>
<th>Mail</th>
<th>Téléphone</th>
<th>Dernière commande</th>
<th class="uk-table-expand"></th>
<th class="uk-table-expand">Actions</th>
</thead>
<tbody>

Expand All @@ -42,8 +41,9 @@
<td>{{ user.firstname }}</td>
<td>{{ user.mail }}</td>
<td>{{ user.num_Tel }}
<td class="uk-table-expand">{{ user.historique }}</td>
<td><a href="/User/update/{{ user.id }}"><span uk-icon="pencil"></span></a>
<td>
<a href="/User/showAd/{{user.id}}"><span uk-icon="info"></span></a>
<a href="/User/update/{{ user.id }}"><span uk-icon="pencil"></span></a>
<a href="#modal-example-{{ user.id }}" uk-toggle><span uk-icon="trash"></span></a>
</td>
</tr>
Expand Down
68 changes: 68 additions & 0 deletions src/View/User/showAdmin.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{% extends 'layout.html.twig' %}
{% block title %}
{{ parent()}} Profil
{% endblock %}
{% block content %}
<div class="uk-container uk-margin-top">
<h3 class="uk-text-center">Profil de {{ user.firstname }} {{ user.lastname }}</h3>
<div class="uk-card uk-card-default uk-width-1-1@m">
<div class="uk-card-header uk-background-muted">
<div class="uk-grid-small uk-flex-middle" uk-grid>
<div class="uk-width-expand">
<p class="uk-text-meta uk-margin-remove-top">Adresse mail: {{ user.mail }}</p>
<p class="uk-text-meta uk-margin-remove-top">Numéro de téléphone: {{ user.num_Tel }}</p>

</div>
</div>
</div>
<div class="uk-card-body">
<h3>Commande la plus récente </h3>
<table class="uk-table ">
{% if recap == null %}
<tr> Aucune commande récente </tr>
{% else %}

<thead class="uk-background-muted">
<tr>
<th>DATE</th>
<th>PRIX</th>
</tr>
</thead>
<tr>
<td>{{ recap.date }}</td>
<td>{{ recap.prix_total }}</td>
</tr>
<tr>
<th colspan="2" class="uk-background-muted">CONTENU</th>
</tr>
{% for item in cart %}
<tr>
<td>{{ item.quantite }} * {{ item.nom }}</td>
</tr>
{% endfor %}
{% if concepts != null %}
<tr>
<th colspan="2" class="uk-text-center">Bouquet personnalisé</th>
</tr>
{% for concept in concepts %}

<tr>
<td class="uk-text-center">1</td>
<td class="uk-text-center">
{{ concept.produit }}
</td>
</tr>
{% endfor %}
{% endif %}
{% endif %}
</table>
</div>
<div class="uk-card-footer uk-text-center">
<a class="uk-button uk-button-secondary" href="/User/index">Retour</a>
</div>
</div>
</div>



{% endblock %}

0 comments on commit a6419de

Please sign in to comment.