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() -%}
|
2020-01-26 02:28:20 +01:00
|
|
|
{% set courier_or_admin = not current_user.is_anonymous() and (current_user.is_admin() or current_user.id == order.courier_id) -%}
|
2015-03-31 20:15:22 +02:00
|
|
|
|
|
|
|
{% import "utils.html" as util %}
|
|
|
|
|
|
|
|
{% block container %}
|
|
|
|
<div class="row">
|
2019-12-05 19:39:35 +01:00
|
|
|
<div class="col-md-push-1 col-md-10 darker order_overview" id="info"><!-- Shitty html -->
|
2015-06-05 11:29:14 +02:00
|
|
|
<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-09-10 02:50:22 +02:00
|
|
|
<form action="{{ url_for('order_bp.close_order', order_id=order.id) }}" method="post" style="display:inline">
|
2019-09-11 16:44:36 +02:00
|
|
|
<input type="submit" class="btn btn-danger" value="Close"></input>
|
|
|
|
</form>
|
2015-06-05 14:27:55 +02:00
|
|
|
{% endif %}{% if courier_or_admin %}
|
2019-09-10 02:50:22 +02:00
|
|
|
<a class="btn btn-warning" href="{{ url_for('order_bp.order_edit', order_id=order.id) }}">Edit</a>
|
2015-06-09 13:46:37 +02:00
|
|
|
{%- endif %}
|
|
|
|
</div></h3>
|
2020-01-26 02:28:20 +01:00
|
|
|
courier: {{ order.courier.username }}
|
|
|
|
{% if order.courier == None and not current_user.is_anonymous() %}
|
2019-09-10 02:50:22 +02:00
|
|
|
<form action="{{ url_for('order_bp.volunteer', order_id=order.id) }}" method="post" style="display:inline">
|
2019-09-11 16:44:36 +02:00
|
|
|
<input type="submit" class="btn btn-primary btn-sm" value="Volunteer"></input>
|
|
|
|
</form>
|
2015-03-31 20:15:22 +02:00
|
|
|
{% endif %}
|
|
|
|
<br/>
|
2020-01-27 22:59:07 +01:00
|
|
|
location: {% if order.location %}
|
|
|
|
<a href="{{ url_for('general_bp.location', location_id=order.location_id) }}">{{ order.location_name }}</a>
|
|
|
|
{% else %}
|
|
|
|
{{ order.location_name }}
|
|
|
|
{% endif %}<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 -%}
|
2019-12-05 19:39:35 +01:00
|
|
|
<div class="col-md-push-1 col-md-10 darker order_order" id="form">
|
2015-03-31 20:15:22 +02:00
|
|
|
<h4>Order:</h4>
|
2019-09-10 02:50:22 +02:00
|
|
|
<form method="post" action="{{ url_for('order_bp.order_item_create', order_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 }}
|
2020-01-27 02:31:02 +01:00
|
|
|
<div class="form-group select2-container select2 {{ 'has-errors' if form.dish_id.errors}}">
|
|
|
|
{{ form.dish_id.label(class='control-label') }}<br>
|
|
|
|
{{ form.dish_id(class='form-control select') }}
|
|
|
|
{{ util.render_form_field_errors(form.dish_id) }}
|
2015-03-31 20:15:22 +02:00
|
|
|
</div>
|
2020-02-23 23:29:39 +01:00
|
|
|
|
|
|
|
{% if dish and dish.choices %}
|
2020-02-24 14:19:20 +01:00
|
|
|
<input type="hidden" name="form_for_dish" value="{{ dish.id }}" />
|
2020-02-23 23:29:39 +01:00
|
|
|
{% for (choice_type, choice) in dish.choices %}
|
|
|
|
<div class="form-group select2-container select2">
|
|
|
|
<label class="control-label" for="choice_{{ choice.id }}">{{ choice.name }}</label><br/>
|
|
|
|
<select
|
|
|
|
{{ "multiple=multiple" if choice_type=="multi_choice" else "required=required" }}
|
|
|
|
name="choice_{{ choice.id }}"
|
|
|
|
class="form-control select">
|
|
|
|
{% for option in choice.options %}
|
2020-02-24 14:33:43 +01:00
|
|
|
<option value="{{ option.id }}"><!--
|
|
|
|
-->{{ option.name }}{{ ": " + option.price|euro if option.price else "" }}<!--
|
|
|
|
-->{{ " (" + option.description + ")" if option.description else "" }}<!--
|
|
|
|
--></option>
|
2020-02-23 23:29:39 +01:00
|
|
|
{% endfor %}
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
{% endfor %}
|
|
|
|
{% endif %}
|
|
|
|
|
2020-01-27 02:31:02 +01:00
|
|
|
<div class="form-group {{ 'has-errors' if form.dish_id.errors }}">
|
|
|
|
{{ form.comment.label(class='control-label') }}<br>
|
|
|
|
{{ form.comment(class='form-control', placeholder='Fill in comment, when applicable') }}
|
|
|
|
{{ util.render_form_field_errors(form.comment) }}
|
2015-06-24 22:10:26 +02:00
|
|
|
</div>
|
2020-02-21 18:38:30 +01:00
|
|
|
|
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">
|
2019-12-05 19:39:35 +01:00
|
|
|
<div class="col-md-push-1 col-md-5 darker order_items" 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>
|
2020-01-27 02:31:02 +01:00
|
|
|
<td><span title="{{ item.comment if item.comment }}">{{ item.dish_name }}{{ "*" if item.comment }}</span></td>
|
|
|
|
<td>{{ item.price|euro }}</td>
|
2019-09-11 16:44:36 +02:00
|
|
|
{% if courier_or_admin %}<td>{% if not item.paid %}
|
|
|
|
<form action="{{ url_for('order_bp.item_paid', order_id=order.id, item_id=item.id) }}" method="post" style="display:inline">
|
|
|
|
<input type="submit" class="btn btn-xs btn-primary" value="Pay"></input>
|
|
|
|
</form>
|
|
|
|
{% 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', '')) -%}
|
|
|
|
<form action="{{ url_for('order_bp.delete_item', order_id=order.id, item_id=item.id) }}" method="post" style="display:inline">
|
|
|
|
<button class="btn btn-link" type="submit"><span class="glyphicon glyphicon-remove"></span></button>
|
|
|
|
</form>
|
|
|
|
{%- 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-12-05 19:39:35 +01:00
|
|
|
<div class="col-md-push-2 col-md-4 darker box order_ordered" id="items-ordered">
|
2020-01-27 02:31:02 +01:00
|
|
|
<h3>Ordered dishes: {{ order.items.count() }}</h3>
|
2019-09-10 02:50:22 +02:00
|
|
|
<a class="divLink" href="{{ url_for('order_bp.items_showcase', order_id=order.id) }}"></a>
|
2020-01-27 02:31:02 +01:00
|
|
|
{% for key, value in order.group_by_dish().items() -%}
|
2015-06-24 22:10:26 +02:00
|
|
|
<div class="product">
|
|
|
|
{{ key }}: {{ value["count"] }}
|
2020-01-27 03:41:38 +01:00
|
|
|
{% if value["comments"]|any -%}
|
|
|
|
<ul class="comments">
|
2020-01-27 02:31:02 +01:00
|
|
|
{% for comment in value["comments"] -%}
|
2020-01-27 03:41:38 +01:00
|
|
|
<li>{% if comment %}{{ comment }}
|
|
|
|
{% else %}<i>No comment</i>
|
|
|
|
{% endif %}</li>
|
2015-06-24 22:10:26 +02:00
|
|
|
{% endfor %}
|
2020-01-27 03:41:38 +01:00
|
|
|
</ul>
|
2015-06-24 22:10:26 +02:00
|
|
|
{%- endif %}
|
|
|
|
</div>
|
2015-06-04 21:20:38 +02:00
|
|
|
{%- endfor %}
|
2015-03-31 20:15:22 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="row">
|
2019-12-05 19:39:35 +01:00
|
|
|
<div class="col-md-push-1 col-md-5 darker order_depts" 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-09-11 16:44:36 +02:00
|
|
|
{% if courier_or_admin %}<td>{% if not value["to_pay"] == 0 %}
|
|
|
|
<form action="{{ url_for('order_bp.items_user_paid', order_id=order.id, user_name=key) }}" method="post" style="display:inline">
|
|
|
|
<input type="submit" class="btn btn-xs btn-primary" value="Pay"></input>
|
|
|
|
</form>
|
|
|
|
{% 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-10-01 17:58:19 +02:00
|
|
|
<link rel="stylesheet" href="{{ url_for('static', filename='css/select2.min.css') }}" />
|
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-10-01 17:58:19 +02:00
|
|
|
<script src="{{ url_for('static', filename='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 %}
|