2015-03-31 20:15:22 +02:00
|
|
|
{% extends "layout.html" %}
|
|
|
|
{% set active_page = "orders" -%}
|
2015-06-04 21:20:38 +02:00
|
|
|
{% set order_items = order.group_by_user() -%}
|
2015-06-05 14:27:55 +02:00
|
|
|
{% set courier_or_admin = not current_user.is_anonymous() and (current_user.is_admin() or current_user.id == order.courrier_id) -%}
|
2015-03-31 20:15:22 +02:00
|
|
|
|
|
|
|
{% import "utils.html" as util %}
|
|
|
|
|
|
|
|
{% block container %}
|
|
|
|
<div class="row">
|
2015-06-05 11:29:14 +02:00
|
|
|
<div class="col-md-push-1 col-md-10 darker" id="info"><!-- Shitty html-->
|
|
|
|
<h3 id="order-title">Order {{ order.id }}
|
2015-06-09 13:46:37 +02:00
|
|
|
<div class="pull-right">
|
2015-06-05 14:27:55 +02:00
|
|
|
{% if order.can_close(current_user.id) -%}
|
2019-08-28 03:46:04 +02:00
|
|
|
<a class="btn btn-danger" href="{{ url_for('order_bp.close_order', id=order.id) }}">Close</a>
|
2015-06-05 14:27:55 +02:00
|
|
|
{% endif %}{% if courier_or_admin %}
|
2019-08-28 03:46:04 +02:00
|
|
|
<a class="btn btn-warning" href="{{ url_for('order_bp.order_edit', id=order.id) }}">Edit</a>
|
2015-06-09 13:46:37 +02:00
|
|
|
{%- endif %}
|
|
|
|
</div></h3>
|
2015-04-05 13:08:02 +02:00
|
|
|
courier: {{ order.courrier.username }}
|
2015-03-31 20:15:22 +02:00
|
|
|
{% if order.courrier == None and not current_user.is_anonymous() %}
|
2019-08-28 03:46:04 +02:00
|
|
|
<a href="{{ url_for('order_bp.volunteer', id=order.id) }}" class="btn btn-primary btn-sm">Volunteer</a>
|
2015-03-31 20:15:22 +02:00
|
|
|
{% endif %}
|
|
|
|
<br/>
|
|
|
|
location: <a href="{{ order.location.website }}">{{ order.location.name }}</a><br/>
|
2015-06-04 18:45:59 +02:00
|
|
|
{% if order.location.telephone != None %}
|
|
|
|
telephone: <a href="tel://{{ order.location.telephone }}">{{ order.location.telephone }}</a><br/>
|
|
|
|
{% endif %}
|
2019-02-15 19:03:35 +01:00
|
|
|
start: {{ order.starttime.strftime("%d/%m/%Y %H:%M") }}<br>
|
2019-02-15 16:47:02 +01:00
|
|
|
{% if order.stoptime %}
|
|
|
|
closing time: {{ order.stoptime.strftime("%H:%M") }} (<span class="time">{{ order.stoptime|countdown }}</span>)
|
|
|
|
{% else %}open{% endif %}<br/>
|
2015-06-04 21:20:38 +02:00
|
|
|
total price: {{ total_price|euro }} {% if courier_or_admin %}- remaining debts: {{ debts|euro }}{% endif %}
|
2015-03-31 20:15:22 +02:00
|
|
|
</div>
|
|
|
|
{% if form -%}
|
2015-06-05 11:29:14 +02:00
|
|
|
<div class="col-md-push-1 col-md-10 darker" id="form">
|
2015-03-31 20:15:22 +02:00
|
|
|
<h4>Order:</h4>
|
2019-08-28 03:46:04 +02:00
|
|
|
<form method="post" action="{{ url_for('order_bp.order_item_create', id=order.id) }}">
|
2018-03-19 18:52:15 +01:00
|
|
|
<span class="pull-right">
|
|
|
|
<a class="btn btn-primary" onclick="chooseRandom()">Choose for me</a>
|
|
|
|
</span>
|
2015-03-31 20:15:22 +02:00
|
|
|
{{ 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>
|
2015-06-24 22:10:26 +02:00
|
|
|
<div class="form-group {{ 'has-errors' if form.product_id.errors }}">
|
|
|
|
{{ form.extra.label(class='control-label') }}<br>
|
|
|
|
{{ form.extra(class='form-control', placeholder='Fill in extras, when applicable') }}
|
|
|
|
{{ util.render_form_field_errors(form.extra) }}
|
|
|
|
</div>
|
2015-03-31 20:15:22 +02:00
|
|
|
{% 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') }}
|
2015-04-02 20:56:31 +02:00
|
|
|
{{ form.name(class='form-control', placeholder='Fill in your name...') }}
|
2015-03-31 20:15:22 +02: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>
|
2015-06-05 11:29:14 +02:00
|
|
|
<div class="row" id="items">
|
|
|
|
<div class="col-md-push-1 col-md-5 darker" id="items-list">
|
2015-06-04 21:20:38 +02:00
|
|
|
<h3>Items</h3>
|
|
|
|
<table class="table table-hover table-condensed">
|
|
|
|
<thead>
|
2015-06-24 22:24:21 +02:00
|
|
|
<tr><th>Name</th><th>Item</th><th>Price</th>{% if courier_or_admin %}<th>Paid?</th>{% endif %}<th>Delete</th></tr>
|
2015-06-04 21:20:38 +02:00
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
{% for item in order.items -%}
|
|
|
|
<tr>
|
|
|
|
<td>{{ item.get_name() }}</td>
|
2015-06-24 22:24:21 +02:00
|
|
|
<td><span title="{{ item.extra if item.extra }}">{{ item.product.name }}{{ "*" if item.extra }}</span></td>
|
2015-06-04 21:20:38 +02:00
|
|
|
<td>{{ item.product.price|euro }}</td>
|
2019-08-28 03:46:04 +02:00
|
|
|
{% if courier_or_admin %}<td>{% if not item.paid %} <a class="btn btn-xs btn-primary" href="{{ url_for('order_bp.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', '')) -%}<a href="{{ url_for('order_bp.delete_item', order_id=order.id, item_id=item.id) }}"><span class="glyphicon glyphicon-remove"></span></a>{%- endif %}<br/></td>
|
2015-06-04 21:20:38 +02:00
|
|
|
</tr>
|
|
|
|
{%- endfor %}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
2015-03-31 20:15:22 +02:00
|
|
|
</div>
|
2019-05-29 20:12:19 +02:00
|
|
|
<div class="col-md-push-2 col-md-4 darker box" id="items-ordered">
|
2018-03-10 00:50:02 +01:00
|
|
|
<h3>Ordered products: {{ order.items.count() }}</h3>
|
2019-08-28 03:46:04 +02:00
|
|
|
<a class="divLink" href="{{ url_for('order_bp.items_showcase', id=order.id) }}"></a>
|
2015-06-04 21:20:38 +02:00
|
|
|
{% for key, value in order.group_by_product().items() -%}
|
2015-06-24 22:10:26 +02:00
|
|
|
<div class="product">
|
|
|
|
{{ key }}: {{ value["count"] }}
|
|
|
|
{% if value["extras"] -%}
|
|
|
|
<div class="extras">
|
|
|
|
{% for extra in value["extras"] -%}
|
|
|
|
<div>{{ extra }}</div>
|
|
|
|
{% endfor %}
|
|
|
|
</div>
|
|
|
|
{%- endif %}
|
|
|
|
</div>
|
2015-06-04 21:20:38 +02:00
|
|
|
{%- endfor %}
|
2015-03-31 20:15:22 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="row">
|
2015-06-05 11:29:14 +02:00
|
|
|
<div class="col-md-push-1 col-md-5 darker" id="debts">
|
2015-03-31 20:15:22 +02:00
|
|
|
<h3>Debts</h3>
|
2015-06-04 21:20:38 +02: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>
|
2019-08-28 03:46:04 +02:00
|
|
|
{% if courier_or_admin %}<td>{% if not value["to_pay"] == 0 %} <a class="btn btn-xs btn-primary" href="{{ url_for('order_bp.items_user_paid', order_id=order.id, user_name=key) }}">Pay</a> {% else %} <span class="glyphicon glyphicon-chevron-down"></span> {% endif %}</td>{% endif %}
|
2015-06-04 21:20:38 +02:00
|
|
|
</tr>
|
|
|
|
{%- endfor %}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
2015-03-31 20:15:22 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{% endblock %}
|
|
|
|
|
|
|
|
{% block styles %}
|
|
|
|
{{ super() }}
|
2019-04-05 23:10:12 +02:00
|
|
|
<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.0/css/select2.min.css" rel="stylesheet" />
|
2015-03-31 20:15:22 +02:00
|
|
|
<link rel="stylesheet" href="{{ url_for('static', filename='css/select2-bootstrap.min.css') }}">
|
2015-06-05 11:29:14 +02:00
|
|
|
<link rel="stylesheet" href="{{ url_for('static', filename='css/print.css') }}">
|
2015-03-31 20:15:22 +02:00
|
|
|
{% endblock %}
|
|
|
|
{% block scripts %}
|
|
|
|
{{ super() }}
|
2019-04-05 23:10:12 +02:00
|
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.0/js/select2.min.js"></script>
|
2015-03-31 20:15:22 +02:00
|
|
|
<script type="text/javascript">
|
2018-03-19 18:52:15 +01:00
|
|
|
var select = $('.select').select2({
|
2015-06-09 13:46:37 +02:00
|
|
|
'sorter': function(results) {
|
|
|
|
return results.sort();
|
|
|
|
}
|
|
|
|
});
|
2018-03-19 18:52:15 +01:00
|
|
|
var options = select[0].options;
|
|
|
|
function chooseRandom() {
|
|
|
|
var index = Math.floor((Math.random() * options.length))
|
|
|
|
var choice = options[index]
|
|
|
|
select.val(choice.value).trigger("change")
|
|
|
|
}
|
2015-03-31 20:15:22 +02:00
|
|
|
</script>
|
2015-04-05 13:08:02 +02:00
|
|
|
{% endblock %}
|