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

$data = json_decode(file_get_contents('php://input'), true);
if (!is_array($data)) { http_response_code(400); exit('Invalid'); }

$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['width_mm'], $f['height_mm'], $f['id']
  ]);
}

echo "OK";
