<?php
require_once __DIR__ . '/../../connect.php';

// استقبال البيانات
$driverID              = filterRequest("driverID");
$passengerID           = filterRequest("passengerID");
$rideID                = filterRequest("rideID");
$isDriverCallPassenger = filterRequest("isDriverCallPassenger");


// If the value is missing or empty, force it to '0' (False)
if ($isDriverCallPassenger === null || $isDriverCallPassenger === "") {
    $isDriverCallPassenger = "0"; 
}

// استخدام التاريخ الحالي
$dateCreated = date("Y-m-d H:i:s");

// تجهيز الاستعلام الآمن
$sql = "INSERT INTO `driver_ride_scam` (
    `driverID`,
    `passengerID`,
    `rideID`,
    `isDriverCallPassenger`,
    `dateCreated`
) VALUES (
    :driverID,
    :passengerID,
    :rideID,
    :isDriverCallPassenger,
    :dateCreated
)";

$stmt = $con->prepare($sql);
$stmt->bindParam(":driverID", $driverID);
$stmt->bindParam(":passengerID", $passengerID);
$stmt->bindParam(":rideID", $rideID);
$stmt->bindParam(":isDriverCallPassenger", $isDriverCallPassenger);
$stmt->bindParam(":dateCreated", $dateCreated);

// تنفيذ الإدخال
$stmt->execute();

if ($stmt->rowCount() > 0) {
    jsonSuccess(null, "Driver ride scam data saved successfully");
} else {
    jsonError("Failed to save driver ride scam data");
}
?>