<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" href="function/dataTables/media/css/demo_page.css">
<link rel="stylesheet" href="function/dataTables/media/css/demo_table_jui.css">
<link rel="stylesheet" href="function/dataTables/media/themes/smoothness/jquery-ui-1.8.4.custom.css">
<link rel="stylesheet" href="include/css/style_tabs.css">
<script type="text/javascript" src="function/dataTables/media/js/jquery.dataTables.js"></script>
<script type="text/javascript" language="javascript">
	$(document).ready(function(){ 
		$("#fromdate").datepicker({
			dateFormat : "yy-mm-dd",
			changeMonth : true,
			changeYear : true,
		});
	});
	$(document).ready(function(){
		$("#todate").datepicker({
			dateFormat : "yy-mm-dd",
			changeMonth : true,
			changeYear : true,
		});
	});
	$(document).ready( function () {
		var oTable = $('#myTables').dataTable( {
			 "sDom": 'R<"H"lfr>t<"F"ip>',
			 "bJQueryUI": true,
			 "sPaginationType": "full_numbers",
			 "iDisplayLength" :10
		});
	});
	$(document).ready( function () {
		var oTable = $('#myTables1').dataTable( {
			 "sDom": 'R<"H"lfr>t<"F"ip>',
			 "bJQueryUI": true,
			 "sPaginationType": "full_numbers",
			 "iDisplayLength" :10
		});
	});
	$(document).ready( function () {
		var oTable = $('#myTables2').dataTable( {
			 "sDom": 'R<"H"lfr>t<"F"ip>',
			 "bJQueryUI": true,
			 "sPaginationType": "full_numbers",
			 "iDisplayLength" :10
		});
	});
	function setTrColor(obj, color)
	{
		obj.style.backgroundColor=color;
		obj.onmouseout = function(){
				obj.style.backgroundColor=''; 
		}
	}
	function print_click_ap(id){
		window.open("transaksi/akuntansi/pdf_transaksi_jurnal_ap.php?jurnal_id="+id,"mywindow","menubar=1,scrollbars=1,resizable=1,width=1000,height=1000");
	}	
	function print_click_ar(id){
		window.open("transaksi/akuntansi/pdf_transaksi_jurnal_ap.php?jurnal_id="+id,"mywindow","menubar=1,scrollbars=1,resizable=1,width=1000,height=1000");
	}
	function print_click_ot(id){
		window.open("transaksi/akuntansi/pdf_transaksi_jurnal_ap.php?jurnal_id="+id,"mywindow","menubar=1,scrollbars=1,resizable=1,width=1000,height=1000");
	}
	function add_click(){
		form.action ='?page=Proses-Jurnal-Ref&Act=ADD';
		form.method = 'post';
		form.submit();		
		return true;
	}
	function posting_click(id,code){
		form.action ='?page=Proses-Jurnal-Ref&Act=POSTING&jurnal_id='+id+'&jurnal_no='+code;
		form.method = 'post';
		form.submit();		
		return true;
	}
	function detail_click(id){
		form.action ='?page=Proses-Jurnal-Ref&Act=DETAIL&jurnal_id='+id;
		form.method = 'post';
		form.submit();		
		return true;
	}
	function delete_click(id,code){
		var a = confirm("Apakah anda yakin akan menghapus data?");
		if (a == true){
			form.action ='?page=Proses-Jurnal-Ref&Act=DELETE&jurnal_id='+id+'&jurnal_no='+code;
			form.method = 'post';
			form.submit();		
			return true;
		}	
	}
	function deletejll_click(id,tipe){
		var a = confirm("Apakah anda yakin akan menghapus data?");
		if (a == true){
			form.action ='?page=Proses-Jurnal-Ref&Act=DELETEJLL&hdr_id='+id+'&tipe_del='+tipe;
			form.method = 'post';
			form.submit();		
			return true;
		}	
	}
	function search_click(){
		form.action ='?page=Data-Jurnal-Ref&cari=CARI';
		form.method = 'post';
		form.submit();		
		return true;
	}
	function invno_search(){
		form.action ='?page=Data-Jurnal-Ref&scari=SCARI&cek=3';
		form.method = 'post';
		form.submit();		
		return true;
	}
	function excel_click(){
		form.action ='./transaksi/akuntansi/export_jurnal_referensi.php';
		form.method = 'post';
		form.submit();			
		return true;
	}
