<?php
// start submeniu orizontal
if($_GET['job'] == 'traseu'){
	$sql_traseu = mysql_query("SELECT * FROM `traseu` order by denumire desc") or die(mysql_error());
		while($traseu = mysql_fetch_row($sql_traseu)){
echo '<a href="index.php?job=traseu&task='.$traseu['0'].'"><p id="butonmeniu">'.$traseu['3'].'</p></a>';
	}
}
// end submeniu orizontal
//===========================
// start administraza traseu
if($_GET['job'] == 'traseu' and $_GET['task'] != ''){
$sql_traseu = mysql_query("SELECT * FROM `traseu` where id = '".$_GET['task']."'") or die(mysql_error());
		while($traseu = mysql_fetch_row($sql_traseu)){
	echo'<TABLE style="width: 100%; text-align: center;">
	
		<TR>
			<TD align="center" colspan="6">
				<p id="bold">'.$traseu['3'].'</p>
			</TD>
		</TR>
		<TR> 
			<TD height="20px" align="center" colspan="5"></TD>
		</TR>
		<TR>
			<TD id="cell">Nr<br />Cursa</TD>
			<TD id="cell">Ora plecare</TD>
			<TD id="cell">Ora sosire</TD>
			<TD id="cell">Masina</TD>
			<TD id="cell">Sofer</TD>
			<TD id="cell">Rovinieta</TD>
			<TD id="cell">Status cursa</TD>
		</TR>';
		for ($nr_ord=01; $nr_ord<=15; $nr_ord++) {	
echo'<form action="" method="post" >	';
	echo'<TR>
			<TD align="center">'.$nr_ord.'.</TD>
			<TD align="center">  
				<select id="selectora" name="oraplecare'.$nr_ord.'" onchange="this.form.submit()">';

					for ($ora1p=00; $ora1p<=23; $ora1p++) {
if($_POST['oraplecare'.$nr_ord.''] == $ora1p){$sel_orap = 'selected';}else{$sel_orap = '';}						
						echo'<option value="'.$ora1p.'" '.$sel_orap.'>'.$ora1p.'</option>';
					}
			echo'</select>
				<select id="selectora" name="minutplecare'.$nr_ord.'" onchange="this.form.submit()">';
					for ($min1p=00; $min1p<=59; $min1p++) {
if($_POST['minutplecare'.$nr_ord.''] == $min1p){$sel_minp = 'selected';}else{$sel_minp = '';}	
						echo'<option value="'.$min1p.'" '.$sel_minp.'>'.$min1p.'</option>';
					}
			echo'</select> 
			</TD>
			<TD align="center">
			<select id="selectora" name="orasosire'.$nr_ord.'" onchange="this.form.submit()">';
					for ($ora1s=00; $ora1s<=23; $ora1s++) {
if($_POST['orasosire'.$nr_ord.''] == $ora1s){$sel_oras = 'selected';}else{$sel_oras = '';}	
						echo'<option value="'.$ora1s.'" '.$sel_oras.'>'.$ora1s.'</option>';
					}
			echo'</select>
				<select id="selectora" name="minutsosire'.$nr_ord.'" onchange="this.form.submit()">';
					for ($min1s=00; $min1s<=59; $min1s++) {
if($_POST['minutsosire'.$nr_ord.''] == $min1s){$sel_mins = 'selected';}else{$sel_mins = '00';}
						echo'<option value="'.$min1s.'" '.$sel_mins.'>'.$min1s.'</option>';
					}
			echo'</select>
			</TD>
			<TD align="center">
				<select id="nrmasina" name="nr_masina'.$nr_ord.'" onchange="this.form.submit()">';
$sql_masina = mysql_query("SELECT * FROM `masina` order by denumire asc") or die(mysql_error());
	if($_POST['nr_masina'.$nr_ord.''] == ''){$sel_nr = 'selected';}else{$sel_nr = '';}
			echo'<option value="" '.$sel_nr.'>Alege masina</option>';
		while($masina = mysql_fetch_row($sql_masina)){
	if($_POST['nr_masina'.$nr_ord.''] == $masina['3']){$sel_nr = 'selected';}else{$sel_nr = '';}

						echo'<option value="'.$masina['3'].'" '.$sel_nr.'>'.$masina['3'].'</option>';
					}
			echo'</select>
			</TD>
			<TD align="center">
				<select id="nrmasina" name="denumire_sofer">';
$sql_sofer = mysql_query("SELECT * FROM `sofer` order by denumire asc") or die(mysql_error());
		while($sofer = mysql_fetch_row($sql_sofer)){
						echo'<option value="'.$sofer['3'].'" selected>'.$sofer['3'].'</option>';
					}
			echo'</select>
			</TD>
			<TD align="center">';
$sql_rovinieta = mysql_query("SELECT * FROM `rovinieta` where masina = '".$_POST['nr_masina'.$nr_ord.'']."' order by id desc limit 1 ") or die(mysql_error());
//$rov_nr = mysql_num_rows($sql_rovinieta);
	while($rovinieta = mysql_fetch_row($sql_rovinieta)){

if($rovinieta['4'] >= $dmy){
		$icon = '<a href="index.php?job=add&task=rovinieta" title="FARA rovinieta" alt="FARA rovinieta"><img width="30px" src="img/nu.png"></a>';
		echo "<script>alert('Pentru aceasta masina trebuie achitionata rovinieta.')</script>";
		echo "<script>location.replace('index.php?job=add&task=rovinieta&nr_masina=".$_POST['nr_masina'.$nr_ord.'']."')</script>";	
	}else{
		$icon = '<a href="index.php?job=add&task=rovinieta" title="CU rovinieta" alt="CU rovinieta"><img width="30px" src="img/da.png"></a>';
		}
// echo $rovinieta['3'].'<br />';
// echo $rovinieta['4'].'<br />';  
// echo $dmy;	
	}

	echo $icon;
	
		echo'</TD>
			<TD align="center">
				<select id="nrmasina" name="status_cursa">
					<option value="DA - se face" selected>DA - se face</option>
					<option value="NU - se face" >NU - se face</option>
				</select>
			</TD>
		</TR>';
		}
	echo'<TR>   
			<TD height="20px" align="center" colspan="5"></TD>
		</TR>
		<TR>
			<TD align="center" colspan="7">
				<input id="butonsubmit" type=submit name="modifica_traseu" value="Salveaza">
			</TD>
		</TR>
	</form>
</TABLE>';
	}
}
// end administraza traseu
//===========================
?>