<?php
require_once __DIR__ . '/auth.php';
require_login();
check_csrf();

$tag = trim($_GET['code'] ?? '');
$st = $pdo->prepare('SELECT id FROM equipment WHERE tag_qr = ?');
$st->execute([$tag]);
$id = $st->fetchColumn();
if ($id) {
  header('Location: '.base_url('equipment_history.php?id='.(int)$id));
} else {
  echo 'TAG não encontrada.';
}
