<?php
// modules/sales/search_products.php - SIMPLE TEST VERSION
header('Content-Type: application/json');

// Simple test data - return this regardless of query
$test_products = [
    [
        'product_id' => 2,
        'sku' => 'PAR-555',
        'product_name' => 'Paracetamol 500mg',
        'generic_name' => 'Panadol',
        'unit' => 'tablet',
        'category' => 'Anti-pain',
        'vat_percent' => 0.00,
        'batch_id' => 4,
        'batch_no' => '265656',
        'expiry_date' => '2025-11-30',
        'cost_price' => 300.00,
        'sell_price' => 400.00,
        'current_qty' => 4984,
        'shop_id' => 1
    ],
    [
        'product_id' => 5,
        'sku' => 'DIC-125',
        'product_name' => 'Diclo',
        'generic_name' => 'Diclofenac',
        'unit' => 'tablet',
        'category' => 'Anti-pain',
        'vat_percent' => 0.00,
        'batch_id' => 15,
        'batch_no' => 'BATCH-2025-001',
        'expiry_date' => '2025-12-31',
        'cost_price' => 300.00,
        'sell_price' => 400.00,
        'current_qty' => 72,
        'shop_id' => 1
    ]
];

// Check if query parameter exists
if (isset($_GET['q'])) {
    $search = $_GET['q'];
    echo json_encode($test_products);
} else {
    echo json_encode(['error' => 'No search query provided']);
}
?>