<?php


session_start();
header("Content-type: text/html; charset=".$_SESSION['encodingmode']);
if($_SESSION['dbName']==""){
header("location:../index.php");
}



print <<< HERE
<HTML>
<HEAD>
<TITLE> Payment </TITLE>

<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">

<style type="text/css">

table.master th { font-size: 14px; 
                  font-weight: bold;
                  font-family:Times-New-Roman;
                }				 
table.master td { font-size: 14px; 
                  font-family:Times-New-Roman;
                 }
table.detail th { font-size: 14px; 
                  font-weight: bold;
                  font-family:Times-New-Roman;
                }				 
				 
table.detail td { font-size: 12px; 
                  font-family:Times-New-Roman;
                 }				 
				 
table.detail td.sr  { font-size: 10px; 
					  font-style: italic; 
                      font-family:Times-New-Roman;
                    }
				 
table.totals td.labels { font-size: 14px; 
                         font-weight: bold;
                         font-family:Times-New-Roman;
						 border-width: 0px;
						 border-style: none solid solid solid;
  						 border-color: #666666;
                       }					  
table.totals td.amounts { font-size: 14px; 
                          font-family:Times-New-Roman;
						  border-width: 0px;
						  border-style: none none solid none;
  						  border-color: #666666;
				        }
table.totals td.totalborder {
								font-size: 14px; 
								font-family:Times-New-Roman;
								border-width: 0px;
								border-style: none solid solid none;
								border-color: #666666;
							}						
				 
h4 { border-top-style: double; 
	 border-top-color: black; 
	 border-top-width: 1px;
   }
   
h3 { border-top-style: double; 
	 border-top-color: black; 
	 border-top-width: 2px;
	 width: 150px;
   }   
   
.bigfont{
	font-size: 150%; 
}
/*div.relative {
	position: relative;
	height:1028px;

}

div.absolute {
	//border-top:solid 1px black;
    position: absolute;
    bottom: 0px;
	//height: 75px;
	width:100%;
}*/
.inlinetable{
	display: inline-table;
}
   .midfont{
	  font-size: 100%;
   }
   
   .headerheight{
	height:200px;
}

html {
  height: 100%;
  box-sizing: border-box;
}

*,
*:before,
*:after {
  box-sizing: inherit;
}

body {
  position: relative;
  margin: 0;
  padding-bottom: 6rem;
  min-height: 100%;
  //font-family: "Helvetica Neue", Arial, sans-serif;
}

.demo {
  margin: 0 auto;
  padding-top: 64px;
  width: 95%;
}



/**
 * Footer Styles
 */

.footer {
position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 1rem;
  background-color: #efefef;
  text-align: center;
  
}
.footer table{
	font-size:11px;
}


.horizantalline{
	border-top:solid 1px black;
}
</style>
<script>

</script>

</HEAD>

<BODY>

HERE;

include("config.inc.php");
$hide=$_GET['hide'];
//echo $hide;
//echo $withorwithout;
$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");

if(	$_SESSION['encodingmode'] == 'utf8' || $_SESSION['encodingmode'] == 'utf-8'){
	mysql_query("SET NAMES 'utf8'"); 
	mysql_query('SET CHARACTER SET utf8'); 
	mysql_set_charset('utf8', $connection);
}

//Read From Setup Table							
$querysetup= " select DecimalBase, DecimalBase1, DecimalBase2, base1, base2, grid_color1, grid_color2, Setup_vatno, ".
             " Date_Format(Setup_VatStartDate,'%Y%m%d') As Setup_VatStartDate, ifNull(Setup_VatPercentage,0) As Setup_VatPercentage, ".
			 " Company_Name as CompanyName,Company_Memo as CompanyMemo, Company_NameF, Company_Memo, Company_MemoF, Company_Capital, Company_CapitalF,
			 company_telephone,company_city,company_fax,company_country,company_address,company_phone2,company_phone3
			 ,company_address2,company_city2,company_city_arabic,company_address_arabic,company_address2_arabic,
			 company_city_arabic,company_city2_arabic,company_country_arabic,company_name_arabic,company_memo_arabic,company_phone4,company_city3,company_city4,company_phone2_city3
			 ,company_phone1_city3,company_telephone_city3 ,company_phone2_city4
			 ,company_phone1_city4,company_telephone_city4,website,company_email".
			 " from setup ";
$resultsetup=mysql_query($querysetup,$connection) or die(mysql_error());
while($rowsetup=mysql_fetch_array($resultsetup)){
	extract($rowsetup);
}

//Read From PurchaseSetup Table
$queryPurchaseSetup="Select PurchaseTTC From PurchaseSetup";
$resultPurchaseSetup=mysql_query($queryPurchaseSetup,$connection) or die(mysql_error());
while($rowPurchaseSetup=mysql_fetch_array($resultPurchaseSetup)){
	extract($rowPurchaseSetup);
}


//Read From Module Table
$querymodule=" Select ifNull(Module_AdditionalTaxes,0) As Module_AdditionalTaxes, ".
             " ifNull(Module_ShowLayoutProj,0) As Module_ShowLayoutProj, ifNull(Module_ShowLayoutCost,0) As Module_ShowLayoutCost From Module";
$resultmodule=mysql_query($querymodule,$connection) or die(mysql_error());
while($rowmodule=mysql_fetch_array($resultmodule)){
	extract($rowmodule);
}
	
	

