<?php
// start submeniu orizontal
if($_GET['job'] == 'add'){
echo '<a href="index.php?job=add&task=traseu"><p id="butonmeniu">Traseu</p></a>';
echo '<a href="index.php?job=add&task=masina"><p id="butonmeniu">Masina</p></a>';
echo '<a href="index.php?job=add&task=sofer"><p id="butonmeniu">Sofer</p></a>';
echo '<a href="index.php?job=add&task=rovinieta"><p id="butonmeniu">Rovinieta</p></a>';
}
// end submeniu orizontal
//===========================
// start add traseu in db
if($_POST['salveaza_traseu']){
$denumire = htmlentities($_POST['denumire']);
	$add_traseu = mysql_query ("INSERT INTO `traseu`(`id`, `data`, `user`, `denumire`) VALUES ('', '".$data."', '".$_SESSION['user']."', '".strtoupper($denumire)."');") or die(mysql_error());	
	
	echo "<script>alert('Noul TRASEU a fost adaugat cu SUCCES')</script>";
}
// end add traseu in db
//===========================
// start add masina in db
if($_POST['salveaza_masina']){
$denumire = htmlentities($_POST['denumire']);
	$add_masina = mysql_query ("INSERT INTO `masina`(`id`, `data`, `user`, `denumire`) VALUES ('', '".$data."', '".$_SESSION['user']."', '".strtoupper($denumire)."');") or die(mysql_error());	
	
		echo "<script>alert('Noua MASINA a fost adaugata cu SUCCES')</script>";
}
// end add masina in db
//===========================
// start add sofer in db
if($_POST['salveaza_sofer']){
$denumire = htmlentities($_POST['denumire']);
	$add_sofer = mysql_query ("INSERT INTO `sofer`(`id`, `data`, `user`, `denumire`) VALUES ('', '".$data."', '".$_SESSION['user']."', '".strtoupper($denumire)."');") or die(mysql_error());	
	
		echo "<script>alert('Noul SOFER a fost adaugat cu SUCCES')</script>";
}
// end add sofer in db
//===========================
// start add rovinieta in db
if($_POST['salveaza_rovinieta']){
	
$data_start = $_POST['rov_an_start'].''.$_POST['rov_luna_start'].''.$_POST['rov_zi_start'];
$data_end = $_POST['rov_an_end'].''.$_POST['rov_luna_end'].''.$_POST['rov_zi_end'];
$masina = $_POST['nr_masina'];

	$add_rovinieta = mysql_query ("INSERT INTO `rovinieta`(`id`, `data`, `user`, `data_start`, `data_end`, `masina`) VALUES ('', '".$data."', '".$_SESSION['user']."', '".$data_start."', '".$data_end."', '".$masina."');") or die(mysql_error());	
	
		echo "<script>alert('Noua rovinieta a fost adaugata cu SUCCES')</script>";
}
// end add rovinieta in db
//===========================
// start form add traseu
if($_GET['job'] == 'add' and $_GET['task'] == 'traseu'){ 

echo'<TABLE width="100%" align="center">
	<form action="" method="post">
		<TR>
			<TD align="left">Denumire traseu: <br /><br />
				<input id="input" type="text" name="denumire" value="">
				<input id="butonsubmit" type=submit name="salveaza_traseu" value="Salveaza">
			</TD>
		</TR>
	</form>
</TABLE>';
}
// end form add traseu
//===========================
// start form add masina
if($_GET['job'] == 'add' and $_GET['task'] == 'masina'){ 

echo'<TABLE width="100%" align="center">
	<form action="" method="post">
		<TR>
			<TD align="left">Numar masina: <br /><br />
				<input id="input" type="text" name="denumire" value="">
				<input id="butonsubmit" type=submit name="salveaza_masina" value="Salveaza">
			</TD>
		</TR>
	</form>
</TABLE>';
}
// end form add masina
//===========================
// start form add sofer
if($_GET['job'] == 'add' and $_GET['task'] == 'sofer'){ 

echo'<TABLE width="100%" align="center">
	<form action="" method="post">
		<TR>
			<TD align="left">Nume/Prenume sofer: <br /><br />
				<input id="input" type="text" name="denumire" value="">
				<input id="butonsubmit" type=submit name="salveaza_sofer" value="Salveaza">
			</TD>
		</TR>
	</form>
</TABLE>';
}
// end form add sofer
//===========================
// start form add rovinieta
if($_GET['job'] == 'add' and $_GET['task'] == 'rovinieta'){ 

echo'<TABLE width="100%" align="center">
	<form action="" method="post">
		<TR>
			<TD align="center" colspan="4">';
if($_GET['nr_masina'] == ''){			
		echo'<p id="bold">Adauga rovinieta </p>';
	}else{
		echo'Adauga rovinieta pentru masina: <p id="bold">'.$_GET['nr_masina'].'</p>';		
			}
		echo'</TD>
		<TD align="center">
				<!-- roviniete.ro start code --><a href="https://goo.gl/4L5YuC" title="Roviniete.ro" target="_blank"><img src="https://www.roviniete.ro/images/webmaster-resource/banner_125_125.jpg" style="width: 80px; border:0;" alt="Roviniete.ro" /></a><!-- roviniete.ro end code -->  
			</TD>
		</TR>
		<TR> 
			<TD height="20px" align="center" colspan="5"></TD>
		</TR>
		<TR>
			<TD id="cell">De la data</TD>
			<TD id="cell">Pana la data</TD>
			<TD id="cell">Masina</TD>
			<TD id="cell" colspan="2"></TD>
		</TR>
		<TR>
			<TD align="center">
				<select id="selectora" name="rov_zi_start">';
					for ($zi=01; $zi<=31; $zi++) {
if($zi == date("d")){$selected1 = 'selected';}else{$selected1 = '';}
						echo'<option value="'.$zi.'" '.$selected1.'>'.$zi.'</option>';
					}
			echo'</select>
				<select id="selectora" name="rov_luna_start">
					<option value="'.($luna-1).'" >'.($luna-1).'</option>
					<option value="'.$luna.'" selected>'.$luna.'</option>
					<option value="'.($luna+1).'" >'.($luna+1).'</option>
				</select>
				<select id="selectan" name="rov_an_start">
					<option value="'.$an.'" selected>'.$an.'</option>
					<option value="'.($an+1).'" >'.($an+1).'</option>
				</select>
			</TD>
			<TD align="center">
				<select id="selectora" name="rov_zi_end">';
					for ($zi=01; $zi<=31; $zi++) {
if($zi == date("d")){$selected2 = 'selected';}else{$selected2 = '';}
						echo'<option value="'.$zi.'" '.$selected2.'>'.$zi.'</option>';
					}
			echo'</select>
				<select id="selectora" name="rov_luna_end">';
					for ($luna1=01; $luna1<=12; $luna1++) {
if($luna1 == date("m")){$selected3 = 'selected';}else{$selected3 = '';}
						echo'<option value="'.$luna1.'" '.$selected3.'>'.$luna1.'</option>';
					}
			echo'</select>
				<select id="selectan" name="rov_an_end">
					<option value="'.$an.'" selected>'.$an.'</option>
					<option value="'.($an+1).'" >'.($an+1).'</option>
					<option value="'.($an+2).'" >'.($an+2).'</option>
				</select>
			</TD>
			<TD align="center">
				<select id="nrmasina" name="nr_masina">';
$sql_masina = mysql_query("SELECT * FROM `masina` order by denumire asc") or die(mysql_error());
		while($masina = mysql_fetch_row($sql_masina)){
			if($_GET['nr_masina'] == $masina['3']){$selected_nrmasina = 'selected';}else{$selected_nrmasina = '';}
						echo'<option value="'.$masina['3'].'" '.$selected_nrmasina.'>'.$masina['3'].'</option>';
					}
			echo'</select>
				
			</TD>
			<TD height="20px" align="center" colspan="5">
				<input id="butonsubmit" type=submit name="salveaza_rovinieta" value="Salveaza">
			</TD>
		</TR>';
		echo'<TR>
			<TD height="40px" align="center" colspan="6">
				Istoric roviniete pentru masina '.$_GET['nr_masina'].'
			</TD>
		</TR>';
$sql_rovi = mysql_query("SELECT * FROM `rovinieta` where masina = '".$_GET['nr_masina']."' order by id desc") or die(mysql_error());
		while($rovi = mysql_fetch_row($sql_rovi)){
	echo'<TR>
			<TD id="cell">'.$rovi['3'].'</TD>
			<TD id="cell">'.$rovi['4'].'</TD>
		</TR>';
		}
echo'</form>
</TABLE>';
}
// end form add rovinieta  
//===========================
?>