<?php $__template->layout('Layout.main'); ?>
<?php $__template->section('title'); ?>تعديل سجل حضور<?php $__template->endSection(); ?>
<?php $__template->section('page_actions'); ?><a href="/hr/attendance" class="btn btn-secondary">رجوع</a><?php $__template->endSection(); ?>
<?php $__template->section('content'); ?>
<div class="card" style="margin-bottom:12px;padding:16px;">
    <strong><?= e($profile->first_name_ar . ' ' . $profile->last_name_ar) ?></strong> - <?= e($attendance->attendance_date) ?>
</div>
<form method="POST" action="/hr/attendance/<?= (int) $attendance->id ?>">
    <?= csrf_field() ?>
    <div class="card" style="margin-bottom:20px;">
        <div style="padding:16px;display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:16px;">
            <div><label style="display:block;margin-bottom:4px;font-size:13px;">وقت الدخول</label><input type="time" name="check_in_time" value="<?= e($attendance->check_in_time ?? '') ?>" class="form-control"></div>
            <div><label style="display:block;margin-bottom:4px;font-size:13px;">وقت الخروج</label><input type="time" name="check_out_time" value="<?= e($attendance->check_out_time ?? '') ?>" class="form-control"></div>
            <div><label style="display:block;margin-bottom:4px;font-size:13px;">ساعات إضافية</label><input type="text" name="overtime_hours" value="<?= e($attendance->overtime_hours ?? '0') ?>" class="form-control"></div>
            <div><label style="display:block;margin-bottom:4px;font-size:13px;">دقائق التأخير</label><input type="number" name="late_minutes" value="<?= (int) ($attendance->late_minutes ?? 0) ?>" class="form-control" min="0"></div>
            <div><label style="display:block;margin-bottom:4px;font-size:13px;">دقائق الانصراف المبكر</label><input type="number" name="early_leave_minutes" value="<?= (int) ($attendance->early_leave_minutes ?? 0) ?>" class="form-control" min="0"></div>
            <div><label style="display:block;margin-bottom:4px;font-size:13px;">الحالة</label>
                <select name="status" class="form-control">
                    <option value="present" <?= $attendance->status === 'present' ? 'selected' : '' ?>>حاضر</option>
                    <option value="absent" <?= $attendance->status === 'absent' ? 'selected' : '' ?>>غائب</option>
                    <option value="late" <?= $attendance->status === 'late' ? 'selected' : '' ?>>متأخر</option>
                    <option value="on_leave" <?= $attendance->status === 'on_leave' ? 'selected' : '' ?>>إجازة</option>
                    <option value="holiday" <?= $attendance->status === 'holiday' ? 'selected' : '' ?>>عطلة</option>
                </select>
            </div>
            <div style="grid-column:1/-1;"><label style="display:block;margin-bottom:4px;font-size:13px;">ملاحظات</label><textarea name="notes" class="form-control" rows="2"><?= e($attendance->notes ?? '') ?></textarea></div>
        </div>
    </div>
    <div style="display:flex;gap:10px;justify-content:flex-end;">
        <a href="/hr/attendance" class="btn btn-secondary">إلغاء</a>
        <button type="submit" class="btn btn-primary">حفظ</button>
    </div>
</form>
<?php $__template->endSection(); ?>
