<?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 Suppliers</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 	Suppliers</td>
</tr>
";

$query = "select Ledger_number, Ledger_name from Suppliers";
$result = mysql_query($query, $connection);
while($row = mysql_fetch_array($result))
{
	extract($row);
	
	$query_transactionsetup = "select * 
	          from Suppliers 
			  where Ledger_number = '".$Ledger_number."' "; 
			  
	$result_transactionsetup = mysql_query($query_transactionsetup, $connection); 
	
	
	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='8%'>Ledger_number</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='8%'>Ledger_name</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='8%'>Ledger_Desc</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='8%'>Supplier_Representative</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='8%'>Supplier_Address</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='8%'>Supplier_Telephone1</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='15%'>Supplier_Telephone2</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='7%'>Supplier_Fax</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='15%'>Supplier_Email</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='15%'>Supplier_Homepage</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='fixed'>Supplier_CreditLimit</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='17%'>Supplier_PaymentTerms</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='15%'>Suplier_Remark</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='fixed'>Area_Code</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='7%'>Currency_Code</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='7%'>Supplier_VAT</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='7%'>Supplier_VatNo</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='7%'>Supplier_Approved</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='7%'>Supplier_BelongsToGroup</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='7%'>Supplier_Address2</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='7%'>Supplier_City</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='7%'>Supplier_Country</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='7%'>Supplier_state</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='7%'>Supplier_Group</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='7%'>SendReceive_Reference</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='7%'>Supplier_posted</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='7%'>SupplierGrp_Code</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='7%'>Project_Code</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='7%'>Supplier_Tax1</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='7%'>Supplier_Tax2</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='7%'>Supplier_Tax3</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='7%'>Supplier_Tax4</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='7%'>Supplier_Tax5</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='7%'>Synchronized</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='7%'>Costcenter_Code</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='7%'>Supplier_GCINO</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='7%'>Supplier_CompOwnerTitle</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='7%'>Supplier_CompOwner</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='7%'>Supplier_ReferedByTitle</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='7%'>Supplier_ReferedBy</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='7%'>Supplier_BusinessSector</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='7%'>Supplier_BusinessSectorDesc</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='7%'>Supplier_VAtDate</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='7%'>Supplier_CreationDate</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='7%'>Supplier_MotherCompany</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='7%'>Supplier_Export</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='7%'>Supplier_BType2</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='7%'>Supplier_BType3</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='7%'>Supplier_SubContractor</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='7%'>Supplier_TaxPercantage</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='7%'>Supplier_Import</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='7%'>Owner_Branch</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='7%'>supplier_targetamount</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='7%'>Ledger_NameF</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='7%'>Supplier_Address3</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='7%'>supplier_Longitude</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='7%'>supplier_Latitude</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='7%'>Supplier_bank_name</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='7%'>Supplier_account_number</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='7%'>Supplier_iban</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='7%'>Supplier_swift</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='7%'>Supplier_bank_address</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='7%'>Supplier_designation</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='7%'>Supplier_is_iso</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='7%'>Supplier_delivery_time</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='7%'>Supplier_port_of_loading</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='7%'>Supplier_incoterm</td>
					 <td style='font-family: Arial; font-size: 14px; font-weight: bold; border-bottom: solid 1.5px #000000;' width='7%'>Supplier_account_name</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='fixed'>".$Ledger_number."</td>
					 <td width='fixed'>".$Ledger_name."</td>
					 <td width='fixed'>".$Ledger_Desc."</td>
					 <td width='8%'>".$Supplier_Representative."</td>
					 <td width='fixed'>".$Supplier_Address."</td>
					 <td width='8%'>".$Supplier_Telephone1."</td>
					 <td width='fixed'>".$Supplier_Telephone2."</td>
					 <td width='12%'>".$Supplier_Fax."</td>
					 <td width='fixed'>".$Supplier_Email."</td>
					 <td width='8%'>".$Supplier_Homepage."</td>
					 <td width='8%'>".$Supplier_CreditLimit."</td>
					 <td width='15%'>".$Supplier_PaymentTerms."</td>
					 <td width='15%'>".$Suplier_Remark."</td>
					 <td width='15%'>".$Area_Code."</td>
					 <td width='15%'>".$Currency_Code."</td>
					 <td width='15%'>".$Supplier_VAT."</td>
					 <td width='15%'>".$Supplier_VatNo."</td>
					 <td width='15%'>".$Supplier_Approved."</td>
					 <td width='15%'>".$Supplier_BelongsToGroup."</td>
					 <td width='15%'>".$Supplier_Address2."</td>
					 <td width='15%'>".$Supplier_City."</td>
					 <td width='15%'>".$Supplier_Country."</td>
					 <td width='15%'>".$Supplier_state."</td>
					 <td width='15%'>".$Supplier_Group."</td>
					 <td width='15%'>".$SendReceive_Reference."</td>
					 <td width='15%'>".$Supplier_posted."</td>
					 <td width='15%'>".$SupplierGrp_Code."</td>
					 <td width='15%'>".$Project_Code."</td>
					 <td width='15%'>".$Supplier_Tax1."</td>
					 <td width='15%'>".$Supplier_Tax2."</td>
					 <td width='15%'>".$Supplier_Tax3."</td>
					 <td width='15%'>".$Supplier_Tax4."</td>
					 <td width='15%'>".$Supplier_Tax5."</td>
					 <td width='15%'>".$Synchronized."</td>
					 <td width='15%'>".$Costcenter_Code."</td>
					 <td width='15%'>".$Supplier_GCINO."</td>
					 <td width='15%'>".$Supplier_CompOwnerTitle."</td>
					 <td width='15%'>".$Supplier_CompOwner."</td>
					 <td width='15%'>".$Supplier_ReferedByTitle."</td>
					 <td width='15%'>".$Supplier_ReferedBy."</td>
					 <td width='15%'>".$Supplier_BusinessSector."</td>
					 <td width='15%'>".$Supplier_BusinessSectorDesc."</td>
					 <td width='15%'>".$Supplier_VAtDate."</td>
					 <td width='15%'>".$Supplier_CreationDate."</td>
					 <td width='15%'>".$Supplier_MotherCompany."</td>
					 <td width='15%'>".$Supplier_Export."</td>
					 <td width='15%'>".$Supplier_BType2."</td>
					 <td width='15%'>".$Supplier_BType3."</td>
					 <td width='15%'>".$Supplier_SubContractor."</td>
					 <td width='15%'>".$Supplier_TaxPercantage."</td>
					 <td width='15%'>".$Supplier_Import."</td>
					 <td width='15%'>".$Owner_Branch."</td>
					 <td width='15%'>".$supplier_targetamount."</td>
					 <td width='15%'>".$Ledger_NameF."</td>
					 <td width='15%'>".$Supplier_Address3."</td>
					 <td width='15%'>".$supplier_Longitude."</td>
					 <td width='15%'>".$supplier_Latitude."</td>
					 <td width='15%'>".$Supplier_bank_name."</td>
					 <td width='15%'>".$Supplier_account_number."</td>
					 <td width='15%'>".$Supplier_iban."</td>
					 <td width='15%'>".$Supplier_swift."</td>
					 <td width='15%'>".$Supplier_bank_address."</td>
					 <td width='15%'>".$Supplier_designation."</td>
					 <td width='15%'>".$Supplier_is_iso."</td>
					 <td width='15%'>".$Supplier_delivery_time."</td>
					 <td width='15%'>".$Supplier_port_of_loading."</td>
					 <td width='15%'>".$Supplier_incoterm."</td>
					 <td width='15%'>".$Supplier_account_name."</td>
					 
					 
					 </tr>";
					 }
					 echo "</table>";
					  echo "<br><br>";
					  

}

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

?>



