<?php

 if (!empty($_GET['bu_org_id'])) {
  $$class->bu_org_id = $_GET['bu_org_id'];
 }

 if (!empty($_GET['class_name']) && $_GET['class_name'] == 'inv_receipt_line') {
  $mode = 2; $readonly = 1;
  $class = 'inv_rma_receipt_header';
  $$class = new $class;

  $class_second = 'inv_receipt_line';
  $$class_second = new $class_second;
  if (!empty($_GET['inv_receipt_line_id'])) {
   $inv_receipt_line_object = array(inv_receipt_line::find_by_id($_GET['inv_receipt_line_id']));
   $$class->inv_receipt_header_id = $inv_receipt_line_object[0]->inv_receipt_header_id;
   $$class->findBy_id($$class->inv_receipt_header_id);
  } else {
   $inv_receipt_line_object = array(new inv_receipt_line());
  }
 }


 if (!empty($inv_receipt_line_object)) {
  foreach ($inv_receipt_line_object as &$inv_receipt_lines) {
   if (!empty($inv_receipt_lines->sd_so_line_id)) {
    $so_all = new sd_so_all_v();
    $so_all_i = $so_all->findBY_soLineId($inv_receipt_lines->sd_so_line_id);
    $inv_receipt_lines->so_number = $so_all_i->so_number;
    $inv_receipt_lines->so_line_number = $so_all_i->line_number;
    $inv_receipt_lines->quantity = $so_all_i->line_quantity;
    $inv_receipt_lines->received_quantity = -$so_all_i->shipped_quantity;
    $inv_receipt_lines->item_number = $so_all_i->item_number;
    $inv_receipt_lines->customer_name = $so_all_i->customer_name;
    $inv_receipt_lines->customer_number = $so_all_i->customer_number;
    $inv_receipt_lines->customer_site_name = $so_all_i->customer_site_name;
    $inv_receipt_lines->customer_site_number = $so_all_i->customer_site_number;
    $inv_receipt_lines->ar_customer_id = $so_all_i->ar_customer_id;
    $inv_receipt_lines->ar_customer_site_id = $so_all_i->ar_customer_site_id;
    $inv_receipt_lines->uom_id = $so_all_i->uom_id;
   } else {
    $so_all = new sd_so_all_v();
    foreach($so_all->field_a as $k => $v ){
     if(property_exists($inv_receipt_lines, $v)){
      $inv_receipt_lines->$v =  null;
     }
    }
   }
  }
 }

//$po_line = new po_line();
//$po_detail = new po_detail();

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

 if (empty($$class->transaction_type_id)) {
  $$class->transaction_type_id = 23;
 }

 if ((!empty($$class->approval_status)) && ($$class->approval_status == 'CANCELLED')) {
  $mode = 2;
  $readonly = 1;
 }
?>
