<!-- Begin Page Content -->
<div class="container-fluid">
  <div data-url="<?= base_url() ?>" class="url"></div>
  <!-- end setting title -->
  <?php if (validation_errors()) : ?>
    <div class="alert alert-danger alert-dismissible fade show" role="alert">
      <strong>Warning!! Data gagal disimpan</strong> <?= validation_errors() ?>
      <button type="button" class="close" data-dismiss="alert" aria-label="Close">
        <span aria-hidden="true">&times;</span>
      </button>
    </div>
  <?php endif ?>
  <div class="setting-container">
    <?= $this->session->flashdata('message') ?>

    <div class="container-setting-title">
      <div class="setting-title d-flex align-items-start">User Control</div>
      <a href="#" data-target="#previewKopSurat" data-toggle="modal"> Preview Kop Surat</a>
    </div>
    <!-- tombol control formulir,statistik -->
    <div class="container-setting-onoff d-flex justify-content-around">
      <div class="toogle-custum align-self-center">
        <p>Formulir</p>
        <label class="switch">
          <input type="checkbox" data-kolom="formulir" value="1" id="formAktif" <?php if ($kop[0]['formulir'] == 1) {
                                                                                  echo "checked";
                                                                                } ?>>
          <span class="slider round"></span>
        </label>
      </div>

      <div class="toogle-custum align-self-center">
        <p>Akses Operator</p>
        <label class="switch">
          <input type="checkbox" data-kolom="aksesOperator" value="1" id="onOperator" <?php if ($kop[0]['aksesOperator'] == 1) {
                                                                                        echo "checked";
                                                                                      } ?>>
          <span class="slider round"></span>
        </label>
      </div>

      <div class="toogle-custum align-self-center">
        <p>Statistik di Home</p>
        <label class="switch">
          <input type="checkbox" data-kolom="statistik_depan" class="custom-control-input" id="onStstistik" <?php if ($kop[0]['statistik_depan'] == 1) {
                                                                                                              echo "checked";
                                                                                                            } ?>>
          <span class="slider round"></span>
        </label>
      </div>

      <!-- <div class="toogle-custum align-self-center">
        <p>Batasi Zonasi Dari Luar</p>
        <label class="switch">
          <input type="checkbox">
          <span class="slider round"></span>
        </label>
      </div> -->
    </div>
    <!-- Control jalur ppdb,kepala sekolah,juknis -->
    <div class="container-baris-dua">
      <div class="control-kepala-sekolah">
        <div class="control-body-kepsek">
          <h2>Kepala Sekolah</h2>
          <div class="form-kepsek">
            <form action="#">
              <div class="form-group">
                <label for="namaKepala">Nama</label>
                <input type="text" value="<?= $kop[0]['nama_kepala']; ?>" name="namaKepala" class="form-control form-control-sm" id="namaKepala" data-kolom="nama_kepala" placeholder="Masukan nama Kepala Sekolah ">
              </div>
              <div class="form-group">
                <label for="nipKepala">NIP</label>
                <input type="text" value="<?= $kop[0]['nip_kepsek']; ?>" class="form-control form-control-sm" data-kolom="nip_kepsek" id="nipKepala" name="nip" placeholder="Masukan Nip">
              </div>
            </form>
            <div class="ttd-kepsek">
              <img src="<?= base_url('assets/img/logo/') . $kop[0]['ttd_kepsek']; ?>" width="100" class="img-fluid">
            </div>
          </div>
        </div>
        <div class="control-body-surat-ppdb">
          <h2>Surat PPDB</h2>
          <form action="#">
            <div class="form-group">
              <label for="nomorSurat">Nomor Surat PPDB</label>
              <input type="text" value="<?= $kop[0]['no_surat'] ?>" class="form-control form-control-sm" id="nomorSurat" data-kolom="no_surat" placeholder="800/....  -PPDB.....2022">
            </div>
            <div class=" form-group">
              <label for="tanggalSurat">Tanggal Surat</label>
              <input type="text" value="<?= $kop[0]['tanggalKelulusan'] ?>" class="form-control form-control-sm" data-kolom="tanggalKelulusan" id="tanggalSurat" placeholder="ketikan tanggal">
            </div>
          </form>
        </div>
      </div>

      <div class="control-bacup-reset">
        <div class="reset-title">
          <h2>Bacup & Reset</h2>
        </div>
        <div class="body-reset">
          <div>
            <a href="<?= base_url('Setting/kosongkan') ?>" type="button" class="btn btn-secondary text-white tombol-kosongkan"><i class="fa fa-database" aria-hidden="true"></i> Kosongkan Databse</a>
          </div>
          <div>
            <a href="<?= base_url('Setting/backup') ?>" type="button" class="btn btn-warning text-white"><i class="fa fa-database" aria-hidden="true"></i> Backup Database</a>
          </div>
          <div>
            <a href="<?= base_url('Pendaftar/ResetAllVerifikasi') ?>" type="button" class="btn btn-danger tombol-reset"><i class="fas fa-reply-all"></i> Reset Ke Verifikasi</a>
          </div>
          <div>
            <a href="#" type="button" class="btn btn-info" data-target="#desaModel" data-toggle="modal"><i class="fas fa-folder-plus"></i> Tambah Data Desa</a>
          </div>
          <div>
            <a href="<?= base_url('Pendaftar/refreshDatabase') ?>" class="btn btn-success"><i class="fas fa-reply-all"></i> Refresh Database</a>
          </div>
          <div>
            <a href="#" data-target="#cabutModel" data-toggle="modal" class="btn btn-primary"><i class="fas fa-reply-all"></i>Re-cabut Berkas</a>
          </div>
          <div>
            <a href="#" data-target="#resetPinPeserta" data-toggle="modal" class="btn btn-warning text-white"><i class="fas fa-reply-all"></i>Reset Pin User</a>
          </div>
          <div>
            <a href="<?= base_url('Pendaftar/reflaceEmail') ?>" class="btn btn-warning text-white"><i class="fas fa-reply-all"></i>Replace Email Kosong</a>
          </div>
          <!-- <div>
            <a href="#" id="tombolTambahOperator" data-toggle="modal" class="btn btn-secondary text-white"><i class="fas fa-reply-all"></i>Tambah Data Operator</a>
          </div> -->

        </div>
      </div>
    </div>
    <!-- identitas sekolah -->
    <div class="container-identitas-sekolah">
      <div class="title-identitas-sekolah">
        <h2>Identitas Sekolah</h2>
      </div>
      <div class="body-identitas-sekolah">
        <form action="setting/updateKop" method="post" enctype="multipart/form-data">
          <input type="hidden" name="id" value="<?= $kop[0]['id']; ?>">
          <div class="form-row">
            <div class="col">
              <div class="form-group">
                <label for="nama">Nama Sekolah</label>
                <input type="text" class="form-control" id="nama" name="nama" value="<?= $kop[0]['nama_sekolah']; ?>">
                <small lass="form-text text-muted">contoh : SMP NEGERI 1 CONTOH</small>
              </div>
            </div>
            <div class="col">
              <div class="form-group">
                <label for="alamat">Alamat Sekolah</label>
                <textarea class="form-control" id="alamat" name="alamat">
                <?= $kop[0]['alamat']; ?>
                </textarea>
              </div>
            </div>
            <div class="col">
              <div class="form-group">
                <label for="kecamatan">kecamatan</label>
                <input type="text" class="form-control" id="kecamatan1" name="kecamatan" value="<?= $kop[0]['kecamatan']; ?>">
              </div>
            </div>
          </div>
          <div class="form-row">
            <div class="col">
              <div class="form-group">
                <label for="desa">desa</label>
                <input type="text" class="form-control" id="desa" name="desa" value="<?= $kop[0]['desa']; ?>">
              </div>
            </div>
            <div class="col">
              <div class="form-group">
                <label for="npsn">npsn</label>
                <input type="text" class="form-control" id="npsn" name="npsn" value="<?= $kop[0]['npsn']; ?>">
              </div>
            </div>
            <div class="col">
              <div class="logo-sekolah">
                <img src="<?= base_url('assets/img/logo/') . $kop[0]['logo'] ?>" class="logo-sek img-fluid">
              </div>
            </div>
          </div>
          <div class="form-row">
            <div class="col">
              <div class="form-group">
                <label for="JumlahRombel">Jumlah Rombel</label>
                <input type="text" class="form-control" value="<?= $kop[0]['jumlahRombel']; ?>" name="JumlahRombel" id="JumlahRombel" placeholder="Jumlah Rombel">
                <small id="JumlahRombelHelp" class="form-text text-danger">Untuk Pembagian Kelompok Saat Daftar Ulang</small>
              </div>
            </div>
            <div class="col">
              <div class="form-group">
                <label for="long">Longitude</label>
                <input type="text" class="form-control" value="<?= $kop[0]['longitude']; ?>" name="long" id="long" placeholder="Longitude">
                <small id="longHelp" class="form-text text-danger">Bisa di ambil di google maps contoh : -6.7487747,106.8026829</small>
              </div>
            </div>

          </div>
          <div class="form-row">
            <div class="col">
              <div class="input-group mb-3">
                <div class="custom-file">
                  <input type="file" name="logo" class="custom-file-input" id="inputGroupFile02">
                  <label class="custom-file-label" for="inputGroupFile02" aria-describedby="inputGroupFileAddon02">Unggah Logo Sekolah</label>
                </div>
              </div>
            </div>
            <div class="col">
              <div class="input-group">
                <div class="custom-file">
                  <input type="file" class="custom-file-input" id="ttd" name="ttd">
                  <label class="custom-file-label" for="ttd">Upload TTD Kepala Sekolah</label>
                </div>
              </div>
            </div>
          </div>
          <div class="form-row">
            <div class="col">
              <small class="mb-3">ukuran logo yg di sarankan adalah 238 x 238 pixel</small>
              <button type="submit" class="btn btn-primary mt-2 px-6">Ubah</button>
            </div>
          </div>
        </form>
      </div>
    </div>

    <!-- tambah data user -->
    <div class="container-tambah-user">
      <h5 class="mb-3">Data Administrator</h5>
      <button type="button" id="tambahUser" data-toggle="modal" data-target="#userModel" class="btn btn-outline-success mb-3">Tambah Pengguna</button>

      <table class="table table-hover table-responsive-sm">
        <thead>
          <tr>
            <th scope="col">#</th>
            <th scope="col">Nama</th>
            <th scope="col">Lavel</th>
            <th scope="col">Action</th>
          </tr>
        </thead>
        <tbody>

          <?php $no = 1;
          foreach ($dataUser as $users) : ?>
            <tr>
              <th scope="row"><?= $no ?></th>
              <td><?= $users['name'] ?></td>
              <td><?php if ($users['role_id'] == 1) {
                    echo "admin";
                  } else if ($users['role_id'] == 2) {
                    echo "Verifikator";
                  } else if ($users['role_id'] == 5) {
                    echo "Operator Sekolah";
                  } else {
                    echo "Tidak dikenali";
                  } ?></td>
              <td>
                <a href="#" class="badge badge-success edit" data-toggle="modal" data-id="<?= $users['id'] ?>" data-target="#userModel"><i class="fas fa-user-edit"></i> Edit</a>

                <a href="<?= base_url('setting/hapusUser/') . $users['id'] ?>" class="badge badge-danger"><i class="fa fa-trash" aria-hidden="true"></i> hapus</a>

              </td>
            </tr>
          <?php $no++;
          endforeach ?>
        </tbody>
      </table>
    </div>

    <!-- tambah data Operator -->
    <div class="container-tambah-user">
    <a href="#" id="tombolTambahOperator" data-toggle="modal" class="btn btn-secondary text-white"><i class="fas fa-reply-all"></i>Tambah Data Operator</a>
      <h5 class="mb-3">Data Operator Kolektif</h5>
      <table class="table table-hover table-responsive-sm" id="table-operator">
        <thead>
          <tr>
            <th scope="col">#</th>
            <th scope="col">Nama</th>
            <th scope="col">Lavel</th>
            <th scope="col">Asal Sekolah</th>
            <th scope="col">Action</th>
          </tr>
        </thead>
        <tbody>

          <?php $no = 1;
          foreach ($dataOperator as $users) : ?>
            <tr>
              <th scope="row"><?= $no ?></th>
              <td><?= $users['name'] ?></td>
              <td><?php if ($users['role_id'] == 1) {
                    echo "admin";
                  } else if ($users['role_id'] == 2) {
                    echo "Verifikator";
                  } else if ($users['role_id'] == 5) {
                    echo "Operator Sekolah";
                  } else {
                    echo "Tidak dikenali";
                  } ?></td>

              <td><?= $users['asal_sekolah_ops'] ?></td>
              <td>
                <a href="#" class="badge badge-success editOperator" data-toggle="modal" data-id="<?= $users['id'] ?>"><i class="fas fa-user-edit"></i> Edit</a>

                <a href="<?= base_url('setting/hapusUser/') . $users['id'] ?>" class="badge badge-danger hapusDataOperator" data-nm="<?= $users['name'] ?>"><i class="fa fa-trash" aria-hidden="true"></i> hapus</a>
                <button class="badge badge-warning button-reset-Operator" data-id="<?= $users['id'] ?>"><i class="fa fa-reset" aria-hidden="true"></i> Reset Password</button>

              </td>
            </tr>
          <?php $no++;
          endforeach ?>
        </tbody>
      </table>
    </div>
  </div>
