<?php
include '../db_connect.php';

$product_id = $_GET['product_id'];

$stmt = $pdo->prepare("
    SELECT id, batch_no, expiry_date, selling_price 
    FROM product_batches 
    WHERE product_id=? 
    ORDER BY expiry_date ASC 
    LIMIT 1
");
$stmt->execute([$product_id]);
$batch = $stmt->fetch();

echo json_encode($batch);
