<?php
 session_start();
 include "header.php";
 include "sidebar.php";
  if(!isset($_SESSION["userrpp"]))
  {
	header("Location: login.php");
  }
 
?>

  
  <main id="main" class="main">

    <div class="pagetitle">
      <nav>
        <ol class="breadcrumb">
          <li class="breadcrumb-item"><a href="index.php">Home</a></li>
          <li class="breadcrumb-item">Data</li>
          <li class="breadcrumb-item active">Guru</li>
        </ol>
      </nav>
    </div><!-- End Page Title -->

    <section class="section">
      <div class="row">
        <div class="col-lg-12">

          <div class="card">
            <div class="card-body">
              <h5 class="card-title">Data Guru</h5>
               <a href="imporguru.php"><button type="button" class="btn btn-primary rounded-pill" onclick="">Impor Data Guru</button></a>
			   <?php 
				if(isset($_GET['berhasil'])){
					echo "<p><font color='green'>".$_GET['berhasil']." Data berhasil di import.</font></p>";
				}
				
				if (isset($_GET['ed'])) {
					echo "<p><font color='green'>Data Guru berhasil di update.</font></p>";
						echo "<br> ";
				}	
				?>
              <!-- Table with stripped rows -->
              <table class="table datatable">
                <thead>
                  <tr>
                    <th scope="col">#</th>
                    <th scope="col">ID User</th>
                    <th scope="col">Nama</th>
                    <th scope="col">User</th>
                    <th scope="col">Password</th>
					<th scope="col">Asal Madrasah</th>
					<th scope="col">Aksi</th>
                  </tr>
                </thead>
                <tbody>
				<?php
				include 'config.php';
				$result = mysqli_query($mysqli, "SELECT * from user ORDER BY Iduser ASC");
				$counter=0;
				// Fetch the next row of a result set as an associative array
				while ($res = mysqli_fetch_assoc($result)) {
					$counter=$counter+1;
					?>
					<tr>
                    <th scope="row">
					<?php
					echo " $counter </th>";
					echo "<td>".$res['Iduser']."</td>";
					echo "<td>".$res['nama']."</td>";
					echo "<td>".$res['userguru']."</td>";
					echo "<td>".$res['password']."</td>";
					echo "<td>".$res['madrasah']."</td>";
					if ($res['level']==1){
					echo "<td><a href=\"editguru.php?id=$res[Iduser]\"><button type=\"button\" class=\"btn btn-info rounded-pill\">&nbsp;&nbsp;Edit&nbsp;&nbsp;</button> <a href=\"hguru.php?id=$res[Iduser]\" onclick=\"return confirm('Yakin ingin menghapus data ini?');\"><button type=\"button\" class=\"btn btn-danger rounded-pill\">Hapus</button></a></td></tr>";
					}else{
					echo "<td><a href=\"editguru.php?id=$res[Iduser]\"><button type=\"button\" class=\"btn btn-info rounded-pill\">&nbsp;&nbsp;Edit&nbsp;&nbsp;</button></td></tr>";
					}
					
				 
				}
						?>
                                  
                </tbody>
              </table>
              <!-- End Table with stripped rows -->

            </div>
          </div>

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

  </main><!-- End #main -->

  <!-- ======= Footer ======= -->
  <?php
 include "footer.php";
?>
 