</div>
<!-- /.container-fluid -->
</div>
<!-- End of Main Content -->
<!-- Modal -->
<div class="modal fade" id="userModel" tabindex="-1" role="dialog" aria-labelledby="userModelModalLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">Tambah User</h5>
        <input type="hidden" name="url" id="url" value="<?= base_url(); ?>">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <form action="<?= base_url('setting/editUser') ?>" method="POST" id="formUser">
        <div class="modal-body">
          <input type="hidden" name="idUser" id="idUser">
          <div class="form-group">
            <input type="text" class="form-control" id="namaUser" value="<?= set_value('nama') ?>" name="nama" placeholder="User Baru">
          </div>
          <div class="form-group">
            <input type="text" class="form-control" value="<?= set_value('email') ?>" id="emailUser" name="email" placeholder="email Baru">
          </div>
          <div class="form-group input-hidden">
            <input type="text" class="form-control" id="passwordUser" name="password" placeholder="password Baru">
          </div>
          <div class="form-group input-hidden">
            <input type="text" class="form-control" id="password2User" name="password2" placeholder="Ulangi password Baru">
          </div>
          <div class="form-group">
            <label for="userakses">User Akses</label>
            <select class="form-control" name="userAkses" id="userAkses">
              <option value="">Pilih---</option>
              <option value="1">Admin</option>
              <option value="2">Verifikasi</option>
            </select>
          </div>

          <div class="form-group">
            <div class="form-check">
              <input class="form-check-input" type="checkbox" name="role_id" value="1" id="defaultCheck1" checked>
              <label class="form-check-label" for="defaultCheck1">
                Status Aktif
              </label>
            </div>
          </div>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
          <button type="submit" class="btn btn-primary">Add</button>
        </div>
      </form>
    </div>
  </div>
