<?php
session_start();

if($_SESSION['dbName']==""){
header("location:../index.php");
}

include("config.inc.php");

$connection = @mysql_connect($config['dbServer'],$config['dbUser'],$config['dbPass'],true,65536) or die("Could not connect to DB");
mysql_select_db($_SESSION['dbName'],$connection) or die("Could not find DB");

$query_setup  = "select company_name, company_memo, DecimalBase, DecimalBase1, DecimalBase2, Setup_VatPercentage, base1, base2, setup_invoiceremarks from setup";
$result_setup = mysql_query($query_setup, $connection); 
$row_setup    = mysql_fetch_array($result_setup);
extract($row_setup);


$query = " Select items.item_code,items.item_description,description1,description2,description3". 
         " From item_location ". 
         " left join items items on  item_location.item_code = items.item_code". 
         " where description1 != '' or description2 != '' or description3  != '' ";
			 
			 
	$result=mysql_query($query,$connection) or die(mysql_error());
	
	
 
	$title='Items Locations';
  
print <<<HERE
<html>
<head>
<title>$title</title>
</head>
<body>
HERE;

echo "<table width=800>
<tr>
<td width=50%><img src='LogoFile.php' width=180 /></td>
<td width=50% style='text-align: center; font-family: Arial; font-size: 40px;  color: #a6a6a6;'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$title</td>
</tr>
</table>
<table width=800>
<tr style='height: 20px'>
<td></td>
</tr>
</table>
<table width=800>
<tr>
<td width=500 style='font-family: Arial; font-size: 14px'><i><b><u>$company_name</u></b></i>
<br><b>
<pre>$company_memo</pre>
</td>
<td style='width: 300px; vertical-align: top;'>
<table width=100%>
<tr>
<td style='text-align: right; font-weight: bold; font-size: 12px; font-family: Arial; width:120px'>DATE:</td>
<td style='width: 20px'></td>
<td style='width: 160px; font-family: Arial; font-size: 13px'>" . date("d/m/Y") . "</td>
</tr>
<tr>
<td style='text-align: right; font-weight: bold; font-size: 12px; font-family: Arial; width:120px'>&nbsp;</td>
<td style='width: 20px'></td>
<td style='width: 160px; font-family: Arial; font-size: 13px'>&nbsp;</td>
</tr>
</table>
</td>
</tr>
<tr style='height: 15px'>
<td></td>
</tr>
</table>
<table width=800>

</table>
<table width=800>";

echo "<tr style='height: 15px'>
<td colspan=2></td>
</tr>";
echo "<tr>
<td colspan=2 style='font-size: 13px; font-family: Arial; font-weight: bold'>&nbsp;</td>
</tr>";
echo "<tr style='height: 15px'>
<td colspan=2></td>
</tr>";
echo"</table>";
echo "<table width=800 style='border-collapse:collapse'>";
echo "<tr >";
	echo "   <th align='left' style='border: solid 1px #000000; font-family: Arial; font-size: 13px; padding: 5px; width: 76px; background: #d0d0d0'>item Code</th>";
	echo "   <th align='left' style='border: solid 1px #000000; font-family: Arial; font-size: 13px; padding: 5px; width: 285px; background: #d0d0d0 '>Description</th>";
	echo "	 <th align='center'  style='border: solid 1px #000000; font-family: Arial; font-size: 13px; padding: 5px; width: 110px; background: #d0d0d0 '>location 1 </th>";
	echo "	 <th align='center'  style='border: solid 1px #000000; font-family: Arial; font-size: 13px; padding: 5px; width: 110px; background: #d0d0d0 '>location 2</th>";
	echo "	 <th align='center'  style='border: solid 1px #000000; font-family: Arial; font-size: 13px; padding: 5px; width: 110px; background: #d0d0d0 '>location 3</th>";
	
	echo "</tr>";
    while($rows=mysql_fetch_array($result)){
		extract($rows);

		echo "<tr >";
            echo "   <th align='left' style='border: solid 1px #000000; font-family: Arial; font-size: 13px; padding: 5px; width: 76px; vertical-align: top; '>$rows[0]</th>";
            echo "   <th align='left' style='border: solid 1px #000000; font-family: Arial; font-size: 13px; padding: 5px; width: 285px; vertical-align: top;'>$rows[1]</th>";
            echo "	 <th align='center'  style='border: solid 1px #000000; font-family: Arial; font-size: 13px; padding: 5px; width: 100px; vertical-align: middle; '>$rows[2]</th>";
            echo "	 <th align='center'  style='border: solid 1px #000000; font-family: Arial; font-size: 13px; padding: 5px; width: 50px; vertical-align: middle; text-align: right;'>$rows[3]</th>";
            echo "	 <th align='center'  style='border: solid 1px #000000; font-family: Arial; font-size: 13px; padding: 5px; width: 76px; vertical-align: middle; text-align: right;'>$rows[4]</th>"; 
        echo "</tr>";
    }
	echo "  
	<tr style='height: 35px'>
	<th colspan=6></th>
	</tr>
	<tr>
	<td colspan=6 style='font-size: 13px; font-weight: none; font-family: Arial'>$setup_invoiceremarks</td>
	</tr>
	<tr style='height: 45px'>
	<th colspan=6></th>
	</tr>
	<tr>
	<th colspan=6 style='font-size: 14px; font-family: Arial'>THANK YOU FOR YOUR BUSINESS!</th>
	</tr>
	";
echo"</table>";
print <<<HERE
<script>
window.print();
</script>
</body>
</html>
HERE;
?>