<?php
include "../../inc/config.php";
$token = get_token();
$url = $db->get_service_url('rest');

switch ($_GET["act"]) {
  case 'delete_all':

  $filter_nim = "id_smt='".$_POST['sem']."'";

  $data_kuliah = $proxy->GetRecordset($token,'kuliah_mahasiswa', $filter_nim,$order,$limit,$offset);

    foreach ($data_kuliah['result'] as $dt) {
       $hapus[] = array(
          'id_smt' => $dt['id_smt'],
          'id_reg_pd'=>$dt['id_reg_pd']
          );
    
     }

        $temp_res = $proxy->DeleteRecordset($token, 'kuliah_mahasiswa', json_encode($hapus));

    break;
  case "delete":
  $id_akm_pd = $_GET["id"];

  $exp = explode("_", $id_akm_pd);

   $hapus = array(
      'id_semester' => $exp[0],
      'id_registrasi_mahasiswa'=>$exp[1]
      );

      
                 $temp_del_dosen = [
                'act' => 'DeletePerkuliahanMahasiswa',
                  'token' => $token,
                  'key' => $hapus
              ];

                  $temp_del = json_decode($db->run($temp_del_dosen,$url));
                  dump($temp_del);


  break;

  case 'del_massal':
     $data_ids = $_REQUEST['data_ids'];
    $data_id_array = explode(",", $data_ids);
    if(!empty($data_id_array)) {

      foreach($data_id_array as $id_kls) {

    $exp = explode("_", $id_kls);

   $hapus = array(
      'id_semester' => $exp[0],
      'id_registrasi_mahasiswa'=>$exp[1]
      );

      
                 $temp_del_dosen = [
                'act' => 'DeletePerkuliahanMahasiswa',
                  'token' => $token,
                  'key' => $hapus
              ];

                  $temp_del = json_decode($db->run($temp_del_dosen,$url));
                  dump($temp_del);



      }

    }
    break;

}