<?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;">تعديل: <?= e($type['code']) ?> — <?= e($type['name_ar']) ?></h3>
    </div>
    <div style="padding:20px;">
        <form method="POST" action="/accounting/journal-types/<?= (int)$type['id'] ?>">
            <?= csrf_field() ?>
            <div style="display:grid;grid-template-columns:1fr 1fr 1fr;gap:15px;">
                <div>
                    <label class="form-label">الكود</label>
                    <input type="text" class="form-input" value="<?= e($type['code']) ?>" disabled dir="ltr" style="background:#F3F4F6;">
                </div>
                <div>
                    <label class="form-label">الاسم (عربي) <span style="color:#DC2626;">*</span></label>
                    <input type="text" name="name_ar" class="form-input" value="<?= e($type['name_ar']) ?>" required>
                </div>
                <div>
                    <label class="form-label">الاسم (إنجليزي) <span style="color:#DC2626;">*</span></label>
                    <input type="text" name="name_en" class="form-input" value="<?= e($type['name_en']) ?>" required dir="ltr">
                </div>
                <div>
                    <label class="form-label">الاسم المختصر (عربي)</label>
                    <input type="text" name="short_name_ar" class="form-input" value="<?= e($type['short_name_ar'] ?? '') ?>" maxlength="20">
                </div>
                <div>
                    <label class="form-label">الاسم المختصر (إنجليزي)</label>
                    <input type="text" name="short_name_en" class="form-input" value="<?= e($type['short_name_en'] ?? '') ?>" dir="ltr" maxlength="20">
                </div>
                <div>
                    <label class="form-label">طريقة الترقيم</label>
                    <select name="numbering_method" class="form-select">
                        <option value="yearly" <?= ($type['numbering_method'] ?? 'yearly') === 'yearly' ? 'selected' : '' ?>>سنوي</option>
                        <option value="monthly" <?= ($type['numbering_method'] ?? '') === 'monthly' ? 'selected' : '' ?>>شهري</option>
                    </select>
                </div>
                <div>
                    <label class="form-label">بادئة الرقم</label>
                    <input type="text" name="number_prefix" class="form-input" value="<?= e($type['number_prefix'] ?? '') ?>" dir="ltr" maxlength="10">
                </div>
                <div>
                    <label class="form-label">طول الرقم</label>
                    <input type="number" name="number_length" class="form-input" value="<?= (int)($type['number_length'] ?? 6) ?>" min="3" max="10" dir="ltr">
                </div>
                <div style="display:flex;align-items:end;gap:20px;">
                    <label class="form-label" style="display:flex;align-items:center;gap:6px;margin:0;">
                        <input type="checkbox" name="is_auto_generated" value="1" <?= (int)($type['is_auto_generated'] ?? 0) ? 'checked' : '' ?>> آلي فقط
                    </label>
                    <label class="form-label" style="display:flex;align-items:center;gap:6px;margin:0;">
                        <input type="checkbox" name="is_default" value="1" <?= (int)($type['is_default'] ?? 0) ? 'checked' : '' ?>> افتراضي
                    </label>
                    <label class="form-label" style="display:flex;align-items:center;gap:6px;margin:0;">
                        <input type="checkbox" name="is_active" value="1" <?= (int)($type['is_active'] ?? 1) ? 'checked' : '' ?>> نشط
                    </label>
                </div>
            </div>
            <div style="margin-top:20px;display:flex;gap:8px;">
                <button type="submit" class="btn btn-primary">حفظ</button>
                <a href="/accounting/journal-types" class="btn btn-outline">إلغاء</a>
            </div>
        </form>
    </div>
</div>
<?php $__template->endSection(); ?>
