<?php


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

session_start();

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



$Trip_ID = $_GET['Trip_ID'];
$U_ID = $_GET['U_ID'];
$Driver_ID = $_GET['Driver_ID'];
$TU_ID = $_GET['TU_ID'];








$sql1 = mysqli_query($dbConn,"select * from trips_users where Status='Dropoff' AND ID='$TU_ID'");
if (mysqli_num_rows($sql1)>0){
	
$row1 = mysqli_fetch_array($sql1);
$TU_ID=$row1['ID'];














$sql2 = mysqli_query($dbConn,"select * from users where ID='$U_ID'");
$row2 = mysqli_fetch_array($sql2);
$Driver_Phone_Type = $row2['Phone_Type'];
$UU_ID = $row2['U_ID'];



if ($User_Phone_Type=='Android'){
	
	
	function sendMessage($UU_ID){
        
    
        $content = array(
            "en" => 'Your trip has been completed, thank you for using SHEELD !'
            );
        
        $fields = array(
            'app_id' => "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
            'include_player_ids' => array($UU_ID),
            'data' => array("foo" => "bar"),
            'contents' => $content
        );
        
        $fields = json_encode($fields);
       // print("\nJSON sent:\n");
       // print($fields);
        
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, "https://onesignal.com/api/v1/notifications");
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json; charset=utf-8'));
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
        curl_setopt($ch, CURLOPT_HEADER, FALSE);
        curl_setopt($ch, CURLOPT_POST, TRUE);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);

        $response = curl_exec($ch);
        curl_close($ch);
        
        return $response;
    }
    
    $response = sendMessage($UU_ID);
    $return["allresponses"] = $response;
    $return = json_encode( $return);
    
   // print("\n\nJSON received:\n");
   //    print($return);
   // print("\n");
	
	
	
	
}else{
	
	
	
	 function sendMessage($UU_ID){
        
        
        
        
        
        $content = array(
            "en" => 'Your trip has been completed, thank you for using SHEELD !'
            );
        
        $fields = array(
            'app_id' => "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
            'include_player_ids' => array($UU_ID),
            'data' => array("foo" => "bar"),
            'contents' => $content
        );
        
        $fields = json_encode($fields);
       // print("\nJSON sent:\n");
       // print($fields);
        
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, "https://onesignal.com/api/v1/notifications");
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json; charset=utf-8'));
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
        curl_setopt($ch, CURLOPT_HEADER, FALSE);
        curl_setopt($ch, CURLOPT_POST, TRUE);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);

        $response = curl_exec($ch);
        curl_close($ch);
        
        return $response;
    }
    
    $response = sendMessage($UU_ID);
    $return["allresponses"] = $response;
    $return = json_encode( $return);
    
   // print("\n\nJSON received:\n");
   //    print($return);
   // print("\n");	
   
   
	
	
	
}































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




}else{

}

?>
