<?php
require_once __DIR__ . '/../config/db_remote.php';
header('Content-Type: application/json');

$q = $mysqli->query("
  SELECT reader_code, display_name, scan_role
  FROM symcode_readers
  WHERE enabled = 1
  ORDER BY created_at DESC
  LIMIT 1
");

if ($q && $r = $q->fetch_assoc()) {
  echo json_encode([
    'code'=>$r['reader_code'],
    'name'=>$r['display_name'],
    'role'=>$r['scan_role']
  ]);
} else {
  echo json_encode(['error'=>'not found']);
}
