<?php
 session_start();
 include "header.php";
 include "sidebar.php";
 include "config.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 active">Input Data Beban Kerja</li>
        </ol>
      </nav>
    </div><!-- End Page Title -->

	<?php
    if(isset($_POST['simpan'])){
    $pilihtapel = $_POST["itapel"];
	$pilihguru = $_POST["iguru"];
	$kosong="";
	$validasi="baru";
	$counter=0;
	if(isset($_POST['s1'])){
	  if(isset($_POST['ikelas1']) && isset($_POST['imapel1']) ){
	  $pilihkelas=$_POST['ikelas1'];
	  $pilihmapel=$_POST['imapel1'];
	  mysqli_query($mysqli,"INSERT INTO `drpp`(`Idrpp`, `Idtapel`, `Iduser`, `Idkelas`, `Idmapel`, `kaldik`, `rpe`, `alokasiwaktu`, `cp`, `atp`, `prota`, `promes`, `kktp`, `modulrpp`, `tglkirim`, `tglvalidasi`, `catatan`, `validasi`) VALUES ('','$pilihtapel','$pilihguru','$pilihkelas','$pilihmapel','$kosong','$kosong','$kosong','$kosong','$kosong','$kosong','$kosong','$kosong','$kosong','$kosong','$kosong','$kosong','$validasi')");
	   $counter++;
	  }
	}
	if(isset($_POST['s2'])){
	  if(isset($_POST['ikelas2']) && isset($_POST['imapel2']) ){
	  $pilihkelas=$_POST['ikelas2'];
	  $pilihmapel=$_POST['imapel2'];
	  mysqli_query($mysqli,"INSERT INTO `drpp`(`Idrpp`, `Idtapel`, `Iduser`, `Idkelas`, `Idmapel`, `kaldik`, `rpe`, `alokasiwaktu`, `cp`, `atp`, `prota`, `promes`, `kktp`, `modulrpp`, `tglkirim`, `tglvalidasi`, `catatan`, `validasi`) VALUES ('','$pilihtapel','$pilihguru','$pilihkelas','$pilihmapel','$kosong','$kosong','$kosong','$kosong','$kosong','$kosong','$kosong','$kosong','$kosong','$kosong','$kosong','$kosong','$validasi')");
	   $counter++;
	  }
	}
	if(isset($_POST['s3'])){
	 if(isset($_POST['ikelas3']) && isset($_POST['imapel3']) ){
	  $pilihkelas=$_POST['ikelas3'];
	  $pilihmapel=$_POST['imapel3'];
	  mysqli_query($mysqli,"INSERT INTO `drpp`(`Idrpp`, `Idtapel`, `Iduser`, `Idkelas`, `Idmapel`, `kaldik`, `rpe`, `alokasiwaktu`, `cp`, `atp`, `prota`, `promes`, `kktp`, `modulrpp`, `tglkirim`, `tglvalidasi`, `catatan`, `validasi`) VALUES ('','$pilihtapel','$pilihguru','$pilihkelas','$pilihmapel','$kosong','$kosong','$kosong','$kosong','$kosong','$kosong','$kosong','$kosong','$kosong','$kosong','$kosong','$kosong','$validasi')");
	   $counter++;
	  }
	}
	if(isset($_POST['s4'])){
	 if(isset($_POST['ikelas4']) && isset($_POST['imapel4']) ){
	  $pilihkelas=$_POST['ikelas4'];
	  $pilihmapel=$_POST['imapel4'];
	  mysqli_query($mysqli,"INSERT INTO `drpp`(`Idrpp`, `Idtapel`, `Iduser`, `Idkelas`, `Idmapel`, `kaldik`, `rpe`, `alokasiwaktu`, `cp`, `atp`, `prota`, `promes`, `kktp`, `modulrpp`, `tglkirim`, `tglvalidasi`, `catatan`, `validasi`) VALUES ('','$pilihtapel','$pilihguru','$pilihkelas','$pilihmapel','$kosong','$kosong','$kosong','$kosong','$kosong','$kosong','$kosong','$kosong','$kosong','$kosong','$kosong','$kosong','$validasi')");
	   $counter++;
	  }
	}
	
	
    echo" <h5> <font color=\"#339900 \">$counter Data Tersimpan</font> </h5>";
	}
	  ?>		 
      
             
              <!-- Horizontal Form -->
              <form name="edit" method="post" action="inputkerja.php">
                
                 <table border=0 width=50%>
                  <tr>
					<td width=150>Tapel / Semester </td>
					<td> <div class="col-sm"> 
					     <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>			
					</div></td>
                  </tr>
				  <tr>
					<td>Nama Guru</td>
					<td> <div class="col-sm"> 
					     <select name="iguru" id="iguru" class="form-select" required >
						  <option value="">Guru ...</option>
						  <?php  
							  $ag= mysqli_query($mysqli,"SELECT `Iduser`,`nama` FROM `user` WHERE `level`=1 ORDER BY Iduser ASC");
							  while($a2= mysqli_fetch_array($ag)){
						  ?>
							  <option value="<?php echo $a2['Iduser'] ?>"><?php echo  $a2['nama'] ?></option>
							  <?php }?>
							</select>			
					</div></td>
                  </tr>
				 
				  </table> 
              
					<table border=0 width=50% cellspacing="2" cellpadding="2" >
					<tr style="background-color: #9d9d9d" >
						<th colspan=2 width=150 align="center">Kelas</th>
						<th align="center">Mata Pelajaran</th>
					</tr>
					<tr style="background-color: #d1d1d1">
						<td><input name="s1" type="checkbox" id="s1" value="1"> </td>
						<td>
						<select name="ikelas1" id="ikelas1" class="form-select" >
						  <option value="">Kelas ...</option>
						  <?php  
							  $ak1= mysqli_query($mysqli,"SELECT * FROM `kelas` ORDER BY Idkelas ASC");
							  while($akelas1= mysqli_fetch_array($ak1)){
						  ?>
							  <option value="<?php echo $akelas1['Idkelas'] ?>"><?php echo  $akelas1['nama'] ?></option>
							  <?php }?>
							</select>			
							</div>						
						</td>
						<td><div class="col-sm-15">
						<select name="imapel1" id="imapel1" class="form-select" >
						  <option value="">Mapel ...</option>
						  <?php  
							  $am1= mysqli_query($mysqli,"SELECT * FROM `mapel` ORDER BY Idmapel ASC");
							  while($amapel1= mysqli_fetch_array($am1)){
						  ?>
							  <option value="<?php echo $amapel1['Idmapel'] ?>"><?php echo  $amapel1['nama'] ?></option>
							  <?php }?>
							</select>			
					</div></td>						
					</tr>
					<tr style="background-color: #d1d1d1">
						<td><input name="s2" type="checkbox" id="s2" value="2"> </td>
						<td>
						<select name="ikelas2" id="ikelas2" class="form-select" >
						  <option value="">Kelas ...</option>
						  <?php  
							  $ak2= mysqli_query($mysqli,"SELECT * FROM `kelas` ORDER BY Idkelas ASC");
							  while($akelas2= mysqli_fetch_array($ak2)){
						  ?>
							  <option value="<?php echo $akelas2['Idkelas'] ?>"><?php echo  $akelas2['nama'] ?></option>
							  <?php }?>
							</select>			
							</div>						
						</td>
						<td><div class="col-sm-15">
						<select name="imapel2" id="imapel2" class="form-select" >
						  <option value="">Mapel ...</option>
						  <?php  
							  $am2= mysqli_query($mysqli,"SELECT * FROM `mapel` ORDER BY Idmapel ASC");
							  while($amapel2= mysqli_fetch_array($am2)){
						  ?>
							  <option value="<?php echo $amapel2['Idmapel'] ?>"><?php echo  $amapel2['nama'] ?></option>
							  <?php }?>
							</select>			
					</div></td>						
					</tr>
					<tr style="background-color: #d1d1d1">
						<td><input name="s3" type="checkbox" id="s3" value="3"> </td>
						<td>
						<select name="ikelas3" id="ikelas3" class="form-select" >
						  <option value="">Kelas ...</option>
						  <?php  
							  $ak3= mysqli_query($mysqli,"SELECT * FROM `kelas` ORDER BY Idkelas ASC");
							  while($akelas3= mysqli_fetch_array($ak3)){
						  ?>
							  <option value="<?php echo $akelas3['Idkelas'] ?>"><?php echo  $akelas3['nama'] ?></option>
							  <?php }?>
							</select>			
							</div>						
						</td>
						<td><div class="col-sm-15">
						<select name="imapel3" id="imapel3" class="form-select" >
						  <option value="">Mapel ...</option>
						  <?php  
							  $am3= mysqli_query($mysqli,"SELECT * FROM `mapel` ORDER BY Idmapel ASC");
							  while($amapel3= mysqli_fetch_array($am3)){
						  ?>
							  <option value="<?php echo $amapel3['Idmapel'] ?>"><?php echo  $amapel3['nama'] ?></option>
							  <?php }?>
							</select>			
					</div></td>						
					</tr>
					<tr style="background-color: #d1d1d1">
						<td><input name="s4" type="checkbox" id="s4" value="4"> </td>
						<td>
						<select name="ikelas4" id="ikelas4" class="form-select" >
						  <option value="">Kelas ...</option>
						  <?php  
							  $ak4= mysqli_query($mysqli,"SELECT * FROM `kelas` ORDER BY Idkelas ASC");
							  while($akelas4= mysqli_fetch_array($ak4)){
						  ?>
							  <option value="<?php echo $akelas4['Idkelas'] ?>"><?php echo  $akelas4['nama'] ?></option>
							  <?php }?>
							</select>			
							</div>						
						</td>
						<td><div class="col-sm-15">
						<select name="imapel4" id="imapel4" class="form-select" >
						  <option value="">Mapel ...</option>
						  <?php  
							  $am4= mysqli_query($mysqli,"SELECT * FROM `mapel` ORDER BY Idmapel ASC");
							  while($amapel4= mysqli_fetch_array($am4)){
						  ?>
							  <option value="<?php echo $amapel4['Idmapel'] ?>"><?php echo  $amapel4['nama'] ?></option>
							  <?php }?>
							</select>			
					</div></td>						
					</tr>
					</table>
			  
			  
				  <table border=0 width=50%>
                  <tr>
					<td ><br> <button type="submit" name="simpan" class="btn btn-primary">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Simpan&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</button></td>
                  </tr>
                  </table> 
              

            
           
        </div><!-- End Left side columns -->

      
      </div>
    </section>
	
<?php
		  
 include "footer.php";
?>