<?php
require_once __DIR__ . '/qrcode_generator.php';

$dataFile = __DIR__ . '/data/products.json';
$products = json_decode(file_get_contents($dataFile), true);

$testProduct = null;
foreach ($products as $p) {
    if ($p['id'] == 38) {
        $testProduct = $p;
        break;
    }
}

if ($testProduct) {
    echo "Product Found: " . $testProduct['title'] . "\n";
    echo "SR NO: " . ($testProduct['sr_no'] ?? 'NOT SET') . "\n";
    
    if (!empty($testProduct['sr_no'])) {
        echo "Formatted SR NO: " . formatProductSRNo($testProduct['sr_no']) . "\n";
        echo "QR Code URL: " . getProductQRCode($testProduct['id'], $testProduct['sr_no']) . "\n";
    }
} else {
    echo "Product 38 not found\n";
    echo "Available products:\n";
    foreach (array_slice($products, 0, 5) as $p) {
        echo "  ID: " . $p['id'] . ", Title: " . $p['title'] . ", SR NO: " . ($p['sr_no'] ?? 'NONE') . "\n";
    }
}
?>
