<?php
require 'koneksi.php';

$barcode = $_GET['barcode'] ?? '';

$stmt = $conn->prepare("SELECT * FROM barang WHERE barcode = ?");
$stmt->bind_param("s", $barcode);
$stmt->execute();
$result = $stmt->get_result();

if ($row = $result->fetch_assoc()) {
    echo json_encode([
        'status' => 'success',
        'id_barang' => $row['id_barang'],
        'nama_barang' => $row['nama_barang']
    ]);
} else {
    echo json_encode(['status' => 'not_found']);
}
?>