</div>

<!-- model tambah desa -->
<div class="modal fade" id="desaModel" tabindex="-1" role="dialog" aria-labelledby="desaModelModalLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">Tambah Desa <?= $idDesa ?></h5>
        <input type="hidden" name="url" id="url" value="<?= base_url(); ?>">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <form action="<?= base_url('Setting/tambahDesa') ?>" method="POST">
        <div class="modal-body">
          <div class="form-group">
            <select name="provinsi" id="provinsi" class="form-control provinsi">
              <option value="">Pilih Provinsi---</option>
              <?php foreach ($provinsi as $prov) : ?>
                <option value="<?= $prov['id'] ?>"><?= $prov['name'] ?></option>
              <?php endforeach ?>
            </select>
          </div>
          <div class="form-group">
            <select name="Kota" id="selectKota" class="form-control selectKota">

            </select>
          </div>
          <div class="form-group">
            <select name="kecamatan" id="selectKecamatan" class="form-control selectKecamatan">

            </select>
          </div>
          <div class="form-group">
            <input type="text" name="namaDesa" id="namaDesa" class="form-control" placeholder="Masukan Nama Desa">
          </div>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
          <button type="submit" class="btn btn-primary">Add</button>
        </div>
      </form>
    </div>
  </div>
</div>
<!-- cabut -->
<div class="modal fade" id="cabutModel" tabindex="-1" role="dialog" aria-labelledby="desaModelModalLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">Reset Cabut Berkas</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <form action="<?= base_url('Setting/resetCabut') ?>" method="POST">
        <div class="modal-body">
          <div class="form-group">
            <input type="text" name="Koreg" id="Koreg" class="form-control" placeholder="Masukan Kode Registrasi">
          </div>
          <div class="form-group">
            <select name="cabutKe" class="form-control">
              <option value="2">Pilih Tujuan Reset</option>
              <option value="2">Dashboard / Belum Verifikasi</option>
              <option value="3">Verifikasi</option>
            </select>
          </div>
        </div>

        <div class="modal-footer">
          <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
          <button type="submit" class="btn btn-primary">Reset Data</button>
        </div>
      </form>
    </div>
  </div>
