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

$json_response = array();

	$sem = "";
    if ($_POST['sem']!='all') {
      $sem = "and nilai_akm.semester='".$_POST['sem']."'";
    }

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

$data = $db->fetch_custom("select *,nilai_akm.id as id_akm from nilai_akm inner join jurusan on nilai_akm.kode_jurusan=jurusan.kode_jurusan where nilai_akm.id is not null $sem $jurusan and valid!=1");
if ($data->rowCount()>0) {
   $json_response['jumlah'] = $data->rowCount();
} else {
  $json_response['jumlah'] = 0;
}

echo json_encode($json_response);

?>
