<?php

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

 if (!empty($$class->employee_id)) {
  $emp_details = hr_employee::find_by_id($$class->employee_id);
  $$class->identification_id = $emp_details->identification_id;
  $$class->employee_name = $emp_details->first_name . ' ' . $emp_details->last_name;
  if (empty($$class->supervisor_employee_id)) {
   $employee_details = hr_employee::find_by_id($$class->employee_id);
   $supr_employee_details = hr_employee::find_by_id($employee_details->supervisor_employee_id);
   if($supr_employee_details){
   $$class->approved_by = $supr_employee_details->first_name . ' ' . $supr_employee_details->last_name;
   }
  }
 }
 
 if (empty($$class->requsted_date)) {
  $$class->requsted_date = current_time(true);
 }
  if (empty($$class->leave_status)) {
  $$class->leave_status = 'ENTERED';
 }
 
 if(!empty($$class->from_date) ){
  $from_date = new DateTime($$class->from_date);
  $curernt_date = new DateTime('NOW');
  if($from_date < $curernt_date ){
  $$class->leave_action_a = array(null);
  }
 }
// 
//    $start_date = new DateTime($$class->from_date);
//   $to_date = new DateTime($$class->to_date);
//   $no_of_days = $to_date->diff($start_date, true);
//   pa($no_of_days);
//   pa($to_date->diff($start_date, false));
//   pa($start_date->diff($to_date, false));
//   pa($start_date->diff($to_date, true));
?>