{% extends "base_view.html" %}
{% load widget_tweaks %}

{% block title %} meliza-lab : order : {{ order.name }} {% endblock %}

{% block content %}

<h2>order: {{ order.name }}</h2>
<hr>

<dl class="dl-horizontal">
  <dt>created on</dt><dd>{{ order.order_date }}</dd>
  <dt>created by<dt><dd>{{ order.ordered_by.username}}</dd>
  <dt>account</dt><dd>{{ order.account }}</dd>
  <dt>status</dt><dd>{{ order.ordered|yesno:"ordered,in progress" }}</dd>
</dl>

<h3>items</h3>

<table class="table table-striped table-condensed">
  <thead>
    <th>Description</th>
    <th>Vendor</th>
    <th>Catalog</th>
    <th>Unit</th>
    <th>Price</th>
    <th>Quantity</th>
    <th>Total Price</th>
    {% if order.ordered %}
    <th>Received</th>
    {% endif %}
    <th></th>
    {% if not order.ordered %}
    <th></th>
    {% endif %}
  </thead>
  <tbody>
    {% for oit in orderitem_list %}
        <tr>
          <td><a href="{% url 'inventory:item' oit.item.id %}">{{ oit.item.name }}</a></td>
          <td>
            {% if oit.item.vendor.url %}<a href="{{ oit.item.vendor.url }}">{{ oit.item.vendor }}</a>
            {% else %}{{ oit.item.vendor }}{% endif %}
          </td>
          <td>
            {% if oit.item.vendor_url %}<a href="{{ oit.item.vendor_url }}">{{ oit.item.catalog }}</a>
            {% else %}{{ oit.item.catalog }}{% endif %}
          </td>
          <td>{{ oit.item.unit_size }}</td>
          <td>{{ oit.cost }}</td>
          <td>{{ oit.units_purchased }}</td>
          <td>{{ oit.total_price }}</td>
	  {% if order.ordered %}
	  <td>{{ oit.date_arrived|default:"no" }}</td>
	  {% endif %}
          <td><a href="{% url 'admin:inventory_orderitem_change' oit.id %}"
                 class="glyphicon glyphicon-edit" alt="[edit]" aria-label="Edit"></a></td>
	  {% if not order.ordered %}
          <td><a href="{% url 'admin:inventory_orderitem_delete' oit.id %}"
                 class="glyphicon glyphicon-trash" alt="[delete]" aria-label="Delete"></a></td>
	  {% endif %}
        </tr>
    {% endfor %}
  </tbody>
</table>


<hr>

<p>To update information about an item after it has been received, click the <span class="glyphicon glyphicon-edit" alt="[edit]".  aria-label="Edit"></span> icon. {% if not order.ordered %} To add items to this order, search the <a href="{% url 'inventory:items' %}">items list</a> or <a href="{% url 'inventory:new_item' %}">add a new item</a>. To remove an item from the order, click the <span class="glyphicon glyphicon-trash" alt="[delete]" aria-label="Delete"></span> icon. {% endif %} </p>
<a href="{% url 'inventory:orders' %}">back to order list</a><br/>
<a href="{% url 'admin:inventory_order_change' order.id %}">edit order (advanced users only)</a><br/>

{% endblock %}
