<!DOCTYPE html>
<meta charset="utf-8">

<HTML>
<HEAD>
<TITLE>Chitanta</TITLE>

<link rel="stylesheet" type="text/css" href="A21_stiluri2.css">
<link rel="stylesheet" type="text/css" href="jquery-ui.css">

<script type="text/javascript" src="jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="jquery-ui.min.js"></script>

</HEAD>
<BODY bgcolor="#DCDCDC">
<CENTER>
<script>

</script>
	
<?php
function convert_number_to_words($number) {
    
    $hyphen      = ' si ';
    $conjunction = '  ';
    $separator   = ', ';
    $negative    = ' minus ';
    $decimal     = ' virgula ';
    $dictionary  = array(
        0                   => 'zero',
        1                   => 'una',
        2                   => 'doua',
        3                   => 'trei',
        4                   => 'patru',
        5                   => 'cinci',
        6                   => 'sase',
        7                   => 'sapte',
        8                   => 'opt',
        9                   => 'noua',
        10                  => 'zece',
        11                  => 'unsprezece',
        12                  => 'doisprezece',
        13                  => 'treisprezece',
        14                  => 'patrusprezece',
        15                  => 'cincisprezece',
        16                  => 'saisprezece',
        17                  => 'saptesprezece',
        18                  => 'optsprezece',
        19                  => 'nouasprezece',
        20                  => 'douazeci',
        30                  => 'treizeci',
        40                  => 'patruzeci',
        50                  => 'cincizeci',
        60                  => 'saizeci',
        70                  => 'saptezeci',
        80                  => 'optzeci',
        90                  => 'nouazeci',
        100                 => 'suta',
        1000                => 'mii',
        1000000             => 'milion',
        1000000000          => 'bilion',
        1000000000000       => 'trilion',
    );
    
    if (!is_numeric($number)) {
        return false;
    }
    
    if (($number >= 0 && (int) $number < 0) || (int) $number < 0 - PHP_INT_MAX) {
        // overflow
        trigger_error(
            'convert_number_to_words only accepts numbers between -' . PHP_INT_MAX . ' and ' . PHP_INT_MAX,
            E_USER_WARNING
        );
        return false;
    }

    if ($number < 0) {
        return $negative . convert_number_to_words(abs($number));
    }
    
    $string = $fraction = null;
    
    if (strpos($number, '.') !== false) {
        list($number, $fraction) = explode('.', $number);
    }
    
    switch (true) {
        case $number < 21:
            $string = $dictionary[$number];
            break;
        case $number < 100:
            $tens   = ((int) ($number / 10)) * 10;
            $units  = $number % 10;
            $string = $dictionary[$tens];
            if ($units) {
                $string .= $hyphen . $dictionary[$units];
            }
            break;
        case $number < 1000:
            $hundreds  = $number / 100;
            $remainder = $number % 100;
            $string = $dictionary[$hundreds] . ' ' . $dictionary[100];
            if ($remainder) {
                $string .= $conjunction . convert_number_to_words($remainder);
            }
            break;
        default:
            $baseUnit = pow(1000, floor(log($number, 1000)));
            $numBaseUnits = (int) ($number / $baseUnit);
            $remainder = $number % $baseUnit;
            $string = convert_number_to_words($numBaseUnits) . ' ' . $dictionary[$baseUnit];
            if ($remainder) {
                $string .= $remainder < 100 ? $conjunction : $separator;
                $string .= convert_number_to_words($remainder);
            }
            break;
    }
    
    if (null !== $fraction && is_numeric($fraction)) {
        $string .= $decimal;
        $words = array();
        foreach (str_split((string) $fraction) as $number) {
            $words[] = $dictionary[$number];
        }
        $string .= implode(' ', $words);
    }
    
    return $string;
}

// include 'A07_javascript1.php';
include 'javascripts.php';
include 'conectare.php';
	
