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

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

$json_response = array();
$filter_semester = "";
$filter_sms = "";
$filter_jenis = '';
$filter_mbkm = '';
$jumlah = 0;
$array_status = array();
        if ($_POST['semester']!='all') {
          $filter_semester = "and id_aktivitas in (select id_akt_mhs from akt_mhs where id_smt='".$_POST['semester']."')";
          
       }

       if ($_POST['jurusan']!='all') {
          $filter_sms = "and id_aktivitas in (select id_akt_mhs from akt_mhs where id_sms='".$_POST['jurusan']."')";
      }

        if ($_POST['jenis']!='all') {
          $filter_jenis = "and id_aktivitas in (select id_akt_mhs from akt_mhs where id_jns_akt_mhs='".$_POST['jenis']."')";
       }

       $filter_mbkm = "id_konversi_aktivitas in(select id_konversi_akt_mhs from konversi_akt_mhs where soft_delete='0') $filter_semester $filter_sms $filter_jenis";

        //echo $filter_mahasiswa;


        $temp_count_mk = [
              'act' => 'GetCountKonversiKampusMerdeka',
                'token' => $token,
                'filter' => $filter_mbkm
            ];
        $temp_count = json_decode($db->run($temp_count_mk,$url));
       // dump($temp_count);
        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);
?>