<?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'];	
$Trip_ID = $_GET['Trip_ID'];	
$Driver_ID = $_GET['Driver_ID'];
$TU_ID = $_GET['TU_ID'];
$Spot_Number = $_GET['Spot_Number'];









if(isset($_POST['Submit']))
{
	
	
$U_ID = $_POST['U_ID'];	
$Trip_ID = $_POST['Trip_ID'];	
$Driver_ID = $_POST['Driver_ID'];
$TU_ID = $_POST['TU_ID'];
$Spot_Number = $_GET['Spot_Number'];
$Complain = $_GET['Complain'];
$Reason = $_GET['Reason'];


$Date = date("Y-m-d");

move_uploaded_file($_FILES["file"]["tmp_name"], "../../../../Administrator/Drivers_Complains_Pictures/" . $_FILES["file"]["name"]);
     	$Complain_Picture = 'Drivers_Complains_Pictures/'.$file;
 


$insert = mysqli_query($dbConn,"insert into users_trips_complains (Trip_ID,User_ID,Driver_ID,Picture,Reason,Complain,Date) values 
('$Trip_ID','$U_ID','$Driver_ID','$Complain_Picture','$Reason','$Complain','$Date')");


	echo "<script language='JavaScript'>
			  alert ('لقد تم إرسال شكوى السائق الخاص بك !');
      </script>";


echo '<script language="JavaScript">
 document.location="shared-mix-gender-6.php?U_ID='.$U_ID.'&Trip_ID='.$Trip_ID.'&Driver_ID='.$Driver_ID.'&TU_ID='.$TU_ID.'&Spot_Number='.$Spot_Number.'";
</script>';



}



	

?>

<!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?Spot_Number=<?php echo $Spot_Number; ?>&Trip_ID=<?php echo $Trip_ID; ?>&U_ID=<?php echo $U_ID; ?>&Driver_ID=<?php echo $Driver_ID; ?>').fadeIn("slow");
}, 60000);





</script>









</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;

                    // ارسال 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 ">
			<a href="shared-same-gender-6.php?U_ID=<?php echo $U_ID; ?>&Driver_ID=<?php echo $Driver_ID; ?>&Trip_ID=<?php echo $Trip_ID; ?>&TU_ID=<?php echo $TU_ID; ?>&Spot_Number=<?php echo $Spot_Number; ?>">
                    <img src="../../../icons/back.svg" alt="Menu Hamburger Icon">
			</a>
            </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>
        
   
   
   <div class="rest-container" style="margin-top:-50px">
                <form class="width-100" action="driver-complain.php" method="post" enctype="multipart/form-data">
				<input type="hidden" name="U_ID" value="<?php echo $U_ID; ?>"/>
				<input type="hidden" name="TU_ID" value="<?php echo $TU_ID; ?>"/>
				<input type="hidden" name="Trip_ID" value="<?php echo $Trip_ID; ?>"/>
				<input type="hidden" name="Driver_ID" value="<?php echo $Driver_ID; ?>"/>
				<input type="hidden" name="Spot_Number" value="<?php echo $Spot_Number; ?>"/>



            <!--Profile Information Fields Container Start-->
            <div class="sign-up-form-container text-center">

                   
				   
				   
			<div class="text-center header-icon-logo-margin">
                <div class="profile-picture-container">
                    <img id="output" src="../../../images/logo.png" width="30%" >
                    <span class="fas fa-camera">
<input class="file-prompt" onchange="loadFile(event)" type="file" name="file" accept="image/*">
</span>
					
					
					
<script>
  var loadFile = function(event) {
    var output = document.getElementById('output');
    output.src = URL.createObjectURL(event.target.files[0]);
    output.onload = function() {
      URL.revokeObjectURL(output.src) // free memory
    }
  };
</script>



                </div>
                
            </div>
			
			<br>
			

               <!--Sign Up Input Field Start-->
                    <div class="form-group">
                        <div class="input-group">
                            <div class="input-group-prepend">
                                <span><img src="../../../icons/support-white.svg" width="12px" height="17px" alt="REASON"></span>
                            </div>
                            <select name="Reason" class="custom-select font-weight-light" style="border-radius: 50px;"  required>
								<option disabled selected value>السبب</option>
								<option value="XXXXX">XXXXX</option>
								<option value="XXXXX">XXXXX</option>
								<option value="XXXXX">XXXXX</option>
								<option value="XXXXX">XXXXX</option>
								

							</select>

                        </div>
                    </div>
					
					
					
					
				  
				  
            <div class="comment-info comment-info-margin" style="text-align:left; color:#fff">
                <span class="comment-label" style="text-align:left; color:#011F39">  الشكوى </span>
                <textarea name="Complain" class="w-100" required style="border-radius: 10px;"></textarea>
            </div>
          
		  
		  

                    <div class="form-submit-button" style="margin-top:-40px">
                        <button name="Submit" type="submit" style="height:50px; font-size: 16px; border-style: dashed; width:311px !important; border-radius: 50px; color:#011F39; border-color:#B3E207; background-color:#ebebeb" class="btn  w-100 mb-3">ارسال</button>
                    </div>
              
            </div>
            <!--Profile Information Fields Container End-->
  </form>
        </div>
   
   

        
    </div>


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

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

</body>
</html>