if(substr($_POST["actiune"],0,1)=="-")
{
	echo "<BODY id=\"bg_list\">";
echo "<div class=\"chitanta1\">";
		echo "<CENTER>";
		
		$connection=mysql_connect("$host","$username","$password") or die("Nu aveti acces la server");
		$baza="apponlin_".$_POST["aplic"]."_".$_POST["unit"];  
		$db=mysql_select_db($baza,$connection) or die("Nu puteti selecta Baza de date ".$baza);
	
	echo "<FORM NAME=\"form3\" ACTION=\"A21_listare_chit.php\" METHOD=\"POST\">";
	include 'A21_param1.php';	
		
	echo "<INPUT TYPE=\"HIDDEN\" NAME=\"chitanta\" VALUE=\"".$_POST["actiune"]."\">";
	$wid_ch=substr($_POST["actiune"],1,strpos($_POST["actiune"],'-',1)-1);
	echo "<INPUT TYPE=\"HIDDEN\" NAME=\"id_chit\" VALUE=\"".$wid_ch."\">";
	echo "<INPUT TYPE=\"HIDDEN\" NAME=\"codcopil\" VALUE=\"".$_POST["codcopil"]."\">";

	echo "<TABLE  cellSpacing=0 cellPadding=0 width=\"45%; height:100%;\" border=0>";
	echo "<TD colspan=\"7\" align=\"right\" height=\"35\">";
	echo "<input type=\"button\" class=\"noPrint\" onClick=\"window.print()\" value=\"PRINTARE\">";	
//	echo "<INPUT TYPE=\"SUBMIT\" NAME=\"actiune\" class=\"noPrint\" VALUE=\"IMPRIMARE\">";
	echo "<button type=\"button\" class=\"noPrint\" onclick=\"javascript:window.close()\">INAPOI</button>";
	echo "</TR>";
	echo "</TABLE>";

		echo "<table bgcolor=white class=\"table20\" style=\"font-size:10pt;border-color:gray;border-style:solid;\" align=\"center\" border=\"1\" cellspacing=\"0\" cellpadding=\"5\">";
		echo "<tr>";
		echo "<td align=\"center\" style=\"font-size:12pt;margin-top:150px; height:20%;\">";
	//	echo "<p class=\"title2\" align=\"center\" >";


		$query="SELECT * FROM unitate";
		$result=mysql_query($query) or die("Interogare esuata: ".mysql_error());
		$row=mysql_fetch_array($result);
				
			echo "<table style=\"font-size:11pt; width:50%; float:left; margin-top:3%;\" align=\"left\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";	
//			echo "<tr>";
//			echo "<img src=\"img\stema.png\" height=35% width=15% align=\"left\" style=\"margin-right:2%;\" class=\"img1\">";
//			echo "<td align=\"left\" style=\"font-size:12pt;\"><B>ROMANIA</B></td>";
//			echo "</tr>";			
			echo "<tr>";
			echo "<td>&nbsp</td>";
			echo "</tr>";			
			echo "<tr>";
			echo "<td align=\"left\" style=\"font-size:12pt;\"><b>".$row["denunit"]."</b></td>";
			echo "</tr>";
			echo "<tr>";
			echo "<td align=\"left\"style=\"font-size:10pt;\">Cod fiscal: ".$row["cf"]."</td>";
			echo "</tr>";	
			echo "<tr>";
			echo "<td align=\"left\" style=\"font-size:10pt;\">Adresa:  ".$row["adresa"]."</td>";
			echo "</tr>";
			echo "<tr>";
			echo "<td align=\"left\" style=\"font-size:10pt;\">Judet: ".$row["judet"]."</td>";
			echo "</tr>";
			
			echo "<td align=\"left\"></td>";							
			echo "</tr>";		
			echo "<tr>";
			echo "<td align=\"left\"></td>";						
			echo "</tr>";
			
			echo "</table>";


	$query2="SELECT *,DATE_FORMAT(data_doc,'%d-%m-%Y') AS data_doc FROM chitante WHERE id=".$wid_ch;
	$result2=mysql_query($query2) or die("Interogare esuata: ".mysql_error());
	
	while ($row2 = mysql_fetch_array( $result2))
	{
			echo "<table style=\"font-size:11pt; width:30%; margin-top:0px;\" align=\"center\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
			echo "<br>";
			echo "<td align=\"center\" style=\"font-size:12pt;margin-top:150px; height:20%;\">";
			echo "<br>";
			echo "<b>CHITANTA</b>";
			echo "</td>";
			echo "<br>";
			echo "<table style=\"font-size:11pt; width:40%; margin-top:0px;border-collaps:collaps;\" align=\"center\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\">";
			echo "<br>";
			echo "<tr>";
			echo "<td  width=\"9%\">Serie / nr. &nbsp</td>";
			echo "<td align=\"center\" width=\"11%\"><B>".$row2["serie_doc"]."_".$row2["nr_doc"]."</B></td>";
			echo "</tr>";
			echo "<tr>";
			echo "<td width=\"9%\">Data &nbsp</td>";
			echo "<td align=\"center\" width=\"11%\"><B>".$row2["data_doc"]."</B></td>";
			echo "</tr>";
			echo "</table>";
			
		$query3="SELECT * FROM copii where codcopil=\"".$_POST["codcopil"]."\"";
		$result3=mysql_query($query3) or die("Interogare esuata: ".mysql_error());	
	
		while ($row3 = mysql_fetch_array( $result3))
		{
			$query4="SELECT * FROM grupe where codgrp=\"".$row3["codgrp"]."\"";
			$result4=mysql_query($query4) or die("Interogare esuata: ".mysql_error());	
			
			$wcodcopil = $row3["codcopil"];
			
			while ($row4 = mysql_fetch_array( $result4))
			{
			    $val_text = convert_number_to_words("".$row2["val_doc"]."")."";
				
				echo "<br>";
				echo "<table style=\"font-size:11pt; width:90%; margin-top:0px;\" align=\"center\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
				echo "<br>";
				echo "<tr>";
				echo "<td style=\"align:left;\">Am &nbsp primit &nbsp de &nbsp la :&nbsp";
//				echo "<input type=\"text\" name=\"nume\" size=\"40\" value=\"\">"; 
				echo "".$row2["platitor"]."";
				echo "</TD>";
				echo "</TR>";
				echo "<tr>";
				echo "<td style=\"align:left;\">";
				echo "Adresa : ";
//				echo "<input type=\"text\" name=\"adresa\" size=\"51\" value=\"\">"; 
				echo "".$row3["adresa"]."";
				echo "</TD>";
				echo "</TR>";
				echo "<tr>";
				echo "<td style=\"align:left;\">";
				echo "Suma : ".$row2["val_doc"]." &nbsp lei &nbsp (".$val_text." lei) &nbsp ";
				echo "</TD>";
				echo "</TR>";
				echo "<TR>";
				echo "<td style=\"align:left;\">Reprezentand :&nbsp c/v &nbsp masa &nbsp pentru &nbsp prescolarul: &nbsp ".$row3["nume"]." ".$row3["prenume"]." &nbsp de &nbsp la &nbsp ".$row4["dengrp"]." &nbsp - &nbsp ".$row2["reprezentand"].".</td>";
				echo "</td>";
				echo "</tr>";
				echo "</table>";
			}
		}
	}	
			echo "<br>";
			echo "<table style=\"font-size:10pt; width:8%; margin-top:0px;\" align=\"left\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";	
			echo "<tr>";
			echo "<td>";
			echo "<P>&nbsp</P>";
			echo "<P>&nbsp</P>";
			echo $wcodcopil;
			echo "</td>";
			echo "</tr>";
			echo "</table>";

			echo "<table style=\"font-size:11pt; width:20%; margin-top:0px;\" align=\"LEFT\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";	
			echo "<tr>";
			echo "<td align=\"right\">";
			echo "Platitor,";
			echo "</td>";
			echo "</tr>";
			echo "</table>";
			
			echo "<table style=\"font-size:11pt; width:40%; margin-top:0px;\" align=\"right\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";	
			echo "<tr>";
			echo "<td>";
			echo "Casier,";
			echo "<BR>";
			echo $_POST["nume_log"]." ".$_POST["prenume_log"];
			echo "</td>";
			echo "</tr>";
			echo "</table>";
			
		echo "</TABLE>";
echo "</div>";		
//******************************************
	echo "<br>";	
	echo "<table align=\"center\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
	echo "<tr>";
	echo "<br>";
	echo "</tr>";
	echo "<br>";
	echo "<tr>";
	echo "<td>&nbsp</td>";
	echo "</tr>";

	echo "<HR width=\"100%\" align=\"center\" class=\"hr_dotted\">";
	echo "</table>";	
//******************************************
echo "<div class=\"chitanta2\">";

	echo "<INPUT TYPE=\"HIDDEN\" NAME=\"chitanta\" VALUE=\"".$_POST["actiune"]."\">";
	$wid_ch=substr($_POST["actiune"],1,strpos($_POST["actiune"],'-',1)-1);
	

	echo "<TABLE  cellSpacing=0 cellPadding=0 width=\"45%; height:100%;\" border=0>";
	echo "<TD colspan=\"7\" align=\"right\" height=\"35\">";
	echo "<input type=\"button\" class=\"noPrint\" onClick=\"window.print()\" value=\"PRINTARE\">";
//	echo "<INPUT TYPE=\"SUBMIT\" NAME=\"actiune\" id=\"button11\" VALUE=\"IMPRIMARE\">";
	echo "<button type=\"button\" class=\"noPrint\" onclick=\"javascript:window.close()\">INAPOI</button>";
	echo "</TR>";
	echo "</TABLE>";

		echo "<table bgcolor=white class=\"table20\" style=\"font-size:10pt;border-color:gray;border-style:solid;\" align=\"center\" border=\"1\" cellspacing=\"0\" cellpadding=\"5\">";
		echo "<tr>";
		echo "<td align=\"center\" style=\"font-size:12pt;margin-top:150px; height:20%;\">";
	//	echo "<p class=\"title2\" align=\"center\" >";
					
		$query="SELECT * FROM unitate";
		$result=mysql_query($query) or die("Interogare esuata: ".mysql_error());
		$row=mysql_fetch_array($result);
				
			echo "<table style=\"font-size:11pt; width:50%; float:left; margin-top:3%;\" align=\"left\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";	
//			echo "<tr>";
//			echo "<img src=\"img\stema.png\" height=35% width=15% align=\"left\" style=\"margin-right:2%;\" class=\"img1\">";
//			echo "<td align=\"left\" style=\"font-size:12pt;\"><B>ROMANIA</B></td>";
//			echo "</tr>";			
			echo "<tr>";
			echo "<td>&nbsp</td>";
			echo "</tr>";			
			echo "<tr>";
			echo "<td align=\"left\" style=\"font-size:12pt;\"><b>".$row["denunit"]."</b></td>";
			echo "</tr>";
			echo "<tr>";
			echo "<td align=\"left\" style=\"font-size:10pt;\">Cod fiscal: ".$row["cf"]."</td>";
			echo "</tr>";	
			echo "<tr>";
			echo "<td align=\"left\" style=\"font-size:10pt;\">Adresa: ".$row["adresa"]."</td>";
			echo "</tr>";
			echo "<tr>";
			echo "<td align=\"left\" style=\"font-size:10pt;\">Judet: ".$row["judet"]."</td>";
			echo "</tr>";
			
			echo "<td align=\"left\"></td>";							
			echo "</tr>";		
			echo "<tr>";
			echo "<td align=\"left\"></td>";						
			echo "</tr>";
			
			echo "</table>";


	$query2="SELECT *,DATE_FORMAT(data_doc,'%d-%m-%Y') AS data_doc FROM chitante WHERE id=".$wid_ch;
	$result2=mysql_query($query2) or die("Interogare esuata: ".mysql_error());
	
	while ($row2 = mysql_fetch_array( $result2))
	{
			echo "<table style=\"font-size:11pt; width:30%; margin-top:0px;\" align=\"center\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
			echo "<br>";
			echo "<td align=\"center\" style=\"font-size:12pt;margin-top:150px; height:20%;\">";
			echo "<br>";
			echo "<b>CHITANTA</b>";
			echo "</td>";
			echo "<br>";
			echo "<table style=\"font-size:11pt; width:40%; margin-top:0px;border-collaps:collaps;\" align=\"center\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\">";
			echo "<br>";
			echo "<tr>";
			echo "<td  width=\"9%\">Serie / nr. &nbsp</td>";
			echo "<td align=\"center\" width=\"11%\"><B>".$row2["serie_doc"]."_".$row2["nr_doc"]."</B></td>";
			echo "</tr>";
			echo "<tr>";
			echo "<td width=\"9%\">Data &nbsp</td>";
			echo "<td align=\"center\" width=\"11%\"><B>".$row2["data_doc"]."</B></td>";
			echo "</tr>";
			echo "</table>";
			
		$query3="SELECT * FROM copii where codcopil=\"".$_POST["codcopil"]."\"";
		$result3=mysql_query($query3) or die("Interogare esuata: ".mysql_error());	
	
		while ($row3 = mysql_fetch_array( $result3))
		{
			$query4="SELECT * FROM grupe where codgrp=\"".$row3["codgrp"]."\"";
			$result4=mysql_query($query4) or die("Interogare esuata: ".mysql_error());	
			
			$wcodcopil = $row3["codcopil"];
			
			while ($row4 = mysql_fetch_array( $result4))
			{
			    $val_text = convert_number_to_words("".$row2["val_doc"]."")."";
				
				echo "<br>";
				echo "<table style=\"font-size:11pt; width:90%; margin-top:0px;\" align=\"center\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
				echo "<br>";
				echo "<tr>";
				echo "<td style=\"align:left;\">Am &nbsp primit &nbsp de &nbsp la :&nbsp";
//				echo "<input type=\"text\" name=\"nume\" size=\"40\" value=\"\">"; 
				echo "".$row2["platitor"]."";
				echo "</TD>";
				echo "</TR>";
				echo "<tr>";
				echo "<td style=\"align:left;\">";
				echo "Adresa : ";
//				echo "<input type=\"text\" name=\"adresa\" size=\"51\" value=\"\">"; 
				echo "".$row3["adresa"]."";
				echo "</TD>";
				echo "</TR>";
				echo "<tr>";
				echo "<td style=\"align:left;\">";
				echo "Suma : ".$row2["val_doc"]." &nbsp lei &nbsp (".$val_text." lei) &nbsp ";
				echo "</TD>";
				echo "</TR>";
				echo "<TR>";
				echo "<td style=\"align:left;\">Reprezentand :&nbsp c/v &nbsp masa &nbsp pentru &nbsp prescolarul: &nbsp ".$row3["nume"]." ".$row3["prenume"]." &nbsp de &nbsp la &nbsp ".$row4["dengrp"]." &nbsp - &nbsp ".$row2["reprezentand"].".</td>";
				echo "</td>";
				echo "</tr>";
				echo "</table>";
			}
		}
	}	
			echo "<br>";
			echo "<table style=\"font-size:10pt; width:8%; margin-top:0px;\" align=\"left\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";	
			echo "<tr>";
			echo "<td>";
			echo "<P>&nbsp</P>";
			echo "<P>&nbsp</P>";
			echo $wcodcopil;
			echo "</td>";
			echo "</tr>";
			echo "</table>";

			echo "<table style=\"font-size:11pt; width:20%; margin-top:0px;\" align=\"LEFT\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";	
			echo "<tr>";
			echo "<td align=\"right\">";
			echo "Platitor,";
			echo "</td>";
			echo "</tr>";
			echo "</table>";
			
			echo "<table style=\"font-size:11pt; width:40%; margin-top:0px;\" align=\"right\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";	
			echo "<tr>";
			echo "<td>";
			echo "Casier,";
			echo "<BR>";
			echo $_POST["nume_log"]." ".$_POST["prenume_log"];
			echo "</td>";
			echo "</tr>";
			echo "</table>";
			
		echo "</TABLE>";
			
echo "</div>";		

mysql_close($connection);	
}				
		
