<?php
error_reporting(0); /*
error_reporting(E_ALL);  
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE); */

include "../config/conn.php";

if(isset($_GET['data'])){
	if($_GET['data'] == 'kalibrasiDetail'){
		$sql = "SELECT shift_list.*, m_lokasi.id_lokasi, m_lokasi.nama_lokasi,m_lokasi.id_bbws,m_lokasi.nama_alat FROM shift_list
				LEFT JOIN m_lokasi ON m_lokasi.nama_lokasi = CONVERT(shift_list.dev_name USING utf8)
				WHERE MD5(shift_list.dev_name) = '".$_GET['id']."'"; 
		$query = mysql_query($sql);

		$row = mysql_fetch_object($query);
		echo json_encode($row);

	}else if($_GET['data'] == 'mandasDetail'){
		$sql = "SELECT * FROM m_das WHERE id_das = ".$_GET['id']."";
		$query=mysql_query($sql);

		$row = mysql_fetch_object($query);
		echo json_encode($row);

	}else if($_GET['data'] == 'manlengkungDetail'){
		$sql = "SELECT
					a.id_debit,
					b.id_lokasi,
					b.nama_lokasi,
					b.nama_alat,
					b.id_tipe,
					b.id_merk,
					a.tahun_debit,
					a.nilai_a,
					a.nilai_b,
					a.nilai_c,
					b.WLevel
				FROM
				m_debit AS a
				INNER JOIN m_lokasi AS b ON b.id_lokasi = a.id_lokasi WHERE a.id_debit=".$_GET['id']."";
		$query=mysql_query($sql);

		$row = mysql_fetch_object($query);
		if($row->tahun_debit == '0'){
    		$row->tahun_debit = '2021';
    	}
		echo json_encode($row);
		
	}else if($_GET['data'] == 'dokkegiatanDetail'){
		$sql = "SELECT * FROM t_kegiatan WHERE id_kegiatan = ".$_GET['id']."";
		$query=mysql_query($sql);

		$row = mysql_fetch_object($query);
		echo json_encode($row);

	}else if($_GET['data'] == 'lokasiDetail'){
		$sql = "SELECT * FROM m_lokasi WHERE id_lokasi = ".$_GET['id']."";
		$query=mysql_query($sql);

		$row = mysql_fetch_object($query);
		echo json_encode($row);
	}else if($_GET['data'] == 'optionKotaByProv'){
		$queryKota = mysql_query("SELECT * FROM m_kota WHERE id_provinsi = ".$_GET['id']."");
		$optionKota = '<option value="0">Pilih Kota</option>';
		while($rowP = mysql_fetch_array($queryKota)){
			$optionKota .= '<option value="'.$rowP['id_kota'].'">'.$rowP['nama_kota'].'</option>';
		}
		echo $optionKota;
	}
}
?>