<?php
require_once __DIR__ . '/db.php';

$data = json_decode(file_get_contents('php://input'), true);

$stmt = $pdo->prepare("
UPDATE bol_fields
SET x_mm=?, y_mm=?, width_mm=?, height_mm=?
WHERE id=?
");

foreach ($data as $f) {
    $stmt->execute([
        $f['x_mm'],
        $f['y_mm'],
        $f['w_mm'],
        $f['h_mm'],
        (int)$f['id']
    ]);
}

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