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

$templateId = 1;

$stmt = $pdo->prepare("
  INSERT INTO bol_fields
  (template_id, code, label, field_type, x_mm, y_mm, width_mm, height_mm, font_family, font_size, font_color, align, is_multiline, sort_order)
  VALUES
  (?, '', 'New Field', 'text', 10, 10, 40, 8, 'helvetica', 9, '#000000', 'L', 0, 999)
");
$stmt->execute([$templateId]);

$id = (int)$pdo->lastInsertId();

echo json_encode([
  'ok' => true,
  'id' => $id,
  'label' => 'New Field',
  'code' => '',
  'field_type' => 'text',
  'font_family' => 'helvetica',
  'font_size' => 9,
  'font_color' => '#000000',
  'align' => 'L',
  'is_multiline' => 0
]);
