<?php
require 'config.php';
$in = json_decode(file_get_contents('php://input'), true);
$phone = trim($in['phone'] ?? ''); $name = trim($in['name'] ?? '');
$date = trim($in['date'] ?? ''); $nights = (int)($in['nights'] ?? 1);
if (!$phone || !$name) out(['ok'=>false,'msg'=>'اطلاعات ناقص است']);
db()->prepare("INSERT INTO bookings (phone, place_name, date_fa, nights) VALUES (?,?,?,?)")
    ->execute([$phone, $name, $date, $nights]);
out(['ok'=>true,'msg'=>'رزرو ثبت شد']);