<?php
session_start();
//include "inc/config.php";
include "../../inc/config.php";
$token = get_token();
		$requestData= $_REQUEST;

		$sSearch = $requestData['search']['value'];
$filter = "";
$semester = "";
$search_filter = "";
$prodi = "";
$keyword = "";
$status = "";
$id_sms = "";
$filter_count = "";
$kode_mk = "";
$kelas = "";
$jumlah = 0;
$and_id_prodi = "";
$id_reg_pd = "nothing";
$and_semester = "";
$and_kelas = "";
//dump($data_dic);
$filter_kelas = "nothing";
$id_reg_pd = "nothing";

if ($sSearch!='') {
	$search_filter = "and lower(nama_substansi) like '%".strtolower($sSearch)."%')";
}

		
		//$Data = $this->input->get('columns');
		//$orders = $requestData['order'];
		//$temp_order = 


		$iStart = $requestData['start'];
		$iLength = $requestData['length'];

		$temp_limit = $iLength;
		$temp_offset = $iStart?$iStart : 0;

		

		$periode = "";
		$jenis_kelamin = "";
		$jurusan = "";

		if ($_POST["jurusan"] != "all") {
		    $jurusan = "and id_prodi='".$_POST['jurusan']."'";
		}

		$filter_dosen = "id_substansi is not null $jurusan $search_filter";

		

		$data_dics = [
			'act' => 'GetListSubstansiKuliah',
		    'token' => $token,
		    'filter' => $filter_dosen,
		    'order' => 'nama_substansi asc',
		    'limit' => $temp_limit,
		    'offset' => $temp_offset

		];


		
$temp_data = service_request($data_dics);
		
		if ($sSearch!='') {
			$totalData = count($temp_data->data);
			$totalFiltered = count($temp_data->data);
		} else {
			
			$array_count = array(
			  'act' => 'GetCountSubstansiKuliah',
			  'token' => $token,
			  'filter' => $filter_dosen
			);
			$temp_count = service_request($array_count);
			$jumlah = $temp_count->data;

			$totalData = $jumlah;
			$totalFiltered = $totalData;
		}


		$temp_datas = array();
		$i=0;
		
		if (!empty($temp_data->data)) {

		foreach ($temp_data->data as $dt) {
						$temps = array();
					
					 $temps[] = '<div class="input-group">
                <b><input type="text" name="total_tagihan" class="form-control id_dosen" readonly="" value="'.$dt->id_substansi.'">
                </b>
                 <span class="input-group-addon salin copy-btn" title="Klik untuk Copy" data-placement="left">Salin</span>
              </div>';
					$temps[] = $dt->nama_substansi;
					$temps[] = $dt->sks_mata_kuliah;
					$temps[] = $dt->sks_tatap_muka;
					$temps[] = $dt->sks_praktek;
					$temps[] = $dt->sks_praktek_lapangan;
					$temps[] = $dt->sks_simulasi;
					$temps[] = $dt->nama_program_studi;
					
				$temp_datas[] = $temps;
			}
		}
			$temp_output = array(
									'draw' => intval($requestData['draw']),
									'recordsTotal' => intval( $totalData ),
									'recordsFiltered' => intval( $totalFiltered ),
									'data' => $temp_datas
				);

			echo json_encode($temp_output);