<?php
header('Access-Control-Allow-Origin: *');
include "../../inc/config.php";
$token = get_token();;
$json_response = array();
$filter_sms = "";
$filter_angkatan = "";
$filter_status = "";
$tahun_lulus = "";
$jumlah = 0;
$array_status = array();
      if ($_POST['jurusan']!="all") {
            $filter_sms = "id_registrasi_mahasiswa is not null and id_prodi='".$_POST['jurusan']."'";
        } else {
            $filter_sms = "id_registrasi_mahasiswa is not null";
        }
         $filter_angkatan = "and (left(id_periode_masuk,4) BETWEEN '".$_POST['angkatan_awal']."' and '".$_POST['angkatan_akhir']."')";

        $filter_status = " and id_registrasi_mahasiswa in (select id_reg_pd from reg_pd where tgl_keluar is null)";
        $filter_pilihan = "";
        if ($_POST['pilihan_akm']!='all') {
          $filter_pilihan = "and id_registrasi_mahasiswa not in(select id_reg_pd from kuliah_mhs where id_smt='".$_POST['sem_filter']."')";
        }
        $data_rec = array();
        $filter_mahasiswa = "$filter_sms $filter_angkatan $filter_status $filter_pilihan";
        if ($_POST['nim']!='all') {
          $filter_nim = "nim='".$_POST['value_nim']."'";
          $filter_mahasiswa = $filter_nim;
        }

        $temp_count_mhs = [
              'act' => 'GetCountRiwayatPendidikanMahasiswa',
                'token' => $token,
                'filter' => $filter_mahasiswa
            ];
        $temp_count = service_request($temp_count_mhs);
        if(!empty($temp_count->data)) {
          $jumlah = $temp_count->data;
        }
/*       dump($temp_count_mhs);
        dump($temp_count);*/


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

        echo json_encode($json_response);
?>