</script>
<?php
$fromdate= isset($_REQUEST['fromdate']) ? $_REQUEST['fromdate'] : $date;
$todate  = isset($_REQUEST['todate']) ? $_REQUEST['todate'] : $date; 
$sinvno	 = isset($_REQUEST['sinvno']) ? $_REQUEST['sinvno'] : ''; 
$scari 	 = isset($_REQUEST['scari']) ? $_REQUEST['scari'] : '';
$cek 	 = isset($_REQUEST['cek']) ? $_REQUEST['cek'] : 1;
if($cek==1){
	$check1 ="checked=checked";
	$check2 ="";
	$check3 ="";
}elseif($cek==2){
	$check1 ="";
	$check2 ="checked=checked";
	$check3 ="";
}elseif($cek==3){
	$check1 ="";
	$check2 ="";
	$check3 ="checked=checked";
}else{
 $check1 ="checked=checked";
 $check2 ="";
 $check3 =""; 
} 
 ?>
<form action="#" method="post" name="form" enctype="multipart/form-data">
<table width="100%" border="0" cellspacing="1" cellpadding="1">
  <tr>
	<td colspan="9" align="center"><h1><b>DATA JURNAL UMUM BC</b></h1></td>
  </tr>
  <tr>
	<td colspan="9"><img src="images/btn_add.png" height="30" width="30" title="Tambah Manual" border="0" style="cursor:pointer" onclick="add_click();" /></td>
  </tr>
  <tr>
	  <td colspan="9">Periode :
	      <input type="text" id="fromdate" name="fromdate" size="9" value="<?=$fromdate;?>" style="border-collapse:inherit"  readonly="true">&nbsp;s/d&nbsp;
	      <input type="text" id="todate" name="todate" size="9" value="<?=$todate;?>" style="border-collapse:inheri" readonly="true">
	      <input type="button" name="cari" value="CARI" style="cursor:pointer" onClick="search_click();">
		  <input type="button" name="export" value="EXCEL" style="cursor:pointer" onClick="excel_click();" />
		</td>
	</tr>
</table>
<input type="radio" name="tab" id="tab1" <?=$check1;?>><label id="label1" for="tab1">Jurnal BC</label>
<input type="radio" name="tab" id="tab2" <?=$check2;?>><label id="label2" for="tab2">Jurnal Lain-Lain</label>
<input type="radio" name="tab" id="tab3" <?=$check3;?>><label id="label3" for="tab3">Cek No.Invocie</label>
<div class="content1">
	<table id="myTables" class="display" cellpadding="0" cellspacing="0">
		<thead>  
	  <tr>
		<th>No</th>
		<th>No Jurnal</th>
		<th>Tanggal</th>
		<th>No Invoice</th>
		<th>Tipe</th>
		<th>Supp/Cust</th>
		<th>NPWP</th>
		<th>Dok. BC</th>
		<th>Status</th>
		<th>Action</th>
	  </tr>
	  </thead>
		<tbody>
	  <?php
		$no=1;
		$qd = mysql_query("SELECT * FROM jurnal WHERE jurnal_status<>100 AND jurnal_date BETWEEN '$fromdate' AND '$todate' AND jurnal_menu IN('BC','BCINC','BCOUT','BCALL')  ORDER BY id DESC");
		while($dd=mysql_fetch_object($qd)){		
		   if($dd->jurnal_status==10){$status = "Baru";}
		   else{$status = "Posting";}
		   if(empty($dd->jurnal_suppname)){ $nama=$dd->jurnal_custname;}else{$nama=$dd->jurnal_suppname;}
		?> 
		  <tr onmouseover="setTrColor(this, '#FF9900');">
			<td align="center"><?=$no;?>.</td>
			<td align="center"><?=$dd->jurnal_no;?></td>
			<td align="center"><?=$dd->jurnal_date;?></td>
			<td><?=$dd->jurnal_invno;?></td>
			<td align="center"><?=$dd->jurnal_type;?></td>
			<td><?=$nama;?></td>		
			<td align="center"><?=$dd->jurnal_idpemasok;?></td>
			<td align="center"><?=$dd->jurnal_doctype;?> - <?=$dd->jurnal_docno;?></td>
			<td align="center"><?=$status;?></td>
			<td align="center">
				<?php if ($dd->jurnal_status==10){ ?>
					<img src="images/btn_posting.png" width="20" height="20" border="0" title="Posting" style="cursor:pointer" 
					onclick="posting_click('<?=$dd->id;?>','<?=$dd->jurnal_no;?>');" />
					<img src="images/btn_edit.png" width="20" height="20" border="0" title="Edit" style="cursor:pointer" onclick="detail_click('<?=$dd->id;?>');" />
					<img src="images/btn_delete.png" width="20" height="20"  border="0"  title="Hapus" style="cursor:pointer" onclick="delete_click('<?=$dd->id;?>', '<?=$dd->jurnal_no;?>');" />
				<?php }else { 
				if($dd->jurnal_type=="AP" || $dd->jurnal_type=="HT" || $dd->jurnal_type=="CS" || $dd->jurnal_type=="BK"){
				?>
					<img src="images/btn_print.png" height="20" width="20" title="Print" border="0" style="cursor:pointer" onclick="print_click_ap('<?=$dd->id;?>');" />
				<?php }elseif($dd->jurnal_type=="AR" || $dd->jurnal_type=="PT"){ ?>
					<img src="images/btn_print.png" height="20" width="20" title="Print" border="0" style="cursor:pointer" onclick="print_click_ar('<?=$dd->id;?>');" />
				<?php }else{ ?>
					<img src="images/btn_print.png" height="20" width="20" title="Print" border="0" style="cursor:pointer" onclick="print_click_ot('<?=$dd->id;?>');" />	
				<?php } } ?>
			</td>
		  </tr>
	  <?php $no++; }  ?>
		</tbody>
	</table>
