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


//untuk coba-coba
// $url = 'http://pddikti.uinsgd.ac.id:8082/ws/live.php?wsdl'; // gunakan live bila

$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']."'";
    }
  }

  
  if ($_POST['jenis']=='all') {
    $jenis = '';
  } else {
    $jenis = "and id_jenis_aktivitas='".$_POST['jenis']."'";
  }

$filter_aktivitas = "id_aktivitas is not null $semester $id_sms $jenis";
       
$data_dic = array(
  'act' => 'GetCountAktivitasMahasiswa',
  'token' => $token,
  'filter' => $filter_aktivitas
);
$temp_recs = json_decode($db->run($data_dic,$url));
//print_r($temp_recs);

if (!empty($temp_recs->data)) {
   $json_response['jumlah'] = $temp_recs->data;
} else {
  $json_response['jumlah'] = 0;
}

echo json_encode($json_response);
?>