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

<!DOCTYPE html>
<meta charset="utf-8">
<html lang="en">
<HEAD>
<TITLE>Observatii / Intrebari</TITLE>

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

var w12;
function target_popup12(form) {
		w12=window.open('', 'win12','width=1200,height=400,top=200,left=30,resizeable,scrollbars');
		form.target = 'win12';
}

var w13;
function target_popup13(form) {
		w13=window.open('', 'win13','width=800,height=600,top=200,left=400,resizeable,scrollbars');
		form.target = 'win13';
}
</script>
</HEAD>
<BODY>
<CENTER>
		
<?php
ob_start();
include 'javascripts.php';
include 'conectare.php';

if ($_POST["actiune"]=="ADAUGARE")		
{
			$connection=mysql_connect("$host","$username","$password") or die("Nu aveti acces la server");
			$baza="apponlin_".$_POST["aplic"]."_".substr($_POST["unitate"],0,3)."_999";
			$db=mysql_select_db($baza,$connection) or die("Nu puteti selecta Baza de date ".$baza);	
			
			echo "<FORM NAME=\"form1\" ACTION=\"A11_instruct_adaug.php\" METHOD=\"POST\">";
			include 'A11_param1.php';
	
			echo "<TR>";
			echo "<TD width=\"100%\" align=\"center\">";
			echo "<B>OBSERVATII SI INTREBARI</B>";
			echo "<BR>";
			echo "</TD>";
			echo "</TR>";
	
			echo "</TABLE>";
			
		date_default_timezone_set("Europe/Bucharest");
		$data_ora = date("Y-m-d H:i:s", time()); 
		
		if (!strlen(trim($_POST['obs_int'])))
		{
		//	echo '<script type="text/javascript">';
		//	echo 'alert("Nu ati introdus nicio noua observatie / intrebare. Adaugare esuata!");';
		//	echo '</script>';
		}
		else
		{
			$query1="INSERT INTO obs_intreb (data_ora,unit,nume1,obs_int)";
			$query1=$query1."VALUES (\"".$data_ora."\",\"".$_POST["unitate"]."\",\"".$_POST["nume1"]."\",\"".$_POST["obs_int"]."\")";
			$result1=mysql_query($query1) or die("Interogare esuata: ".mysql_error());
		}
			echo "</table>";
			
			echo "<BR><BR>";
			echo "<TABLE  cellSpacing=0 cellPadding=0 width=\"100%\" border=0>";
			echo "<TR BGCOLOR=\"white\">";
			echo "<TH align=\"center\" width=\"100%\" class=\"td14\">Observatii / Intrebari anterioare</TH>";		
			echo "</TR>";
		
			$query="SELECT * FROM obs_intreb WHERE unit=\"".$_POST["unitate"]."\" order by data_ora ASC";
			$result=mysql_query($query) or die("Interogare esuata: ".mysql_error());	
		
			$i=0;
			while($row = mysql_fetch_array($result)) 
			{ 
				echo "<TR>";
				echo "<TD align=\"left\">";
				echo "".$row["obs_int"]."";
				echo "</TD>";
				echo "</TR>";
				$i++;			
			}
			
			echo "</table>";
			
			echo "<BR><BR>";
			
				echo "<TABLE  cellSpacing=0 cellPadding=0 width=\"100%\"align=\"center\" border=0>";
				echo "<TR BGCOLOR=\"white\">";
				echo "<TH align=\"center\" width=\"100%\" class=\"td14\">Introduceti observatii / intrebari</TH>";	
				echo "</TR>";
				echo "<TR BGCOLOR=\"white\">";
				echo"<TD width=\"100%\" align=\"left\">";
				echo "<textarea name=\"obs_int\" rows = \"10\" cols = \"93\" id=\"obs_int\" autofocus=\"autofocus\" wrap=\"hard\" align=\"left\"></textarea>";
				//echo "<input type=\"submit\" value=\"\" name=\"actiune\">";
				echo "</TD>";
				echo "</TR>";
				echo "</TABLE>";
	
				echo "<TABLE cellSpacing=0 cellPadding=0 width=\"90%; height:100%;\" border=0>";
				echo "<TD colspan=\"7\" align=\"right\" height=\"35\">";
				echo "<INPUT TYPE=\"SUBMIT\" id=\"button10\" NAME=\"actiune\" VALUE=\"ADAUGARE\">";		
				echo "<input type=\"button\" onclick=\"javascript:window.close()\" id=\"button10\" value=\"RENUNT\">";
				echo "</TR>";
				echo "</TABLE>";	
			
		mysql_close($connection);	
			
}
	
?>
</FORM>
</body>
</html>	