<?php session_start(); ?>
<?php session_cache_limiter('private-no-expire'); ?>

<?php
/*
if (!empty($_POST["luna_sel"]) AND !empty($_POST["grp_sel"]))
{
	$_SESSION["luna_sel"]=substr($_POST["luna_sel"],0,2);
	$_SESSION["grp_sel"]=substr($_POST["grp_sel"],0,2);
}
*/
if (isset($_POST["aplic"]) and isset($_POST["unit"]))
{
	$_SESSION["aplic"]=$_POST["aplic"];
	$_SESSION["unit"]=$_POST["unit"];
}

//$luna_sel = $_SESSION["luna_sel"];
//$grp_sel = $_SESSION["grp_sel"];

include 'conectare.php';

/*
	$connection=mysql_connect("$host","$username","$password") or die("Nu aveti acces la server");
	$baza="apponlin_".$_SESSION["aplic"]."_".$_SESSION["unit"];
	$db=mysql_select_db($baza,$connection) or die("Nu puteti selecta Baza de date ".$baza);	

mysql_query("SET NAMES 'utf8'");
	
// include and create object
	include("inc/jqgrid_dist.php");

	$col = array();
	$col["title"] = "ID"; // caption of column
	$col["name"] = "id";
	$col["width"] = "1";
	$col["editable"] = false;  // this column is not editable
	$col["align"] = "center";
	$col["search"] = false; // this column is not searchable
	$col["hidden"] = true; // hide column by default
	$cols[] = $col;
		
	$col = array();
	$col["title"] = "Descriere";
	$col["name"] = "detalii";
	$col["width"] = "10";
	$col["editable"] = true; // this column is editable
	$col["align"] = "left";
	$col["search"] = true; // this column is searchable
//	$col["editrules"] = array("required"=>true, "readonly"=>true, "readonly-when"=>array("==","A"));	
	$cols[] = $col;

	$col = array();
	$col["title"] = "Data 1";
	$col["name"] = "data1";
	$col["width"] = "3";
	$col["editable"] = true; // this column is editable
	$col["align"] = "center";
	$col["search"] = true; // this column is searchable
	$col["hidden"] = false; // hide column by default
	$col["formatter"] = "date";
	$col["formatoptions"] = array("srcformat"=>'Y-m-d',"newformat"=>'d-m-Y');	
	$col["searchoptions"]["sopt"] = array("cn"); // cn = contains	
	$cols[] = $col;	
	
	$col = array();
	$col["title"] = "Data 2";
	$col["name"] = "data2";
	$col["width"] = "3";
	$col["editable"] = true; // this column is editable
	$col["align"] = "center";
	$col["search"] = true; // this column is searchable
	$col["hidden"] = false; // hide column by default
	//$col["editrules"] = array("required"=>true, "edithidden"=>true); // and is required	
//	$col["editrules"] = array("required"=>true, "readonly"=>true, "readonly-when"=>array("==","23-11-2017"));
//	$col["editrules"] = array("readonly"=>true);
	$col["formatter"] = "date";
	$col["formatoptions"] = array("srcformat"=>'Y-m-d',"newformat"=>'d-m-Y');	
	$col["searchoptions"]["sopt"] = array("cn"); // cn = contains	
	$cols[] = $col;		
	
	$col = array();
	$col["title"] = "Actiuni";
	$col["name"] = "act";
	$col["width"] = "1";
	$col["hidden"] = true;
	$col["align"] = "left"; // this column is not editable
	$cols[] = $col;	
	
	$g = new jqgrid();

// set few params
// $grid["url"] = ""; // your paramterized URL -- defaults to REQUEST_URI
	$grid["rowNum"] = 30;
	$grid["sortname"] = 'data1'; // by default sort grid by this field
	$grid["sortorder"] = "asc"; // ASC or DESC
	$grid["caption"] = "Zile libere"; // caption of grid
	$grid["autowidth"] = true; // expand grid to screen width
	$grid["height"] = "70%";
	$grid["multiselect"] = false; // allow you to multi-select through checkboxes	
//	$grid["altRows"] = true; // Set a zebra-striped grid, boolean
//	$grid["altclass"] = "myAltRowClass";

	$grid["add_options"] = array('width'=>'300',    
                            "closeAfterEdit"=>true, // close dialog after add/edit
                            "top"=>"100", // absolute top position of dialog
                            "left"=>"200" // absolute left position of dialog
                            );

	$grid["edit_options"] = array('width'=>'300',    
                            "closeAfterEdit"=>true, // close dialog after add/edit
                            "top"=>"100", // absolute top position of dialog
                            "left"=>"200" // absolute left position of dialog
                            );
	$grid["delete_options"] = array('width'=>'300',    
                            "closeAfterEdit"=>true, // close dialog after add/edit
                            "top"=>"100", // absolute top position of dialog
                            "left"=>"200" // absolute left position of dialog
                            );
						
//	$grid["export"] = array("format"=>"xlsx", "filename"=>"my-file", "sheetname"=>"test"); // only in Premium Version

	$g->set_options($grid);

	$g->set_actions(array(	
						"add"=>true, // allow/disallow add
						"edit"=>true, // allow/disallow edit
						"delete"=>true, // allow/disallow delete
						"rowactions"=>true, // show/hide row wise edit/del/save option
						"export"=>true, // show/hide export to excel option
						"autofilter" => true, // show/hide autofilter for search
						"search" => "advance" // show single/multi field search condition (e.g. simple or advance)
					) 
				);
				

// you can provide custom SQL query to display data

	$g->select_command = "select * from zile_libere";
					
// set database table for CRUD operations
	$g->table = "zile_libere";
	
	$g->set_columns($cols);	

/*
$f = array();
$f["column"] = "detalii";
$f["css"] = "'background-color':'#FBEC88', 'color':'green', 'font-weight':'bold'"; // must use (single quote ') with css attr and value
$f_conditions[] = $f;

$g->set_conditional_css($f_conditions);	// NU STIE DE FUNCTIE
*/		
	
// render grid
/*
	$out = $g->render("list1");

	$themes = array("redmond","smoothness","start","dot-luv","excite-bike","flick","ui-darkness","cupertino","dark-hive","ui-lightness");
	$i = rand(0,8);
*/

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
		<link rel="stylesheet" type="text/css" media="screen" href="js/themes/start/jquery-ui.custom.css"></link>		
		<link rel="stylesheet" type="text/css" media="screen" href="js/jqgrid/css/ui.jqgrid.css"></link>	
		<link rel="stylesheet" type="text/css" href="A21_stiluri2.css"> 
	
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	
	<script src="js/jquery.min.js" type="text/javascript"></script>
	<script src="js/jqgrid/js/i18n/grid.locale-ro.js" type="text/javascript"></script>
	<script src="js/jqgrid/js/jquery.jqGrid.min.js" type="text/javascript"></script>	
	<script src="js/themes/jquery-ui.custom.min.js" type="text/javascript"></script>
	
</HEAD>
<script language="javascript" type="text/javascript">

function load()
{
alert("Datele au fost salvate cu succes!");
window.close();
}

function prel()
{
alert("Preluarea s-a efectuat cu succes!");
window.close();
}

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=1200,height=190,top=300,left=30,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=800,height=170,top=300,left=250,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=350,top=200,left=400,resizeable,scrollbars');
		form.target = 'win10';
}


if (!document.all) 
{
	document.captureEvents (Event.CLICK);
}
document.onclick = function() 
{
	if (w3 != null && !w3.closed) 
	{
		w3.focus();
	}
	
	if (w4 != null && !w4.closed) 
	{
		w4.focus();
	}
	
	if (w5 != null && !w5.closed) 
	{
		w5.focus();
	}
	
	if (w10 != null && !w10.closed) 
	{
		w10.focus();
	}
}

function check1() {
	
	var t = document.getElementById("grp_sel");
	document.getElementById("dengrupa_sel1").value = t.options[t.selectedIndex].text;
	
	var v = document.getElementById("grp_sel");
	document.getElementById("grupa_sel1").value = v.options[v.selectedIndex].value;

}

function confirm_stergere_p() {

//    if(document.getElementById("marca").value == "")
//     {
//        alert("ATENTIE! NU ATI SELECTAT MARCA");
//        return false;
//    }

    var msg = confirm('Sigur doriti stergerea?');
    if(msg == false) {
        return false;
    }
	else
	{
	setTimeout('self.close()',500)	
	}
}

function confirm_stergere_g() {

    var msg = confirm('Sigur doriti stergerea? ATENTIE!!! \n Se vor sterge si toti prescolarii din grupa respectiva si chitantele aferente lor.');
    if(msg == false) {
        return false;
    }
	else
	{
	setTimeout('self.close()',500)	
	}
}

function prel()
{
alert("Preluarea s-a efectuat cu succes!");
window.close();
}
	
function confirm_preluare() {

var msg = confirm('Sigur doriti preluarea soldurilor initiale? \n ATENTIE! Soldurile precedente deja existente vor fi inlocuite!');
	if(msg == false) {
    return false;
    }
	else
	{
	//setTimeout('self.close()',500)	
	}
}
</script>

</head>
<body>
<style>
    .myAltRowClass { background-color: aqua; background-image: none; }
	</style>
<CENTER>
<?php
ob_start();
include 'javascripts.php';
include 'conectare.php';

