<?php


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

session_start();

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



$U_ID = $_SESSION['U_Log'];




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





$sql3 = mysqli_query($dbConn,"select * from users where ID='$U_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'];


$U_ID = $_GET['U_ID'];	
$Driver_ID = $_GET['Driver_ID'];
$TP_ID = $_GET['TP_ID'];


$sql1 = mysqli_query($dbConn,"select * from trips_privates where ID='$TP_ID'");
$row1 = mysqli_fetch_array($sql1);
$From_Longitude=$row1['From_Longitude'];
$From_Latitude=$row1['From_Latitude'];
$Total_Riders=$row1['Total_Riders'];










$sql33 = mysqli_query($dbConn,"select * from trips_privates where ID='$TP_ID'");
$row33 = mysqli_fetch_array($sql33);
$T_Gender = $row33['Gender'];
$T_Total_Riders = $row33['Total_Riders'];
$T_From_Longitude = $row33['From_Longitude'];
$T_From_Latitude = $row33['From_Latitude'];
$T_To_Longitude = $row33['To_Longitude'];	
$T_To_Latitude = $row33['To_Latitude'];	
$T_From_Location = $row33['From_Location'];
$T_To_Location = $row33['To_Location'];	
$T_Total_KM_Distance = $row33['Total_KM_Distance'];
$T_Total_Price = $row33['Total_Price'];	
$T_Payment_Type = $row33['Payment_Type'];	
	




$sql1 = mysqli_query($dbConn,"select * from drivers where ID='$Driver_ID'");
	$row1 = mysqli_fetch_array($sql1);
	$D_Name = $row1['Name'];
	$D_Phone_Number = $row1['Phone_Number'];
	$D_Photo = $row1['Photo'];
	$Car_Plat_Number = $row1['Car_Plat_Number'];
	$Car_Type = $row1['Car_Type'];
	$Car_Color = $row1['Car_Color'];
	$D_Total_Rates = $row1['Total_Rates'];
	$D_Gender = $row1['Gender'];
	
	
	
	
	

?>

<!doctype html>
<html lang="ar" dir="rtl">
<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>معلومات السائق الخاص بك</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/GE-SS-Two-Bold.otf);
   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>


<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js"></script>
<script type="text/javascript">
var auto_refresh = setInterval(
function ()
{
$('#load').load('check-confirm-pickup.php?TP_ID=<?php echo $TP_ID; ?>&U_ID=<?php echo $U_ID; ?>&Driver_ID=<?php echo $Driver_ID; ?>').fadeIn("slow");
}, 10000);






</script>







 <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDemEmJPVUC9PoCzTLZLZdhwJLt5fu5XUc&libraries=places"></script>
    <script>
        function initializeMap() {
			
			
			
            var mapOptions = {
                center: new google.maps.LatLng(<?php echo $From_Latitude; ?>, <?php echo $From_Longitude; ?>),
                zoom: 15,

                mapTypeId: google.maps.MapTypeId.roadmap  
            };
			
  
            var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
			const trafficLayer = new google.maps.TrafficLayer();
			trafficLayer.setMap(map);
			
				
				var marker = new google.maps.Marker({
				position: { lat: <?php echo $From_Latitude; ?>, lng: <?php echo $From_Longitude; ?> },
        map: map,
		icon: "../user-icon.png", // Path to your car icon

        title: 'موقع التحميل' // Set the title for the marker
    });


var infoWindow = new google.maps.InfoWindow({
        content: 'موقع التحميل'
    });
	
	
	marker.addListener('click', function() {
        infoWindow.open(map, marker);
    });



            function updateLocations() {

				
				
				
                fetch("get-driver-location-2.php?Driver_ID=<?php echo $Driver_ID; ?>")
                .then(response => response.json())
                .then(data => {
					
						
                    

                        var driver = data[0];
						
						
                        var marker2 = new google.maps.Marker({
                            position: new google.maps.LatLng(driver.Latitude, driver.Longitude),
                            map: map,
                            icon: "../car-icon.png",
                            title: driver.Name
                        });
						
						
						

						var infoWindow = new google.maps.InfoWindow({
                           
							        content: 'Your driver location'

                        });

						

                       /* var infoWindow = new google.maps.InfoWindow({
                            content: 
							"<div><center><img src='../../../../Drivers_App/EN/Drivers/" + driver.Photo + "'/><br><br>"+
							"<div><strong>اسم السائق: " + driver.Name + "</strong>"+
							"<div><strong>جنس السائق: " + driver.Gender + "</strong>"+
							"<div><strong>رقم اللوحة: " + driver.Car_Plat_Number + "</strong>"+
							"<div><strong>نوع السيارة: " + driver.Car_Type + "</strong>"+
							"<div><strong>لون السيارة: " + driver.Car_Color + "</strong>"+
							"<div><strong>PHONE NUMBER: " + driver.Phone_Number + "</strong></div>"+
							
							"<br>"+
							"<div><center><a style='color:#000; border-color:#d0ff0b; background-color:#B3E207; float: none;' class='btn btn-sm btn-center ' href='confirm-pickup.php?Total_Riders=<?php echo $Total_Riders; ?>&U_ID=<?php echo $U_ID; ?>&Driver_ID=<?php echo $Driver_ID; ?>&TP_ID=<?php echo $TP_ID; ?>'>CONFIRM PICKUP</a>"+
							" | <a style='color:#000; border-color:#d0ff0b; background-color:#B3E207; float: none;' class='btn btn-sm btn-center ' href='tel:" + driver.Phone_Number + "'>CALL DRIVER</a>"+
							" <br><br> <a style='color:#fff; ' class='btn btn-danger btn-sm btn-center ' href='cancel-request.php?U_ID=<?php echo $U_ID; ?>&Driver_ID=<?php echo $Driver_ID; ?>&TP_ID=<?php echo $TP_ID; ?>'>CANCEL REQUEST</a>"+
							" <br><br> <a style='color:#fff;' class='btn btn-danger btn-sm btn-center' href='driver-complain.php?U_ID=<?php echo $U_ID; ?>&Driver_ID=<?php echo $Driver_ID; ?>&TP_ID=<?php echo $TP_ID; ?>' >DRIVER COMPLAIN</a>"+
							"</div>"
                        });
						*/
																


                        marker2.addListener("click", function() {
							
							
	
	
                            infoWindow.open(map, marker2);
							
                        });
						
						setTimeout(function() {
						marker2.setMap(null);
						}, 5000);
						
						
						
					
                    
                });
				
			

				

				
				
            }

            updateLocations();
			
            setInterval(updateLocations, 5000); // Update every 5 seconds
        }
    </script>

