mirror of
https://github.com/ae-utbm/sith3.git
synced 2024-07-01 02:48:03 +00:00
80 lines
3.2 KiB
Django/Jinja
80 lines
3.2 KiB
Django/Jinja
{% extends "core/base.jinja" %}
|
|
|
|
{% macro add_product(id, content) %}
|
|
<form method="post" action="{{ url('counter:click', counter_id=counter.id, user_id=customer.user.id) }}" class="inline" style="display:inline">
|
|
{% csrf_token %}
|
|
<input type="hidden" name="action" value="add_product">
|
|
<button type="submit" name="product_id" value="{{ id }}"> {{ content }} </button>
|
|
</form>
|
|
{% endmacro %}
|
|
|
|
{% macro del_product(id, content) %}
|
|
<form method="post" action="{{ url('counter:click', counter_id=counter.id, user_id=customer.user.id) }}" class="inline" style="display:inline">
|
|
{% csrf_token %}
|
|
<input type="hidden" name="action" value="del_product">
|
|
<button type="submit" name="product_id" value="{{ id }}"> {{ content }} </button>
|
|
</form>
|
|
{% endmacro %}
|
|
|
|
{% block content %}
|
|
<h3>{% trans %}Counter{% endtrans %}</h3>
|
|
<h4>{{ counter }}</h4>
|
|
<p><strong>{% trans %}Club: {% endtrans %}</strong> {{ counter.club }}</p>
|
|
|
|
<div>
|
|
<h5>{% trans %}Customer{% endtrans %}</h5>
|
|
<p>{{ customer.user.get_display_name() }}, {{ customer.amount }} €</p>
|
|
</div>
|
|
{% if counter.type == 'BAR' %}
|
|
<div>
|
|
<h5>{% trans %}Refilling{% endtrans %}</h5>
|
|
<form method="post" action="{{ url('counter:click', counter_id=counter.id, user_id=customer.user.id) }}">
|
|
{% csrf_token %}
|
|
{{ refill_form.as_p() }}
|
|
<input type="hidden" name="action" value="refill">
|
|
<input type="submit" value="{% trans %}Go{% endtrans %}" />
|
|
</form>
|
|
</div>
|
|
{% endif %}
|
|
<div>
|
|
<h5>{% trans %}Selling{% endtrans %}</h5>
|
|
{% if request.session['not_enough'] %}
|
|
<p><strong>{% trans %}Not enough money{% endtrans %}</strong></p>
|
|
{% endif %}
|
|
<form method="post" action="{{ url('counter:click', counter_id=counter.id, user_id=customer.user.id) }}">
|
|
{% csrf_token %}
|
|
<input type="hidden" name="action" value="code">
|
|
<input type="input" name="code" value="" autofocus />
|
|
<input type="submit" value="{% trans %}Go{% endtrans %}" />
|
|
</form>
|
|
<p>{% trans %}Basket: {% endtrans %}</p>
|
|
<ul>
|
|
{% for id,infos in request.session['basket']|dictsort %}
|
|
{% set product = counter.products.filter(id=id).first() %}
|
|
{% set s = infos['qty'] * infos['price'] / 100 %}
|
|
<li>{{ del_product(id, '-') }} {{ infos['qty'] }} {{ add_product(id, '+') }} {{ product.name }}: {{ "%0.2f"|format(s) }} €</li>
|
|
{% endfor %}
|
|
</ul>
|
|
<p><strong>{% trans %}Total: {% endtrans %}{{ "%0.2f"|format(basket_total) }} €</strong></p>
|
|
<form method="post" action="{{ url('counter:click', counter_id=counter.id, user_id=customer.user.id) }}">
|
|
{% csrf_token %}
|
|
<input type="hidden" name="action" value="finish">
|
|
<input type="submit" value="{% trans %}Finish{% endtrans %}" />
|
|
</form>
|
|
<form method="post" action="{{ url('counter:click', counter_id=counter.id, user_id=customer.user.id) }}">
|
|
{% csrf_token %}
|
|
<input type="hidden" name="action" value="cancel">
|
|
<input type="submit" value="{% trans %}Cancel{% endtrans %}" />
|
|
</form>
|
|
<p><strong>{% trans %}Products: {% endtrans %}</strong>
|
|
{% for p in counter.products.all() %}
|
|
{{ add_product(p.id, p.name) }}
|
|
{% endfor %}
|
|
</p>
|
|
</div>
|
|
|
|
{% endblock %}
|
|
|
|
|
|
|