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

<?php $__template->section('title'); ?>تسوية جديدة<?php $__template->endSection(); ?>

<?php $__template->section('content'); ?>
<div class="card">
    <div class="card-header"><h3 style="margin:0;font-size:16px;">إنشاء تسوية</h3></div>
    <div style="padding:20px;">
        <form method="POST" action="/accounting/settlements">
            <?= csrf_field() ?>

            <div style="display:grid;grid-template-columns:1fr 1fr;gap:15px;margin-bottom:15px;">
                <div>
                    <label class="form-label">نوع التسوية</label>
                    <select name="settlement_type" class="form-select" required>
                        <option value="">— اختر —</option>
                        <option value="supplier">تسوية مورد</option>
                        <option value="member">تسوية عضو</option>
                        <option value="other">أخرى</option>
                    </select>
                </div>
                <div>
                    <label class="form-label">التاريخ</label>
                    <input type="date" name="settlement_date" value="<?= date('Y-m-d') ?>" class="form-control" required>
                </div>
            </div>

            <div style="display:grid;grid-template-columns:1fr 1fr;gap:15px;margin-bottom:15px;">
                <div>
                    <label class="form-label">المورد</label>
                    <select name="supplier_id" class="form-select">
                        <option value="">— اختياري —</option>
                        <?php foreach ($suppliers as $s): ?>
                            <option value="<?= (int)$s['id'] ?>"><?= e($s['name_ar']) ?></option>
                        <?php endforeach; ?>
                    </select>
                </div>
                <div>
                    <label class="form-label">الحساب البنكي</label>
                    <select name="bank_account_id" class="form-select">
                        <option value="">— اختياري —</option>
                        <?php foreach ($bankAccounts as $ba): ?>
                            <option value="<?= (int)$ba['id'] ?>"><?= e($ba['account_name_ar']) ?></option>
                        <?php endforeach; ?>
                    </select>
                </div>
            </div>

            <div style="display:grid;grid-template-columns:1fr 1fr;gap:15px;margin-bottom:15px;">
                <div>
                    <label class="form-label">المبلغ</label>
                    <input type="number" name="amount" step="0.01" class="form-control" required>
                </div>
                <div>
                    <label class="form-label">المرجع</label>
                    <input type="text" name="reference" class="form-control" placeholder="رقم الشيك / الحوالة">
                </div>
            </div>

            <div style="margin-bottom:15px;">
                <label class="form-label">ملاحظات</label>
                <textarea name="notes" class="form-control" rows="3"></textarea>
            </div>

            <div style="display:flex;gap:10px;">
                <button type="submit" class="btn btn-primary">حفظ التسوية</button>
                <a href="/accounting/settlements" class="btn btn-outline">إلغاء</a>
            </div>
        </form>
    </div>
</div>
<?php $__template->endSection(); ?>
