<!-- DataTales Example -->
{% extends "index.html"%} {% block content%}
<div class="container-fluid">
  <div class="card shadow mb-4">
    <div class="card-header py-3">
      <h2    class="m-0 font-weight-bold text-primary">Data peminjaman</h2   >
      <br />
      {% if messages %} 
        {% for message in messages %}
        <div
            class="alert alert-{{ message.tags }} alert-dismissible fade show"
            role="alert"
        >
            <button
            type="button"
            class="close"
            data-dismiss="alert"
            aria-label="Close"
            >
            <span aria-hidden="true">&times;</span>
            </button>
            {{ message | safe }}
        </div>
        {% endfor %} 

        
      {% endif %}
      
      <a href="{% url 'createpeminjaman'%}" type="button" class="btn btn-primary"><i class="fas fa-fw fa-save"></i> Tambah Data Peminjaman</a>
    </div>
    <div class="card-body">
      <div class="table-responsive">
        <table
          class="table table-bordered"
          id="dataTable"
          width="100%"
          cellspacing="0"
        >
          <thead>
            <tr>
              <th>No</th>
              <th>Nama Peminjam</th>
              <th>Judul Buku</th>
              <th>tanggal pinjam</th>
              <th>tanggal Kembali</th>
              <th>tanggal Pengembalian</th>
              <th>Status Peminjaman</th>
              <th>Aksi</th>
            </tr>
          </thead>
          <tbody>
            {% for peminjaman in peminjaman %}
            <tr>
              <td>{{peminjaman.id}}</td>
              <td>{{peminjaman.member.username}}</td>
              <td>{{peminjaman.buku.judul}}</td>
              <td>{{peminjaman.tanggal_pinjam}}</td>
              <td>{{peminjaman.tanggal_kembali}}</td>
              <td>{{peminjaman.tanggal_pengembalian|default:"Not Rerturned"}}</td>
              <td>{% if peminjaman.status %}
                Returned
                {% else %}
                Not Returned
                {% endif %}
              </td>
              <td>
                <a href="edit/{{peminjaman.id}}" class="btn btn-warning ">
                  <i class="fas fa-fw fa-edit"></i><span class="text"> Edit</span>
                </a>
                <a href="delete/{{peminjaman.id}}" onclick="return confirm('apakah anda yakin?')" class="btn btn-danger ">
                  <i class="fas fa-fw fa-trash"></i><span class="text"> Delete</span>
                </a>
              </td>
            </tr>
            {%endfor%}
          </tbody>
        </table>
      </div>
    </div>
  </div>
  
</div>
{% endblock content%}