if ($_POST["actiune"]=="DEFINIRE DATE UNITATE")
{	
			echo "<TR>";
			echo "<TD colspan=\"35\" align=\"center\">";
			echo "<B>DEFINIRE DATE UNITATE</B>";
			echo "</TD>";
			echo "</TR>";
			echo "<FORM NAME=\"form1\" ACTION=\"A21_utilitare.php\" METHOD=\"POST\">";
			include 'A21_param1.php';
			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);

			$query="SELECT * FROM unitate where unit=\"".$_POST["unit"]."\"";
			$result=mysql_query($query) or die("Interogare esuata: ".mysql_error());

	$i=0;
	while($row=mysql_fetch_array($result))
	{
		echo "<TABLE class=\"table2\" id=\"navigate\" cellSpacing=0 cellPadding=0 width=\"100%\" border=0>";
		if ($i-floor($i/2)*2==0)
		{
			echo "<TR BGCOLOR=\"#FFFFFF\">";
		}
		else
		{
			echo "<TR BGCOLOR=\"#EAEBEB\">";
		}
			  	
		echo "<tr><td><BR></td></tr>";
/*		
		echo "<tr>";
		echo "<td colspan=\"2\">Cod unitate:</td>";
		echo "<td colspan=\"2\">";
		echo "".$row["unit"]."";
		echo "</td>";
		echo "</tr>";
*/		
		echo "<tr>";
		echo "<td colspan=\"2\">Denumire unitate:</td>";
		echo "<td colspan=\"2\">";
		echo "<input name=\"denunit\" type=\"text\" onkeydown=\"ModifyEnterKeyPressAsTab(event)\" onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\" id=\"denunit\" size=\"70\" VALUE=\"".$row["denunit"]."\">";
		echo "</td>";
		echo "</tr>";
		echo "<tr>";
		echo "<td colspan=\"2\">Cod fiscal:</td>";
		echo "<td colspan=\"2\">";
		echo "<INPUT TYPE=\"TEXT\"  onkeydown=\"ModifyEnterKeyPressAsTab(event)\" onfocus=\"onfocus_camp(this)\" onblur=\"onblur_numar(this)\" onkeypress=\"return isNumberKey(event)\" size=\"12\"  NAME=\"cf\" VALUE=\"".$row["cf"]."\">";
		echo "</td>";
		echo "</tr>";
		echo "<tr>";
		echo "<td colspan=\"2\">Denumire functie 1:</td>";
		echo "<td colspan=\"2\">";
		echo "<INPUT TYPE=\"TEXT\" onkeydown=\"ModifyEnterKeyPressAsTab(event)\" onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\"  NAME=\"func1\" size=\"40\" VALUE=\"".$row["func1"]."\">";		
		echo "</td>";
		echo "</tr>";
		echo "<tr>";
		echo "<td colspan=\"2\">Nume si prenume 1:</td>";
		echo "<td colspan=\"2\">";
		echo "<INPUT TYPE=\"TEXT\"  onkeydown=\"ModifyEnterKeyPressAsTab(event)\" onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\"  NAME=\"nume_p1\" size=\"40\" VALUE=\"".$row["nume1"]."\">";		
		echo "</td>";
		echo "</tr>";
		echo "<tr>";
		echo "<td colspan=\"2\">Denumire functie 2:</td>";
		echo "<td colspan=\"2\">";
		echo "<INPUT TYPE=\"TEXT\" onkeydown=\"ModifyEnterKeyPressAsTab(event)\" onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\"  NAME=\"func2\" size=\"40\" VALUE=\"".$row["func2"]."\">";				
		echo "</td>";
		echo "</tr>";
		echo "<tr>";
		echo "<td colspan=\"2\">Nume si prenume 2:</td>";
		echo "<td colspan=\"2\">";
		echo "<INPUT TYPE=\"TEXT\" onkeydown=\"ModifyEnterKeyPressAsTab(event)\" onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\"  NAME=\"nume_p2\" size=\"40\" VALUE=\"".$row["nume2"]."\">";		
		echo "</td>";
		echo "</tr>";
		echo "<tr>";
		echo "<td colspan=\"2\">Adresa:</td>";
		echo "<td colspan=\"2\">";
		echo "<INPUT TYPE=\"TEXT\" onkeydown=\"ModifyEnterKeyPressAsTab(event)\" onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\"  NAME=\"adresa_p\" size=\"50\" VALUE=\"".$row["adresa"]."\">";		
		echo "</td>";
		echo "</tr>";
		echo "<tr>";
		echo "<td colspan=\"2\">Judetul:</td>";
		echo "<td colspan=\"2\">";
		echo "<INPUT TYPE=\"TEXT\" onkeydown=\"ModifyEnterKeyPressAsTab(event)\" onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\"  NAME=\"judet\" size=\"25\" VALUE=\"".$row["judet"]."\">";		
		echo "</td>";
		echo "</tr>";
	
		echo "<tr><td><BR></td></tr>";

		echo "<tr>";
		echo "<td colspan=\"5\" align=\"right\" height=\"35px\">";
		echo "<input type=\"submit\" name=\"actiune\" id=\"button10\" value=\"MODIFIC\">";
		echo "<input type=\"hidden\" name=\"tip_act4\" value=\"DATE_GEN\">";
		//echo "<input type=\"submit\" name=\"actiune\" value=\"MODIFIC\" onMouseUp=\"javascript:setTimeout('window.close()',3000);\">";
		echo "<input type=\"button\" onclick=\"javascript:window.close()\" id=\"button10\" value=\"RENUNT\">";
		echo "</td>";
		echo "</tr>";
		$i++;
					
	}	
	 echo  "</table>";		
	mysql_close($connection);
		
				
}	 

if ($_POST["actiune"]=="MODIFIC" AND isset($_POST["tip_act4"]) AND $_POST["tip_act4"]=="DATE_GEN")
{
		
		echo "<body onload=\"load()\">";

			include 'A21_param1.php';
			echo "<TR>";
			echo "<TD colspan=\"35\" align=\"center\">";
			echo "<B>DEFINIRE DATE UNITATE</B>";
			echo "</TD>";
			echo "</TR>";
			echo "<FORM NAME=\"form1\" ACTION=\"A21_utilitare.php\" METHOD=\"POST\">";
			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);
			
			include 'A21_param1.php';
			
			$query="UPDATE unitate SET denunit=\"".$_POST["denunit"]."\",cf=\"".$_POST["cf"]."\",func1=\"".$_POST["func1"]."\",";
			$query=$query."nume1=\"".$_POST["nume_p1"]."\",func2=\"".$_POST["func2"]."\",nume2=\"".$_POST["nume_p2"]."\",";
			$query=$query."adresa=\"".$_POST["adresa_p"]."\",judet=\"".$_POST["judet"]."\" where unit=\"".$_POST["unit"]."\"";
			$result=mysql_query($query) or die("Interogare esuata: ".mysql_error());
									
			$query2="SELECT * FROM unitate where unit=\"".$_POST["unit"]."\"";
			$result2=mysql_query($query2) or die("Interogare esuata: ".mysql_error());
			$total2 = mysql_num_rows($result2);
		
	$i=0;
	while($row=mysql_fetch_array($result2))
	{
		echo "<TABLE class=\"table2\" id=\"navigate\" cellSpacing=0 cellPadding=0 width=\"100%\" border=0>";
		if ($i-floor($i/2)*2==0)
		{
			echo "<TR BGCOLOR=\"#FFFFFF\">";
		}
		else
		{
			echo "<TR BGCOLOR=\"#EAEBEB\">";
		}		  	
		echo "<tr><td><BR></td></tr>";

		echo "<tr>";
		echo "<td colspan=\"2\">Denumire unitate:</td>";
		echo "<td colspan=\"2\">";
		echo "<input name=\"denunit\" type=\"text\" onkeydown=\"ModifyEnterKeyPressAsTab(event)\" onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\" id=\"denunit\" size=\"70\" VALUE=\"".$row["denunit"]."\">";
		echo "</td>";
		echo "</tr>";
		echo "<tr>";
		echo "<td colspan=\"2\">Cod fiscal:</td>";
		echo "<td colspan=\"2\">";
		echo "<INPUT TYPE=\"TEXT\"  onkeydown=\"ModifyEnterKeyPressAsTab(event)\" onfocus=\"onfocus_camp(this)\" onblur=\"onblur_numar(this)\" onkeypress=\"return isNumberKey(event)\" size=\"12\"  NAME=\"cf\" VALUE=\"".$row["cf"]."\">";
		echo "</td>";
		echo "</tr>";
		echo "<tr>";
		echo "<td colspan=\"2\">Denumire functie 1:</td>";
		echo "<td colspan=\"2\">";
		echo "<INPUT TYPE=\"TEXT\" onkeydown=\"ModifyEnterKeyPressAsTab(event)\" onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\"  NAME=\"func1\" size=\"40\" VALUE=\"".$row["func1"]."\">";		
		echo "</td>";
		echo "</tr>";
		echo "<tr>";
		echo "<td colspan=\"2\">Nume si prenume 1:</td>";
		echo "<td colspan=\"2\">";
		echo "<INPUT TYPE=\"TEXT\"  onkeydown=\"ModifyEnterKeyPressAsTab(event)\" onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\"  NAME=\"nume_p1\" size=\"40\" VALUE=\"".$row["nume1"]."\">";		
		echo "</td>";
		echo "</tr>";
		echo "<tr>";
		echo "<td colspan=\"2\">Denumire functie 2:</td>";
		echo "<td colspan=\"2\">";
		echo "<INPUT TYPE=\"TEXT\" onkeydown=\"ModifyEnterKeyPressAsTab(event)\" onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\"  NAME=\"func2\" size=\"40\" VALUE=\"".$row["func2"]."\">";				
		echo "</td>";
		echo "</tr>";
		echo "<tr>";
		echo "<td colspan=\"2\">Nume si prenume 2:</td>";
		echo "<td colspan=\"2\">";
		echo "<INPUT TYPE=\"TEXT\" onkeydown=\"ModifyEnterKeyPressAsTab(event)\" onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\"  NAME=\"nume_p2\" size=\"40\" VALUE=\"".$row["nume2"]."\">";		
		echo "</td>";
		echo "</tr>";
		echo "<tr>";
		echo "<td colspan=\"2\">Adresa:</td>";
		echo "<td colspan=\"2\">";
		echo "<INPUT TYPE=\"TEXT\" onkeydown=\"ModifyEnterKeyPressAsTab(event)\" onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\"  NAME=\"adresa_p\" size=\"50\" VALUE=\"".$row["adresa"]."\">";		
		echo "</td>";
		echo "</tr>";
		echo "<tr>";
		echo "<td colspan=\"2\">Judetul:</td>";
		echo "<td colspan=\"2\">";
		echo "<INPUT TYPE=\"TEXT\" onkeydown=\"ModifyEnterKeyPressAsTab(event)\" onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\"  NAME=\"judet\" size=\"25\" VALUE=\"".$row["judet"]."\">";		
		echo "</td>";
		echo "</tr>";
			
		echo "<tr><td><BR></td></tr>";

		echo "<tr>";
		echo "<td colspan=\"5\" align=\"right\">";
		echo "<input type=\"submit\" name=\"actiune\" id=\"button10\" value=\"MODIFIC\" onLoad=\"javascript:window.close();\">";
		//echo "<input type=\"submit\" name=\"actiune\" value=\"MODIFIC\" onMouseUp=\"javascript:setTimeout('window.close()',3000);\">";
		echo "<input type=\"button\" onclick=\"javascript:window.close()\" id=\"button10\" value=\"RENUNT\">";
		echo "</td>";
		echo "</tr>";
		$i++;
					
	}	
	echo "</form>";
	echo  "</table>";		
	mysql_close($connection);																																
}			
	
