haldis/app/templates/order.html
Feliciaan De Palmenaer 39cfd77a7d Merge branch 'master' of github.com:ZeusWPI/Foodbot into feat/19/paid-indicator
* 'master' of github.com:ZeusWPI/Foodbot:
  Edit orders
2015-06-04 21:24:13 +02:00

112 lines
5.5 KiB
HTML

{% 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 %}
<div class="row">
<div class="col-md-push-1 col-md-10 darker"><!-- Shitty html-->
<h3>Order {{ order.id }}
{% if courier_or_admin -%}
<a class="btn btn-danger pull-right" href="{{ url_for('.close_order', id=order.id) }}">Close</a><br/>
<a class="btn btn-warning pull-right" href="{{ url_for('.order_edit', id=order.id) }}">Edit</a>
{%- endif %}</h3>
courier: {{ order.courrier.username }}
{% if order.courrier == None and not current_user.is_anonymous() %}
<a href="{{ url_for('.volunteer', id=order.id) }}" class="btn btn-primary btn-sm">Volunteer</a>
{% endif %}
<br/>
location: <a href="{{ order.location.website }}">{{ order.location.name }}</a><br/>
{% if order.location.telephone != None %}
telephone: <a href="tel://{{ order.location.telephone }}">{{ order.location.telephone }}</a><br/>
{% endif %}
<b>status:</b> {% if order.stoptime %}<span class="time">{{ order.stoptime|countdown }}</span>{% else %}open{% endif %}<br/>
total price: {{ total_price|euro }} {% if courier_or_admin %}- remaining debts: {{ debts|euro }}{% endif %}
</div>
{% if form -%}
<div class="col-md-push-1 col-md-10 darker">
<h4>Order:</h4>
<form method="post" action="{{ url_for('.order_item_create', id=order.id) }}">
{{ form.csrf_token }}
<div class="form-group select2-container select2 {{ 'has-errors' if form.product_id.errors}}">
{{ form.product_id.label(class='control-label') }}<br>
{{ form.product_id(class='form-control select') }}
{{ util.render_form_field_errors(form.product_id) }}
</div>
{% if current_user.is_anonymous() %}
<div class="form-group{{ ' has-error' if form.name.errors }}{{ ' required' if form.name.flags.required }}">
{{ form.name.label(class='control-label') }}
{{ form.name(class='form-control', placeholder='Fill in your name...') }}
{{ util.render_form_field_errors(form.name) }}
</div>
{% endif %}
<div class="form-group" style="padding-top: 8px;">
{{ form.submit_button(class='btn btn-primary') }}
</div>
</form>
</div>
{%- endif %}
</div>
<div class="row">
<div class="col-md-push-1 col-md-5 darker">
<h3>Items</h3>
<table class="table table-hover table-condensed">
<thead>
<tr><th>Name</th><th>Item</th><th>Price</th>{% if courier_or_admin %}<th>Paid?</th>{% endif %}<th>Delete</th></tr>
</thead>
<tbody>
{% for item in order.items -%}
<tr>
<td>{{ item.get_name() }}</td>
<td>{{ item.product.name }}</td>
<td>{{ item.product.price|euro }}</td>
{% if courier_or_admin %}<td>{% if not item.paid %} <a class="btn btn-xs btn-primary" href="{{ url_for('.item_paid', order_id=order.id, item_id=item.id) }}">Pay</a> {% else %} <span class="glyphicon glyphicon-chevron-down"></span> {% endif %}</td>{% endif %}
<td>{% if item.can_delete(order.id, current_user.id, session.get('anon_name', '')) or courier_or_admin -%}<a href="{{ url_for('.delete_item', order_id=order.id, item_id=item.id) }}"><span class="glyphicon glyphicon-remove"></span></a>{%- endif %}<br/></td>
</tr>
{%- endfor %}
</tbody>
</table>
</div>
<div class="col-md-push-2 col-md-4 darker">
<h3>Ordered products:</h3>
{% for key, value in order.group_by_product().items() -%}
{{ key }} - {{ value }}<br/>
{%- endfor %}
</div>
</div>
<div class="row">
<div class="col-md-push-1 col-md-5 darker">
<h3>Debts</h3>
<table class="table table-hover table-condensed">
<thead>
<tr><th>Name</th><th>Total</th><th>To pay</th>{% if courier_or_admin %}<th>Paid?</th>{% endif %}</tr>
</thead>
<tbody>
{% for key, value in order_items.items() -%}
<tr>
<td>{{ key }}</td>
<td>{{ value["total"]|euro }}</td>
<td>{{ value["to_pay"]|euro }}</td>
{% if courier_or_admin %}<td>{% if not value["to_pay"] == 0 %} <a class="btn btn-xs btn-primary" href="{{ url_for('.items_user_paid', order_id=order.id, user_name=key) }}">Pay</a> {% else %} <span class="glyphicon glyphicon-chevron-down"></span> {% endif %}</td>{% endif %}
</tr>
{%- endfor %}
</tbody>
</table>
</div>
</div>
{% endblock %}
{% block styles %}
{{ super() }}
<link href="//cdnjs.cloudflare.com/ajax/libs/select2/4.0.0-rc.2/css/select2.min.css" rel="stylesheet" />
<link rel="stylesheet" href="{{ url_for('static', filename='css/select2-bootstrap.min.css') }}">
{% endblock %}
{% block scripts %}
{{ super() }}
<script src="//cdnjs.cloudflare.com/ajax/libs/select2/4.0.0-rc.2/js/select2.min.js"></script>
<script type="text/javascript">
$('.select').select2();
</script>
{% endblock %}