<?php
// /api/admin/flag_meter.php
session_start();
require_once __DIR__ . '/../../core/db_connect.php';

header('Content-Type: application/json');

$serial = $_POST['serial'] ?? '';
$source = $_POST['source'] ?? '';
$type   = $_POST['type'] ?? '';

if (!$serial || !$type) {
    echo json_encode(['error' => 'Missing info']);
    exit;
}

$conn_rbe->prepare("
    INSERT INTO meter_flags (serial_number, source, flag_type, flagged_at)
    VALUES (?, ?, ?, NOW())
")->execute([$serial, $source, $type]);

echo json_encode(['status' => 'ok']);