if ($_POST["actiune"]=="GRUPE PRESCOLARI" 
		OR $_POST["actiune"]=="CONFIRM" AND isset($_POST["tip_act2"]) AND $_POST["tip_act2"]=="GRUPE"
		OR $_POST["actiune"]=="MODIFIC" AND isset($_POST["tip_act2"]) AND $_POST["tip_act2"]=="GRUPE"
		OR $_POST["actiune"]=="STERGE" AND isset($_POST["tip_act2"]) AND $_POST["tip_act2"]=="GRUPE")
{	
			echo "<TABLE class=\"style1\" cellSpacing=0 cellPadding=0 width=\"100%\" border=0>";		
			echo "<TR>";
			echo "<TD colspan=\"35\" align=\"center\">";
			echo "<B>GRUPE PRESCOLARI</B>";
			echo "</TD>";
			echo "</TR>";
			echo "</TABLE>";
			echo "<BR>";
			$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);

			IF ($_POST["actiune"]=="CONFIRM" AND isset($_POST["tip_act2"]) AND $_POST["tip_act2"]=="GRUPE")
			{
				include 'A21_param1.php';
				
				$wcodgrp = $_POST["codgrp"];
				$wdengrp=$_POST["dengrp_".$wcodgrp];
				
				
				$query1="INSERT INTO grupe (codgrp,dengrp)";
				$query1=$query1."VALUES (\"".$wcodgrp."\",\"".$wdengrp."\")";
				$result1=mysql_query($query1) or die("Interogare esuata: ".mysql_error());	
			}
			
			if ($_POST["actiune"]=="MODIFIC" and isset($_POST["tip_act2"]) AND $_POST["tip_act2"] == "GRUPE")
			{	
				include 'A21_param1.php';
		
				$wcodgrp=$_POST["codgrp"];
				$wdengrp=$_POST["dengrp"];
			
				$query2="UPDATE grupe set codgrp=\"".$wcodgrp."\", dengrp=\"".$wdengrp."\" WHERE codgrp = \"".$_POST["codgrp"]."\"";
				$result2=mysql_query($query2) or die("Interogare esuata: ".mysql_error());
			}
			
			if ($_POST["actiune"]=="STERGE" and isset($_POST["tip_act2"]) AND $_POST["tip_act2"] == "GRUPE")
			{
				include 'A21_param1.php';
		
				$query3="DELETE FROM grupe WHERE codgrp = \"".$_POST["codgrp"]."\"";
				$result3=mysql_query($query3) or die("Interogare esuata: ".mysql_error());
				
				$query4="DELETE FROM copii WHERE codgrp = \"".$_POST["codgrp"]."\"";
				$result4=mysql_query($query4) or die("Interogare esuata: ".mysql_error());
				
				$query4="DELETE FROM chitante WHERE codgrp = \"".$_POST["codgrp"]."\"";
				$result4=mysql_query($query4) or die("Interogare esuata: ".mysql_error());
			}

	
			echo "<FORM NAME=\"form\" ACTION=\"A21_utilitare.php\" METHOD=\"POST\" onsubmit=\"target_popup5(this)\">";
			include 'A21_param1.php';
			echo "<TABLE cellSpacing=0 cellPadding=0 width=\"70%; height:100%;\" border=0 align=\"right\">";	
			echo "<TR>";
			echo "<TD align=\"right\" height=\"35\">";
			echo "<input type=\"submit\" class=\"noPrint\" NAME=\"actiune\" value=\"ADAUGARE\">";
			echo "<input type=\"hidden\" name=\"tip_act\" value=\"GRUPE\">";
			echo "</TD>";	
			echo "</FORM>";
			
			echo "<FORM NAME=\"form\" ACTION=\"A21_copii.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\" onMouseUp=\"javascript:setTimeout('window.close()',300);\">";
			echo "<input type=\"button\" onclick=\"javascript:window.close()\" id=\"button10\" value=\"RENUNT\">";
			echo "<input type=\"hidden\" name=\"tip_act\" value=\"GRUPE\">";
			echo "</TD>";
			echo "</TR>";
//			echo "<TR><TD>&nbsp</TD></TR>";
			echo "</TABLE>";
			echo "<br>";
			echo "<TABLE cellSpacing=0 cellPadding=0 width=\"90%\" border=0>";
			echo "<TR BGCOLOR=\"white\">";			
			echo 	"<TH align=\"center\" width=\"10%\" class=\"td35\">Cod grupa</TH>";					
			echo	"<TH align=\"center\" width=\"40%\"  class=\"td35\">Denumire grupa</TH>";	
			echo	"<TH align=\"center\" width=\"10%\" class=\"td39\">Nr. prescolari</TH>";		
			echo "</TR>";
			echo "</form>";
			
			$query="SELECT * FROM grupe order by codgrp";
			$result=mysql_query($query) or die("Interogare esuata: ".mysql_error());
			
			echo "<FORM NAME=\"form\" ACTION=\"A21_utilitare.php\" METHOD=\"POST\" onsubmit=\"target_popup5(this)\">";
			include 'A21_param1.php';
			echo "<input type=\"hidden\" name=\"tip_act3\" value=\"EDITG\">";
			
			$i=0;
			while($row = mysql_fetch_array( $result))	
			{ 	
				$query2="SELECT * FROM copii where codgrp=\"".$row["codgrp"]."\"";
				$result2=mysql_query($query2) or die("Interogare esuata: ".mysql_error());
				$total2=mysql_num_rows($result2);	
					
				if ($i-floor($i/2)*2==0)
				{
					echo "<TR class=\"tr4\" BGCOLOR=\"#FFFFFF\">";
				}
				else
				{
					echo "<TR class=\"tr4\" BGCOLOR=\"#EAEBEB\">";
				}
				
				echo "<TD width=\"10%\" height=\"30px\" align=\"center\">";			
				echo "<input type=\"submit\" name=\"actiune\" class=\"noPrint11\" value='<".$row["codgrp"].">'>";
				echo "</TD>";
				echo"<TD width=\"40%\" align=\"left\">";
				echo "&nbsp".$row["dengrp"]."&nbsp";
				echo "</TD>";
				echo"<TD width=\"10%\" align=\"center\">";
				echo "&nbsp".$total2."&nbsp";
				echo "</TD>";
				echo "</TR>";
				$i++;					
			}
			
		echo "</FORM>";
		echo "</TABLE>";
}	

IF ($_POST["actiune"]=="ADAUGARE" AND isset($_POST["tip_act"]) AND $_POST["tip_act"]=="GRUPE")
{			
			echo "<TABLE class=\"style1\" cellSpacing=0 cellPadding=0 width=\"100%\" border=0>";		
			echo "<TR>";
			echo "<TD colspan=\"35\" align=\"center\">";
			echo "<B>GRUPE PRESCOLARI</B>";
			echo "</TD>";
			echo "</TR>";
			echo "<FORM NAME=\"form1\" ACTION=\"A21_utilitare.php\" METHOD=\"POST\" TARGET=\"win16\">";
			include 'A21_param1.php';
			echo "</TABLE>";
			echo "<BR>";
			$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 grupe where codgrp=(select max(codgrp) from grupe WHERE codgrp <> 99) order by codgrp";
			$result=mysql_query($query) or die("Interogare esuata: ".mysql_error());
	
			echo "<TABLE cellSpacing=0 cellPadding=0 width=\"60%\" border=0>";
			echo "<TR BGCOLOR=\"white\">";			
			echo 	"<TH align=\"center\" width=\"10%\" class=\"td35\">Cod grupa</TH>";					
			echo	"<TH align=\"center\" width=\"40%\"  class=\"td39\">Denumire grupa</TH>";	
			echo "</TR>";
			
		$i=0;		
		$wcodgrp=0;	
		if(mysql_num_rows($result) == 0) 
		{
			$wcodgrp = "10";
			
				if ($i-floor($i/2)*2==0)
				{
					echo "<TR class=\"tr4\" BGCOLOR=\"#FFFFFF\">";
				}
				else
				{
					echo "<TR class=\"tr4\" BGCOLOR=\"#EAEBEB\">";
				}
				
				echo"<TD width=\"10%\" align=\"center\">";
				echo "".$wcodgrp."";
				echo "<INPUT TYPE=\"HIDDEN\" NAME=\"codgrp\" VALUE=\"".$wcodgrp."\">";
				echo "</TD>";			
				echo "<TD width=\"40%\" align=\"left\">";
				echo "<INPUT TYPE=\"TEXT\" size=\"70\" onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\" class=\"text13\" NAME=\"dengrp_".$wcodgrp."\" VALUE=\"\">";
				echo "</TD>";				
				$i++;					
		}
		else
		{
			while($row = mysql_fetch_array( $result )) 
			{ 	
				$wcodgrp = $row["codgrp"] + "5";
				
				if ($i-floor($i/2)*2==0)
				{
					echo "<TR class=\"tr4\" BGCOLOR=\"#FFFFFF\">";
				}
				else
				{
					echo "<TR class=\"tr4\" BGCOLOR=\"#EAEBEB\">";
				}
				
				echo"<TD width=\"10%\" align=\"center\">";
				echo "".$wcodgrp."";
				echo "<INPUT TYPE=\"HIDDEN\" NAME=\"codgrp\" VALUE=\"".$wcodgrp."\">";
				echo "</TD>";			
				echo "<TD width=\"40%\" align=\"left\">";
				echo "<INPUT TYPE=\"TEXT\" size=\"70\" onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\" class=\"text13\" NAME=\"dengrp_".$wcodgrp."\" VALUE=\"\">";
				echo "</TD>";				
				$i++;
			}	
		}
			
			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);\" onclick=\"this.disabled=true;this.form.submit();\" value=\"CONFIRM\">";
			echo "</td>";
			echo "<INPUT TYPE=\"HIDDEN\" NAME=\"actiune\" VALUE=\"CONFIRM\">";
			echo "<input type=\"hidden\"name=\"tip_act2\" value=\"GRUPE\">";
			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>";
}	

