<?php
 $class_second = 'wip_wo_routing_line';
 $$class_second = &$wip_wo_routing_line;
?>

<?php

 if (!empty($_GET["wip_wo_header_id"]) && (!is_array($_GET["wip_wo_header_id"]))) {
  $wip_wo_header_id = $_GET["wip_wo_header_id"];

  $wwrv = new wip_wo_routing_v();
  $wwrv->wip_wo_header_id = $wip_wo_header_id;
  $wwrv_i = $wwrv->findBy_woHeaderId();
  $wip_wo_header = wip_wo_header::find_by_id($wip_wo_header_id);

  $$class->wip_wo_header_id = $wip_wo_header_id;
  $$class->wo_number = $wwrv_i[0]->wo_number;
  $$class->total_quantity = $wwrv_i[0]->quantity;
  $$class->item_number = $wwrv_i[0]->item_number;
  $$class->item_description = $wwrv_i[0]->item_description;
  $$class->uom = $wwrv_i[0]->uom_id;
  $$class->item_id_m = $wwrv_i[0]->item_id_m;
  $$class->org_id = $wwrv_i[0]->org_id;


  $wip_wo_routing_detail_object = &$wwrv_i;
  if (empty($wip_wo_routing_detail_object)) {
   $wip_wo_routing_detail_object = array($wwrv);
   }
 }

//for WIP Resource transaction view 
 if (!empty($_GET["wip_resource_transaction_id"]) && (!is_array($_GET["wip_resource_transaction_id"]))) {
  $wip_resource_transaction_id = $_GET["wip_resource_transaction_id"];
  $wip_wo_header_id = $$class->wip_wo_header_id;
  $wip_wo_header = wip_wo_header::find_by_id($wip_wo_header_id);

  $wip_wo_routing_detail_object = [];
  $$class->total_quantity = $wip_wo_header->quantity;
  $item = item::find_by_id($wip_wo_header->item_id_m);
  $$class->item_id_m = $wip_wo_header->item_id_m;
  $$class->wo_number = $wip_wo_header->wo_number;
  $$class->item_number = $item->item_number;
  $$class->item_description = $item->item_description;
  $$class->uom = $item->uom_id;

  $wip_wo_routing_line = wip_wo_routing_line::find_by_id($$class->wip_wo_routing_line_id);
  foreach ($wip_wo_routing_line as $key => $value) {
   if (empty($$class->$value)) {
    $$class->$key = $value;
   }
  }
  
    $wip_wo_routing_detail = wip_wo_routing_detail::find_by_id($$class->wip_wo_routing_detail_id);

  foreach ($wip_wo_routing_detail as $key => $value) {
   if (empty($$class->$value)) {
    $$class->$key = $value;
   }
  }

  array_push($wip_wo_routing_detail_object, $$class);

  $readonly = 1;
  $mode = 2;
 }

 if (empty($_GET["wip_resource_transaction_id"]) && (empty($_GET["wip_wo_header_id"]))) {
  $wip_wo_routing_detail_object = array(new wip_wo_routing_detail());
 }

 if (empty($$class->transaction_date)) {
  $$class->transaction_date = current_time(true);
 }
 $$class->transaction_type = 'WIP_RESOURCE_TRANSACTION';
 
?>
