<!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">
<script type="text/javascript" src="function/dataTables/media/js/jquery.dataTables.js"></script>
<script type="text/javascript" language="javascript">
	$(document).ready( function () {
		var oTable = $('#myTables').dataTable( {
			 "sDom": 'R<"H"lfr>t<"F"ip>',
			 "bJQueryUI": true,
			 "sPaginationType": "full_numbers",
			 "iDisplayLength" :10
		});
	});
	$(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() {
      $("#search").click(function(event){	 
	  	var doc_type = $("#doc_type").val();
	    var doctype = doc_type.replace(' ', '%20'); 
	     $.post("laporan/grid_bln_pemasukan.php?action=in_bln",
             { name: "Data" },
             function(data) {
				$('#list').load("laporan/grid_bln_pemasukan.php?action=in_bln&fromdate="+$("#fromdate").val()+"&todate="+$("#todate").val()+"&doctype="+doctype); 
             }
          );  
      });
   });
   function export_data(){
		var doc_type = $("#doc_type").val();
	    var jdp = doc_type.replace(' ', '%20');
		if(jdp=="BC%202.3"){
			form.action ='./laporan/excel_1_bc23_pemasukan.php';
			form.method = 'post';
			form.submit();			
			return true;
		}else if(jdp=="BC%202.4"){
			form.action ='./laporan/excel_1_bc24_pemasukan.php';
			form.method = 'post';
			form.submit();			
			return true;
		}else if(jdp=="BC%202.7"){
			form.action ='./laporan/excel_1_bc27_pemasukan.php';
			form.method = 'post';
			form.submit();			
			return true;
		}else if(jdp=="BC%202.6.2"){
			form.action ='./laporan/excel_1_bc262_pemasukan.php';
			form.method = 'post';
			form.submit();			
			return true;
		}else if(jdp=="BC%204.0"){
			form.action ='./laporan/excel_1_bc40_pemasukan.php';
			form.method = 'post';
			form.submit();			
			return true;
		}else if(jdp=="LOKAL"){
			form.action ='./laporan/excel_1_lokal_pemasukan.php';
			form.method = 'post';
			form.submit();			
			return true;
		}else if(jdp=="BC%202.0"){
			form.action ='./laporan/excel_1_bc20_pemasukan.php';
			form.method = 'post';
			form.submit();			
			return true;
		}else if(jdp=="BLANK"){
			form.action ='./laporan/excel_lap_pemasukanall.php';
			form.method = 'post';
			form.submit();			
			return true;
		}
	}
	function export_data_jmldoc(){		
		form.action ='./laporan/excel_jmldok_pemasukan.php';
		form.method = 'post';
		form.submit();			
		return true;
	}
	/*----------------*/
   function showDiv(divID,show) {
	  var w=document.getElementById(divID);
	  w.style.visibility=(show==1)?'visible':'hidden';
	}
	function search_click(){
		form.action ='?page=Data-Bln-Pemasukan&cari=CARI';
		form.method = 'post';
		form.submit();			
		return true;
	}
</script>
</head>
<body>
<?php
if(isset($_REQUEST['cari'])=="CARI"){
	 $start_date	= $_REQUEST['fromdate'];
	 $end_date     	= $_REQUEST['todate']; 	
	 $doc_type		= $_REQUEST['doc_type'];	 
}else{
	 $start_date	= $start_date;
	 $end_date      = $end_date;	
	 $doc_type	    = "BLANK";
}
?>
<h1>LAPORAN PEMASUKAN BULANAN</h1>
<form name="form" enctype="multipart/form-data" method="post">
<table width="100%" border="0"  class="table-list">
	<tr>
	  <td colspan="3" bgcolor="#CCCCCC"><div align="left">PERIODE BULAN</div></td>
	</tr>
	<tr>
	  <td width="90">Bulan</td>
	  <td width="5">:</td>
	  <td width="815">
	      <input type="text" id="fromdate" name="fromdate" size="9" value="<?=$start_date;?>" style="border-collapse:inherit"  readonly="true">&nbsp;s/d&nbsp;
	      <input type="text" id="todate" name="todate" size="9" value="<?=$end_date;?>" style="border-collapse:inheri" readonly="true"> 
		  <select name="doc_type" id="doc_type">
			  <option value="BLANK">ALL</option> 
				<?php
				  $dataSql = mysql_query("SELECT id,doc_type FROM document_type WHERE doc_status=1 ORDER BY  id ASC");
				  while ($dataRow = mysql_fetch_array($dataSql)) {
					if ($dataRow['doc_type']== $doc_type) {
						$cek = " selected";
					} else { $cek=""; }
					echo "<option value='$dataRow[doc_type]' $cek>$dataRow[doc_type]</option>";
				  }
				  $sqlData ="";
				?>
		  </select>
	      <input type="button" name="cari" value="CARI" style="cursor:pointer" onClick="search_click();">
		  <input type="button" name="export" value="EXCEL-LAP" onClick="export_data();" style="cursor:pointer" />
		  <input type="button" name="export_cdoc" value="EXCEL-JUMLAH-DOK" onClick="export_data_jmldoc();" style="cursor:pointer" /></td>
	</tr>
</table>
<table id="myTables" class="display" cellpadding="0" cellspacing="0">
	<thead>
  <tr>
    <th colspan="3">Dok Pabean</th>			
	<th colspan="2">BPB</th>
	<th rowspan="2">Pemasok</th>
	<th rowspan="2">Kode</th>
	<th rowspan="2">Nama Barang</th>
	<th rowspan="2">Satuan</th>
	<th rowspan="2">Jumlah</th>
	<th rowspan="2">Valuta</th>
	<th rowspan="2">Nilai</th>	
  </tr>
  <tr>
  	<th>Jenis</th>
	<th>Nomor</th>
	<th>Tanggal</th>
	<th>Nomor</th>
	<th>Tanggal</th>
  </tr>
  </thead>
	<tbody>
  <?php
	if($doc_type=="BLANK"){
		$qd = mysql_query("CALL spvw_bln_incomingall ('$start_date','$end_date');");
	}else{
		$qd = mysql_query("CALL spvw_bln_incoming ('$start_date','$end_date','$doc_type');");
	}
	while($data=mysql_fetch_array($qd)){	
	if($data['incd_currency']=="IDR"){
		$incd_price = $data['incd_price'];
	}else{
		$incd_price = $data['incd_price_usd'];
	}		
	?> 
	 <tr onmouseover="setTrColor(this, '#FF9900');">
		<td align="center"><?=$data['doc_type'];?></td>			
		<td align="center"><?=$data['inch_docno'];?></td>
		<td align="center"><?=$data['inch_docdate'];?></td>
		<td align="center"><?=$data['inch_bpbno'];?></td>
		<td align="center"><?=$data['inch_bpbdate'];?></td>
		<td><?=$data['sup_name'];?></td>
		<td><?=$data['prod_code'];?></td>
		<td><?=$data['prod_name'];?></td>
		<td align="center"><?=$data['prod_sat'];?></td>
		<td align="right"><?=number_format($data['incd_qty'],2,'.',',');?></td>
		<td align="center"><?=$data['incd_currency'];?></td>
		<td align="right"><?=number_format($incd_price,2,'.',',');?></td>
	  </tr>	  
  <?php }  ?> 
  </tbody> 
</table>
</form>
</body>
</html>