if (substr($_POST["actiune"],0,1)=="<" AND isset($_POST["tip_act3"]) and $_POST["tip_act3"]=="EDITG")
{
			echo "<TABLE class=\"style1\" cellSpacing=0 cellPadding=0 width=\"100%\" border=0>";		
			echo "<TR>";
			echo "<TD colspan=\"35\" align=\"center\" class=\"td_print2\">";
			echo "<B>GRUPE PRESCOLARI</B>";
			echo "</TD>";
			echo "</TR>";
			echo "<FORM NAME=\"form1\" ACTION=\"A21_utilitare.php\" METHOD=\"POST\" TARGET=\"win16\">";
			include 'A21_param1.php';
			echo "</TABLE>";
			echo "<BR>";
			$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 grupe where codgrp=".substr($_POST["actiune"],1,strpos($_POST["actiune"],'>')-1)."";
			$result=mysql_query($query) or die("Interogare esuata: ".mysql_error());
	
			echo "<TABLE cellSpacing=0 cellPadding=0 width=\"60%\" border=0 align=\"center\">";
			echo "<TR BGCOLOR=\"white\">";			
			echo 	"<TH align=\"center\" width=\"10%\" class=\"td35\">Cod grupa</TH>";					
			echo	"<TH align=\"center\" width=\"40%\"  class=\"td39\">Denumire grupa</TH>";	
			echo "</TR>";
			
			$i=0;
			while($row = mysql_fetch_array( $result )) 
			{ 	
				$wcodgrp = $row["codgrp"];
				
				if ($i-floor($i/2)*2==0)
				{
					echo "<TR class=\"tr4\" BGCOLOR=\"#FFFFFF\">";
				}
				else
				{
					echo "<TR class=\"tr4\" BGCOLOR=\"#EAEBEB\">";
				}
				
				echo "<TD width=\"10%\" align=\"center\">";
//				echo "<input type=\"text\" readonly=\"readonly\" size=\"5\" name=\"codgrp\" value=\"".$row["codgrp"]."\"";
				echo "".$row["codgrp"]."";
				echo "<INPUT TYPE=\"HIDDEN\" NAME=\"codgrp\" VALUE=\"".$row["codgrp"]."\">";
				echo "</TD>";			
				echo "<TD width=\"40%\" align=\"left\">";
				echo "<INPUT TYPE=\"TEXT\" size=\"70\" onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\" class=\"text13\" NAME=\"dengrp\" VALUE=\"".$row["dengrp"]."\">";
				echo "</TD>";				
				$i++;							
			}
			
			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=\"MODIFIC\">";
			echo "<input type=\"hidden\"name=\"tip_act2\" value=\"GRUPE\">";
			echo "</td>";			
			echo "<td width=\"1%\" height=\"35\" align=\"left\">";
			echo "<input type=\"submit\" name=\"actiune\" id=\"button10\" onClick=\"return confirm_stergere_g()\" value=\"STERGE\">";	
			echo "<INPUT TYPE=\"HIDDEN\" NAME=\"tip_act2\" VALUE=\"GRUPE\">";
			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>";
}	


