{% extends 'base.html.twig' %}
{% block body %}
{% set summe = 0 %}
<br>
<div class="container">
<h2>Ihre Bestellung</h2>
<br>
<table class="table table-striped">
<thead>
<tr>
<td>Bestell Nr.</td>
<td>Name</td>
<td>Preis</td>
<td>Status</td>
<td></td>
</tr>
</thead>
<tbody>
{% for bestellung in bestellungen %}
{% set summe = summe + bestellung.preis %}
<tr>
<td>{{bestellung.bnummer}}</td>
<td>{{bestellung.name}}</td>
<td>{{bestellung.preis}}</td>
{% if not is_granted('ROLE_USER') %}
<td>{{bestellung.status}}</td>
{% endif %}
{% if is_granted('ROLE_USER') %}
<td>
<div class="dropdown show">
<a class="btn btn-secondary dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
{{bestellung.status}}
</a>
<div class="dropdown-menu" aria-labelledby="dropdownMenuLink">
<a class="dropdown-item" href="{{path('app_status',{id: bestellung.id, status: 'offen'})}}">offen</a>
<a class="dropdown-item" href="{{path('app_status',{id: bestellung.id, status: 'fertig'})}}">fertig</a>
<a class="dropdown-item" href="{{path('app_status',{id: bestellung.id, status: 'archiv'})}}">archiv</a>
</div>
</div>
</td>
{% endif %}
{% if bestellung.status == 'offen' %} <!-- Die Möglichkeit zur Löschung besteht nur, wenn die Bestellung noch offen ist -->
<td><a class="btn btn-outline-danger btn-sm" href="{{path('app_loeschen',{id: bestellung.id})}}" role="button">Entfernen</a></td>
{% else %}
<td> </td>
{% endif %}
</tr>
{% endfor %}
<tr>
<td> </td>
<td> </td>
<td>{{summe}} CHF</td>
{% if not is_granted('ROLE_USER') %}
<td> </td>
{% endif %}
{% if is_granted('ROLE_USER') %}
<td> </td>
{% endif %}
<td> </td>
</tr>
</tbody>
</table>
</div>
{% endblock %}