{% extends "layout.html" %} {% set active_page = "orders" -%} {% if current_user.is_anonymous() %} {% set my_items = order.for_user(anon=session.get("anon_name", "")) %} {% else %} {% set my_items = order.for_user(user=current_user) %} {% endif %} {% set courier_or_admin = not current_user.is_anonymous() and (current_user.is_admin() or current_user.id == order.courier_id) -%} {% import "utils.html" as util %} {% block metas %} {{ super() }} {% endblock %} {% block container %}

Order {{ order.id }}

{% if order.location %} {{ order.location_name }} {% else %} {{ order.location_name }} {% endif %}

My items

{% if my_items %}
    {% for item in my_items %}
  • {% if item.can_delete(order.id, current_user.id, session.get('anon_name', '')) -%}
    {%- endif %} {{ item.dish_name }}{% if item.comment %}; {{ item.comment }}{% endif %} {{ item.price | euro }}
  • {% endfor %}
{% else %}
(None)
{% endif %}
{% if form %}

Add item to order

{% for dish in order.location.dishes %}
{{ form.csrf_token }} {% if form.dish_id.errors %}
{{ util.render_form_field_errors(form.dish_id) }}
{% endif %}
{{ dish.name }} {{ dish.price_range() | price_range }} {% if dish.description %}
{{ dish.description }}
{% endif %} {% for (choice_type, choice) in dish.choices %}

{% endfor %}
{{ form.comment.label }}
{{ form.comment(class='form-control', placeholder='Fill in comment, when applicable') }} {{ util.render_form_field_errors(form.comment) }}
{% if current_user.is_anonymous() %}
{{ form.user_name.label(class='control-label') }} {{ form.user_name(class='form-control', placeholder='Fill in your name...') }} {{ util.render_form_field_errors(form.user_name) }}
{% endif %}
{{ form.submit_button(class='btn btn-primary') }}
{% endfor %}
{% endif %} {% if form %}
{% endif %}

Order information

Order opens
{{ order.starttime.strftime("%Y-%m-%d, %H:%M") }}
Order closes
{% if order.stoptime %} {% set stoptimefmt = ( "%H:%M" if order.stoptime.date() == order.starttime.date() else "%Y-%m-%d, %H:%M" ) %} {{ order.stoptime.strftime(stoptimefmt) }} ({{ order.stoptime|countdown }}) {% else %} Never {% endif %}
Location
{% if order.location %} {{ order.location_name }} {% else %} {{ order.location_name }} {% endif %}
Courier
{% if order.courier == None %} {% if not current_user.is_anonymous() %}
{% else %}No-one{% endif %} {% else %} {{ order.courier.username }} {% endif %}
{% if order.can_close(current_user.id) -%}
{% endif %} {% if courier_or_admin %} Edit {%- endif %}

About {{ order.location_name }}

{% if order.location.telephone %}
Telephone
{{ order.location.telephone }}
{% endif %} {% if order.location.website %}
Website
{{ order.location.website }}
{% endif %} {% if order.location.address or order.location.osm %}
Location
{% if order.location.osm %} {{ order.location.address or "View on OSM" }} {% else %} {{ order.location.address }} {% endif %}
{% endif %}
{% if not form %}
{% endif %}

Ordered dishes

{% for dish_name, dish_order_items in order.group_by_dish() -%} {% set has_comments = dish_order_items | map(attribute="comment") | any -%}

{{ dish_order_items | length }} × {{ dish_name }}

{% if has_comments -%}
    {% for item in dish_order_items -%}
  • {% if item["comment"] %}{{ item["comment"] }} {% else %}No comment {% endif %} for {{ item.for_name }}
  • {% endfor %}
{% else %} for {{ dish_order_items | map(attribute="for_name") | join(", ") }} {%- endif %}

{%- endfor %}

Items per person

{% for user_name, order_items in order.group_by_user() -%} {%- endfor %}
TotalNameItems
{% set paid = order_items | map(attribute="paid") | all %} {{ order_items | map(attribute="price") | sum | euro }} {% if paid %}paid{% endif %} {{ user_name }}
    {% for item in order_items %}
  • {% if item.can_delete(order.id, current_user.id, session.get('anon_name', '')) -%}
    {% else %} {%- endif %}
    {{ item.price|euro }}
    {{ item.dish_name }}{{ "; " + item.comment if item.comment }}
  • {% endfor %}
{% endblock %} {% block styles %} {{ super() }} {% endblock %} {% block scripts %} {{ super() }} {% if form %} {% endif %} {% endblock %}