<?php

if (!empty($_GET['inv_abc_assignment_header_id']) && empty($inv_abc_assignment_line_object)) {
 $inv_abc_assignment_line_object = mdm_price_list_line::find_by_parent_id($_GET['inv_abc_assignment_header_id']);
}

if (empty($inv_abc_assignment_line_object)) {
 $inv_abc_assignment_line_object = [new inv_abc_assignment_line()];
}

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

if (!empty($inv_abc_assignment_line_object)) {
 foreach ($inv_abc_assignment_line_object as &$abc_assignment_line) {
  if (!empty($abc_assignment_line->item_id_m)) {
   $item = item::find_by_item_id_m($abc_assignment_line->item_id_m);
   $abc_assignment_line->item_number = !empty($item->item_number) ? $item->item_number : null;
   $abc_assignment_line->item_description = !empty($item->item_description) ? $item->item_description : null;
  } else {
   $abc_assignment_line->item_number = null;
   $abc_assignment_line->item_description = null;
  }
 }
}

if(!empty($$class->inv_abc_valuation_id)){
 $inv_abc_valuation_i = inv_abc_valuation::find_by_id($$class->inv_abc_valuation_id);
 $$class->valuation_name = $inv_abc_valuation_i->valuation_name;
 
 $inv_abc_valuation_result_i = inv_abc_valuation_result::find_impInfo_by_headerid($$class->inv_abc_valuation_id);
 $$class->total_value =  $inv_abc_valuation_result_i->total_value;
 $$class->total_no_of_items =  $inv_abc_valuation_result_i->total_no_of_items;
}else{
  $$class->valuation_name =  null;
}
?>