if ($_POST["actiune"]=="PARINTI" 
		OR $_POST["actiune"]=="CONFIRM" AND isset($_POST["tip_act"]) and $_POST["tip_act"]=="PARINTE"
		OR $_POST["actiune"]=="MODIFIC" AND isset($_POST["tip_act"]) and $_POST["tip_act"]=="PARINTE"
		OR $_POST["actiune"]=="STERGE"  AND isset($_POST["tip_act"]) and $_POST["tip_act"]=="PARINTE"
		OR substr($_POST["actiune"],0,4)=="CAUT" AND isset($_POST["tip_act"]) and $_POST["tip_act"]=="PARINTE"
		OR $_POST["actiune"]=="CONFIRM" AND isset($_POST["tip_act"]) and $_POST["tip_act"]=="CONT"
		OR $_POST["actiune"]=="MODIFIC" AND isset($_POST["tip_act"]) and $_POST["tip_act"]=="CONT")
{
			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_utilitare.php\" METHOD=\"POST\" onsubmit=\"target_popup4(this)\">";
			include 'A21_param1.php';
			
			//$wdenluna_sel=substr($_POST["luna_sel"],3,strlen($_POST["luna_sel"])-3);
			//$wdengrp_sel=substr($_POST["grp_sel"],3,strlen($_POST["grp_sel"])-3);
			
			echo "<TABLE class=\"style1\" cellSpacing=0 cellPadding=0 width=\"100%\" border=0>";				
			echo "<TR>";
			echo "<TD align=\"center\" class=\"td_print2\">";
//			echo "<B>EDITARE PARINTI &nbsp<U>".$wdengrp_sel."</B>";
			echo "<B>EDITARE PARINTI</B>";
			echo "<BR>";
			echo "</TD>";
			echo "</TR>";
			echo "</TABLE>";
			echo "<TABLE class=\"style1\" cellSpacing=0 cellPadding=0 width=\"50%\" border=0>";
			echo "<TR>";
			echo "<TD align=\"center\" class=\"td_print2\">";
//			echo "<B>LUNA:&nbsp<U>".$wdenluna_sel."</U>&nbsp&nbsp&nbsp&nbsp ANUL:&nbsp<U>".$_POST["an"]."</U></B>";
			echo "<B>ANUL:&nbsp<U>".$_POST["an"]."</U></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=\"PARINTE\">";
			if(isset($_POST["sel_nume_p1"]))
			{
				echo "<INPUT TYPE=\"HIDDEN\" NAME=\"sel_nume_p1\" VALUE=\"".$_POST["sel_nume_p1"]."\">";
			}
			if(isset($_POST["sel_pren_p1"]))
			{
				echo "<INPUT TYPE=\"HIDDEN\" NAME=\"sel_pren_p1\" VALUE=\"".$_POST["sel_pren_p1"]."\">";
			}
			if(isset($_POST["sel_nume_p2"]))
			{
				echo "<INPUT TYPE=\"HIDDEN\" NAME=\"sel_nume_p2\" VALUE=\"".$_POST["sel_nume_p2"]."\">";
			}
			if(isset($_POST["sel_pren_p2"]))
			{
				echo "<INPUT TYPE=\"HIDDEN\" NAME=\"sel_pren_p2\" VALUE=\"".$_POST["sel_pren_p2"]."\">";
			}
			echo "</TD>";
			echo "</FORM>";
			
			echo "<FORM NAME=\"form\" ACTION=\"A21_copii.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\">";
			echo "<input type=\"hidden\" name=\"tip_act\" value=\"PARINTE\">";
			echo "</FORM>";
			
			echo "<FORM NAME=\"form\" ACTION=\"A21_utilitare.php\" METHOD=\"POST\" target=\"win01\">";
			include 'A21_param1.php';	
			if(isset($_POST["sel_nume_p1"]))
			{
				echo "<INPUT TYPE=\"HIDDEN\" NAME=\"sel_nume_p1\" VALUE=\"".$_POST["sel_nume_p1"]."\">";
			}
			if(isset($_POST["sel_pren_p1"]))
			{
				echo "<INPUT TYPE=\"HIDDEN\" NAME=\"sel_pren_p1\" VALUE=\"".$_POST["sel_pren_p1"]."\">";
			}
			if(isset($_POST["sel_nume_p2"]))
			{
				echo "<INPUT TYPE=\"HIDDEN\" NAME=\"sel_nume_p2\" VALUE=\"".$_POST["sel_nume_p2"]."\">";
			}
			if(isset($_POST["sel_pren_p2"]))
			{
				echo "<INPUT TYPE=\"HIDDEN\" NAME=\"sel_pren_p2\" VALUE=\"".$_POST["sel_pren_p2"]."\">";
			}
			echo "</TD>";
			echo "</TR>";
			echo "</TABLE>";
			
			
	IF ($_POST["actiune"]=="CONFIRM" and isset($_POST["tip_act"]) AND $_POST["tip_act"] == "PARINTE")
	{
		include 'A21_param1.php';
		
//************VERIFICARE CNP****************************************************************************************************************//	
/*	
			$query="SELECT * FROM parinte where codparinte1=\"".$_POST["codparinte1"]."\"";	
			$result=mysql_query($query) or die("Interogare esuata: ".mysql_error());
			
			$query1="SELECT * FROM parinte where codparinte2=\"".$_POST["codparinte2"]."\"";	
			$result1=mysql_query($query1) or die("Interogare esuata: ".mysql_error());
			
			$query3="SELECT * FROM parinte where codparinte1=\"".$_POST["codparinte2"]."\"";	
			$result3=mysql_query($query3) or die("Interogare esuata: ".mysql_error());
			
			$query4="SELECT * FROM parinte where codparinte2=\"".$_POST["codparinte1"]."\"";	
			$result4=mysql_query($query4) or die("Interogare esuata: ".mysql_error());
		
			IF (mysql_num_rows($result) > 0 AND $_POST["codparinte1"]<>"")
			{
				echo "<script type='text/javascript'>alert('Persoana cu acelasi Cod parinte 1 deja existenta.Reluati! ');</script>";
			}
			ELSEIF (mysql_num_rows($result1) > 0 AND $_POST["codparinte2"]<>"")
			{
				echo "<script type='text/javascript'>alert('Persoana cu acelasi Cod parinte 2 deja existenta.Reluati! ');</script>";
			}
			ELSEIF ($_POST["codparinte1"]=="" AND $_POST["codparinte2"]=="")
			{
				echo "<script type='text/javascript'>alert('Nu ati completat campul Cod parinte 1.Reluati! ');</script>";
			}
			ELSEIF (mysql_num_rows($result3) > 0)
			{
				echo "<script type='text/javascript'>alert('Persoana cu acelasi Cod parinte 1 deja existenta.Reluati! ');</script>";
			}
			ELSEIF (mysql_num_rows($result4) > 0)
			{
				echo "<script type='text/javascript'>alert('Persoana cu acelasi Cod parinte 2 deja existenta.Reluati! ');</script>";
			}
			ELSE
			{
				$query2="INSERT INTO parinte (codparinte1,nume1,pren1,tel1,codparinte2,nume2,pren2,tel2,adresa)";
				$query2=$query2."VALUES (\"".$_POST["codparinte1"]."\",\"".$_POST["nume_p1"]."\",\"".$_POST["pren_p1"]."\",\"".$_POST["tel1"]."\",\"".$_POST["codparinte2"]."\",\"".$_POST["nume_p2"]."\",\"".$_POST["pren_p2"]."\",\"".$_POST["tel2"]."\",\"".$_POST["adresa_p"]."\")";
				$result2=mysql_query($query2) or die("Interogare esuata: ".mysql_error());	
			}
*/			
//***********************************************************************************************************************************************			
			$query="SELECT * FROM parinte where codgrp=\"".substr($_POST["grp_sel"],0,2)."\" and codparinte1=(select max(codparinte1) from parinte where codgrp=\"".substr($_POST["grp_sel"],0,2)."\") order by codparinte1";
			$result=mysql_query($query) or die("Interogare esuata: ".mysql_error());
			$row=mysql_fetch_array($result);
		
			if(mysql_num_rows($result) == 0) 
			{
				$wcodparinte1=substr($_POST["grp_sel"],0,2)."901";
			}
			else 
			{	
				$wcodparinte1 = $row["codparinte1"] + 1;
				$_SESSION["codparinte1"] = $wcodparinte1;	
			}	
		
			$query2="INSERT INTO parinte (codgrp,codparinte1,nume1,pren1,tel1,codparinte2,nume2,pren2,tel2,adresa)";
			$query2=$query2."VALUES (\"".$_POST["grp_sel"]."\",\"".$wcodparinte1."\",\"".$_POST["nume_p1"]."\",\"".$_POST["pren_p1"]."\",\"".$_POST["tel1"]."\",'',\"".$_POST["nume_p2"]."\",\"".$_POST["pren_p2"]."\",\"".$_POST["tel2"]."\",\"".$_POST["adresa_p"]."\")";
			$result2=mysql_query($query2) or die("Interogare esuata: ".mysql_error());	
	}
	
	if ($_POST["actiune"]=="MODIFIC" and isset($_POST["tip_act"]) AND $_POST["tip_act"] == "PARINTE")
	{	
		include 'A21_param1.php';
		
			$query4="UPDATE parinte set codparinte1=\"".$_POST["codparinte1"]."\", nume1=\"".$_POST["nume_p1"]."\", pren1=\"".$_POST["pren_p1"]."\",tel1=\"".$_POST["tel1"]."\",codparinte2='',nume2=\"".$_POST["nume_p2"]."\",pren2=\"".$_POST["pren_p2"]."\",tel2=\"".$_POST["tel2"]."\",adresa=\"".$_POST["adresa_p"]."\" WHERE codparinte1 = \"".$_POST["codparinte1"]."\"";
			$result4=mysql_query($query4) or die("Interogare esuata: ".mysql_error());
	}
	
	if ($_POST["actiune"]=="STERGE" and isset($_POST["tip_act"]) AND $_POST["tip_act"] == "PARINTE")
	{
		include 'A21_param1.php';
		
			$query4="DELETE FROM parinte WHERE codparinte1 = \"".$_POST["codparinte1"]."\"";
			$result4=mysql_query($query4) or die("Interogare esuata: ".mysql_error());	
	}

	IF ($_POST["actiune"]=="CONFIRM" and isset($_POST["tip_act"]) AND $_POST["tip_act"] == "CONT")
	{
		include 'A21_param1.php';
		
			$query="SELECT * FROM parinte where codparinte1=\"".$_POST["codparinte1"]."\"";	
			$result=mysql_query($query) or die("Interogare esuata: ".mysql_error());
			$row = mysql_fetch_array($result);
			
			$wuser = '#'.$_POST["user"];
			$wpass = $_POST["pass"];
			
			$query2="SELECT * FROM users.login_fgr where user=\"".$wuser."\" and pw=\"".$wpass."\"";	
			$result2=mysql_query($query2) or die("Interogare esuata: ".mysql_error());	
		
			IF (mysql_num_rows($result2) > 0)
			{
				echo "<script type='text/javascript'>alert('Cont cu acelasi utilizator si parola deja existent.Reluati! ');</script>";
			}
			else
			{
				$query2="INSERT INTO users.login_fgr (user,pw,nume,prenume,codparinte,grup,unit,aplic,serie_chit,nr_chit)";
				$query2=$query2."VALUES (\"".$wuser."\",\"".$wpass."\",\"".$row["nume1"]."\",\"".$row["pren1"]."\",\"".$row["codparinte1"]."\",'parinte',\"".$_POST["unit"]."\",\"".$_POST["aplic"]."\",' ',' ')";
				$result2=mysql_query($query2) or die("Interogare esuata: ".mysql_error());	
			
				echo "<script type='text/javascript'>alert('Cont inregistrat cu succes! \\nUtilizator: ".$wuser." \\nParola: ".$wpass." ');</script>";
			}
	}
	
	if ($_POST["actiune"]=="MODIFIC" and isset($_POST["tip_act"]) AND $_POST["tip_act"] == "CONT")
	{	
		include 'A21_param1.php';
		
			$query="SELECT * FROM parinte where codparinte1=\"".$_POST["codparinte1"]."\"";	
			$result=mysql_query($query) or die("Interogare esuata: ".mysql_error());
			$row = mysql_fetch_array($result);
	
			IF (substr($_POST["user"],0,1)=='#')
			{
				$wuser = $_POST["user"];
			}
			else
			{
				$wuser = '#'.$_POST["user"];
			}
				$wpass = $_POST["pass"];
				
			$query2="SELECT * FROM users.login_fgr where user=\"".$wuser."\" and pw=\"".$wpass."\"";	
			$result2=mysql_query($query2) or die("Interogare esuata: ".mysql_error());
			
			IF (mysql_num_rows($result2) > 0)
			{
				echo "<script type='text/javascript'>alert('Cont cu acelasi utilizator si parola deja existent.Reluati! ');</script>";
			}
			else
			{	
				$query4="UPDATE users.login_fgr set user=\"".$wuser."\",pw=\"".$wpass."\", nume=\"".$row["nume1"]."\", prenume=\"".$row["pren1"]."\",codparinte=\"".$row["codparinte1"]."\",grup='parinte',unit=\"".$_POST["unit"]."\",aplic=\"".$_POST["aplic"]."\",serie_chit=' ',nr_chit=' ' WHERE codparinte = \"".$_POST["codparinte1"]."\"";
				$result4=mysql_query($query4) or die("Interogare esuata: ".mysql_error());
			
				echo "<script type='text/javascript'>alert('Cont actualizat cu succes!\\nUtilizator: ".$wuser." \\nParola: ".$wpass." ');</script>";
			}	
	}
	
	
// *****************				
		if(isset($_POST["sel_nume_p1"]))
		{
			$wsel_nume_p1=$_POST["sel_nume_p1"];
			echo "<INPUT TYPE=\"HIDDEN\" NAME=\"sel_nume_p1\" VALUE=\"".$_POST["sel_nume_p1"]."\">";
		}
		else
		{
			$wsel_nume_p1=" ";
		}
		if(isset($_POST["sel_pren_p1"]))
		{
			$wsel_pren_p1=$_POST["sel_pren_p1"];
			echo "<INPUT TYPE=\"HIDDEN\" NAME=\"sel_pren_p1\" VALUE=\"".$_POST["sel_pren_p1"]."\">";
		}
		else
		{
			$wsel_pren_p1=" ";
		}		
		if(isset($_POST["sel_nume_p2"]))
		{
			$wsel_nume_p2=$_POST["sel_nume_p2"];
			echo "<INPUT TYPE=\"HIDDEN\" NAME=\"sel_nume_p2\" VALUE=\"".$_POST["sel_nume_p2"]."\">";
		}
		else
		{
			$wsel_nume_p2=" ";
		}
		if(isset($_POST["sel_pren_p2"]))
		{
			$wsel_pren_p2=$_POST["sel_pren_p2"];
			echo "<INPUT TYPE=\"HIDDEN\" NAME=\"sel_pren_p2\" VALUE=\"".$_POST["sel_pren_p2"]."\">";
		}
		else
		{
			$wsel_pren_p2=" ";
		}		
		
			echo "<TABLE cellSpacing=0 cellPadding=0 width=\"90%\" border=0>";
			echo "<TR>";
			echo "<TD colspan=\"1\" align=\"left\">&nbsp</TD>";
			echo "<TD colspan=\"1\" align=\"left\">&nbsp</TD>";
			echo "<TD colspan=\"1\" align=\"left\">";  
			echo "<INPUT name=\"sel_nume_p1\" SIZE=\"33\" type=\"text\" VALUE=\"".$wsel_nume_p1."\">";
			echo "</TD>";
			echo "<TD colspan=\"1\" align=\"left\">&nbsp</TD>";
//			echo "<TD colspan=\"1\" align=\"left\">&nbsp</TD>";
//			echo "<TD colspan=\"1\" align=\"left\">";  
//			echo "<INPUT name=\"sel_pren1\" type=\"text\" VALUE=\"".$wsel_pren1."\">";
//			echo "</TD>";
			echo "<TD colspan=\"1\" align=\"left\">";  
			echo "<INPUT name=\"sel_nume_p2\" SIZE=\"33\" type=\"text\" VALUE=\"".$wsel_nume_p2."\">";
			echo "</TD>";
//			echo "<TD colspan=\"1\" align=\"left\">";  
//			echo "<INPUT name=\"sel_pren2\" type=\"text\" VALUE=\"".$wsel_pren2."\">";
//			echo "</TD>";
			echo "<TD colspan=\"1\" align=\"left\" height=\"30px\">";  
			echo "<INPUT TYPE=\"SUBMIT\" name=\"actiune\" class=\"noPrint\" VALUE=\"CAUT\">";
			echo "<INPUT TYPE=\"HIDDEN\" name=\"tip_act\" VALUE=\"PARINTE\">";
			echo "</TD>";
			echo "</TR>";
				
// *******************				

				
// ************************************
				if($_POST["actiune"]=="CAUT" or isset($_POST["sel_nume_p1"]) or isset($_POST["sel_nume_p1"]))
				{
					$wcaut_nume_p1=strtoupper(trim($_POST["sel_nume_p1"]));
					$wlen_nume_p1=strlen($wcaut_nume_p1);
//					$wcaut_pren1=strtoupper(trim($_POST["sel_pren1"]));
//					$wlen_pren1=strlen($wcaut_pren1);
					$wcaut_nume_p2=strtoupper(trim($_POST["sel_nume_p2"]));
					$wlen_nume_p2=strlen($wcaut_nume_p2);
//					$wcaut_pren2=strtoupper(trim($_POST["sel_pren2"]));
//					$wlen_pren2=strlen($wcaut_pren2);
					
					$query="SELECT * FROM parinte";
					if ($wlen_nume_p1<>0)
					{
						$query=$query."  WHERE substr(upper(nume1),1,".$wlen_nume_p1.")=\"".$wcaut_nume_p1."\"";
					}
//					if ($wlen_pren1<>0)
//					{
//						$query=$query."  and substr(upper(concat(nume1,' ',pren1)),1,".$wlen_pren1.")=\"".$wcaut_pren1."\"";
//					}
					if ($wlen_nume_p2<>0)
					{
						$query=$query."  WHERE substr(upper(nume2),1,".$wlen_nume_p2.")=\"".$wcaut_nume_p2."\"";
					}
//					if ($wlen_pren2<>0)
//					{
//						$query=$query."  and substr(upper(concat(nume2,' ',pren2)),1,".$wlen_pren2.")=\"".$wcaut_pren2."\"";
//					}
					$query=$query."  order by nume1,pren1";
				}
				else
				{
					$query="SELECT * FROM parinte order by nume1,pren1";
				}
				$result=mysql_query($query) or die("Interogare esuata: ".mysql_error());	
// ************************************
		
		echo "</FORM>";
			echo "<BR>";
			echo "<TR BGCOLOR=\"white\">";
			
			echo 	"<TH align=\"center\" width=\"5%\" class=\"td35\">Nr. crt.</TH>";
			echo 	"<TH align=\"center\" width=\"6%\" class=\"td35\">Cod parinte</TH>";					
			echo	"<TH align=\"center\" width=\"20%\" class=\"td35\">Nume Prenume 1</TH>";
			echo	"<TH align=\"center\" width=\"10%\" class=\"td35\">Telefon 1</TH>";			
//			echo	"<TH align=\"center\" width=\"8%\" class=\"td35\">Cod parinte 2</TH>";		
			echo	"<TH align=\"center\" width=\"20%\" class=\"td35\">Nume Prenume 2</TH>";
			echo	"<TH align=\"center\" width=\"10%\" class=\"td35\">Telefon 2</TH>";
			echo	"<TH align=\"center\" width=\"25%\" class=\"td39\">Adresa</TH>";
			
			echo "</TR>";
			
		$i=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=\"5%\" align=\"center\">",$i+1,"</TD>";
		
			echo "<TD width=\"8%\" height=\"30px\" align=\"center\">";
			
			echo "<FORM NAME=\"form\" ACTION=\"A21_utilitare.php\" METHOD=\"POST\" onsubmit=\"target_popup4(this)\">";
			include 'A21_param1.php';
			echo "<input type=\"submit\" name=\"actiune\" class=\"noPrint11\" value='<".$row["codparinte1"].">'>";
			echo "<INPUT TYPE=\"hidden\" NAME=\"tip_act\" VALUE=\"PARINTE\">"; 
			if(isset($_POST["sel_nume_p1"]))
			{
				$wsel_nume_p1=$_POST["sel_nume_p1"];
				echo "<INPUT TYPE=\"HIDDEN\" NAME=\"sel_nume_p1\" VALUE=\"".$_POST["sel_nume_p1"]."\">";
			}
			else
			{
				$wsel_nume_p1=" ";
			}
			if(isset($_POST["sel_pren_p1"]))
			{
				$wsel_pren_p1=$_POST["sel_pren_p1"];
				echo "<INPUT TYPE=\"HIDDEN\" NAME=\"sel_pren_p1\" VALUE=\"".$_POST["sel_pren_p1"]."\">";
			}
			else
			{
				$wsel_pren_p1=" ";
			}		
			if(isset($_POST["sel_nume_p2"]))
			{
				$wsel_nume_p2=$_POST["sel_nume_p2"];
				echo "<INPUT TYPE=\"HIDDEN\" NAME=\"sel_nume_p2\" VALUE=\"".$_POST["sel_nume_p2"]."\">";
			}
			else
			{
				$wsel_nume_p2=" ";
			}
			if(isset($_POST["sel_pren_p2"]))
			{
				$wsel_pren_p2=$_POST["sel_pren_p2"];
				echo "<INPUT TYPE=\"HIDDEN\" NAME=\"sel_pren_p2\" VALUE=\"".$_POST["sel_pren_p2"]."\">";
			}
			else
			{
				$wsel_pren_p2=" ";
			}			
				echo "</TD>";
				
				echo"<TD width=\"20%\" align=\"left\">";
				echo "&nbsp".trim($row["nume1"])." ".trim($row["pren1"])."&nbsp";
				echo "</TD>";
				echo"<TD width=\"10%\" align=\"center\">";
				echo "&nbsp".$row["tel1"]."&nbsp";
				echo "</TD>";
//				echo"<TD width=\"8%\" align=\"center\">";
//				echo "&nbsp".$row["codparinte2"]."&nbsp";
//				echo "&nbsp";
//				echo "</TD>";
				echo"<TD width=\"20%\" align=\"left\">";
				echo "&nbsp".trim($row["nume2"])." ".trim($row["pren2"])."&nbsp";
				echo "</TD>";
				echo"<TD width=\"10%\" align=\"center\">";
				echo "&nbsp".$row["tel2"]."&nbsp";
				echo "</TD>";
				echo"<TD width=\"25%\" align=\"left\">";
				echo "&nbsp".$row["adresa"]."&nbsp";
				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"]=="PARINTE")
{
	echo "<CENTER>";
	
		echo "<FORM NAME=\"form2\" ACTION=\"A21_utilitare.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 parinte order by nume1,pren1";
//			$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 PARINTE</B>";
			echo "<BR>";
			echo "</TD>";
			echo "</TR>";
			echo "</TABLE>";
			
			echo "<TABLE class=\"table1\" cellSpacing=0 cellPadding=0 height=\"100%\" width=\"95%\" border=0>";
			echo "<BR>";
			echo "<TR BGCOLOR=\"white\">";
			
			echo 	"<TH align=\"center\" width=\"12%\" class=\"td35\">Grupa</TH>";	
//			echo 	"<TH align=\"center\" width=\"12%\" class=\"td35\">Cod parinte 1</TH>";					
			echo	"<TH align=\"center\" width=\"35%\" class=\"td35\">Nume 1</TH>";
			echo	"<TH align=\"center\" width=\"35%\" class=\"td35\">Prenume 1</TH>";
			echo 	"<TH align=\"center\" width=\"10%\" class=\"td35\">Tel 1</TH>";
//			echo 	"<TH align=\"center\" width=\"12%\" class=\"td35\">Cod parinte 2</TH>";					
			echo	"<TH align=\"center\" width=\"35%\" class=\"td35\">Nume 2</TH>";
			echo	"<TH align=\"center\" width=\"35%\" class=\"td35\">Prenume 2</TH>";
			echo 	"<TH align=\"center\" width=\"10%\" class=\"td35\">Tel 2</TH>";
			echo 	"<TH align=\"center\" width=\"25%\" class=\"td39\">Adresa</TH>";
			
			echo "</TR>";
		
	
		$query="SELECT * FROM grupe order by codgrp";
		$result=mysql_query($query) or die("Interogare esuata: ".mysql_error());
		
		echo "<TR class=\"tr4\" BGCOLOR=\"#FFFFFF\">";	

		echo "<TD align=\"center\">";
		echo "<SELECT onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\" NAME=\"grp_sel\" id=\"grp_sel\">";

		while($row=mysql_fetch_array($result))
		{	
			echo "<OPTION value=\"".$row["codgrp"]."-".$row["dengrp"]."\">".$row["dengrp"]."</OPTION>";	
		}
		echo "</TD>";
/*		
		echo "<TD width=\"12%\" align=\"center\">";
		echo "<INPUT TYPE=\"TEXT\" size=\"12\" onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\" class=\"text13\" NAME=\"codparinte1\" VALUE=\"\">";
		echo "</TD>";	
*/		
		echo "<TD width=\"35%\" align=\"left\">";
		echo "<INPUT TYPE=\"TEXT\" size=\"15\" onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\" class=\"text13\" NAME=\"nume_p1\" VALUE=\"\">";
		echo "</TD>";				
		echo "<TD width=\"35%\" align=\"left\">";
		echo "<INPUT TYPE=\"TEXT\" size=\"15\" onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\" class=\"text13\" NAME=\"pren_p1\" VALUE=\"\">";
		echo "</TD>";
		echo "<TD width=\"10%\" align=\"center\">";
		echo "<INPUT TYPE=\"TEXT\" size=\"10\" onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\" class=\"text13\" NAME=\"tel1\" VALUE=\"\">";
		echo "</TD>";
//		echo "<TD width=\"12%\" align=\"center\">";
//		echo "<INPUT TYPE=\"TEXT\" size=\"12\" onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\" class=\"text13\" NAME=\"codparinte2\" VALUE=\"\">";
//		echo "</TD>";		
		echo "<TD width=\"35%\" align=\"left\">";
		echo "<INPUT TYPE=\"TEXT\" size=\"15\" onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\" class=\"text13\" NAME=\"nume_p2\" VALUE=\"\">";
		echo "</TD>";				
		echo "<TD width=\"35%\" align=\"left\">";
		echo "<INPUT TYPE=\"TEXT\" size=\"15\" onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\" class=\"text13\" NAME=\"pren_p2\" VALUE=\"\">";
		echo "</TD>";
		echo "<TD width=\"10%\" align=\"center\">";
		echo "<INPUT TYPE=\"TEXT\" size=\"10\" onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\" class=\"text13\" NAME=\"tel2\" VALUE=\"\">";
		echo "</TD>";
		echo "<TD width=\"25%\" align=\"center\">";
		echo "<INPUT TYPE=\"TEXT\" size=\"25\" onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\" class=\"text13\" NAME=\"adresa_p\" VALUE=\"\">";
		echo "</TD>";
		echo "</TR>";	
		
		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);\" onClick=\"check1(this);\" value=\"CONFIRM\">";
		echo "<INPUT TYPE=\"HIDDEN\" NAME=\"tip_act\" VALUE=\"PARINTE\">";
		echo "<INPUT TYPE=\"HIDDEN\" NAME=\"dengrp_sel\" id=\"dengrupa_sel1\">";
		echo "<INPUT TYPE=\"HIDDEN\" NAME=\"grp_sel\" id=\"grupa_sel1\">";
		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"]=="PARINTE")
{
		echo "<CENTER>";
	
		echo "<FORM NAME=\"form2\" ACTION=\"A21_utilitare.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 parinte WHERE codparinte1=\"".substr($_POST["actiune"],1,strpos($_POST["actiune"],'>')-1)."\" order by nume1,pren1";
			$result=mysql_query($query) or die("Interogare esuata: ".mysql_error());
			$row = mysql_fetch_array($result);
	
			$query2="SELECT * FROM users.login_fgr WHERE codparinte=\"".substr($_POST["actiune"],1,strpos($_POST["actiune"],'>')-1)."\"";
			$result2=mysql_query($query2) or die("Interogare esuata: ".mysql_error());
			$total2=mysql_num_rows($result2);
			
			echo "<TABLE class=\"style1\" cellSpacing=0 cellPadding=0 width=\"100%\" border=0>";				
			echo "<TR>";
			echo "<TD align=\"center\" class=\"td_print2\">";
			echo "<B>EDITARE DATE PARINTI</B>";
			echo "<BR>";
			echo "</TD>";
			echo "</TR>";
			echo "</TABLE>";
			
			echo "<TABLE class=\"table1\" cellSpacing=0 cellPadding=0 height=\"100%\" width=\"92%\" border=0>";
			echo "<BR>";
			echo "<TR BGCOLOR=\"white\">";
			
			echo 	"<TH align=\"center\" width=\"6%\" class=\"td35\">Cod parinte</TH>";					
			echo	"<TH align=\"center\" width=\"35%\" class=\"td35\">Nume 1</TH>";
			echo	"<TH align=\"center\" width=\"35%\" class=\"td35\">Prenume 1</TH>";
			echo 	"<TH align=\"center\" width=\"10%\" class=\"td35\">Tel 1</TH>";
//			echo 	"<TH align=\"center\" width=\"12%\" class=\"td35\">Cod parinte 2</TH>";					
			echo	"<TH align=\"center\" width=\"35%\" class=\"td35\">Nume 2</TH>";
			echo	"<TH align=\"center\" width=\"35%\" class=\"td35\">Prenume 2</TH>";
			echo 	"<TH align=\"center\" width=\"10%\" class=\"td35\">Tel 2</TH>";
			echo 	"<TH align=\"center\" width=\"30%\" class=\"td39\">Adresa</TH>";
			
			echo "</TR>";
			 
		echo "<TR class=\"tr4\" BGCOLOR=\"#FFFFFF\">";		
		echo "<TD width=\"6%\" align=\"center\">";
//		echo "<INPUT TYPE=\"TEXT\" DISABLED size=\"5\" onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\" NAME=\"codparinte1\" VALUE=\"".$row["codparinte1"]."\">";
		echo "".$row["codparinte1"]."";
		echo "<INPUT TYPE=\"HIDDEN\" NAME=\"codcopil\" VALUE=\"".$row["codparinte1"]."\">";
		echo "</TD>";		
		echo "<TD width=\"35%\" align=\"left\">";
		echo "<INPUT TYPE=\"TEXT\" size=\"20\" onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\" class=\"text13\" NAME=\"nume_p1\" VALUE=\"".$row["nume1"]."\">";
		echo "</TD>";				
		echo "<TD width=\"35%\" align=\"left\">";
		echo "<INPUT TYPE=\"TEXT\" size=\"20\" onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\" class=\"text13\" NAME=\"pren_p1\" VALUE=\"".$row["pren1"]."\">";
		echo "</TD>";
		echo "<TD width=\"10%\" align=\"center\">";
		echo "<INPUT TYPE=\"TEXT\" size=\"10\" onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\" class=\"text13\" NAME=\"tel1\" VALUE=\"".$row["tel1"]."\"";
		echo "</TD>";
//		echo "<TD width=\"12%\" align=\"center\">";
//		echo "<INPUT TYPE=\"TEXT\" size=\"12\" onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\" class=\"text13\" NAME=\"codparinte2\" VALUE=\"".$row["codparinte2"]."\">";
//		echo "</TD>";		
		echo "<TD width=\"35%\" align=\"left\">";
		echo "<INPUT TYPE=\"TEXT\" size=\"20\" onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\" class=\"text13\" NAME=\"nume_p2\" VALUE=\"".$row["nume2"]."\">";
		echo "</TD>";				
		echo "<TD width=\"35%\" align=\"left\">";
		echo "<INPUT TYPE=\"TEXT\" size=\"20\" onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\" class=\"text13\" NAME=\"pren_p2\" VALUE=\"".$row["pren2"]."\">";
		echo "</TD>";
		echo "<TD width=\"10%\" align=\"center\">";
		echo "<INPUT TYPE=\"TEXT\" size=\"10\" onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\" class=\"text13\" NAME=\"tel2\" VALUE=\"".$row["tel2"]."\">";
		echo "</TD>";
		echo "<TD width=\"30%\" align=\"center\">";
		echo "<INPUT TYPE=\"TEXT\" size=\"30\" onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\" class=\"text13\" NAME=\"adresa_p\" VALUE=\"".$row["adresa"]."\">";
		echo "</TD>";
		echo "</TR>";	
		
		echo "</table>";
		echo "<TABLE cellSpacing=0 align=\"CENTER\" cellPadding=0 width=\"80%; height:15%;\" border=0>";
		include 'A21_param1.php';
		
		echo  "<BR>";
		echo "<tr>";
		echo "<td width=\"1%\" height=\"35\" align=\"left\">";
		echo "<input type=\"submit\" name=\"actiune\" id=\"button10\" onClick=\"return confirm_stergere_p()\" value=\"STERGE\">";	
		echo "</TD>";
	    echo "<td width=\"50%\" 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=\"PARINTE\">";
		echo "<INPUT TYPE=\"HIDDEN\" NAME=\"codparinte1\" VALUE=\"".substr($_POST["actiune"],1,strpos($_POST["actiune"],'>')-1)."\">";
		echo "</td>";
		echo "<td width=\"5%\" align=\"left\">";
		echo "<input name=\"button\" type=\"button\" id=\"button10\" value=\"RENUNT\" onClick=\"javascript:window.close()\">";
		echo "</td>";
		echo "</form>";
		
		echo "<FORM NAME=\"form2\" ACTION=\"A21_utilitare.php\" METHOD=\"POST\" onsubmit=\"target_popup3(this)\">";
		include 'A21_param1.php';
		 echo "<td width=\"10%\" height=\"35\" align=\"right\">";
		 
		IF ($total2 == 0)
		{
			echo "<input type=\"submit\" name=\"actiune\" class=\"noPrint10\" onMouseUp=\"javascript:setTimeout('window.close()',300);\" value=\"CREEAZA CONT\">";
		}
		ELSE
		{
			echo "<input type=\"submit\" name=\"actiune\" class=\"noPrint10\" onMouseUp=\"javascript:setTimeout('window.close()',300);\" value=\"MODIFICA CONT\">";
		}
		echo "<INPUT TYPE=\"HIDDEN\" NAME=\"tip_act\" VALUE=\"PARINTE\">";
		echo "<INPUT TYPE=\"HIDDEN\" NAME=\"codparinte1\" VALUE=\"".substr($_POST["actiune"],1,strpos($_POST["actiune"],'>')-1)."\">";
		echo "</td>";	
		echo "</form>";
		echo  "</tr>";
		echo "</TABLE>";	
			
		mysql_close($connection);
}

if ($_POST["actiune"]=="CREEAZA CONT" and isset($_POST["tip_act"]) and $_POST["tip_act"]=="PARINTE"
	OR $_POST["actiune"]=="MODIFICA CONT" and isset($_POST["tip_act"]) and $_POST["tip_act"]=="PARINTE")
{
	echo "<CENTER>";
	
		echo "<FORM NAME=\"form2\" ACTION=\"A21_utilitare.php\" METHOD=\"POST\" TARGET=\"win01\">";
		include 'A21_param1.php';
		
			$connection=mysql_connect("$host","$username","$password") or die("Nu aveti acces la server");	

			$query="SELECT * FROM users.login_fgr where codparinte=\"".$_POST["codparinte1"]."\"";	
			$result=mysql_query($query) or die("Interogare esuata: ".mysql_error());
			$row = mysql_fetch_array($result);
		
			echo "<INPUT TYPE=\"HIDDEN\" NAME=\"codparinte1\" VALUE=\"".$_POST["codparinte1"]."\">";
		
			echo "<TABLE class=\"style1\" cellSpacing=0 cellPadding=0 width=\"100%\" border=0>";				
			echo "<TR>";
			echo "<TD align=\"center\" class=\"td_print2\">";
			echo "<B>GENERARE CONT</B>";
			echo "<BR>";
			echo "</TD>";
			echo "</TR>";
			echo "</TABLE>";
			
			echo "<TABLE class=\"table1\" cellSpacing=0 cellPadding=0 height=\"100%\" width=\"40%\" border=0>";
			echo "<BR>";
			echo "<TR BGCOLOR=\"white\">";
			
			echo 	"<TH align=\"center\" width=\"20%\" class=\"td35\">Utilizator</TH>";					
			echo	"<TH align=\"center\" width=\"20%\" class=\"td39\">Parola</TH>";
			
			echo "</TR>";
			
		echo "<TR class=\"tr4\" BGCOLOR=\"#FFFFFF\">";		
		echo "<TD width=\"20%\" align=\"left\">";
		echo "<INPUT TYPE=\"TEXT\" size=\"20\" onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\" class=\"text13\" NAME=\"user\" VALUE=\"".$row["user"]."\">";
		echo "</TD>";		
		echo "<TD width=\"20%\" align=\"left\">";
		echo "<INPUT TYPE=\"TEXT\" size=\"20\" onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\" class=\"text13\" NAME=\"pass\" VALUE=\"".$row["pw"]."\">";
		echo "</TD>";				
		echo  "</tr>";
		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\">";
		
		IF (mysql_num_rows($result) == 0 )
		{
			echo "<input type=\"submit\" name=\"actiune\" id=\"button10\" onMouseUp=\"javascript:setTimeout('window.close()',300);\" value=\"CONFIRM\">";
		}
		else
		{
			echo "<input type=\"submit\" name=\"actiune\" id=\"button10\" onMouseUp=\"javascript:setTimeout('window.close()',300);\" value=\"MODIFIC\">";
		}
		echo "<INPUT TYPE=\"HIDDEN\" NAME=\"tip_act\" VALUE=\"CONT\">";
		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,3)=="SCH" OR $_POST["actiune"]=="CONFIRM" and isset($_POST["tip_act"]) and $_POST["tip_act"]=="PAROLA")
{
			echo "<TABLE class=\"table2\" cellSpacing=0 cellPadding=0 width=\"100%; height:100%;\" border=0>";

			echo "<TR><TD>&nbsp</TD></TR>";
			echo "<TR>";
			echo "<TD colspan=\"35\" align=\"center\">";
			echo "<B> SCHIMBARE PAROLA</B>";
			echo "</TD>";
			echo "</TR>";
			echo "<TR><TD>&nbsp</TD></TR>";
			echo "<FORM NAME=\"form1\" ACTION=\"A21_utilitare.php\" METHOD=\"POST\">";
			include 'A21_param1.php';
			echo "</TABLE>";			
			
			$connection=mysql_connect("$host","$username","$password") or die("Nu aveti acces la server");
			$baza='apponlin_users';
			$db=mysql_select_db($baza,$connection) or die("Nu puteti selecta Baza de date ".$baza);

			echo "<INPUT TYPE=\"HIDDEN\" NAME=\"acces\" VALUE=\"1\">"; 	
					
			if ($_POST["actiune"]=="CONFIRM")
			{	
/*
				IF ($_POST["grup"] <> 'admin')
				{
					$query="SELECT * FROM login_fgr WHERE codparinte=\"".$_POST["codparinte"]."\"";
				}
				else
				{
					$query="SELECT * FROM login WHERE unit=\"".$_POST["unit"]."\"";
				}
*/
				$query="SELECT * FROM login WHERE unit=\"".$_POST["unit"]."\" AND aplic=\"".$_POST["aplic"]."\"";
				$result=mysql_query($query) or die("Interogare esuata: ".mysql_error());
				$row=mysql_fetch_array($result);
				
				IF ($_POST["pw_v"]<>$row["pw"] AND !empty($_POST["pw_v"]))
				{		
					$mesaj = 'Parola veche introdusa difera de cea existenta!';
					echo "<script type='text/javascript'>alert('$mesaj');</script>";
				}	
				ELSEIF (empty($_POST["pw_v"]))
				{
					$mesaj = 'Campul "Parola veche" nu este completat!';
					echo "<script type='text/javascript'>alert('$mesaj');</script>";
				}
				ELSEIF ($_POST["pw_v"]==$row["pw"] AND empty($_POST["pw_n"]))
				{
					$mesaj = 'Campul "Parola noua" nu este completat!';
					echo "<script type='text/javascript'>alert('$mesaj');</script>";
				}
				ELSEIF ($_POST["pw_v"]==$row["pw"] AND !empty($_POST["pw_n"]) AND empty($_POST["rpw_n"]))
				{
					$mesaj = 'Campul "Reintroduceti parola noua" nu este completat!';
					echo "<script type='text/javascript'>alert('$mesaj');</script>";
				}
				ELSEIF ($_POST["pw_v"]==$row["pw"] AND !empty($_POST["pw_n"]) AND !empty($_POST["rpw_n"]) AND $_POST["pw_n"] <> $_POST["rpw_n"] )
				{
					$mesaj = 'Parola reintrodusa difera de parola noua!';
					echo "<script type='text/javascript'>alert('$mesaj');</script>";
				}
				ELSE
				{
					echo "<body onload=\"load()\">";
/*					
					IF ($_POST["grup"] <> 'admin')
					{
						$query1="UPDATE login_fgr set pw=\"".$_POST["pw_n"]."\" where codparinte=\"".$_POST["codparinte"]."\"" ;	
					}
					else
					{
						$query1="UPDATE login set pw=\"".$_POST["pw_n"]."\" where unit=\"".$_POST["unit"]."\"" ;
					}
					
*/						$query1="UPDATE login set pw=\"".$_POST["pw_n"]."\" where unit=\"".$_POST["unit"]."\" AND aplic=\"".$_POST["aplic"]."\"" ;
						$result1=mysql_query($query1) or die("Interogare esuata: ".mysql_error());
				}			
			}

				echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"50%\" height=\"10%\">";
				echo "<tr>";
				echo  "<td style = \" width:30%\" class=\"text13\">Parola veche</td>";
				echo  "<td><input type=\"password\" onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\" type=\"text\" style = \" width:10%\; text-align :left;\" NAME=\"pw_v\" VALUE=\"\">";
				echo  "</td>";
				echo  "</td>";
				echo  "</tr>";
				echo  "<tr>";
				echo  "<td style = \"width:30%\" class=\"text13\">Parola noua</td>";
				echo  "<td><input type=\"password\" onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\" type=\"text\" style = \" width:10%\; text-align :left;\" NAME=\"pw_n\" VALUE=\"\">";
				echo  "</td>";
				echo  "</tr>";
				echo  "<tr>";
				echo  "<td style = \"width:30%\" class=\"text13\">Reintroduceti parola noua</td>";
				echo  "<td><input type=\"password\" onfocus=\"onfocus_camp(this)\" onblur=\"onblur_text(this)\" type=\"text\" style = \" width:10%\; text-align :left;\" NAME=\"rpw_n\" VALUE=\"\">";
				echo  "</td>";
				echo  "</tr>";
				echo "<tr>";
				echo "<td colspan=\"5\" height=\"30\" align=\"center\">";
				echo "<input type=\"submit\" name=\"actiune\" id=\"button10\" value=\"CONFIRM\">";
				echo "<input type=\"hidden\" name=\"tip_act\" value=\"PAROLA\">";
				echo "<input type=\"button\" onclick=\"javascript:window.close()\" id=\"button10\" value=\"RENUNT\">";
				echo "</td>";
				echo "</tr>";
				echo  "</table>";

	  echo "</form>";
	  echo "</table>";
	  
	  mysql_close($connection);	
}
	  
