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

$token = get_token();
$url = get_service_url();

$json_response = array();

$filter_jurusan = "";
$filter_kurikulum = "";
$filter_matkul = "";
$filter_mk = "";
$jumlah = 0;
        if ($_POST['jurusan']!="all") {
                $temp_count_mk = [
                      'act' => 'GetCountMataKuliah',
                        'token' => $token,
                        'filter' => "id_prodi='".$_POST['jurusan']."' and id_matkul not in(select id_mk from matkul_kurikulum)"
                    ];
                $temp_count = json_decode($db->run($temp_count_mk,$url));
                if(!empty($temp_count->data)) {
                  $jumlah = $temp_count->data;
                }
          
          } else {
            $temp_count_mk = [
                  'act' => 'GetCountMataKuliah',
                    'token' => $token,
                    'filter' => "id_matkul not in(select id_mk from matkul_kurikulum)"
                ];
            $temp_count = json_decode($db->run($temp_count_mk,$url));
            if(!empty($temp_count->data)) {
              $jumlah = $temp_count->data;
            }

          }
        
        if ($jumlah>0) {
           $json_response['jumlah'] = $jumlah;
        } else {
          $json_response['jumlah'] = 0;
        }

        echo json_encode($json_response);
?>