<?php include("includes/email.php"); ?>

<?php include("includes/templates/header.tpl.php"); ?>


<?php

if ($_POST['submit']){
/*
echo "<pre>";								
print_r($_POST);
echo "</pre>";
*/



	$organizatie = htmlspecialchars(trim($_POST['organizatie']));
	$domeniuActivitate = htmlspecialchars(trim($_POST['domeniuActivitate']));
	$adresa = htmlspecialchars(trim($_POST['adresa']));
	$oras = htmlspecialchars(trim($_POST['oras']));
	$judet = htmlspecialchars(trim($_POST['judet']));
	$codPostal = htmlspecialchars(trim($_POST['codPostal']));
	$telefonFax = htmlspecialchars(trim($_POST['telefonFax']));
	$email = htmlspecialchars(trim($_POST['email']));
	$nrInregRegCom = htmlspecialchars(trim($_POST['nrInregRegCom']));
	$codUnicIdent = htmlspecialchars(trim($_POST['codUnicIdent']));
	$banca = htmlspecialchars(trim($_POST['banca']));
	$cont = htmlspecialchars(trim($_POST['cont']));
	$reprezentant1 = htmlspecialchars(trim($_POST['reprezentant1']));
	$functieReprezentant1 = htmlspecialchars(trim($_POST['functieReprezentant1']));
	$telefonReprezentant1 = htmlspecialchars(trim($_POST['telefonReprezentant1']));
	$emailReprezentant1 = htmlspecialchars(trim($_POST['emailReprezentant1']));
	$reprezentant2 = htmlspecialchars(trim($_POST['reprezentant2']));
	$functieReprezentant2 = htmlspecialchars(trim($_POST['functieReprezentant2']));
	$telefonReprezentant2 = htmlspecialchars(trim($_POST['telefonReprezentant2']));
	$emailReprezentant2 = htmlspecialchars(trim($_POST['emailReprezentant2']));
	$reprezentant3 = htmlspecialchars(trim($_POST['reprezentant3']));
	$functieReprezentant3 = htmlspecialchars(trim($_POST['functieReprezentant3']));
	$telefonReprezentant3 = htmlspecialchars(trim($_POST['telefonReprezentant3']));
	$emailReprezentant3 = htmlspecialchars(trim($_POST['emailReprezentant3']));
	
		if (	empty($organizatie)  or empty($domeniuActivitate) or 
				empty($adresa) or empty($oras) or 
				empty($judet) or empty($codPostal) or 
				empty($telefonFax) or empty($email) or 
				empty($reprezentant1) or empty($functieReprezentant1) or 
				empty($telefonReprezentant1) or empty($emailReprezentant1)){
					
			include("includes/templates/form_register.tpl.php");
			if (empty($organizatie)){
				$validateMsg = "*** campul <b>Organizatie</b> nu este completat <br>";
			}
			if (empty($domeniuActivitate)){
				$validateMsg .= "*** campul <b>Domeniu de activitate</b> nu este completat <br>";
			}
			if (empty($adresa)){
				$validateMsg .= "*** campul <b>Adresa</b> nu este completat <br>";
			}
			if (empty($oras)){
				$validateMsg .= "*** campul <b>Oras</b> nu este completat <br>";
			}
			if (empty($judet)){
				$validateMsg .= "*** campul <b>Judet</b> nu este completat <br>";
			}
			if (empty($codPostal)){
				$validateMsg .= "*** campul <b>Cod Postal</b> nu este completat <br>";
			}
			if (empty($telefonFax)){
				$validateMsg .= "*** campul <b>Telefon / Fax</b> nu este completat <br>";
			}
			if (empty($email)){
				$validateMsg .= "*** campul <b>Email</b> nu este completat <br>";
			}
			if (empty($reprezentant1)){
				$validateMsg .= "*** campul <b>Reprezentant </b> nu este completat <br>";
			}
			if (empty($functieReprezentant1)){
				$validateMsg .= "*** campul <b>Functie reprezentant </b> nu este completat <br>";
			}
			if (empty($telefonReprezentant1)){
				$validateMsg .= "*** campul <b>Telefon reprezentant </b> nu este completat <br>";
			}
			if (empty($emailReprezentant1)){
				$validateMsg .= "*** campul <b>Email reprezentant </b> nu este completat <br>";
			}

				echo "<tr>
						<td   align='left' colspan='2' class='dateNecompletate'>
							 $validateMsg
						</td>
					</tr>";
					
		}
		else {

		$sql = "INSERT INTO `prorec_workshop`.`workshop` (
					`id` ,
					`organizatie` ,
					`domeniuActivitate` ,
					`adresa` ,
					`oras` ,
					`judet` ,
					`codPostal` ,
					`telefonFax` ,
					`email` ,
					`nrInregRegCom` ,
					`codUnicIdent` ,
					`banca` ,
					`cont` ,
					`reprezentant1` ,
					`functieReprezentant1` ,
					`telefonReprezentant1` ,
					`emailReprezentant1` ,
					`reprezentant2` ,
					`functieReprezentant2` ,
					`telefonReprezentant2` ,
					`emailReprezentant2` ,
					`reprezentant3` ,
					`functieReprezentant3` ,
					`telefonReprezentant3` ,
					`emailReprezentant3`
					)
					VALUES (
						NULL , 
						'$organizatie', 
						'$domeniuActivitate', 
						'$adresa', 
						'$oras', 
						'$judet', 
						'$codPostal', 
						'$telefonFax', 
						'$email', 
						'$nrInregRegCom', 
						'$codUnicIdent', 
						'$banca', 
						'$cont', 
						'$reprezentant1', 
						'$functieReprezentant1', 
						'$telefonReprezentant1', 
						'$emailReprezentant1', 
						'$reprezentant2', 
						'$functieReprezentant2', 
						'$telefonReprezentant2', 
						'$emailReprezentant2', 
						'$reprezentant3', 
						'$functieReprezentant3', 
						'$telefonReprezentant3', 
						'$emailReprezentant3'
					)
";
//echo $sql;
				
	$link = mysql_connect('localhost','prorec_workshop','w0rk');
	if (!$link){
		die("eroare conectare la baza de date");	
	}

	mysql_select_db('prorec_workshop');
	$result = mysql_query($sql);
	if ($result){

		echo "<span class='dateNecompletate'><b>Datele au fost introduse in baza de date!!!! <br> Va Multumim!!</b></span>";
	}    

 	send_email_message($organizatie, $domeniuActivitate, $adresa, $oras, $judet, $codPostal, $telefonFax, $email, $nrInregRegCom, $codUnicIdent, $banca, $cont, $reprezentant1, $functieReprezentant1, $telefonReprezentant1, $emailReprezentant1, $reprezentant2, $functieReprezentant2, $telefonReprezentant2, $emailReprezentant2, $reprezentant3, $functieReprezentant3, $telefonReprezentant3, $emailReprezentant3	); 
 	?>
 	<meta http-equiv="refresh" content="2;url=index.php">
 	<?php
		}  	
				
}
else {

?>


			
	
		<?php include("includes/templates/form_register.tpl.php"); ?>			
		
	
	
<?php } ?>

<?php include("includes/templates/footer.tpl.php"); ?>
<script>