<?php $__template->layout('Layout.main'); ?>

<?php $__template->section('title'); ?>حساب بنكي جديد<?php $__template->endSection(); ?>

<?php $__template->section('content'); ?>
<div class="card">
    <div style="padding:15px 20px;border-bottom:1px solid #E5E7EB;">
        <h3 style="margin:0;">إضافة حساب بنكي جديد</h3>
    </div>
    <div style="padding:20px;">
        <form method="POST" action="/accounting/bank-accounts">
            <?= csrf_field() ?>
            <div style="display:grid;grid-template-columns:1fr 1fr;gap:15px;">
                <div>
                    <label class="form-label">اسم الحساب (عربي) <span style="color:#DC2626;">*</span></label>
                    <input type="text" name="account_name_ar" class="form-input" required>
                </div>
                <div>
                    <label class="form-label">اسم الحساب (إنجليزي) <span style="color:#DC2626;">*</span></label>
                    <input type="text" name="account_name_en" class="form-input" dir="ltr" required>
                </div>
                <div>
                    <label class="form-label">اسم البنك (عربي) <span style="color:#DC2626;">*</span></label>
                    <input type="text" name="bank_name_ar" class="form-input" required>
                </div>
                <div>
                    <label class="form-label">اسم البنك (إنجليزي)</label>
                    <input type="text" name="bank_name_en" class="form-input" dir="ltr">
                </div>
                <div>
                    <label class="form-label">رقم الحساب <span style="color:#DC2626;">*</span></label>
                    <input type="text" name="account_number" class="form-input" required dir="ltr">
                </div>
                <div>
                    <label class="form-label">IBAN</label>
                    <input type="text" name="iban" class="form-input" dir="ltr">
                </div>
                <div>
                    <label class="form-label">SWIFT Code</label>
                    <input type="text" name="swift_code" class="form-input" dir="ltr">
                </div>
                <div>
                    <label class="form-label">فرع البنك</label>
                    <input type="text" name="branch_name" class="form-input">
                </div>
                <div>
                    <label class="form-label">حساب دفتر الأستاذ</label>
                    <select name="gl_account_id" class="form-select">
                        <option value="">— ربط بحساب —</option>
                        <?php foreach ($gl_accounts as $gl): ?>
                            <option value="<?= (int)$gl['id'] ?>"><?= e($gl['account_code']) ?> — <?= e($gl['name_ar']) ?></option>
                        <?php endforeach; ?>
                    </select>
                </div>
                <div>
                    <label class="form-label">الرصيد الافتتاحي</label>
                    <input type="number" name="opening_balance" class="form-input" value="0.00" step="0.01" dir="ltr">
                </div>
                <div>
                    <label class="form-label" style="display:flex;align-items:center;gap:8px;">
                        <input type="checkbox" name="is_default" value="1"> حساب افتراضي
                    </label>
                </div>
                <div style="grid-column:1/-1;">
                    <label class="form-label">ملاحظات</label>
                    <textarea name="notes" class="form-textarea" rows="2"></textarea>
                </div>
            </div>
            <div style="margin-top:20px;display:flex;gap:8px;">
                <button type="submit" class="btn btn-primary">حفظ</button>
                <a href="/accounting/bank-accounts" class="btn btn-outline">إلغاء</a>
            </div>
        </form>
    </div>
</div>
<?php $__template->endSection(); ?>
