<?php 
ob_start();
include "../include/config.php"; 
include "../function/inc_function.php"; 

$start_date = $_REQUEST['fromdate'];
$end_date   = $_REQUEST['todate'];
$month 		= substr($start_date,5,2);
$year		= substr($start_date,0,4);
$cek        = $month-1;
if($cek==0){
	$bln = 12;
	$thn = $year-1;
}else{
	$bln = $cek;
	$thn = $year;
}
$sqlShow 	= mysql_query("SELECT prof_name FROM profil");
$dataShow 	= mysql_fetch_array($sqlShow);
?>
<html>
<head>
<link rel='stylesheet' type='text/css' href="../include/css/printdoc_styles.css" />
</head>
<body>
<table class="tables_inout1">
    <tr>
  		<td colspan="13">LAPORAN PENGELUARAN BARANG PER DOKUMEN PABEAN</td>
    </tr>
    <tr>
  		<td colspan="13">KAWASAN BERIKAT <?=strtoupper($dataShow['prof_name']);?></td>
    </tr>
    <tr>
  		<td colspan="13">PERIODE <?=DateToIndo($start_date);?> S/D <?=DateToIndo($end_date);?> </td>
    </tr>
    <tr>
  		<td colspan="13">&nbsp;</td>
    </tr>
</table>	
<table style="width:1400px;" class="tables_inout">	
  <tr>
    <th align="center"bgcolor="#D1D1D1" rowspan="2" style="width:30px;">No</th>
    <th align="center"bgcolor="#D1D1D1" colspan="3" style="width:180px;">Dokumen Pabean</th>
    <th align="center"bgcolor="#D1D1D1" colspan="2" style="width:120px;">Surat Jalan</th>
    <th align="center"bgcolor="#D1D1D1" rowspan="2" style="width:150px;">Penerima</th>
    <th align="center"bgcolor="#D1D1D1" rowspan="2" style="width:100px;">Kode Barang </th>
    <th align="center"bgcolor="#D1D1D1" rowspan="2" style="width:160px;">Nama Barang </th>
    <th align="center"bgcolor="#D1D1D1" rowspan="2" style="width:50px;">Satuan </th>
    <th align="center"bgcolor="#D1D1D1" rowspan="2" style="width:60px;">Jumlah </th>
    <th align="center"bgcolor="#D1D1D1" rowspan="2" style="width:50px;">Valuta</th>
    <th align="center"bgcolor="#D1D1D1" rowspan="2" style="width:90px;">Nilai Barang </th>
  </tr>
  <tr>
    <th align="center"bgcolor="#D1D1D1" style="width:60px;">Jenis</th>
    <th align="center"bgcolor="#D1D1D1" style="width:60px;">Nomor</th>
    <th align="center"bgcolor="#D1D1D1" style="width:60px;">Tanggal</th>
    <th align="center"bgcolor="#D1D1D1" style="width:60px;">Nomor</th>
    <th align="center"bgcolor="#D1D1D1" style="width:60px;">Tanggal</th>
  </tr>
	<?php
	    $no=0;		
		$qd = mysql_query("CALL spvw_outgoing('$start_date','$end_date');");
		while($dd=mysql_fetch_object($qd))
		{		
		$no++;
		?> 
		 <tr>
			<td align="center"><?=$no;?></td>
			<td align="center"><?=$dd->doc_type;?></td>
			<td align="center"><?php echo "'"."$dd->outh_docno";?></td>
			<td align="center"><?=DateToIndo($dd->outh_docdate);?></td>
			<td align="center"><?=$dd->outh_sjno;?></td>
			<td align="center"><?=DateToIndo($dd->outh_sjdate);?></td>
			<td align="left"><?=$dd->cust_name;?></td>
			<td align="left"><?=$dd->prod_code;?></td>
			<td align="left"><?=$dd->prod_name;?></td>
			<td align="left"><?=$dd->prod_sat;?></td>
			<td align="center"><?=number_format($dd->outd_qty,0,'.',',');?></td>
			<td align="center"><?=$dd->outd_currency;?></td>
			<td align="right"><?=number_format($dd->outd_price,2,'.',',');?></td>
		  </tr>
      <?php }  ?>	
</table>
<?php  
	 #PDF
	 $filename="laporan_pengeluaran.pdf";   
	 $content = ob_get_clean();  
	 //$content = '<page style="font-family: Arial;">'.nl2br($content).'</page>';  
	 require_once('../function/html2pdf/html2pdf.class.php');  
	 try  
	 {  
	  //$html2pdf = new HTML2PDF('P',array(240,280),'en', false, 'ISO-8859-15',array(0, 0, 0, 0));  
	  $html2pdf = new HTML2PDF('L','A4','en', false, 'ISO-8859-15',array(0, 0, 0, 0));
	  $html2pdf->setDefaultFont('Arial');  
	  $html2pdf->writeHTML($content, isset($_GET['vuehtml']));  
	  $html2pdf->Output($filename);  
	 }  
	 catch(HTML2PDF_exception $e) { echo $e; }
?> 