<?php include("../cn.php");

$customer = $_REQUEST["id"];
$bookingno = $_REQUEST["BookingNo"];

$sql = "UPDATE rentedcars SET `status`='Cancelled by the Customer', `PaymentStatus`='Cancelled by the Customer' 
        WHERE  `BookingNumber`='$bookingno' AND `appuser`='$customer' AND `StartTime` is NULL AND  `driver_id` is NULL ";

// $myfile = fopen("testfile.txt", "w");
// fwrite($myfile, $sql);
// fclose($myfile);

$result = mysqli_query($connect, $sql);
// $response["count"] = mysqli_affected_rows($result);

if ($result)
{
$response["code"] = "200";
$response["msg"] = "Ride Cancelled Successfully";
}
else
{
    $response["code"] = "202";
    $response["msg"] = "Ride Assigned to a Driver. Cannot be cancelled.";
}

echo json_encode($response);

?>