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

    $query_jenis = '';
    $query_jurusan = '';
    $sem = "";

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

$json_response = array();

$data = $db->fetch_custom("select substansi_kuliah.* from substansi_kuliah where substansi_kuliah.id is not null $query_jurusan and status_error!=1 $query_jenis");
if ($data->rowCount()>0) {
   $json_response['jumlah'] = $data->rowCount();
} else {
  $json_response['jumlah'] = 0;
}

echo json_encode($json_response);

?>