</head>
<body onload="initializeMap()">
<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;

                    // ارسال 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?U_ID=<?php echo $U_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 remaining-height">

        <!--Page Title & Icons Start-->
        <div class="header-icons-container position-relative text-center">
            <span class="float-left menu-open closed">
                    <img src="../../../icons/menu.svg" alt="Menu Hamburger Icon">
            </span>
            <span class="title"><br>معلومات السائق الخاص بك</span>
            
<span class="float-right" style="margin-top:-27px !important">
                    <img src="../../../images/icon.png" alt="Logo" width="14px" height="20px">
                </span>
				
        </div>
        <!--Page Title & Icons End-->


<div class="mini-profile-info" style="margin-top:10px">
           
            <div class="profile-picture text-center">
                <img src="../../../../Drivers_App/EN/Drivers/<?php echo $D_Photo; ?>" width="20%" alt="Profile Picture">
            </div>
            <div class="profile-info">
                <div class="profile-name text-center" style="color:#011F39"><?php echo $D_Name; ?></div>
                <div class="profile-phone text-center" style="color:#011F39"><span><img src="../../../icons/phone.svg" alt="Phone Number"></span> <a  style="color:#011F39" href="tel:<?php echo $D_Phone_Number; ?>"><?php echo $D_Phone_Number; ?></a></div>
      






	   </div>
        </div>
		
		



<div class="rest-container" style="margin-top:-50px">
            <div class="all-history-items remaining-height">
                <div class="history-items-container trip-history">
                    <div class="history-item">
                       

                        
                       

                        <!--Trip Costs Container Start-->
                        <div class="border-bottom-primary thin width-48 border-bottom-light-grey" style="color:#011F39">
                            <div class=" trip-fare">معلومات السائق</div>
                        </div>

                        <div class="trip-fare-container font-weight-light" style="color:#011F39">
						
						
						
	
					
							
							
							<div class="trip-fare-item">
                                <span class="float-left">الجنس</span>
                                <span class="float-right blue-price"><?php echo $D_Gender; ?></span>
                                <span class="clearfix"></span>
                            </div>
							
                            <div class="trip-fare-item">
                                <span class="float-left">رقم لوحة المركبة</span>
                                <span class="float-right blue-price"><?php echo $Car_Plat_Number; ?></span>
                                <span class="clearfix"></span>
                            </div>
                            <div class="trip-fare-item">
                                <span class="float-left">نوع المركبة</span>
                                <span class="float-right blue-price" ><?php echo $Car_Type; ?></span>
                                <span class="clearfix"></span>
                            </div>
							
							
							
							
							
							
                            <div class="trip-fare-item">
                                <span class="float-left">لون المركبة</span>
                                <span class="float-right blue-price"><?php echo $Car_Color; ?></span>
                                <span class="clearfix"></span>
                            </div>
							
							
							<center>
							
							<br>
							




							<a style="border-style: dashed; border-radius: 50px; color:#011F39; border-color:#B3E207; background-color:#ebebeb" class='btn btn-sm btn-center' href="JavaScript:if(confirm('هل أنت متأكد من إلغاء هذه الرحلة؟')==true)
{window.location='cancel-request.php?U_ID=<?php echo $U_ID; ?>&Driver_ID=<?php echo $Driver_ID; ?>&TP_ID=<?php echo $TP_ID; ?>';}">الغاء الطلب</a>
							<a style="border-style: dashed; border-radius: 50px; color:red; border-color:#B3E207; background-color:#ebebeb" class='btn btn-sm btn-center' href='driver-complain.php?U_ID=<?php echo $U_ID; ?>&Driver_ID=<?php echo $Driver_ID; ?>&TP_ID=<?php echo $TP_ID; ?>' >ارسال شكوى بالسائق</a>
							</center>
							
							
							
                        </div>
                        <!--Trip Costs Container End-->

                        

                    </div>
                </div>
            </div>
        </div>


		<br>
		
		

    <div id="map_canvas" style="width: 100%; height: 50%;"></div>


      


        
    </div>


	
	
<div id="load" > </div>

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

</body>
</html>