<?php
include "../../include/config.php";
include "../../function/inc_function.php";
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="data_return_bhnbaku_'.date('Y-m-d H:i:s').'.xls"');
header('Cache-Control: max-age=0');

$fromdate = $_REQUEST['fromdate'];
$todate = $_REQUEST['todate'];
?>
<table width="100%" border="0">
    <tr>
  		<td colspan="12" align="left"><strong>DATA PENGEMBALIAN BAHAN BAKU / BAHAN PENOLONG</strong></td>
    </tr>
	<tr>
  		<td colspan="12" align="left"><strong>PERIODE : <?=$fromdate;?> s/d <?=$todate;?></strong></td>
    </tr>
</table>	
<table width="100%" border="1">	
  <tr>
    <th align="center" bgcolor="#D1D1D1">NO</th>
	<th align="center" bgcolor="#D1D1D1">NOMOR TRANSAKSI</th>
    <th align="center" bgcolor="#D1D1D1">TANGGAL</th>
	<th align="center" bgcolor="#D1D1D1">KODE BARANG</th>
	<th align="center" bgcolor="#D1D1D1">NAMA BARANG</th>
	<th align="center" bgcolor="#D1D1D1">JUMLAH</th>
	<th align="center" bgcolor="#D1D1D1">SATUAN</th>
	<th align="center" bgcolor="#D1D1D1">PIC</th>
	<th align="center" bgcolor="#D1D1D1">STATUS</th>
	<th align="center" bgcolor="#D1D1D1">JENIS</th>
	<th align="center" bgcolor="#D1D1D1">NOMOR</th>
	<th align="center" bgcolor="#D1D1D1">TANGGAL</th>
  </tr>
	<?php		
		$qd = mysql_query("SELECT a.trf_status, a.trf_spbno, a.trf_spbdate,b.trfd_qty,c.prod_code,c.prod_name,c.prod_sat,a.trf_pic, b.trfd_doctype, b.trfd_docno, trfd_docdate
 		  FROM transfer a
		  INNER JOIN transfer_detailexbc b ON b.trfd_hid=a.id INNER JOIN product c ON c.id=b.trfd_prodid
		  WHERE a.trf_spbdate BETWEEN '$fromdate' AND '$todate' AND a.trf_status <> 100 AND a.trf_category =3
		  ORDER BY a.trf_spbdate ASC");
		$no = 1;
		while($dd=mysql_fetch_object($qd)){	
		if($dd->trf_status==10){ $status="Baru"; }else{ $status="Posting";}	
		?> 
		 <tr>
			<td align="center"><?=$no;?></td>
			<td align="center"><?=$dd->trf_spbno;?></td>
			<td align="center"><?=$dd->trf_spbdate;?></td>
			<td align="left"><?=$dd->prod_code;?></td>
			<td align="left"><?=$dd->prod_name;?></td>
			<td align="right"><?=number_format($dd->trfd_qty,2,'.','');?></td>
			<td align="center"><?=$dd->prod_sat;?></td>
			<td align="center"><?=$dd->trf_pic;?></td>
			<td align="center"><?=$status?></td>
			<td align="center"><?=$dd->trfd_doctype;?></td>
			<td align="center">'<?=$dd->trfd_docno;?></td>
			<td align="center"><?=$dd->trfd_docdate;?></td>
		  </tr>
      <?php $no++; }  ?>	
</table>