<?php
include "../../include/config.php";
include "../../function/inc_function.php";
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="data_wo_nonbom'.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="7" align="left"><strong>DATA WORKORDER NON BOM</strong></td>
    </tr>
	<tr>
  		<td colspan="7" align="left"><strong>PERIODE : <?=$fromdate;?> s/d <?=$todate;?></strong></td>
    </tr>
</table>	
<table width="100%" border="1">	
  <tr>
    <th align="center" bgcolor="#D1D1D1" rowspan="2">NO</th>
	<th align="center" bgcolor="#D1D1D1" rowspan="2">NOMOR TRANSAKSI</th>
    <th align="center" bgcolor="#D1D1D1" rowspan="2">TANGGAL</th>
	<th align="center" bgcolor="#D1D1D1" colspan="4">DETAIL BAHAN BAKU/PENOLONG/WIP</th>
  </tr>
  <tr>
	<th align="center" bgcolor="#D1D1D1">KODE</th>
	<th align="center" bgcolor="#D1D1D1">NAMA</th>
	<th align="center" bgcolor="#D1D1D1">JUMLAH</th>
	<th align="center" bgcolor="#D1D1D1">SATUAN</th>
  </tr>
	<?php		
		$qd = mysql_query("SELECT a.wonb_no, a.wonb_date,
		d.prod_code dcode, d.prod_name dname, d.prod_sat dsat, c.wonbd_qty 
		FROM workorder_nonbom a
		INNER JOIN workorder_nonbom_detail c ON c.wonbd_hid=a.id INNER JOIN product d ON d.id=c.wonbd_prodid
		WHERE a.wonb_date BETWEEN '$fromdate' AND '$todate' AND a.wonb_status<>100 ORDER BY a.id DESC");
		$no = 1;
		while($dd=mysql_fetch_object($qd)){	
		?> 
		 <tr>
			<td align="center"><?=$no;?></td>
			<td align="center"><?=$dd->wonb_no;?></td>
			<td align="center"><?=$dd->wonb_date;?></td>
			<td align="left"><?=$dd->dcode;?></td>
			<td align="left"><?=$dd->dname;?></td>
			<td align="right"><?=number_format($dd->wonbd_qty,2,'.','');?></td>
			<td align="center"><?=$dd->dsat;?></td>
		  </tr>
      <?php $no++; }  ?>	
</table>