/**
 * Get all the contacts relative to an inventory object.
 *
 * There are two ways to get the list. By default, all the contacts in the
 * company that has the inventory contract will be returned. Anyway, if the
 * contacts list was changed manually when updating or creating the
 * inventory object, then these are the contacts of the object.
 *
 * @param int Inventory id.
 * @param bool Whether to return only contact names (default) or all the fields.
 *
 * @return array List of contacts relative to an inventory object.
 */
function get_inventory_contacts($id_inventory, $only_names = false)
{
    global $config;
    include_once "include/functions_crm.php";
    /* First try to get only defined contacts */
    $owner = get_db_value('owner', 'tinventory', 'id', $id_inventory);
    $owner_info = get_db_row("tusuario", "id_usuario", $owner);
    $all_contacts = array();
    $contact = array("id" => $owner, "type" => "user", "id_company" => $owner_info["id_company"], "fullname" => $owner_info["nombre_real"], "email" => $owner_info["direccion"], "phone" => $owner_info["telefono"], "mobile" => __("N/A"), "position" => __("N/A"), "description" => $owner_info["comentarios"], "disabled" => $owner_info["disabled"]);
    $all_contacts[$contact["id"]] = $contact;
    //Get all users associated to the inventory object
    $inv_users = inventory_get_users($id_inventory, false);
    if ($inv_users === ENTERPRISE_NOT_HOOK) {
        $inv_users = array();
    }
    foreach ($inv_users as $user) {
        $contact = array("id" => $user["id_usuario"], "type" => "user", "id_company" => $user["id_company"], "fullname" => $user["nombre_real"], "email" => $user["direccion"], "phone" => $user["telefono"], "mobile" => __("N/A"), "position" => __("N/A"), "description" => $user["comentarios"], "disabled" => $user["disabled"]);
        $all_contacts[$contact["id"]] = $contact;
    }
    $inv_companies = inventory_get_companies($id_inventory, false);
    if ($inv_companies === ENTERPRISE_NOT_HOOK) {
        $inv_companies = array();
    }
    foreach ($inv_companies as $comp) {
        $where_clause = sprintf("WHERE id_company = %d", $comp["id"]);
        $contacts = crm_get_all_contacts($where_clause);
        if (!$contacts) {
            $contacts = array();
        }
        foreach ($contacts as $contact) {
            $all_contacts[$contact['id']] = $contact;
        }
    }
    $contracts = get_inventory_contracts($id_inventory, false);
    if ($contracts === false) {
        return array();
    }
    foreach ($contracts as $contract) {
        $company = get_company($contract['id_company']);
        if ($company === false) {
            continue;
        }
        if (!give_acl($config['id_user'], $contract['id_group'], "IR")) {
            continue;
        }
        $contacts = get_company_contacts($company['id'], false);
        foreach ($contacts as $contact) {
            if (isset($all_contacts[$contact['id']])) {
                continue;
            }
            $all_contacts[$contact['id']] = $contact;
        }
    }
    if (!$only_names) {
        return $all_contacts;
    }
    $retval = array();
    foreach ($all_contacts as $contact) {
        $retval[$contact['id']] = $contact['fullname'];
    }
    return $retval;
}
	
		$table->data[1][1] = print_label (__('Contract'), '', '', true, $contract);
		$table->data[1][2] = print_label (__('Manufacturer'), '', '', true, $manufacturer);
	}


	/* Third row */
	$all_inventory_status = inventories_get_inventory_status ();
	$table->data[2][0] = print_select ($all_inventory_status, 'inventory_status', $inventory_status, 'show_issue_date();', '', '', true, false, false, __('Status'));


	$companies[0] = "none";
	$users[0] = "none";

	if ($id) {
		$companies = inventory_get_companies ($id);
		$count_companies = count($companies);
		if($count_companies == 0){
			$companies[0] = __('None');
		}
		$users = inventory_get_users ($id);
		$count_users = count($users);
		if($count_users == 0){
			$users[0] = __('None');
		}
	}

	if($companies){
		foreach ($companies as $key => $value) {
			$company_id = $key . ', ';
			$company_name = $value . ',';