//echo $query_user;

$now=current_server_time($connection);
$dt=split(" ",$now[0]);
$printdate=split("-",$dt[0]);

$TotalQty = 0;




	
	//echo "<div class='relative' >";
	
	if ($hide=='0'){
		echo "<div class='demo' >";
		echo "<table><thead>";
		echo "<table border=0 width=100% cellspacing=0 cellpadding=0>";
	echo "<tr><td align='left' ><table border='0' width='270px'> <col width=10><col width=10>";
	echo "<tr><td align='left'><table><tr><td align='center' class='bigfont'><b><pre>".str_replace( '\n', '<br>', $CompanyName)."<pre></b></td></tr>
		<tr><td align='center' class='midfont'><pre>".str_replace( '\n', '<br>', $CompanyMemo)."<pre></td></tr></table></td>";
		
		
	
	echo "</table></td>";
	echo "<td height='60' align='center'><img src='LogoFile.php' width='100' height='100' /></td>";
	
	echo "<td align='right'><table border='0'> <col width=10><col width=10>";
	echo "<tr><td align='right' ><table border='0'  width='270'><tr><td align='center' class='bigfont'><b><pre>".str_replace( '\n', '<br>', $company_name_arabic)."<pre></b></td></tr>
		<tr><td align='center' class='midfont'><pre>".str_replace( '\n', '<br>', $company_memo_arabic)."<pre></td></tr></table></td>";
	echo "</table></td>
		
	</tr></thead><tr height=10px></tr>";
	}
	else echo "<div class='headerheight'></div>";
	
	 echo "<tr height='40'><td>Date:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/&nbsp;&nbsp;20</td><td align='center' ><b><font size=5>  سند صرف</font></td><td align='right'> 20 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;تاريخ</td></tr>";
echo "<tr height='20'></tr>";

echo "<table width=100%>";
 echo "<tr height='30'>
					<td>Reiceved From ................................................................................................................................وصلني من </td></tr>";
	   echo "<tr height='30'>
					<td >The Sum Of..............................................................................................................................................فقط</td></tr>";
	    echo "<tr height='30'><td>For............................................................................................................................................................وذلك</td></tr>";
		 echo "<tr height='30'><td >Cash/Chk.NO.....................................................................................................................................نقدا/ شيك</td></tr>";
		 echo "<tr height='20'></tr>";
		 echo "</table>";
		 echo "<tr height='10'></tr>";
echo "<table style='float:right' border='1' width='100%' cellpadding=10 cellspacing=0>";
echo "<col width=400>
	  
	  <col width=100>
	  <col width=100 >";
	 
			echo "<tr ><td align='center'>المحاسبة</td>
			<td  align='center'>التوقيع</td>
			<td align='center'>المستلم</td></tr>";
			echo "<tr height=80>
					<td align='center'></td>
					<td  align='center'></td>
					<td align='center'></td>
				</tr>";

echo "</table>";

if ($hide=='0'){
	
echo "</div>";
echo "<div class='footer'>";
echo "<div class='horizantalline'></div>";
echo "<table border='0' class='inlinetable'><col width=150px><col width=150px><col width=150px><col width=150px><col width=150px><tr><td align='center'>";

echo "<table border='0'><tr><td><i>$website</i></td></tr><tr><td><i>$company_email</i></td></tr></table> </td>";

echo "<td><table border=0><col width='70'><col width=100><tr><th colspan='2'><i>
$company_city</i></th></tr><tr><td align='right'>phone:</td><td><i>$company_telephone</i></td></tr><tr><td></td><td><i>$company_phone2</i></td></tr><tr><td align='right'>fax:</td><td><i>$company_phone4</i></td></tr></table></td>
<td><table><tr><th colspan='2'><i> $company_city3  </i></th></tr><tr><td align='right'>phone:</td><td><i>$company_telephone_city3</i></td></tr><tr><td></td><td><i>$company_phone1_city3</i></td></tr><tr><td align='right'>fax:</td><td><i>$company_phone2_city3</i></td></tr></table></td>
<td><table border='0'><tr><th colspan='2'><i> $company_city4 </i></th></tr><tr><td align='right'>phone:</td><td><i>$company_telephone_city4</i></td></tr><tr><td></td><td><i>$company_phone1_city4</i></td></tr><tr><td align='right'>fax:</td><td><i>$company_phone2_city4</i></td></tr></table></td>
<td valign='top'><table border='0'><tr><th colspan='2'><i> $company_city2 </i> </th></tr><tr><td>phone:</td><td><i>$company_phone3</i></td></tr></table></td></tr>";
echo "<tr><td></td></tr>";
echo "</table><tfoot></table>";
echo "</div>";

}


//echo "</div>";


function current_server_time($connection){

  $string="Select date_format(NOW(),'%Y-%m-%d %h:%i %p') ";
  $result=mysql_query($string,$connection) or die(mysql_error());
  $now=mysql_fetch_row($result);

  return $now;
}

function format_currency($amount, $DecimalBase) { 

    if($amount < 0) 
        return "(".number_format(abs($amount),$DecimalBase).")"; 
 
    else return number_format($amount, $DecimalBase); 
} 

print <<< HERE

<script language=javascript>
if (typeof(window.print) != 'undefined')
{
    window.print();
}
</script>
</BODY>
</HTML>
HERE;
?>

