<?php
//session_start();
include("../library/inc.connection.php");
include_once "library/inc.library.php";
include_once "library/inc.sesadmin.php";
include_once "library/inc.dataadmin.php";			
$txtKode=$_POST['txtKode'];
$txtMapel = pg_escape_string($_POST['txtMapel']);
$txtringkas = pg_escape_string($_POST['txtringkas']);
 
	#INSERT TABEL KKM
$qcek = pg_query("SELECT * FROM tabel_mapel 
  WHERE mata_pelajaran_id='$txtKode' AND kelompok='S'");
if ($cek = pg_fetch_array($qcek)){
	echo "<script>alert('data Mata Pelajaran Suplemen  sudah ada');
	location.replace('?page=Data-Mapel-Suplemen');</script>";
	
}else{
  

  $sqlSave2="INSERT INTO tabel_mapel VALUES ( 
    	'$txtKode', '$txtMapel','S','1','0','1','$txtMapel','$txtringkas')";
	$simpandata=pg_query($sqlSave2)	;
	if($simpandata){
	 echo "<script>alert('data Mata Pelajaran Lokal berhasil ditambah')
	 location.replace('?page=Data-Mapel-Suplemen')</script>";
	}else{
		//echo $sqlSave2;
		echo "<script>alert('Gagal menambah data Mata Pelajaran Lokal, silahkan isi data dengan benar!')
		location.replace('?page=Data-Mapel-Suplemen')</script>";
	}
}
?>