
    <form data-parsley-validate="" novalidate="" role="form" enctype="multipart/form-data"
          action="<?php echo base_url() ?>admin/payroll/save_advance_salary/<?php
          if (!empty($advance_salary->advance_salary_id)) {
              echo $advance_salary->advance_salary_id;
          }
          ?>" method="post" class="space-y-4">

        <?php if ($this->session->userdata('user_type') == 1) { ?>
            <?php
            $user_id = !empty($advance_salary->user_id) ? $advance_salary->user_id : $this->session->userdata('user_id');
            $employee_options = array('' => lang('select_employee') . '...');
            if (!empty($all_employee)) {
                foreach ($all_employee as $dept_name => $v_all_employee) {
                    if (!empty($v_all_employee)) {
                        foreach ($v_all_employee as $v_employee) {
                            $employee_options[$v_employee->user_id] = $dept_name . ' - ' . $v_employee->fullname . ' ( ' . $v_employee->designations . ' )';
                        }
                    }
                }
            }
            echo form_select_group('user_id', lang('employee'), $employee_options, $user_id, true, array('id' => 'user_id', 'class' => 'select_box'));
            ?>
        <?php } else { ?>
            <input type="hidden" id="user_id" name="user_id" value="<?php echo $this->session->userdata('user_id') ?>">
        <?php } ?>

        <?= form_input_group('advance_amount', lang('amount'), !empty($advance_salary->advance_amount) ? $advance_salary->advance_amount : '', 'number', true, array('data-parsley-type' => 'number', 'onchange' => 'check_advance_amount(this.value)')); ?>
        <div class="text-xs text-red-500" id="advance_amount"></div>

        <?= form_datepicker('deduct_month', lang('deduct_month'), !empty($advance_salary->deduct_month) ? $advance_salary->deduct_month : date('Y-m', safe_strtotime('+1 month')), true, array('class' => 'monthyear', 'data-type' => 'month', 'data-format' => 'Y-m', 'data-auto-close' => 'true')); ?>

        <?= form_textarea_group('reason', lang('reason'), !empty($advance_salary->reason) ? $advance_salary->reason : '', 4, false); ?>

        <div class="flex items-center justify-end gap-2 pt-2">
            <button id="sbtn" type="submit" name="sbtn" value="1"
                    class="inline-flex items-center gap-2 rounded-lg bg-indigo-600 px-3 py-2 text-xs font-semibold text-white shadow-sm hover:bg-indigo-500">
                <i data-lucide="save" class="h-4 w-4"></i>
                <?= lang('save') ?>
            </button>
        </div>

    </form>
