<?php if ($_GET[act] == '') { ?>
  <div class="col-xs-12">
    
		<div class="box box-warning">
      <div class="box-header">
        <h3 class="box-title">Data Guru BK </h3>
      </div><!-- /.box-header -->
      <div class="table-responsive">
        <table id="example1" class="table table-bordered table-striped">
          <thead>
            <tr>
              <th style='width:30px'>No</th>
              <th>NIP</th>
              <th>Nama Lengkap</th>
              <th>Tempat Lahir </th>
              <th>Tanggal Lahir</th>
             
              
              <th style='width:70px'>Action</th>
            </tr>
          </thead>
          <tbody>
            <?php
            $tampil = mysqli_query($conn, "SELECT * FROM rb_guru where id_jenis_ptk='3' ORDER BY nip DESC");
            $no = 1;
            while ($r = mysqli_fetch_array($tampil)) {
              echo "<tr><td>$no</td>
                              <td>$r[nip]</td>
                              <td>$r[nama_guru]</td>
                              <td>$r[tempat_lahir]</td>
                              <td>$r[tanggal_lahir]</td>
  
                              <td><center>
                                <a class='btn btn-success btn-xs' title='Edit Data' href='?view=guru&act=editguru&id=$r[nip]'><span class='glyphicon glyphicon-edit'></span></a>
                              </center></td>";
              echo "</tr>";
              $no++;
            }


            ?>
          </tbody>
        </table>
      </div><!-- /.box-body -->
    </div><!-- /.box -->
  </div>
<?php
} elseif ($_GET[act] == 'edit') {
  if (isset($_POST[update])) {
    $data = md5($_POST[b]);
    $passs = hash("sha512", $data);
    if (trim($_POST[b]) == '') {
      mysqli_query($conn, "UPDATE rb_users SET username = '$_POST[a]',
                                         nama_lengkap = '$_POST[c]',
                                         email = '$_POST[d]',
                                         no_telpon = '$_POST[e]',
                                         jabatan = '$_POST[f]' where id_user='$_POST[id]'");
    } else {
      mysqli_query($conn, "UPDATE rb_users SET username = '$_POST[a]',
                                         password = '$passs',
                                         nama_lengkap = '$_POST[c]',
                                         email = '$_POST[d]',
                                         no_telpon = '$_POST[e]',
                                         jabatan = '$_POST[f]' where id_user='$_POST[id]'");
    }
    echo "<script>document.location='index.php?view=wakilkepala';</script>";
  }
  $edit = mysqli_query($conn, "SELECT * FROM rb_users a where a.id_user='$_GET[id]'");
  $s = mysqli_fetch_array($edit);
  echo "<div class='col-md-12'>
              <div class='box box-warning'>
                <div class='box-header with-border'>
                  <h3 class='box-title'>Edit Data Login Guru BK</h3>
                </div>
              <div class='box box-warning'>
              <form method='POST' class='form-horizontal' action='' enctype='multipart/form-data'>
                <div class='table-responsive'>
                  <table class='table table-condensed table-bordered'>
                  <tbody>
                    <input type='hidden' name='id' value='$s[id_user]'>
                    <tr><th width='120px' scope='row'>Username</th> <td><input type='text' class='form-control' name='a' value='$s[username]'> </td></tr>
                    <tr><th scope='row'>Password</th>               <td><input type='text' class='form-control' name='b' placeholder='Kosongkan saja Jika Password tidak diganti,...'></td></tr>
                    <tr><th scope='row'>Nama Lengkap</th>           <td><input type='text' class='form-control' name='c' value='$s[nama_lengkap]'></td></tr>
                    <tr><th scope='row'>Alamat Email</th>           <td><input type='text' class='form-control' name='d' value='$s[email]'></td></tr>
                    <tr><th scope='row'>No Telpon</th>              <td><input type='text' class='form-control' name='e' value='$s[no_telpon]'></td></tr>
                    <tr><th scope='row'>Jabatan</th>                <td><input type='text' class='form-control' name='f' value='$s[jabatan]'></td></tr>
                  </tbody>
                  </table>
                </div>
              </div>
              <div class='box-footer'>
                    <button type='submit' name='update' class='btn btn-info'>Update</button>
                    <a href='index.php?view=guru'><button class='btn btn-default pull-right'>Cancel</button></a>
                    
                  </div>
              </form>
            </div>";
}
?>