<?php
include "../../include/config.php";
include "../../function/inc_function.php";
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="master_price_'.get_datetime().'.xls"');
header('Cache-Control: max-age=0');

?>
<table border="1" cellpadding="0" cellspacing="0">
	<thead>
	<tr>
		<td colspan="11" align="center">MASTER PRICE</td>
	</tr>
	<tr>
		<th>No.</th>
		<th>Kode Barang</th>
		<th>Nama Barang</th>
		<th>Satuan</th>
		<th>Price List</th>
		<th>Currencry</th>
		<th>Nett</th>
		<th>Gross</th>
		<th>Box</th>
		<th>Pallet</th>
		<th>Kategori</th>
	</tr>
	</thead>
	<tbody>
	<?php		
	  	$no=1;
		$qd = mysql_query("SELECT a.id,a.prod_code, a.prod_name, a.prod_type, a.prod_spec, a.prod_sat, a.prod_desc, b.prod_cat
		FROM product a INNER JOIN product_category b ON b.id=a.prod_cat WHERE a.prod_cat =5 ORDER BY a.id DESC");
		while($dd=mysql_fetch_object($qd)){	
			$mtp = mysql_fetch_array(mysql_query("SELECT * FROM master_price WHERE mtp_prodid='$dd->id' AND mtp_status=10"));
			if(empty($mtp['id'])){
				$mtp_price = 0;
			}else{
				$mtp_price = $mtp['mtp_price'];
			}
		?> 
		  <tr onmouseover="setTrColor(this, '#FF9900');">
			<td align="center"><?=$no;?>.</td>
			<td align="left"><?=$dd->prod_code;?></td>
			<td align="left"><?=$dd->prod_name;?></td>
			<td align="center"><?=$dd->prod_sat;?></td>
			<td align="center"><?=$mtp_price;?></td>
			<td align="center"><?=$mtp['mtp_currency'];?></td>
			<td align="center"><?=$mtp['mtp_nett'];?></td>
			<td align="center"><?=$mtp['mtp_gross'];?></td>
			<td align="center"><?=$mtp['mtp_box'];?></td>
			<td align="center"><?=$mtp['mtp_pallet'];?></td>			
			<td align="left"><?=$dd->prod_cat;?></td>
		  </tr>
      <?php $no++; }  ?>	
	  </tbody>
</table>