<table>
<tr>
<td>Вартість</td>
<td>
{% if context.order.discount_sum %}
{{ context.order.discount_sum }} грн.
{% else %}
{{ context.order.total_sum }} грн.
{% endif %}
</td>
</tr>
<tr>
<td>Адреса доставки</td>
<td>{{ context.order.address }}</td>
</tr>
</table>
<table>
<tr>
<th>Артикул</th>
<th>Виробник</th>
<th>Назва</th>
<th>К-сть</th>
<th>Сума</th>
</tr>
{% for item in context.order.orderitem_set.all %}
<tr>
<td><a target="blank" href="{{item.url}}">{{ item.art }}</a></td>
<td>{{ item.item_name }}</td>
<td>{{ item.item_type }}</td>
<td>{{ item.count }}</td>
<td>{{ item.total_price }} грн.</td>
</tr>
{% endfor %}
</table>
<form action="." method="get">
<p><label for="id_date_min">Date min:</label>
<input class="datepicker" id="id_date_min" name="date_min" type="text"></p>
<p><label for="id_date_max">Date max:</label>
<input class="datepicker" id="id_date_max" name="date_max" type="text"></p>
<input type="submit" value="Зробити виписку">
</form>
{% extends "header.html" %}
{% load staticfiles %}
{% load custom_tag %}
{% block body_block %}
<ul>
<li><b>Title: </b>{{ order.title }}</li>
<li><b>Profile: </b>{{ order.profile }}</li>
<li><b>Create date: </b>{{ order.created }}</li>
<li><b>Update date: </b>{{ order.updated }}</li>
<li><b>Status: </b>{{ order.status }}</li>
<li><b>Products: </b>
<table border='1'>
<tr>
<th>Group name</th>
<th>Art</th>
<th>Product name</th>
<th>Image</th>
<th>Packing</th>
<th>Cost</th>
<th>Discount price</th>
<th>Count</th>
<th>Sum</th>
</tr>
{% for product in orders.orderproducts_set.all %}
<tr>
<td>{{ product.product.group }}</td>
<td>{{ product.product.art }}</td>
<td>{{ product.product.product_name }}</td>
<td><img src="{{ MEDIA_URL }}{{product.product.photo}}" height="50" width="50"></td>
<td>{{product.product.get_packing_display}}</td>
<td>{{product.product.cost}}</td>
<td>{{product.price}}</td>
<td>{{product.count}}</td>
<td>{{product.price|divide:product.count}}</td>
</tr>
{% endfor %}
</table>
</li>
</ul>
{% if order.status != "accepted" %}
<a href="{% url 'order_details' pk=order.id %}?accept=True"><button>Accept</button></a>
{% endif %}
<a href="{% url 'order_details' pk=order.id %}?decline=True"><button>Decline</button></a>
{% endblock %}
class OrderDetailsView(DetailView):
model = Orders
template_name = 'orders/order_details.html'
def get_context_data(self, *args, **kwargs):
try:
accept = self.request.GET.get('accept')
except:
accept = False
try:
decline = self.request.GET.get('decline')
except:
decline = False
context = super(OrderDetailsView, self).get_context_data(*args, **kwargs)
context['order'] = Orders.objects.get(id=self.kwargs['pk'], organization=self.request.user.organization)
if accept:
Orders.objects.filter(id=self.kwargs['pk'], organization=self.request.user.organization).update(is_order=True, status='accepted')
return reverse('manage_orders')
if decline:
Orders.objects.filter(id=self.kwargs['pk'], organization=self.request.user.organization).update(is_order=False, status='declined')
return reverse('manage_orders')
return context