haldis/app/templates/order.html

113 lines
5.5 KiB
HTML
Raw Normal View History

2015-03-31 18:15:22 +00:00
{% extends "layout.html" %}
{% set active_page = "orders" -%}
2015-06-04 19:20:38 +00:00
{% set order_items = order.group_by_user() -%}
{% set courier_or_admin = order.can_close(current_user.id) -%}
2015-03-31 18:15:22 +00:00
{% 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 }}
2015-06-04 19:20:38 +00:00
{% if courier_or_admin -%}
2015-03-31 18:15:22 +00:00
<a class="btn btn-danger pull-right" href="{{ url_for('.close_order', id=order.id) }}">Close</a><br/>
2015-06-04 17:11:08 +00:00
<a class="btn btn-warning pull-right" href="{{ url_for('.order_edit', id=order.id) }}">Edit</a>
2015-03-31 18:15:22 +00:00
{%- endif %}</h3>
2015-04-05 11:08:02 +00:00
courier: {{ order.courrier.username }}
2015-03-31 18:15:22 +00:00
{% 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/>
2015-06-04 16:45:59 +00:00
{% if order.location.telephone != None %}
telephone: <a href="tel://{{ order.location.telephone }}">{{ order.location.telephone }}</a><br/>
{% endif %}
2015-03-31 18:15:22 +00:00
<b>status:</b> {% if order.stoptime %}<span class="time">{{ order.stoptime|countdown }}</span>{% else %}open{% endif %}<br/>
2015-06-04 19:20:38 +00:00
total price: {{ total_price|euro }} {% if courier_or_admin %}- remaining debts: {{ debts|euro }}{% endif %}
2015-03-31 18:15:22 +00:00
</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...') }}
2015-03-31 18:15:22 +00:00
{{ 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">
2015-06-04 19:20:38 +00:00
<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>
2015-03-31 18:15:22 +00:00
</div>
2015-06-04 19:20:38 +00:00
<div class="col-md-push-2 col-md-4 darker">
2015-03-31 18:15:22 +00:00
<h3>Ordered products:</h3>
2015-06-04 19:20:38 +00:00
{% for key, value in order.group_by_product().items() -%}
2015-03-31 18:15:22 +00:00
{{ key }} - {{ value }}<br/>
2015-06-04 19:20:38 +00:00
{%- endfor %}
2015-03-31 18:15:22 +00:00
</div>
</div>
<div class="row">
2015-06-04 19:20:38 +00:00
<div class="col-md-push-1 col-md-5 darker">
2015-03-31 18:15:22 +00:00
<h3>Debts</h3>
2015-06-04 19:20:38 +00:00
<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>
2015-03-31 18:15:22 +00:00
</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>
2015-04-05 11:08:02 +00:00
{% endblock %}