<?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%; 
}

.inlinetable{
	display: inline-table;
}
   .bigfont{
	   font-size:150%; 
   }
    .midfont{
	   font-size: 100%; 
   }
   
  .headerheight{
	height:200px;
}
.inlinetable{
	display: inline-table;
}
   
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%;
  position:fixed;
   padding: 1rem;
}



/**
 * Footer Styles
 */

.footer {
position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 1rem;
  text-align: center;
}

.footer table{
	font-size:11px;
}

.horizantalline{
	border-top:solid 1px black;
}

.dotted{
    border-bottom: dotted 1px #000000;
	border-collapse:collapse;
}

.containerdiv{
	border:solid 1px yellow;
}
</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);
}
	
	


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

$transdt="select transdt_amount,transdt_description,currency_code,transdt_dbcd
from transdt where trans_id=$TransId and transdt_dbcd='D' ;";

$result_trandt=mysql_query($transdt,$connection) or die(mysql_error());

	
	
	if ($hide=='0'){
		echo "<div class='demo' >";
		
			
			echo "<table border='0' width=100% cellspacing=0 cellpadding=0>
			<col width=270>
			<col width=100>
			<col width=270>
			<tr>
			<td>
				<table border=0 width=270>
					<tr><td class='bigfont' align='center'><b><pre>".str_replace( '\n', '<br>', $CompanyName)."<pre></b></td>";

					echo "</tr>
					<tr><td class='midfont' align='center'><pre>".str_replace( '\n', '<br>', $CompanyMemo)."<pre></td>";

					echo "</tr>
		
				</table>
			</td>
			
			<td align=center><img src='LogoFile.php' width='100' height='100' /></td>
			<td align=right>
			<table border=0 width=270>
					<tr><td class='bigfont' align='center'><b><pre>".str_replace( '\n', '<br>', $company_name_arabic)."<pre></b></td>";

					echo "</tr>
					<tr><td class='midfont' align='center'><pre>".str_replace( '\n', '<br>', $company_memo_arabic)."<pre></td>";

					echo "</tr>
		
				</table>
			</td>
			</tr>
			<tr height=20></tr>
			<tr height='40'><td align='center' colspan='3'><b><font size=5>سند صرف </font></td></tr>
			</table>";
		

		

	echo "</div>";
	
	}
	 echo "<div class='headerheight'></div>";
	 echo "<table width=100% border=0>";
	 
	 echo "<tr><td><table width=100% border=0>
	 <col  width=270px><col width='100'><col width='270'>
	 <tr height='40' style='border:solid 1px black;'>
	 <td align='left' >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></table></td></tr>";
	 
echo "<tr height='20'></tr>";

echo "<tr><td > ";
echo "<table border='0' width=100% cellpadding=0 cellspacing=0>";
echo "<col width=300>
	  <col width=80>  
	  <col width=150 >";
	  
	  		
			
			
	 echo "<tr  ><td colspan=3 valign='top'>";
	  echo "<table border='0' width='100%' style='float:right' cellpadding=10 cellspacing=0 >
	  <col width=100>
	  <col width=600>
	  
	  <col width=100>";
	  echo "
	  <tr><td align='right' style='border-top : solid 1px black;  border-left:solid 1px black; border-bottom:solid 1px black;'>المحترم</td>
	  <td  class='dotted' style='border-top : solid 1px black;  '></td>
	  <td align='left' style='border-top : solid 1px black; border-right:solid 1px black;  border-bottom:solid 1px black;'> ادفعوا الى</td></tr></table></td></tr>";

			echo "<tr height=40>
				<td align='center' style='border-top : solid 1px black; border-right:solid 1px black; border-left:solid 1px black; border-bottom:solid 1px black;'>التفاصيل</td>
				<td align='center' style='border-top : solid 1px black; border-right:solid 1px black; border-left:solid 1px black; border-bottom:solid 1px black;'>$ .ل.ل</td>
				<td align='center' style='border-top : solid 1px black; border-right:solid 1px black; border-left:solid 1px black; border-bottom:solid 1px black;'>القيمة</td>
				
			</tr>";
			$i=1;
	$j=1;
	$page=0;
	$nbline=10;
	$num_rows = mysql_num_rows($resultdt);
			while($transdetails=mysql_fetch_array($result_trandt)){
			//while(($transdetails=mysql_fetch_array($result_trandt))||($j<=13)){
	

			echo "<tr height='40'>";
			echo"<td  align='center' style='border-top : solid 1px black; border-right:solid 1px black; border-left:solid 1px black; border-bottom:solid 1px black;'>$transdetails[1] </td>
				<td align='center' style='border-top : solid 1px black; border-right:solid 1px black; border-left:solid 1px black; border-bottom:solid 1px black;'>$transdetails[2] </td>
				<td align='center' style='border-top : solid 1px black; border-right:solid 1px black; border-left:solid 1px black; border-bottom:solid 1px black;'>$transdetails[0] </td>";
			echo "</tr>";
			
		
		if ($page!=0){$nbline=16;}
		else {$nbline=13;}
		
		if ($i==$nbline){
		
	$page++;
	$i=1;
	echo "<tr><td>&nbsp;<p style='page-break-before: always'></p>
		</td></tr>";
				echo "<tr><td><div class='headerheight'></div></td></tr>";
		if ($j!=100){
			
			echo "<tr height=40>
				<td align='center' style='border-top : solid 1px black; border-right:solid 1px black; border-left:solid 1px black; border-bottom:solid 1px black;'>التفاصيل</td>
				<td align='center' style='border-top : solid 1px black; border-right:solid 1px black; border-left:solid 1px black; border-bottom:solid 1px black;'>$ .ل.ل</td>
				<td align='center' style='border-top : solid 1px black; border-right:solid 1px black; border-left:solid 1px black; border-bottom:solid 1px black;'>القيمة</td>
				
			</tr>";
	
		}
	
	
		}
		$j++;
		$i++;
			}
		echo "</table></td></tr>";
			
			echo "<tr><td><table width=100% border=1 cellpadding=0 cellspacing=0>
			<col width=230>
			<col width=150>
			<col width=150>
			";
			echo "<tr height=40><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></table></td></tr>";

echo "</table>";

if ($hide=='0'){
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>";


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;
}


print <<< HERE

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

