<?php
require("../../../config/koneksi.php");
require("../../../config/function.php");
require("../../../config/crud.php");

(isset($_GET['pg'])) ? $pg = $_GET['pg'] : $pg = '';

if ($pg == 'tambah') {
  $where = [
				'fase' => $_POST['fase'],
				'kelas'=>$_POST['kelas'],
				 'judul'=>$_POST['judul'],
				
    ];
    $data = [
				'fase' => $_POST['fase'],
				'kelas'=>$_POST['kelas'],
				 'judul'=>$_POST['judul'],
				 'deskripsi'=>$_POST['deskripsi']
				
    ];
	
	 $cek = rowcount($koneksi, 'm_proyek', $where);
            if ($cek == 0) {
            $exec = insert($koneksi, 'm_proyek', $data);
            echo $exec;
        }
}

if ($pg == 'hapus') {
    $id = $_POST['id'];
    delete($koneksi, 'm_proyek', ['id' => $id]);
}
if ($pg == 'hapusmateri') {
    $id = $_POST['id'];
    delete($koneksi, 'lingkup', ['id' => $id]);
}