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

<html lang="en">
<HEAD>
<TITLE>Evidenta elevi</TITLE>


<link rel="stylesheet" type="text/css" href="A21_stiluri1.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>

<script language="JavaScript" type="text/javascript">

$(document).ready(function() {
    $('#data_incep').each(function() {
        $(this).datepicker({ dateFormat: 'dd-mm-yy' });
    });
});

$(document).ready(function() {
    $('#data_fin').each(function() {
        $(this).datepicker({ dateFormat: 'dd-mm-yy' });
    });
});


$(document).ready(function() {
    $('#data_rap').each(function() {
        $(this).datepicker({ dateFormat: 'dd-mm-yy' });
    });
});

</script>

<script language="JavaScript" type="text/javascript">

var w3;
function target_popup3(form) {
		w3=window.open('', 'win03','width=600,height=190,top=300,left=350,toolbar=no, location=no,status=no,menubar=no,scrollbars=no,resizable=no');
		form.target = 'win03';
}
var w4;
function target_popup4(form) {
		w4=window.open('', 'win04','width=1160,height=300,top=300,left=50,toolbar=no, location=no,status=no,menubar=no,scrollbars=no,resizable=no');
		form.target = 'win04';
}

var w5;
function target_popup5(form) {
		w5=window.open('', 'win05','width=1160,height=170,top=300,left=50,toolbar=no, location=no,status=no,menubar=no,scrollbars=no,resizable=no');
		form.target = 'win05';
}

var w10;
function target_popup10(form) {
		w10=window.open('', 'win10','width=600,height=540,top=205,left=610,resizeable,scrollbars');
		form.target = 'win10';
}
var w11;
function target_popup11(form) {
		w11=window.open('', 'win11','width=800,height=750,top=100,left=400,resizeable,scrollbars');
		form.target = 'win11';
}

var w12;
function target_popup12(form) {
		w12=window.open('', 'win12','width=1265,height=700,top=100,left=0,resizeable,scrollbars');
		form.target = 'win12';
}		
</script>

<script language="JavaScript" type="text/javascript">

function check1(elem) {
// document.getElementById('luna').disabled = !elem.selectedIndex;
	
var x=document.getElementById("grp").selectedIndex;
document.getElementById("grp_sel").value = document.getElementsByTagName("option")[x].value;

document.getElementById("dengrp_sel").value = document.getElementsByTagName("option")[x].text;
}
function check2(elem) {

var t = document.getElementById("luna");
	document.getElementById("denluna_sel").value = t.options[t.selectedIndex].text;
	
var v = document.getElementById("luna");
	document.getElementById("luna_sel").value = v.options[v.selectedIndex].value;
}

function check3(elem) {
if(document.getElementById("grp").value == "")
    document.getElementById("button").disabled=true;
else
    document.getElementById("button").disabled=false;
}

function check4(elem) {
if(document.getElementById("luna").value == "")
    document.getElementById("button1").disabled=true;
else
    document.getElementById("button1").disabled=false;
}

function check5(elem) {

var t = document.getElementById("grp");
	document.getElementById("dengrupa_sel").value = t.options[t.selectedIndex].text;
	
var v = document.getElementById("grp");
	document.getElementById("grupa_sel").value = v.options[v.selectedIndex].value;
}

</script>
</HEAD>
<BODY>

		
		
<?php
ob_start();
include 'javascripts.php';
include 'conectare.php';

if ($_POST["actiune"]=="INAPOI" and !isset($_POST["tip_act"]))
{	
			$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 "<TABLE class=\"table2\" cellSpacing=0 cellPadding=0 width=\"100%\" border=0>";
			echo "<tr>";
			echo "<td bgcolor=\"white\" colspan=\"20\" height=\"1px\"></td>";
			echo "</tr>";
			echo "<TR BGCOLOR=\"#4EAEF2\">";
			echo "<TD colspan=\"11\" class=\"style1\" height=\"25\" align=\"center\">";
			echo "<B> ".$_POST["den_aplic"]."</B>";
			echo "</TD>";
			echo "</TR>";
			echo "<tr>";
			echo "<td bgcolor=\"white\" colspan=\"20\" height=\"1px\"></td>";
			echo "</tr>";
			echo "<TR BGCOLOR=\"#A3D9FF\">";
			echo "<TD width=\"250\" class=\"style1\" colspan=\"2\" height=\"25\" align=\"left\"><B>Unitatea: &nbsp".$_POST["denunit"]."</B>";
			echo "</TD>";
			echo "<TD width=\"100\" class=\"style1\"  height=\"25\" align=\"left\"><B>An:".$_POST["an"]."</B>";
			echo "</TD>";
			echo "</tr>";
			echo "<tr>";
			echo "<td bgcolor=\"white\" colspan=\"20\" height=\"1px\"></td>";
			echo "</tr>";
			echo "<tr>";
			echo "<FORM NAME=\"elevi\" method=\"POST\" action=\"A21_elevi.php\" TARGET=\"win01\">";
			include "A21_param1.php";
			
			echo "<TD bgcolor=\"#CDE6F9\" colspan=\"25\" height=\"35\" align=\"right\">";
			echo "<INPUT TYPE=\"button\" onClick=\"window.location='index.php'\" id=\"button3\" NAME=\"actiune\" VALUE=\"INAPOI\">";  
			echo "</td>";
			echo "</tr>";
			echo "</table>";
			
			echo "<table class=\"table1\" cellpadding=\"0\" cellspacing=\"0\">"; 
		
			echo "<tr>";
			echo "<div style= \"margin-top:0px;\">";
			echo "</td>";
			echo "</tr>";
			echo "<tr>";
			echo "</tr>";
			
			$query="SELECT * FROM grupe";
			$result=mysql_query($query) or die("Interogare esuata: ".mysql_error());
			
			echo "<tr>";
			echo "<div style= \"margin-top:0px;\">";
			echo "<TD class=\"td1\" align=\"center\">GRUPA:&nbsp</TD>";
			echo "</tr>";
			echo "<tr>";
			echo "<TD colspan=\"15\" align=\"center\">";
			echo "<SELECT onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\" id=\"grp\" NAME=\"grp\" onChange=\"check1(this);\" onClick=\"check3(this);\" onMouseUp=\"check5(this);\">";
			echo "<OPTION selected value =".$_POST["grp_sel"].">".$_POST["dengrp_sel"]."</OPTION>";
			while($row=mysql_fetch_array($result))
			{	
				echo "<OPTION value=".$row["codgrp"].">".$row["dengrp"]."</OPTION>";
			}
			echo "</select>";
			echo "</TD>";
			echo "</tr>";
			echo "</div>";
	
			$query="SELECT * FROM luni";
			$result=mysql_query($query) or die("Interogare esuata: ".mysql_error());
			
			echo "<tr>";
			echo "<div style= \"margin-top:0px;\">";
			echo "<TD class=\"td1\" align=\"center\">LUNA:&nbsp</TD>";
			echo "</td>";
			echo "</tr>";
			echo "<tr>";
			echo "<TD colspan=\"15\" align=\"center\">";
			echo "<SELECT onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\" id=\"luna\" NAME=\"luna\" onChange=\"check2(this);\" onClick=\"check4(this);\">";
			echo "<OPTION selected value =".$_POST["luna_sel"].">".$_POST["denluna_sel"]."</OPTION>";
			while($row=mysql_fetch_array($result))
			{		
				echo "<OPTION value=".$row["luna"].">".$row["denluna"]."</OPTION>";
			}
			echo "</select>";
			echo "</TD>";
			echo "</tr>";
			echo "</div>";

			echo "<INPUT TYPE=\"HIDDEN\" NAME=\"luna_sel\" id=\"luna_sel\" value=\"".$_POST["luna_sel"]."\">";
			echo "<INPUT TYPE=\"HIDDEN\" NAME=\"denluna_sel\" id=\"denluna_sel\" value=\"".$_POST["denluna_sel"]."\">";
			echo "<INPUT TYPE=\"HIDDEN\" NAME=\"grp_sel\" id=\"grp_sel\" value=\"".$_POST["grp_sel"]."\">";
			echo "<INPUT TYPE=\"HIDDEN\" NAME=\"dengrp_sel\" id=\"dengrp_sel\" value=\"".$_POST["dengrp_sel"]."\">";
			
			echo "<tr>";
			echo "<div style= \"margin-top:0px;\">";
			echo "<TD class=\"td1\">EDITARE:&nbsp</TD>";
			echo "</td>";
			echo "</tr>";
			
			echo "<tr>";
			echo "<td height=\"25px\"><input type=\"submit\" id=\"button1\" name=\"actiune\" value=\"EVIDENTA ELEVI\" ></td>";   
			echo "</tr>";  
			echo "</div>";
			
			echo "<tr>";
			echo "<div style= \"margin-top:0px;\">";
			echo "<TD class=\"td1\"> REZULTATE:</TD>";
			echo "</tr>";

			echo "<tr>";
			echo "<td height=\"25px\"><input type=\"submit\" id=\"button1\" name=\"actiune\" value=\"BORDEROU DEBITE SI PLATI\" ></td>";   
			echo "</tr>";  
			echo "<tr>";
			echo "<td height=\"25px\"><input type=\"submit\" id=\"button1\" name=\"actiune\" value=\"BORDEROU INCASARI\" ></td>";   
			echo "</tr>";  
			echo "<tr>";
			echo "<td height=\"25px\"><input type=\"submit\" id=\"button1\" name=\"actiune\" value=\"RECAPITULATIE\" ></td>";   
			echo "</tr>";  
			echo "</FORM>";
			
			echo "<tr>";
			echo "<TD class=\"td1\"> UTILITARE:</TD>";
			echo "</tr>";
			
			echo "<tr>";
			echo "<TD colspan=\"10\" align=\"left\">";
			echo "</td>";
			echo "</tr>";

			echo "<FORM name=\"form41\" ACTION=\"A21_tarife.php\" METHOD=\"POST\" onsubmit=\"target_popup5(this)\">";
			include "A21_param1.php";
			
			echo "<INPUT TYPE=\"HIDDEN\" NAME=\"grupa_sel\" id=\"grupa_sel\" value=\"".$_POST["grp_sel"]."\">";
			echo "<INPUT TYPE=\"HIDDEN\" NAME=\"dengrupa_sel\" id=\"dengrupa_sel\" value=\"".$_POST["dengrp_sel"]."\">";
			
			echo "<tr>";
			echo "<td height=\"25px\"><input type=\"submit\" id=\"button\" name=\"actiune\" value=\"STABILIRE TARIFE\" ></td>";   
			echo "</tr>";  
			echo "</form>";
			echo "<FORM name=\"form41\" ACTION=\"A03_definire_date.php\" METHOD=\"POST\" onsubmit=\"target_popup10(this)\">";	
			include "A21_param1.php";
			
			echo "<tr>";
			echo "<td height=\"25px\"><input type=\"submit\" id=\"button1\" name=\"actiune\" value=\"DEFINIRE DATE UNITATE\" ></td>";   
			echo "</tr>";  
			echo "</form>";

			echo "<FORM name=\"form41\" ACTION=\"A03_instruct.php\" METHOD=\"POST\" onsubmit=\"target_popup11(this)\">";	
			include "A21_param1.php";

			echo "<tr>";
			echo "<td height=\"25px\"><input DISABLED type=\"submit\" id=\"button1\" name=\"actiune\" value=\"SCHIMBARE PAROLA\"></td>";   
			echo "</tr>";  

			echo "<tr>";
			echo "<td height=\"25px\"><input type=\"submit\" id=\"button1\" name=\"actiune\" value=\"INSTRUCTIUNI DE UTILIZARE\" ></td>";  
			echo "</tr>";  
			
			echo "<tr>";
			echo "<td>&nbsp</td>";  
			echo "</tr>";
			echo "<tr>";
			echo "<td>&nbsp</td>";  			
			echo "</tr>";

		echo "</div>";
		echo "</form>";
		echo "</table>";

}
	
