<div class="col-sm-12">
  <div class="card">
    <div class="card-header">

      <div class="row align-items-center">
    <!-- Icon + Text -->
    <div class="col-md-9 d-flex align-items-center">
        <i class="material-icons-two-tone text-primary d-block f-46">add_business</i>

        <div>
            <h5 class="mb-0">
                List of all <span class="text-primary"><?= $total_departments ?></span> Departments with actions
            </h5>
            <small>You can Edit or Delete (depending on rights)</small>
        </div>
    </div>

    <!-- Button -->
    <div class="col-md-3 text-end">
        <button class="btn btn-primary btn-sm btn-round" data-bs-toggle="modal" data-bs-target="#add_departments_modal">
            Add New Department
          </button>
    </div>
</div>
    </div>
    <div class="card-body">
      <div class="dt-responsive table-responsive">
        <table id="departments-table" class="table table-striped table-bordered nowrap">
          <thead>
            <tr>
              <th>ID</th>
              <th>Name</th>
              <th>Description</th>
              <th>Action</th>
            </tr>
          </thead>
          <tbody>
            <?php foreach($departments as $d): ?>
            <tr>
              <td><?= $d->id ?></td>
              <td><?= $d->name ?></td>
              <td><?= $d->description ?></td>
              <td class="small text-right">
                <a href="#" class="badge  bg-light-success edit-department-btn"
                   data-id="<?= $d->id ?>"
                   data-name="<?= $d->name ?>"
                   data-description="<?= $d->description ?>">
                   <i data-feather="edit"></i>
                </a>
                <a href="javascript:void(0);" class="badge  bg-light-danger delete-confirmation-modal"
                   data-url="<?= base_url('admin/departments/delete/' . $d->id) ?>">
                   <i data-feather="trash"></i>
                </a>
              </td>
            </tr>
            <?php endforeach; ?>
          </tbody>
        </table>
      </div>
    </div>
  </div>
</div>

<script>
$(document).ready(function() {
    $('#services-table').DataTable({
        responsive: true,
        pageLength: 10,
        lengthMenu: [10,25,50,100],
        order: [[2,'asc']]
    });
});
</script>
