<?php

if (!$readonly) {
 $id_array = [1, 2, 3];
}

if (!empty($_GET['inv_transaction_id']) && (!is_array($_GET['inv_transaction_id']))) {
 $item = item::find_by_id($$class->item_id_m);
 $$class->item_number = $item->item_number;
 $$class->item_description = $item->item_description;
 $$class->uom_id = $item->uom_id;

 if ((!empty($$class->reference)) && (!empty($$class->document_id))) {
  $idColumn_name = $$class->reference;
  $path = path::find_by_idColumn_name($idColumn_name);
  $view_doc_statement = '<a href="';
  $view_doc_statement.= HOME_URL . $path->value . '?' . $$class->reference . '=' . $$class->document_id;
  $view_doc_statement .= '" target=\'_new\'>Click Here</a>';
 }
}

if (!(empty($search_result))) {
 if (!empty($pagination)) {
  $pagination_statement = $pagination->show_pagination($pagination, 'inv_transactions', $pageno, $query_string);
 }
} elseif (!empty($inv_transaction)) {
 $search_result = array();
 array_push($search_result, $inv_transaction);
} else {
 $form_line = new inv_transaction;
 $search_result = array();
 array_push($search_result, $form_line);
}

//view reference statement
if ((!empty($$class->reference_type)) && (!empty($$class->reference_key_name)) && (!empty($$class->reference_key_value))) {
 $ref_doc_stmt = show_reference_doc($$class->reference_key_name, $$class->reference_key_value);
}

if ((!empty($$class->inv_transaction_id))) {
 $mode = 2;
 $readonly = 1;
 switch ($$class->transaction_type_id) {
  case '1':
   $$class->account_id = $$class->to_account_id;
   break;
  
  case '2':
   $$class->account_id = $$class->from_account_id;
   break;

  default :
   break;
 }
} else {
 $$class->transaction_type_id = 1;
}
?>
