<?php


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


include("config.inc.php");
include("Functions_Purchase.php");


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

$query_setup  = "select DecimalBase, DecimalBase1, DecimalBase2, Base1, Base2, COMPANY_NAME as CompanyName from setup";
$result_setup = mysql_query($query_setup, $connection); 
$row_setup    = mysql_fetch_array($result_setup);
extract($row_setup);
if($export ==1){
	$filename = "Clients_Archeive" . date('d/m/Y') . ".xls";
	header("Content-Disposition: attachment; filename=\"$filename\"");
	header("Content-Type: application/vnd.ms-excel");
}
echo "<html>
<head>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1256\" />
<title>List of Area</title>
</head>
<body>
<table width='1300' style='border-collapse:collapse'>
<tr>
<th colspan='12' style='font-size: 20px; border-bottom: solid 2px #000000'>List of 	Area</td>
</tr>
";

$query = "select Area_Code, Area_Name from Area";
$result = mysql_query($query, $connection);
while($row = mysql_fetch_array($result))
{
	extract($row);
	
	$query_transactionsetup = "select Area_code, Area_name, date_format(Area_CreationDate, '%d/%m/%Y') as Area_date
	          from Area 
			  where Area_code = '".$Area_Code."' "; 
			  
	$result_transactionsetup = mysql_query($query_transactionsetup, $connection); 
	echo "<tr>
   <td><u><b>Group: </b></u>".$Area_Name."[".$Area_Code."]</td>
    </tr>";	
	
	echo "<table style='border-collapse: collapse'>
	<tr>
					
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='200'>Code</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='500'>Name</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='100'>Date</td>
					 
				
					 </tr>";
					 
					 $count = 0;
					 while($row_transactionsetup    = mysql_fetch_array($result_transactionsetup)){
	                    extract($row_transactionsetup);
						$count ++;
						if($count % 2 != 0)
	{
		$style="background-color: #b9bbbc";
	}
	else
	{
		$style="background-color: #909090";
	}
	
						echo "<tr style='$style'>
					 
					 <td width='200'>".$Area_Code."</td>
					 <td width='500'>".$Area_Name."</td>
					 <td width='100'>".$Area_date."</td>
					 
					
					 </tr>";
					 }
					 echo "</table>";
					  echo "<br><br>";
					  

}

echo "</table>
</body>
</html>";

?>



