<?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/cost-centers">
            <?= 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="code" class="form-input" required dir="ltr">
                </div>
                <div>
                    <label class="form-label">النوع <span style="color:#DC2626;">*</span></label>
                    <select name="type" class="form-select" required>
                        <option value="cost_center">مركز تكلفة</option>
                        <option value="profit_center">مركز ربحية</option>
                    </select>
                </div>
                <div>
                    <label class="form-label">الاسم (عربي) <span style="color:#DC2626;">*</span></label>
                    <input type="text" name="name_ar" class="form-input" required>
                </div>
                <div>
                    <label class="form-label">الاسم (إنجليزي) <span style="color:#DC2626;">*</span></label>
                    <input type="text" name="name_en" class="form-input" required dir="ltr">
                </div>
                <div>
                    <label class="form-label">الفرع</label>
                    <select name="branch_id" class="form-select">
                        <option value="">— بدون —</option>
                        <?php foreach ($branches as $b): ?>
                            <option value="<?= (int)$b['id'] ?>"><?= e($b['name_ar']) ?></option>
                        <?php endforeach; ?>
                    </select>
                </div>
                <div>
                    <label class="form-label">المركز الأب</label>
                    <select name="parent_id" class="form-select">
                        <option value="">— بدون —</option>
                        <?php foreach ($parents as $p): ?>
                            <option value="<?= (int)$p['id'] ?>"><?= e($p['code']) ?> — <?= e($p['name_ar']) ?></option>
                        <?php endforeach; ?>
                    </select>
                </div>
                <div style="grid-column:1/-1;">
                    <label class="form-label">وصف</label>
                    <textarea name="description" 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/cost-centers" class="btn btn-outline">إلغاء</a>
            </div>
        </form>
    </div>
</div>
<?php $__template->endSection(); ?>
