<?php
require '../config/db.php';

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $id = $_POST['id'];

    $sql = "UPDATE owings SET status = 'Paid' WHERE id = ?";
    $stmt = $pdo->prepare($sql);
    if ($stmt->execute([$id])) {
        echo "<script>alert('Owing record marked as Paid successfully.'); window.location.href = 'owing_management.php';</script>";
    } else {
        echo "<script>alert('Failed to update owing status.'); window.location.href = 'owing_management.php';</script>";
    }
}
?>
