|
|
@ -1,36 +1,46 @@ |
|
|
|
{% extends 'base.html' %} |
|
|
|
{% block main %} |
|
|
|
<h1>{{ title }}</h1> |
|
|
|
{% if event %} |
|
|
|
<h2>{{ event.name }}</h2> |
|
|
|
<h3>{{ event.starts_at }} → {{ event.ends_at }}</h3> |
|
|
|
{% else %} |
|
|
|
<h2>No ongoing event!</h2> |
|
|
|
{% endif %} |
|
|
|
<div id="products"> |
|
|
|
{% for product in products %} |
|
|
|
<button type="button" |
|
|
|
onclick="addProduct({{ product.uid }})"> |
|
|
|
<span class="name">{{ product.name }}</span> |
|
|
|
<span class="price">{{ product.price }}</span> |
|
|
|
<span class="price"> |
|
|
|
€ {{ '{0:.02f}'.format(product.price / 100.0) }} |
|
|
|
</span> |
|
|
|
</button> |
|
|
|
{% endfor %} |
|
|
|
</div> |
|
|
|
<div id="basket"> |
|
|
|
</div> |
|
|
|
<form id="sell" action="/sell" method="POST"> |
|
|
|
<div id="summary"> |
|
|
|
<div id="basket"></div> |
|
|
|
<form id="sell" action="/sell" method="POST"> |
|
|
|
{% for product in products %} |
|
|
|
<input type="hidden" |
|
|
|
id="prod_{{ product.uid }}" |
|
|
|
name="{{ product.uid }}" |
|
|
|
data-name="{{ product.name }}" |
|
|
|
data-price="{{ product.price }}" |
|
|
|
value="0"> |
|
|
|
<input type="hidden" |
|
|
|
id="prod_{{ product.uid }}" |
|
|
|
name="{{ product.uid }}" |
|
|
|
data-name="{{ product.name }}" |
|
|
|
data-price="{{ '{0:.02f}'.format(product.price / 100.0) }}" |
|
|
|
value="0"> |
|
|
|
{% endfor %} |
|
|
|
<button type="submit">Print</input> |
|
|
|
<p>Total: € <span id="total">0.00</span></p> |
|
|
|
<button type="submit">Print</input> |
|
|
|
</form> |
|
|
|
|
|
|
|
</div> |
|
|
|
<script type="text/javascript"> |
|
|
|
function reset() { |
|
|
|
{%- for product in products %} |
|
|
|
document.getElementById('prod_{{ product.uid }}').value = 0 |
|
|
|
{%- endfor %} |
|
|
|
} |
|
|
|
|
|
|
|
function updateTotal(amount) { |
|
|
|
total_el = document.getElementById('total') |
|
|
|
total = parseFloat(total_el.innerText) |
|
|
|
total += amount |
|
|
|
total_el.innerText = total.toFixed(2) |
|
|
|
} |
|
|
|
|
|
|
|
function addProduct(uid) { |
|
|
|
// This is the hidden input element inside the form. We'll use this DOM |
|
|
|
// element to keep informations about the product, such as the name, |
|
|
@ -56,6 +66,8 @@ function addProduct(uid) { |
|
|
|
new_text = form_el.value + ' x ' + form_el.dataset.name |
|
|
|
basket_el.innerText = new_text |
|
|
|
} |
|
|
|
|
|
|
|
updateTotal(parseFloat(form_el.dataset.price)) |
|
|
|
} |
|
|
|
|
|
|
|
function delProduct(uid) { |
|
|
@ -71,6 +83,10 @@ function delProduct(uid) { |
|
|
|
new_text = form_el.value + ' x ' + form_el.dataset.name |
|
|
|
basket_el.innerText = new_text |
|
|
|
} |
|
|
|
|
|
|
|
updateTotal(parseFloat(-form_el.dataset.price)) |
|
|
|
} |
|
|
|
|
|
|
|
reset() |
|
|
|
</script> |
|
|
|
{% endblock %} |
|
|
|