<?php
include '../includes/config.php';
if (isset($_GET['id'])) {
    $id = intval($_GET['id']);
    $stmt = $conn->prepare("DELETE FROM purchase_lines WHERE id = :id");
    $stmt->bindValue(':id', $id, PDO::PARAM_INT);
    if ($stmt->execute()) {
        echo "<script>
                alert('Purchase line deleted successfully!');
                window.location.href = '../list_purchase.php?msg=deleted';
              </script>";
        exit;
    } else {
        echo "<script>
                alert('Error deleting record!');
                window.history.back();
              </script>";
    }
}
?>
