<?php
require("../../../config/koneksi.php");
require("../../../config/function.php");
require("../../../config/crud.php");
cek_session_guru();
(isset($_GET['pg'])) ? $pg = $_GET['pg'] : $pg = '';
if ($pg == 'hapus') {
   $id = $_POST['id'];
    delete($koneksi, 'agenda_proto', ['id_proto' => $id]);
}
if ($pg == 'tambah') {
	           
                
                $kelas = $_POST['kelas'];
                $tanggal = $_POST['tgl'];
                $lm = $_POST['lm'];
                 $tp = $_POST['tp'];
               
				 $guru=$_POST['guru'];

				 
				 
           	
$data = [
'tanggal' => $tanggal,
'idlm' => $lm,
'kelas' => $kelas,
'idtp' => $tp,
'guru' => $guru

];
$where = [
                
                'kelas' => $kelas,
				 'idlm' => $lm,
				  'idtp' => $tp
            ];
            $cek = rowcount($koneksi, 'agenda_proto', $where);
            if ($cek == 0) {
      $exec=insert($koneksi,'agenda_proto',$data);
	   echo $exec;
	    }else{
			}
			

		
			
}
if ($pg == 'tambah_jurnal') {
	            $id=$_POST['id'];
                $pecah = $_POST['pecah'];
				 $hambat = $_POST['hambat'];
				

           
           
$data = [
'hambatan' => $hambat,
'pemecahan' => $pecah

];
 $cek = rowcount($koneksi, 'agenda_proto', $data);
            if ($cek == 0) {
      $exec=update($koneksi,'agenda_proto',$data,['id_proto'=>$id]);
	   echo $exec;
			}else{
				
			}
			
}