<?php
session_start();
include "../../../inc/config.php";



$url = get_service_url('rest');
$token = get_token();
   $semester = '';
  if ($_POST['semester']=='all') {
      $semester = '';
      if ($_POST['jurusan']=='all') {
    $id_sms = '';
      if ($_SESSION['level']!=1) {
      $id_sms = "id_prodi='".$_SESSION['id_sms']."'";
    }

    } else {
      $id_sms = "and id_prodi='".$_POST['jurusan']."'";
    }
  } else {
    $semester = "and id_semester='".$_POST['semester']."'";
      if ($_POST['jurusan']=='all') {
        $id_sms = '';
        if ($_SESSION['level']!=1) {
      $id_sms = "and id_prodi='".$_SESSION['id_sms']."'";
    }
    } else {
      $id_sms = "and id_prodi='".$_POST['jurusan']."'";
    }
  }

  
$filter_aktivitas = "id_aktivitas is not null $semester $id_sms";

$nidn ="";
  if ($_POST['jenis_peran']=='bimbing') {
    $jenis = "Pembimbing ";
    $table = "GetListBimbingMahasiswa";
    $table_soap = 'bimbing_mahasiswa';
    $filter_count = "and jns_peran_mhs='".$_POST['jenis_peran']."' ";
  } else {
    $table = "GetListUjiMahasiswa";
    $jenis = "Penguji ";
    $table_soap = 'uji_mahasiswa';
  }

if ($_POST['nidn']!='all') {
    $nidn  = "nidn like '%".$_POST['value_nidn']."%'";
    $data_dic = array(
    'act' => $table,
    'token' => $token,
    'filter' => $nidn
    );
    $temp_recs = json_decode($db->run($data_dic,$url));
    $jumlah = count($temp_recs->data);
} else {
  $data_dic = array(
  'act' => 'GetCountAktivitasMahasiswa',
  'token' => $token,
  'filter' => $filter_aktivitas
  );
  $temp_recs = json_decode($db->run($data_dic,$url));
  $jumlah = $temp_recs->data;
  //print_r($temp_recs);
}


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

echo json_encode($json_response);
?>