</div>

<!-- reset pin peserta -->
<div class="modal fade" id="resetPinPeserta" tabindex="-1" role="dialog" aria-labelledby="resetPinPesertaModelModalLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">RESET PIN PESERTA</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>

      <div class="modal-body">
        <div class="form-group">
          <input type="text" name="risetPIN" id="risetPIN" class="form-control risetPIN" placeholder="Masukan NISN Pendaftar">
        </div>
      </div>

      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
        <a href="#" class="btn btn-primary tombol-riset-pin">Reset PIN</a>
      </div>

    </div>
  </div>
</div>



<!-- moda preview kop surat -->
<div class="modal fade" id="previewKopSurat" tabindex="-1" role="dialog" aria-labelledby="previewKopSuratModelModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">Preview Kop Surat</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>

      <div class="modal-body">
        <div class="card">
          <div class="card-body">
            <div class="row d-flex justify-content-center">
              <div class="col-2">
                <img src="<?= base_url('assets/img/logo/kabBogor.png') ?>" class="logo-dinas img-fluid">
              </div>
              <div class="col-8">
                <h3 class="pemerintah">PEMERINTAH KABUPATEN BOGOR</h3>
                <h3 class="dinas text-center">DINAS PENDIDIKAN</h3>
                <h3 class="sekolah text-center"><?= $kop[0]['nama_sekolah']; ?></h3>
                <h3 class="alamat text-center text-capitalize"><?= $kop[0]['alamat']; ?></h3>
              </div>
              <div class="col-2">
                <img src="<?= base_url('assets/img/logo/') . $kop[0]['logo'] ?>" class="logo-sek img-fluid">
              </div>
            </div>
            <hr class="h-2">
          </div>
        </div>
      </div>

      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
      </div>

    </div>
  </div>
