<?php
header("Content-Type: application/json; charset=UTF-8");
require_once "db.php";

$id = $_POST['id'] ?? '';
$due_date = $_POST['due_date'] ?? '';
$notes = $_POST['notes'] ?? '';

// القيمة الثابتة
$attachmentPath = "تخارج بيان";

if (!$id || !$due_date) {
    echo json_encode(['success' => false, 'message' => 'بيانات ناقصة']);
    exit;
}

$stmt = $conn->prepare("UPDATE financialMH SET due_date = ?, notes = ?, AttachmentPath = ? WHERE id = ?");
$stmt->bind_param("sssi", $due_date, $notes, $attachmentPath, $id);

if ($stmt->execute()) {
    echo json_encode(['success' => true]);
} else {
    echo json_encode(['success' => false, 'message' => 'فشل التنفيذ: ' . $conn->error]);
}

$stmt->close();
$conn->close();
?>
