{% 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"><h3>Bulk edit</h3></div>
<form method="POST" class="form form-inline">
  {% 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>
        {% if mode == 'BO' %}<th>Type</th>{% endif %}
        <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>
      </tr></thead>
      <tbody>{% for form in formset %}
        <tr>
          <td style="vertical-align:middle">
            {{ forloop.counter }}
            {{ form.id }}
            {{ form.device_info }}
          </td>
          {% for field in form %}
            {% if "-device_info" in field.html_name or "-id" in field.html_name %}
              {# do nothing... #}
            {% elif "-barcode" in field.html_name  %}
              <td class="control-group{% if form.device_info.value and field.errors %} error{% endif %}" style="vertical-align:middle">
                {% if form.device_info.value %}
                  {{ field }}
                  {% if field.errors %}
                    <span class="help-inline">{% for error in field.errors %}{{ error }} {% endfor %}</span>
                  {% endif %}
                {% endif %}
              </td>
            {% else %}
              <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>
            {% endif %}
          {% endfor %}
        </tr>
      {% endfor %}</tbody>
    </table>
  </div>
  <div class="row">
    <div class="form-actions">
      <button type="submit" class="btn btn-primary">Save</button>
    </div>
  </div>
</form>
{% endblock %}
