<?php
$selected_user_id = !empty($user_id) ? $user_id : $this->session->userdata('user_id');
$selected_user = !empty($selected_user_id) ? get_staff_details($selected_user_id) : null;
$selected_user_label = !empty($selected_user) ? $selected_user->fullname . ' (' . $selected_user->designations . ')' : '';
$check_head = $this->db->where('department_head_id', $this->session->userdata('user_id'))->get('tbl_departments')->row();
$role = $this->session->userdata('user_type');
?>

    

    <form id="time_validation" action="<?= base_url() ?>admin/attendance/saved_manual_time" method="post" class="space-y-4">
        <div class="grid grid-cols-1 gap-4 md:grid-cols-2">
            <?php if ($role == 1 || !empty($check_head)): ?>
                <div class="md:col-span-2">
                    <?= form_grouped_lookup_group('user_id', lang('employee'), grouped_staff_lookup_groups(), $selected_user_id, $selected_user_label, true, array('id' => 'employee'), '', array()) ?>
                </div>
            <?php else: ?>
                <input type="hidden" name="user_id" value="<?= $this->session->userdata('user_id') ?>">
            <?php endif; ?>

            <div>
                <?= form_datepicker('date_in', lang('date_in'), date('Y-m-d'), true, ['data-max' => '#date_out', 'data-auto-close' => 'true']); ?>
            </div>
            <div>
                <?= form_timepicker('clockin_time', lang('clock_in'), '', true); ?>
            </div>
            <div>
                <?= form_datepicker('date_out', lang('day_out'), date('Y-m-d'), true, ['data-min' => '#date_in', 'data-auto-close' => 'true']); ?>
            </div>
            <div>
                <?= form_timepicker('clockout_time', lang('clock_out'), '', true); ?>
            </div>
        </div>

        <div class="flex items-center justify-end border-t border-border pt-4">
            <?= btn_modal_close() ?>
            <?= btn_update() ?>
        </div>
    </form>
