<?php
session_start();
header('Access-Control-Allow-Origin: *');
include "../../../inc/config.php";

$query_matkul = '';
    $query_kelas = '';
        $sem = "";
    if ($_POST['sem']!='all') {
      $sem = "and kurikulum.mulai_berlaku='".$_POST['sem']."'";
    }


$jurusan = $_POST['jurusan'];
if ($jurusan=='all') {
	$jurusan = "";
    if ($_SESSION['level']!=1) {
        $jurusan = "and jurusan.kode_jurusan='".$_SESSION['jurusan']."'";
      }
} else {
	$jurusan = "and jurusan.kode_jurusan='".$_POST['jurusan']."'";
}

$json_response = array();
$data = $db->fetch_custom("select *,kurikulum.id as id_krs from kurikulum inner join jurusan on kurikulum.kode_jurusan=jurusan.kode_jurusan where status_error!=1 $sem $jurusan");
if ($data->rowCount()>0) {
   $json_response['jumlah'] = $data->rowCount();
} else {
  $json_response['jumlah'] = 0;
}

echo json_encode($json_response);

?>