if($_POST["actiune"]=="IMPRIMARE")
{

	echo "<BODY id=\"bg_list\">";
echo "<div class=\"chitanta1\">";
		echo "<CENTER>";
		
		$connection=mysql_connect("$host","$username","$password") or die("Nu aveti acces la server");
		$baza="apponlin_".$_POST["aplic"]."_".$_POST["unit"];  
		$db=mysql_select_db($baza,$connection) or die("Nu puteti selecta Baza de date ".$baza);

	echo "<INPUT TYPE=\"HIDDEN\" NAME=\"chitanta\" VALUE=\"".$_POST["actiune"]."\">";
//	$wid_ch=substr($_POST["actiune"],1,strpos($_POST["actiune"],'-',1)-1);
	

	echo "<TABLE  cellSpacing=0 cellPadding=0 width=\"45%; height:100%;\" border=0>";
	echo "<TD colspan=\"7\" align=\"right\" height=\"35\">";
	echo "<input type=\"button\" class=\"noPrint\" onClick=\"window.print()\" value=\"PRINTARE\">";
	echo "<button type=\"button\" class=\"noPrint\" onclick=\"javascript:window.close()\">INAPOI</button>";
	echo "</TR>";
	echo "</TABLE>";

		echo "<table bgcolor=white class=\"table20\" style=\"font-size:10pt;border-color:silver;border-style:solid;\" align=\"center\" border=\"1\" cellspacing=\"0\" cellpadding=\"5\">";
		echo "<tr>";
		echo "<td align=\"center\" style=\"font-size:12pt;margin-top:150px; height:20%;\">";
	//	echo "<p class=\"title2\" align=\"center\" >";
					
		$query="SELECT * FROM unitate";
		$result=mysql_query($query) or die("Interogare esuata: ".mysql_error());
		$row=mysql_fetch_array($result);
				
			echo "<table style=\"font-size:9pt; width:30%; float:left; margin-top:3%;\" align=\"left\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";	
			echo "<tr>";
//			echo "<img src=\"img\stema.png\" height=35% width=15% align=\"left\" style=\"margin-right:2%;\" class=\"img1\">";
			echo "<td align=\"left\" style=\"font-size:12pt;\"><B>ROMANIA</B></td>";
			echo "</tr>";			
			echo "<tr>";
			echo "<td>&nbsp</td>";
			echo "</tr>";			
			echo "<tr>";
			echo "<td align=\"left\" style=\"font-size:12pt;\"><u>".$row["denunit"]."</u></td>";
			echo "</tr>";
			echo "<tr>";
			echo "<td>&nbsp</td>";
			echo "</tr>";
			echo "<tr>";
			echo "<td align=\"left\">Cod Fiscal: ".$row["cf"]."</td>";
			echo "</tr>";	
			echo "<tr>";
			echo "<td align=\"left\">Adresa: ".$row["adresa"]."</td>";
			echo "</tr>";
			echo "<td align=\"left\">Cont IBAN:</td>";							
			echo "</tr>";		
			echo "<tr>";
			echo "<td align=\"left\">Banca:</td>";						
			echo "</tr>";
			echo "</table>";


	$query2="SELECT *,DATE_FORMAT(data_doc,'%d-%m-%Y') AS data_doc FROM chitante WHERE id=\"".$_POST["id_chit"]."\"";
	$result2=mysql_query($query2) or die("Interogare esuata: ".mysql_error());
	
	while ($row2 = mysql_fetch_array( $result2))
	{
			echo "<table style=\"font-size:11pt; width:30%; margin-top:0px;\" align=\"center\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
			echo "<br>";
			echo "<td align=\"center\" style=\"font-size:12pt;margin-top:150px; height:20%;\">";
			echo "<br>";
			echo "<b>CHITANTA</b>";
			echo "</td>";
			echo "<br>";
			echo "<table style=\"font-size:11pt; width:40%; margin-top:0px;border-collaps:collaps;\" align=\"center\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\">";
			echo "<br>";
			echo "<tr>";
			echo "<td  width=\"9%\">Serie / nr. &nbsp</td>";
			echo "<td align=\"center\" width=\"11%\"><B>".$row2["serie_doc"]."_".$row2["nr_doc"]."</B></td>";
			echo "</tr>";
			echo "<tr>";
			echo "<td width=\"9%\">Data &nbsp</td>";
			echo "<td align=\"center\" width=\"11%\"><B>".$row2["data_doc"]."</B></td>";
			echo "</tr>";
			echo "</table>";
			
		$query3="SELECT * FROM copii where codcopil=\"".$_POST["codcopil"]."\"";
		$result3=mysql_query($query3) or die("Interogare esuata: ".mysql_error());	
	
		while ($row3 = mysql_fetch_array( $result3))
		{
			$query4="SELECT * FROM grupe where codgrp=\"".$row3["codgrp"]."\"";
			$result4=mysql_query($query4) or die("Interogare esuata: ".mysql_error());	
			
			$wcodcopil = $row3["codcopil"];
			
			while ($row4 = mysql_fetch_array( $result4))
			{
			    $val_text = convert_number_to_words("".$row2["val_doc"]."")."";
				
				echo "<br>";
				echo "<table style=\"font-size:11pt; width:80%; margin-top:0px;\" align=\"center\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
				echo "<br>";
				echo "<tr>";
				echo "<td>";
				echo "<td style=\"align:left;\">Am &nbsp primit &nbsp de &nbsp la &nbsp";
				echo "<B>".$_POST["nume"]."</B>";	
				echo "&nbsp  suma &nbsp de &nbsp <b>".$row2["val_doc"]."</b> &nbsp lei,"; 
				echo "<br>";
				echo "adica <B> &nbsp(".$val_text." lei)&nbsp </B>";
				echo " reprezentand &nbsp plata &nbsp taxei &nbsp de &nbsp gradinita &nbsp pentru &nbsp ";
				echo "<B>".$row3["nume"]." ".$row3["prenume"]."</B> &nbsp de &nbsp la &nbsp <B>".$row4["dengrp"]."</B> &nbsp.</td>";
				echo "</td>";
				echo "</tr>";
				echo "</table>";
			}
		}
	}	
			echo "<br>";
			echo "<table style=\"font-size:10pt; width:8%; margin-top:0px;\" align=\"left\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";	
			echo "<tr>";
			echo "<td>";
			echo "<P>&nbsp</P>";
			echo "<P>&nbsp</P>";
			echo $wcodcopil;
			echo "</td>";
			echo "</tr>";
			echo "</table>";

			echo "<br>";
			echo "<table style=\"font-size:10pt; width:40%; margin-top:0px;\" align=\"right\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";	
			echo "<tr>";
			echo "<td>";
			echo "<P>Casier,</P>";
			echo $_POST["nume_log"]." ".$_POST["prenume_log"];
			echo "</td>";
			echo "</tr>";
			echo "</table>";
			
		echo "</TABLE>";
echo "</div>";		
//******************************************
	echo "<br>";	
	echo "<table align=\"center\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
	echo "<br>";
	echo "<tr>";
	echo "<br>";
	echo "<td>&nbsp</td>";
	echo "<br>";
	echo "</tr>";
	echo "<tr>";
	echo "<td>&nbsp</td>";
	echo "</tr>";
	echo "<tr>";
//	echo "<td>&nbsp</td>";
	echo "</tr>";
	echo "<HR width=\"100%\" size=\"2px\" align=\"center\" noshade=\"noshade\">";
	echo "</table>";	
//******************************************
echo "<div class=\"chitanta2\">";

	echo "<INPUT TYPE=\"HIDDEN\" NAME=\"chitanta\" VALUE=\"".$_POST["actiune"]."\">";
	$wid_ch=substr($_POST["actiune"],1,strpos($_POST["actiune"],'-',1)-1);
	

	echo "<TABLE  cellSpacing=0 cellPadding=0 width=\"45%; height:100%;\" border=0>";
	echo "<TD colspan=\"7\" align=\"right\" height=\"35\">";
	echo "<input type=\"button\" class=\"noPrint\" onClick=\"window.print()\" value=\"PRINTARE\">";
	echo "<button type=\"button\" class=\"noPrint\" onclick=\"javascript:window.close()\">INAPOI</button>";
	echo "</TR>";
	echo "</TABLE>";

		echo "<table bgcolor=white class=\"table20\" style=\"font-size:10pt;border-color:silver;border-style:solid;\" align=\"center\" border=\"1\" cellspacing=\"0\" cellpadding=\"5\">";
		echo "<tr>";
		echo "<td align=\"center\" style=\"font-size:12pt;margin-top:150px; height:20%;\">";
	//	echo "<p class=\"title2\" align=\"center\" >";
					
		$query="SELECT * FROM unitate";
		$result=mysql_query($query) or die("Interogare esuata: ".mysql_error());
		$row=mysql_fetch_array($result);
				
			echo "<table style=\"font-size:9pt; width:30%; float:left; margin-top:3%;\" align=\"left\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";	
			echo "<tr>";
//			echo "<img src=\"img\stema.png\" height=35% width=15% align=\"left\" style=\"margin-right:2%;\" class=\"img1\">";
			echo "<td align=\"left\" style=\"font-size:12pt;\"><B>ROMANIA</B></td>";
			echo "</tr>";			
			echo "<tr>";
			echo "<td>&nbsp</td>";
			echo "</tr>";			
			echo "<tr>";
			echo "<td align=\"left\" style=\"font-size:12pt;\"><u>".$row["denunit"]."</u></td>";
			echo "</tr>";
			echo "<tr>";
			echo "<td>&nbsp</td>";
			echo "</tr>";
			echo "<tr>";
			echo "<td align=\"left\">Cod Fiscal: ".$row["cf"]."</td>";
			echo "</tr>";	
			echo "<tr>";
			echo "<td align=\"left\">Adresa: ".$row["adresa"]."</td>";
			echo "</tr>";
			echo "<td align=\"left\">Cont IBAN:</td>";							
			echo "</tr>";		
			echo "<tr>";
			echo "<td align=\"left\">Banca:</td>";						
			echo "</tr>";
			echo "</table>";


	$query2="SELECT *,DATE_FORMAT(data_doc,'%d-%m-%Y') AS data_doc FROM chitante WHERE id=\"".$_POST["id_chit"]."\"";
	$result2=mysql_query($query2) or die("Interogare esuata: ".mysql_error());
	
	while ($row2 = mysql_fetch_array( $result2))
	{
			echo "<table style=\"font-size:11pt; width:30%; margin-top:0px;\" align=\"center\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
			echo "<br>";
			echo "<td align=\"center\" style=\"font-size:12pt;margin-top:150px; height:20%;\">";
			echo "<br>";
			echo "<b>CHITANTA</b>";
			echo "</td>";
			echo "<br>";
			echo "<table style=\"font-size:11pt; width:40%; margin-top:0px;border-collaps:collaps;\" align=\"center\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\">";
			echo "<br>";
			echo "<tr>";
			echo "<td  width=\"9%\">Serie / nr. &nbsp</td>";
			echo "<td align=\"center\" width=\"11%\"><B>".$row2["serie_doc"]."_".$row2["nr_doc"]."</B></td>";
			echo "</tr>";
			echo "<tr>";
			echo "<td width=\"9%\">Data &nbsp</td>";
			echo "<td align=\"center\" width=\"11%\"><B>".$row2["data_doc"]."</B></td>";
			echo "</tr>";
			echo "</table>";
			
		$query3="SELECT * FROM copii where codcopil=\"".$_POST["codcopil"]."\"";
		$result3=mysql_query($query3) or die("Interogare esuata: ".mysql_error());	
	
		while ($row3 = mysql_fetch_array( $result3))
		{
			$query4="SELECT * FROM grupe where codgrp=\"".$row3["codgrp"]."\"";
			$result4=mysql_query($query4) or die("Interogare esuata: ".mysql_error());	
			
			$wcodcopil = $row3["codcopil"];
			
			while ($row4 = mysql_fetch_array( $result4))
			{
			    $val_text = convert_number_to_words("".$row2["val_doc"]."")."";
				
				echo "<br>";
				echo "<table style=\"font-size:11pt; width:80%; margin-top:0px;\" align=\"center\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
				echo "<br>";
				echo "<tr>";
				echo "<td>";
				echo "<td style=\"align:left;\">Am &nbsp primit &nbsp de &nbsp la &nbsp";
				echo "<B>".$_POST["nume"]."</B>"; 	
				echo "&nbsp  suma &nbsp de &nbsp <b>".$row2["val_doc"]."</b> &nbsp lei,"; 
				echo "</br>";
				echo "adica <B> &nbsp(".$val_text." lei)&nbsp </B>";
				echo "reprezentand &nbsp plata &nbsp taxei &nbsp de &nbsp gradinita &nbsp pentru &nbsp ";
				echo "<B>".$row3["nume"]." ".$row3["prenume"]."</B> &nbsp de &nbsp la &nbsp <B>".$row4["dengrp"]."</B> &nbsp.</td>";
				echo "</td>";
				echo "</tr>";
				echo "</table>";
			}
		}
	}	
			echo "<br>";
			echo "<table style=\"font-size:10pt; width:8%; margin-top:0px;\" align=\"left\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";	
			echo "<tr>";
			echo "<td>";
			echo "<P>&nbsp</P>";
			echo "<P>&nbsp</P>";
			echo $wcodcopil;
			echo "</td>";
			echo "</tr>";
			echo "</table>";

			echo "<br>";
			echo "<table style=\"font-size:10pt; width:40%; margin-top:0px;\" align=\"right\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";	
			echo "<tr>";
			echo "<td>";
			echo "<P>Casier,</P>";
			echo $_POST["nume_log"]." ".$_POST["prenume_log"];
			echo "</td>";
			echo "</tr>";
			echo "</table>";
			
		echo "</TABLE>";	
			
echo "</div>";		
echo "</form>";
mysql_close($connection);	
}					
?>
</CENTER>
</BODY>
</HTML>