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

if ($pg == 'mapel') {
	 $kode = $_POST['mapel'];
     $tingkat = $_POST['level'];
     $pk = $_POST['jrs'];
	  $urut = $_POST['urut'];
	  $kelompok = $_POST['kelompok'];
	   $sikap = $_POST['sikap'];
	    $kuri = $_POST['kuri'];
    $cek = mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM mapel_rapor WHERE  kode='$kode' AND tingkat='$tingkat'"));
        if ($cek > 0) :
            echo "GAGAL";
        else :
		
        $exec = mysqli_query($koneksi, "INSERT INTO mapel_rapor (urut,kode,tingkat,pk,kelompok,sikap,kurikulum) VALUES ('$urut','$kode','$tingkat','$pk','$kelompok','$sikap','$kuri')");
endif;
}
if ($pg == 'hapus') {
    $id = $_POST['id'];
    $exec = delete($koneksi, 'mapel_rapor', ['idm' => $id]);
    echo $exec;
}