  <?= $this->extend('layout/admin') ?>

  <?= $this->section('title') ?>
  <title>USER &mdash; KUA WAY BUNGUR</title>
  <?= $this->endSection() ?>

  <?= $this->section('content') ?>
  <section class="section">
      <div class="section-header">
          <h1>User</h1>

          <div class="section-header-breadcrumb">
              <div class="breadcrumb-item active"><a href="<?= base_url('dashboard') ?>">Dashboard</a></div>
              <div class="breadcrumb-item">User</div>
          </div>
      </div>

      <div class="section-body">
          <h2 class="section-title">Kelola User</h2>
          <p class="section-lead">
              Halaman ini berisi data user.
          </p>
          <!--notifikasi berhasil-->
          <div class="swal" data-swal="<?= session('success') ?>"></div>
          <!--notifikasi berhasil-->
          <div class="row">
              <div class="col-12 col-md-12 col-lg-12">
                  <div class="card">
                      <div class="card-header">
                          <div class="section-header-button">
                              <a href="<?= base_url('user/add') ?>" type="button" class="btn btn-info sm">
                                  <i class="fas fa-add"></i> Tambah Data
                              </a>
                          </div>
                      </div>
                      <div class="card-body table-responsive">
                          <table class="table table-striped table-md" id="table-1" style="width: 100%;">
                              <thead>
                                  <tr>
                                      <th class="text-center" scope="col">#</th>
                                      <th class="text-center" scope="col">Foto</th>
                                      <th scope="col">Nama</th>
                                      <th scope="col">Email</th>
                                      <th data-sortable="false" class="text-center" scope="col">Opsi</th>
                                  </tr>
                              </thead>
                              <tbody>
                                  <?php foreach ($user as $key => $value) : ?>
                                  <tr>
                                      <th class="text-center align-middle" scope="row"><?= $key + 1 ?></th>
                                      <td class="text-center align-middle"><img alt="image"
                                              src="<?= base_url() ?>/foto_user/<?= $value->gambar_admin ?>"
                                              class="rounded" loading="lazy" width="50" data-toggle="tooltip"
                                              title="<?= $value->nama_admin ?>">
                                      </td>
                                      <td class="text-left align-middle"><?= $value->nama_admin ?></td>
                                      <td class="text-left align-middle"><?= $value->email_admin ?></td>

                                      <td class="text-center align-middle">
                                          <div class="">
                                              <a style="margin: 2px;"
                                                  href="<?= base_url('user/edit/' . $value->id_admin) ?>" type="button"
                                                  class="btn btn-success sm">
                                                  <i class="fas fa-edit"></i>
                                              </a>
                                              <form action="<?= base_url('user/' . $value->id_admin) ?>" method="post"
                                                  class="d-inline" id="del-<?= $value->id_admin ?>">
                                                  <?= csrf_field() ?>
                                                  <input type="hidden" name="_method" value="DELETE">
                                                  <button class="btn btn-danger sm"
                                                      data-confirm="Hapus Data?|Apakah Anda Yakin?"
                                                      data-confirm-yes="submitDel(<?= $value->id_admin ?>)">
                                                      <i class="fas fa-trash-alt"></i>
                                                  </button>
                                              </form>
                                          </div>
                                      </td>
                                  </tr>
                                  <?php endforeach; ?>
                              </tbody>
                          </table>
                      </div>
                  </div>
              </div>
  </section>
  <?= $this->endSection() ?>