<?php
require_once __DIR__ . '/../core/auth.php';
require_login();
$pdo = db();

if ($_POST) {
  $stmt = $pdo->prepare("INSERT INTO CustomerAddresses (CustomerID, Address, City, ZoneID, IsDefault) VALUES (?,?,?,?,?)");
  $stmt->execute([
    $_POST['CustomerID'],
    $_POST['Address'],
    $_POST['City'],
    $_POST['ZoneID'] ?: null,
    isset($_POST['IsDefault']) ? 1 : 0
  ]);
}
header("Location: customers.php");