if ($_POST["actiune"]=="EVIDENTA ELEVI" 
		OR $_POST["actiune"]=="CONFIRM" AND isset($_POST["tip_act"]) and $_POST["tip_act"]=="ELEV"
		OR $_POST["actiune"]=="MODIFIC" AND isset($_POST["tip_act"]) and $_POST["tip_act"]=="ELEV"
		OR $_POST["actiune"]=="STERGE"  AND isset($_POST["tip_act"]) and $_POST["tip_act"]=="ELEV"
		
		OR $_POST["actiune"]=="INAPOI"  AND isset($_POST["tip_act"]) and $_POST["tip_act"]=="PLA"
		OR $_POST["actiune"]=="INAPOI"  AND isset($_POST["tip_act"]) and $_POST["tip_act"]=="DEB"
		or substr($_POST["actiune"],0,4)=="CAUT")
{
			echo "<CENTER>";
			echo "<TABLE class=\"table2\" cellSpacing=0 cellPadding=0 width=\"100%\" border=0>";
			echo "<tr>";
			echo "<td bgcolor=\"white\" colspan=\"20\" height=\"1px\"></td>";
			echo "</tr>";
			echo "<TR BGCOLOR=\"#4EAEF2\">";
			echo "<TD colspan=\"11\" class=\"style1\" height=\"25\" align=\"center\">";
			echo "<B> ".$_POST["den_aplic"]."</B>";
			echo "</TD>";
			echo "</TR>";
			echo "<tr>";
			echo "<td bgcolor=\"white\" colspan=\"20\" height=\"1px\"></td>";
			echo "</tr>";
			echo "<TR BGCOLOR=\"#A3D9FF\">";
			echo "<TD width=\"250\" class=\"style1\" colspan=\"2\" height=\"25\" align=\"left\"><B>Unitatea: &nbsp".$_POST["denunit"]."</B>";
			echo "</TD>";
			echo "<TD width=\"100\" class=\"style1\"  height=\"25\" align=\"left\"><B>An:".$_POST["an"]."</B>";
			echo "</TD>";
			echo "</td>";
			echo "</tr>";
			echo "<tr>";
			echo "<td bgcolor=\"white\" colspan=\"20\" height=\"1px\"></td>";
			echo "</tr>";
			echo "</table>";
			
			echo "<TABLE class=\"table2\" cellSpacing=0 cellPadding=0 width=\"100%\" border=0>";
			echo "<tr>";
			echo "<td colspan=\"20\" height=\"1px\"></td>";
			echo "</tr>";
			echo "</table>";
			
			$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=\"form\" ACTION=\"A21_elevi.php\" METHOD=\"POST\" onsubmit=\"target_popup3(this)\">";
			include 'A21_param1.php';
			
			echo "<TABLE class=\"style1\" cellSpacing=0 cellPadding=0 width=\"100%\" border=0>";				
			echo "<TR>";
			echo "<TD align=\"center\" class=\"td_print2\">";
			echo "<B>EVIDENTA ELEVI</B>";
			echo "<BR>";
			echo "</TD>";
			echo "</TR>";
			
			echo "<TR>";
			echo "<TD align=\"center\" class=\"td_print2\">";
			echo "<B>LUNA:&nbsp<U>".$_POST["denluna_sel"]."</U>&nbsp &nbsp  &nbsp &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp ANUL:&nbsp<U>".$_POST["an"]."</U></B>";
			echo "<BR>";
			echo "</TD>";
			echo "</TR>";
			echo "<TR>";
			echo "<TD align=\"center\" class=\"td_print2\">";
			echo "<B>GRUPA:&nbsp<U>".$_POST["dengrp_sel"]."</U>&nbsp &nbsp &nbsp &nbsp &nbsp</B>";
			echo "<BR>";
			echo "</TD>";
			echo "</TR>";
			echo "</TABLE>";

			echo "<TABLE cellSpacing=0 cellPadding=0 width=\"30%; height:100%;\" border=0 align=\"right\">";
			echo "<TR>";
			echo "<TD align=\"right\" height=\"35\">";
			echo "<INPUT TYPE=\"SUBMIT\" class=\"noPrint\" NAME=\"actiune\" VALUE=\"ADAUG\">";
			echo "<INPUT TYPE=\"HIDDEN\" NAME=\"tip_act\" VALUE=\"ELEV\">";
			if(isset($_POST["sel_codelev"]))
			{
				echo "<INPUT TYPE=\"HIDDEN\" NAME=\"sel_codelev\" VALUE=\"".$_POST["sel_codelev"]."\">";
			}
			if(isset($_POST["sel_elevul"]))
			{
				echo "<INPUT TYPE=\"HIDDEN\" NAME=\"sel_elevul\" VALUE=\"".$_POST["sel_elevul"]."\">";
			}
			echo "</TD>";
			echo "</FORM>";
			
			echo "<FORM NAME=\"form\" ACTION=\"A21_elevi.php\" METHOD=\"POST\" TARGET=\"win01\">";
			include 'A21_param1.php';
			echo "<TD align=\"left\" height=\"35\">";
			echo "<input type=\"submit\" class=\"noPrint\" name=\"actiune\" value=\"INAPOI\">";
			if(isset($_POST["sel_codelev"]))
			{
				echo "<INPUT TYPE=\"HIDDEN\" NAME=\"sel_codelev\" VALUE=\"".$_POST["sel_codelev"]."\">";
			}
			if(isset($_POST["sel_elevul"]))
			{
				echo "<INPUT TYPE=\"HIDDEN\" NAME=\"sel_elevul\" VALUE=\"".$_POST["sel_elevul"]."\">";
			}
			echo "</TD>";
			echo "</TR>";
			echo "</TABLE>";
			
			
	IF ($_POST["actiune"]=="CONFIRM" and isset($_POST["tip_act"]) AND $_POST["tip_act"] == "ELEV")
	{
		include 'A21_param1.php';
	
			$wcodelev = $_POST["codelev"];
			$wnume=$_POST["nume_".$wcodelev];						
			$wprenume=$_POST["prenume_".$wcodelev];

			$query="SELECT * FROM elevi where codgrp=\"".$_POST["grp_sel"]."\"";
			$result=mysql_query($query) or die("Interogare esuata: ".mysql_error());
			$row = mysql_fetch_array( $result);
/*	
			$query3="INSERT INTO elevi (codgrp,codelev,nume,prenume,t_val00,t_val01,t_val02,t_val03,t_val04,t_val05,t_val06,t_val07,t_val08,t_val09,t_val10,t_val11,t_val12)";
			$query3=$query3."VALUES (\"".$_POST["grp_sel"]."\",\"".$wcodelev."\",\"".$wnume."\",\"".$wprenume."\",";
			$query3=$query3."\"".$row["t_val00"]."\",\"".$row["t_val01"]."\",\"".$row["t_val02"]."\",\"".$row["t_val03"]."\",\"".$row["t_val04"]."\",";
			$query3=$query3."\"".$row["t_val05"]."\",\"".$row["t_val06"]."\",\"".$row["t_val07"]."\",\"".$row["t_val08"]."\",\"".$row["t_val09"]."\",";
			$query3=$query3."\"".$row["t_val10"]."\",\"".$row["t_val11"]."\",\"".$row["t_val12"]."\")";
			$result3=mysql_query($query3) or die("Interogare esuata: ".mysql_error());		
*/			
			$query3="INSERT INTO elevi (codgrp,codelev,nume,prenume,t_val00,t_val01,t_val02,t_val03,t_val04,t_val05,t_val06,t_val07,t_val08,t_val09,t_val10,t_val11,t_val12)";
			$query3=$query3."VALUES (\"".$_POST["grp_sel"]."\",\"".$wcodelev."\",\"".$wnume."\",\"".$wprenume."\",";
			$query3=$query3."'0','0','0','0','0','0','0','0','0','0','0','0','0')";
			$result3=mysql_query($query3) or die("Interogare esuata: ".mysql_error());	
	}
	
	if ($_POST["actiune"]=="MODIFIC" and isset($_POST["tip_act"]) AND $_POST["tip_act"] == "ELEV")
	{	
		include 'A21_param1.php';
		
			$wcodelev = $_POST["codelev"];
			$wnume=$_POST["nume_".$wcodelev];						
			$wprenume=$_POST["prenume_".$wcodelev];
			
			$query4="UPDATE elevi set nume=\"".$wnume."\", prenume=\"".$wprenume."\" WHERE codelev = \"".$_POST["codelev"]."\"";
			$result4=mysql_query($query4) or die("Interogare esuata: ".mysql_error());
	}
	
	if ($_POST["actiune"]=="STERGE" and isset($_POST["tip_act"]) AND $_POST["tip_act"] == "ELEV")
	{
		include 'A21_param1.php';
		
			$wcodelev = $_POST["codelev"];

			$query4="DELETE FROM elevi WHERE codelev = \"".$_POST["codelev"]."\"";
			$result4=mysql_query($query4) or die("Interogare esuata: ".mysql_error());
	}

	
	
// *****************				
		if(isset($_POST["sel_codelev"]))
		{
			$wsel_codelev=$_POST["sel_codelev"];
			echo "<INPUT TYPE=\"HIDDEN\" NAME=\"sel_codelev\" VALUE=\"".$_POST["sel_codelev"]."\">";
		}
		else
		{
			$wsel_codelev=" ";
		}
		if(isset($_POST["sel_elevul"]))
		{
			$wsel_elevul=$_POST["sel_elevul"];
			echo "<INPUT TYPE=\"HIDDEN\" NAME=\"sel_elevul\" VALUE=\"".$_POST["sel_elevul"]."\">";
		}
		else
		{
			$wsel_elevul=" ";
		}		
		
			echo "<TABLE cellSpacing=0 cellPadding=0 width=\"90%\" border=0>";
			echo "<TR>";
			echo "<TD colspan=\"1\" align=\"left\">";  
			echo "<INPUT name=\"sel_codelev\" SIZE=\"2\" type=\"text\" VALUE=\"".$wsel_codelev."\">";
			echo "</TD>";
			echo "<TD colspan=\"1\" align=\"left\">";  
			echo "<INPUT name=\"sel_elevul\" type=\"text\" VALUE=\"".$wsel_elevul."\">";
			echo "</TD>";
			echo "<TD colspan=\"1\" align=\"left\" height=\"30px\">";  
			echo "<INPUT TYPE=\"SUBMIT\" name=\"actiune\" id=\"button10_1\" VALUE=\"CAUT\">";
			echo "</TD>";
			echo "</TR>";
				
// *******************				

				
// ************************************
				if($_POST["actiune"]=="CAUT" or isset($_POST["sel_codelev"]) or isset($_POST["sel_elevul"]))
				{
					$wcaut_codelev=strtoupper(trim($_POST["sel_codelev"]));
					$wlen_codelev=strlen($wcaut_codelev);
					$wcaut_elevul=strtoupper(trim($_POST["sel_elevul"]));
					$wlen_elevul=strlen($wcaut_elevul);
					
					$query="SELECT * FROM elevi WHERE codgrp=\"".substr($_POST["grp_sel"],0,2)."\" ";
					if ($wlen_codelev<>0)
					{
						$query=$query."  and substr(upper(codelev),1,".$wlen_codelev.")=\"".$wcaut_codelev."\"";
					}
					if ($wlen_elevul<>0)
					{
						$query=$query."  and substr(upper(concat(nume,' ',prenume)),1,".$wlen_elevul.")=\"".$wcaut_elevul."\"";
					}
					
					$query=$query."  order by nume,prenume,codelev";
				}
				else
				{
					$query="SELECT * FROM elevi WHERE codgrp=\"".substr($_POST["grp_sel"],0,2)."\"  order by nume,prenume,codelev";
				}
				$result=mysql_query($query) or die("Interogare esuata: ".mysql_error());	
// ************************************
		
		echo "</FORM>";
			echo "<BR>";
			echo "<TR BGCOLOR=\"white\">";
			
			echo 	"<TH align=\"center\" width=\"4%\" class=\"td35\">Cod elev</TH>";					
			echo	"<TH align=\"center\" width=\"14%\"  class=\"td35\">Nume Prenume</TH>";	
			echo	"<TH align=\"center\" width=\"6%\" class=\"td35\">TipReg</TH>";		
			echo	"<TH align=\"center\" width=\"3%\" class=\"td35\">PREC</TH>";
			echo	"<TH align=\"center\" width=\"3%\" class=\"td35\">IAN</TH>";
			echo	"<TH align=\"center\" width=\"3%\" class=\"td35\">FEB</TH>";
			echo	"<TH align=\"center\" width=\"3%\" class=\"td35\">MAR</TH>";
			echo	"<TH align=\"center\" width=\"3%\" class=\"td35\">APR</TH>";
			echo	"<TH align=\"center\" width=\"3%\" class=\"td35\">MAI</TH>";
			echo	"<TH align=\"center\" width=\"3%\" class=\"td35\">IUN</TH>";
			echo	"<TH align=\"center\" width=\"3%\" class=\"td35\">IUL</TH>";
			echo	"<TH align=\"center\" width=\"3%\" class=\"td35\">AUG</TH>";
			echo	"<TH align=\"center\" width=\"3%\" class=\"td35\">SEP</TH>";
			echo	"<TH align=\"center\" width=\"3%\" class=\"td35\">OCT</TH>";
			echo	"<TH align=\"center\" width=\"3%\" class=\"td35\">NOI</TH>";
			echo	"<TH align=\"center\" width=\"3%\" class=\"td35\">DEC</TH>";
			echo	"<TH align=\"center\" width=\"3%\" class=\"td39\">TOTAL</TH>";
			
			echo "</TR>";
			
		$i=0;
		$debit_tot=0;
		$wlu=substr($_POST["luna_sel"],0,2);
		while($row = mysql_fetch_array( $result))	
		{ 	
			$debit_tot = $row["d_val00"] + $row["d_val01"] + $row["d_val02"] + $row["d_val03"] + $row["d_val04"] + $row["d_val05"] + $row["d_val06"] + $row["d_val07"] + $row["d_val08"] + $row["d_val09"] + $row["d_val10"] + $row["d_val11"] + $row["d_val12"];
			$platit_tot = $row["p_val01"] + $row["p_val02"] + $row["p_val03"] + $row["p_val04"] + $row["p_val05"] + $row["p_val06"] + $row["p_val07"] + $row["p_val08"] + $row["p_val09"] + $row["p_val10"] + $row["p_val11"] + $row["p_val12"];
			$rest_tot = $debit_tot - $platit_tot;
			if ($i-floor($i/2)*2==0)
			{
				echo "<TR class=\"tr4\" BGCOLOR=\"#FFFFFF\">";
			}
			else
			{
				echo "<TR class=\"tr4\" BGCOLOR=\"#EAEBEB\">";
			}
		
		echo "<TD width=\"2%\" height=\"30px\" align=\"center\">";
				
		echo "<FORM NAME=\"form\" ACTION=\"A21_elevi.php\" METHOD=\"POST\" onsubmit=\"target_popup3(this)\">";
		include 'A21_param1.php';
		echo "<input type=\"submit\" name=\"actiune\" class=\"noPrint9\" value='<".$row["codelev"].">'>";
		echo "<INPUT TYPE=\"HIDDEN\" NAME=\"tip_act\" VALUE=\"ELEV\">";
		if(isset($_POST["sel_codelev"]))
		{
			echo "<INPUT TYPE=\"HIDDEN\" NAME=\"sel_codelev\" VALUE=\"".$_POST["sel_codelev"]."\">";
		}
		if(isset($_POST["sel_elevul"]))
		{
			echo "<INPUT TYPE=\"HIDDEN\" NAME=\"sel_elevul\" VALUE=\"".$_POST["sel_elevul"]."\">";
		}
		echo "</FORM>";
		
				echo "</TD>";
				echo"<TD width=\"10%\" align=\"left\">";
				echo "&nbsp".trim($row["nume"])." ".trim($row["prenume"])."&nbsp";
				echo "</TD>";
				echo"<TD width=\"1%\" height=\"30px\" align=\"center\">";
				
		echo "<FORM NAME=\"form\" ACTION=\"A21_elevi.php\" METHOD=\"POST\" onsubmit=\"target_popup4(this)\">";
		include 'A21_param1.php';
		echo "<input type=\"submit\" class=\"noPrint6\" NAME=\"actiune\" value=\"D-".$row["codelev"]."\">";
		echo "<INPUT TYPE=\"HIDDEN\" NAME=\"tip_act\" VALUE=\"DEB\">";
		if(isset($_POST["sel_codelev"]))
		{
			echo "<INPUT TYPE=\"HIDDEN\" NAME=\"sel_codelev\" VALUE=\"".$_POST["sel_codelev"]."\">";
		}
		if(isset($_POST["sel_elevul"]))
		{
			echo "<INPUT TYPE=\"HIDDEN\" NAME=\"sel_elevul\" VALUE=\"".$_POST["sel_elevul"]."\">";
		}
		echo "</FORM>";
		
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "&nbsp".$row["d_val00"]."&nbsp";
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "&nbsp".$row["d_val01"]."&nbsp";
				if($wlu=="01")
				{
					$debit_ln=$row["d_val00"]+$row["d_val01"];
					echo "(<B>".$debit_ln."</B>)&nbsp";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "&nbsp".$row["d_val02"]."&nbsp";
				if($wlu=="02")
				{
					$debit_ln=$row["d_val00"]+$row["d_val01"]+$row["d_val02"];
					echo "(<B>".$debit_ln."</B>)&nbsp";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "&nbsp".$row["d_val03"]."&nbsp";
				if($wlu=="03")
				{
					$debit_ln=$row["d_val00"]+$row["d_val01"]+$row["d_val02"]+$row["d_val03"];
					echo "(<B>".$debit_ln."</B>)&nbsp";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "&nbsp".$row["d_val04"]."&nbsp";
				if($wlu=="04")
				{
					$debit_ln=$row["d_val00"]+$row["d_val01"]+$row["d_val02"]+$row["d_val03"]+$row["d_val04"];
					echo "(<B>".$debit_ln."</B>)&nbsp";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "&nbsp".$row["d_val05"]."&nbsp";
				if($wlu=="05")
				{
					$debit_ln=$row["d_val00"]+$row["d_val01"]+$row["d_val02"]+$row["d_val03"]+$row["d_val04"]+$row["d_val05"];
					echo "(<B>".$debit_ln."</B>)&nbsp";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "&nbsp".$row["d_val06"]."&nbsp";
				if($wlu=="06")
				{
					$debit_ln=$row["d_val00"]+$row["d_val01"]+$row["d_val02"]+$row["d_val03"]+$row["d_val04"]+$row["d_val05"]+$row["d_val06"];
					echo "(<B>".$debit_ln."</B>)&nbsp";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "&nbsp".$row["d_val07"]."&nbsp";
				if($wlu=="07")
				{
					$debit_ln=$row["d_val00"]+$row["d_val01"]+$row["d_val02"]+$row["d_val03"]+$row["d_val04"]+$row["d_val05"]+$row["d_val06"]+$row["d_val07"];
					echo "(<B>".$debit_ln."</B>)&nbsp";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "&nbsp".$row["d_val08"]."&nbsp";
				if($wlu=="08")
				{
					$debit_ln=$row["d_val00"]+$row["d_val01"]+$row["d_val02"]+$row["d_val03"]+$row["d_val04"]+$row["d_val05"]+$row["d_val06"]+$row["d_val07"]+$row["d_val08"];
					echo "(<B>".$debit_ln."</B>)&nbsp";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "&nbsp".$row["d_val09"]."&nbsp";
				if($wlu=="09")
				{
					$debit_ln=$row["d_val00"]+$row["d_val01"]+$row["d_val02"]+$row["d_val03"]+$row["d_val04"]+$row["d_val05"]+$row["d_val06"]+$row["d_val07"]+$row["d_val08"]+$row["d_val09"];
					echo "(<B>".$debit_ln."</B>)&nbsp";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "&nbsp".$row["d_val10"]."&nbsp";
				if($wlu=="10")
				{
					$debit_ln=$row["d_val00"]+$row["d_val01"]+$row["d_val02"]+$row["d_val03"]+$row["d_val04"]+$row["d_val05"]+$row["d_val06"]+$row["d_val07"]+$row["d_val08"]+$row["d_val09"]+$row["d_val10"];
					echo "(<B>".$debit_ln."</B>)&nbsp";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "&nbsp".$row["d_val11"]."&nbsp";
				if($wlu=="11")
				{
					$debit_ln=$row["d_val00"]+$row["d_val01"]+$row["d_val02"]+$row["d_val03"]+$row["d_val04"]+$row["d_val05"]+$row["d_val06"]+$row["d_val07"]+$row["d_val08"]+$row["d_val09"]+$row["d_val10"]+$row["d_val11"];
					echo "(<B>".$debit_ln."</B>)&nbsp";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "&nbsp".$row["d_val12"]."&nbsp";
				if($wlu=="12")
				{
					$debit_ln=$row["d_val00"]+$row["d_val01"]+$row["d_val02"]+$row["d_val03"]+$row["d_val04"]+$row["d_val05"]+$row["d_val06"]+$row["d_val07"]+$row["d_val08"]+$row["d_val09"]+$row["d_val10"]+$row["d_val11"]+$row["d_val12"];
					echo "(<B>".$debit_ln."</B>)&nbsp";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "<B>&nbsp $debit_tot &nbsp</B>";
				echo "</TD>";
				echo "</TR>";
				
			if ($i-floor($i/2)*2==0)
			{
				echo "<TR class=\"tr4\" BGCOLOR=\"#FFFFFF\">";
			}
			else
			{
				echo "<TR class=\"tr4\" BGCOLOR=\"#EAEBEB\">";
			}
		
				echo "<TD width=\"3%\" align=\"center\"> </TD>";
				echo"<TD width=\"13%\" align=\"left\">";
				echo " ";
				echo "</TD>";
				echo"<TD width=\"1%\" height=\"30px\" align=\"center\">";
				
		echo "<FORM NAME=\"form\" ACTION=\"A21_elevi.php\" METHOD=\"POST\" onsubmit=\"target_popup10(this)\">";
		include 'A21_param1.php';
		echo "<input type=\"submit\" class=\"noPrint6\" NAME=\"actiune\" value=\"P-".$row["codelev"]."\">";
		echo "<INPUT TYPE=\"HIDDEN\" NAME=\"tip_act\" VALUE=\"PLA\">";
		echo "<INPUT TYPE=\"HIDDEN\" NAME=\"nume\" VALUE=\"".$row["nume"]."\">";
		echo "<INPUT TYPE=\"HIDDEN\" NAME=\"prenume\" VALUE=\"".$row["prenume"]."\">";
		if(isset($_POST["sel_codelev"]))
		{
			echo "<INPUT TYPE=\"HIDDEN\" NAME=\"sel_codelev\" VALUE=\"".$_POST["sel_codelev"]."\">";
		}
		if(isset($_POST["sel_elevul"]))
		{
			echo "<INPUT TYPE=\"HIDDEN\" NAME=\"sel_elevul\" VALUE=\"".$_POST["sel_elevul"]."\">";
		}
		echo "</FORM>";
		
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo " ";
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "&nbsp".$row["p_val01"]."&nbsp";
				if($wlu=="01")
				{
					$platit_ln=$row["p_val01"];
					echo "(<B>".$platit_ln."</B>)&nbsp";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "&nbsp".$row["p_val02"]."&nbsp";
				if($wlu=="02")
				{
					$platit_ln=$row["p_val01"]+$row["p_val02"];
					echo "(<B>".$platit_ln."</B>)&nbsp";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "&nbsp".$row["p_val03"]."&nbsp";
				if($wlu=="03")
				{
					$platit_ln=$row["p_val01"]+$row["p_val02"]+$row["p_val03"];
					echo "(<B>".$platit_ln."</B>)&nbsp";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "&nbsp".$row["p_val04"]."&nbsp";
				if($wlu=="04")
				{
					$platit_ln=$row["p_val01"]+$row["p_val02"]+$row["p_val03"]+$row["p_val04"];
					echo "(<B>".$platit_ln."</B>)&nbsp";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "&nbsp".$row["p_val05"]."&nbsp";
				if($wlu=="05")
				{
					$platit_ln=$row["p_val01"]+$row["p_val02"]+$row["p_val03"]+$row["p_val04"]+$row["p_val05"];
					echo "(<B>".$platit_ln."</B>)&nbsp";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "&nbsp".$row["p_val06"]."&nbsp";
				if($wlu=="06")
				{
					$platit_ln=$row["p_val01"]+$row["p_val02"]+$row["p_val03"]+$row["p_val04"]+$row["p_val05"]+$row["p_val06"];
					echo "(<B>".$platit_ln."</B>)&nbsp";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "&nbsp".$row["p_val07"]."&nbsp";
				if($wlu=="07")
				{
					$platit_ln=$row["p_val01"]+$row["p_val02"]+$row["p_val03"]+$row["p_val04"]+$row["p_val05"]+$row["p_val06"]+$row["p_val07"];
					echo "(<B>".$platit_ln."</B>)&nbsp";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "&nbsp".$row["p_val08"]."&nbsp";
				if($wlu=="08")
				{
					$platit_ln=$row["p_val01"]+$row["p_val02"]+$row["p_val03"]+$row["p_val04"]+$row["p_val05"]+$row["p_val06"]+$row["p_val07"]+$row["p_val08"];
					echo "(<B>".$platit_ln."</B>)&nbsp";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "&nbsp".$row["p_val09"]."&nbsp";
				if($wlu=="09")
				{
					$platit_ln=$row["p_val01"]+$row["p_val02"]+$row["p_val03"]+$row["p_val04"]+$row["p_val05"]+$row["p_val06"]+$row["p_val07"]+$row["p_val08"]+$row["p_val09"];
					echo "(<B>".$platit_ln."</B>)&nbsp";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "&nbsp".$row["p_val10"]."&nbsp";
				if($wlu=="10")
				{
					$platit_ln=$row["p_val01"]+$row["p_val02"]+$row["p_val03"]+$row["p_val04"]+$row["p_val05"]+$row["p_val06"]+$row["p_val07"]+$row["p_val08"]+$row["p_val09"]+$row["p_val10"];
					echo "(<B>".$platit_ln."</B>)&nbsp";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "&nbsp".$row["p_val11"]."&nbsp";
				if($wlu=="11")
				{
					$platit_ln=$row["p_val01"]+$row["p_val02"]+$row["p_val03"]+$row["p_val04"]+$row["p_val05"]+$row["p_val06"]+$row["p_val07"]+$row["p_val08"]+$row["p_val09"]+$row["p_val10"]+$row["p_val11"];
					echo "(<B>".$platit_ln."</B>)&nbsp";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "&nbsp".$row["p_val12"]."&nbsp";
				if($wlu=="12")
				{
					$platit_ln=$row["p_val01"]+$row["p_val02"]+$row["p_val03"]+$row["p_val04"]+$row["p_val05"]+$row["p_val06"]+$row["p_val07"]+$row["p_val08"]+$row["p_val09"]+$row["p_val10"]+$row["p_val11"]+$row["p_val12"];
					echo "(<B>".$platit_ln."</B>)&nbsp";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "<B>&nbsp $platit_tot &nbsp</B>";
				echo "</TD>";
				echo "</TR>";
//				$i++;
			if ($i-floor($i/2)*2==0)
			{
				echo "<TR class=\"tr4\" BGCOLOR=\"#FFFFFF\">";
			}
			else
			{
				echo "<TR class=\"tr4\" BGCOLOR=\"#EAEBEB\">";
			}
		
				echo "<TD width=\"3%\" align=\"center\"> </TD>";
				echo"<TD width=\"13%\" align=\"left\">";
				echo " ";
				echo "</TD>";
				echo"<TD width=\"1%\" height=\"30px\" align=\"center\">";
				echo "<B>REST_PL</B>";
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo " ";
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				if($wlu=="01")
				{
					echo "<B>";
				}
				echo "&nbsp".$row["r_val01"]."&nbsp";
				if($wlu=="01")
				{
					echo "</B>";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				if($wlu=="02")
				{
					echo "<B>";
				}
				echo "&nbsp".$row["r_val02"]."&nbsp";
				if($wlu=="02")
				{
					echo "</B>";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				if($wlu=="03")
				{
					echo "<B>";
				}
				echo "&nbsp".$row["r_val03"]."&nbsp";
				if($wlu=="03")
				{
					echo "</B>";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				if($wlu=="04")
				{
					echo "<B>";
				}
				echo "&nbsp".$row["r_val04"]."&nbsp";
				if($wlu=="04")
				{
					echo "</B>";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				if($wlu=="05")
				{
					echo "<B>";
				}
				echo "&nbsp".$row["r_val05"]."&nbsp";
				if($wlu=="05")
				{
					echo "</B>";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				if($wlu=="06")
				{
					echo "<B>";
				}
				echo "&nbsp".$row["r_val06"]."&nbsp";
				if($wlu=="06")
				{
					echo "</B>";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				if($wlu=="07")
				{
					echo "<B>";
				}
				echo "&nbsp".$row["r_val07"]."&nbsp";
				if($wlu=="07")
				{
					echo "</B>";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				if($wlu=="08")
				{
					echo "<B>";
				}
				echo "&nbsp".$row["r_val08"]."&nbsp";
				if($wlu=="08")
				{
					echo "</B>";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				if($wlu=="09")
				{
					echo "<B>";
				}
				echo "&nbsp".$row["r_val09"]."&nbsp";
				if($wlu=="09")
				{
					echo "</B>";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				if($wlu=="10")
				{
					echo "<B>";
				}
				echo "&nbsp".$row["r_val10"]."&nbsp";
				if($wlu=="10")
				{
					echo "</B>";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				if($wlu=="11")
				{
					echo "<B>";
				}
				echo "&nbsp".$row["r_val11"]."&nbsp";
				if($wlu=="11")
				{
					echo "</B>";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				if($wlu=="12")
				{
					echo "<B>";
				}
				echo "&nbsp".$row["r_val12"]."&nbsp";
				if($wlu=="12")
				{
					echo "</B>";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "<B>&nbsp $rest_tot &nbsp</B>";
				echo "</TD>";
				echo "</TR>";
				$i++;
		}
						
		echo "</form>";
		echo "</table>";	

		mysql_close($connection);
}

if ($_POST["actiune"]=="ADAUG" and isset($_POST["tip_act"]) and $_POST["tip_act"]=="ELEV")
{
	echo "<CENTER>";
	
		echo "<FORM NAME=\"form2\" ACTION=\"A21_elevi.php\" METHOD=\"POST\" TARGET=\"win01\"";
		include 'A21_param1.php';

			$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);		

			$query="SELECT * FROM elevi where codgrp=\"".substr($_POST["grp_sel"],0,2)."\" and codelev=(select max(codelev) from elevi where codgrp=\"".substr($_POST["grp_sel"],0,2)."\") order by codelev";
			$result=mysql_query($query) or die("Interogare esuata: ".mysql_error());
	
			echo "<TABLE class=\"style1\" cellSpacing=0 cellPadding=0 width=\"100%\" border=0>";				
			echo "<TR>";
			echo "<TD align=\"center\" class=\"td_print2\">";
			echo "<B>ADAUGARE ELEV</B>";
			echo "<BR>";
			echo "</TD>";
			echo "</TR>";
			echo "</TABLE>";
			
			echo "<TABLE class=\"table1\" cellSpacing=0 cellPadding=0 height=\"100%\" width=\"80%\" border=0>";
			echo "<BR>";
			echo "<TR BGCOLOR=\"white\">";
			
			echo 	"<TH align=\"center\" width=\"3%\" class=\"td35\">Cod Elev</TH>";					
			echo	"<TH align=\"center\" width=\"35%\" class=\"td35\">Nume</TH>";
			echo	"<TH align=\"center\" width=\"35%\" class=\"td39\">Prenume</TH>";
			
			echo "</TR>";
			
		$i=0;		
		$wcodelev=0;
		
	if(mysql_num_rows($result) == 0) 
	{
		$wcodelev=substr($_POST["grp_sel"],0,2)."001";
		
		if ($i-floor($i/2)*2==0)
		{
			echo "<TR class=\"tr4\" BGCOLOR=\"#FFFFFF\">";
		}
		else
		{
			echo "<TR class=\"tr4\" BGCOLOR=\"#EAEBEB\">";
		}
		
		echo"<TD width=\"3%\" align=\"center\">";
		echo "".$wcodelev."";
		echo "<INPUT TYPE=\"HIDDEN\" NAME=\"codelev\" VALUE=\"".$wcodelev."\">";
		echo "</TD>";			
		echo "<TD width=\"35%\" align=\"left\">";
		echo "<INPUT TYPE=\"TEXT\" size=\"32\" onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\" class=\"text13\" NAME=\"nume_".$wcodelev."\" VALUE=\"\">";
		echo "</TD>";				
		echo "<TD width=\"35%\" align=\"left\">";
		echo "<INPUT TYPE=\"TEXT\" size=\"32\" onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\" class=\"text13\" NAME=\"prenume_".$wcodelev."\" VALUE=\"\">";
		echo "</TD>";
		echo "</TR>";
	}
	else 
	{

		while($row = mysql_fetch_array( $result )) 
		{ 	
			$wcodelev = $row["codelev"] + 1;
			$_SESSION["codelev"] = $wcodelev;	
			
			if ($i-floor($i/2)*2==0)
			{
				echo "<TR class=\"tr4\" BGCOLOR=\"#FFFFFF\">";
			}
			else
			{
				echo "<TR class=\"tr4\" BGCOLOR=\"#EAEBEB\">";
			}
			
				echo"<TD width=\"3%\" align=\"center\">";
				echo "".$wcodelev."";
				echo "<INPUT TYPE=\"HIDDEN\" NAME=\"codelev\" VALUE=\"".$wcodelev."\">";
				echo "</TD>";			
				echo "<TD width=\"35%\" align=\"left\">";
				echo "<INPUT TYPE=\"TEXT\" size=\"32\" onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\" class=\"text13\" NAME=\"nume_".$wcodelev."\" VALUE=\"\">";
				echo "</TD>";				
				echo "<TD width=\"35%\" align=\"left\">";
				echo "<INPUT TYPE=\"TEXT\" size=\"32\" onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\" class=\"text13\" NAME=\"prenume_".$wcodelev."\" VALUE=\"\">";
				echo "</TD>";
				echo "</TR>";
				$i++;
		}	
	}	
			echo "</table>";
			
				include 'A21_param1.php';
				echo "<TABLE cellSpacing=0 align=\"right\" cellPadding=0 width=\"50%; height:15%;\" border=0>";
				echo "<TR>";
				echo "<TD>&nbsp</TD>";
				echo "</TR>";
				echo "<tr>";
			    echo "<td width=\"15%\" height=\"35\" align=\"right\">";
				echo "<input type=\"submit\" name=\"actiune\" id=\"button10\" onMouseUp=\"javascript:setTimeout('window.close()',300);\" value=\"CONFIRM\">";
				echo "<INPUT TYPE=\"HIDDEN\" NAME=\"tip_act\" VALUE=\"ELEV\">";
				echo "</td>";
				echo "<td width=\"15%\" height=\"35\" align=\"left\">";
				echo "<input name=\"button\" type=\"button\" id=\"button10\" value=\"RENUNT\" onClick=\"javascript:window.close()\">";
				echo "</td>";
				echo  "</tr>";
				echo "</TABLE>";
		
			echo "</form>";
			echo "</TABLE>";
			
		mysql_close($connection);
		
}

if (substr($_POST["actiune"],0,1)=="<" AND isset($_POST["tip_act"]) and $_POST["tip_act"]=="ELEV")
{
	echo "<CENTER>";
	
		echo "<FORM NAME=\"form3\" ACTION=\"A21_elevi.php\" METHOD=\"POST\" TARGET=\"win01\"";
		include 'A21_param1.php';

			$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);		
			
			$query="SELECT * FROM elevi where codelev=\"".substr($_POST["actiune"],1,strpos($_POST["actiune"],'>')-1)."\" order by codelev";
			$result=mysql_query($query) or die("Interogare esuata: ".mysql_error());		
			echo "<TABLE class=\"style1\" cellSpacing=0 cellPadding=0 width=\"100%\" border=0>";				
			echo "<TR>";
			echo "<TD align=\"center\" class=\"td_print2\">";
			echo "<B>EDITARE ELEV</B>";
			echo "<BR>";
			echo "</TD>";
			echo "</TR>";
			echo "</TABLE>";
			
			echo "<TABLE class=\"table1\" cellSpacing=0 cellPadding=0 height=\"100%\" width=\"80%\" border=0>";
			echo "<BR>";
			echo "<TR BGCOLOR=\"white\">";
			
			echo 	"<TH align=\"center\" width=\"3%\" class=\"td35\">Cod Elev</TH>";					
			echo	"<TH align=\"center\" width=\"35%\" class=\"td35\">Nume</TH>";
			echo	"<TH align=\"center\" width=\"35%\" class=\"td39\">Prenume</TH>";	
			
			echo "</TR>";
			
		$i=0;
		$wcodelev=0;	
		while($row = mysql_fetch_array( $result )) 
		{ 	
			$wcodelev = $row["codelev"];
				
			if ($i-floor($i/2)*2==0)
				{
					echo "<TR class=\"tr4\" BGCOLOR=\"#FFFFFF\">";
				}
				else
				{
					echo "<TR class=\"tr4\" BGCOLOR=\"#EAEBEB\">";
				}
				
				echo"<TD width=\"3%\" align=\"center\">";
				echo "".$wcodelev."";
				echo "<INPUT TYPE=\"HIDDEN\" NAME=\"codelev\" VALUE=\"".$wcodelev."\">";
				echo "</TD>";				
				echo "<TD width=\"35%\" align=\"left\">";
				echo "<INPUT TYPE=\"TEXT\" size=\"32\" onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\" class=\"text13\" NAME=\"nume_".$wcodelev."\" VALUE=\"".$row["nume"]."\">";
				echo "</TD>";				
				echo "<TD width=\"35%\" align=\"left\">";
				echo "<INPUT TYPE=\"TEXT\" size=\"32\" onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\" class=\"text13\" NAME=\"prenume_".$wcodelev."\" VALUE=\"".$row["prenume"]."\">";
				echo "</TD>";
				echo "</TR>";
				$i++;
		}	
			echo "</table>";
			
				include 'A21_param1.php';
				echo "<TABLE cellSpacing=0 align=\"center\" cellPadding=0 width=\"70%; height:15%;\" border=0>";
				echo "<TR>";
				echo "<TD>&nbsp</TD>";
				echo "</TR>";
				echo "<tr>";
				echo "<td width=\"1%\" height=\"35\" align=\"left\">";
				echo "<input type=\"submit\" name=\"actiune\" id=\"button10\" onMouseUp=\"javascript:setTimeout('window.close()',300);\" onClick=\"javascript:return confirm('Doriti sa stergeti?')\" value=\"STERGE\">";	
				echo "<INPUT TYPE=\"HIDDEN\" NAME=\"tip_act\" VALUE=\"ELEV\">";
				echo "</TD>";
			    echo "<td width=\"1%\" height=\"35\" align=\"right\">";
				echo "<input type=\"submit\" name=\"actiune\" id=\"button10\" onMouseUp=\"javascript:setTimeout('window.close()',300);\" value=\"MODIFIC\">";
				echo "<INPUT TYPE=\"HIDDEN\" NAME=\"tip_act\" VALUE=\"ELEV\">";
				echo "<input name=\"button\" type=\"button\" id=\"button10\" value=\"RENUNT\" onClick=\"javascript:window.close()\">";
				echo "</td>";
				echo  "</tr>";
				echo "</TABLE>";
		
			echo "</form>";
			echo "</TABLE>";
			
		mysql_close($connection);
		
}

if (substr($_POST["actiune"],0,2)=="D-" AND isset($_POST["tip_act"]) and $_POST["tip_act"]=="DEB" 
	OR $_POST["actiune"]=="CONFIRM"  AND isset($_POST["tip_act"]) and $_POST["tip_act"]=="DEB")
{
	echo "<BODY id=\"bg_deb\">";
	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\" id=\"form_confirm\" ACTION=\"A21_elevi.php\" METHOD=\"POST\" TARGET=\"win01\">";
			include 'A21_param1.php';
		
			echo "<TABLE cellSpacing=0 cellPadding=0 width=\"30%; height:100%;\" border=0 align=\"right\">";
			echo "<TR>";
			echo "<TD align=\"right\" height=\"35\">";
			echo "<INPUT TYPE=\"SUBMIT\" class=\"noPrint\" NAME=\"actiune\" onClick=\"javascript:setTimeout('window.close()',300);\" VALUE=\"INAPOI\">";
		//	echo "<INPUT TYPE=\"SUBMIT\" class=\"noPrint\" NAME=\"actiune\"  VALUE=\"INAPOI\">";
			echo "<INPUT TYPE=\"HIDDEN\" NAME=\"tip_act\" VALUE=\"DEB\">";
			echo "</TD>";
			echo "</TR>";
			echo "</table>";
			echo "</form>";
			
		echo "<FORM NAME=\"form3\" id=\"form_confirm\" ACTION=\"A21_elevi.php\" METHOD=\"POST\">";
		include 'A21_param1.php';

		echo "<INPUT TYPE=\"HIDDEN\" NAME=\"codelev\" VALUE=\"".substr($_POST["actiune"],2,5)."\">";	
		
		$query="SELECT * FROM elevi where codelev=\"".substr($_POST["actiune"],2,5)."\"";
		$result=mysql_query($query) or die("Interogare esuata: ".mysql_error());		
		$row = mysql_fetch_array( $result);		

	IF ($_POST["actiune"]=="CONFIRM" and isset($_POST["tip_act"]) AND $_POST["tip_act"] == "DEB")
	{
		echo "<FORM NAME=\"form3\" id=\"form_confirm\" ACTION=\"A21_elevi.php\" METHOD=\"POST\" >";
		include 'A21_param1.php';
		echo "<INPUT TYPE=\"HIDDEN\" NAME=\"codelev\" VALUE=\"".$_POST["codelev"]."\">";
		
		$query2="SELECT * FROM elevi ";
		$result2=mysql_query($query2) or die("Interogare esuata: ".mysql_error());
	//	$row = mysql_fetch_array( $result);
	
		$i=0;
		while ($row2 = mysql_fetch_array( $result2))
		{
			$query="SELECT * FROM elevi WHERE codelev=\"".$_POST["codelev"]."\"";
			$result=mysql_query($query) or die("Interogare esuata: ".mysql_error());
			$row = mysql_fetch_array( $result);
		
			$w_z_val00=$_POST["z_val00"];
			$w_z_val01=$_POST["z_val01"];
			$w_z_val02=$_POST["z_val02"];
			$w_z_val03=$_POST["z_val03"];
			$w_z_val04=$_POST["z_val04"];
			$w_z_val05=$_POST["z_val05"];
			$w_z_val06=$_POST["z_val06"];
			$w_z_val07=$_POST["z_val07"];
			$w_z_val08=$_POST["z_val08"];
			$w_z_val09=$_POST["z_val09"];
			$w_z_val10=$_POST["z_val10"];
			$w_z_val11=$_POST["z_val11"];
			$w_z_val12=$_POST["z_val12"];
		
			$w_t_val00=$row["t_val00"];
			$w_t_val01=$row["t_val01"];
			$w_t_val02=$row["t_val02"];
			$w_t_val03=$row["t_val03"];
			$w_t_val04=$row["t_val04"];
			$w_t_val05=$row["t_val05"];
			$w_t_val06=$row["t_val06"];
			$w_t_val07=$row["t_val07"];
			$w_t_val08=$row["t_val08"];
			$w_t_val09=$row["t_val09"];
			$w_t_val10=$row["t_val10"];
			$w_t_val11=$row["t_val11"];
			$w_t_val12=$row["t_val12"];
	
			IF ($w_t_val00 == "0")
			{
			$w_d_val00 = 0;
			}
			else
			{
			$w_d_val00=$w_z_val00 * $w_t_val00;
			}
			IF ($w_t_val01 == "0")
			{
			$w_d_val01 = 0;
			}
			else
			{
			$w_d_val01=$w_z_val01 * $w_t_val01;
			}
			IF ($w_t_val02 == "0")
			{
			$w_d_val02 = 0;
			}
			else
			{
			$w_d_val02=$w_z_val02 * $w_t_val02;
			}
			IF ($w_t_val03 == "0")
			{
			$w_d_val03 = 0;
			}
			else
			{
			$w_d_val03=$w_z_val03 * $w_t_val03;
			}
			IF ($w_t_val04 == "0")
			{
			$w_d_val04 = 0;
			}
			else
			{
			$w_d_val04=$w_z_val04 * $w_t_val04;
			}
			IF ($w_t_val05 == "0")
			{
			$w_d_val05 = 0;
			}
			else
			{
			$w_d_val05=$w_z_val00 * $w_t_val05;
			}
			IF ($w_t_val06 == "0")
			{
			$w_d_val06 = 0;
			}
			else
			{
			$w_d_val06=$w_z_val06 * $w_t_val06;
			}
			IF ($w_t_val07 == "0")
			{
			$w_d_val07 = 0;
			}
			else
			{
			$w_d_val07=$w_z_val07 * $w_t_val07;
			}
			IF ($w_t_val08 == "0")
			{
			$w_d_val08 = 0;
			}
			else
			{
			$w_d_val08=$w_z_val08 * $w_t_val08;
			}
			IF ($w_t_val09 == "0")
			{
			$w_d_val09 = 0;
			}
			else
			{
			$w_d_val09=$w_z_val09 * $w_t_val09;
			}
			IF ($w_t_val10 == "0")
			{
			$w_d_val10 = 0;
			}
			else
			{
			$w_d_val10=$w_z_val10 * $w_t_val10;
			}
			IF ($w_t_val11 == "0")
			{
			$w_d_val11 = 0;
			}
			else
			{
			$w_d_val11=$w_z_val11 * $w_t_val11;
			}
			IF ($w_t_val12 == "0")
			{
			$w_d_val12 = 0;
			}
			else
			{
			$w_d_val12=$w_z_val12 * $w_t_val12;
			}
			
			$w_p_val01=$row["p_val01"];
			$w_p_val02=$row["p_val02"];
			$w_p_val03=$row["p_val03"];
			$w_p_val04=$row["p_val04"];
			$w_p_val05=$row["p_val05"];
			$w_p_val06=$row["p_val06"];
			$w_p_val07=$row["p_val07"];
			$w_p_val08=$row["p_val08"];
			$w_p_val09=$row["p_val09"];
			$w_p_val10=$row["p_val10"];
			$w_p_val11=$row["p_val11"];
			$w_p_val12=$row["p_val12"];
	
			$w_r_val01=($w_d_val00+$w_d_val01)-$w_p_val01;
			$w_r_val02=($w_d_val00+$w_d_val01+$w_d_val02)-($w_p_val01+$w_p_val02);
			$w_r_val03=($w_d_val00+$w_d_val01+$w_d_val02+$w_d_val03)-($w_p_val01+$w_p_val02+$w_p_val03);
			$w_r_val04=($w_d_val00+$w_d_val01+$w_d_val02+$w_d_val03+$w_d_val04)-($w_p_val01+$w_p_val02+$w_p_val03+$w_p_val04);
			$w_r_val05=($w_d_val00+$w_d_val01+$w_d_val02+$w_d_val03+$w_d_val04+$w_d_val05)-($w_p_val01+$w_p_val02+$w_p_val03+$w_p_val04+$w_p_val05);
			$w_r_val06=($w_d_val00+$w_d_val01+$w_d_val02+$w_d_val03+$w_d_val04+$w_d_val05+$w_d_val06)-($w_p_val01+$w_p_val02+$w_p_val03+$w_p_val04+$w_p_val05+$w_p_val06);
			$w_r_val07=($w_d_val00+$w_d_val01+$w_d_val02+$w_d_val03+$w_d_val04+$w_d_val05+$w_d_val06+$w_d_val07)-($w_p_val01+$w_p_val02+$w_p_val03+$w_p_val04+$w_p_val05+$w_p_val06+$w_p_val07);
			$w_r_val08=($w_d_val00+$w_d_val01+$w_d_val02+$w_d_val03+$w_d_val04+$w_d_val05+$w_d_val06+$w_d_val07+$w_d_val08)-($w_p_val01+$w_p_val02+$w_p_val03+$w_p_val04+$w_p_val05+$w_p_val06+$w_p_val07+$w_p_val08);
			$w_r_val09=($w_d_val00+$w_d_val01+$w_d_val02+$w_d_val03+$w_d_val04+$w_d_val05+$w_d_val06+$w_d_val07+$w_d_val08+$w_d_val09)-($w_p_val01+$w_p_val02+$w_p_val03+$w_p_val04+$w_p_val05+$w_p_val06+$w_p_val07+$w_p_val08+$w_p_val09);
			$w_r_val10=($w_d_val00+$w_d_val01+$w_d_val02+$w_d_val03+$w_d_val04+$w_d_val05+$w_d_val06+$w_d_val07+$w_d_val08+$w_d_val09+$w_d_val10)-($w_p_val01+$w_p_val02+$w_p_val03+$w_p_val04+$w_p_val05+$w_p_val06+$w_p_val07+$w_p_val08+$w_p_val09+$w_p_val10);
			$w_r_val11=($w_d_val00+$w_d_val01+$w_d_val02+$w_d_val03+$w_d_val04+$w_d_val05+$w_d_val06+$w_d_val07+$w_d_val08+$w_d_val09+$w_d_val10+$w_d_val11)-($w_p_val01+$w_p_val02+$w_p_val03+$w_p_val04+$w_p_val05+$w_p_val06+$w_p_val07+$w_p_val08+$w_p_val09+$w_p_val10+$w_p_val11);
			$w_r_val12=($w_d_val00+$w_d_val01+$w_d_val02+$w_d_val03+$w_d_val04+$w_d_val05+$w_d_val06+$w_d_val07+$w_d_val08+$w_d_val09+$w_d_val10+$w_d_val11+$w_d_val12)-($w_p_val01+$w_p_val02+$w_p_val03+$w_p_val04+$w_p_val05+$w_p_val06+$w_p_val07+$w_p_val08+$w_p_val09+$w_p_val10+$w_p_val11+$w_p_val12);
		
			$query4="UPDATE elevi set z_val00=\"".$w_z_val00."\", z_val01=\"".$w_z_val01."\", z_val02=\"".$w_z_val02."\", z_val03=\"".$w_z_val03."\", ";
			$query4=$query4."z_val04=\"".$w_z_val04."\", z_val05=\"".$w_z_val05."\", z_val06=\"".$w_z_val06."\", z_val07=\"".$w_z_val07."\", ";
			$query4=$query4."z_val08=\"".$w_z_val08."\", z_val09=\"".$w_z_val09."\", z_val10=\"".$w_z_val10."\", z_val11=\"".$w_z_val11."\", ";
			$query4=$query4."z_val12=\"".$w_z_val12."\", ";
			$query4=$query4."d_val00=\"".$w_d_val00."\", d_val01=\"".$w_d_val01."\", d_val02=\"".$w_d_val02."\", d_val03=\"".$w_d_val03."\", ";
			$query4=$query4."d_val04=\"".$w_d_val04."\", d_val05=\"".$w_d_val05."\", d_val06=\"".$w_d_val06."\", d_val07=\"".$w_d_val07."\", ";
			$query4=$query4."d_val08=\"".$w_d_val08."\", d_val09=\"".$w_d_val09."\", d_val10=\"".$w_d_val10."\", d_val11=\"".$w_d_val11."\", ";
			$query4=$query4."d_val12=\"".$w_d_val12."\", ";
			$query4=$query4."r_val01=\"".$w_r_val01."\", r_val02=\"".$w_r_val02."\", r_val03=\"".$w_r_val03."\", ";
			$query4=$query4."r_val04=\"".$w_r_val04."\", r_val05=\"".$w_r_val05."\", r_val06=\"".$w_r_val06."\", r_val07=\"".$w_r_val07."\", ";
			$query4=$query4."r_val08=\"".$w_r_val08."\", r_val09=\"".$w_r_val09."\", r_val10=\"".$w_r_val10."\", r_val11=\"".$w_r_val11."\", ";
			$query4=$query4."r_val12=\"".$w_r_val12."\" ";
			$query4=$query4."WHERE codelev = \"".$_POST["codelev"]."\"";
			$result4=mysql_query($query4) or die("Interogare esuata: ".mysql_error());	

			
			$query="SELECT * FROM elevi WHERE codelev=\"".$_POST["codelev"]."\"";
			$result=mysql_query($query) or die("Interogare esuata: ".mysql_error());
			$row = mysql_fetch_array( $result);	
		}		
	//	echo "</form>";
	}			
		
			
			echo "<TABLE cellSpacing=0 cellPadding=0 width=\"100%\" border=0>";			
			echo "<TR>";
			echo "<TD colspan=\"32\" align=\"center\" class=\"td_print2\">";
			echo "<B>EDITARE DEBITE</B>";
			echo "</TD>";
			echo "</TR>";
			echo "<TR>";
			echo "<TD>";
			echo "<BR>";
			echo "</TD>";
			echo "</TR>";
			echo "<BR>";
			echo "<TR BGCOLOR=\"white\">";
			
			echo 	"<TH align=\"center\" width=\"2%\" class=\"td35\">Cod elev</TH>";					
			echo	"<TH align=\"center\" width=\"10%\"  class=\"td35\">Nume Prenume</TH>";
			echo	"<TH align=\"center\" width=\"3%\" class=\"td35\">&nbsp</TH>";
			echo	"<TH align=\"center\" width=\"3%\" class=\"td35\">PREC</TH>";
			echo	"<TH align=\"center\" width=\"3%\" class=\"td35\">IAN</TH>";
			echo	"<TH align=\"center\" width=\"3%\" class=\"td35\">FEB</TH>";
			echo	"<TH align=\"center\" width=\"3%\" class=\"td35\">MAR</TH>";
			echo	"<TH align=\"center\" width=\"3%\" class=\"td35\">APR</TH>";
			echo	"<TH align=\"center\" width=\"3%\" class=\"td35\">MAI</TH>";
			echo	"<TH align=\"center\" width=\"3%\" class=\"td35\">IUN</TH>";
			echo	"<TH align=\"center\" width=\"3%\" class=\"td35\">IUL</TH>";
			echo	"<TH align=\"center\" width=\"3%\" class=\"td35\">AUG</TH>";
			echo	"<TH align=\"center\" width=\"3%\" class=\"td35\">SEP</TH>";
			echo	"<TH align=\"center\" width=\"3%\" class=\"td35\">OCT</TH>";
			echo	"<TH align=\"center\" width=\"3%\" class=\"td35\">NOI</TH>";
			echo	"<TH align=\"center\" width=\"3%\" class=\"td35\">DEC</TH>";
			echo	"<TH align=\"center\" width=\"3%\" class=\"td39\">TOTAL</TH>";			
			echo "</TR>";	

			
			$zile_tot = $row["z_val00"] + $row["z_val01"] + $row["z_val02"] + $row["z_val03"] + $row["z_val04"] + $row["z_val05"] + $row["z_val06"] + $row["z_val07"] + $row["z_val08"] + $row["z_val09"] + $row["z_val10"] + $row["z_val11"] + $row["z_val12"];
			
			$tarif_tot = $row["t_val00"] + $row["t_val01"] + $row["t_val02"] + $row["t_val03"] + $row["t_val04"] + $row["t_val05"] + $row["t_val06"] + $row["t_val07"] + $row["t_val08"] + $row["t_val09"] + $row["t_val10"] + $row["t_val11"] + $row["t_val12"];
			
			$debit_tot = $row["d_val00"] + $row["d_val01"] + $row["d_val02"] + $row["d_val03"] + $row["d_val04"] + $row["d_val05"] + $row["d_val06"] + $row["d_val07"] + $row["d_val08"] + $row["d_val09"] + $row["d_val10"] + $row["d_val11"] + $row["d_val12"];
			
			echo "<TR class=\"tr4\" BGCOLOR=\"#FFFFFF\">";
		
				echo "<TD width=\"2%\" height=\"30px\" align=\"center\">";
				echo $row["codelev"];
				echo "</TD>";
				echo"<TD width=\"10%\" align=\"left\">";
				echo "&nbsp".trim($row["nume"])." ".trim($row["prenume"])."&nbsp";
				echo "</TD>";
				echo "<TD width=\"2%\" align=\"center\">";
				echo "Nr. zile prezent";
				echo "</TD>";
				echo"<TD width=\"2%\" align=\"right\">";
				echo "<INPUT TYPE=\"TEXT\" size=\"2\" onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\" onkeypress=\"return isNumberKey(event)\" class=\"text1\" NAME=\"z_val00\" VALUE=\"".$row["z_val00"]."\">";
				echo "</TD>";
				echo"<TD width=\"2%\" align=\"right\">";
				echo "<INPUT TYPE=\"TEXT\" size=\"2\" onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\" onkeypress=\"return isNumberKey(event)\" class=\"text1\" NAME=\"z_val01\" VALUE=".$row["z_val01"].">";
				echo "</TD>";
				echo"<TD width=\"2%\" align=\"right\">";
				echo "<INPUT TYPE=\"TEXT\" size=\"2\"  onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\" onkeypress=\"return isNumberKey(event)\" class=\"text1\" NAME=\"z_val02\" VALUE=".$row["z_val02"].">";
				echo "</TD>";
				echo"<TD width=\"2%\" align=\"right\">";
				echo "<INPUT TYPE=\"TEXT\" size=\"2\"  onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\" onkeypress=\"return isNumberKey(event)\" class=\"text1\" NAME=\"z_val03\" VALUE=".$row["z_val03"].">";
				echo "</TD>";
				echo"<TD width=\"2%\" align=\"right\">";
				echo "<INPUT TYPE=\"TEXT\" size=\"2\"  onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\" onkeypress=\"return isNumberKey(event)\" class=\"text1\" NAME=\"z_val04\" VALUE=".$row["z_val04"].">";
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "<INPUT TYPE=\"TEXT\" size=\"2\"  onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\" onkeypress=\"return isNumberKey(event)\" class=\"text1\" NAME=\"z_val05\" VALUE=".$row["z_val05"].">";
				echo "</TD>";
				echo"<TD width=\"2%\" align=\"right\">";
				echo "<INPUT TYPE=\"TEXT\" size=\"2\"  onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\" onkeypress=\"return isNumberKey(event)\" class=\"text1\" NAME=\"z_val06\" VALUE=".$row["z_val06"].">";
				echo "</TD>";
				echo"<TD width=\"2%\" align=\"right\">";
				echo "<INPUT TYPE=\"TEXT\" size=\"2\"  onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\" onkeypress=\"return isNumberKey(event)\" class=\"text1\" NAME=\"z_val07\" VALUE=".$row["z_val07"].">";
				echo "</TD>";
				echo"<TD width=\"2%\" align=\"right\">";
				echo "<INPUT TYPE=\"TEXT\" size=\"2\"  onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\" onkeypress=\"return isNumberKey(event)\" class=\"text1\" NAME=\"z_val08\" VALUE=".$row["z_val08"].">";
				echo "</TD>";
				echo"<TD width=\"2%\" align=\"right\">";
				echo "<INPUT TYPE=\"TEXT\" size=\"2\"  onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\" onkeypress=\"return isNumberKey(event)\" class=\"text1\" NAME=\"z_val09\" VALUE=".$row["z_val09"].">";
				echo "</TD>";
				echo"<TD width=\"2%\" align=\"right\">";
				echo "<INPUT TYPE=\"TEXT\" size=\"2\"  onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\" onkeypress=\"return isNumberKey(event)\" class=\"text1\" NAME=\"z_val10\" VALUE=".$row["z_val10"].">";
				echo "</TD>";
				echo"<TD width=\"2%\" align=\"right\">";
				echo "<INPUT TYPE=\"TEXT\" size=\"2\"  onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\" onkeypress=\"return isNumberKey(event)\" class=\"text1\" NAME=\"z_val11\" VALUE=".$row["z_val11"].">";
				echo "</TD>";
				echo"<TD width=\"2%\" align=\"right\">";
				echo "<INPUT TYPE=\"TEXT\" size=\"2\"  onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\" onkeypress=\"return isNumberKey(event)\" class=\"text1\" NAME=\"z_val12\" VALUE=".$row["z_val12"].">";
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "<B>&nbsp $zile_tot &nbsp</B>";
				echo "</TD>";
				echo "</TR>";

				echo "<TR class=\"tr4\" BGCOLOR=\"#EAEBEB\">";
				echo "<TD width=\"2%\" height=\"30px\" align=\"center\">";
				echo "</TD>";
				echo"<TD width=\"10%\" align=\"left\">";
				echo "</TD>";
				echo "<TD width=\"2%\" align=\"center\">";
				echo "Tarif / zi";
				echo "</TD>";
				echo"<TD width=\"2%\" align=\"right\">";
				echo "".$row["t_val00"]."&nbsp";
				echo "</TD>";
				echo"<TD width=\"2%\" align=\"right\">";
				echo "".$row["t_val01"]."&nbsp";
				echo "</TD>";
				echo"<TD width=\"2%\" align=\"right\">";
				echo "".$row["t_val02"]."&nbsp";
				echo "</TD>";
				echo"<TD width=\"2%\" align=\"right\">";
				echo "".$row["t_val03"]."&nbsp";
				echo "</TD>";
				echo"<TD width=\"2%\" align=\"right\">";
				echo "".$row["t_val04"]."&nbsp";
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "".$row["t_val05"]."&nbsp";
				echo "</TD>";
				echo"<TD width=\"2%\" align=\"right\">";
				echo "".$row["t_val06"]."&nbsp";
				echo "</TD>";
				echo"<TD width=\"2%\" align=\"right\">";
				echo "".$row["t_val07"]."&nbsp";
				echo "</TD>";
				echo"<TD width=\"2%\" align=\"right\">";
				echo "".$row["t_val08"]."&nbsp";
				echo "</TD>";
				echo"<TD width=\"2%\" align=\"right\">";
				echo "".$row["t_val09"]."&nbsp";
				echo "</TD>";
				echo"<TD width=\"2%\" align=\"right\">";
				echo "".$row["t_val10"]."&nbsp";
				echo "</TD>";
				echo"<TD width=\"2%\" align=\"right\">";
				echo "".$row["t_val11"]."&nbsp";
				echo "</TD>";
				echo"<TD width=\"2%\" align=\"right\">";
				echo "".$row["t_val12"]."&nbsp";
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "<B>&nbsp $tarif_tot &nbsp</B>";
				echo "</TD>";
				echo "</TR>";
				echo "<TR>";
				echo "<TD colspan=\"17\">";
				echo "<hr width=\"100%\">";
				echo "</TD>";
				echo "</TR>";
				echo "<TR>";
				echo "<TD width=\"2%\" height=\"30px\" align=\"center\">";				
				echo "</TD>";
				echo"<TD width=\"10%\" align=\"left\">";
				echo "</TD>";
				echo "<TD width=\"2%\" align=\"center\">";
				echo "<B>TOTAL:&nbsp</B>";
				echo "</TD>";
				echo"<TD width=\"2%\" align=\"right\">";
				echo "<B>".$row["d_val00"]."</B>&nbsp";
				echo "</TD>";
				echo"<TD width=\"2%\" align=\"right\">";
				echo "<B>".$row["d_val01"]."</B>&nbsp";
				echo "</TD>";
				echo"<TD width=\"2%\" align=\"right\">";
				echo "<B>".$row["d_val02"]."</B>&nbsp";
				echo "</TD>";
				echo"<TD width=\"2%\" align=\"right\">";
				echo "<B>".$row["d_val03"]."</B>&nbsp";
				echo "</TD>";
				echo"<TD width=\"2%\" align=\"right\">";
				echo "<B>".$row["d_val04"]."</B>&nbsp";
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "<B>".$row["d_val05"]."</B>&nbsp";
				echo "</TD>";
				echo"<TD width=\"2%\" align=\"right\">";
				echo "<B>".$row["d_val06"]."</B>&nbsp";
				echo "</TD>";
				echo"<TD width=\"2%\" align=\"right\">";
				echo "<B>".$row["d_val07"]."</B>&nbsp";
				echo "</TD>";
				echo"<TD width=\"2%\" align=\"right\">";
				echo "<B>".$row["d_val08"]."</B>&nbsp";
				echo "</TD>";
				echo"<TD width=\"2%\" align=\"right\">";
				echo "<B>".$row["d_val09"]."</B>&nbsp";
				echo "</TD>";
				echo"<TD width=\"2%\" align=\"right\">";
				echo "<B>".$row["d_val10"]."</B>&nbsp";
				echo "</TD>";
				echo"<TD width=\"2%\" align=\"right\">";
				echo "<B>".$row["d_val11"]."</B>&nbsp";
				echo "</TD>";
				echo"<TD width=\"2%\" align=\"right\">";
				echo "<B>".$row["d_val12"]."</B>&nbsp";
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "<B>&nbsp $debit_tot &nbsp</B>";
				echo "</TD>";
				echo "</TR>";
				echo "</B>";
				
				echo "<TR>";
				echo "<TD>&nbsp</TD>";
				echo "</TR>";
				echo "<tr>";
			    echo "<td colspan=\"15\" width=\"15%\" height=\"35\" align=\"right\">";
			//	echo "<input type=\"submit\" name=\"actiune\" id=\"button10\" onMouseUp=\"javascript:setTimeout('window.close()',300);\" value=\"CONFIRM\">";
				echo "<input type=\"submit\" name=\"actiune\" id=\"button10\" value=\"CONFIRM\">";
				echo "<INPUT TYPE=\"HIDDEN\" NAME=\"tip_act\" VALUE=\"DEB\">";
				echo "<INPUT TYPE=\"HIDDEN\" NAME=\"tip_actiune\" VALUE=\"CONF\">";
				echo "</td>";
				echo "<td  colspan=\"2\" width=\"15%\" height=\"35\" align=\"left\">";
				if (!isset($_POST["tip_actiune"]))
				{	
					echo "<input name=\"button\" type=\"button\" id=\"button10_2\" onMouseUp=\"javascript:setTimeout('window.close()',300);\" value=\"RENUNT\" >";				
				}
				else
				{
					echo "<input name=\"button\" type=\"button\" disabled=\"disabled\" id=\"button10_2\" onMouseUp=\"javascript:setTimeout('window.close()',300);\" value=\"RENUNT\" >";	
				}			
				echo "</td>";
				echo  "</tr>";			

		echo "</form>";
		echo "</table>";	
		mysql_close($connection);
}

if (substr($_POST["actiune"],0,2)=="P-" and isset($_POST["tip_act"]) and $_POST["tip_act"]=="PLA")
{
	echo "<BODY id=\"bg_plati\">";
	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);		
			
			$query="SELECT * FROM chitante where codelev=\"".substr($_POST["actiune"],2,5)."\" order by data_doc,nr_doc";
			$result=mysql_query($query) or die("Interogare esuata: ".mysql_error());		
		
			echo "<TABLE class=\"table2\" cellSpacing=0 cellPadding=0 width=\"100%\" border=0>";				
			echo "<TR>";
			echo "<TD colspan=\"6\" align=\"left\" class=\"td_print2\">";
			echo "<B>PLATI</B>";
			echo "</TD>";
			echo "</TR>";
			echo "<TR>";
			echo "<TD colspan=\"6\" align=\"left\">";
			echo "<B>".substr($_POST["actiune"],2,5)." - ";
			echo "&nbsp".trim($_POST["nume"])." ".trim($_POST["prenume"])."&nbsp";
			echo "</B></TD>";
			echo "</TR>";
			
		echo "<FORM NAME=\"form3\" ACTION=\"A21_editare_chit.php\" METHOD=\"POST\" onsubmit=\"target_popup10(this)\">";
		include 'A21_param1.php';
		echo "<INPUT TYPE=\"HIDDEN\" NAME=\"codelev\" VALUE=\"".substr($_POST["actiune"],2,5)."\">";
		echo "<INPUT TYPE=\"HIDDEN\" NAME=\"tip_act\" VALUE=\"PLA\">";
		echo "<INPUT TYPE=\"HIDDEN\" NAME=\"nume\" VALUE=\"".$_POST["nume"]."\">";
		echo "<INPUT TYPE=\"HIDDEN\" NAME=\"prenume\" VALUE=\"".$_POST["prenume"]."\">";

		echo "<TR>";
		echo "<TD colspan=\"8\" height=\"35\" align=\"right\">";
		echo "<INPUT TYPE=\"SUBMIT\" id=\"button11\" NAME=\"actiune\" VALUE=\"INAPOI\" onClick=\"javascript:setTimeout('window.close()',300);\">";
		echo "</TD>";
		echo "</TR>";				
		echo "<TR>";
		echo "<TD colspan=\"8\" height=\"35\" align=\"right\">";
		echo "<INPUT TYPE=\"SUBMIT\" NAME=\"actiune\" id=\"button11\" VALUE=\"ADAUG\">";
		echo "</TD>";
		echo "</TR>";
		echo "<TR>";
		echo "<TD>";
		echo "&nbsp";
		echo "</TR>";
		echo "<TR>";
		echo "<TD>";
		echo "&nbsp";
		echo "</TD>";
		echo "</TR>";
		//echo "</FORM>";
		
			echo "<BR>";
			echo "<TR BGCOLOR=\"white\">";			
			echo    "<TH colspan=\"1\" align=\"center\" width=\"15%\" class=\"td35\">Nrc</TH>";
			echo	"<TH colspan=\"1\" align=\"center\" width=\"15%\" class=\"td35\">Tip</TH>";
			echo	"<TH colspan=\"1\" align=\"center\" width=\"20%\" class=\"td35\">Nr doc</TH>";
			echo	"<TH colspan=\"1\" align=\"center\" width=\"20%\" class=\"td35\">Data doc</TH>";
			echo	"<TH colspan=\"1\" align=\"center\" width=\"15%\" class=\"td35\">Suma</TH>";
			echo    "<TH colspan=\"1\" align=\"center\" width=\"15%\" class=\"td35\">Editare</TH>";		
			echo    "<TH colspan=\"1\" align=\"center\" width=\"15%\" class=\"td35\">Listare</TH>";
			echo    "<TH colspan=\"1\" align=\"center\" width=\"5%\" class=\"td39\">Anulat</TH>";			
			echo "</TR>";
			$platit_tot=0;
			$i=0;
			while ($row = mysql_fetch_array( $result))
			{
				echo "<FORM NAME=\"form3\" ACTION=\"A21_editare_chit.php\" METHOD=\"POST\" onsubmit=\"target_popup10(this)\">";
				include 'A21_param1.php';
				echo "<INPUT TYPE=\"HIDDEN\" NAME=\"codelev\" VALUE=\"".substr($_POST["actiune"],2,5)."\">";
				echo "<INPUT TYPE=\"HIDDEN\" NAME=\"tip_act\" VALUE=\"PLA\">";
				echo "<INPUT TYPE=\"HIDDEN\" NAME=\"nume\" VALUE=\"".$_POST["nume"]."\">";
				echo "<INPUT TYPE=\"HIDDEN\" NAME=\"prenume\" VALUE=\"".$_POST["prenume"]."\">";
				
				if ($row["anulat"] <> 'X')
				{				
					$platit_tot = $platit_tot+$row["val_doc"];
				}
			
				if ($i-floor($i/2)*2==0)
				{
					echo "<TR class=\"tr4\" BGCOLOR=\"#FFFFFF\">";
				}
				else
				{
					echo "<TR class=\"tr4\" BGCOLOR=\"#EAEBEB\">";
				}
		 
				echo "<TD colspan=\"1\" width=\"15%\" height=\"25px\" align=\"center\">",$i+1,"</TD>";
				echo"<TD colspan=\"1\" width=\"15%\" align=\"center\">";
				echo "&nbsp".$row["tip_doc"]."&nbsp";
				echo "</TD>";
				echo"<TD colspan=\"1\" width=\"20%\" align=\"center\">";
				if($row["tip_doc"]=="CHA")
				{
					echo "&nbsp".$row["serie_doc"]."_".$row["nr_doc"]."&nbsp";
				}
				else
				{
					echo "&nbsp".$row["nr_doc"]."&nbsp";
				}
				echo "</TD>";
				echo"<TD colspan=\"1\" width=\"20%\" align=\"center\">";
				echo "&nbsp".$row["data_doc"]."&nbsp";
				echo "</TD>";
				
				if ($row["anulat"] == 'X')
				{
					echo"<TD colspan=\"1\" width=\"15%\" align=\"center\">";
					echo "0&nbsp(".$row["val_doc"].")&nbsp";
					echo "</TD>";
					echo "<td colspan=\"1\" width=\"15%\" align=\"center\">";
					echo "</TD>";
				}
				else
				{
					echo"<TD colspan=\"1\" width=\"15%\" align=\"center\">";
					echo "&nbsp".$row["val_doc"]."&nbsp";
					echo "</TD>";
					echo "<td colspan=\"1\" width=\"15%\" align=\"center\">";
					echo "<INPUT TYPE=\"SUBMIT\" NAME=\"actiune\" id=\"button11\" VALUE=\"<".$row["id"].">\">";
					echo "<INPUT TYPE=\"HIDDEN\" NAME=\"nume\" VALUE=\"".$_POST["nume"]."\">";
					echo "<INPUT TYPE=\"HIDDEN\" NAME=\"prenume\" VALUE=\"".$_POST["prenume"]."\">";
					echo "</TD>";
				}
				
				if ($row["tip_doc"] == "CHA" and $row["anulat"] <> 'X')
				{	
					echo "</FORM>";
					echo "<FORM NAME=\"form3\" ACTION=\"A21_listare_chit.php\" METHOD=\"POST\" onsubmit=\"target_popup12(this)\">";		
					include 'A21_param1.php';
					echo "<INPUT TYPE=\"HIDDEN\" NAME=\"codelev\" VALUE=\"".substr($_POST["actiune"],2,5)."\">";
					echo "<INPUT TYPE=\"HIDDEN\" NAME=\"tip_act\" VALUE=\"PLA\">";
					
					echo "<td colspan=\"1\" width=\"15%\" align=\"center\">";
					echo "<INPUT TYPE=\"SUBMIT\" NAME=\"actiune\" id=\"button11\" VALUE=\"-".$row["id"]."-\">";
					echo "<INPUT TYPE=\"HIDDEN\" NAME=\"nume\" VALUE=\"".$_POST["nume"]."\">";
					echo "<INPUT TYPE=\"HIDDEN\" NAME=\"prenume\" VALUE=\"".$_POST["prenume"]."\">";
					echo "</TD>";
					echo "</FORM>";
				}			
				else
				{
					echo "<td colspan=\"1\" width=\"15%\" align=\"center\">";
					echo "</TD>";
				}
				echo"<TD colspan=\"1\" width=\"5%\" align=\"center\">";
				echo "&nbsp".$row["anulat"]."&nbsp";
				echo "</TD>";
				$i++;
			}
				
				echo "<TR>";
				echo "<TD>&nbsp</TD>";
				echo "</TR>";

				echo "<tr>";
			    echo "<td colspan=\"4\" align=\"right\">";
				echo "Total:";
				echo "</TD>";
			    echo "<td colspan=\"1\" align=\"center\">";
				echo $platit_tot;
				echo "</TD>";
				echo "</TR>";
				
				echo "<TR>";
				echo "<TD>&nbsp</TD>";
				echo "</TR>";
				
		echo "</form>";
		echo "</table>";	
		mysql_close($connection);
}

if ($_POST["actiune"]=="BORDEROU DEBITE SI PLATI")
{
	echo "<CENTER>";
			echo "<TABLE class=\"table2\" cellSpacing=0 cellPadding=0 width=\"100%\" border=0>";
			echo "<tr>";
			echo "<td bgcolor=\"white\" colspan=\"20\" height=\"1px\"></td>";
			echo "</tr>";
			echo "<TR BGCOLOR=\"#4EAEF2\">";
			echo "<TD colspan=\"11\" class=\"style2\" height=\"25\" align=\"center\">";
			echo "<B> ".$_POST["den_aplic"]."</B>";
			echo "</TD>";
			echo "</TR>";
			echo "<tr>";
			echo "<td bgcolor=\"white\" colspan=\"20\" height=\"1px\"></td>";
			echo "</tr>";
			echo "<TR BGCOLOR=\"#A3D9FF\">";
			echo "<TD width=\"250\" class=\"style2\" colspan=\"2\" height=\"25\" align=\"left\"><B>Unitatea: &nbsp".$_POST["denunit"]."</B>";
			echo "</TD>";
			echo "<TD width=\"100\" class=\"style2\"  height=\"25\" align=\"left\"><B>An:".$_POST["an"]."</B>";
			echo "</TD>";
			echo "</td>";
			echo "</tr>";
			echo "<tr>";
			echo "<td bgcolor=\"white\" colspan=\"20\" height=\"1px\"></td>";
			echo "</tr>";
			echo "</table>";
		
			echo "<TABLE class=\"table2\" cellSpacing=0 cellPadding=0 width=\"100%\" border=0>";
			echo "<tr>";
			echo "<td colspan=\"20\" height=\"1px\"></td>";
			echo "</tr>";
			echo "</table>";
			
			$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=\"form\" ACTION=\"A21_elevi.php\" METHOD=\"POST\">";
			include 'A21_param1.php';
		
	
			echo "<TABLE class=\"style1\" cellSpacing=0 cellPadding=0 width=\"100%\" border=0>";				
			echo "<TR>";
			echo "<TD align=\"center\" class=\"td_print2\">";
			echo "<B>BORDEROU DE DEBITE SI PLATI</B>";
			echo "<BR>";
			echo "</TD>";
			echo "</TR>";
						
			echo "<TR>";
			echo "<TD align=\"center\" class=\"td_print2\">";
			echo "<B>LUNA:&nbsp<U>".$_POST["denluna_sel"]."</U>&nbsp &nbsp  &nbsp &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp ANUL:&nbsp<U>".$_POST["an"]."</U></B>";
			echo "<BR>";
			echo "</TD>";
			echo "</TR>";
			echo "<TR>";
			echo "<TD align=\"center\" class=\"td_print2\">";
			echo "<B>GRUPA:&nbsp<U>".$_POST["dengrp_sel"]."</U>&nbsp &nbsp &nbsp &nbsp &nbsp</B>";
			echo "<BR>";
			echo "</TD>";
			echo "</TR>";
			echo "</TABLE>";
			
			echo "<TABLE cellSpacing=0 cellPadding=0 width=\"60%; height:100%;\" border=0 align=\"center\">";
			echo "<TR>";
			echo "<TD align=\"right\" height=\"35\">";
			echo "<input type=\"button\" class=\"noPrint\" onClick=\"window.print()\" value=\"PRINTARE\">";
			echo "<input type=\"submit\" class=\"noPrint\" name=\"actiune\" value=\"INAPOI\">";
			echo "</TD>";
			echo "</TR>";
			echo "</TABLE>";


			echo "<TABLE cellSpacing=0 cellPadding=0 width=\"60%\" class=\"tabel_bord\" border=0>";
			echo "<BR>";
			echo "<TR BGCOLOR=\"white\">";
			
			echo 	"<TH align=\"center\" rowspan=\"2\" width=\"2%\" class=\"td35\">Cod elev</TH>";					
			echo	"<TH align=\"center\" rowspan=\"2\" width=\"10%\"  class=\"td35\">Nume Prenume</TH>";		
			
			echo	"<TH align=\"center\" colspan=\"2\" scope=\"colgroup\" width=\"3%\" class=\"td39\">PRECEDENT</TH>";
			echo	"<TH align=\"center\" colspan=\"2\" scope=\"colgroup\" width=\"3%\" class=\"td35\">Luna &nbsp ".$_POST["denluna_sel"]."</TH>";	
			echo	"<TH align=\"center\" colspan=\"3\" scope=\"colgroup\" width=\"3%\" class=\"td39\">CUMULAT</TH>";
			echo 	"</TR>";
			echo    "<TR BGCOLOR=\"white\">";
			echo	"<TH align=\"center\" scope=\"row\" width=\"1%\" class=\"td35\">Debite</TH>";
			echo	"<TH align=\"center\" scope=\"row\" width=\"1%\" class=\"td35\">Plati</TH>";
			echo	"<TH align=\"center\" scope=\"row\" width=\"1%\" class=\"td35\">Debite</TH>";
			echo	"<TH align=\"center\" scope=\"row\" width=\"1%\" class=\"td35\">Plati</TH>";	
			echo	"<TH align=\"center\" scope=\"row\" width=\"1%\" class=\"td35\">Debite</TH>";
			echo	"<TH align=\"center\" scope=\"row\" width=\"1%\" class=\"td35\">Plati</TH>";
			echo	"<TH align=\"center\" scope=\"row\" width=\"1%\" class=\"td39\">Rest_PL</TH>";
			echo    "</TR>";
					
			$query="SELECT * FROM elevi WHERE codgrp=\"".$_POST["grp_sel"]."\"  order by nume,prenume,codelev";
			$result=mysql_query($query) or die("Interogare esuata: ".mysql_error());
	
		$i=0;
		$wlu=$_POST["luna_sel"];
		
		$wdebit=0;
		$wplati=0;
		$wrest=0;
		$wdebit_tot=0;
		$wplati_tot=0;
		$wrest_tot=0;
		$wdebit_prec=0;
		$wplati_prec=0;
		
		while($row=mysql_fetch_array($result))	
		{ 			
			if ($i-floor($i/2)*2==0)
			{
				echo "<TR class=\"tr4\" BGCOLOR=\"#FFFFFF\">";
			}
			else
			{
				echo "<TR class=\"tr4\" BGCOLOR=\"#EAEBEB\">";
			}
				echo "<TD width=\"2%\" align=\"center\">";
				echo "".$row["codelev"]."";
				echo "</TD>";
				echo"<TD width=\"10%\" align=\"left\">";
				echo "&nbsp".trim($row["nume"])." ".trim($row["prenume"])."&nbsp";
				echo "</TD>";

				if($wlu=="01")
				{			
					$debit_ln=$row["d_val00"]+$row["d_val01"];
					$plati_ln=$row["p_val01"];
					$rest_ln= $debit_ln - $plati_ln;
					
					$debit_prec=$debit_ln - $row["d_val01"];
					$plati_prec=$plati_ln - $row["p_val01"];
					
					if ($debit_prec == 0)
					{
						$debit_prec = ' ';
					}
					if ($plati_prec == 0 )
					{
						$plati_prec = ' ';
					}
					
					$wdebit_prec += $debit_prec;
					$wplati_prec += $plati_prec;
					
					$wdebit += $row["d_val01"];
					$wplati += $row["p_val01"];
					$wrest += $row["r_val01"];
					
					$wdebit_tot += $debit_ln;
					$wplati_tot += $plati_ln;
					$wrest_tot += $rest_ln;					
					
					echo"<TD width=\"1%\" align=\"right\">";
					echo "&nbsp".$debit_prec."&nbsp";
					echo "</TD>";
					echo"<TD width=\"1%\" align=\"right\">";
					echo "&nbsp".$plati_prec."&nbsp";
					echo "</TD>";
					
					echo"<TD width=\"1%\" align=\"right\">";
					echo "&nbsp".$row["d_val01"]."&nbsp";
					echo "</TD>";
					echo"<TD width=\"1%\" align=\"right\">";
					echo "&nbsp".$row["p_val01"]."&nbsp";
					echo "</TD>";
					echo"<TD width=\"1%\" align=\"right\">";					
					echo "<B>".$debit_ln."</B>&nbsp";
					echo "</TD>";
					echo"<TD width=\"1%\" align=\"right\">";					
					echo "<B>".$plati_ln."</B>&nbsp";
					echo "</TD>";
					echo"<TD width=\"1%\" align=\"right\">";					
					echo "<B>".$rest_ln."</B>&nbsp";
					echo "</TD>";									
				}
				if($wlu=="02")
				{
				
					$debit_ln=$row["d_val00"]+$row["d_val01"]+$row["d_val02"];
					$plati_ln=$row["p_val01"]+$row["p_val02"];
					$rest_ln= $debit_ln - $plati_ln;
					
					$debit_prec=$debit_ln - $row["d_val02"];
					$plati_prec=$plati_ln - $row["p_val02"];
					
					if ($debit_prec == 0)
					{
						$debit_prec = ' ';
					}
					if ($plati_prec == 0 )
					{
						$plati_prec = ' ';
					}
					
					$wdebit_prec += $debit_prec;
					$wplati_prec += $plati_prec;
					
					$wdebit += $row["d_val02"];
					$wplati += $row["p_val02"];
					$wrest += $row["r_val02"];
					
					$wdebit_tot += $debit_ln;
					$wplati_tot += $plati_ln;
					$wrest_tot += $rest_ln;
					
					echo"<TD width=\"1%\" align=\"right\">";
					echo "&nbsp".$debit_prec."&nbsp";
					echo "</TD>";
					echo"<TD width=\"1%\" align=\"right\">";
					echo "&nbsp".$plati_prec."&nbsp";
					echo "</TD>";
					
					echo"<TD width=\"1%\" align=\"right\">";
					echo "&nbsp".$row["d_val02"]."&nbsp";
					echo "</TD>";
					echo"<TD width=\"1%\" align=\"right\">";
					echo "&nbsp".$row["p_val02"]."&nbsp";
					echo "</TD>";				
					echo"<TD width=\"1%\" align=\"right\">";					
					echo "<B>".$debit_ln."</B>&nbsp";
					echo "</TD>";
					echo"<TD width=\"1%\" align=\"right\">";					
					echo "<B>".$plati_ln."</B>&nbsp";
					echo "</TD>";
					echo"<TD width=\"1%\" align=\"right\">";					
					echo "<B>".$rest_ln."</B>&nbsp";
					echo "</TD>";					
				}
				if($wlu=="03")
				{				
					$debit_ln=$row["d_val00"]+$row["d_val01"]+$row["d_val02"]+$row["d_val03"];
					$plati_ln=$row["p_val01"]+$row["p_val02"]+$row["p_val03"];
					$rest_ln= $debit_ln - $plati_ln;
					
					$debit_prec=$debit_ln - $row["d_val03"];
					$plati_prec=$plati_ln - $row["p_val03"];
					
					if ($debit_prec == 0)
					{
						$debit_prec = ' ';
					}
					if ($plati_prec == 0 )
					{
						$plati_prec = ' ';
					}
					
					$wdebit_prec += $debit_prec;
					$wplati_prec += $plati_prec;
					
					$wdebit += $row["d_val03"];
					$wplati += $row["p_val03"];
					$wrest += $row["r_val03"];
					
					$wdebit_tot += $debit_ln;
					$wplati_tot += $plati_ln;
					$wrest_tot += $rest_ln;
					
					echo"<TD width=\"1%\" align=\"right\">";
					echo "&nbsp".$debit_prec."&nbsp";
					echo "</TD>";
					echo"<TD width=\"1%\" align=\"right\">";
					echo "&nbsp".$plati_prec."&nbsp";
					echo "</TD>";				
					echo"<TD width=\"1%\" align=\"right\">";
					echo "&nbsp".$row["d_val03"]."&nbsp";
					echo "</TD>";
					echo"<TD width=\"1%\" align=\"right\">";
					echo "&nbsp".$row["p_val03"]."&nbsp";
					echo "</TD>";				
					echo"<TD width=\"1%\" align=\"right\">";					
					echo "<B>".$debit_ln."</B>&nbsp";
					echo "</TD>";
					echo"<TD width=\"1%\" align=\"right\">";					
					echo "<B>".$plati_ln."</B>&nbsp";
					echo "</TD>";		
					echo"<TD width=\"1%\" align=\"right\">";					
					echo "<B>".$rest_ln."</B>&nbsp";
					echo "</TD>";		
				}
				if($wlu=="04")
				{
					$debit_ln=$row["d_val00"]+$row["d_val01"]+$row["d_val02"]+$row["d_val03"]+$row["d_val04"];
					$plati_ln=$row["p_val01"]+$row["p_val02"]+$row["p_val03"]+$row["p_val04"];
					$rest_ln= $debit_ln - $plati_ln;
					
					$debit_prec=$debit_ln - $row["d_val04"];
					$plati_prec=$plati_ln - $row["p_val04"];
					
					if ($debit_prec == 0)
					{
						$debit_prec = ' ';
					}
					if ($plati_prec == 0 )
					{
						$plati_prec = ' ';
					}
					
					$wdebit_prec += $debit_prec;
					$wplati_prec += $plati_prec;
					
					$wdebit += $row["d_val04"];
					$wplati += $row["p_val04"];
					$wrest += $row["r_val04"];
					
					$wdebit_tot += $debit_ln;
					$wplati_tot += $plati_ln;
					$wrest_tot += $rest_ln;
					
					echo"<TD width=\"1%\" align=\"right\">";
					echo "&nbsp".$debit_prec."&nbsp";
					echo "</TD>";
					echo"<TD width=\"1%\" align=\"right\">";
					echo "&nbsp".$plati_prec."&nbsp";
					echo "</TD>";
					echo"<TD width=\"1%\" align=\"right\">";
					echo "&nbsp".$row["d_val04"]."&nbsp";
					echo "</TD>";
					echo"<TD width=\"1%\" align=\"right\">";
					echo "&nbsp".$row["p_val04"]."&nbsp";
					echo "</TD>";			
					echo"<TD width=\"1%\" align=\"right\">";					
					echo "<B>".$debit_ln."</B>&nbsp";
					echo "</TD>";
					echo"<TD width=\"1%\" align=\"right\">";					
					echo "<B>".$plati_ln."</B>&nbsp";
					echo "</TD>";
					echo"<TD width=\"1%\" align=\"right\">";					
					echo "<B>".$rest_ln."</B>&nbsp";
					echo "</TD>";				
				}
				if($wlu=="05")
				{
					$debit_ln=$row["d_val00"]+$row["d_val01"]+$row["d_val02"]+$row["d_val03"]+$row["d_val04"]+$row["d_val05"];
					$plati_ln=$row["p_val01"]+$row["p_val02"]+$row["p_val03"]+$row["p_val04"]+$row["p_val05"];
					$rest_ln= $debit_ln - $plati_ln;
					
					$debit_prec=$debit_ln - $row["d_val05"];
					$plati_prec=$plati_ln - $row["p_val05"];
					
					if ($debit_prec == 0)
					{
						$debit_prec = ' ';
					}
					if ($plati_prec == 0 )
					{
						$plati_prec = ' ';
					}
					
					$wdebit_prec += $debit_prec;
					$wplati_prec += $plati_prec;
					
					$wdebit += $row["d_val05"];
					$wplati += $row["p_val05"];
					$wrest += $row["r_val05"];
					
					$wdebit_tot += $debit_ln;
					$wplati_tot += $plati_ln;
					$wrest_tot += $rest_ln;
					
					echo"<TD width=\"1%\" align=\"right\">";
					echo "&nbsp".$debit_prec."&nbsp";
					echo "</TD>";
					echo"<TD width=\"1%\" align=\"right\">";
					echo "&nbsp".$plati_prec."&nbsp";
					echo "</TD>";
					echo"<TD width=\"1%\" align=\"right\">";
					echo "&nbsp".$row["d_val05"]."&nbsp";
					echo "</TD>";
					echo"<TD width=\"1%\" align=\"right\">";
					echo "&nbsp".$row["p_val05"]."&nbsp";
					echo "</TD>";				
					echo"<TD width=\"1%\" align=\"right\">";					
					echo "<B>".$debit_ln."</B>&nbsp";
					echo "</TD>";
					echo"<TD width=\"1%\" align=\"right\">";					
					echo "<B>".$plati_ln."</B>&nbsp";
					echo "</TD>";
					echo"<TD width=\"1%\" align=\"right\">";					
					echo "<B>".$rest_ln."</B>&nbsp";
					echo "</TD>";				
				}
				if($wlu=="06")
				{
					$debit_ln=$row["d_val00"]+$row["d_val01"]+$row["d_val02"]+$row["d_val03"]+$row["d_val04"]+$row["d_val05"]+$row["d_val06"];
					$plati_ln=$row["p_val01"]+$row["p_val02"]+$row["p_val03"]+$row["p_val04"]+$row["p_val05"]+$row["p_val06"];
					$rest_ln= $debit_ln - $plati_ln;
					
					$debit_prec=$debit_ln - $row["d_val06"];
					$plati_prec=$plati_ln - $row["p_val06"];
					
					if ($debit_prec == 0)
					{
						$debit_prec = ' ';
					}
					if ($plati_prec == 0 )
					{
						$plati_prec = ' ';
					}
					
					$wdebit_prec += $debit_prec;
					$wplati_prec += $plati_prec;
					
					$wdebit += $row["d_val06"];
					$wplati += $row["p_val06"];
					$wrest += $row["r_val06"];
					
					$wdebit_tot += $debit_ln;
					$wplati_tot += $plati_ln;
					$wrest_tot += $rest_ln;
					
					echo"<TD width=\"1%\" align=\"right\">";
					echo "&nbsp".$debit_prec."&nbsp";
					echo "</TD>";
					echo"<TD width=\"1%\" align=\"right\">";
					echo "&nbsp".$plati_prec."&nbsp";
					echo "</TD>";
					echo"<TD width=\"1%\" align=\"right\">";
					echo "&nbsp".$row["d_val06"]."&nbsp";
					echo "</TD>";
					echo"<TD width=\"1%\" align=\"right\">";
					echo "&nbsp".$row["p_val06"]."&nbsp";
					echo "</TD>";					
					echo"<TD width=\"1%\" align=\"right\">";					
					echo "<B>".$debit_ln."</B>&nbsp";
					echo "</TD>";
					echo"<TD width=\"1%\" align=\"right\">";					
					echo "<B>".$plati_ln."</B>&nbsp";
					echo "</TD>";
					echo"<TD width=\"1%\" align=\"right\">";					
					echo "<B>".$rest_ln."</B>&nbsp";
					echo "</TD>";				
				}
				if($wlu=="07")
				{
					$debit_ln=$row["d_val00"]+$row["d_val01"]+$row["d_val02"]+$row["d_val03"]+$row["d_val04"]+$row["d_val05"]+$row["d_val06"]+$row["d_val07"];
					$plati_ln=$row["p_val01"]+$row["p_val02"]+$row["p_val03"]+$row["p_val04"]+$row["p_val05"]+$row["p_val06"]+$row["p_val07"];
					$rest_ln= $debit_ln - $plati_ln;
					
					$debit_prec=$debit_ln - $row["d_val07"];
					$plati_prec=$plati_ln - $row["p_val07"];
					
					if ($debit_prec == 0)
					{
						$debit_prec = ' ';
					}
					if ($plati_prec == 0 )
					{
						$plati_prec = ' ';
					}
					
					$wdebit_prec += $debit_prec;
					$wplati_prec += $plati_prec;
					
					$wdebit += $row["d_val07"];
					$wplati += $row["p_val07"];
					$wrest += $row["r_val07"];
					
					$wdebit_tot += $debit_ln;
					$wplati_tot += $plati_ln;
					$wrest_tot += $rest_ln;
					
					echo"<TD width=\"1%\" align=\"right\">";
					echo "&nbsp".$debit_prec."&nbsp";
					echo "</TD>";
					echo"<TD width=\"1%\" align=\"right\">";
					echo "&nbsp".$plati_prec."&nbsp";
					echo "</TD>";
					echo"<TD width=\"1%\" align=\"right\">";
					echo "&nbsp".$row["d_val07"]."&nbsp";
					echo "</TD>";
					echo"<TD width=\"1%\" align=\"right\">";
					echo "&nbsp".$row["p_val07"]."&nbsp";
					echo "</TD>";
					echo"<TD width=\"1%\" align=\"right\">";					
					echo "<B>".$debit_ln."</B>&nbsp";
					echo "</TD>";
					echo"<TD width=\"1%\" align=\"right\">";					
					echo "<B>".$plati_ln."</B>&nbsp";
					echo "</TD>";
					echo"<TD width=\"1%\" align=\"right\">";				
					echo "<B>".$rest_ln."</B>&nbsp";
					echo "</TD>";				
				}
				if($wlu=="08")
				{
					$debit_ln=$row["d_val00"]+$row["d_val01"]+$row["d_val02"]+$row["d_val03"]+$row["d_val04"]+$row["d_val05"]+$row["d_val06"]+$row["d_val07"]+$row["d_val08"];
					$plati_ln=$row["p_val01"]+$row["p_val02"]+$row["p_val03"]+$row["p_val04"]+$row["p_val05"]+$row["p_val06"]+$row["p_val07"]+$row["p_val08"];
					$rest_ln= $debit_ln - $plati_ln;
					
					$debit_prec=$debit_ln - $row["d_val08"];
					$plati_prec=$plati_ln - $row["p_val08"];
					
					if ($debit_prec == 0)
					{
						$debit_prec = ' ';
					}
					if ($plati_prec == 0 )
					{
						$plati_prec = ' ';
					}
					
					$wdebit_prec += $debit_prec;
					$wplati_prec += $plati_prec;
					
					$wdebit += $row["d_val08"];
					$wplati += $row["p_val08"];
					$wrest += $row["r_val08"];
					
					$wdebit_tot += $debit_ln;
					$wplati_tot += $plati_ln;
					$wrest_tot += $rest_ln;
					
					echo"<TD width=\"1%\" align=\"right\">";
					echo "&nbsp".$debit_prec."&nbsp";
					echo "</TD>";
					echo"<TD width=\"1%\" align=\"right\">";
					echo "&nbsp".$plati_prec."&nbsp";
					echo "</TD>";
					echo"<TD width=\"1%\" align=\"right\">";
					echo "&nbsp".$row["d_val08"]."&nbsp";
					echo "</TD>";
					echo"<TD width=\"1%\" align=\"right\">";
					echo "&nbsp".$row["p_val08"]."&nbsp";
					echo "</TD>";
					echo"<TD width=\"1%\" align=\"right\">";					
					echo "<B>".$debit_ln."</B>&nbsp";
					echo "</TD>";
					echo"<TD width=\"1%\" align=\"right\">";					
					echo "<B>".$plati_ln."</B>&nbsp";
					echo "</TD>";
					echo"<TD width=\"1%\" align=\"right\">";					
					echo "<B>".$rest_ln."</B>&nbsp";
					echo "</TD>";									
				}
				if($wlu=="09")
				{
					$debit_ln=$row["d_val00"]+$row["d_val01"]+$row["d_val02"]+$row["d_val03"]+$row["d_val04"]+$row["d_val05"]+$row["d_val06"]+$row["d_val07"]+$row["d_val08"]+$row["d_val09"];
					$plati_ln=$row["p_val01"]+$row["p_val02"]+$row["p_val03"]+$row["p_val04"]+$row["p_val05"]+$row["p_val06"]+$row["p_val07"]+$row["p_val08"]+$row["p_val09"];
					$rest_ln= $debit_ln - $plati_ln;
					
					$debit_prec=$debit_ln - $row["d_val09"];
					$plati_prec=$plati_ln - $row["p_val09"];
					
					if ($debit_prec == 0)
					{
						$debit_prec = ' ';
					}
					if ($plati_prec == 0 )
					{
						$plati_prec = ' ';
					}
					
					$wdebit_prec += $debit_prec;
					$wplati_prec += $plati_prec;
					
					$wdebit += $row["d_val09"];
					$wplati += $row["p_val09"];
					$wrest += $row["r_val09"];
					
					$wdebit_tot += $debit_ln;
					$wplati_tot += $plati_ln;
					$wrest_tot += $rest_ln;
					
					echo"<TD width=\"1%\" align=\"right\">";
					echo "&nbsp".$debit_prec."&nbsp";
					echo "</TD>";
					echo"<TD width=\"1%\" align=\"right\">";
					echo "&nbsp".$plati_prec."&nbsp";
					echo "</TD>";
					echo"<TD width=\"1%\" align=\"right\">";
					echo "&nbsp".$row["d_val09"]."&nbsp";
					echo "</TD>";
					echo"<TD width=\"1%\" align=\"right\">";
					echo "&nbsp".$row["p_val09"]."&nbsp";
					echo "</TD>";
					echo"<TD width=\"1%\" align=\"right\">";					
					echo "<B>".$debit_ln."</B>&nbsp";
					echo "</TD>";
					echo"<TD width=\"1%\" align=\"right\">";					
					echo "<B>".$plati_ln."</B>&nbsp";
					echo "</TD>";
					echo"<TD width=\"1%\" align=\"right\">";					
					echo "<B>".$rest_ln."</B>&nbsp";
					echo "</TD>";					
				}
				if($wlu=="10")
				{
					$debit_ln=$row["d_val00"]+$row["d_val01"]+$row["d_val02"]+$row["d_val03"]+$row["d_val04"]+$row["d_val05"]+$row["d_val06"]+$row["d_val07"]+$row["d_val08"]+$row["d_val09"]+$row["d_val10"];
					$plati_ln=$row["p_val01"]+$row["p_val02"]+$row["p_val03"]+$row["p_val04"]+$row["p_val05"]+$row["p_val06"]+$row["p_val07"]+$row["p_val08"]+$row["p_val09"]+$row["p_val10"];
					$rest_ln= $debit_ln - $plati_ln;
					
					$debit_prec=$debit_ln - $row["d_val10"];
					$plati_prec=$plati_ln - $row["p_val10"];
					
					if ($debit_prec == 0)
					{
						$debit_prec = ' ';
					}
					if ($plati_prec == 0 )
					{
						$plati_prec = ' ';
					}
					
					$wdebit_prec += $debit_prec;
					$wplati_prec += $plati_prec;
					
					$wdebit += $row["d_val10"];
					$wplati += $row["p_val10"];
					$wrest += $row["r_val10"];
					
					$wdebit_tot += $debit_ln;
					$wplati_tot += $plati_ln;
					$wrest_tot += $rest_ln;
				
					echo"<TD width=\"1%\" align=\"right\">";
					echo "&nbsp".$debit_prec."&nbsp";
					echo "</TD>";
					echo"<TD width=\"1%\" align=\"right\">";
					echo "&nbsp".$plati_prec."&nbsp";
					echo "</TD>";
					echo"<TD width=\"1%\" align=\"right\">";
					echo "&nbsp".$row["d_val10"]."&nbsp";
					echo "</TD>";
					echo"<TD width=\"1%\" align=\"right\">";
					echo "&nbsp".$row["p_val10"]."&nbsp";
					echo "</TD>";
					echo"<TD width=\"1%\" align=\"right\">";					
					echo "<B>".$debit_ln."</B>&nbsp";
					echo "</TD>";
					echo"<TD width=\"1%\" align=\"right\">";					
					echo "<B>".$plati_ln."</B>&nbsp";
					echo "</TD>";
					echo"<TD width=\"1%\" align=\"right\">";					
					echo "<B>".$rest_ln."</B>&nbsp";
					echo "</TD>";				
				}
				if($wlu=="11")
				{
					$debit_ln=$row["d_val00"]+$row["d_val01"]+$row["d_val02"]+$row["d_val03"]+$row["d_val04"]+$row["d_val05"]+$row["d_val06"]+$row["d_val07"]+$row["d_val08"]+$row["d_val09"]+$row["d_val10"]+$row["d_val11"];
					$plati_ln=$row["p_val01"]+$row["p_val02"]+$row["p_val03"]+$row["p_val04"]+$row["p_val05"]+$row["p_val06"]+$row["p_val07"]+$row["p_val08"]+$row["p_val09"]+$row["p_val10"]+$row["p_val11"];
					$rest_ln= $debit_ln - $plati_ln;
					
					$debit_prec=$debit_ln - $row["d_val11"];
					$plati_prec=$plati_ln - $row["p_val11"];

					if ($debit_prec == 0)
					{
						$debit_prec = ' ';
					}
					if ($plati_prec == 0 )
					{
						$plati_prec = ' ';
					}					
					
					$wdebit += $row["d_val11"];
					$wplati += $row["p_val11"];
					$wrest += $row["r_val11"];
					
					$wdebit_prec += $debit_prec;
					$wplati_prec += $plati_prec;
					
					$wdebit_tot += $debit_ln;
					$wplati_tot += $plati_ln;
					$wrest_tot += $rest_ln;
					
					echo"<TD width=\"1%\" align=\"right\">";
					echo "&nbsp".$debit_prec."&nbsp";
					echo "</TD>";
					echo"<TD width=\"1%\" align=\"right\">";
					echo "&nbsp".$plati_prec."&nbsp";
					echo "</TD>";
					echo"<TD width=\"1%\" align=\"right\">";
					echo "&nbsp".$row["d_val11"]."&nbsp";
					echo "</TD>";
					echo"<TD width=\"1%\" align=\"right\">";
					echo "&nbsp".$row["p_val11"]."&nbsp";
					echo "</TD>";	
					echo"<TD width=\"1%\" align=\"right\">";					
					echo "<B>".$debit_ln."</B>&nbsp";
					echo "</TD>";
					echo"<TD width=\"1%\" align=\"right\">";					
					echo "<B>".$plati_ln."</B>&nbsp";
					echo "</TD>";
					echo"<TD width=\"1%\" align=\"right\">";					
					echo "<B>".$rest_ln."</B>&nbsp";
					echo "</TD>";									
				}
				if($wlu=="12")
				{
					$debit_ln=$row["d_val00"]+$row["d_val01"]+$row["d_val02"]+$row["d_val03"]+$row["d_val04"]+$row["d_val05"]+$row["d_val06"]+$row["d_val07"]+$row["d_val08"]+$row["d_val09"]+$row["d_val10"]+$row["d_val11"]+$row["d_val12"];
					$plati_ln=$row["p_val01"]+$row["p_val02"]+$row["p_val03"]+$row["p_val04"]+$row["p_val05"]+$row["p_val06"]+$row["p_val07"]+$row["p_val08"]+$row["p_val09"]+$row["p_val10"]+$row["p_val11"]+$row["p_val12"];
					$rest_ln= $debit_ln - $plati_ln;
					
					$debit_prec=$debit_ln - $row["d_val12"];
					$plati_prec=$plati_ln - $row["p_val12"];
					
					if ($debit_prec == 0)
					{
						$debit_prec = ' ';
					}
					if ($plati_prec == 0 )
					{
						$plati_prec = ' ';
					}
					
					$wdebit += $row["d_val12"];
					$wplati += $row["p_val12"];
					$wrest += $row["r_val12"];
					
					$wdebit_prec += $debit_prec;
					$wplati_prec += $plati_prec;
					
					$wdebit_tot += $debit_ln;
					$wplati_tot += $plati_ln;
					$wrest_tot += $rest_ln;
				
					echo"<TD width=\"1%\" align=\"right\">";
					echo "&nbsp".$debit_prec."&nbsp";
					echo "</TD>";
					echo"<TD width=\"2%\" align=\"right\">";
					echo "&nbsp".$plati_prec."&nbsp";
					echo "</TD>";
					echo"<TD width=\"1%\" align=\"right\">";
					echo "&nbsp".$row["d_val12"]."&nbsp";
					echo "</TD>";
					echo"<TD width=\"2%\" align=\"right\">";
					echo "&nbsp".$row["p_val12"]."&nbsp";
					echo "</TD>";
					echo"<TD width=\"2%\" align=\"right\">";					
					echo "<B>".$debit_ln."</B>&nbsp";
					echo "</TD>";
					echo"<TD width=\"1%\" align=\"right\">";					
					echo "<B>".$plati_ln."</B>&nbsp";
					echo "</TD>";
					echo"<TD width=\"2%\" align=\"right\">";					
					echo "<B>".$rest_ln."</B>&nbsp";
					echo "</TD>";									
				}
				
				
				echo "</TR>";
				$i++;
		}		

			echo "<TR>";
			echo "<TD colspan=\"9\">&nbsp</TD>";
			echo "</TR>";
			echo "<TR>";
			echo "<TD colspan=\"9\"><HR></HR>&nbsp</TD>";
			echo "</TR>";			
			echo "<TR class=\"tr4\">";		
			echo "<TD width=\"2%\" align=\"center\">";
			echo "</TD>";
			echo"<TD width=\"10%\" align=\"right\">";
			echo "<B>TOTAL:</B>";
			echo "</TD>";
			echo"<TD width=\"1%\" align=\"right\">";
			echo "<B>&nbsp".$wdebit_prec."&nbsp</B>";
			echo "</TD>";
			echo"<TD width=\"1%\" align=\"right\">";
			echo "<B>&nbsp".$wplati_prec."&nbsp</B>";
			echo "</TD>";			
			echo"<TD width=\"1%\" align=\"right\">";
			echo "<B>&nbsp".$wdebit."&nbsp</B>";
			echo "</TD>";
			echo"<TD width=\"1%\" align=\"right\">";
			echo "<B>&nbsp".$wplati."&nbsp</B>";
			echo "</TD>";
			echo"<TD width=\"1%\" align=\"right\">";					
			echo "<B>".$wdebit_tot."</B>&nbsp";
			echo "</TD>";
			echo"<TD width=\"1%\" align=\"right\">";					
			echo "<B>".$wplati_tot."</B>&nbsp";
			echo "</TD>";
			echo"<TD width=\"1%\" align=\"right\">";					
			echo "<B>".$wrest_tot."</B>&nbsp";
			echo "</TD>";		
			echo "</table>";
/*		
			echo "<TABLE cellSpacing=0 cellPadding=0 width=\"60%\" class=\"tabel_bord_1\" border=0 align=\"center\">";
			echo "<BR>";
			echo "<tr>";
			echo "<hr width=\"60%\" class=\"hr_bord\" align=\"center\">";			
			echo "</tr>";
			echo "<TR>";
			echo 	"<TD align=\"right\" width=\"2%\"></TD>";					
			echo	"<TD align=\"right\" class=\"td41\"></TD>";
			echo	"<TD align=\"right\" width=\"1%\" class=\"td_bord\"><B>TOTAL:</B></TD>";
			echo	"<TD align=\"right\" width=\"2%\"><B>$wdebit_prec</B></TD>";
			echo	"<TD align=\"right\" width=\"2%\"><B>$wplati_prec</B></TD>";	
			echo	"<TD align=\"right\" width=\"2%\"><B>$wdebit</B></TD>";
			echo	"<TD align=\"right\" width=\"2%\"><B>$wplati</B></TD>";		
			echo	"<TD align=\"right\" width=\"2%\"><B>$wdebit_tot</B></TD>";
			echo	"<TD align=\"right\" width=\"2%\"><B>$wplati_tot</B></TD>";
			echo	"<TD align=\"right\" width=\"3%\"><B>$wrest_tot</B></TD>";
			echo "</TR>";
*/
		echo "</form>";
		
		include 'A03_denfunctii.php';
		
		echo "</table>";	
		echo "</div>";
		echo "</div>";
		mysql_close($connection);		
}

if ($_POST["actiune"]=="BORDEROU INCASARI")
{
	echo "<CENTER>";
			echo "<TABLE class=\"table2\" cellSpacing=0 cellPadding=0 width=\"100%\" border=0>";
			echo "<tr>";
			echo "<td bgcolor=\"white\" colspan=\"20\" height=\"1px\"></td>";
			echo "</tr>";
			echo "<TR BGCOLOR=\"#4EAEF2\">";
			echo "<TD colspan=\"11\" class=\"style2\" height=\"25\" align=\"center\">";
			echo "<B> ".$_POST["den_aplic"]."</B>";
			echo "</TD>";
			echo "</TR>";
			echo "<tr>";
			echo "<td bgcolor=\"white\" colspan=\"20\" height=\"1px\"></td>";
			echo "</tr>";
			echo "<TR BGCOLOR=\"#A3D9FF\">";
			echo "<TD width=\"250\" class=\"style2\" colspan=\"2\" height=\"25\" align=\"left\"><B>Unitatea: &nbsp".$_POST["denunit"]."</B>";
			echo "</TD>";
			echo "<TD width=\"100\" class=\"style2\"  height=\"25\" align=\"left\"><B>An:".$_POST["an"]."</B>";
			echo "</TD>";
			echo "</td>";
			echo "</tr>";
			echo "<tr>";
			echo "<td bgcolor=\"white\" colspan=\"20\" height=\"1px\"></td>";
			echo "</tr>";
			echo "</table>";
	
			echo "<TABLE class=\"table2\" cellSpacing=0 cellPadding=0 width=\"100%\" border=0>";
			echo "<tr>";
			echo "<td colspan=\"20\" height=\"1px\"></td>";
			echo "</tr>";
			echo "</table>";
			
			$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=\"form\" ACTION=\"A21_elevi.php\" METHOD=\"POST\">";
			include 'A21_param1.php';
			
			echo "<TABLE class=\"style1\" cellSpacing=0 cellPadding=0 width=\"100%\" border=0>";				
			echo "<TR>";
			echo "<TD align=\"center\" class=\"td_print2\">";
			echo "<B>BORDEROU INCASARI</B>";
			echo "<BR>";
			echo "</TD>";
			echo "</TR>";
				
			echo "<TR>";
			echo "<TD align=\"center\" class=\"td_print2\">";
			echo "<B>LUNA:&nbsp<U>".$_POST["denluna_sel"]."</U>&nbsp &nbsp  &nbsp &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp ANUL:&nbsp<U>".$_POST["an"]."</U></B>";
			echo "<BR>";
			echo "</TD>";
			echo "</TR>";
			echo "<TR>";
			echo "<TD align=\"center\" class=\"td_print2\">";
			echo "<B>GRUPA:&nbsp<U>".$_POST["dengrp_sel"]."</U>&nbsp &nbsp &nbsp &nbsp &nbsp</B>";
			echo "<BR>";
			echo "</TD>";
			echo "</TR>";
			echo "</div>";
			echo "</TABLE>";
			
			echo "<TABLE cellSpacing=0 cellPadding=0 width=\"60%;\" border=0 align=\"center\">";
			echo "<TR>";
			echo "<TD align=\"right\" height=\"35\">";
			echo "<input type=\"button\" class=\"noPrint\" onClick=\"window.print()\" value=\"PRINTARE\">";
			echo "<input type=\"submit\" class=\"noPrint\" name=\"actiune\" value=\"INAPOI\">";
			echo "</TD>";
			echo "</TR>";
			echo "</TABLE>";
 
			echo "<TABLE cellSpacing=0 cellPadding=0 class=\"table23\" border=0>";
			echo "<BR>";
			echo "<TR BGCOLOR=\"white\">";
			
			echo 	"<TH align=\"center\" width=\"2%\" class=\"td35\">Nr. crt.</TH>";
			echo 	"<TH align=\"center\" width=\"4%\" class=\"td35\">Cod elev</TH>";					
			echo	"<TH align=\"center\" width=\"15%\"  class=\"td35\">Nume Prenume</TH>";
			echo	"<TH align=\"center\" width=\"3%\" class=\"td35\">Tip doc</TH>";		
			echo	"<TH align=\"center\" width=\"8%\" class=\"td35\">Data</TH>";			
			echo	"<TH align=\"center\" width=\"4%\" class=\"td35\">Nr. chitanta</TH>";
			echo	"<TH align=\"center\" width=\"4%\" class=\"td35\">Suma</TH>";
			echo	"<TH align=\"center\" width=\"3%\" class=\"td39\">Anulat</TH>";
			echo    "</TR>";
			
			$query="SELECT * FROM chitante WHERE codgrp=\"".$_POST["grp_sel"]."\" and ln = \"".$_POST["luna_sel"]."\" order by data_doc,nr_doc";
			$result=mysql_query($query) or die("Interogare esuata: ".mysql_error());
		
		$i=0;
		$wcodelevp = ' ';
		//$wlu=substr($_POST["luna_sel"],0,2);
		$suma_tot=0;
		while($row = mysql_fetch_array( $result))	
		{ 	
			if ($row["anulat"] <> 'X')
			{
				$suma_tot += $row["val_doc"];
			}	
			$data_doc = date("d-m-Y", strtotime($row["data_doc"]));
		
			$wcodelev = $row["codelev"];
			
			if ($i-floor($i/2)*2==0)
			{
				echo "<TR class=\"tr4\" BGCOLOR=\"#FFFFFF\">";
			}
			else
			{
				echo "<TR class=\"tr4\" BGCOLOR=\"#EAEBEB\">";
			}
			
			echo "<TD width=\"2%\" align=\"center\">",$i+1,"</TD>";
							
				echo "<TD width=\"4%\" align=\"center\">";
				echo "".$row["codelev"]."";
				echo "</TD>";
				
				$query2="SELECT * FROM elevi WHERE codgrp=\"".substr($_POST["grp_sel"],0,2)."\" and codelev=\"".$wcodelev."\" group by nume,prenume";
				$result2=mysql_query($query2) or die("Interogare esuata: ".mysql_error());	
				$row2 = mysql_fetch_array( $result2);	
				
					echo"<TD width=\"15%\" align=\"left\">";
					echo "&nbsp".trim($row2["nume"])." ".trim($row2["prenume"])."&nbsp";
					echo "</TD>";
					
					$wcodelevp = $row["codelev"];			
		
				echo"<TD width=\"3%\" align=\"center\">";
				echo "&nbsp".$row["tip_doc"]."&nbsp";
				echo "</TD>";
				echo"<TD width=\"8%\" align=\"center\">";
				echo "&nbsp".$data_doc."&nbsp";
				echo "</TD>";
				
				if ($row["tip_doc"] == "CHA")
				{
					echo"<TD width=\"4%\" align=\"center\">";
					echo "&nbsp".$row["serie_doc"]."_".$row["nr_doc"]."&nbsp";
					echo "</TD>";
				}
				else
				{				
					echo"<TD width=\"4%\" align=\"center\">";
					echo "&nbsp".$row["nr_doc"]."&nbsp";
					echo "</TD>";
				}
				if ($row["anulat"] == 'X')
				{
					echo"<TD width=\"4%\" align=\"center\">";
					echo "0&nbsp(".$row["val_doc"].")&nbsp";
					echo "</TD>";
				}
				else
				{				
					echo"<TD width=\"4%\" align=\"center\">";
					echo "&nbsp".$row["val_doc"]."&nbsp";
					echo "</TD>";
				}	
				echo"<TD width=\"3%\" align=\"center\">";
				echo "&nbsp".$row["anulat"]."&nbsp";
				echo "</TD>";
				echo "</TR>";
				$i++;			
		}
		
			echo "<TR>";
			echo "<TD colspan=\"9\">&nbsp</TD>";
			echo "</TR>";
			echo "<TR>";
			echo "<TD colspan=\"9\"><HR></HR>&nbsp</TD>";
			echo "</TR>";	
			echo "<TR>";	
			echo "<TD width=\"2%\" align=\"center\">&nbsp</TD>";				
			echo "<TD width=\"4%\" align=\"center\">&nbsp</TD>";
			echo"<TD width=\"15%\" align=\"left\">&nbsp</TD>";
			echo"<TD width=\"3%\" align=\"center\">&nbsp</TD>";
			echo"<TD width=\"8%\" align=\"center\">&nbsp</TD>";
			echo"<TD width=\"4%\" align=\"center\"><B>TOTAL:</B></TD>";
			echo"<TD width=\"4%\" align=\"center\"><B>$suma_tot</B></TD>";	
			echo"<TD width=\"3%\" align=\"center\">&nbsp</TD>";
			echo "</TR>";
/*
			echo "<TABLE cellSpacing=0 cellPadding=0 width=\"60%\" border=0 align=\"center\">";
			echo "<BR>";
			echo "<tr>";
			echo "<hr class=\"hr3\" align=\"center\">";			
			echo "</tr>";
			echo "<TR>";		
			echo	"<TD align=\"right\" class=\"td_tot\"><B>TOTAL:</B></TD>";	
			echo	"<TD align=\"center\" class=\"td_sum\"><B>$suma_tot</B></TD>";
			echo "</TR>";
			echo "</TABLE>";
*/			
			include 'A03_denfunctii.php';
			
			
	mysql_close($connection);
		
}
if ($_POST["actiune"]=="RECAPITULATIE")
{
	echo "<CENTER>";
			echo "<TABLE class=\"table2\" cellSpacing=0 cellPadding=0 width=\"100%\" border=0>";
			echo "<tr>";
			echo "<td bgcolor=\"white\" colspan=\"20\" height=\"1px\"></td>";
			echo "</tr>";
			echo "<TR BGCOLOR=\"#4EAEF2\">";
			echo "<TD colspan=\"11\" class=\"style2\" height=\"25\" align=\"center\">";
			echo "<B> ".$_POST["den_aplic"]."</B>";
			echo "</TD>";
			echo "</TR>";
			echo "<tr>";
			echo "<td bgcolor=\"white\" colspan=\"20\" height=\"1px\"></td>";
			echo "</tr>";
			echo "<TR BGCOLOR=\"#A3D9FF\">";
			echo "<TD width=\"250\" class=\"style2\" colspan=\"2\" height=\"25\" align=\"left\"><B>Unitatea: &nbsp".$_POST["denunit"]."</B>";
			echo "</TD>";
			echo "<TD width=\"100\" class=\"style2\"  height=\"25\" align=\"left\"><B>An:".$_POST["an"]."</B>";
			echo "</TD>";
			echo "</td>";
			echo "</tr>";
			echo "<tr>";
			echo "<td bgcolor=\"white\" colspan=\"20\" height=\"1px\"></td>";
			echo "</tr>";
			echo "</table>";
	
			echo "<TABLE class=\"table2\" cellSpacing=0 cellPadding=0 width=\"100%\" border=0>";
			echo "<tr>";
			echo "<td colspan=\"20\" height=\"1px\"></td>";
			echo "</tr>";
			echo "</table>";
			
			$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=\"form\" ACTION=\"A21_elevi.php\" METHOD=\"POST\">";
			include 'A21_param1.php';
			
			echo "<TABLE class=\"style1\" cellSpacing=0 cellPadding=0 width=\"100%\" border=0>";				
			echo "<TR>";
			echo "<TD align=\"center\" class=\"td_print2\">";
			echo "<B>RECAPITULATIE</B>";
			echo "<BR>";
			echo "</TD>";
			echo "</TR>";
	
			echo "<TR>";
			echo "<TD align=\"center\" class=\"td_print2\">";
			echo "<B>LUNA:&nbsp<U>".$_POST["denluna_sel"]."</U>&nbsp &nbsp  &nbsp &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp ANUL:&nbsp<U>".$_POST["an"]."</U></B>";
			echo "<BR>";
			echo "</TD>";
			echo "</TR>";
			echo "</TABLE>";
			
			echo "<TABLE cellSpacing=0 cellPadding=0 width=\"100%;\" border=0 align=\"center\">";
			echo "<TR>";
			echo "<TD align=\"right\" height=\"35\">";
			echo "<input type=\"button\" class=\"noPrint\" onClick=\"window.print()\" value=\"PRINTARE\">";
			echo "<input type=\"submit\" class=\"noPrint\" name=\"actiune\" value=\"INAPOI\">";
			echo "</TD>";
			echo "</TR>";
			echo "</TABLE>";

			echo "<TABLE cellSpacing=0 cellPadding=0 width=\"100%\" border=0>";
			echo "<BR>";
			echo "<TR BGCOLOR=\"white\">";
			
			echo 	"<TH align=\"center\" width=\"2%\" class=\"td35\">Nr. crt.</TH>";					
			echo	"<TH align=\"center\" width=\"10%\" class=\"td35\">Grupa</TH>";	
			echo	"<TH align=\"center\" width=\"1%\" class=\"td35\">Tip Reg</TH>";		
			echo	"<TH align=\"center\" width=\"3%\" class=\"td35\">PREC</TH>";
			echo	"<TH align=\"center\" width=\"3%\" class=\"td35\">IAN</TH>";
			echo	"<TH align=\"center\" width=\"3%\" class=\"td35\">FEB</TH>";
			echo	"<TH align=\"center\" width=\"3%\" class=\"td35\">MAR</TH>";
			echo	"<TH align=\"center\" width=\"3%\" class=\"td35\">APR</TH>";
			echo	"<TH align=\"center\" width=\"3%\" class=\"td35\">MAI</TH>";
			echo	"<TH align=\"center\" width=\"3%\" class=\"td35\">IUN</TH>";
			echo	"<TH align=\"center\" width=\"3%\" class=\"td35\">IUL</TH>";
			echo	"<TH align=\"center\" width=\"3%\" class=\"td35\">AUG</TH>";
			echo	"<TH align=\"center\" width=\"3%\" class=\"td35\">SEP</TH>";
			echo	"<TH align=\"center\" width=\"3%\" class=\"td35\">OCT</TH>";
			echo	"<TH align=\"center\" width=\"3%\" class=\"td35\">NOI</TH>";
			echo	"<TH align=\"center\" width=\"3%\" class=\"td35\">DEC</TH>";
			echo	"<TH align=\"center\" width=\"3%\" class=\"td39\">TOTAL</TH>";
			
			echo "</TR>";
			
			$query="SELECT id,codgrp,codelev,nume,prenume,sum(d_val00) as d_val00, sum(d_val01) as d_val01, sum(d_val02) as d_val02, sum(d_val03) as d_val03, sum(d_val04) as d_val04, sum(d_val05) as d_val05, sum(d_val06) as d_val06, sum(d_val07) as d_val07, sum(d_val08) as d_val08, sum(d_val09) as d_val09, sum(d_val10) as d_val10, sum(d_val11) as d_val11, sum(d_val12) as d_val12, sum(p_val01) as p_val01, sum(p_val02) as p_val02, sum(p_val03) as p_val03, sum(p_val04) as p_val04, sum(p_val05) as p_val05, sum(p_val06) as p_val06, sum(p_val07) as p_val07, sum(p_val08) as p_val08, sum(p_val09) as p_val09, sum(p_val10) as p_val10, sum(p_val11) as p_val11, sum(p_val12) as p_val12, sum(r_val01) as r_val01, sum(r_val02) as r_val02, sum(r_val03) as r_val03, sum(r_val04) as r_val04, sum(r_val05) as r_val05, sum(r_val06) as r_val06, sum(r_val07) as r_val07, sum(r_val08) as r_val08, sum(r_val09) as r_val09, sum(r_val10) as r_val10, sum(r_val11) as r_val11, sum(r_val12) as r_val12 FROM elevi group by codgrp"	;	
			$result=mysql_query($query) or die("Interogare esuata: ".mysql_error());

		$i=0;
		$debit_tot=0;
		$wlu=substr($_POST["luna_sel"],0,2);
		
		$d_val00_tot=0;
		$d_val01_tot=0;
		$d_val02_tot=0;
		$d_val03_tot=0;
		$d_val04_tot=0;
		$d_val05_tot=0;
		$d_val06_tot=0;
		$d_val07_tot=0;
		$d_val08_tot=0;
		$d_val09_tot=0;
		$d_val10_tot=0;
		$d_val11_tot=0;
		$d_val12_tot=0;
		$d_val_tot=0;
		$p_val01_tot=0;
		$p_val02_tot=0;
		$p_val03_tot=0;
		$p_val04_tot=0;
		$p_val05_tot=0;
		$p_val06_tot=0;
		$p_val07_tot=0;
		$p_val08_tot=0;
		$p_val09_tot=0;
		$p_val10_tot=0;
		$p_val11_tot=0;
		$p_val12_tot=0;
		$p_val_tot=0;
		$r_val01_tot=0;
		$r_val02_tot=0;
		$r_val03_tot=0;
		$r_val04_tot=0;
		$r_val05_tot=0;
		$r_val06_tot=0;
		$r_val07_tot=0;
		$r_val08_tot=0;
		$r_val09_tot=0;
		$r_val10_tot=0;
		$r_val11_tot=0;
		$r_val12_tot=0;
		$r_val_tot=0;
		
		while($row = mysql_fetch_array( $result))		
		{ 	
			$debit_tot = $row["d_val00"] + $row["d_val01"] + $row["d_val02"] + $row["d_val03"] + $row["d_val04"] + $row["d_val05"] + $row["d_val06"] + $row["d_val07"] + $row["d_val08"] + $row["d_val09"] + $row["d_val10"] + $row["d_val11"] + $row["d_val12"];
			$platit_tot = $row["p_val01"] + $row["p_val02"] + $row["p_val03"] + $row["p_val04"] + $row["p_val05"] + $row["p_val06"] + $row["p_val07"] + $row["p_val08"] + $row["p_val09"] + $row["p_val10"] + $row["p_val11"] + $row["p_val12"];
			$rest_tot = $debit_tot - $platit_tot;
			
			$d_val00_tot += $row["d_val00"];
			$d_val01_tot += $row["d_val01"];
			$d_val02_tot += $row["d_val02"];
			$d_val03_tot += $row["d_val03"];
			$d_val04_tot += $row["d_val04"];
			$d_val05_tot += $row["d_val05"];
			$d_val06_tot += $row["d_val06"];
			$d_val07_tot += $row["d_val07"];
			$d_val08_tot += $row["d_val08"];
			$d_val09_tot += $row["d_val09"];
			$d_val10_tot += $row["d_val10"];
			$d_val11_tot += $row["d_val11"];
			$d_val12_tot += $row["d_val12"];
			$d_val_tot = $d_val00_tot + $d_val01_tot + $d_val02_tot + $d_val03_tot + $d_val04_tot + $d_val05_tot + $d_val06_tot + $d_val07_tot + $d_val08_tot + $d_val09_tot + $d_val10_tot + $d_val11_tot + $d_val12_tot;
			$d_val01_total = $d_val00_tot + $d_val01_tot;
			$d_val02_total = $d_val00_tot + $d_val01_tot + $d_val02_tot;
			$d_val03_total = $d_val00_tot + $d_val01_tot + $d_val02_tot + $d_val03_tot;
			$d_val04_total = $d_val00_tot + $d_val01_tot + $d_val02_tot + $d_val03_tot + $d_val04_tot;
			$d_val05_total = $d_val00_tot + $d_val01_tot + $d_val02_tot + $d_val03_tot + $d_val04_tot + $d_val05_tot;
			$d_val06_total = $d_val00_tot + $d_val01_tot + $d_val02_tot + $d_val03_tot + $d_val04_tot + $d_val05_tot + $d_val06_tot;
			$d_val07_total = $d_val00_tot + $d_val01_tot + $d_val02_tot + $d_val03_tot + $d_val04_tot + $d_val05_tot + $d_val06_tot + $d_val07_tot;
			$d_val08_total = $d_val00_tot + $d_val01_tot + $d_val02_tot + $d_val03_tot + $d_val04_tot + $d_val05_tot + $d_val06_tot + $d_val07_tot + $d_val08_tot;
			$d_val09_total = $d_val00_tot + $d_val01_tot + $d_val02_tot + $d_val03_tot + $d_val04_tot + $d_val05_tot + $d_val06_tot + $d_val07_tot + $d_val08_tot + $d_val09_tot;
			$d_val10_total = $d_val00_tot + $d_val01_tot + $d_val02_tot + $d_val03_tot + $d_val04_tot + $d_val05_tot + $d_val06_tot + $d_val07_tot + $d_val08_tot + $d_val09_tot + $d_val10_tot;
			$d_val11_total = $d_val00_tot + $d_val01_tot + $d_val02_tot + $d_val03_tot + $d_val04_tot + $d_val05_tot + $d_val06_tot + $d_val07_tot + $d_val08_tot + $d_val09_tot + $d_val10_tot + $d_val11_tot;
			$d_val12_total = $d_val00_tot + $d_val01_tot + $d_val02_tot + $d_val03_tot + $d_val04_tot + $d_val05_tot + $d_val06_tot + $d_val07_tot + $d_val08_tot + $d_val09_tot + $d_val10_tot + $d_val11_tot + $d_val12_tot;

			$p_val01_tot += $row["p_val01"];
			$p_val02_tot += $row["p_val02"];
			$p_val03_tot += $row["p_val03"];
			$p_val04_tot += $row["p_val04"];
			$p_val05_tot += $row["p_val05"];
			$p_val06_tot += $row["p_val06"];
			$p_val07_tot += $row["p_val07"];
			$p_val08_tot += $row["p_val08"];
			$p_val09_tot += $row["p_val09"];
			$p_val10_tot += $row["p_val10"];
			$p_val11_tot += $row["p_val11"];
			$p_val12_tot += $row["p_val12"];
			$p_val_tot = $p_val01_tot + $p_val02_tot + $p_val03_tot + $p_val04_tot + $p_val05_tot + $p_val06_tot + $p_val07_tot + $p_val08_tot + $p_val09_tot + $p_val10_tot + $p_val11_tot + $p_val12_tot;
			$p_val01_total = $p_val01_tot;
			$p_val02_total = $p_val01_tot + $p_val02_tot;
			$p_val03_total = $p_val01_tot + $p_val02_tot + $p_val03_tot;
			$p_val04_total = $p_val01_tot + $p_val02_tot + $p_val03_tot + $p_val04_tot;
			$p_val05_total = $p_val01_tot + $p_val02_tot + $p_val03_tot + $p_val04_tot + $p_val05_tot;
			$p_val06_total = $p_val01_tot + $p_val02_tot + $p_val03_tot + $p_val04_tot + $p_val05_tot + $p_val06_tot;
			$p_val07_total = $p_val01_tot + $p_val02_tot + $p_val03_tot + $p_val04_tot + $p_val05_tot + $p_val06_tot + $p_val07_tot;
			$p_val08_total = $p_val01_tot + $p_val02_tot + $p_val03_tot + $p_val04_tot + $p_val05_tot + $p_val06_tot + $p_val07_tot + $p_val08_tot;
			$p_val09_total = $p_val01_tot + $p_val02_tot + $p_val03_tot + $p_val04_tot + $p_val05_tot + $p_val06_tot + $p_val07_tot + $p_val08_tot + $p_val09_tot;
			$p_val10_total = $p_val01_tot + $p_val02_tot + $p_val03_tot + $p_val04_tot + $p_val05_tot + $p_val06_tot + $p_val07_tot + $p_val08_tot + $p_val09_tot + $p_val10_tot;
			$p_val11_total = $p_val01_tot + $p_val02_tot + $p_val03_tot + $p_val04_tot + $p_val05_tot + $p_val06_tot + $p_val07_tot + $p_val08_tot + $p_val09_tot + $p_val10_tot + $p_val11_tot;
			$p_val12_total = $p_val01_tot + $p_val02_tot + $p_val03_tot + $p_val04_tot + $p_val05_tot + $p_val06_tot + $p_val07_tot + $p_val08_tot + $p_val09_tot + $p_val10_tot + $p_val11_tot + $p_val12_tot;
			
			$r_val01_tot += $row["r_val01"];
			$r_val02_tot += $row["r_val02"];
			$r_val03_tot += $row["r_val03"];
			$r_val04_tot += $row["r_val04"];
			$r_val05_tot += $row["r_val05"];
			$r_val06_tot += $row["r_val06"];
			$r_val07_tot += $row["r_val07"];
			$r_val08_tot += $row["r_val08"];
			$r_val09_tot += $row["r_val09"];
			$r_val10_tot += $row["r_val10"];
			$r_val11_tot += $row["r_val11"];
			$r_val12_tot += $row["r_val12"];
			$r_val_tot = $d_val_tot - $p_val_tot;
						
			if ($i-floor($i/2)*2==0)
			{
				echo "<TR class=\"tr4\" BGCOLOR=\"#FFFFFF\">";
			}
			else
			{
				echo "<TR class=\"tr4\" BGCOLOR=\"#EAEBEB\">";
			}
		
				echo "<TD width=\"2%\" align=\"center\">",$i+1,"</TD>";
				
				$query2 = "SELECT * from grupe where codgrp=\"".$row["codgrp"]."\" order by codgrp";
				$result2=mysql_query($query2) or die("Interogare esuata: ".mysql_error());
				$row2 = mysql_fetch_array( $result2);
				
				echo"<TD width=\"10%\" align=\"left\">";
				echo "&nbsp".$row2["dengrp"]."&nbsp";
				echo "</TD>";
				echo"<TD width=\"1%\" align=\"center\">";
				echo "<B>DEBIT</B>";
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "&nbsp".$row["d_val00"]."&nbsp";
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "&nbsp".$row["d_val01"]."&nbsp";
				if($wlu=="01")
				{
					$debit_ln=$row["d_val00"]+$row["d_val01"];
					echo "(<B>".$debit_ln."</B>)&nbsp";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "&nbsp".$row["d_val02"]."&nbsp";
				if($wlu=="02")
				{
					$debit_ln=$row["d_val00"]+$row["d_val01"]+$row["d_val02"];
					echo "(<B>".$debit_ln."</B>)&nbsp";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "&nbsp".$row["d_val03"]."&nbsp";
				if($wlu=="03")
				{
					$debit_ln=$row["d_val00"]+$row["d_val01"]+$row["d_val02"]+$row["d_val03"];
					echo "(<B>".$debit_ln."</B>)&nbsp";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "&nbsp".$row["d_val04"]."&nbsp";
				if($wlu=="04")
				{
					$debit_ln=$row["d_val00"]+$row["d_val01"]+$row["d_val02"]+$row["d_val03"]+$row["d_val04"];
					echo "(<B>".$debit_ln."</B>)&nbsp";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "&nbsp".$row["d_val05"]."&nbsp";
				if($wlu=="05")
				{
					$debit_ln=$row["d_val00"]+$row["d_val01"]+$row["d_val02"]+$row["d_val03"]+$row["d_val04"]+$row["d_val05"];
					echo "(<B>".$debit_ln."</B>)&nbsp";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "&nbsp".$row["d_val06"]."&nbsp";
				if($wlu=="06")
				{
					$debit_ln=$row["d_val00"]+$row["d_val01"]+$row["d_val02"]+$row["d_val03"]+$row["d_val04"]+$row["d_val05"]+$row["d_val06"];
					echo "(<B>".$debit_ln."</B>)&nbsp";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "&nbsp".$row["d_val07"]."&nbsp";
				if($wlu=="07")
				{
					$debit_ln=$row["d_val00"]+$row["d_val01"]+$row["d_val02"]+$row["d_val03"]+$row["d_val04"]+$row["d_val05"]+$row["d_val06"]+$row["d_val07"];
					echo "(<B>".$debit_ln."</B>)&nbsp";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "&nbsp".$row["d_val08"]."&nbsp";
				if($wlu=="08")
				{
					$debit_ln=$row["d_val00"]+$row["d_val01"]+$row["d_val02"]+$row["d_val03"]+$row["d_val04"]+$row["d_val05"]+$row["d_val06"]+$row["d_val07"]+$row["d_val08"];
					echo "(<B>".$debit_ln."</B>)&nbsp";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "&nbsp".$row["d_val09"]."&nbsp";
				if($wlu=="09")
				{
					$debit_ln=$row["d_val00"]+$row["d_val01"]+$row["d_val02"]+$row["d_val03"]+$row["d_val04"]+$row["d_val05"]+$row["d_val06"]+$row["d_val07"]+$row["d_val08"]+$row["d_val09"];
					echo "(<B>".$debit_ln."</B>)&nbsp";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "&nbsp".$row["d_val10"]."&nbsp";
				if($wlu=="10")
				{
					$debit_ln=$row["d_val00"]+$row["d_val01"]+$row["d_val02"]+$row["d_val03"]+$row["d_val04"]+$row["d_val05"]+$row["d_val06"]+$row["d_val07"]+$row["d_val08"]+$row["d_val09"]+$row["d_val10"];
					echo "(<B>".$debit_ln."</B>)&nbsp";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "&nbsp".$row["d_val11"]."&nbsp";
				if($wlu=="11")
				{
					$debit_ln=$row["d_val00"]+$row["d_val01"]+$row["d_val02"]+$row["d_val03"]+$row["d_val04"]+$row["d_val05"]+$row["d_val06"]+$row["d_val07"]+$row["d_val08"]+$row["d_val09"]+$row["d_val10"]+$row["d_val11"];
					echo "(<B>".$debit_ln."</B>)&nbsp";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "&nbsp".$row["d_val12"]."&nbsp";
				if($wlu=="12")
				{
					$debit_ln=$row["d_val00"]+$row["d_val01"]+$row["d_val02"]+$row["d_val03"]+$row["d_val04"]+$row["d_val05"]+$row["d_val06"]+$row["d_val07"]+$row["d_val08"]+$row["d_val09"]+$row["d_val10"]+$row["d_val11"]+$row["d_val12"];
					echo "(<B>".$debit_ln."</B>)&nbsp";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "<B>&nbsp $debit_tot &nbsp</B>";
				echo "</TD>";
				echo "</TR>";
				$i++;
			if ($i-floor($i/2)*2==0)
			{
				echo "<TR class=\"tr4\" BGCOLOR=\"#FFFFFF\">";
			}
			else
			{
				echo "<TR class=\"tr4\" BGCOLOR=\"#EAEBEB\">";
			}
		
				echo "<TD width=\"2%\" align=\"center\">",$i+1,"</TD>";
				echo"<TD width=\"10%\" align=\"left\">";
				echo "</TD>";
				echo"<TD width=\"1%\" align=\"center\">";
				echo "<B>PLATI</B>";
				echo "</TD>";
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo " ";
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "&nbsp".$row["p_val01"]."&nbsp";
				if($wlu=="01")
				{
					$platit_ln=$row["p_val01"];
					echo "(<B>".$platit_ln."</B>)&nbsp";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "&nbsp".$row["p_val02"]."&nbsp";
				if($wlu=="02")
				{
					$platit_ln=$row["p_val01"]+$row["p_val02"];
					echo "(<B>".$platit_ln."</B>)&nbsp";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "&nbsp".$row["p_val03"]."&nbsp";
				if($wlu=="03")
				{
					$platit_ln=$row["p_val01"]+$row["p_val02"]+$row["p_val03"];
					echo "(<B>".$platit_ln."</B>)&nbsp";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "&nbsp".$row["p_val04"]."&nbsp";
				if($wlu=="04")
				{
					$platit_ln=$row["p_val01"]+$row["p_val02"]+$row["p_val03"]+$row["p_val04"];
					echo "(<B>".$platit_ln."</B>)&nbsp";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "&nbsp".$row["p_val05"]."&nbsp";
				if($wlu=="05")
				{
					$platit_ln=$row["p_val01"]+$row["p_val02"]+$row["p_val03"]+$row["p_val04"]+$row["p_val05"];
					echo "(<B>".$platit_ln."</B>)&nbsp";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "&nbsp".$row["p_val06"]."&nbsp";
				if($wlu=="06")
				{
					$platit_ln=$row["p_val01"]+$row["p_val02"]+$row["p_val03"]+$row["p_val04"]+$row["p_val05"]+$row["p_val06"];
					echo "(<B>".$platit_ln."</B>)&nbsp";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "&nbsp".$row["p_val07"]."&nbsp";
				if($wlu=="07")
				{
					$platit_ln=$row["p_val01"]+$row["p_val02"]+$row["p_val03"]+$row["p_val04"]+$row["p_val05"]+$row["p_val06"]+$row["p_val07"];
					echo "(<B>".$platit_ln."</B>)&nbsp";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "&nbsp".$row["p_val08"]."&nbsp";
				if($wlu=="08")
				{
					$platit_ln=$row["p_val01"]+$row["p_val02"]+$row["p_val03"]+$row["p_val04"]+$row["p_val05"]+$row["p_val06"]+$row["p_val07"]+$row["p_val08"];
					echo "(<B>".$platit_ln."</B>)&nbsp";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "&nbsp".$row["p_val09"]."&nbsp";
				if($wlu=="09")
				{
					$platit_ln=$row["p_val01"]+$row["p_val02"]+$row["p_val03"]+$row["p_val04"]+$row["p_val05"]+$row["p_val06"]+$row["p_val07"]+$row["p_val08"]+$row["p_val09"];
					echo "(<B>".$platit_ln."</B>)&nbsp";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "&nbsp".$row["p_val10"]."&nbsp";
				if($wlu=="10")
				{
					$platit_ln=$row["p_val01"]+$row["p_val02"]+$row["p_val03"]+$row["p_val04"]+$row["p_val05"]+$row["p_val06"]+$row["p_val07"]+$row["p_val08"]+$row["p_val09"]+$row["p_val10"];
					echo "(<B>".$platit_ln."</B>)&nbsp";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "&nbsp".$row["p_val11"]."&nbsp";
				if($wlu=="11")
				{
					$platit_ln=$row["p_val01"]+$row["p_val02"]+$row["p_val03"]+$row["p_val04"]+$row["p_val05"]+$row["p_val06"]+$row["p_val07"]+$row["p_val08"]+$row["p_val09"]+$row["p_val10"]+$row["p_val11"];
					echo "(<B>".$platit_ln."</B>)&nbsp";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "&nbsp".$row["p_val12"]."&nbsp";
				if($wlu=="12")
				{
					$platit_ln=$row["p_val01"]+$row["p_val02"]+$row["p_val03"]+$row["p_val04"]+$row["p_val05"]+$row["p_val06"]+$row["p_val07"]+$row["p_val08"]+$row["p_val09"]+$row["p_val10"]+$row["p_val11"]+$row["p_val12"];
					echo "(<B>".$platit_ln."</B>)&nbsp";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "<B>&nbsp $platit_tot &nbsp</B>";
				echo "</TD>";
				echo "</TR>";
				$i++;
			if ($i-floor($i/2)*2==0)
			{
				echo "<TR class=\"tr4\" BGCOLOR=\"#FFFFFF\">";
			}
			else
			{
				echo "<TR class=\"tr4\" BGCOLOR=\"#EAEBEB\">";
			}
		
				echo "<TD width=\"2%\" align=\"center\">",$i+1,"</TD>";
				echo"<TD width=\"10%\" align=\"left\">";
				echo "</TD>";
				echo"<TD width=\"1%\" align=\"center\">";
				echo "<B>REST_PL</B>";
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo " ";
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				if($wlu=="01")
				{
					echo "<B>";
				}
				echo "&nbsp".$row["r_val01"]."&nbsp";
				if($wlu=="01")
				{
					echo "</B>";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				if($wlu=="02")
				{
					echo "<B>";
				}
				echo "&nbsp".$row["r_val02"]."&nbsp";
				if($wlu=="02")
				{
					echo "</B>";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				if($wlu=="03")
				{
					echo "<B>";
				}
				echo "&nbsp".$row["r_val03"]."&nbsp";
				if($wlu=="03")
				{
					echo "</B>";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				if($wlu=="04")
				{
					echo "<B>";
				}
				echo "&nbsp".$row["r_val04"]."&nbsp";
				if($wlu=="04")
				{
					echo "</B>";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				if($wlu=="05")
				{
					echo "<B>";
				}
				echo "&nbsp".$row["r_val05"]."&nbsp";
				if($wlu=="05")
				{
					echo "</B>";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				if($wlu=="06")
				{
					echo "<B>";
				}
				echo "&nbsp".$row["r_val06"]."&nbsp";
				if($wlu=="06")
				{
					echo "</B>";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				if($wlu=="07")
				{
					echo "<B>";
				}
				echo "&nbsp".$row["r_val07"]."&nbsp";
				if($wlu=="07")
				{
					echo "</B>";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				if($wlu=="08")
				{
					echo "<B>";
				}
				echo "&nbsp".$row["r_val08"]."&nbsp";
				if($wlu=="08")
				{
					echo "</B>";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				if($wlu=="09")
				{
					echo "<B>";
				}
				echo "&nbsp".$row["r_val09"]."&nbsp";
				if($wlu=="09")
				{
					echo "</B>";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				if($wlu=="10")
				{
					echo "<B>";
				}
				echo "&nbsp".$row["r_val10"]."&nbsp";
				if($wlu=="10")
				{
					echo "</B>";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				if($wlu=="11")
				{
					echo "<B>";
				}
				echo "&nbsp".$row["r_val11"]."&nbsp";
				if($wlu=="11")
				{
					echo "</B>";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				if($wlu=="12")
				{
					echo "<B>";
				}
				echo "&nbsp".$row["r_val12"]."&nbsp";
				if($wlu=="12")
				{
					echo "</B>";
				}
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "<B>&nbsp $rest_tot &nbsp</B>";
				echo "</TD>";
				echo "</TR>";
				
				echo "<TR>";
				echo "<TD>";
				echo "<BR>";
				echo "</TD>";
				echo "</TR>";
				$i++;
		}
					
				echo "<TR>";
				echo "<TD colspan=\"17\">&nbsp</TD>";
				echo "</TR>";
				echo "<TR>";
				echo "<TD colspan=\"17\"><HR></HR>&nbsp</TD>";
				echo "</TR>";	
				echo "<TR class=\"tr4\">";
				echo "<TD width=\"2%\" align=\"center\">&nbsp</TD>";
				echo"<TD width=\"10%\" align=\"right\"><B>TOTAL:</B></TD>";
				echo"<TD width=\"1%\" align=\"center\">";
				echo "<B>DEBIT</B>";
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\"><B>$d_val00_tot</B></TD>";
				echo"<TD width=\"3%\" align=\"right\">&nbsp";
				if($wlu=="01")
				{
				echo	"<B>$d_val01_tot ($d_val01_total)</B>";				
				}
				else
				{
				echo	"<B>$d_val01_tot</B>";
				}	
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">&nbsp";
				if($wlu=="02")
				{
				echo	"<B>$d_val02_tot ($d_val02_total)</B>";				
				}
				else
				{
				echo	"<B>$d_val02_tot</B>";
				}	
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">&nbsp";
				if($wlu=="03")
				{
				echo	"<B>$d_val03_tot ($d_val03_total)</B>";				
				}
				else
				{
				echo	"<B>$d_val03_tot</B>";
				}	
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">&nbsp";
				if($wlu=="04")
				{
				echo	"<B>$d_val04_tot ($d_val04_total)</B>";				
				}
				else
				{
				echo	"<B>$d_val01_tot</B>";
				}	
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">&nbsp";
				if($wlu=="05")
				{
				echo	"<B>$d_val05_tot ($d_val05_total)</B>";				
				}
				else
				{
				echo	"<B>$d_val05_tot</B>";
				}	
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">&nbsp";
				if($wlu=="06")
				{
				echo	"<B>$d_val06_tot ($d_val06_total)</B>";				
				}
				else
				{
				echo	"<B>$d_val06_tot</B>";
				}	
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">&nbsp";
				if($wlu=="07")
				{
				echo	"<B>$d_val07_tot ($d_val07_total)</B>";				
				}
				else
				{
				echo	"<B>$d_val07_tot</B>";
				}	
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">&nbsp";
				if($wlu=="08")
				{
				echo	"<B>$d_val08_tot ($d_val08_total)</B>";				
				}
				else
				{
				echo	"<B>$d_val08_tot</B>";
				}	
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">&nbsp";
				if($wlu=="09")
				{
				echo	"<B>$d_val09_tot ($d_val09_total)</B>";				
				}
				else
				{
				echo	"<B>$d_val09_tot</B>";
				}	
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">&nbsp";
				if($wlu=="10")
				{
				echo	"<B>$d_val10_tot ($d_val10_total)</B>";				
				}
				else
				{
				echo	"<B>$d_val10_tot</B>";
				}	
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">&nbsp";
				if($wlu=="11")
				{
				echo	"<B>$d_val11_tot ($d_val11_total)</B>";				
				}
				else
				{
				echo	"<B>$d_val11_tot</B>";
				}	
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">&nbsp";
				if($wlu=="12")
				{
				echo	"<B>$d_val12_tot ($d_val12_total)</B>";				
				}
				else
				{
				echo	"<B>$d_val12_tot</B>";
				}	
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "<B>&nbsp $d_val_tot &nbsp</B>";
				echo "</TD>";
				echo "</TR>";	
				echo "<TR class=\"tr4\">";
				echo "<TD width=\"2%\" align=\"center\">&nbsp</TD>";
				echo"<TD width=\"10%\" align=\"left\">&nbsp</TD>";
				echo"<TD width=\"1%\" align=\"center\">";
				echo "<B>PLATI</B>";
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">&nbsp</TD>";
				echo"<TD width=\"3%\" align=\"right\">&nbsp";
				if($wlu=="01")
				{
				echo	"<B>$p_val01_tot ($p_val01_total)</B>";				
				}
				else
				{
				echo	"<B>$p_val01_tot</B>";
				}	
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">&nbsp";
				if($wlu=="02")
				{
				echo	"<B>$p_val02_tot ($p_val02_total)</B>";				
				}
				else
				{
				echo	"<B>$p_val02_tot</B>";
				}	
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">&nbsp";
				if($wlu=="03")
				{
				echo	"<B>$p_val03_tot ($p_val03_total)</B>";				
				}
				else
				{
				echo	"<B>$p_val03_tot</B>";
				}	
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">&nbsp";
				if($wlu=="04")
				{
				echo	"<B>$p_val04_tot ($p_val04_total)</B>";				
				}
				else
				{
				echo	"<B>$p_val01_tot</B>";
				}	
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">&nbsp";
				if($wlu=="05")
				{
				echo	"<B>$p_val05_tot ($p_val05_total)</B>";				
				}
				else
				{
				echo	"<B>$p_val05_tot</B>";
				}	
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">&nbsp";
				if($wlu=="06")
				{
				echo	"<B>$p_val06_tot ($p_val06_total)</B>";				
				}
				else
				{
				echo	"<B>$p_val06_tot</B>";
				}	
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">&nbsp";
				if($wlu=="07")
				{
				echo	"<B>$p_val07_tot ($p_val07_total)</B>";				
				}
				else
				{
				echo	"<B>$p_val07_tot</B>";
				}	
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">&nbsp";
				if($wlu=="08")
				{
				echo	"<B>$p_val08_tot ($p_val08_total)</B>";				
				}
				else
				{
				echo	"<B>$p_val08_tot</B>";
				}	
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">&nbsp";
				if($wlu=="09")
				{
				echo	"<B>$p_val09_tot ($p_val09_total)</B>";				
				}
				else
				{
				echo	"<B>$p_val09_tot</B>";
				}	
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">&nbsp";
				if($wlu=="10")
				{
				echo	"<B>$p_val10_tot ($p_val10_total)</B>";				
				}
				else
				{
				echo	"<B>$p_val10_tot</B>";
				}	
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">&nbsp";
				if($wlu=="11")
				{
				echo	"<B>$p_val11_tot ($p_val11_total)</B>";				
				}
				else
				{
				echo	"<B>$p_val11_tot</B>";
				}	
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">&nbsp";
				if($wlu=="12")
				{
				echo	"<B>$p_val12_tot ($p_val12_total)</B>";				
				}
				else
				{
				echo	"<B>$p_val12_tot</B>";
				}	
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "<B>&nbsp $p_val_tot &nbsp</B>";
				echo "</TD>";
				echo "</TR>";
				echo "<TR class=\"tr4\">";
				echo "<TD width=\"2%\" align=\"center\">&nbsp</TD>";
				echo"<TD width=\"10%\" align=\"left\">&nbsp</TD>";
				echo"<TD width=\"1%\" align=\"center\">";
				echo "<B>REST_PL</B>";
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">&nbsp</TD>";
				echo"<TD width=\"3%\" align=\"right\">&nbsp";
				echo	"<B>$r_val01_tot</B>";
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">&nbsp";				
				echo	"<B>$r_val02_tot</B>";
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">&nbsp";
				echo	"<B>$r_val03_tot</B>";
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">&nbsp";
				echo	"<B>$r_val01_tot</B>";
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">&nbsp";
				echo	"<B>$r_val05_tot</B>";
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">&nbsp";
				echo	"<B>$r_val06_tot</B>";
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">&nbsp";
				echo	"<B>$r_val07_tot</B>";
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">&nbsp";
				echo	"<B>$r_val08_tot</B>";
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">&nbsp";
				echo	"<B>$r_val09_tot</B>";
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">&nbsp";
				echo	"<B>$r_val10_tot</B>";
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">&nbsp";
				echo	"<B>$r_val11_tot</B>";
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">&nbsp";
				echo	"<B>$r_val12_tot</B>";
				echo "</TD>";
				echo"<TD width=\"3%\" align=\"right\">";
				echo "<B>&nbsp $r_val_tot &nbsp</B>";
				echo "</TD>";
				echo "</TR>";	
/*				
			echo "<TABLE cellSpacing=0 cellPadding=0 width=\"100%\" border=0>";
			echo "<tr>";
			echo "<hr width=\"100%\" align=\"center\">";			
			echo "</tr>";
			echo "<TR>";			
	//		echo 	"<TD align=\"right\" width=\"1%\"></TD>";					
			echo	"<TD align=\"right\" width=\"12%\" class=\"td_recap\"><B>TOTAL:</B></TD>";	
			echo	"<TD align=\"center\" width=\"1%\"><B>DEBIT</B></TD>";		
			echo	"<TD align=\"right\" width=\"1%\"><B>$d_val00_tot</B></TD>";
			if($wlu=="01")
			{
			 echo	"<TD align=\"right\" width=\"4%\"><B>$d_val01_tot ($d_val01_total)</B></TD>";				
			}
			else
			{
			echo	"<TD align=\"right\" width=\"3%\"><B>$d_val01_tot</B></TD>";
			}	
			if($wlu=="02")
			{
			 echo	"<TD align=\"right\" width=\"4%\"><B>$d_val02_tot ($d_val02_total)</B></TD>";				
			}
			else
			{
			echo	"<TD align=\"right\" width=\"3%\"><B>$d_val02_tot</B></TD>";
			}
			if($wlu=="03")
			{
			 echo	"<TD align=\"right\" width=\"4%\"><B>$d_val03_tot ($d_val03_total)</B></TD>";				
			}
			else
			{
			echo	"<TD align=\"right\" width=\"3%\"><B>$d_val03_tot</B></TD>";
			}
			if($wlu=="04")
			{
			 echo	"<TD align=\"right\" width=\"4%\"><B>$d_val04_tot ($d_val04_total)</B></TD>";				
			}
			else
			{
			echo	"<TD align=\"right\" width=\"3%\"><B>$d_val04_tot</B></TD>";
			}
			if($wlu=="05")
			{
			 echo	"<TD align=\"right\" width=\"4%\"><B>$d_val05_tot ($d_val05_total)</B></TD>";				
			}
			else
			{
			echo	"<TD align=\"right\" width=\"3%\"><B>$d_val05_tot</B></TD>";
			}
			if($wlu=="06")
			{
			 echo	"<TD align=\"right\" width=\"4%\"><B>$d_val06_tot ($d_val06_total)</B></TD>";				
			}
			else
			{
			echo	"<TD align=\"right\" width=\"3%\"><B>$d_val06_tot</B></TD>";
			}
			if($wlu=="07")
			{
			 echo	"<TD align=\"right\" width=\"4%\"><B>$d_val07_tot ($d_val07_total)</B></TD>";				
			}
			else
			{
			echo	"<TD align=\"right\" width=\"3%\"><B>$d_val07_tot</B></TD>";
			}
			if($wlu=="08")
			{
			 echo	"<TD align=\"right\" width=\"4%\"><B>$d_val08_tot ($d_val08_total)</B></TD>";				
			}
			else
			{
			echo	"<TD align=\"right\" width=\"3%\"><B>$d_val08_tot</B></TD>";
			}
			if($wlu=="09")
			{
			 echo	"<TD align=\"right\" width=\"4%\"><B>$d_val09_tot ($d_val09_total)</B></TD>";				
			}
			else
			{
			echo	"<TD align=\"right\" width=\"3%\"><B>$d_val09_tot</B></TD>";
			}
			if($wlu=="10")
			{
			 echo	"<TD align=\"right\" width=\"4%\"><B>$d_val10_tot ($d_val10_total)</B></TD>";				
			}
			else
			{
			echo	"<TD align=\"right\" width=\"3%\"><B>$d_val10_tot</B></TD>";
			}
			if($wlu=="11")
			{
			 echo	"<TD align=\"right\" width=\"4%\"><B>$d_val11_tot ($d_val11_total)</B></TD>";				
			}
			else
			{
			echo	"<TD align=\"right\" width=\"3%\"><B>$d_val11_tot</B></TD>";
			}
			if($wlu=="12")
			{
			 echo	"<TD align=\"right\" width=\"4%\"><B>$d_val12_tot ($d_val12_total)</B></TD>";				
			}
			else
			{
			echo	"<TD align=\"right\" width=\"3%\"><B>$d_val12_tot</B></TD>";
			}
			echo	"<TD align=\"right\" width=\"3%\"><B>$d_val_tot</B></TD>";
			echo "</TR>";
			echo "<TR>";			
//			echo 	"<TD align=\"right\" width=\"2%\"></TD>";					
			echo	"<TD align=\"right\" width=\"12%\" class=\"td_recap\"></TD>";	
			echo	"<TD align=\"center\" width=\"1%\"><B>PLATI</B></TD>";		
			echo	"<TD align=\"right\" width=\"2%\"></TD>";
			if($wlu=="01")
			{
			 echo	"<TD align=\"right\" width=\"4%\"><B>$p_val01_tot ($p_val01_total)</B></TD>";				
			}
			else
			{
			echo	"<TD align=\"right\" width=\"3%\"><B>$p_val01_tot</B></TD>";
			}
			if($wlu=="02")
			{
			 echo	"<TD align=\"right\" width=\"4%\"><B>$p_val02_tot ($p_val02_total)</B></TD>";				
			}
			else
			{
			echo	"<TD align=\"right\" width=\"3%\"><B>$p_val02_tot</B></TD>";
			}
			if($wlu=="03")
			{
			 echo	"<TD align=\"right\" width=\"4%\"><B>$p_val03_tot ($p_val03_total)</B></TD>";				
			}
			else
			{
			echo	"<TD align=\"right\" width=\"3%\"><B>$p_val03_tot</B></TD>";
			}
			if($wlu=="04")
			{
			 echo	"<TD align=\"right\" width=\"4%\"><B>$p_val04_tot ($p_val04_total)</B></TD>";				
			}
			else
			{
			echo	"<TD align=\"right\" width=\"3%\"><B>$p_val04_tot</B></TD>";
			}
			if($wlu=="05")
			{
			 echo	"<TD align=\"right\" width=\"4%\"><B>$p_val05_tot ($p_val05_total)</B></TD>";				
			}
			else
			{
			echo	"<TD align=\"right\" width=\"3%\"><B>$p_val05_tot</B></TD>";
			}
			if($wlu=="06")
			{
			 echo	"<TD align=\"right\" width=\"4%\"><B>$p_val06_tot ($p_val06_total)</B></TD>";				
			}
			else
			{
			echo	"<TD align=\"right\" width=\"3%\"><B>$p_val06_tot</B></TD>";
			}
			if($wlu=="07")
			{
			 echo	"<TD align=\"right\" width=\"4%\"><B>$p_val07_tot ($p_val07_total)</B></TD>";				
			}
			else
			{
			echo	"<TD align=\"right\" width=\"3%\"><B>$p_val07_tot</B></TD>";
			}
			if($wlu=="08")
			{
			 echo	"<TD align=\"right\" width=\"4%\"><B>$p_val08_tot ($p_val08_total)</B></TD>";				
			}
			else
			{
			echo	"<TD align=\"right\" width=\"3%\"><B>$p_val08_tot</B></TD>";
			}
			if($wlu=="09")
			{
			 echo	"<TD align=\"right\" width=\"4%\"><B>$p_val09_tot ($p_val09_total)</B></TD>";				
			}
			else
			{
			echo	"<TD align=\"right\" width=\"3%\"><B>$p_val09_tot</B></TD>";
			}
			if($wlu=="10")
			{
			 echo	"<TD align=\"right\" width=\"4%\"><B>$p_val10_tot ($p_val10_total)</B></TD>";				
			}
			else
			{
			echo	"<TD align=\"right\" width=\"3%\"><B>$p_val10_tot</B></TD>";
			}
			if($wlu=="11")
			{
			 echo	"<TD align=\"right\" width=\"4%\"><B>$p_val11_tot ($p_val11_total)</B></TD>";				
			}
			else
			{
			echo	"<TD align=\"right\" width=\"3%\"><B>$p_val11_tot</B></TD>";
			}
			if($wlu=="12")
			{
			 echo	"<TD align=\"right\" width=\"4%\"><B>$p_val12_tot ($p_val12_total)</B></TD>";				
			}
			else
			{
			echo	"<TD align=\"right\" width=\"3%\"><B>$p_val12_tot</B></TD>";
			}
			echo	"<TD align=\"right\" width=\"3%\"><B>$p_val_tot</B></TD>";
			echo "</TR>";	
			echo "<TR>";			
	//		echo 	"<TD align=\"right\" width=\"2%\"></TD>";					
			echo	"<TD align=\"right\" width=\"12%\" class=\"td_recap\"></TD>";	
			echo	"<TD align=\"center\" width=\"1%\"><B>REST_PL</B></TD>";		
			echo	"<TD align=\"right\" width=\"3%\"></TD>";				
			echo	"<TD align=\"right\" width=\"3%\"><B>$r_val01_tot</B></TD>";
			echo	"<TD align=\"right\" width=\"3%\"><B>$r_val02_tot</B></TD>";
			echo	"<TD align=\"right\" width=\"3%\"><B>$r_val03_tot</B></TD>";
			echo	"<TD align=\"right\" width=\"3%\"><B>$r_val04_tot</B></TD>";
			echo	"<TD align=\"right\" width=\"3%\"><B>$r_val05_tot</B></TD>";
			echo	"<TD align=\"right\" width=\"3%\"><B>$r_val06_tot</B></TD>";
			echo	"<TD align=\"right\" width=\"3%\"><B>$r_val07_tot</B></TD>";
			echo	"<TD align=\"right\" width=\"3%\"><B>$r_val08_tot</B></TD>";
			echo	"<TD align=\"right\" width=\"3%\"><B>$r_val09_tot</B></TD>";
			echo	"<TD align=\"right\" width=\"3%\"><B>$r_val10_tot</B></TD>";
			echo	"<TD align=\"right\" width=\"3%\"><B>$r_val11_tot</B></TD>";
			echo	"<TD align=\"right\" width=\"3%\"><B>$r_val12_tot</B></TD>";			
			echo	"<TD align=\"right\" width=\"3.5%\"><B>$r_val_tot</B></TD>";
			echo "</TR>";	
			echo "</TABLE>";
	*/		
		include 'A03_denfunctii.php';

		echo "</form>";
		echo "</table>";	
 
		mysql_close($connection);
		echo "</center>";
}	


?>

</body>
</html>		
					