<?php

$action_readonly = false;

if (!empty($_SESSION['user_id']) && empty($$class->employee_id)) {
 $user_details = ino_user::find_by_id($_SESSION['user_id']);
 $$class->hr_employee_id = $user_details->hr_employee_id;
}

if (!empty($$class->hr_employee_id)) {
 $emp_details = hr_employee::find_by_id($$class->hr_employee_id);
 $$class->identification_id = $emp_details->identification_id;
 $$class->employee_name = $emp_details->first_name . ' ' . $emp_details->last_name;
 if (empty($$class->approved_by_employee_id)) {
  $employee_details = hr_employee::find_by_id($$class->hr_employee_id);
  $$class->approved_by_employee_id = $employee_details->supervisor_employee_id;
 }
}

if (!empty($$class->approved_by_employee_id)) {
 $supr_employee_details = hr_employee::find_by_id($$class->approved_by_employee_id);
 if ($supr_employee_details) {
  $$class->approver_employee_name = $supr_employee_details->first_name . ' ' . $supr_employee_details->last_name;
 }
}

if (!empty($_GET['copydoc']) && $_GET['copydoc'] == 1) {
$$class->claim_number =  $$class->status = $$class->hr_expense_header_id = $$class->approved_date = null;
}

if (empty($$class->hr_expense_header_id)) {
 if (empty($$class->claim_date)) {
  $$class->claim_date = current_time(true);
 }

 if (empty($$class->status)) {
  $$class->status = 'ENTERED';
 }
}


if ((!empty($$class->status)) && (!in_array($$class->status, ['ENTERED', 'APPR_HOLD']))) {
 $mode = 2;
 $readonly = 1;
}
?>