<?php include 'header2.php'; ?>

<?php
	
if(isset($_GET['id'])) {
  $id=$_GET['id'];
}


if ($_SERVER['REQUEST_METHOD'] === 'POST') {
	if($_POST['promijeni_status'] ) {
	
		$mejl = $_POST['mejl'];
		$id = $_POST['id'];
	
    	$sqlIzmijeni = "UPDATE korisnici SET mejl  = ".$mejl ." WHERE id=".$id;	
	
		if ($conn->query($sqlIzmijeni) === TRUE) {

			echo '<script> location.replace("' . $url_pocetna . '/app/' . $strana_pregleda.'.php"); </script>';
    		 
		} else {
    		echo "Greska: " . $conn->error;
		}
	}
}
	

	
	
		
	$sql = "SELECT * FROM korisnici where id=".$id."";
	$result = $conn->query($sql);
	$row = $result->fetch_assoc();
		
	$jezik = $row["jezik"];
	$pocetak = $row["pocetak"];
	$kraj = $row["kraj"];
	$trajanje = $row["trajanje"];
	$klasa = $row["klasa"];
	$placanje = $row["placanje"];
	$povratak = $row["povratak"];
	
	include 'language.php';	
	include 'obrada_podataka.php';
	
	
			echo '
	 			 
					<div class="labelInfo">Booking number:</div>
					<div class="valueInfo"># '.$row["id"].'</div> 
					
					<div class="labelInfo">Pickup location:</div>
					<div class="valueInfo">'.$row["pocetak"].'</div>

					<div class="labelInfo">Destination location:</div>
					<div class="valueInfo">'.($row["kraj"] != '' ? $row["kraj"] : ' - ').'</div>

					<div class="labelInfo">Date and time:</div>
					<div class="valueInfo">'.$row["vrijemepolazak"].'</div>

					<div class="labelInfo">Transfer type:</div>
					<div class="valueInfo">'.$povratak_display.'</div>

					<div class="labelInfo">Return date and time:</div>
					<div class="valueInfo">'.($row["vrijemepovratak"] != '' ? $row["vrijemepovratak"] : ' - ').'</div>

					<div class="labelInfo">Number of hours:</div>
					<div class="valueInfo">'.($row["sati"] != '' ? $row["sati"].' h' : ' - ').'</div>

					<div class="labelInfo">Preis:</div>
					<div class="valueInfo">'.$row["cijena"].' CHF</div>
		
					<div class="labelInfo">Entfernung:</div>
					<div class="valueInfo">'.($row["distanca"] != 0 ? $row["distanca"].' km' : ' - ').' </div>

					<div class="labelInfo">Ca. Dauer:</div>
					<div class="valueInfo">'.($row["distanca"] != 0 ? $trajanje_display : ' - ').'</div>
 
					<div class="labelInfo">Fahrzeugklasse:</div>
					<div class="valueInfo">'.$klasa_display.'</div>
 
					<div class="labelInfo">Anzahl der Passagiere:</div>
					<div class="valueInfo">'.$row["putnici"].'</div>

					<div class="labelInfo">Gepäck:</div>
					<div class="valueInfo">'.$row["prtljag"].'</div>
 
					 
					
					 
					<div class="labelInfo">Name and Surname /Country:</div>
					<div class="valueInfo">'.$row["ime"].' '.$row["prezime"].'</div>
 
					<div class="labelInfo">Institution:</div>
					<div class="valueInfo">'.$row["firma"].'</div>
					 
					<div class="labelInfo">E-mail:</div>
					<div class="valueInfo">'.$row["email"].'</div>
					 
					<div class="labelInfo">Telephone:</div>
					<div class="valueInfo">'.$row["telefon"].'</div>
					
					<div class="labelInfo">Booking details:</div>
					<div class="valueInfo">'.($row["buking"] != '' ? $row["buking"] : ' - ').'</div>
					 
					<div class="labelInfo">Flight Number:</div>
					<div class="valueInfo">'.($row["let"] != '' ? $row["let"] : ' - ').'</div>
					 
					<div class="labelInfo">Nameboard:</div>
					<div class="valueInfo">'.($row["letboard"] != '' ? $row["letboard"] : ' - ').'</div>
					 
					
					<div class="labelInfo">Payment method:</div>
					<div class="valueInfo">'.$placanje_display.'</div>
 
					<div class="labelInfo">Reservations status:</div>
					<div class="span100 info_status">
						<form method="POST" action="'.htmlspecialchars($_SERVER["PHP_SELF"]).'">
							
							<input type="text" name="id"  value="'.$id.'" readonly="readonly" style="display:none;"  />
							
							<div class="span50 prikaz_lijevo">
								<select name="mejl"  readonly="readonly" >
									<option value="2" '.(($row["mejl"]==2)?'selected="selected"':"").'>Cancelled</option>
									<option value="1" '.(($row["mejl"]==1)?'selected="selected"':"").'>Confirmed</option>
									<option value="0" '.(($row["mejl"]==0)?'selected="selected"':"").'>Unconfirmed</option>
								</select>	
							</div>
							<div class="span50 prikaz_desno">
								<input name="promijeni_status" class="dugme" type="submit" value="CHANGE STATUS" />
							</div>
						</form>
					</div>
					';
					
					
				 
			


?>
</div>


<script>
//document.getElementById("povratak").addEventListener("load", prikaz);

function prikaz(p) {
	document.getElementById("demo").innerHTML=p;
	if(p=="roundtrip"){
		document.getElementById("vrijemepovratka").readOnly = false;
	}else{
		document.getElementById("vrijemepovratka").readOnly = true;
	}
	
}


</script>

<?php
 include 'footer.php';

?>