<?php
require("../../config/koneksi.php");
require("../../config/function.php");
require("../../config/crud.php");
cek_session_admin();
(isset($_GET['pg'])) ? $pg = $_GET['pg'] : $pg = '';

if ($pg == 'editjadwal') {
     $kelas = $_POST['kelas']; 
$data = [
'kkm' =>$_POST['kkm']

];

    update($koneksi, 'jadwal_mapel',$data,['kelas' => $kelas]);
}
if ($pg == 'editmulti') {
     $kelas = $_POST['kelas']; 
	 $kode = $_POST['mapel'];
	 $kkm = $_POST['kkm'];
$jml_data = count($_POST['mapel']);
for ($i=0; $i <= $jml_data; $i++){
	  $exec = mysqli_query($koneksi,"UPDATE jadwal_mapel SET kkm='".$kkm[$i]."' WHERE kode='".$kode[$i]."' AND kelas='".$kelas[$i]."'");
}
}
if ($pg == 'spiritual') {
     $level = $_POST['level']; 
     $kode = $_POST['kode']; 
   mysqli_query($koneksi,"UPDATE jadwal_mapel SET agama='1' WHERE tingkat='$level' AND kode='$kode'");
}
if ($pg == 'sosial') {
     $level = $_POST['level']; 
     $kode = $_POST['kode']; 
   mysqli_query($koneksi,"UPDATE jadwal_mapel SET ppkn='1' WHERE tingkat='$level' AND kode='$kode'");
}