</div>
<div class="content2">
	<table id="myTables1" class="display" cellpadding="0" cellspacing="0">
		<thead>  
	  <tr>
		<th>No</th>
		<th>Jenis</th>
		<th>Nomor</th>
		<th>Tanggal</th>
		<th>Supp/Cust</th>
		<th>NPWP</th>
		<th>Action</th>
	  </tr>
	  </thead>
		<tbody>
	  <?php
		$no2=1;
		$qd2 = mysql_query("SELECT a.* FROM
		(SELECT id, inch_doctype doctype, inch_docno docno, inch_docdate docdate, nm_pemasok suppcust, id_pemasok npwp, 'INC' tipe FROM incoming WHERE inch_paytype='OT' AND inch_status=20
		UNION ALL
		SELECT id, outh_doctype doctype, outh_docno docno, outh_docdate docdate, nm_penerima suppcust, id_penerima npwp, 'OUT' tipe FROM outgoing where outh_paytype='OT' AND outh_status=20) a
		WHERE a.docdate BETWEEN '$fromdate' AND '$todate' ORDER BY a.docdate DESC");
		while($dd2=mysql_fetch_object($qd2)){		
		?> 
		  <tr onmouseover="setTrColor(this, '#FF9900');">
			<td align="center"><?=$no2;?>.</td>
			<td align="center"><?=$dd2->doctype;?></td>
			<td align="center"><?=$dd2->docno;?></td>
			<td align="center"><?=$dd2->docdate;?></td>
			<td align="left"><?=$dd2->suppcust;?></td>		
			<td align="center"><?=$dd2->npwp;?></td>
			<td align="center">
					<img src="images/btn_delete.png" width="20" height="20"  border="0"  title="Hapus" style="cursor:pointer" onclick="deletejll_click('<?=$dd2->id;?>','<?=$dd2->tipe;?>');" />
			</td>
		  </tr>
	  <?php $no2++; }  ?>
		</tbody>
	</table>
</div>	
<div class="content3">
	Masukan No Invoice : <input type="text" name="sinvno" size="20" value="<?=$sinvno;?>" style="border-collapse:inheri">
	      <input type="button" name="cari" value="CARI" style="cursor:pointer" onClick="invno_search();">
	<table id="myTables2" class="display" cellpadding="0" cellspacing="0">
	  <thead>  
	  <tr>
		<th>No</th>
		<th>No Jurnal</th>
		<th>Tanggal</th>
		<th>No Dokumen</th>
		<th>Jenis Dokumen</th>
		<th>No. Invoice</th>
	  </tr>
	  </thead>
		<tbody>
	  <?php
		$no3=1;
		if($scari=="SCARI"){
		$qd3 = mysql_query("SELECT * FROM jurnal WHERE jurnal_status<>100 AND jurnal_invno LIKE '%$sinvno%'");
		while($dd3=mysql_fetch_object($qd3)){		
		?> 
		  <tr onmouseover="setTrColor(this, '#FF9900');">
			<td align="center"><?=$no3;?>.</td>
			<td align="center"><?=$dd3->jurnal_no;?></td>
			<td align="center"><?=$dd3->jurnal_date;?></td>
			<td align="center"><?=$dd3->jurnal_docno;?></td>
			<td align="center"><?=$dd3->jurnal_doctype;?></td>		
			<td align="center"><?=$dd3->jurnal_invno;?></td>
		  </tr>
		<?php $no3++; } } ?>
		</tbody>
	</table>
</div>
</form>
