Commit a0eeaf43 authored by Mat's avatar Mat

Page qui résume les commandes de l'utilisateur

parent 6c6e9051
......@@ -285,10 +285,20 @@ class MembreController extends MasterController
*/
public function resumeAction()
{
return $this->render('PotageBundle:Membre:resume.html.twig', array(
));
$user = $this->getUser();
if ($user !== null)
{
$em = $this->getDoctrine()->getManager();
$commandes = $em->getRepository('PotageBundle:Commande')
->findAllCurrentByUser($user->getId());
return $this->render('PotageBundle:Membre:resume.html.twig', array(
'commandes' => $commandes
));
}
}
}
......@@ -10,4 +10,20 @@ namespace PotageBundle\Repository;
*/
class CommandeRepository extends \Doctrine\ORM\EntityRepository
{
/**
* Toutes les commandes d'un utilisateur
* TODO introduire un status sur les commandes
*
* @param $id
* @return array
*/
public function findAllCurrentByUser($id)
{
$qb = $this->createQueryBuilder('c')
->where('c.user = :id')
->setParameter(':id', $id)
->orderBy('c.createdAt', 'DESC');
return $qb->getQuery()->getResult();
}
}
......@@ -96,6 +96,10 @@
<a href="{{ path('fos_user_profile_show') }}" class="dropdown-item">
Mon profil
</a>
<a href="{{ path('potage_resume') }}" class="dropdown-item">
Mes commandes
</a>
<div class="dropdown-divider"></div>
<a href="{{ path('fos_user_security_logout') }}" class="dropdown-item">
{{ 'layout.logout'|trans({}, 'FOSUserBundle') }}
......
......@@ -11,18 +11,31 @@
<div class="col-md-10 offset-md-1 bloc">
<div class="row">
{% for label, messages in app.flashes() %}
{% for message in messages %}
<div class="alert alert-{{ label }}" role="alert">
{{ message }}
</div>
{% endfor %}
{% for label, messages in app.flashes() %}
{% for message in messages %}
<div class="alert alert-{{ label }}" role="alert">
{{ message }}
</div>
{% endfor %}
{% endfor %}
<h1>Commandes en cours</h1>
<ul>
<li>
<a href="{{ path('potage_today') }}">Passer une nouvelle commande</a>
</li>
{% for commande in commandes %}
<li>
<a href="#">Commande n°{{ commande.id }}</a>,
<small>
enregistrée le {{ commande.createdAt|date('d/m/Y, à H:i:s') }}
(→ offre {{ commande.offre.reference }})
</small>
</li>
{% endfor %}
</ul>
</div>
<h1>Historique des commandes</h1>
{#
<div class="row ">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment