<?php






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

session_start();

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



$D_ID = $_SESSION['D_Log'];




if (!$_SESSION['D_Log'])
echo '<script language="JavaScript">
 document.location="../Drivers-Sign-In.php";
</script>';







$sql3 = mysqli_query($dbConn,"select * from drivers where ID='$D_ID'");
					$row3 = mysqli_fetch_array($sql3);
$Name=$row3['Name'];
$Phone_Number=$row3['Phone_Number'];
$Gender=$row3['Gender'];
$Photo=$row3['Photo'];
$lon=$row3['Longitude'];
$lat=$row3['Latitude'];
$Total_Rates=$row3['Total_Rates'];
$Car_Type=$row3['Car_Type'];
$Car_Color=$row3['Car_Color'];
$Penalty_Balance=$row3['Penalty_Balance'];
$Credit_Balance=$row3['Credit_Balance'];
$Total_Need_Balance=$row3['Total_Need_Balance'];
$Avalability_Status=$row3['Avalability_Status'];




?>

<!doctype html>
<html lang="en">
<head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="../../css/bootstrap.min.css">
    <!-- FontAwesome -->
    <link rel="stylesheet" href="../../css/fontawesome.css">
    <!-- Main Style -->
    <link rel="stylesheet" href="../../css/styles.css">
    <title>My private trips</title>
	
	    <link rel="shortcut icon" href="../../images/icon.ico"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0,user-scalable=0"/>


	<style>
@font-face {
   font-family: myFirstFont;
   src: url(../../fonts/Arial-Rounded-MT-Bold-Regular.ttf);
   font-size:8px;
}

body {
   font-family: myFirstFont !important;
}


@font-face {
   font-family: myFirstFont2;
   src: url(../../fonts/GE-SS-Two-Bold.otf);
   font-size:8px;
}



</style>






</head>
<body >
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script type="text/javascript">
        function getLocation() {
            if (navigator.geolocation) {
                navigator.geolocation.getCurrentPosition(function(position) {
                    var latitude = position.coords.latitude;
                    var longitude = position.coords.longitude;

                    // Send this to your PHP script via AJAX or other means
                    sendDataToServer(latitude, longitude);
                });
            } else {
                alert("Geolocation is not supported by this browser.");
            }
        }

        function sendDataToServer(latitude, longitude) {
            // Using fetch API to send data to PHP
            fetch('update-my-location-1.php?D_ID=<?php echo $D_ID; ?>	', {
                method: 'POST',
                headers: {
                    'Content-Type': 'application/json',
                },
                body: JSON.stringify({
                    latitude: latitude,
                    longitude: longitude
                })
            })
            .then(response => response.json())
            .then(data => {
                console.log('Success:', data);
            })
            .catch((error) => {
                console.error('Error:', error);
            });
        }

        // Keep updating every 5 seconds
        setInterval(getLocation, 5000);
    </script>



<!--Loading Container Start-->
<div id="load" class="loading-overlay display-flex flex-column justify-content-center align-items-center">
    <div class="primary-color font-28 fas fa-spinner fa-spin"></div>
</div>
<!--Loading Container End-->


<div class="row h-100">
    
            
		
 <div class="col-xs-12 col-sm-12 emaining-height"">

         <!--Page Title & Icons Start-->
        <div class="header-icons-container text-center">
           
                <span class="float-left menu-open closed">
                    <img src="../../icons/menu.svg" alt="Menu Hamburger Icon">
            </span>
            <span class="title"><br>My private trips</span>
            <a href="#">
<span class="float-right" style="margin-top:-27px !important">
                    <img src="../../images/icon.png" alt="Logo" width="14px" height="20px">
                </span>
            </a>
        </div>
        <!--Page Title & Icons End-->

       
	   
	   
	   
	   
	   
	   
	   
	   
	   
	   
	   
	   
	   
	   
	   
	   
	   
	   <div class="rest-container">
            <div class="all-history-items remaining-height">

                
				
				
				
				
				
			<?php
$sql2 = mysqli_query($dbConn,"select * from trips_privates where Driver_ID='$D_ID' AND Status='Dropoff' order by Add_Date_Time DESC");
if (mysqli_num_rows($sql2)>0){
	while ($row2 = mysqli_fetch_array($sql2)){
	
	$TP_ID = $row2['ID'];
	$Gender = $row2['Gender'];
	$Date = $row2['Date'];
	$From_Longitude = $row2['From_Longitude'];
	$From_Latitude = $row2['From_Latitude'];
	$To_Longitude = $row2['To_Longitude'];
	$To_Latitude = $row2['To_Latitude'];
	$From_Location = $row2['From_Location'];
	$To_Location = $row2['To_Location'];
	$Total_KM_Distance = $row2['Total_KM_Distance'];
	$Total_Riders = $row2['Total_Riders'];
	$From_Time = $row2['From_Time'];
	$To_Time = $row2['To_Time'];
	$Total_Price = $row2['Total_Price'];


	
	
?>	
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				
				<!--History Item Container Start-->
                <div class="history-items-container history-items-padding ">
                    <div class="history-item">
			
                        <!--Google Map Start-->
                        <!--<div id="map<?php echo $TP_ID; ?>"></div>-->
                        <!--Google Map End-->

                        <!--Date and Price Container Start-->
                        <div class="border-bottom-primary thin">
                            <div class="status-container">
                                <div class="date float-left" style="color:#011F39">
                                    <?php echo $Date; ?>  | <?php echo $Total_Price; ?> JOD	
                                </div>
                                <div class="status float-right text-uppercase" style="color:#B3E207">
                                    <?php echo $Gender; ?> 
                                </div>
                                <div class="clearfix"></div>
                            </div>
                        </div>
                        <!--Date and Price Container End-->

                        <!--Address Container Start-->
                        <div class="addresses-container position-relative">
                            <div class="height-auto">
                                <div class="w-100 map-input-container map-input-container-top" style="border-color:#00000000 ">
                                    <span class="fas fa-location-arrow location-icon-rotate  map-input-icon" style="background-color:#00000000 "></span>
                                    <div class="map-input display-flex">
                                        <input class="controls flex-1 font-weight-light" type="text"
                                               placeholder="Enter an origin location" value="<?php echo $From_Location; ?>" disabled>
											   
                                    </div>
                                </div>
                                <div class="w-100 map-input-container map-input-container-bottom">
                                        <span class="map-input-icon"><img src="../../icons/circle.svg"  alt="Current Location Icon"></span>
                                        <div class="map-input display-flex controls flex-1 align-items-center">
                                            <?php echo $To_Location; ?>
                                        </div>
                                        <span class="dotted-line"></span>
                                    </div>
                            </div>
                        </div>
                        <!--Address Container End-->
<br>
                        <!--Support Button Start-->
                        <div>
                           <center> <a href="View_Details_2.php?TP_ID=<?php echo $TP_ID; ?>" style="height:50px; font-size: 16px; width:150px !important; border-radius: 12px; color:#fff; border:none; background-image: linear-gradient(to right, #B3E207 0%, #3ADBDB 100%);" class="btn btn-primary w-100 box-shadow-0 font-weight-light ">View details</a>
                         
                        </div>
                        <!--Support Button End-->
                    </div>
                </div>
                <!--History Item Container End-->

                








<?php
	}
	
}else{
		
		echo '<center><br><br><br><br><br><br><br><br><br><br><h5 style="color:#011F39">You dont have trips !</h5></center>';
		
	}
	
	?>
                
            </div>
        </div>
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
	   
	   
	   
    </div>









        
    </div>

<?php
include 'menu.php'
?>


</body>
</html>