<?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 == 'seting') {
   
    $data = [
        'elearn' => $_POST['elearn'],
	'daring' => $_POST['daring']   
    ];
	
  
	$exec = update($koneksi, 'menu', $data, ['id_menu' => 1]);
   
}

if ($pg == 'setting_clear') {
    $pengawas = fetch($koneksi, 'users', ['id_pengawas' => $_SESSION['id_pengawas']]);
    $password = $_POST['password'];
    if (!password_verify($password, $pengawas['password'])) {
        echo "password salah";
    } else {
        if (!empty($_POST['data'])) {
            $data = $_POST['data'];
            if ($data <> '') {
                foreach ($data as $table) {
                    if ($table <> 'pengawas') {
                        mysqli_query($koneksi, "TRUNCATE $table");
                    } else {
                        mysqli_query($koneksi, "DELETE FROM $table WHERE level!='admin'");
                    }
                }
                echo "ok";
            }
        }
    }
}

if ($pg == 'edit') {
	$id = $_POST['id'];
     $datax = [
        'status' => $_POST['sts']
		 
		];
    $exec = update($koneksi, 'daftar', $datax, ['id_daftar' => $id]);
}
if ($pg == 'hapus') {
	$id = $_POST['id'];
     
    $exec = delete($koneksi, 'kontak',['id_kontak' => $id]);
}
if ($pg == 'hapus_j') {
	$id = $_POST['id'];
     
    $exec = delete($koneksi, 'jenjang',['id_jenjang' => $id]);
}
if ($pg == 'hapus_b') {
	$id = $_POST['id'];
     
    $exec = delete($koneksi, 'biaya',['id_biaya' => $id]);
}
if ($pg == 'hapus_rek') {
	$id = $_POST['id'];
     
    $exec = delete($koneksi, 'm_rek',['id' => $id]);
}
if ($pg == 'konbayar') {
	$id = $_POST['id'];
     $datax = [
        'verifikasi' => 1
		 
		];
    $exec = update($koneksi, 'bayar', $datax, ['id_bayar' => $id]);
}