<?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("Detail Email Pesan Notifikasi");
	$tanggal="";
	$tanggalkirim="";
	$email="";
	$pesan="";
	$subject="";
	$statuspesan="Belum dikirim";
	$status=0;
	if($id>0){
		$page->setJudul("Detail Email Pesan Notifikasi");
		$query="SELECT * FROM tb_kirim_email 
			WHERE id=?";
		$rs=$db->loadAssoc($query,array($id));
		if(isset($rs['id'])){
			$email=$rs['email'];
			$pesan=$rs['pesan'];
			$subject=$rs['subject'];
			$tanggal=$db->fulldate($rs['tanggal']);
			if(isset($rs['tanggal_kirim'])) $tanggalkirim=$db->fulldate($rs['tanggal_kirim']);
			if($rs['status']==1) $statuspesan="Terkirim";
			if($rs['status']==3) $statuspesan="Tidak Terkirim";
			$status=$rs['status'];
		}
	}else{
		exit;
	}
	$datahasil=array("id"=>$id);
	$page->addLoad("kirimemail.edit(".json_encode($datahasil,true).")");
	
	?>
	<div class="box_main_konten">
		<h3>DATA EMAIL NOTIFIKASI</h3>
		<div class="group_form">
			<title>Tanggal Pesan</title>
			<div class="col10">
				<div class="formdata"><?php echo $tanggal;?></div>
			</div>
		</div>
		<div class="group_form">
			<title>Email</title>
			<div class="col10">
				<div class="formdata"><?php echo $email;?></div>
			</div>
		</div>
		<div class="group_form">
			<title>Subject</title>
			<div class="col10">
				<div class="formdata"><?php echo $subject;?></div>
			</div>
		</div>
		<div class="group_form">
			<title>Pesan</title>
			<div class="col10">
				<div class="formdata"><?php echo $pesan;?></div>
			</div>
		</div>
		<div class="group_form">
			<title>Status</title>
			<div class="col10">
				<div class="formdata"><?php echo $statuspesan;?></div>
			</div>
		</div>
		<?php
		if($status==1){
			?>
			<div class="group_form">
				<title>Tanggal Terkirim</title>
				<div class="col10">
					<div class="formdata"><?php echo $tanggalkirim;?></div>
				</div>
			</div>
			<?php
		}
		?>
		<div style="clear: both;"></div>
	</div>
	<div class="box_button_bawah">
		<div id="loader_kirimemail" class="error"></div>
		<span class="btmerah btncancel" onclick="kirimemail.kembali()">Kembali</span>
	</div>
	<?php
}else{
	$page->addLoad("kirimemail.load()");
	$page->setJudul("Monitoring Email Notifikasi");
	?>
	<div class="box_button_atas">
		Jumlah baris: <select id="jumlah_hal" class="slkecil" onchange="kirimemail.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="kirimemail.load()"><option value="1">1</option></select>
		&nbsp;<input placeholder="Default: Email" onkeypress="kirimemail.enter(event)" id="cari" class="in_cari" />
		&nbsp;&nbsp;<span id="btcari" class="btnone btncari" onclick="kirimemail.loade()">Cari</span>
		&nbsp;&nbsp;<span class="btnone btncanggih" onclick="kirimemail.caricanggih()">Cari Detail</span>
	</div>
	<div id="grid_kirimemail"></div>
	<div id="loader_datakirimemail" class="error"></div>
	
	<div id="btedit" style="display:none;">
		<span class="btlihat" onclick="kirimemail.buat(#{id})"></span>
	</div>
	<span id="btstatus" class="medium #('#{status}'=='1')?'bthijau':(('#{status}'=='3')?'btmerah':'bthitam')#" style="display:none;">#('#{status}'=='1')?'Terkirim':(('#{status}'=='3')?'Tidak Terkirim':'Belum dikirim')#</span>
	<?php
}
?>
