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

$query_matkul = '';
    $query_kelas = '';
    $query_jurusan = '';

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

$json_response = array();

$data = $db->fetch_custom("select mat_rencana_pembelajaran.id from mat_rencana_pembelajaran inner join jurusan on mat_rencana_pembelajaran.kode_jurusan=jurusan.kode_jurusan where mat_rencana_pembelajaran.id is not null $query_jurusan and status_error!=1 $query_matkul $query_kelas");
if ($data->rowCount()>0) {
   $json_response['jumlah'] = $data->rowCount();
} else {
  $json_response['jumlah'] = 0;
}

echo json_encode($json_response);

?>
