{% extends "layout.html" %} {% set active_page = "orders" -%} {% set order_items = order.group_by_user() -%} {% set courier_or_admin = order.can_close(current_user.id) -%} {% import "utils.html" as util %} {% block container %}

Order {{ order.id }} {% if courier_or_admin -%} Close
{%- endif %}

courier: {{ order.courrier.username }} {% if order.courrier == None and not current_user.is_anonymous() %} Volunteer {% endif %}
location: {{ order.location.name }}
{% if order.location.telephone != None %} telephone: {{ order.location.telephone }}
{% endif %} status: {% if order.stoptime %}{{ order.stoptime|countdown }}{% else %}open{% endif %}
total price: {{ total_price|euro }} {% if courier_or_admin %}- remaining debts: {{ debts|euro }}{% endif %}
{% if form -%}

Order:

{{ form.csrf_token }}
{{ form.product_id.label(class='control-label') }}
{{ form.product_id(class='form-control select') }} {{ util.render_form_field_errors(form.product_id) }}
{% if current_user.is_anonymous() %}
{{ form.name.label(class='control-label') }} {{ form.name(class='form-control', placeholder='Fill in your name...') }} {{ util.render_form_field_errors(form.name) }}
{% endif %}
{{ form.submit_button(class='btn btn-primary') }}
{%- endif %}

Items

{% if courier_or_admin %}{% endif %} {% for item in order.items -%} {% if courier_or_admin %}{% endif %} {%- endfor %}
NameItemPricePaid?Delete
{{ item.get_name() }} {{ item.product.name }} {{ item.product.price|euro }}{% if not item.paid %} Pay {% else %} {% endif %}{% if item.can_delete(order.id, current_user.id, session.get('anon_name', '')) or courier_or_admin -%}{%- endif %}

Ordered products:

{% for key, value in order.group_by_product().items() -%} {{ key }} - {{ value }}
{%- endfor %}

Debts

{% if courier_or_admin %}{% endif %} {% for key, value in order_items.items() -%} {% if courier_or_admin %}{% endif %} {%- endfor %}
NameTotalTo payPaid?
{{ key }} {{ value["total"]|euro }} {{ value["to_pay"]|euro }}{% if not value["to_pay"] == 0 %} Pay {% else %} {% endif %}
{% endblock %} {% block styles %} {{ super() }} {% endblock %} {% block scripts %} {{ super() }} {% endblock %}