<?php
if(count(get_included_files()) ==1) exit("Direct access not permitted.");
if(!$statuslogin) exit;
$mod = basename(__FILE__, '.php');
$page->tbJs($mod);
if(isset($_GET['id'])){
	$id=strip_tags(stripslashes($_GET['id']));
	$page->setJudul("Input Data Kota Baru");
	$nama="";
	$idpropinsi=0;
	$kode="";
	$lokasi="";
	if($id>0){
		$page->setJudul("Edit Data Kota Baru");
		$query="SELECT * FROM tb_kota WHERE id=?";
		$rs=$db->loadAssoc($query,array($id));
		if(isset($rs['id'])){
			$nama=$rs['kota'];
			$idpropinsi=$rs['idpropinsi'];
			$kode=$rs['kode'];
			$lokasi=$rs['lokasi'];
		}
	}
	$page->addLoad("masterkota.edit($id,$idpropinsi)");
	?>
	<div class="box_main_konten">
		<h3>DETAIL DATA KOTA</h3>
		<div class="group_form">
			<title>Propinsi</title>
			<div class="col10">
				<select id="sl_propinsi">
				<?php
				$qr="select * from tb_propinsi order by propinsi asc";
				$rs=$db->getObj($qr);
				foreach ($rs as $obj) {
					?>
					<option value="<?php echo $obj->id;?>"><?php echo $obj->propinsi;?></option>
					<?php
				}
				?>
				</select>
			</div>
		</div>
		<div class="group_form">
			<title>Kode Kota</title>
			<div class="col10"><input id="kode" value="<?php echo $kode;?>" />
				
			</div>
		</div>
		<div class="group_form">
			<title>Nama Kota</title>
			<div class="col10"><input id="nama" value="<?php echo $nama;?>" />
				
			</div>
		</div>
		<div class="group_form" style="display: none;">
			<title>Koordinat Lokasi</title>
			<div class="col10">
				<div id="lokasi" class="boxparrent" onclick="masterkota.pilihlokasi()"><?php echo $lokasi;?></div>
			</div>
		</div>
		<div style="clear: both;"></div>
	</div>
	<div class="box_button_bawah">
		<div id="loader_err_kota" class="error"></div>
		<span class="btmerah btncancel" onclick="masterkota.kembali()">Kembali</span>&nbsp;&nbsp;<span onclick="masterkota.simpan()" class="bthijau btnsave">Simpan</span>
	</div>
	<?php
}else{
	$page->addLoad("masterkota.load()");
	$page->setJudul("Master Kota");
	?>
	<div class="box_button_atas">
		Jumlah baris: <select id="jumlah_hal" class="slkecil" onchange="masterkota.loade()">
			<option value="30">30</option>
			<option value="50">50</option>
			<option value="100">100</option>
		</select> &nbsp;
		Hal: <select id="hal_ke" class="slkecil" onchange="masterkota.load()"><option value="1">1</option></select>
		&nbsp;<input placeholder="Default: Nama Kota" onkeypress="masterkota.enter(event)" id="cari" class="in_cari" />
		&nbsp;&nbsp;<span id="btcari" class="btnone btncari" onclick="masterkota.loade()">Cari</span>
		&nbsp;&nbsp;<span class="btnone btncanggih" onclick="masterkota.caricanggih()">Cari Detail</span>
	</div>
	<div id="grid_masterkota"></div>
	<div id="loader_datakota" class="error"></div>
	<div class="box_button_bawah">
		<span onclick="masterkota.buat(0)" class="bthijau btninput">Tambah Nama Kota</span>
	</div>
	<div id="btedit" style="display:none;">
		<span class="icon_del" onclick="masterkota.hapus(#{id})"></span>
		<span class="icon_edit" onclick="masterkota.buat(#{id})"></span>
	</div>
	<span id="btlokasi" class="bthijau medium" style="display:none;" onclick="masterkota.setlokasi(#{id},##{jumlah_tabel},##{baris_tabel},this)">#{lokasipeta}</span>
	<?php
}
?>
