<!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_pengeluaran.php?action=out_bln",
             { name: "Data" },
             function(data) {
				$('#list').load("laporan/grid_bln_pengeluaran.php?action=out_bln&fromdate="+$("#fromdate").val()+"&todate="+$("#todate").val()+"&doctype="+doctype); 
             }
          );  
      });
   });
   function export_data(){
		var doc_type = $("#doc_type").val();
	    var doctype = doc_type.replace(' ', '%20');
		if(doctype=="BC%202.5"){
			form.action ='./laporan/excel_1_bc25_pengeluaran.php';
			form.method = 'post';
			form.submit();			
			return true;
		}else if(doctype=="BC%202.6.1"){
			form.action ='./laporan/excel_1_bc261_pengeluaran.php';
			form.method = 'post';
			form.submit();			
			return true;
		}else if(doctype=="BC%202.7"){
			form.action ='./laporan/excel_1_bc27_pengeluaran.php';
			form.method = 'post';
			form.submit();			
			return true;
		}else if(doctype=="BC%203.0"){
			form.action ='./laporan/excel_1_bc30_pengeluaran.php';
			form.method = 'post';
			form.submit();			
			return true;			
		}else if(doctype=="BC%203.3"){
			form.action ='./laporan/excel_1_bc33_pengeluaran.php';
			form.method = 'post';
			form.submit();			
			return true;			
		}else if(doctype=="BC%204.1"){
			form.action ='./laporan/excel_1_bc41_pengeluaran.php';
			form.method = 'post';
			form.submit();			
			return true;
		}else if(doctype=="SCRAP"){
			form.action ='./laporan/excel_1_scrap_pengeluaran.php';
			form.method = 'post';
			form.submit();			
			return true;
		}else if(doctype=="BLANK"){
			form.action ='./laporan/excel_lap_pengeluaranall.php';
			form.method = 'post';
			form.submit();			
			return true;
		}
	}
	function export_data_exbc(){
		var doc_type = $("#doc_type").val();
	    var doctype = doc_type.replace(' ', '%20');
		if(doctype=="BLANK"){
			alert("Jenis dokumen pabean harus dipilih terlebih dahulu");
			form.doc_type.focus();
			return false;		
		}else if(doctype=="BC%203.0"){
			form.action ='./laporan/excel_exbc_bc27_pengeluaran.php';
			form.method = 'post';
			form.submit();			
			return true;
		}else{
			form.action ='./laporan/excel_exbc_bc27_pengeluaran.php';
			form.method = 'post';
			form.submit();			
			return true;
		}
	}
	function export_data_jmldoc(){		
		form.action ='./laporan/excel_jmldok_pengeluaran.php';
		form.method = 'post';
		form.submit();			
		return true;
	}
	function export_data_po(){		
		form.action ='./laporan/excel_lap_pengeluaranpo.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-Pengeluaran&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 PENGELUARAN BARANG PER DOKUMEN PABEAN</h1>
<form name="form" enctype="multipart/form-data">
<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">Periode</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=2 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_exbc" value="EXCEL-EXBC" onClick="export_data_exbc();" style="cursor:pointer" />
		  <input type="button" name="export_cdoc" value="EXCEL-JUMLAH-DOK" onClick="export_data_jmldoc();" style="cursor:pointer" />
		  <!--<input type="button" name="export_cpo" value="EXCEL-PO" onClick="export_data_po();" style="cursor:pointer" />-->
	  </td>
	</tr>
</table>
<table id="myTables" class="display" cellpadding="0" cellspacing="0">
	<thead>
  <tr>
    <th rowspan="2">No</th>
	<th colspan="3">Dokumen Pabean</th>			
	<th colspan="2">Bukti Pengeluaran Barang</th>
	<th rowspan="2">Penerima</th>
	<th rowspan="2">Kode</th>
	<th rowspan="2">Nama Barang</th>
	<th rowspan="2">Satuan</th>
	<!--<th rowspan="2">Kategori</th>-->
	<th rowspan="2">Jumlah</th>
	<th rowspan="2">Valuta</th>
	<th rowspan="2">Nilai</th>	
	<?php if($doc_type=="BC 3.0" || $doc_type=="BC 3.3"){ ?>
	<th rowspan="2">FOB</th>
	<th rowspan="2">Maklon</th>
	<th rowspan="2">Tipe</th>
	<?php } ?>
  </tr>
  <tr>
  	<th>Jenis</th>
	<th>Nomor</th>
	<th>Tanggal</th>
	<th>Nomor</th>
	<th>Tanggal</th>
  </tr>
  </thead>
	<tbody>
  <?php $no=1;
	if($doc_type=="BLANK"){
		$qd = mysql_query("CALL spvw_bln_outgoingall ('$start_date','$end_date');");
	}else{
		$qd = mysql_query("CALL spvw_bln_outgoing ('$start_date','$end_date','$doc_type');");
	}	
	while($data=mysql_fetch_array($qd)){	
	if($data['outd_currency']=="IDR"){
		$outd_price = $data['outd_price'];
	}else{
		$outd_price = $data['outd_price_usd'];
	}		
	?> 
	 <tr onmouseover="setTrColor(this, '#FF9900');">
		<td align="center"><?=$no;?>.</td>
		<td align="center"><?=$data['doc_type'];?></td>			
		<td align="center"><?=$data['outh_docno'];?></td>
		<td align="center"><?=$data['outh_docdate'];?></td>
		<td align="center"><?=$data['outh_sjno'];?></td>
		<td align="center"><?=$data['outh_sjdate'];?></td>
		<td><?=$data['cust_name'];?></td>
		<td><?=$data['prod_code'];?></td>
		<td><?=$data['prod_name'];?></td>
		<td align="center"><?=$data['prod_sat'];?></td>
		<!--<td align="left"><?=$data['prod_cat'];?></td>-->
		<td align="right"><?=number_format($data['outd_qty'],2,'.',',');?></td>
		<td align="center"><?=$data['outd_currency'];?></td>
		<td align="right"><?=number_format($outd_price,2,'.',',');?></td>
		<?php if($doc_type=="BC 3.0" || $doc_type=="BC 3.3"){ ?>
		<td align="right"><?=number_format($data['harga_fob'],2,'.',',');?></td>
		<td align="right"><?=number_format($data['harga_maklon'],2,'.',',');?></td>
		<td align="center"><?=$data['tipe_dokumen'];?></td>
		<?php } ?>
	  </tr>	  
  <?php $no++;}  ?> 
  </tbody> 
</table>
</form>
</body>
</html>