<?php
 $class_second = 'wip_wo_routing_line';
 $$class_second = &$wip_wo_routing_line;
$class_third = 'wip_wo_bom';
$$class_third = &$wip_wo_bom;
 $$class->transaction_type = 'WIP_MOVE';
?>

<?php

 if (!empty($_GET["wip_wo_header_id"]) && !is_array($_GET["wip_wo_header_id"])) {
  $wip_wo_header_id = htmlentities($_GET["wip_wo_header_id"]);
  $wip_wo_header = wip_wo_header::find_by_id($wip_wo_header_id);
  $wmt = new wip_move_transaction();

  foreach ($wmt->field_a as $key => $value) {
   if (!empty($wip_wo_header->$value)) {
    $$class->$value = $wip_wo_header->$value;
   }
  }
  $$class->wip_wo_heared_id = $wip_wo_header_id;
  $$class->total_quantity = $wip_wo_header->quantity;
  $item = item::find_by_id($$class->item_id_m);
  $$class->item_number = $item->item_number;
  $$class->item_description = $item->item_description;
  $$class->uom = $item->uom_id;
  $$class->transaction_type = 'WIP_MOVE';

  $wip_wo_bom_object = wip_wo_bom::find_by_wip_wo_headerId($wip_wo_header_id);
  if (count($wip_wo_bom_object) == 0) {
   $wip_wo_bom_object = array(new wip_wo_bom());
  } else {
   $routing_line_details = wip_wo_routing_line::find_by_wip_wo_headerId($wip_wo_header_id);
   foreach ($wip_wo_bom_object as & $wip_wobom) {
    if (!empty($wip_wobom->component_item_id_m)) {
     $item = item::find_by_orgId_item_id_m($wip_wobom->component_item_id_m, $$class->org_id);
     $wip_wobom->component_item_number = $item->item_number;
     $wip_wobom->component_description = $item->item_description;
     $wip_wobom->component_uom = $item->uom_id;
     $wip_wobom->serial_generation = $item->serial_generation;
     $wip_wobom->lot_generation = $item->lot_generation;
    }
   }
  }

//  pa($wip_wo_bom_object);

  $wip_wo_routing_line_object = wip_wo_routing_line::find_by_wip_wo_headerId($wip_wo_header_id);
  if (count($wip_wo_routing_line_object) == 0) {
   $wip_wo_routing_line_object = array(new wip_wo_routing_line);
  }
 } else {
  $$class->total_quantity = '';
  $wip_wo_bom = new wip_wo_bom();
  $wip_wo_bom_object = array();
  array_push($wip_wo_bom_object, $wip_wo_bom);

  $wip_wo_routing_line = new wip_wo_routing_line();
  $wip_wo_routing_line_object = array();
  array_push($wip_wo_routing_line_object, $wip_wo_routing_line);
 }

//for move transaction view 
 if (!empty($_GET["wip_move_transaction_id"]) && !is_array($_GET["wip_move_transaction_id"])) {
  $wip_wo_header_id = $$class->wip_wo_header_id;
  $wip_wo_header = wip_wo_header::find_by_id($wip_wo_header_id);
  $$class->total_quantity = $wip_wo_header->quantity;

  $item = item::find_by_id($$class->item_id_m);
  $$class->item_number = $item->item_number;
  $$class->item_description = $item->item_description;
  $$class->uom = $item->uom_id;
  $$class->transaction_type = 'WIP_MOVE';
  $readonly = 1;
  $mode = 2;
 }

 if (empty($$class->transaction_date)) {
  $$class->transaction_date = current_time();
 }
 ?>