{% extends "epic/base_layout.html" %}
{% load humanize %}

{% block buttons %}
  <a class="btn btn-default" href="{% url 'epic:epic_index' %}">
    Up <i class="glyphicon glyphicon-chevron-up"></i>
  </a>

  <a class="btn btn-default" href="{% url 'epic:ship_add' %}">
    Add New Shipment <i class="glyphicon glyphicon-plus"></i>
  </a>
{% endblock buttons %}

{% block content %}
{{ block.super }}

<div class="panel panel-default">
  <div class="panel-heading">
    <h2 class="panel-title">Existing Shipments</h2>
  </div>
  <div class="panel-body">
    {{ list_pager|safe }}
    <table class="table table-bordered table-hover table-striped"
	   style="background-color: white">
      <thead>
	<tr>
	  <th>SO&nbsp;#</th>
	  <th>PO&nbsp;#</th>
	  <th>From</th>
	  <th>To</th>
	  <th>Tracking #s</th>
	  <th>Order&nbsp;Date</th>
	  <th>Ship&nbsp;Date</th>
	  <th>Notes</th>
	</tr>
      </thead>
      {% for shipment in shipment_list %}
      <tr>
	<td>{{ shipment.html_link|safe }}</td>
	<td>
	  {% if shipment.from_warehouse %}
	  n/a
	  {% else %}
	  {{  shipment.ordr.html_link|safe }}
	  {% endif %}
	</td>
	<td>
	  {% if shipment.from_warehouse %}
	  {{  shipment.from_warehouse.html_link|safe }}
	  {% else %}
	  {{  shipment.ordr.vendor.html_link|safe }}
	  {% endif %}
	</td>
	<td>
	  {{ shipment.warehouse.html_link|safe }}
	</td>
	<td>{{ shipment.html_tracking_links|safe }}</td>
	<td>
	  {% if shipment.from_warehouse %}
	  n/a
	  {% else %}
	  {{  shipment.ordr.ts|date:"Y‑m‑d" }}
	  {% endif %}
	</td>
	<td>
	  {{ shipment.ts|date:"Y‑m‑d" }}
	</td>
	<td>{{ shipment.notes|linebreaksbr }}</td>
      </tr>
      {% endfor %}
    </table>
    {{ list_pager|safe }}
  </div>
</div>

{% endblock content %}
