<?php
include 'includes/config.php'; 

if (isset($_GET['ref_no'])) {
    $ref_no = $_GET['ref_no'];

    $stmt = $conn->prepare("SELECT COUNT(*) FROM purchase_lines WHERE ref_no = ?");
    $stmt->execute([$ref_no]);

    $exists = $stmt->fetchColumn() > 0;

    echo json_encode(['exists' => $exists]);
}
?>