if (substr($_POST["actiune"],0,3)=="PRE" OR $_POST["actiune"]=="CONFIRM" and isset($_POST["tip_act"]) and $_POST["tip_act"]=="SOLD")
{
			$wan = $_POST["an"] + 1;
	
			echo "<TABLE class=\"table2\" cellSpacing=0 cellPadding=0 width=\"100%; height:100%;\" border=0>";

			echo "<TR><TD>&nbsp</TD></TR>";
			echo "<TR>";
			echo "<TD colspan=\"35\" align=\"center\">";
			echo "<B>PRELUARE SOLDURI INITIALE PENTRU ANUL SCOLAR:  ".$_POST["an"]." - ".$wan."</B>";
			echo "</TD>";
			echo "</TR>";
			echo "<TR><TD>&nbsp</TD></TR>";
		
			echo "<FORM NAME=\"form1\" ACTION=\"A21_utilitare.php\" METHOD=\"POST\">";
			include 'A21_param1.php';
			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 "<INPUT TYPE=\"HIDDEN\" NAME=\"acces\" VALUE=\"1\">"; 	
					
			if ($_POST["actiune"]=="CONFIRM")
			{									
				echo "<body onload=\"prel()\">";

				//$query="SELECT * FROM gospodarii WHERE codloc=\"".substr($_POST["loc_sel"],0,2)."\"  order by nume,prenume,codgos";
				
				$query="SELECT * FROM copii order by codgrp,nume,prenume";
				$result=mysql_query($query) or die("Interogare esuata: ".mysql_error());	
				
				while($row = mysql_fetch_assoc( $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 ($row["codgrp"] <> 99)
					{	
						$query1="UPDATE copii SET d_val00 = \"".$rest_tot."\", r_val01 = \"".$rest_tot."\", r_val02 = \"".$rest_tot."\", r_val03 = \"".$rest_tot."\", r_val04 = \"".$rest_tot."\", r_val05 = \"".$rest_tot."\", r_val06 = \"".$rest_tot."\", r_val07 = \"".$rest_tot."\", r_val08 = \"".$rest_tot."\", r_val09 = \"".$rest_tot."\", r_val10 = \"".$rest_tot."\", r_val11 = \"".$rest_tot."\", r_val12 = \"".$rest_tot."\" where codcopil=\"".$row["codcopil"]."\" order by nume,prenume";
						$result1=mysql_query($query1) or die("Interogare esuata: ".mysql_error());
						
						$query2="UPDATE copii SET z_val00 = NULL, z_val01 = NULL, z_val02 = NULL, z_val03 = NULL, z_val04 = NULL, z_val05 = NULL, z_val06 = NULL, z_val07 = NULL, z_val08 = NULL, z_val09 = NULL, z_val10 = NULL, z_val11 = NULL, z_val12 = NULL, d_val01 = NULL, d_val02 = NULL, d_val03 = NULL, d_val04 = NULL, d_val05 = NULL, d_val06 = NULL, d_val07 = NULL, d_val08 = NULL, d_val09 = NULL, d_val10 = NULL, d_val11 = NULL, d_val12 = NULL, p_val01 = NULL, p_val02 = NULL, p_val03 = NULL, p_val04 = NULL, p_val05 = NULL, p_val06 = NULL, p_val07 = NULL, p_val08 = NULL, p_val09 = NULL, p_val10 = NULL, p_val11 = NULL, p_val12 = NULL where codcopil=\"".$row["codcopil"]."\" order by nume,prenume";
						$result2=mysql_query($query2) or die("Interogare esuata: ".mysql_error());
					}
					ELSE
					{
						$query2="UPDATE copii SET z_val00 = NULL, z_val01 = NULL, z_val02 = NULL, z_val03 = NULL, z_val04 = NULL, z_val05 = NULL, z_val06 = NULL, z_val07 = NULL, z_val08 = NULL, z_val09 = NULL, z_val10 = NULL, z_val11 = NULL, z_val12 = NULL, d_val00 = NULL, d_val01 = NULL, d_val02 = NULL, d_val03 = NULL, d_val04 = NULL, d_val05 = NULL, d_val06 = NULL, d_val07 = NULL, d_val08 = NULL, d_val09 = NULL, d_val10 = NULL, d_val11 = NULL, d_val12 = NULL, p_val01 = NULL, p_val02 = NULL, p_val03 = NULL, p_val04 = NULL, p_val05 = NULL, p_val06 = NULL, p_val07 = NULL, p_val08 = NULL, p_val09 = NULL, p_val10 = NULL, p_val11 = NULL, p_val12 = NULL, r_val01 = NULL, r_val02 = NULL, r_val03 = NULL, r_val04 = NULL, r_val05 = NULL, r_val06 = NULL, r_val07 = NULL, r_val08 = NULL, r_val09 = NULL, r_val10 = NULL, r_val11 = NULL, r_val12 = NULL where codcopil=\"".$row["codcopil"]."\" order by nume,prenume";
						$result2=mysql_query($query2) or die("Interogare esuata: ".mysql_error());
					}
				}	
			}

				echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"50%\" height=\"10%\">";
				echo "<tr>";
				echo "<td colspan=\"5\" height=\"30\" align=\"center\">";
				echo "<input type=\"submit\" name=\"actiune\" id=\"button10\" onClick=\"return confirm_preluare()\" value=\"CONFIRM\">";
				echo "<input type=\"hidden\" name=\"tip_act\" value=\"SOLD\">";
				echo "<input type=\"button\" onclick=\"javascript:window.close()\" id=\"button10\" value=\"RENUNT\">";
				echo "</td>";
				echo "</tr>";
				echo  "</table>";
				
	  echo "</table>";  
	  echo "</form>";
	  
	  mysql_close($connection);	  				
}	

if ($_POST["actiune"]==="STABILIRE ZILE LIBERE")
{
	$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_copii.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>STABILIRE ZILE LIBERE</B>";
	echo "<BR>";
	echo "</TD>";
	echo "</TR>";
	echo "</TABLE>";
	echo "<TABLE class=\"style1\" cellSpacing=0 cellPadding=0 width=\"50%\" border=0>";
	echo "<TR>";
	echo "<TD align=\"center\" class=\"td_print2\">";
	echo "<BR>";
	echo "</TD>";
	echo "</TR>";
	echo "</TABLE>";

	echo "</FORM>";
	
	echo "<FORM NAME=\"form\" ACTION=\"A21_copii.php\" METHOD=\"POST\">";
	include 'A21_param1.php';
	echo "<TABLE class=\"style1\" cellSpacing=0 cellPadding=0 width=\"100%\" border=0>";
	echo "<TR>";	
	echo "<TD align=\"right\" height=\"35\">";
	echo "<input name=\"button\" type=\"button\" class=\"noPrint\"  value=\"INAPOI\" onClick=\"javascript:window.close()\">";
	echo "</TD>";
	echo "</TR>";
	echo "</TABLE>";
	echo "</FORM>";
	
	echo "<TABLE class=\"style1\" cellSpacing=0 cellPadding=0 width=\"100%\" border=0>";
	echo "<TR>";		
	echo $out;
	echo "</TR>";
	echo "</TABLE>";

	mysql_close($connection);		
}	
			
?>
</CENTER>
</BODY>
</HTML>