<?php
// Simple test file to check if the API is working
define('SUPPRESS_ERRORS', true);
header('Content-Type: application/json');

include_once('../../includes/config.php');

// Test database connection
if (!$con) {
    echo json_encode(['success' => false, 'message' => 'Database connection failed']);
    exit;
}

// Test getting first unit
$query = "SELECT * FROM tblunits LIMIT 1";
$result = mysqli_query($con, $query);

if ($result && mysqli_num_rows($result) > 0) {
    $data = mysqli_fetch_assoc($result);
    echo json_encode(['success' => true, 'message' => 'API working', 'data' => $data]);
} else {
    echo json_encode(['success' => false, 'message' => 'No data found', 'query' => $query]);
}
?>