<?php

$payroll_id = '';
//pa($$class);pa($$class_second);
if (empty($$class->hr_payslip_header_id) && !empty($_GET['employee_id'])&& !is_array($_GET['employee_id']) && !empty($_GET['period_name_id'])) {
 $ps_h = hr_payslip_header::find_by_employeeId_periodNameId($_GET['employee_id'], $_GET['period_name_id']);
 if ($ps_h) {
  foreach ($$class->field_a as $k => $v) {
   $$class->$v = $ps_h->$v;
  }
  $hr_payslip_line_object = hr_payslip_line::find_by_parent_id($$class->hr_payslip_header_id);
 }
}

if(empty($hr_payslip_line_object)){
 $hr_payslip_line_object = array(new hr_payslip_line());
}

if (!empty($$class->employee_id)) {
 $employee_i = hr_employee::find_by_id($$class->employee_id);
 $$class->employee_name = $employee_i->first_name . ' ' . $employee_i->last_name;
 $$class->identification_id = $employee_i->identification_id;
 $payroll_id = $employee_i->payroll_id;
}

if($$class->status == 'PAID'){
 $readonly = true; $mode = 2;
}

$total_count = count($hr_payslip_line_object);
 $pageno = !empty($_GET['pageno']) && !is_array($_GET['pageno']) ? $_GET['pageno'] : 1;
 $per_page = (!empty($_GET['per_page'])  && !is_array($_GET['per_page'])) ? $_GET['per_page'] : 10;
 $pagination = new pagination($pageno, $per_page, $total_count);
 $pagination->setProperty('_path', 'form.php?');
 $position = ($pageno - 1) * $per_page;
?>