<?php
require_once "../config/db.php";
require_once "../includes/auth.php";
include "partials/header.php";

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $stmt = $pdo->prepare("INSERT INTO bank_accounts (bank_name, account_number, iban, account_holder) VALUES (?,?,?,?)");
    $stmt->execute([$_POST['bank_name'], $_POST['account_number'], $_POST['iban'], $_POST['account_holder']]);
    header("Location: settings.php?added=1");
    exit;
}
?>

<section class="card">
  <h2>إضافة حساب بنكي جديد</h2>
  <form method="post">
    <label>اسم البنك:</label>
    <input type="text" name="bank_name" required style="width:100%;padding:8px;margin:6px 0;">

    <label>رقم الحساب:</label>
    <input type="text" name="account_number" required style="width:100%;padding:8px;margin:6px 0;">

    <label>رقم الآيبان:</label>
    <input type="text" name="iban" required style="width:100%;padding:8px;margin:6px 0;">

    <label>اسم صاحب الحساب:</label>
    <input type="text" name="account_holder" required style="width:100%;padding:8px;margin:6px 0;">

    <button type="submit" class="btn">حفظ</button>
  </form>
</section>

<?php include __DIR__ . "/partials/footer.php"; ?>
