<?php


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

session_start();

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





	$TP_ID = $_GET['TP_ID'];
	$Driver_ID = $_GET['Driver_ID'];	
	$User_ID = $_GET['User_ID'];
	
	
	
	$sql11 = mysqli_query($dbConn,"select * from trips_privates where ID='$TP_ID'");
	$row11 = mysqli_fetch_array($sql11);
	$Date = $row11['Date'];
	$Total_Riders = $row11['Total_Riders'];
	
	

$sql2 = mysqli_query($dbConn,"select * from drivers_private_trips_cancelation where Driver_ID='$Driver_ID' AND Date='$Date'");
if (mysqli_num_rows($sql2)>0){
	
	$PA = $Total_Riders*0.50;
	
	
	echo "<script language='JavaScript'>
			  alert ('نعتذر ... لقد تم إضافة مبلغ الغرامة بمبلغ ($PA دينار اردني) إلى رصيد الجزاء الخاص بك !');
      </script>";
	  
	  
	  
	  $sql3 = mysqli_query($dbConn,"insert into drivers_private_trips_cancelation (Trip_ID,Driver_ID,Date) values ('$TP_ID','$Driver_ID','$Date')");
	
	$sql4 = mysqli_query($dbConn,"update trips_privates set Status='Canceled', Total_Price='0', Notes='Trip canceled by driver' where ID='$TP_ID'");

	
		$sql6 = mysqli_query($dbConn,"select * from drivers where ID='$Driver_ID'");
		$row6 = mysqli_fetch_array($sql6);
		
		$Penalty_Balance = $row6['Penalty_Balance'];
		
		$New_Penalty_Balance = $Penalty_Balance + $PA;
		
		
		
	$sql7 = mysqli_query($dbConn,"update drivers set Penalty_Balance='$New_Penalty_Balance' where ID='$Driver_ID'");

	
	
	
	
	
	

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


	
}else{
	
	$sql3 = mysqli_query($dbConn,"insert into drivers_private_trips_cancelation (Trip_ID,Driver_ID,Date) values ('$TP_ID','$Driver_ID','$Date')");
	
	$sql4 = mysqli_query($dbConn,"update trips_privates set Status='Canceled', Total_Price='0', Notes='Trip canceled by driver' where Trip_ID='$TP_ID'");

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






	
}
	
	


?>
