{% extends "layout.html" %} {% set active_page = "orders" -%} {% set order_items = order.group_by_user() -%} {% set courier_or_admin = not current_user.is_anonymous() and (current_user.is_admin() or current_user.id == order.courrier_id) -%} {% import "utils.html" as util %} {% block container %}

Order {{ order.id }}
{% if order.can_close(current_user.id) -%} Close {% endif %}{% if courier_or_admin %} Edit {%- 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 %} start: {{ order.starttime.strftime("%d/%m/%Y %H:%M") }}
{% if order.stoptime %} closing time: {{ order.stoptime.strftime("%H:%M") }} ({{ order.stoptime|countdown }}) {% else %}open{% endif %}
total price: {{ total_price|euro }} {% if courier_or_admin %}- remaining debts: {{ debts|euro }}{% endif %}
{% if form -%}

Order:

Choose for me {{ 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) }}
{{ form.extra.label(class='control-label') }}
{{ form.extra(class='form-control', placeholder='Fill in extras, when applicable') }} {{ util.render_form_field_errors(form.extra) }}
{% 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 }}{{ "*" if item.extra }} {{ item.product.price|euro }}{% if not item.paid %} Pay {% else %} {% endif %}{% if item.can_delete(order.id, current_user.id, session.get('anon_name', '')) -%}{%- endif %}

Ordered products: {{ order.items.count() }}

{% for key, value in order.group_by_product().items() -%}
{{ key }}: {{ value["count"] }} {% if value["extras"] -%}
{% for extra in value["extras"] -%}
{{ extra }}
{% endfor %}
{%- endif %}
{%- 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 %}