</div>


<!-- modal tambah Operator -->
<div class="modal fade" id="operatorModel" tabindex="-1" role="dialog" aria-labelledby="operatorModelModalLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">Tambah Data Operator</h5>
        <input type="hidden" name="url" id="url" value="<?= base_url(); ?>">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <form action="<?= base_url('setting/tambahUserOperator') ?>" method="POST" id="formOperator">
        <div class="modal-body">
          <input type="hidden" name="idOperator" id="idOperator">
          <div class="form-group">
            <input type="text" class="form-control" id="namaOperator" value="<?= set_value('nama') ?>" name="nama" placeholder="Nama Operator">
          </div>
          <div class="form-group">
            <input type="text" class="form-control emailOperator" value="<?= set_value('email') ?>" id="emailOperator" name="email" placeholder="Email Operrator">
          </div>
          <div class="form-group">
            <input type="text" class="form-control" value="<?= set_value('namaSekolahOps') ?>" id="namaSekolahOpsOperator" name="namaSekolahOps" placeholder="SEKOLAH ASAL OPS">
          </div>
          <div class="form-group">
            <input type="text" class="form-control" value="<?= set_value('npsnOps') ?>" id="npsnOps" name="npsnOps" placeholder="NPSN Sekolah Operator">
          </div>
          <div class="form-group input-hidden">
            <input type="text" class="form-control" id="passwordOperator" name="password" placeholder="password Baru">
          </div>
          <div class="form-group input-hidden">
            <input type="text" class="form-control" id="password2Operator" name="password_repeat" placeholder="Ulangi password Baru">
          </div>
          <div class="form-group">
            <div class="form-check">
              <input class="form-check-input" type="checkbox" name="role_id" value="1" id="defaultCheck1" checked>
              <label class="form-check-label" for="defaultCheck1">
                Status Aktif
              </label>
            </div>
          </div>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
          <button type="submit" class="btn btn-primary">Add</button>
        </div>
      </form>
    </div>
  </div>
</div>