<?php


ini_set('session.gc_maxlifetime', 30*60);

session_start();

include '../../../includes/config.php';





$Trip_ID = $_GET['Trip_ID'];
	$Max_Limit_Riders = $_GET['Max_Limit_Riders'];	
	$Gender = $_GET['Gender'];
	$Total_KM_Distance = $_GET['Total_KM_Distance'];	

	$Date = $_GET['Date'];
	$D_ID = $_GET['D_ID'];	


	$lng1 = $_GET['lng1'];	
	$lat1 = $_GET['lat1'];	
	$lng2 = $_GET['lng2'];	
	$lat2 = $_GET['lat2'];	
	$From_Location = $_GET['From_Location'];	
	$To_Location = $_GET['To_Location'];
	
	
	$sql11 = mysqli_query($dbConn,"select * from trips where ID='$Trip_ID'");
	$row11 = mysqli_fetch_array($sql11);
	$From_Time = $row11['From_Time'];
	
	
	



$sql1 = mysqli_query($dbConn,"select * from trips_users where Status!='Dropoff' AND Trip_ID='$Trip_ID'");
if (mysqli_num_rows($sql1)>0){
	
	
	echo "<script language='JavaScript'>
			  alert ('Sorry ... you cant finish your trip ... you still have riders requests !');
      </script>";
	
	

	echo '<script language="JavaScript">
 document.location="shared-same-gender-4.php?Trip_ID='.$Trip_ID.'&Max_Limit_Riders='.$Max_Limit_Riders.'&Gender='.$Gender.'&Total_KM_Distance='.$Total_KM_Distance.'&Date='.$Date.'&D_ID='.$D_ID.'&lng1='.$lng1.'&lat1='.$lat1.'&lng2='.$lng2.'&lat2='.$lat2.'&From_Location='.$From_Location.'&To_Location='.$To_Location.'";
</script>';

	
	
}else{
	
	
	
	$To_Time = date("H:i");
	
	
	$start = strtotime($From_Time);
	$end = strtotime($To_Time);
	$mins = ($end - $start) / 60;




	
	$Estimation_Time = $mins;
	
	
	
$sql3 = mysqli_query($dbConn,"update trips set To_Time='$To_Time', Estimation_Time='$Estimation_Time', Status='Finished' WHERE ID='$Trip_ID'");
	
	
	

	echo '<script language="JavaScript">
 document.location="../index.php";
</script>';

	
	
	
}


?>
