{% extends 'assets/base.html' %}
{% load bob %}
{% load icons %}

{% block content %}
<div id="float_toolbar">
  <a id="fill_all_rows" href="#" title="Fill all rows">
    {% icon 'fugue-pencil--plus' %}
  </a>
</div>
<div class="row">
  <hgroup>
    <h3>Split device:</h3>
    <h4>
      <a href="{% url device_edit mode='dc' asset_id=device.id %}">
        {{ device.model }} (sn: {{ device.sn }}, price: {{ device.price|default:"0,00" }})
      </a>
    </h4>
  </hgroup>
</div>
<form method="POST" class="form form-inline form-split">
  {% csrf_token %}
  {{ formset.management_form }}
  <div class="row overflow-x">
    <table class="table table-striped table-bordered table-condensed scrollable-table">
      <thead><tr>
        <th></th>
        <th>Remove</th>
        <th>Model proposed</th>
        <th>Model</th>
        <th>Invoice Number</th>
        <th>Order Number</th>
        <th>SN</th>
        <th>Barcode</th>
        <th>Price</th>
        <th>Support price</th>
        <th>Support period</th>
        <th>Support type</th>
        <th>Support void reporting</th>
        <th>Provider</th>
        <th>Source</th>
        <th>Status</th>
        <th>Request date</th>
        <th>Delivery date</th>
        <th>Invoice date</th>
        <th>Production use date</th>
        <th>Provider order date</th>
        <th>Warehouse</th>
      </tr></thead>
      <tbody>
        {% for form in formset %}
          <tr>
            <td style="vertical-align:middle" class="ordinal" data-no="{{ forloop.counter }}">
              {{ forloop.counter }}
              {{ form.id }}
              {{ form.device_info }}
            </td>
            {% for field in form %}
              <td class="control-group{% if "-support_period" in field.html_name %} small{% endif %}{% if field.errors %} error{% endif %}" style="vertical-align:middle">
                {{ field }}
                {% if field.errors %}
                  <span class="help-inline">{% for error in field.errors %}{{ error }} {% endfor %}</span>
                {% endif %}
              </td>
            {% endfor %}
          </tr>
        {% endfor %}
      </tbody>
    </table>
  </div>
    <div class="row" style="margin-top:10px;">
      <a href="#" class="btn btn-success add_row">+</a>
    </div>
  <div class="row">
    <div class="form-actions">
      <button type="submit" class="btn btn-primary">Save</button>
    </div>
  </div>
</form>
{% endblock %}
