<?php

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

$driverID = filterRequest("driverID");
$title = filterRequest("title");
$body = filterRequest("body");
$isPin = filterRequest("isPin");

$sql = "INSERT INTO `notificationCaptain` (
  `driverID`,
  `title`,
  `body`,
  `isPin`
) VALUES (
  :driverID,
  :title,
  :body,
  :isPin
)";

$stmt = $con->prepare($sql);
$stmt->execute([
    ':driverID' => $driverID,
    ':title'    => $title,
    ':body'     => $body,
    ':isPin'    => $isPin
]);

if ($stmt->rowCount() > 0) {
    jsonSuccess(null, "Notification data saved successfully");
} else {
    jsonError("Failed to save notification data");
}

?>