Show multiple accounts in accountmodal
This commit is contained in:
parent
e5d9d61211
commit
9f04b7b557
@ -1,28 +1,34 @@
|
||||
{% if account %}
|
||||
{% if accounts %}
|
||||
<div id="accountsmodal" class="modal" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">Abrechnung: ({{ account.desk.desk_no }}) {{ account.desk.name }} </h4>
|
||||
<h4 class="modal-title">Abrechnung</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>Normalpreis:</td>
|
||||
<td>Tisch #</td>
|
||||
<td>Tisch Name</td>
|
||||
<td>Normalpreis</td>
|
||||
<td>Preis HH</td>
|
||||
<td>Gesamt</td>
|
||||
</tr>
|
||||
</thead>
|
||||
{% for account in accounts %}
|
||||
<tr>
|
||||
<td>{{ account.desk.desk_no }}</td>
|
||||
<td>{{ account.desk.name }}</td>
|
||||
<td>{{ account.prize_normal }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Preis Happy Hour:</td>
|
||||
<td>{{ account.prize_hh }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Gesamt:</td>
|
||||
<td>{{ account.prize }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<a class="btn btn-default btn-primary" href="{% url 'billard:account_modal_confirm' pk=account.id loc_pk=loc_pk %}">Schliessen</a>
|
||||
<a class="btn btn-default btn-primary" href="{% url 'billard:account_modal_confirm' pks=pks loc_pk=loc_pk %}">Schliessen</a>
|
||||
</div>
|
||||
</div><!-- /.modal-content -->
|
||||
</div><!-- /.modal-dialog -->
|
||||
|
@ -19,7 +19,7 @@ urlpatterns = [
|
||||
# ex. /billard/1/account_modal/
|
||||
url(r'^(?P<loc_pk>[0-9]+)/account_modal/$', views.account_modal_view, name='account_modal'),
|
||||
# ex. /billard/1/account_modal/confirm/
|
||||
url(r'^(?P<loc_pk>[0-9]+)/account_modal/(?P<pk>[0-9]+)/confirm/$', views.account_modal_confirm_view,
|
||||
url(r'^(?P<loc_pk>[0-9]+)/account_modal/(?P<pks>([0-9],)+)/confirm/$', views.account_modal_confirm_view,
|
||||
name='account_modal_confirm'),
|
||||
# ex. /billard/api/v1/ (rest api)
|
||||
url(r'api/v1/', include(router.urls)),
|
||||
|
@ -81,19 +81,21 @@ def accounting_confirm(request, pk):
|
||||
def account_modal_view(request, loc_pk):
|
||||
try:
|
||||
uuids = Client.objects.filter(report_user=request.user).values_list('uuid')
|
||||
account = Accounting.objects.filter(reporter_uuid__in=uuids).first
|
||||
accounts = Accounting.objects.filter(reporter_uuid__in=uuids)
|
||||
# TODO: support multiple account objects
|
||||
except Client.DoesNotExist:
|
||||
account = None
|
||||
accounts = None
|
||||
context = {
|
||||
'account': account,
|
||||
'accounts': accounts,
|
||||
'loc_pk': loc_pk,
|
||||
'pks': ','.join([account.pk for account in accounts]),
|
||||
}
|
||||
return render(request, 'billard/accountmodal.html', context=context)
|
||||
|
||||
|
||||
@login_required
|
||||
def account_modal_confirm_view(request, loc_pk, pk):
|
||||
def account_modal_confirm_view(request, loc_pk, pks):
|
||||
for pk in pks.split(','):
|
||||
account = Accounting.objects.get(pk=pk)
|
||||
account.reporter_uuid = None
|
||||
account.save()
|
||||
|
Loading…
Reference in New Issue
Block a user