<?php

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

// Get the values from the request
$driver_id = filterRequest("driver_id");
$assured = filterRequest("assured"); // إذا كانت قيمة حساسة يجب تشفيرها
$health_insurance_provider = filterRequest("health_insurance_provider"); // إذا كانت حساسة، شفرها

// إذا تحتاج تشفير، فعّل التالي:
// $assured = $encryptionHelper->encryptData($assured);
// $health_insurance_provider = $encryptionHelper->encryptData($health_insurance_provider);

// SQL using bind parameters
$sql = "INSERT INTO `driver_health_assurance` (
  `driver_id`,
  `assured`,
  `health_insurance_provider`
) VALUES (
  :driver_id,
  :assured,
  :health_insurance_provider
)";

$stmt = $con->prepare($sql);
$stmt->bindParam(':driver_id', $driver_id);
$stmt->bindParam(':assured', $assured);
$stmt->bindParam(':health_insurance_provider', $health_insurance_provider);

if ($stmt->execute()) {
    jsonSuccess(null, "Health assurance data saved successfully");
} else {
    jsonError("Failed to save health assurance data");
}
?>