<?php
include "../../inc/config.php";

 $config = $db->fetch_single_row('config_user','id',1);

if ($config->live=='Y') {
  $url = 'http://'.$config->url.':'.$config->port.'/ws/live2.php'; // gunakan live
} else {
  $url = 'http://'.$config->url.':'.$config->port.'/ws/sandbox2.php'; // gunakan sandbox
}


# MENDAPATKAN TOKEN
$data = array(
  'act' => 'GetToken',
  'username' => $config->username,
  'password' => $config->password
);
$result = json_decode($db->run($data,$url));
$token = $result->data->token;


$id_jur = $_POST['jurusan'];
$semester = $_POST['semester'];

 $prodi = $db->fetch_single_row('jurusan','id_sms',$id_jur);

$id_sms = $prodi->id_sms;


    $filter_kelas = "id_prodi='".$id_sms."' and id_semester='".$semester."'";

                $temp_data_kelas = [
      'act' => 'GetDetailKelasKuliah',
        'token' => $token,
        'filter' => $filter_kelas,
        'order' => "id_semester DESC",
        'limit' => "",
        'offset' => ""

    ];


    $kelas = json_decode($db->run($temp_data_kelas,$url));



foreach ($kelas->data as $data_kelas) {
    $array_kode_mk[$data_kelas->id_matkul] = $data_kelas->nama_mata_kuliah;
}
$kode_mk_group = array_unique($array_kode_mk);

echo '<option value="all">Semua</option>';
foreach ($kode_mk_group as $isi => $data) {
echo "<option value='".$isi."'>".$data."</option>";
} 
