{% load i18n admin_urls simpelcore_tags %}


<div class="card shadow-sm mb-4">
  <div class="card-header d-flex px-5 py-4">
    <div class="me-auto">
      <div class="mb-1">
        <a href="{% url object.base_opts|admin_urlname:'inspect' pk=object.id %}">
          <strong>{{ object.inner_id }}</strong>
        </a>
        <span>{{ object.name }}</span>
      </div>
      <h5 class="fs-5 fw-bold mb-3">{{ object.reference_id }} {{ object.product }}</h5>
    </div>
    <div class="text-end">
      <div>{{ object.completes }} {% trans "of" %} {{ object.quantity }} {{ object.product.unit }}</div>
      <div>Progress: {{ object.progress|point }}</div>
    </div>
  </div>
  <div class="card-body py-5 px-5">
    
    {% if object.deliverable_information %}
      <div class="p-3 border mb-3">
        <div class="d-flex justify-content-center">
          <strong class="text-muted border-bottom d-inline-block mb-3 pb-2 me-auto">
            {% trans "Deliverable Informations" %}
          </strong>
        </div>
        <div class="mb-0">
          {% if object.deliverable_information %}
              <div>
                <div>{{ object.deliverable_information.name|title }}{% if object.deliverable_information.phone %}, {{ object.billing_address.phone }}{% endif %}</div>
                <div>{{ object.deliverable_information.text_line_1 }}</div>
                <div>{{ object.deliverable_information.text_line_2 }}</div>
              </div>
            {% else %}
              <div>{% trans "Deliverable information not set, using customer profile." %}</div>
          {% endif %}
        </div>
      </div>
    {% endif %}

    {% if object.reference.bundles.count %}
      <div class="table-responsive pt-3">
        <table class="table m-0 border small">
          <thead>
            <tr>
              <th class="align-middle" width="110">{% trans "#" %}</th>
              <th class="align-middle">{% trans "Item" %}</th>
              <th class="align-middle">{% trans "Unit" %}</th>
              <th class="align-middle">{% trans "Unit Code" %}</th>
              <th class="align-middle">{% trans "Analysis Method" %}</th>
            </tr>
          </thead>
          <tbody>
            {% for parameter in object.get_parameters %}
              <tr>
                <td>{{ parameter.inner_id }}</td>
                <td>{{ parameter.name }}</td>
                <td>{% firstof parameter.unit '-' %}</td>
                <td>{% firstof parameter.unit_code '-' %}</td>
                <td>{% firstof parameter.analysis_method '-' %}</td>
              </tr>
            {% endfor %}
          </tbody>
        </table>
      </div>
    {% endif %}
  </div>
  <div class="card-footer px-5 py-4">
    {% if not object.progress_complete and perms.simpel_projects.add_deliverable %}
      {% url object.opts|admin_urlname:'change' object.pk|admin_urlquote as change_url %}
      <a href="{{ change_url }}" class="btn btn-primary">{% trans "Add Deliverable" %}</a>
    {% else %}
      <a href="#" class="btn btn-primary disabled">{% trans "Add Deliverable" %}</a>
    {% endif %}
    {% url object.opts|admin_urlname:'inspect' object.pk|admin_urlquote as inspect_url %}
    <a href="{{ inspect_url }}" class="btn btn-primary">{% trans "Inspect Task" %}</a>
  </div>
</div>
