<?php
require_once 'config/config.php';
header('Content-Type: application/json');

if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['id']) && is_numeric($_POST['id'])) {
    $id = (int)$_POST['id'];
    $closed_date = $_POST['closed_date'] ?? date('Y-m-d');
    $status = $_POST['status'] ?? 'Waiting';

    $stmt = $conn->prepare("UPDATE customers_followup SET followed_up = 1, closed_date = ?, status = ? WHERE id = ?");
    $stmt->bind_param("ssi", $closed_date, $status, $id);
    $success = $stmt->execute();

    echo json_encode(['success' => $success]);
} else {
    echo json_encode(['success' => false]);
}
