<?php $__template->layout('Layout.main'); ?>
<?php $isEdit = $jobTitle !== null; ?>
<?php $__template->section('title'); ?><?= $isEdit ? 'تعديل المسمى الوظيفي' : 'إضافة مسمى وظيفي' ?><?php $__template->endSection(); ?>

<?php $__template->section('page_actions'); ?>
<a href="/hr/job-titles" class="btn btn-secondary">رجوع</a>
<?php $__template->endSection(); ?>

<?php $__template->section('content'); ?>
<form method="POST" action="<?= $isEdit ? '/hr/job-titles/' . (int) $jobTitle->id : '/hr/job-titles' ?>">
    <?= csrf_field() ?>
    <div class="card" style="margin-bottom:20px;">
        <div style="padding:16px;display:grid;grid-template-columns:repeat(auto-fit,minmax(250px,1fr));gap:16px;">
            <div>
                <label style="display:block;margin-bottom:4px;font-size:13px;">الاسم بالعربي <span style="color:#DC2626;">*</span></label>
                <input type="text" name="name_ar" value="<?= e(old('name_ar') ?? ($isEdit ? $jobTitle->name_ar : '')) ?>" class="form-control" required>
            </div>
            <div>
                <label style="display:block;margin-bottom:4px;font-size:13px;">الاسم بالإنجليزي</label>
                <input type="text" name="name_en" value="<?= e(old('name_en') ?? ($isEdit ? $jobTitle->name_en : '')) ?>" class="form-control">
            </div>
            <div>
                <label style="display:block;margin-bottom:4px;font-size:13px;">الكود <span style="color:#DC2626;">*</span></label>
                <input type="text" name="title_code" value="<?= e(old('title_code') ?? ($isEdit ? $jobTitle->title_code : '')) ?>" class="form-control" required>
            </div>
            <div>
                <label style="display:block;margin-bottom:4px;font-size:13px;">الدرجة الوظيفية</label>
                <input type="number" name="grade_level" value="<?= e(old('grade_level') ?? ($isEdit ? $jobTitle->grade_level : '')) ?>" class="form-control" min="0">
            </div>
            <div>
                <label style="display:block;margin-bottom:4px;font-size:13px;">الحد الأدنى للراتب</label>
                <input type="text" name="min_salary" value="<?= e(old('min_salary') ?? ($isEdit ? $jobTitle->min_salary : '')) ?>" class="form-control" placeholder="0.00">
            </div>
            <div>
                <label style="display:block;margin-bottom:4px;font-size:13px;">الحد الأقصى للراتب</label>
                <input type="text" name="max_salary" value="<?= e(old('max_salary') ?? ($isEdit ? $jobTitle->max_salary : '')) ?>" class="form-control" placeholder="0.00">
            </div>
            <div><label style="display:block;margin-bottom:4px;font-size:13px;"><input type="checkbox" name="is_active" value="1" <?= (old('is_active') ?? ($isEdit ? $jobTitle->is_active : 1)) ? 'checked' : '' ?>> فعال</label></div>
            <div style="grid-column:1/-1;">
                <label style="display:block;margin-bottom:4px;font-size:13px;">الوصف</label>
                <textarea name="description_ar" class="form-control" rows="3"><?= e(old('description_ar') ?? ($isEdit ? $jobTitle->description_ar : '')) ?></textarea>
            </div>
        </div>
    </div>
    <div style="display:flex;gap:10px;justify-content:flex-end;">
        <a href="/hr/job-titles" class="btn btn-secondary">إلغاء</a>
        <button type="submit" class="btn btn-primary"><?= $isEdit ? 'تحديث' : 'حفظ' ?></button>
    </div>
</form>
<?php $__template->endSection(); ?>
