-
Notifications
You must be signed in to change notification settings - Fork 3
/
order.html
168 lines (158 loc) · 7.1 KB
/
order.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
{% extends "_base.html" %}
{% load static %}
{% block title %}
Order
{% endblock %}
{% block script %}
<script src="{% static 'js/order.js' %}"></script>
{% endblock %}
{% block nav_list %}
<li><a href="../menu">Menu</a></li>
<li><a href="../cart">Shopping chart</a></li>
<li><a href="../orders">Orders</a></li>
<li class="active"><a href="#">#{{ order.id }}</a></li>
{% endblock %}
{% block disp %}
<h2>Order #{{ order.id }}</h2>
<form id="modify_order" action="{% url 'order' id=order.id %}" method="post">
{% csrf_token %}
{% if items|length > 0 %}
<table class="table table-striped table-hover table-responsive" cellspacing="0">
<thead>
<th width="50%" colspan="2"></th>
<th width="10%">Servings</th>
<th width="10%">Unit Price</th>
<th width="15%">Created</th>
<th width="15%">Updated</th>
</thead>
<tbody>
{% for item in items %}
<tr>
<td width="50%" colspan="2">
<span data-toggle="tooltip" title="${{ item.item.product.price }}/serving">
<strong>{{ item.item.product.category }}</strong> - {{ item.item.product.name}} ({{ item.item.product.size }})
</span>
</td>
<td width="10%">
<input id="product_{{ item.item.id }}" name="product_{{ item.item.id }}" data-class="qty" data-item="{{ item.item.id }}"
type="number" min="0" style="width:50%" value="{{ item.quantity }}"
{% if order.status != 'Pending' %}readonly{% endif %} />
</td>
<td width="10%">
$<span id="product_price_{{ item.item.id }}" name="product_price_{{ item.item.id }}" data-class="price"
data-item="{{ item.item.id }}">{{ item.item.price }}</span>
</td>
<td width="15%">{{ item.item.created|date:"Y/m/d H:i:s" }}</td>
<td width="15%">{{ item.item.updated|date:"Y/m/d H:i:s" }}</td>
</tr>
{% if item.item.topping.all|length > 0 %}
{% for topping in item.item.itemtopping_item.all %}
<tr>
<td width="10%"></td>
<td width="40%">
<span data-toggle="tooltip" title="${{ topping.topping.price }}/serving">
<span style="color:#bbb">+Topping:</span> {{ topping.topping.name }} x {{ topping.quantity }}
</span>
</td>
<td width="10%"></td>
<td width="10%"></td>
<td width="15%"></td>
<td width="15%"></td>
</tr>
{% endfor %}
{% endif %}
{% if item.item.addition.all|length > 0 %}
{% for addition in item.item.itemaddition_item.all %}
<tr>
<td width="10%"></td>
<td width="40%">
<span data-toggle="tooltip" title="${{ addition.addition.price }}/serving">
<span style="color:#bbb">+Addition:</span> {{ addition.addition.name }} ({{ addition.addition.size }}) x {{ addition.quantity }}
</span>
</td>
<td width="10%"></td>
<td width="10%"></td>
<td width="15%"></td>
<td width="15%"></td>
</tr>
{% endfor %}
{% endif %}
{% endfor %}
</tbody>
</table>
{% else %}
<p>No items found.</p>
{% endif %}
<hr>
<div class="container">
<div class="row">
<div class="col-lg-8 col-md-8 col-sm-0"></div>
<div class="col-lg-1 col-md-1 col-sm-4"><h4>Status: </h4></div>
<div class="col-lg-3 col-md-3 col-sm-8">
<h4 style="text-align:right;font-weight:bold">
<span id="status" class=
{% if order.status == 'Paid' %}"text-success bg-success"
{% elif order.status == 'Completed' %}"text-info bg-info"
{% elif order.status == 'Failed' %}"text-danger bg-danger"
{% elif order.status == 'Cancelled' %}"text-muted"
{% else %}"bg-primary"
{% endif %}>{{ order.status }}
</span>
</h4>
</div>
</div>
<div class="row">
<div class="col-lg-8 col-md-8 col-sm-0"></div>
<div class="col-lg-1 col-md-1 col-sm-4"><h4>Created: </h4></div>
<div class="col-lg-3 col-md-3 col-sm-8">
<h4 style="text-align:right"><span>{{ order.created|date:"Y/m/d H:i:s" }}</span></h4>
</div>
</div>
<div class="row">
<div class="col-lg-8 col-md-8 col-sm-0"></div>
<div class="col-lg-1 col-md-1 col-sm-4"><h4>Updated: </h4></div>
<div class="col-lg-3 col-md-3 col-sm-8">
<h4 style="text-align:right"><span>{{ order.updated|date:"Y/m/d H:i:s" }}</span></h4>
</div>
</div>
<div class="row">
<div class="col-lg-8 col-md-8 col-sm-0"></div>
<div class="col-lg-1 col-md-1 col-sm-4"><h4>Total: </h4></div>
<div class="col-lg-3 col-md-3 col-sm-8">
<h4 style="text-align:right;font-weight:bold">$<span id="total_price">{{ cart_sum }}</span></h4>
</div>
</div>
<div class="row">
<div class="col-lg-8 col-md-6 col-sm-0"></div>
<div class="col-lg-2 col-md-3 col-sm-6">
<button id="btn_save" name="btn_save" value="{{ order.id }}" type="submit" class="btn btn-secondary btn-block"
{% if order.status != 'Pending' %}
disabled="disabled"
{% endif %}>Save</button>
</div>
<div class="col-lg-2 col-md-3 col-sm-6">
<button id="btn_pay" name="btn_pay" value="{{ order.id }}" type="submit" class="btn btn-primary btn-block"
{% if order.status == 'Paid' or order.status == 'Completed' or order.status == 'Cancelled' %}
disabled="disabled"
{% endif %}>Pay</button>
</div>
</div>
<div class="col-12"> </div>
<div class="row">
<div class="col-lg-8 col-md-6 col-sm-0"></div>
<div class="col-lg-2 col-md-3 col-sm-6">
<button id="btn_cancel" name="btn_cancel" value="{{ order.id }}" type="submit" class="btn btn-warning btn-block"
{% if order.status == 'Paid' or order.status == 'Cancelled' %}
disabled="disabled"
{% endif %}>Cancel</button>
</div>
<div class="col-lg-2 col-md-3 col-sm-6">
<button id="btn_delete" name="btn_delete" value="{{ order.id }}" type="submit" class="btn btn-danger btn-block"
{% if order.status == 'Paid' or order.status == 'Completed' %}
disabled="disabled"
{% endif %}>Delete</button>
</div>
</div>
</div>
</form>
{% endblock disp %}