<?php if (!isset($_GET['act']) OR $_GET['act']==''){ ?> 
            <div class="col-xs-12">  
              <div class="box">
                <div class="box-header">
                  <h3 class="box-title">Data Kepala Sekolah </h3>
                </div><!-- /.box-header -->
                <div class="box-body">
                  <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>Alamat Email</th>
                        <th>No Telpon</th>
                        <th>Jabatan</th>
                        <th>Level</th>
                        <th style='width:70px'>Action</th>
                      </tr>
                    </thead>
                    <tbody>
                  <?php 
                    $tampil = mysqli_query(dblink(), "SELECT * FROM rb_users where level!='superuser' ORDER BY id_user DESC");
                    $no = 1;
                    while($r=mysqli_fetch_array($tampil)){
                    echo "<tr><td>$no</td>
                              <td>".$r['username']."</td>
                              <td>".$r['nama_lengkap']."</td>
                              <td>".$r['email']."</td>
                              <td>".$r['no_telpon']."</td>
                              <td>".$r['jabatan']."</td>
                              <td>".$r['level']."</td>
                              <td><center>
                                <a class='btn btn-info btn-xs' title='Lihat Detail' href='?view=guru&act=detailguru&id=".$r['username']."'><span class='glyphicon glyphicon-search'></span></a>
                                <a class='btn btn-success btn-xs' title='Edit Data' href='?view=wakilkepala&act=edit&id=".$r['id_user']."'><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(dblink(), "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(dblink(), "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(dblink(), "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-info'>
                <div class='box-header with-border'>
                  <h3 class='box-title'>Edit Data Login Kepala Sekolah</h3>
                </div>
              <div class='box-body'>
              <form method='POST' class='form-horizontal' action='' enctype='multipart/form-data'>
                <div class='col-md-12'>
                  <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' class='btn btn-default pull-right'>Cancel</a>
                    
                  </div>
              </form>
            </div>";
}
?>