<?php
if(count(get_included_files()) ==1) exit("Direct access not permitted.");
if(!$statuslogin) exit;
$mod = basename(__FILE__, '.php');
$page->tbJs($mod);
$page->addPlugin("upload");
if(isset($_GET['id'])){
	$id=strip_tags(stripslashes($_GET['id']));
	$page->setJudul("Input Banner slide");
	$judul="";
	$tautan="";
	$keterangan="";
	$idgambar=0;
	$namaawal="";
	$namabaru="";
	$folder="";
	if($id>0){
		$page->setJudul("Edit Banner slide");
		$query="SELECT t1.`id`,
					t1.`judul`,
					t1.`idgambar`,
					t1.`keterangan`,
					t1.`tautan`,
					t1.`urutan`,
					t1.`status`,
					if(t2.nama_awal is null,'PILIH GAMBAR BANNER',t2.nama_awal) as nama_awal,
					if(t2.nama_baru is null,'',t2.nama_baru) as nama_baru,
					if(t2.folder is null,'',t2.folder) as folder
			FROM tb_banner as t1
			left join tb_dokumen as t2 on t1.idgambar=t2.id
			WHERE t1.id=?";
		$rs=$db->loadAssoc($query,array($id));
		if(isset($rs['id'])){
			$judul=$rs['judul'];
			$tautan=$rs['tautan'];
			$keterangan=$rs['keterangan'];
			$idgambar=$rs['idgambar'];
			$namaawal=$rs['nama_awal'];
			$namabaru=$rs['nama_baru'];
			$folder=$rs['folder'];
		}else{
			exit;
		}
	}
	$hasildata=array(
		"id"=>$id,
		"idgambar"=>$idgambar,
		"namaawal"=>$namaawal,
		"namabaru"=>$namabaru,
		"folder"=>$folder
	);
	$page->addLoad("managbanner.edit(".json_encode($hasildata,true).")");
	?>
	<div class="box_main_konten">
		<h3>DETAIL DATA BANNER DEPAN</h3>
		<div class="group_form">
			<title>Judul Banner</title>
			<div class="col10"><input id="judul" value="<?php echo $judul;?>" />
				
			</div>
		</div>
		<div class="group_form">
			<title>Tautan</title>
			<div class="col10"><input id="tautan" value="<?php echo $tautan;?>" />
				
			</div>
		</div>
		
		<div class="group_form">
			<title>Gambar</title>
			<div class="col10"><div id="box_gambar_banner"></div>
				
			</div>
		</div>
		<div style="clear: both;"></div>
	</div>
	<div class="box_main_konten">
		<h3>KETERANGAN/DESKRIPSI</h3>
		<div>
			<textarea id="keterangan"><?php echo $keterangan;?></textarea>
		</div>
		<div style="clear: both;"></div>
	</div>
	<div class="box_button_bawah">
		<div id="loader_banner_err" class="error"></div>
		<span class="btmerah btncancel" onclick="managbanner.kembali()">Kembali</span>&nbsp;&nbsp;<span onclick="managbanner.simpan()" class="bthijau btnsave">Simpan</span>
	</div>
	
	<?php
}else{
	$page->addLoad("managbanner.load()");
	$page->setJudul("Manajemen Slide Banner Halaman");
	?>
	<div class="box_button_atas">
		Jumlah baris: <select id="jumlah_hal" class="slkecil" onchange="managbanner.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="managbanner.load()"><option value="1">1</option></select>
		&nbsp;<input placeholder="Default: Judul Banner" onkeypress="managbanner.enter(event)" id="cari" class="in_cari" />
		&nbsp;&nbsp;<span id="btcari" class="btnone btncari" onclick="managbanner.loade()">Cari</span>
		&nbsp;&nbsp;<span class="btnone btncanggih" onclick="managbanner.caricanggih()">Cari Detail</span>
	</div>
	<div id="grid_managbanner"></div>
	<div id="loader_daatabanner" class="error"></div>
	<div class="box_button_bawah">
		<span onclick="managbanner.buat(0)" class="bthijau btninput">Tambah Banner</span>
	</div>
	<div id="btedit" style="display:none;">
		<span class="icon_del" onclick="managbanner.hapus(#{id})"></span>
		<span class="icon_edit" onclick="managbanner.buat(#{id})"></span>
	</div>
	<span id="bturutan" class="bthijau medium" style="display: none;" onclick="managbanner.ubahurutan(#{id},##{jumlah_tabel},##{baris_tabel},this)">#{urutan}</span>
	<div id="box_urutan" style="display: none;">
		<div style="padding: 10px;">
			<div class="group_form">
				<title>Urutan</title>
				<div class="col10">
					<input id="urutan" />
				</div>
			</div>
			<div class="group_form">
				<title>&nbsp;</title>
				<div class="col10">
					<div class="box_button_bawah" style="margin-top: 20px;">
						<div id="loader_simpan_urutan" class="error"></div>
						<div>
							<span class="btmerah" onclick="managbanner.batalurutan()">Batal</span>&nbsp;&nbsp;
							<span onclick="managbanner.simpanurutan()" class="bthijau">Simpan</span>
						</div>
					</div>
				</div>
			</div>
			<div style="clear: both;"></div>
		</div>
	</div>
	<span id="btstatus" style="display: none" class="#(#{status}==1)?'mini_ok':'mini_dis'#" onclick="managbanner.setstatus(#{id},##{jumlah_tabel},##{baris_tabel},this)"></span>
	<div id="btdetailbanner" style="display: none;">
		<div><b>#{judul}</b></div>
		<div><b>#{tautan}</b></div>
		<div><b>#{keterangan}</b></div>
	</div>
	<?php
}
?>
