<?php

if (empty($search_result) && (!empty($_GET["item_number"])) && (!empty($_GET["org_id"]))) {
 $$class->item_number = $item_number = $_GET["item_number"];
 $$class->org_id = $org_id = $_GET["org_id"];

 $item_obj = $$class->findBy_itemNumber_OrgId();
 if(!empty($item_obj)){
 $$class = & $item_obj;
 }
 if ($item_obj) {
	$org_i = $org->findBy_id($item_obj->org_id);
 } else {
	$msg = "Item or Item-Organization is not defined!!";
 }
}

//check all the assigned inventory orgs
if (!empty($item->item_number)) {
 $all_inventory = $org->findAll_inventory();
 $assigned_inventory_orgIds = item::find_all_assigned_org_ids($item->item_number);
 $assigned_inventory_statement = "<ul id='inventory_assignment' class='column header_field'>";
 foreach ($all_inventory as $org_array) {
	$assigned_inventory_statement .= "<li class='checkBox' data-org_id=\"$org_array->org_id\"><label>$org_array->org  </label> ";
	if (in_array($org_array->org_id, $assigned_inventory_orgIds)) {
	 $value = 1;
	} else {
	 $value = "";
	}
	$assigned_inventory_statement .= form::checkBox_field('assigned_orgs', $value, '', '1');
	$assigned_inventory_statement .= "</li>";
 }
 $assigned_inventory_statement .="</ul>";
}

if(!empty($$class->sourcing_rule_id)){
 $$class->sourcing_rule = po_sourcing_rule_header::find_by_id($$class->sourcing_rule_id)->sourcing_rule;
}else{
 $$class->sourcing_rule = null;
}

$readonly_mas= false;
if(!empty($$class->item_id)){
 if($$class->item_id == $$class->item_id_m){
	$readonly_mas= false;
 }else{
	$readonly_mas = true;
 }
}

$mode = 2; $readonly = 1;
?>