<?php
 session_start();
 include "header.php";
 include "sidebar.php";
 include "config.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 active">Perangkat Pembelajaran</li>
        </ol>
      </nav>
    </div><!-- End Page Title -->
	<section class="section">
      <div class="row">
        <div class="col-lg-6">

	<div class="card">
            <div class="card-body">
			 <form name="edit" method="post" action="lihatmonitoringguru.php">
              <h5 class="card-title">Data Perangkat Pembelajaran Guru</h5>
			  
			  <div class="btn-group" role="group" aria-label="Basic example">
			  <label for="inputEmail1" class="col-sm-3 col-form-label">Tapel / Smt</label> 

			    <select name="itapel" id="itapel" class="form-select" required >
						  <option value="">Tapel ...</option>
						  <?php  
							  $aa= mysqli_query($mysqli,"SELECT * FROM tapel ");
							  while($a1= mysqli_fetch_array($aa)){
							  $nilai="";
							  $nilai2=" | ";
							  $nilai=$a1['nama'].$nilai2.$a1['semester'];
						  ?>
							  <option value="<?php echo $a1['Idtapel'] ?>"><?php echo  $nilai ?></option>
							  <?php }?>
							</select>
			
			 <button type="submit" name="simpan" class="btn btn-primary">Lihat Data</button>
          
            </div>
          </div>
		   <?php
                  if (isset($_GET['ed'])) {
					echo "<p><font color='green'>Data berhasil di simpan.</font></p>";
						echo "<br> ";
				}	     
			  ?>
	</div>
	</div>
	</form>
	
	<?php
	if(isset($_POST['simpan'])){
    $kodeuser=$_SESSION["Iduser"];
	$pilihtapel = $_POST["itapel"];
	$aa= mysqli_query($mysqli,"SELECT * FROM tapel where Idtapel='$pilihtapel' ");
	$a1= mysqli_fetch_array($aa);
	$namatapel=$a1['nama'];
	$smt=$a1['semester'];
   ?>
    <section class="section">
      <div class="row">
        <div class="col-lg-12">

          <div class="card">
            <div class="card-body">
               <h5 class="card-title">Data Rencana Perangkat Pembelajaran Guru  <?php echo " Semester $smt Tahun Pelajaran $namatapel ";?> </h5> 
			  
              <!-- Table with stripped rows -->
			<div class="table-container">
              <?php //<table class="table datatable"> ?>
			   <table>
                <thead>
                  <tr bgcolor=#6da66a>
                    <th scope="col">No</th>
					<th scope="col">Nama Guru</th>
                    <th scope="col">Mata Pelajaran</th>
                    <th scope="col">Kelas</th>
                    <th scope="col">Tanggal Kirim</th>
					<th scope="col">Tanggal Verifikasi</th>
					<th scope="col">Catatan</th>
					<th scope="col">Feedback Pengawas</th>
					<th scope="col">Status</th>
					<th scope="col">Aksi</th>
                  </tr>
                </thead>
                <tbody>
				<?php
				
				$result = mysqli_query($mysqli, "SELECT drpp.Idrpp kodeid,user.nama nmguru,mapel.nama nmmapel, kelas.nama nmkelas, drpp.tglkirim, drpp.tglvalidasi, drpp.catatan,drpp.catat_pengawas,drpp.validasi FROM drpp,user,mapel,kelas WHERE drpp.Iduser=user.Iduser AND drpp.Idmapel=mapel.Idmapel AND drpp.Idkelas=kelas.Idkelas AND drpp.Idtapel='$pilihtapel' ORDER BY drpp.Idrpp ASC");
				$counter=0;
				// Fetch the next row of a result set as an associative array
				while ($res = mysqli_fetch_assoc($result)) {
					$counter=$counter+1;
					if ($counter % 2) {
						echo "<tr>";
					} else {
						  echo "<tr bgcolor='#d9d9d9'>";
					 }
					?>
					<td scope="row">
					<?php
					echo " $counter </td>";
					echo "<td>".$res['nmguru']."</td>";
					echo "<td>".$res['nmmapel']."</td>";
					echo "<td>".$res['nmkelas']."</td>";
					echo "<td>".$res['tglkirim']."</td>";
					echo "<td>".$res['tglvalidasi']."</td>";
					echo "<td>".$res['catatan']."</td>";
					echo "<td>".$res['catat_pengawas']."</td>";
					echo "<td>".$res['validasi']."</td>";
					echo "<td>";
					?>
						<div class="btn-group" role="group" aria-label="Basic example">
					<?php
					if ($res['validasi']=="kirim") {
						
						echo "<a href=\"lihatrpp.php?idrpp=$res[kodeid]\"><button type=\"button\" class=\"btn btn-info\">Lihat RPP</button><a href=\"catatanpengawas.php?idrpp=$res[kodeid]\"><button type=\"button\" class=\"btn btn-warning\">Feedback Pengawas</button>";
						
					} else if ($res['validasi']=="verifikasi") {
						echo "<a href=\"lihatrpp.php?idrpp=$res[kodeid]\"><button type=\"button\" class=\"btn btn-info\">Lihat RPP</button><a href=\"catatanpengawas.php?idrpp=$res[kodeid]\"><button type=\"button\" class=\"btn btn-warning\">Feedback Pengawas</button><a href=\"cetakbuktirpp.php?idrpp=$res[kodeid]\" target=\"_blank\"><button type=\"button\" class=\"btn btn-success\">Cetak Bukti</button>";
					} else {
						echo "";
					}
					
					echo "</div> </td></tr>";
					
					
				 
				}
						?>
                                 
                </tbody>
              </table>
			   <?php // echo" <br><br><a href=\"data.php?id=$pilihtapel\">export</a>";?>
              <!-- End Table with stripped rows -->
			</div>
            </div>
          </div>

        </div>
      </div>
    </section>
	<?php
	}
	?>

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

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