Beispiel #1
0
function print_child_tree($id, $depth = 0)
{
    $children = get_inventory_children($id);
    if ($children === false || sizeof($children) == 0) {
        return;
    }
    foreach ($children as $child) {
        print_inventory_object($child['id'], $children, array(), true, true, $depth);
        if ($child['id_contract']) {
            /* Only check ACLs if the inventory has a contract */
            if (!give_acl($config['id_user'], get_inventory_group($child['id']), "VR")) {
                continue;
            } else {
                print_child_tree($child['id'], $depth + 1);
            }
        }
    }
}
// Copyright (c) 2007-2008 Esteban Sanchez, estebans@artica.es
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
global $config;
if (check_login() != 0) {
    audit_db("Noauth", $config["REMOTE_ADDR"], "No authenticated access", "Trying to access inventory viewer");
    require "general/noaccess.php";
    exit;
}
$id = (int) get_parameter('id');
if (!give_acl($config['id_user'], get_inventory_group($id), 'VR')) {
    audit_db($config['id_user'], $config["REMOTE_ADDR"], "ACL Violation", "Trying to access to inventory " . $id);
    include "general/noaccess.php";
    return;
}
echo '<h3>' . __('Contract details on inventory object') . ' #' . $id . '</h3>';
$contracts = get_inventory_contracts($id, false);
$table->class = 'inventory-contracts databox';
$table->width = '740px';
$table->colspan = array();
$table->colspan[1][1] = 3;
$table->style = array();
$table->style[0] = 'font-weight: bold';
$table->style[2] = 'font-weight: bold';
foreach ($contracts as $contract) {
    $table->data = array();
function fill_inventories_table($inventories, &$table)
{
    global $config;
    $table->width = "99%";
    foreach ($inventories as $inventory) {
        $data = array();
        $id_group = get_inventory_group($inventory['id']);
        $has_permission = true;
        if (!give_acl($config['id_user'], $id_group, 'VR')) {
            $has_permission = false;
        }
        $contract = get_contract($inventory['id_contract']);
        $company = get_company($contract['id_company']);
        $data[0] = $inventory['name'];
        if ($has_permission) {
            $table->head[1] = __('Company');
            $table->head[2] = __('Contract');
            if ($inventory['description']) {
                $data[0] .= ' ' . print_help_tip($inventory['description'], true, 'tip_info');
            }
            $data[1] = $company['name'];
            $data[2] = $contract['name'];
        }
        if (give_acl($config['id_user'], $id_group, "VW")) {
            $table->head[4] = __('Edit');
            $table->align[4] = 'center';
            $data[4] = '<a href="index.php?sec=inventory&sec2=operation/inventories/inventory_detail&check_inventory=1&id=' . $inventory['id'] . '">' . '<img src="images/wrench.png" /></a>';
        }
        $table->head[5] = __('More info');
        $data[5] = '<a href="javascript: openInventoryMoreInfo(' . $inventory['id'] . ');" id="show_info-' . $inventory["id"] . '">';
        $data[5] .= print_image("images/information.png", true, array("title" => __('Show object type fields')));
        $data[5] .= '</a>&nbsp;';
        array_push($table->data, $data);
    }
}