{% extends "base.html" %} {% block content %}
<div class="row">
    <div class="col-md-12">
        <div class="row pb-2">
        <div class="col msm-4">
            <a href="{% url "tambah_jurusan" %}" class="btn btn-primary btn-sm"><i class="fa-solid fa-user-plus"></i> Tambah</a>
        </div>
        </div>
        <div class="row">
            <table class="table table-bordered" id="myTable">
                <thead>
                  <tr>
                    <th scope="col">NO</th>
                    <th scope="col">KODE</th>
                    <th scope="col">PROGRAM STUDI</th>
                    <th scope="col">JENJANG</th>
                    <th scope="col">AKSI</th>
                  </tr>
                </thead>
                <tbody>
                  {% for a in jurusan %}
                    <tr>
                      <td>{{forloop.counter}}</td>
                      <td>{{a.kodejurusan}}</td>
                      <td>{{a.namajurusan}}</td>
                      <td>{{a.jenjang}}</td>
                      <td>
                        <a href="{% url "edit_jurusan" a.id %}" class="btn btn-warning btn-sm" title="Edit"><i class="fa-regular fa-pen-to-square"></i></a>
                        <button type="button" class="btn btn-danger btn-sm" data-bs-toggle="modal" title="Hapus" data-bs-target="#hapus-{{a.id}}">
                          <i class="fa-solid fa-trash"></i>
                        </button>
                      </td>
                      <div class="modal fade" id="hapus-{{a.id}}" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
                        <div class="modal-dialog">
                          <div class="modal-content">
                            <div class="modal-header">
                              <h1 class="modal-title fs-5" id="exampleModalLabel">Kofirmasi Penghapusan Data Jurusan</h1>
                              <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                            </div>
                            <div class="modal-body">
                              Apakah anda ingin menghapus Jurusan <strong>{{a.namajurusan}}</strong> ?
                            </div>
                            <div class="modal-footer">
                              <a href="{% url "manage_jurusan" %}" class="btn btn-danger btn-sm"><i class="fa fa-times"></i> Batal</a>
                              <a href="{% url "hapus_jurusan" a.id %}" class="btn btn-warning"><i class="fa fa-trash"></i> Hapus</a>
                            </div>
                          </div>
                        </div>
                      </div>
                    </tr>
                  {% endfor %}
                </tbody>
              </table>
        </div>
        
        </div>
</div>

{% endblock content %}

{% block custom_js %}

<script>
  $(document).ready( function () {
    $('#myTable').DataTable();
  } );
</script>

{% endblock custom_js %}
