/**
 * Print a nice HTML head for every page
 *
 * @param $title title of the page
 * @param $url not used anymore.
 * @param $sector sector in which the page displayed is
 * @param $item item corresponding to the page displayed
 * @param $option option corresponding to the page displayed
 *
**/
function commonHeader($title, $url = '', $sector = "none", $item = "none", $option = "")
{
    global $CFG_GLPI, $LANG, $PLUGIN_HOOKS, $HEADER_LOADED, $DB;
    // Print a nice HTML-head for every page
    if ($HEADER_LOADED) {
        return;
    }
    $HEADER_LOADED = true;
    includeCommonHtmlHeader($title);
    // Body
    echo "<body>";
    // Generate array for menu and check right
    // INVENTORY
    $showstate = false;
    $menu['inventory']['title'] = $LANG['Menu'][38];
    if (haveRight("computer", "r")) {
        $menu['inventory']['default'] = '/front/computer.php';
        $menu['inventory']['content']['computer']['title'] = $LANG['Menu'][0];
        $menu['inventory']['content']['computer']['shortcut'] = 'c';
        $menu['inventory']['content']['computer']['page'] = '/front/computer.php';
        $menu['inventory']['content']['computer']['links']['search'] = '/front/computer.php';
        if (haveRight("computer", "w")) {
            $menu['inventory']['content']['computer']['links']['add'] = '/front/setup.templates.php?' . 'itemtype=Computer&amp;add=1';
            $menu['inventory']['content']['computer']['links']['template'] = '/front/setup.templates.php?' . 'itemtype=Computer&amp;add=0';
        }
        $showstate = true;
    }
    if (haveRight("monitor", "r")) {
        $menu['inventory']['content']['monitor']['title'] = $LANG['Menu'][3];
        $menu['inventory']['content']['monitor']['shortcut'] = 'm';
        $menu['inventory']['content']['monitor']['page'] = '/front/monitor.php';
        $menu['inventory']['content']['monitor']['links']['search'] = '/front/monitor.php';
        if (haveRight("monitor", "w")) {
            $menu['inventory']['content']['monitor']['links']['add'] = '/front/setup.templates.php?' . 'itemtype=Monitor&amp;add=1';
            $menu['inventory']['content']['monitor']['links']['template'] = '/front/setup.templates.php?' . 'itemtype=Monitor&amp;add=0';
        }
        $showstate = true;
    }
    if (haveRight("software", "r")) {
        $menu['inventory']['content']['software']['title'] = $LANG['Menu'][4];
        $menu['inventory']['content']['software']['shortcut'] = 's';
        $menu['inventory']['content']['software']['page'] = '/front/software.php';
        $menu['inventory']['content']['software']['links']['search'] = '/front/software.php';
        if (haveRight("software", "w")) {
            $menu['inventory']['content']['software']['links']['add'] = '/front/setup.templates.php?' . 'itemtype=Software&amp;add=1';
            $menu['inventory']['content']['software']['links']['template'] = '/front/setup.templates.php?' . 'itemtype=Software&amp;add=0';
        }
        $showstate = true;
    }
    if (haveRight("networking", "r")) {
        $menu['inventory']['content']['networking']['title'] = $LANG['Menu'][1];
        $menu['inventory']['content']['networking']['shortcut'] = 'n';
        $menu['inventory']['content']['networking']['page'] = '/front/networkequipment.php';
        $menu['inventory']['content']['networking']['links']['search'] = '/front/networkequipment.php';
        if (haveRight("networking", "w")) {
            $menu['inventory']['content']['networking']['links']['add'] = '/front/setup.templates.php?' . 'itemtype=NetworkEquipment&amp;add=1';
            $menu['inventory']['content']['networking']['links']['template'] = '/front/setup.templates.php?' . 'itemtype=NetworkEquipment&amp;add=0';
        }
        $showstate = true;
    }
    if (haveRight("peripheral", "r")) {
        $menu['inventory']['content']['peripheral']['title'] = $LANG['Menu'][16];
        $menu['inventory']['content']['peripheral']['shortcut'] = 'n';
        $menu['inventory']['content']['peripheral']['page'] = '/front/peripheral.php';
        $menu['inventory']['content']['peripheral']['links']['search'] = '/front/peripheral.php';
        if (haveRight("peripheral", "w")) {
            $menu['inventory']['content']['peripheral']['links']['add'] = '/front/setup.templates.php?' . 'itemtype=Peripheral&amp;add=1';
            $menu['inventory']['content']['peripheral']['links']['template'] = '/front/setup.templates.php?' . 'itemtype=Peripheral&amp;add=0';
        }
        $showstate = true;
    }
    if (haveRight("printer", "r")) {
        $menu['inventory']['content']['printer']['title'] = $LANG['Menu'][2];
        $menu['inventory']['content']['printer']['shortcut'] = 'p';
        $menu['inventory']['content']['printer']['page'] = '/front/printer.php';
        $menu['inventory']['content']['printer']['links']['search'] = '/front/printer.php';
        if (haveRight("printer", "w")) {
            $menu['inventory']['content']['printer']['links']['add'] = '/front/setup.templates.php?' . 'itemtype=Printer&amp;add=1';
            $menu['inventory']['content']['printer']['links']['template'] = '/front/setup.templates.php?' . 'itemtype=Printer&amp;add=0';
        }
        $showstate = true;
    }
    if (haveRight("cartridge", "r")) {
        $menu['inventory']['content']['cartridge']['title'] = $LANG['Menu'][21];
        $menu['inventory']['content']['cartridge']['shortcut'] = 'c';
        $menu['inventory']['content']['cartridge']['page'] = '/front/cartridgeitem.php';
        $menu['inventory']['content']['cartridge']['links']['search'] = '/front/cartridgeitem.php';
        if (haveRight("cartridge", "w")) {
            $menu['inventory']['content']['cartridge']['links']['add'] = '/front/cartridgeitem.form.php';
        }
    }
    if (haveRight("consumable", "r")) {
        $menu['inventory']['content']['consumable']['title'] = $LANG['Menu'][32];
        $menu['inventory']['content']['consumable']['shortcut'] = 'g';
        $menu['inventory']['content']['consumable']['page'] = '/front/consumableitem.php';
        $menu['inventory']['content']['consumable']['links']['search'] = '/front/consumableitem.php';
        if (haveRight("consumable", "w")) {
            $menu['inventory']['content']['consumable']['links']['add'] = '/front/consumableitem.form.php';
        }
        $menu['inventory']['content']['consumable']['links']['summary'] = '/front/consumableitem.php?' . 'synthese=yes';
    }
    if (haveRight("phone", "r")) {
        $menu['inventory']['content']['phone']['title'] = $LANG['Menu'][34];
        $menu['inventory']['content']['phone']['shortcut'] = 't';
        $menu['inventory']['content']['phone']['page'] = '/front/phone.php';
        $menu['inventory']['content']['phone']['links']['search'] = '/front/phone.php';
        if (haveRight("phone", "w")) {
            $menu['inventory']['content']['phone']['links']['add'] = '/front/setup.templates.php?' . 'itemtype=Phone&amp;add=1';
            $menu['inventory']['content']['phone']['links']['template'] = '/front/setup.templates.php?' . 'itemtype=Phone&amp;add=0';
        }
        $showstate = true;
    }
    if ($showstate) {
        $menu['inventory']['content']['state']['title'] = $LANG['Menu'][28];
        $menu['inventory']['content']['state']['shortcut'] = 'n';
        $menu['inventory']['content']['state']['page'] = '/front/states.php';
        $menu['inventory']['content']['state']['links']['search'] = '/front/states.php';
        $menu['inventory']['content']['state']['links']['summary'] = '/front/states.php?synthese=yes';
    }
    // ASSISTANCE
    $menu['maintain']['title'] = $LANG['title'][24];
    if (haveRight("observe_ticket", "1") || haveRight("show_all_ticket", "1") || haveRight("create_ticket", "1")) {
        $menu['maintain']['default'] = '/front/ticket.php';
        $menu['maintain']['content']['ticket']['title'] = $LANG['Menu'][5];
        $menu['maintain']['content']['ticket']['shortcut'] = 't';
        $menu['maintain']['content']['ticket']['page'] = '/front/ticket.php';
        $menu['maintain']['content']['ticket']['links']['search'] = '/front/ticket.php';
        $menu['maintain']['content']['ticket']['links']['search'] = '/front/ticket.php';
        if (haveRight('validate_ticket', 1)) {
            $opt = array();
            $opt['reset'] = 'reset';
            $opt['field'][0] = 55;
            // validation status
            $opt['searchtype'][0] = 'equals';
            $opt['contains'][0] = 'waiting';
            $opt['link'][0] = 'AND';
            $opt['field'][1] = 59;
            // validation aprobator
            $opt['searchtype'][1] = 'equals';
            $opt['contains'][1] = getLoginUserID();
            $opt['link'][1] = 'AND';
            $pic_validate = "<img title=\"" . $LANG['validation'][15] . "\" alt=\"" . $LANG['validation'][15] . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/menu_showall.png'>";
            $menu['maintain']['content']['ticket']['links'][$pic_validate] = '/front/ticket.php?' . append_params($opt, '&amp;');
        }
    }
    if (haveRight("create_ticket", "1")) {
        $menu['maintain']['content']['ticket']['links']['add'] = '/front/ticket.form.php';
    }
    if (haveRight("show_planning", "1") || haveRight("show_all_planning", "1")) {
        $menu['maintain']['content']['planning']['title'] = $LANG['Menu'][29];
        $menu['maintain']['content']['planning']['shortcut'] = 'l';
        $menu['maintain']['content']['planning']['page'] = '/front/planning.php';
        $menu['maintain']['content']['planning']['links']['search'] = '/front/planning.php';
    }
    if (haveRight("statistic", "1")) {
        $menu['maintain']['content']['stat']['title'] = $LANG['Menu'][13];
        $menu['maintain']['content']['stat']['shortcut'] = '1';
        $menu['maintain']['content']['stat']['page'] = '/front/stat.php';
    }
    // FINANCIAL
    if (haveRight("budget", "r")) {
        $menu['financial']['content']['budget']['title'] = $LANG['financial'][110];
        $menu['financial']['content']['budget']['shortcut'] = 'n';
        $menu['financial']['content']['budget']['page'] = '/front/budget.php';
        $menu['financial']['content']['budget']['links']['search'] = '/front/budget.php';
        if (haveRight("budget", "w")) {
            $menu['financial']['content']['budget']['links']['add'] = '/front/setup.templates.php?' . 'itemtype=Budget&amp;add=1';
            $menu['financial']['content']['budget']['links']['template'] = '/front/setup.templates.php?' . 'itemtype=Budget&amp;add=0';
        }
    }
    $menu['financial']['title'] = $LANG['Menu'][26];
    if (haveRight("contact_enterprise", "r")) {
        $menu['financial']['content']['supplier']['title'] = $LANG['Menu'][23];
        $menu['financial']['content']['supplier']['shortcut'] = 'e';
        $menu['financial']['content']['supplier']['page'] = '/front/supplier.php';
        $menu['financial']['content']['supplier']['links']['search'] = '/front/supplier.php';
        $menu['financial']['default'] = '/front/contact.php';
        $menu['financial']['content']['contact']['title'] = $LANG['Menu'][22];
        $menu['financial']['content']['contact']['shortcut'] = 't';
        $menu['financial']['content']['contact']['page'] = '/front/contact.php';
        $menu['financial']['content']['contact']['links']['search'] = '/front/contact.php';
        if (haveRight("contact_enterprise", "w")) {
            $menu['financial']['content']['contact']['links']['add'] = '/front/contact.form.php';
            $menu['financial']['content']['supplier']['links']['add'] = '/front/supplier.form.php';
        }
    }
    if (haveRight("contract", "r")) {
        $menu['financial']['content']['contract']['title'] = $LANG['Menu'][25];
        $menu['financial']['content']['contract']['shortcut'] = 'n';
        $menu['financial']['content']['contract']['page'] = '/front/contract.php';
        $menu['financial']['content']['contract']['links']['search'] = '/front/contract.php';
        if (haveRight("contract", "w")) {
            $menu['financial']['content']['contract']['links']['add'] = '/front/contract.form.php';
        }
    }
    if (haveRight("document", "r")) {
        $menu['financial']['content']['document']['title'] = $LANG['Menu'][27];
        $menu['financial']['content']['document']['shortcut'] = 'd';
        $menu['financial']['content']['document']['page'] = '/front/document.php';
        $menu['financial']['content']['document']['links']['search'] = '/front/document.php';
        if (haveRight("document", "w")) {
            $menu['financial']['content']['document']['links']['add'] = '/front/document.form.php';
        }
    }
    // UTILS
    $menu['utils']['title'] = $LANG['Menu'][18];
    $menu['utils']['default'] = '/front/reminder.php';
    $menu['utils']['content']['reminder']['title'] = $LANG['title'][37];
    $menu['utils']['content']['reminder']['page'] = '/front/reminder.php';
    $menu['utils']['content']['reminder']['links']['search'] = '/front/reminder.php';
    $menu['utils']['content']['reminder']['links']['add'] = '/front/reminder.form.php';
    if (haveRight("knowbase", "r") || haveRight("faq", "r")) {
        if (haveRight("knowbase", "r")) {
            $menu['utils']['content']['knowbase']['title'] = $LANG['Menu'][19];
        } else {
            $menu['utils']['content']['knowbase']['title'] = $LANG['knowbase'][1];
        }
        $menu['utils']['content']['knowbase']['page'] = '/front/knowbaseitem.php';
        $menu['utils']['content']['knowbase']['links']['search'] = '/front/knowbaseitem.php';
        if (haveRight("knowbase", "w") || haveRight("faq", "w")) {
            $menu['utils']['content']['knowbase']['links']['add'] = '/front/knowbaseitem.form.php?id=new';
        }
    }
    if (haveRight("reservation_helpdesk", "1") || haveRight("reservation_central", "r")) {
        $menu['utils']['content']['reservation']['title'] = $LANG['Menu'][17];
        $menu['utils']['content']['reservation']['page'] = '/front/reservationitem.php';
        $menu['utils']['content']['reservation']['links']['search'] = '/front/reservationitem.php';
        $menu['utils']['content']['reservation']['links']['showall'] = '/front/reservation.php';
    }
    if (haveRight("reports", "r")) {
        $menu['utils']['content']['report']['title'] = $LANG['Menu'][6];
        $menu['utils']['content']['report']['page'] = '/front/report.php';
    }
    if ($CFG_GLPI["use_ocs_mode"] && haveRight("ocsng", "w")) {
        $menu['utils']['content']['ocsng']['title'] = $LANG['Menu'][33];
        $menu['utils']['content']['ocsng']['page'] = '/front/ocsng.php';
        $menu['utils']['content']['ocsng']['options']['import']['title'] = $LANG['ocsng'][2];
        $menu['utils']['content']['ocsng']['options']['import']['page'] = '/front/ocsng.import.php';
        $menu['utils']['content']['ocsng']['options']['sync']['title'] = $LANG['ocsng'][1];
        $menu['utils']['content']['ocsng']['options']['sync']['page'] = '/front/ocsng.sync.php';
        $menu['utils']['content']['ocsng']['options']['clean']['title'] = $LANG['ocsng'][3];
        $menu['utils']['content']['ocsng']['options']['clean']['page'] = '/front/ocsng.clean.php';
        $menu['utils']['content']['ocsng']['options']['link']['title'] = $LANG['ocsng'][4];
        $menu['utils']['content']['ocsng']['options']['link']['page'] = '/front/ocsng.link.php';
    }
    // PLUGINS
    if (isset($PLUGIN_HOOKS["menu_entry"]) && count($PLUGIN_HOOKS["menu_entry"])) {
        $menu['plugins']['title'] = $LANG['common'][29];
        $plugins = array();
        foreach ($PLUGIN_HOOKS["menu_entry"] as $plugin => $active) {
            if ($active) {
                // true or a string
                $function = "plugin_version_{$plugin}";
                if (function_exists($function)) {
                    $plugins[$plugin] = $function();
                }
            }
        }
        if (count($plugins)) {
            $list = array();
            foreach ($plugins as $key => $val) {
                $list[$key] = $val["name"];
            }
            asort($list);
            foreach ($list as $key => $val) {
                $menu['plugins']['content'][$key]['title'] = $val;
                $menu['plugins']['content'][$key]['page'] = '/plugins/' . $key . '/';
                if (is_string($PLUGIN_HOOKS["menu_entry"][$key])) {
                    $menu['plugins']['content'][$key]['page'] .= $PLUGIN_HOOKS["menu_entry"][$key];
                }
                // Set default link for plugins
                if (!isset($menu['plugins']['default'])) {
                    $menu['plugins']['default'] = $menu['plugins']['content'][$key]['page'];
                }
                if ($sector == "plugins" && $item == $key) {
                    if (isset($PLUGIN_HOOKS["submenu_entry"][$key]) && is_array($PLUGIN_HOOKS["submenu_entry"][$key])) {
                        foreach ($PLUGIN_HOOKS["submenu_entry"][$key] as $name => $link) {
                            // New complete option management
                            if ($name == "options") {
                                $menu['plugins']['content'][$key]['options'] = $link;
                            } else {
                                // Keep it for compatibility
                                if (is_array($link)) {
                                    // Simple link option
                                    if (isset($link[$option])) {
                                        $menu['plugins']['content'][$key]['links'][$name] = '/plugins/' . $key . '/' . $link[$option];
                                    }
                                } else {
                                    $menu['plugins']['content'][$key]['links'][$name] = '/plugins/' . $key . '/' . $link;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    /// ADMINISTRATION
    $menu['admin']['title'] = $LANG['Menu'][15];
    if (haveRight("user", "r")) {
        $menu['admin']['default'] = '/front/user.php';
        $menu['admin']['content']['user']['title'] = $LANG['Menu'][14];
        $menu['admin']['content']['user']['shortcut'] = 'u';
        $menu['admin']['content']['user']['page'] = '/front/user.php';
        $menu['admin']['content']['user']['links']['search'] = '/front/user.php';
        if (haveRight("user", "w")) {
            $menu['admin']['content']['user']['links']['add'] = "/front/user.form.php";
        }
        $menu['admin']['content']['user']['options']['ldap']['title'] = $LANG['login'][2];
        $menu['admin']['content']['user']['options']['ldap']['page'] = "/front/ldap.php";
    }
    if (haveRight("group", "r")) {
        $menu['admin']['content']['group']['title'] = $LANG['Menu'][36];
        $menu['admin']['content']['group']['shortcut'] = 'g';
        $menu['admin']['content']['group']['page'] = '/front/group.php';
        $menu['admin']['content']['group']['links']['search'] = '/front/group.php';
        if (haveRight("group", "w")) {
            $menu['admin']['content']['group']['links']['add'] = "/front/group.form.php";
            $menu['admin']['content']['group']['options']['ldap']['title'] = $LANG['login'][2];
            $menu['admin']['content']['group']['options']['ldap']['page'] = "/front/ldap.group.php";
        }
    }
    if (haveRight("entity", "r")) {
        $menu['admin']['content']['entity']['title'] = $LANG['Menu'][37];
        $menu['admin']['content']['entity']['shortcut'] = 'z';
        $menu['admin']['content']['entity']['page'] = '/front/entity.php';
        $menu['admin']['content']['entity']['links']['search'] = '/front/entity.php';
        $menu['admin']['content']['entity']['links']['add'] = "/front/entity.form.php";
    }
    if (haveRight("rule_ldap", "r") || haveRight("rule_ocs", "r") || haveRight("entity_rule_ticket", "r") || haveRight("rule_softwarecategories", "r") || haveRight("rule_mailcollector", "r")) {
        $menu['admin']['content']['rule']['title'] = $LANG['rulesengine'][17];
        $menu['admin']['content']['rule']['shortcut'] = 'r';
        $menu['admin']['content']['rule']['page'] = '/front/rule.php';
        if ($sector == 'admin' && $item == 'rule') {
            foreach ($CFG_GLPI["rulecollections_types"] as $rulecollectionclass) {
                $rulecollection = new $rulecollectionclass();
                if ($rulecollection->canList()) {
                    $ruleclassname = $rulecollection->getRuleClassName();
                    $menu['admin']['content']['rule']['options'][$rulecollection->menu_option]['title'] = $rulecollection->getRuleClass()->getTitle();
                    $menu['admin']['content']['rule']['options'][$rulecollection->menu_option]['page'] = getItemTypeSearchURL($ruleclassname, false);
                    $menu['admin']['content']['rule']['options'][$rulecollection->menu_option]['links']['search'] = getItemTypeSearchURL($ruleclassname, false);
                    if ($rulecollection->canCreate()) {
                        $menu['admin']['content']['rule']['options'][$rulecollection->menu_option]['links']['add'] = getItemTypeFormURL($ruleclassname, false);
                    }
                }
            }
        }
    }
    if (haveRight("transfer", "r") && isMultiEntitiesMode()) {
        $menu['admin']['content']['rule']['options']['transfer']['title'] = $LANG['transfer'][1];
        $menu['admin']['content']['rule']['options']['transfer']['page'] = "/front/transfer.php";
        $menu['admin']['content']['rule']['options']['transfer']['links']['search'] = "/front/transfer.php";
        if (haveRight("transfer", "w")) {
            $menu['admin']['content']['rule']['options']['transfer']['links']['summary'] = "/front/transfer.action.php";
            $menu['admin']['content']['rule']['options']['transfer']['links']['add'] = "/front/transfer.form.php";
        }
    }
    if (haveRight("rule_dictionnary_dropdown", "r") || haveRight("rule_dictionnary_software", "r") || haveRight("rule_dictionnary_printer", "r")) {
        $menu['admin']['content']['dictionnary']['title'] = $LANG['rulesengine'][77];
        $menu['admin']['content']['dictionnary']['shortcut'] = 'r';
        $menu['admin']['content']['dictionnary']['page'] = '/front/dictionnary.php';
        if ($sector == 'admin' && $item == 'dictionnary') {
            $menu['admin']['content']['dictionnary']['options']['manufacturers']['title'] = $LANG['common'][5];
            $menu['admin']['content']['dictionnary']['options']['manufacturers']['page'] = '/front/ruledictionnarymanufacturer.php';
            $menu['admin']['content']['dictionnary']['options']['manufacturers']['links']['search'] = '/front/ruledictionnarymanufacturer.php';
            if (haveRight("rule_dictionnary_dropdown", "w")) {
                $menu['admin']['content']['dictionnary']['options']['manufacturers']['links']['add'] = '/front/ruledictionnarymanufacturer.form.php';
            }
            $menu['admin']['content']['dictionnary']['options']['software']['title'] = $LANG['Menu'][4];
            $menu['admin']['content']['dictionnary']['options']['software']['page'] = '/front/ruledictionnarysoftware.php';
            $menu['admin']['content']['dictionnary']['options']['software']['links']['search'] = '/front/ruledictionnarysoftware.php';
            if (haveRight("rule_dictionnary_software", "w")) {
                $menu['admin']['content']['dictionnary']['options']['software']['links']['add'] = '/front/ruledictionnarysoftware.form.php';
            }
            $menu['admin']['content']['dictionnary']['options']['model.computer']['title'] = $LANG['setup'][91];
            $menu['admin']['content']['dictionnary']['options']['model.computer']['page'] = '/front/ruledictionnarycomputermodel.php';
            $menu['admin']['content']['dictionnary']['options']['model.computer']['links']['search'] = '/front/ruledictionnarycomputermodel.php';
            if (haveRight("rule_dictionnary_dropdown", "w")) {
                $menu['admin']['content']['dictionnary']['options']['model.computer']['links']['add'] = '/front/ruledictionnarycomputermodel.form.php';
            }
            $menu['admin']['content']['dictionnary']['options']['model.monitor']['title'] = $LANG['setup'][94];
            $menu['admin']['content']['dictionnary']['options']['model.monitor']['page'] = '/front/ruledictionnarymonitormodel.php';
            $menu['admin']['content']['dictionnary']['options']['model.monitor']['links']['search'] = '/front/ruledictionnarymonitormodel.php';
            if (haveRight("rule_dictionnary_dropdown", "w")) {
                $menu['admin']['content']['dictionnary']['options']['model.monitor']['links']['add'] = '/front/ruledictionnarymonitormodel.form.php';
            }
            $menu['admin']['content']['dictionnary']['options']['model.printer']['title'] = $LANG['setup'][96];
            $menu['admin']['content']['dictionnary']['options']['model.printer']['page'] = '/front/ruledictionnaryprintermodel.php';
            $menu['admin']['content']['dictionnary']['options']['model.printer']['links']['search'] = '/front/ruledictionnaryprintermodel.php';
            if (haveRight("rule_dictionnary_dropdown", "w")) {
                $menu['admin']['content']['dictionnary']['options']['model.printer']['links']['add'] = '/front/ruledictionnaryprintermodel.form.php';
            }
            $menu['admin']['content']['dictionnary']['options']['model.peripheral']['title'] = $LANG['setup'][97];
            $menu['admin']['content']['dictionnary']['options']['model.peripheral']['page'] = '/front/ruledictionnaryperipheralmodel.php';
            $menu['admin']['content']['dictionnary']['options']['model.peripheral']['links']['search'] = '/front/ruledictionnaryperipheralmodel.php';
            if (haveRight("rule_dictionnary_dropdown", "w")) {
                $menu['admin']['content']['dictionnary']['options']['model.peripheral']['links']['add'] = '/front/ruledictionnaryperipheralmodel.form.php';
            }
            $menu['admin']['content']['dictionnary']['options']['model.networking']['title'] = $LANG['setup'][95];
            $menu['admin']['content']['dictionnary']['options']['model.networking']['page'] = '/front/ruledictionnarynetworkequipmentmodel.php';
            $menu['admin']['content']['dictionnary']['options']['model.networking']['links']['search'] = '/front/ruledictionnarynetworkequipmentmodel.php';
            if (haveRight("rule_dictionnary_dropdown", "w")) {
                $menu['admin']['content']['dictionnary']['options']['model.networking']['links']['add'] = '/front/ruledictionnarynetworkequipmentmodel.form.php';
            }
            $menu['admin']['content']['dictionnary']['options']['model.phone']['title'] = $LANG['setup'][503];
            $menu['admin']['content']['dictionnary']['options']['model.phone']['page'] = '/front/ruledictionnaryphonemodel.php';
            $menu['admin']['content']['dictionnary']['options']['model.phone']['links']['search'] = '/front/ruledictionnaryphonemodel.php';
            if (haveRight("rule_dictionnary_dropdown", "w")) {
                $menu['admin']['content']['dictionnary']['options']['model.phone']['links']['add'] = '/front/ruledictionnaryphonemodel.form.php';
            }
            $menu['admin']['content']['dictionnary']['options']['type.computer']['title'] = $LANG['setup'][4];
            $menu['admin']['content']['dictionnary']['options']['type.computer']['page'] = '/front/ruledictionnarycomputertype.php';
            $menu['admin']['content']['dictionnary']['options']['type.computer']['links']['search'] = '/front/ruledictionnarycomputertype.php';
            if (haveRight("rule_dictionnary_dropdown", "w")) {
                $menu['admin']['content']['dictionnary']['options']['type.computer']['links']['add'] = '/front/ruledictionnarycomputertype.form.php';
            }
            $menu['admin']['content']['dictionnary']['options']['type.monitor']['title'] = $LANG['setup'][44];
            $menu['admin']['content']['dictionnary']['options']['type.monitor']['page'] = '/front/ruledictionnarymonitortype.php';
            $menu['admin']['content']['dictionnary']['options']['type.monitor']['links']['search'] = '/front/ruledictionnarymonitortype.php';
            if (haveRight("rule_dictionnary_dropdown", "w")) {
                $menu['admin']['content']['dictionnary']['options']['type.monitor']['links']['add'] = '/front/ruledictionnarymonitortype.form.php';
            }
            $menu['admin']['content']['dictionnary']['options']['type.printer']['title'] = $LANG['setup'][43];
            $menu['admin']['content']['dictionnary']['options']['type.printer']['page'] = '/front/ruledictionnaryprintertype.php';
            $menu['admin']['content']['dictionnary']['options']['type.printer']['links']['search'] = '/front/ruledictionnaryprintertype.php';
            if (haveRight("rule_dictionnary_dropdown", "w")) {
                $menu['admin']['content']['dictionnary']['options']['type.printer']['links']['add'] = '/front/ruledictionnaryprintertype.form.php';
            }
            $menu['admin']['content']['dictionnary']['options']['type.peripheral']['title'] = $LANG['setup'][69];
            $menu['admin']['content']['dictionnary']['options']['type.peripheral']['page'] = '/front/ruledictionnaryperipheraltype.php';
            $menu['admin']['content']['dictionnary']['options']['type.peripheral']['links']['search'] = '/front/ruledictionnaryperipheraltype.php';
            if (haveRight("rule_dictionnary_dropdown", "w")) {
                $menu['admin']['content']['dictionnary']['options']['type.peripheral']['links']['add'] = '/front/ruledictionnaryperipheraltype.form.php';
            }
            $menu['admin']['content']['dictionnary']['options']['type.networking']['title'] = $LANG['setup'][42];
            $menu['admin']['content']['dictionnary']['options']['type.networking']['page'] = '/front/ruledictionnarynetworkequipmenttype.php';
            $menu['admin']['content']['dictionnary']['options']['type.networking']['links']['search'] = '/front/ruledictionnarynetworkequipmenttype.php';
            if (haveRight("rule_dictionnary_dropdown", "w")) {
                $menu['admin']['content']['dictionnary']['options']['type.networking']['links']['add'] = '/front/ruledictionnarynetworkequipmenttype.form.php';
            }
            $menu['admin']['content']['dictionnary']['options']['type.phone']['title'] = $LANG['setup'][504];
            $menu['admin']['content']['dictionnary']['options']['type.phone']['page'] = '/front/ruledictionnaryphonetype.php';
            $menu['admin']['content']['dictionnary']['options']['type.phone']['links']['search'] = '/front/ruledictionnaryphonetype.php';
            if (haveRight("rule_dictionnary_dropdown", "w")) {
                $menu['admin']['content']['dictionnary']['options']['type.phone']['links']['add'] = '/front/ruledictionnaryphonetype.form.php';
            }
            $menu['admin']['content']['dictionnary']['options']['os']['title'] = $LANG['computers'][9];
            $menu['admin']['content']['dictionnary']['options']['os']['page'] = '/front/ruledictionnaryoperatingsystem.php';
            $menu['admin']['content']['dictionnary']['options']['os']['links']['search'] = '/front/ruledictionnaryoperatingsystem.php';
            if (haveRight("rule_dictionnary_dropdown", "w")) {
                $menu['admin']['content']['dictionnary']['options']['os']['links']['add'] = '/front/ruledictionnaryoperatingsystem.form.php';
            }
            $menu['admin']['content']['dictionnary']['options']['os_sp']['title'] = $LANG['computers'][53];
            $menu['admin']['content']['dictionnary']['options']['os_sp']['page'] = '/front/ruledictionnaryoperatingsystemservicepack.php';
            $menu['admin']['content']['dictionnary']['options']['os_sp']['links']['search'] = '/front/ruledictionnaryoperatingsystemservicepack.php';
            if (haveRight("rule_dictionnary_dropdown", "w")) {
                $menu['admin']['content']['dictionnary']['options']['os_sp']['links']['add'] = '/front/ruledictionnaryoperatingsystemservicepack.form.php';
            }
            $menu['admin']['content']['dictionnary']['options']['os_version']['title'] = $LANG['computers'][52];
            $menu['admin']['content']['dictionnary']['options']['os_version']['page'] = '/front/ruledictionnaryoperatingsystemversion.php';
            $menu['admin']['content']['dictionnary']['options']['os_version']['links']['search'] = '/front/ruledictionnaryoperatingsystemversion.php';
            if (haveRight("rule_dictionnary_dropdown", "w")) {
                $menu['admin']['content']['dictionnary']['options']['os_version']['links']['add'] = '/front/ruledictionnaryoperatingsystemversion.form.php';
            }
            $menu['admin']['content']['dictionnary']['options']['printer']['title'] = $LANG['rulesengine'][39];
            $menu['admin']['content']['dictionnary']['options']['printer']['page'] = '/front/ruledictionnaryprinter.php';
            $menu['admin']['content']['dictionnary']['options']['printer']['links']['search'] = '/front/ruledictionnaryprinter.php';
            if (haveRight("rule_dictionnary_printer", "w")) {
                $menu['admin']['content']['dictionnary']['options']['printer']['links']['add'] = '/front/ruledictionnaryprinter.form.php';
            }
        }
    }
    if (haveRight("profile", "r")) {
        $menu['admin']['content']['profile']['title'] = $LANG['Menu'][35];
        $menu['admin']['content']['profile']['shortcut'] = 'p';
        $menu['admin']['content']['profile']['page'] = '/front/profile.php';
        $menu['admin']['content']['profile']['links']['search'] = "/front/profile.php";
        if (haveRight("profile", "w")) {
            $menu['admin']['content']['profile']['links']['add'] = "/front/profile.form.php";
        }
    }
    if (haveRight("backup", "w")) {
        $menu['admin']['content']['backup']['title'] = $LANG['Menu'][12];
        $menu['admin']['content']['backup']['shortcut'] = 'b';
        $menu['admin']['content']['backup']['page'] = '/front/backup.php';
    }
    if (haveRight("logs", "r")) {
        $menu['admin']['content']['log']['title'] = $LANG['Menu'][30];
        $menu['admin']['content']['log']['shortcut'] = 'l';
        $menu['admin']['content']['log']['page'] = '/front/event.php';
    }
    /// CONFIG
    $config = array();
    $addconfig = array();
    $menu['config']['title'] = $LANG['common'][12];
    if (haveRight("dropdown", "r") || haveRight("entity_dropdown", "r")) {
        $menu['config']['content']['dropdowns']['title'] = $LANG['setup'][0];
        $menu['config']['content']['dropdowns']['page'] = '/front/dropdown.php';
        $menu['config']['default'] = '/front/dropdown.php';
        if ($item == "dropdowns") {
            $dps = Dropdown::getStandardDropdownItemTypes();
            foreach ($dps as $tab) {
                foreach ($tab as $key => $val) {
                    if ($key == $option) {
                        $tmp = new $key();
                        $menu['config']['content']['dropdowns']['options'][$option]['title'] = $val;
                        $menu['config']['content']['dropdowns']['options'][$option]['page'] = $tmp->getSearchURL(false);
                        $menu['config']['content']['dropdowns']['options'][$option]['links']['search'] = $tmp->getSearchURL(false);
                        if ($tmp->canCreate()) {
                            $menu['config']['content']['dropdowns']['options'][$option]['links']['add'] = $tmp->getFormURL(false);
                        }
                    }
                }
            }
        }
    }
    if (haveRight("device", "w")) {
        $menu['config']['content']['device']['title'] = $LANG['title'][30];
        $menu['config']['content']['device']['page'] = '/front/device.php';
        if ($item == "device") {
            $dps = Dropdown::getDeviceItemTypes();
            foreach ($dps as $tab) {
                foreach ($tab as $key => $val) {
                    if ($key == $option) {
                        $tmp = new $key();
                        $menu['config']['content']['device']['options'][$option]['title'] = $val;
                        $menu['config']['content']['device']['options'][$option]['page'] = $tmp->getSearchURL(false);
                        $menu['config']['content']['device']['options'][$option]['links']['search'] = $tmp->getSearchURL(false);
                        if ($tmp->canCreate()) {
                            $menu['config']['content']['device']['options'][$option]['links']['add'] = $tmp->getFormURL(false);
                        }
                    }
                }
            }
        }
    }
    if ($CFG_GLPI['use_mailing'] && haveRight("notification", "r") || haveRight("config", "w")) {
        $menu['config']['content']['mailing']['title'] = $LANG['setup'][704];
        $menu['config']['content']['mailing']['page'] = '/front/setup.notification.php';
        $menu['config']['content']['mailing']['options']['notification']['title'] = $LANG['setup'][704];
        $menu['config']['content']['mailing']['options']['notification']['page'] = '/front/notification.php';
        $menu['config']['content']['mailing']['options']['notification']['links']['add'] = '/front/notification.form.php';
        $menu['config']['content']['mailing']['options']['notification']['links']['search'] = '/front/notification.php';
    }
    if (haveRight("sla", "r")) {
        $menu['config']['content']['sla']['title'] = $LANG['Menu'][43];
        $menu['config']['content']['sla']['page'] = '/front/sla.php';
        $menu['config']['content']['sla']['links']['search'] = "/front/sla.php";
        if (haveRight("sla", "w")) {
            $menu['config']['content']['sla']['links']['add'] = "/front/sla.form.php";
        }
    }
    if (haveRight("config", "w")) {
        $menu['config']['content']['config']['title'] = $LANG['setup'][703];
        $menu['config']['content']['config']['page'] = '/front/config.form.php';
        $menu['config']['content']['control']['title'] = $LANG['Menu'][41];
        $menu['config']['content']['control']['page'] = '/front/control.php';
        $menu['config']['content']['control']['options']['FieldUnicity']['title'] = $LANG['setup'][811];
        $menu['config']['content']['control']['options']['FieldUnicity']['page'] = '/front/fieldunicity.php';
        $menu['config']['content']['control']['options']['FieldUnicity']['links']['add'] = '/front/fieldunicity.form.php';
        $menu['config']['content']['control']['options']['FieldUnicity']['links']['search'] = '/front/fieldunicity.php';
        $menu['config']['content']['crontask']['title'] = $LANG['crontask'][0];
        $menu['config']['content']['crontask']['page'] = '/front/crontask.php';
        $menu['config']['content']['crontask']['links']['search'] = "/front/crontask.php";
        $menu['config']['content']['mailing']['options']['config']['title'] = $LANG['mailing'][118];
        $menu['config']['content']['mailing']['options']['config']['page'] = '/front/notificationmailsetting.form.php';
        $menu['config']['content']['mailing']['options']['notificationtemplate']['title'] = $LANG['mailing'][113];
        $menu['config']['content']['mailing']['options']['notificationtemplate']['page'] = '/front/notificationtemplate.php';
        $menu['config']['content']['mailing']['options']['notificationtemplate']['links']['add'] = '/front/notificationtemplate.form.php';
        $menu['config']['content']['mailing']['options']['notificationtemplate']['links']['search'] = '/front/notificationtemplate.php';
        $menu['config']['content']['extauth']['title'] = $LANG['login'][10];
        $menu['config']['content']['extauth']['page'] = '/front/setup.auth.php';
        $menu['config']['content']['extauth']['options']['ldap']['title'] = $LANG['login'][2];
        $menu['config']['content']['extauth']['options']['ldap']['page'] = '/front/authldap.php';
        $menu['config']['content']['extauth']['options']['imap']['title'] = $LANG['login'][3];
        $menu['config']['content']['extauth']['options']['imap']['page'] = '/front/authmail.php';
        $menu['config']['content']['extauth']['options']['others']['title'] = $LANG['common'][67];
        $menu['config']['content']['extauth']['options']['others']['page'] = '/front/auth.others.php';
        $menu['config']['content']['extauth']['options']['settings']['title'] = $LANG['common'][12];
        $menu['config']['content']['extauth']['options']['settings']['page'] = '/front/auth.settings.php';
        switch ($option) {
            case "ldap":
                // LDAP
                $menu['config']['content']['extauth']['options']['ldap']['links']['search'] = '/front/authldap.php';
                $menu['config']['content']['extauth']['options']['ldap']['links']['add'] = '' . '/front/authldap.form.php';
                break;
            case "imap":
                // IMAP
                $menu['config']['content']['extauth']['links']['search'] = '/front/authmail.php';
                $menu['config']['content']['extauth']['links']['add'] = '' . '/front/authmail.form.php';
                break;
        }
        $menu['config']['content']['mailcollector']['title'] = $LANG['Menu'][39];
        $menu['config']['content']['mailcollector']['page'] = '/front/mailcollector.php';
        if (canUseImapPop()) {
            $menu['config']['content']['mailcollector']['links']['search'] = '/front/mailcollector.php';
            $menu['config']['content']['mailcollector']['links']['add'] = '/front/mailcollector.form.php';
            $menu['config']['content']['mailcollector']['options']['rejectedemails']['links']['search'] = '/front/notimportedemail.php';
        }
    }
    if ($CFG_GLPI["use_ocs_mode"] && haveRight("config", "w")) {
        $menu['config']['content']['ocsng']['title'] = $LANG['setup'][134];
        $menu['config']['content']['ocsng']['page'] = '/front/ocsserver.php';
        $menu['config']['content']['ocsng']['links']['search'] = '/front/ocsserver.php';
        $menu['config']['content']['ocsng']['links']['add'] = '/front/ocsserver.form.php';
    }
    if (haveRight("link", "r")) {
        $menu['config']['content']['link']['title'] = $LANG['title'][33];
        $menu['config']['content']['link']['page'] = '/front/link.php';
        $menu['config']['content']['link']['hide'] = true;
        $menu['config']['content']['link']['links']['search'] = '/front/link.php';
        if (haveRight("link", "w")) {
            $menu['config']['content']['link']['links']['add'] = "/front/link.form.php";
        }
    }
    if (haveRight("config", "w")) {
        $menu['config']['content']['plugins']['title'] = $LANG['common'][29];
        $menu['config']['content']['plugins']['page'] = '/front/plugin.php';
    }
    // Special items
    $menu['preference']['title'] = $LANG['Menu'][11];
    $menu['preference']['default'] = '/front/preference.php';
    echo "<div id='header'>";
    echo "<div id='c_logo'>";
    echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/central.php' title=\"" . $LANG['central'][5] . "\"></a>";
    echo "</div>";
    /// Prefs / Logout link
    echo "<div id='c_preference' >";
    echo "<ul>";
    echo "<li id='deconnexion'><a href='" . $CFG_GLPI["root_doc"] . "/logout.php";
    /// logout witout noAuto login for extauth
    if (isset($_SESSION['glpiextauth']) && $_SESSION['glpiextauth']) {
        echo "?noAUTO=1";
    }
    echo "' title=\"" . $LANG['central'][6] . "\">" . $LANG['central'][6] . "</a>";
    // check user id : header used for display messages when session logout
    if (getLoginUserID()) {
        echo " (";
        echo formatUserName(0, $_SESSION["glpiname"], $_SESSION["glpirealname"], $_SESSION["glpifirstname"], 0, 20);
        echo ")";
    }
    echo "</li>\n";
    echo "<li><a href='" . (empty($CFG_GLPI["central_doc_url"]) ? "http://glpi-project.org/help-central" : $CFG_GLPI["central_doc_url"]) . "' target='_blank' title=\"" . $LANG['central'][7] . "\">" . $LANG['central'][7] . "</a></li>";
    echo "<li><a href='" . $CFG_GLPI["root_doc"] . "/front/preference.php' title=\"" . $LANG['Menu'][11] . "\">" . $LANG['Menu'][11] . "</a></li>";
    echo "</ul>";
    echo "<div class='sep'></div>";
    echo "</div>\n";
    /// Search engine
    echo "<div id='c_recherche' >\n";
    echo "<form method='get' action='" . $CFG_GLPI["root_doc"] . "/front/search.php'>\n";
    echo "<div id='boutonRecherche'>";
    echo "<input type='image' src='" . $CFG_GLPI["root_doc"] . "/pics/ok2.png' value='OK' title=\"" . $LANG['buttons'][2] . "\"  alt=\"" . $LANG['buttons'][2] . "\"></div>";
    echo "<div id='champRecherche'><input size='15' type='text' name='globalsearch' value='" . $LANG['buttons'][0] . "' onfocus=\"this.value='';\"></div>";
    echo "</form>";
    echo "<div class='sep'></div>\n";
    echo "</div>";
    ///Main menu
    echo "<div id='c_menu'>";
    echo "<ul id='menu'>";
    // Get object-variables and build the navigation-elements
    $i = 1;
    foreach ($menu as $part => $data) {
        if (isset($data['content']) && count($data['content'])) {
            echo "<li id='menu{$i}' onmouseover=\"javascript:menuAff('menu{$i}','menu');\" >";
            $link = "#";
            if (isset($data['default']) && !empty($data['default'])) {
                $link = $CFG_GLPI["root_doc"] . $data['default'];
            }
            if (utf8_strlen($data['title']) > 14) {
                $data['title'] = utf8_substr($data['title'], 0, 14) . "...";
            }
            echo "<a href='{$link}' class='itemP'>" . $data['title'] . "</a>";
            echo "<ul class='ssmenu'>";
            // list menu item
            foreach ($data['content'] as $key => $val) {
                if (isset($val['page']) && isset($val['title'])) {
                    echo "<li><a href='" . $CFG_GLPI["root_doc"] . $val['page'] . "'";
                    if (isset($data['shortcut']) && !empty($data['shortcut'])) {
                        echo " accesskey='" . $val['shortcut'] . "'";
                    }
                    echo ">" . $val['title'] . "</a></li>\n";
                }
            }
            echo "</ul></li>";
            $i++;
        }
    }
    echo "</ul>";
    echo "<div class='sep'></div>";
    echo "</div>";
    // End navigation bar
    // End headline
    // Le sous menu contextuel 1
    echo "<div id='c_ssmenu1' >";
    echo "<ul>";
    // list sous-menu item
    if (isset($menu[$sector])) {
        if (isset($menu[$sector]['content']) && is_array($menu[$sector]['content'])) {
            $ssmenu = $menu[$sector]['content'];
            if (count($ssmenu) > 12) {
                foreach ($ssmenu as $key => $val) {
                    if (isset($val['hide'])) {
                        unset($ssmenu[$key]);
                    }
                }
                $ssmenu = array_splice($ssmenu, 0, 12);
            }
            foreach ($ssmenu as $key => $val) {
                if (isset($val['page']) && isset($val['title'])) {
                    echo "<li><a href='" . $CFG_GLPI["root_doc"] . $val['page'] . "'";
                    if (isset($val['shortcut']) && !empty($val['shortcut'])) {
                        echo " accesskey='" . $val['shortcut'] . "'";
                    }
                    echo ">" . $val['title'] . "</a></li>\n";
                }
            }
        } else {
            echo "<li>&nbsp;</li>";
        }
    } else {
        echo "<li>&nbsp;</li>";
    }
    echo "</ul></div>";
    //  Le fil d ariane
    echo "<div id='c_ssmenu2' >";
    echo "<ul>";
    // Display item
    echo "<li><a href='" . $CFG_GLPI["root_doc"] . "/front/central.php' title=\"" . $LANG['central'][5] . "\">" . $LANG['central'][5] . "</a> ></li>";
    if (isset($menu[$sector])) {
        $link = "/front/central.php";
        if (isset($menu[$sector]['default'])) {
            $link = $menu[$sector]['default'];
        }
        echo "<li><a href='" . $CFG_GLPI["root_doc"] . $link . "' title=\"" . $menu[$sector]['title'] . "\">" . $menu[$sector]['title'] . "</a> ></li>";
    }
    if (isset($menu[$sector]['content'][$item])) {
        // Title
        $with_option = false;
        if (!empty($option) && isset($menu[$sector]['content'][$item]['options'][$option]['title']) && isset($menu[$sector]['content'][$item]['options'][$option]['page'])) {
            $with_option = true;
        }
        if (isset($menu[$sector]['content'][$item]['page'])) {
            echo "<li><a href='" . $CFG_GLPI["root_doc"] . $menu[$sector]['content'][$item]['page'] . "' " . ($with_option ? "" : "class='here'") . " title=\"" . $menu[$sector]['content'][$item]['title'] . "\" >" . $menu[$sector]['content'][$item]['title'] . "</a>" . (!$with_option ? "" : " > ") . "</li>";
        }
        if ($with_option) {
            echo "<li><a href='" . $CFG_GLPI["root_doc"] . $menu[$sector]['content'][$item]['options'][$option]['page'] . "' class='here' title=\"" . $menu[$sector]['content'][$item]['options'][$option]['title'] . "\" >";
            echo resume_name($menu[$sector]['content'][$item]['options'][$option]['title'], 17);
            echo "</a></li>";
        }
        echo "<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>";
        $links = array();
        // Item with Option case
        if (!empty($option) && isset($menu[$sector]['content'][$item]['options'][$option]['links']) && is_array($menu[$sector]['content'][$item]['options'][$option]['links'])) {
            $links = $menu[$sector]['content'][$item]['options'][$option]['links'];
            // Without option case : only item links
        } else {
            if (isset($menu[$sector]['content'][$item]['links']) && is_array($menu[$sector]['content'][$item]['links'])) {
                $links = $menu[$sector]['content'][$item]['links'];
            }
        }
        // Add item
        echo "<li>";
        if (isset($links['add'])) {
            echo "<a href='" . $CFG_GLPI["root_doc"] . $links['add'] . "'>";
            echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/menu_add.png' title=\"" . $LANG['buttons'][8] . "\" alt=\"" . $LANG['buttons'][8] . "\"></a>";
        } else {
            echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/menu_add_off.png' title=\"" . $LANG['buttons'][8] . "\" alt=\"" . $LANG['buttons'][8] . "\">";
        }
        echo "</li>";
        // Search Item
        if (isset($links['search'])) {
            echo "<li><a href='" . $CFG_GLPI["root_doc"] . $links['search'] . "'>";
            echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/menu_search.png' title=\"" . $LANG['buttons'][0] . "\" alt=\"" . $LANG['buttons'][0] . "\"></a></li>";
        } else {
            echo "<li><img src='" . $CFG_GLPI["root_doc"] . "/pics/menu_search_off.png' title=\"" . $LANG['buttons'][0] . "\" alt=\"" . $LANG['buttons'][0] . "\"></li>";
        }
        // Links
        if (count($links) > 0) {
            foreach ($links as $key => $val) {
                switch ($key) {
                    case "add":
                    case "search":
                        break;
                    case "template":
                        echo "<li><a href='" . $CFG_GLPI["root_doc"] . $val . "'><img title=\"" . $LANG['common'][8] . "\" alt=\"" . $LANG['common'][8] . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/menu_addtemplate.png'></a></li>";
                        break;
                    case "showall":
                        echo "<li><a href='" . $CFG_GLPI["root_doc"] . $val . "'><img title=\"" . $LANG['buttons'][40] . "\" alt=\"" . $LANG['buttons'][40] . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/menu_showall.png'></a></li>";
                        break;
                    case "summary":
                        echo "<li><a href='" . $CFG_GLPI["root_doc"] . $val . "'><img title=\"" . $LANG['state'][1] . "\" alt=\"" . $LANG['state'][1] . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/menu_show.png'></a></li>";
                        break;
                    case "config":
                        echo "<li><a href='" . $CFG_GLPI["root_doc"] . $val . "'><img title=\"" . $LANG['common'][12] . "\" alt=\"" . $LANG['common'][12] . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/menu_config.png'></a></li>";
                        break;
                    default:
                        echo "<li><a href='" . $CFG_GLPI["root_doc"] . $val . "'>" . $key . "</a></li>";
                        break;
                }
            }
        }
    } else {
        echo "<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>";
        echo "<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" . "&nbsp;&nbsp;&nbsp;&nbsp;</li>";
    }
    // Add common items
    echo "<li>";
    // Display MENU ALL
    echo "<div id='show_all_menu' onmouseover=\"completecleandisplay('show_all_menu');\">";
    $items_per_columns = 15;
    $i = -1;
    echo "<table><tr><td class='top'><table>";
    foreach ($menu as $part => $data) {
        if (isset($data['content']) && count($data['content'])) {
            if ($i > $items_per_columns) {
                $i = 0;
                echo "</table></td><td class='top'><table>";
            }
            $link = "#";
            if (isset($data['default']) && !empty($data['default'])) {
                $link = $CFG_GLPI["root_doc"] . $data['default'];
            }
            echo "<tr><td class='tab_bg_1 b'>";
            echo "<a href='{$link}' title=\"" . $data['title'] . "\" class='itemP'>" . $data['title'] . "</a>";
            echo "</td></tr>";
            $i++;
            // list menu item
            foreach ($data['content'] as $key => $val) {
                if ($i > $items_per_columns) {
                    $i = 0;
                    echo "</table></td><td class='top'><table>";
                }
                if (isset($val['page']) && isset($val['title'])) {
                    echo "<tr><td><a href='" . $CFG_GLPI["root_doc"] . $val['page'] . "'";
                    if (isset($data['shortcut']) && !empty($data['shortcut'])) {
                        echo " accesskey='" . $val['shortcut'] . "'";
                    }
                    echo ">" . $val['title'] . "</a></td></tr>\n";
                    $i++;
                }
            }
        }
    }
    echo "</table></td></tr></table>";
    echo "</div>";
    echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
    echo "</li>";
    /// Bookmark load
    echo "<li>";
    echo "<a href='#' onClick=\"var w=window.open('" . $CFG_GLPI["root_doc"] . "/front/popup.php?popup=load_bookmark' ,'glpibookmarks', 'height=500, width=" . (Bookmark::WIDTH + 250) . ", top=100, left=100, scrollbars=yes' );w.focus();\">";
    echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/bookmark.png' title=\"" . $LANG['buttons'][52] . " " . $LANG['bookmark'][1] . "\"  alt=\"" . $LANG['buttons'][52] . " " . $LANG['bookmark'][1] . "\">";
    echo "</a></li>";
    /// MENU ALL
    echo "<li >";
    echo "<img alt='' src='" . $CFG_GLPI["root_doc"] . "/pics/menu_all.png' " . "onclick=\"completecleandisplay('show_all_menu')\">";
    echo "</li>";
    // check user id : header used for display messages when session logout
    if (getLoginUserID()) {
        showProfileSelecter($CFG_GLPI["root_doc"] . "/front/central.php");
    }
    echo "</ul>";
    echo "</div>";
    echo "</div>\n";
    // fin header
    echo "<div id='page' >";
    if ($DB->isSlave() && !$DB->first_connection) {
        echo "<div id='dbslave-float'>";
        echo "<a href='#see_debug'>" . $LANG['setup'][809] . "</a>";
        echo "</div>";
    }
    // call function callcron() every 5min
    callCron();
    displayMessageAfterRedirect();
}
Example #2
0
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GLPI; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
--------------------------------------------------------------------------
*/
// ----------------------------------------------------------------------
// Original Author of file:
// Purpose of file:
// ----------------------------------------------------------------------
define('GLPI_ROOT', '..');
include GLPI_ROOT . "/inc/includes.php";
checkRight("config", "w");
$config = new Config();
if (!empty($_POST["update_auth"])) {
    $config->update($_POST);
    glpi_header($_SERVER['HTTP_REFERER']);
}
if (!empty($_POST["update"])) {
    $config->update($_POST);
    if (isset($_POST["use_ocs_mode"]) && $_POST["use_ocs_mode"] && !$CFG_GLPI["use_ocs_mode"]) {
        glpi_header(getItemTypeSearchURL('OcsServer'));
    } else {
        glpi_header(getItemTypeFormURL('Config'));
    }
}
commonHeader($LANG['common'][12], $_SERVER['PHP_SELF'], "config", "config");
$config->showForm(1);
commonFooter();
Example #3
0
     if ($ok) {
     }
     Html::redirect(getItemTypeSearchURL('PluginSimcardSimcard'));
 } else {
     if (isset($_POST["restore"])) {
         $simcard->check($_POST['id'], 'd');
         if ($simcard->restore($_POST)) {
             Event::log($_POST["id"], "computers", 4, "inventory", sprintf(__('%s restores the item'), $_SESSION["glpiname"]));
         }
         html::redirect(getItemTypeSearchURL('PluginSimcardSimcard'));
     } else {
         if (isset($_REQUEST["purge"])) {
             $simcard->check($_REQUEST['id'], 'd');
             if ($simcard->delete($_REQUEST, 1)) {
             }
             Html::redirect(getItemTypeSearchURL('PluginSimcardSimcard'));
             //update a computer
         } else {
             if (isset($_POST["update"])) {
                 $simcard->check($_POST['id'], 'w');
                 $simcard->update($_POST);
                 Html::back();
             } else {
                 if (isset($_GET["unglobalize"])) {
                     $simcard->check($_GET["id"], 'w');
                     Html::redirect(getItemTypeFormURL('PluginSimcardSimcard') . "?id=" . $_GET["id"]);
                 } else {
                     //print computer information
                     Html::header(PluginSimcardSimcard::getTypeName(2), $_SERVER['PHP_SELF'], "plugins", "simcard", "simcard");
                     //show computer form to add
                     $simcard->showForm($_GET["id"], $_GET);
Example #4
0
    echo "<a href='https://forge.indepnet.net/projects/ocsinventoryng/wiki' target='_blank'>" . __('Use mode', 'ocsinventoryng') . "</a></td></tr>";
}
$config = new PluginOcsinventoryngConfig();
if (isset($_POST["update"])) {
    $config->update($_POST);
    Html::back();
}
if (isset($_POST["soft_lock"])) {
    $config->setScriptLock();
}
if (isset($_POST["soft_unlock"])) {
    $config->removeScriptLock();
}
$plugin = new Plugin();
if ($plugin->isInstalled("ocsinventoryng") && $plugin->isActivated("ocsinventoryng")) {
    Html::header(__('History of automatic actions', 'ocsinventoryng'), "", "plugins", "ocsinventoryng", "config");
    if (!countElementsInTable("glpi_plugin_ocsinventoryng_ocsservers")) {
        configHeader();
        echo "<tr class='tab_bg_2'><td class='center'>" . __('No server configured', 'ocsinventoryng');
        echo "<a href='" . getItemTypeSearchURL("PluginOcsinventoryngOcsServer") . "'>" . __('Configuration', 'ocsinventoryng') . "</a></th></tr>";
        echo "</table></div>";
    } else {
        $config->showConfigForm($_SERVER['PHP_SELF']);
    }
} else {
    Html::header(__('Number of processed computers', 'ocsinventoryng'), "", "plugins", "ocsinventoryng", "config");
    echo "<div class='center'><br><br>";
    echo "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/warning.png\" alt='" . __s('Warning') . "'><br><br>";
    echo "<b>__('Please activate the plugin', 'ocsinventoryng')</b></div>";
}
Html::footer();
 /**
  * Print the HTML array for infocoms linked
  *
  *@return Nothing (display)
  *
  **/
 function showInfocoms()
 {
     global $DB, $CFG_GLPI, $LANG;
     $instID = $this->fields['id'];
     if (!$this->can($instID, 'r')) {
         return false;
     }
     $query = "SELECT DISTINCT `itemtype`\n                FROM `glpi_infocoms`\n                WHERE `suppliers_id` = '{$instID}'\n                      AND `itemtype` NOT IN ('ConsumableItem', 'CartridgeItem', 'Software')\n                ORDER BY `itemtype`";
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     echo "<div class='spaced'><table class='tab_cadre_fixe'>";
     echo "<tr><th colspan='2'>";
     printPagerForm();
     echo "</th><th colspan='3'>";
     if ($DB->numrows($result) == 0) {
         echo $LANG['document'][13];
     } else {
         echo $LANG['document'][19];
     }
     echo "</th></tr>";
     echo "<tr><th>" . $LANG['common'][17] . "</th>";
     echo "<th>" . $LANG['entity'][0] . "</th>";
     echo "<th>" . $LANG['common'][16] . "</th>";
     echo "<th>" . $LANG['common'][19] . "</th>";
     echo "<th>" . $LANG['common'][20] . "</th>";
     echo "</tr>";
     $num = 0;
     for ($i = 0; $i < $number; $i++) {
         $itemtype = $DB->result($result, $i, "itemtype");
         if (!class_exists($itemtype)) {
             continue;
         }
         $item = new $itemtype();
         if ($item->canView()) {
             $linktype = $itemtype;
             $linkfield = 'id';
             $itemtable = getTableForItemType($itemtype);
             $query = "SELECT `glpi_infocoms`.`entities_id`, `name`, `{$itemtable}`.*\n                      FROM `glpi_infocoms`\n                      INNER JOIN `{$itemtable}` ON (`{$itemtable}`.`id` = `glpi_infocoms`.`items_id`) ";
             // Set $linktype for entity restriction AND link to search engine
             if ($itemtype == 'Cartridge') {
                 $query .= "INNER JOIN `glpi_cartridgeitems`\n                            ON (`glpi_cartridgeitems`.`id`=`glpi_cartridges`.`cartridgeitems_id`) ";
                 $linktype = 'CartridgeItem';
                 $linkfield = 'cartridgeitems_id';
             }
             if ($itemtype == 'Consumable') {
                 $query .= "INNER JOIN `glpi_consumableitems`\n                            ON (`glpi_consumableitems`.`id`=`glpi_consumables`.`consumableitems_id`) ";
                 $linktype = 'ConsumableItem';
                 $linkfield = 'consumableitems_id';
             }
             $linktable = getTableForItemType($linktype);
             $query .= "WHERE `glpi_infocoms`.`itemtype` = '{$itemtype}'\n                             AND `glpi_infocoms`.`suppliers_id` = '{$instID}'" . getEntitiesRestrictRequest(" AND", $linktable) . "\n                       ORDER BY `glpi_infocoms`.`entities_id`,\n                                `{$linktable}`.`name`";
             $result_linked = $DB->query($query);
             $nb = $DB->numrows($result_linked);
             // Set $linktype for link to search engine pnly
             if ($itemtype == 'SoftwareLicense' && $nb > $_SESSION['glpilist_limit']) {
                 $linktype = 'Software';
                 $linkfield = 'softwares_id';
             }
             if ($nb > $_SESSION['glpilist_limit']) {
                 echo "<tr class='tab_bg_1'>";
                 echo "<td class='center'>" . $item->getTypeName($nb) . "&nbsp;:&nbsp;{$nb}</td>";
                 echo "<td class='center' colspan='2'>";
                 echo "<a href='" . getItemTypeSearchURL($linktype) . "?" . rawurlencode("contains[0]") . "=" . rawurlencode('$$$$' . $instID) . "&" . rawurlencode("field[0]") . "=53&sort=80&order=ASC&is_deleted=0&start=0" . "'>" . $LANG['reports'][57] . "</a></td>";
                 echo "<td class='center'>-</td><td class='center'>-</td></tr>";
             } else {
                 if ($nb) {
                     for ($prem = true; $data = $DB->fetch_assoc($result_linked); $prem = false) {
                         $ID = "";
                         if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) {
                             $ID = " (" . $data["id"] . ")";
                         }
                         $link = getItemTypeFormURL($linktype);
                         $name = "<a href=\"" . $link . "?id=" . $data[$linkfield] . "\">" . $data["name"] . "{$ID}</a>";
                         echo "<tr class='tab_bg_1'>";
                         if ($prem) {
                             echo "<td class='center top' rowspan='{$nb}'>" . $item->getTypeName($nb) . ($nb > 1 ? "&nbsp;:&nbsp;{$nb}</td>" : "</td>");
                         }
                         echo "<td class='center'>" . Dropdown::getDropdownName("glpi_entities", $data["entities_id"]) . "</td>";
                         echo "<td class='center";
                         echo (isset($data['is_deleted']) && $data['is_deleted'] ? " tab_bg_2_2'" : "'") . ">";
                         echo $name . "</td>";
                         echo "<td class='center'>" . (isset($data["serial"]) ? "" . $data["serial"] . "" : "-") . "</td>";
                         echo "<td class='center'>" . (isset($data["otherserial"]) ? "" . $data["otherserial"] . "" : "-") . "</td>";
                         echo "</tr>";
                     }
                 }
             }
             $num += $nb;
         }
     }
     echo "<tr class='tab_bg_2'>";
     echo "<td class='center'>" . ($num > 0 ? $LANG['common'][33] . "&nbsp;=&nbsp;{$num}" : "&nbsp;") . "</td>";
     echo "<td colspan='4'>&nbsp;</td></tr> ";
     echo "</table></div>";
 }
Example #6
0
 function showAndAddRuleForm($item)
 {
     global $LANG;
     $canedit = haveRight($this->right, "w");
     if ($canedit && $item->getType() == 'Entity') {
         $this->showNewRuleForm($item->getField('id'));
     }
     //Get all rules and actions
     $crit = array('field' => getForeignKeyFieldForTable($item->getTable()), 'value' => $item->getField('id'));
     $rules = $this->getRulesForCriteria($crit);
     echo "<div class='spaced'>";
     if (empty($rules)) {
         echo "<table class='tab_cadre_fixehov'>";
         echo "<tr><th>" . $LANG['search'][15] . "</th>";
         echo "</tr>\n";
         echo "</table>\n";
     } else {
         if ($canedit) {
             $formname = $item->getType() . "_" . $this->getType() . "_form";
             echo "\n<form name='{$formname}' id='{$formname}' method='post' " . "action='" . getItemTypeSearchURL(get_class($this)) . "'>";
         }
         echo "<table class='tab_cadre_fixehov'><tr>";
         if ($canedit) {
             echo "<th></th>";
         }
         echo "<th>" . $this->getTitle() . "</th>";
         echo "<th>" . $LANG['joblist'][6] . "</th>";
         echo "<th>" . $LANG['common'][60] . "</th>";
         echo "</tr>\n";
         initNavigateListItems(get_class($this), $item->getTypeName() . "=" . $item->getName());
         foreach ($rules as $rule) {
             addToNavigateListItems(get_class($this), $rule->fields["id"]);
             echo "<tr class='tab_bg_1'>";
             if ($canedit) {
                 echo "<td width='10'>";
                 echo "<input type='checkbox' name='item[" . $rule->fields["id"] . "]' value='1'>";
                 echo "</td>";
                 echo "<td><a href='" . getItemTypeFormURL(get_class($this)) . "?id=" . $rule->fields["id"] . "&amp;onglet=1'>" . $rule->fields["name"] . "</a></td>";
             } else {
                 echo "<td>" . $rule->fields["name"] . "</td>";
             }
             echo "<td>" . $rule->fields["description"] . "</td>";
             echo "<td>" . Dropdown::getYesNo($rule->fields["is_active"]) . "</td>";
             echo "</tr>\n";
         }
         echo "</table>\n";
         if ($canedit) {
             openArrowMassive($formname, true);
             echo "<input type='hidden' name='action' value='delete'>";
             closeArrowMassive('massiveaction', $LANG['buttons'][6]);
             echo "</form>";
         }
     }
     echo "</div>";
 }
 /**
  * Display a list to select a itemtype with link to search form
  *
  * @param $optgroup array (group of dropdown) of array (itemtype => localized name)
  */
 static function showItemTypeList($optgroup)
 {
     global $LANG;
     echo "<p><a href=\"javascript:showHideDiv('list_nav','img_nav','";
     echo GLPI_ROOT . "/pics/folder.png','" . GLPI_ROOT . "/pics/folder-open.png');\">";
     echo "<img alt='' name='img_nav' src=\"" . GLPI_ROOT . "/pics/folder.png\">&nbsp;";
     echo $LANG['buttons'][40] . "</a></p>";
     echo "<div id='list_nav' style='display:none;'>";
     $nb = 0;
     foreach ($optgroup as $label => $dp) {
         $nb += count($dp);
     }
     $step = $nb > 15 ? $nb / 3 : $nb;
     echo "<table><tr class='top'><td><table class='tab_cadre'>";
     $i = 1;
     foreach ($optgroup as $label => $dp) {
         echo "<tr><th>{$label}</th></tr>\n";
         foreach ($dp as $key => $val) {
             echo "<tr class='tab_bg_1'><td><a href='" . getItemTypeSearchURL($key) . "'>";
             echo "{$val}</a></td></tr>\n";
             $i++;
         }
         if ($i >= $step) {
             echo "</table></td><td width='25'>&nbsp;</td><td><table class='tab_cadre'>";
             $step += $step;
         }
     }
     echo "</table></td></tr></table></div>";
 }
Example #8
0
 /**
  * Print generic search form
  *
  * @param $itemtype type to display the form
  * @param $params parameters array may include field, contains, sort, is_deleted, link, link2,
  *                                             contains2, field2, type2
  *
  *@return nothing (displays)
  **/
 static function showGenericSearch($itemtype, $params)
 {
     global $LANG, $CFG_GLPI;
     // Default values of parameters
     $p['link'] = array();
     //
     $p['field'] = array();
     $p['contains'] = array();
     $p['searchtype'] = array();
     $p['sort'] = '';
     $p['is_deleted'] = 0;
     $p['link2'] = '';
     //
     $p['contains2'] = '';
     $p['field2'] = '';
     $p['itemtype2'] = '';
     $p['searchtype2'] = '';
     foreach ($params as $key => $val) {
         $p[$key] = $val;
     }
     $options = self::getCleanedOptions($itemtype);
     $target = getItemTypeSearchURL($itemtype);
     // Instanciate an object to access method
     $item = NULL;
     if ($itemtype != 'States' && class_exists($itemtype)) {
         $item = new $itemtype();
     }
     $linked = self::getMetaItemtypeAvailable($itemtype);
     echo "<form name='searchform{$itemtype}' method='get' action=\"{$target}\">";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>";
     echo "<table>";
     // Display normal search parameters
     for ($i = 0; $i < $_SESSION["glpisearchcount"][$itemtype]; $i++) {
         echo "<tr><td class='left' width='50%'>";
         // First line display add / delete images for normal and meta search items
         if ($i == 0) {
             echo "<input type='hidden' disabled id='add_search_count' name='add_search_count'\n                   value='1'>";
             echo "<a href='#' onClick = \"document.getElementById('add_search_count').disabled=false;\n                   document.forms['searchform{$itemtype}'].submit();\">";
             echo "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/plus.png\" alt='+' title=\"" . $LANG['search'][17] . "\"></a>&nbsp;&nbsp;&nbsp;&nbsp;";
             if ($_SESSION["glpisearchcount"][$itemtype] > 1) {
                 echo "<input type='hidden' disabled id='delete_search_count'\n                      name='delete_search_count' value='1'>";
                 echo "<a href='#' onClick = \"document.getElementById('delete_search_count').disabled=false;\n                      document.forms['searchform{$itemtype}'].submit();\">";
                 echo "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/moins.png\" alt='-' title=\"" . $LANG['search'][18] . "\"></a>&nbsp;&nbsp;&nbsp;&nbsp;";
             }
             if (is_array($linked) && count($linked) > 0) {
                 echo "<input type='hidden' disabled id='add_search_count2' name='add_search_count2'\n                      value='1'>";
                 echo "<a href='#' onClick=\"document.getElementById('add_search_count2').disabled=false;\n                      document.forms['searchform{$itemtype}'].submit();\">";
                 echo "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/meta_plus.png\" alt='+' title=\"" . $LANG['search'][19] . "\"></a>&nbsp;&nbsp;&nbsp;&nbsp;";
                 if ($_SESSION["glpisearchcount2"][$itemtype] > 0) {
                     echo "<input type='hidden' disabled id='delete_search_count2'\n                         name='delete_search_count2' value='1'>";
                     echo "<a href='#' onClick=\"document.getElementById('delete_search_count2').disabled=false;\n                         document.forms['searchform{$itemtype}'].submit();\">";
                     echo "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/meta_moins.png\" alt='-' title=\"" . $LANG['search'][20] . "\"></a>&nbsp;&nbsp;&nbsp;&nbsp;";
                 }
             }
             $itemtable = getTableForItemType($itemtype);
             if ($item && $item->maybeDeleted()) {
                 echo "<input type='hidden' id='is_deleted' name='is_deleted' value='" . $p['is_deleted'] . "'>";
                 echo "<a href='#' onClick = \"toogle('is_deleted','','','');\n                      document.forms['searchform{$itemtype}'].submit();\">\n                      <img src=\"" . $CFG_GLPI["root_doc"] . "/pics/showdeleted" . (!$p['is_deleted'] ? '_no' : '') . ".png\" name='img_deleted'  alt=\"" . (!$p['is_deleted'] ? $LANG['common'][3] : $LANG['common'][81]) . "\" title=\"" . (!$p['is_deleted'] ? $LANG['common'][3] : $LANG['common'][81]) . "\" ></a>";
                 // Dropdown::showYesNo("is_deleted",$p['is_deleted']);
                 echo '&nbsp;&nbsp;';
             }
         }
         // Display link item
         if ($i > 0) {
             echo "<select name='link[{$i}]'>";
             echo "<option value = 'AND' ";
             if (is_array($p["link"]) && isset($p["link"][$i]) && $p["link"][$i] == "AND") {
                 echo "selected";
             }
             echo ">AND</option>\n";
             echo "<option value='OR' ";
             if (is_array($p["link"]) && isset($p["link"][$i]) && $p["link"][$i] == "OR") {
                 echo "selected";
             }
             echo ">OR</option>\n";
             echo "<option value='AND NOT' ";
             if (is_array($p["link"]) && isset($p["link"][$i]) && $p["link"][$i] == "AND NOT") {
                 echo "selected";
             }
             echo ">AND NOT</option>\n";
             echo "<option value='OR NOT' ";
             if (is_array($p["link"]) && isset($p["link"][$i]) && $p["link"][$i] == "OR NOT") {
                 echo "selected";
             }
             echo ">OR NOT</option>";
             echo "</select>&nbsp;";
         }
         // display select box to define search item
         echo "<select id='Search{$itemtype}{$i}' name=\"field[{$i}]\" size='1'>";
         echo "<option value='view' ";
         if (is_array($p['field']) && isset($p['field'][$i]) && $p['field'][$i] == "view") {
             echo "selected";
         }
         echo ">" . $LANG['search'][11] . "</option>\n";
         reset($options);
         $first_group = true;
         $selected = 'view';
         $str_limit = 28;
         $nb_in_group = 0;
         $group = '';
         foreach ($options as $key => $val) {
             // print groups
             if (!is_array($val)) {
                 if (!$first_group) {
                     $group .= "</optgroup>\n";
                 } else {
                     $first_group = false;
                 }
                 if ($nb_in_group) {
                     echo $group;
                 }
                 $group = '';
                 $nb_in_group = 0;
                 $group .= "<optgroup label=\"" . utf8_substr($val, 0, $str_limit) . "\">";
             } else {
                 if (!isset($val['nosearch']) || $val['nosearch'] == false) {
                     $nb_in_group++;
                     $group .= "<option title=\"" . cleanInputText($val["name"]) . "\" value='{$key}'";
                     if (is_array($p['field']) && isset($p['field'][$i]) && $key == $p['field'][$i]) {
                         $group .= "selected";
                         $selected = $key;
                     }
                     $group .= ">" . utf8_substr($val["name"], 0, $str_limit) . "</option>\n";
                 }
             }
         }
         if (!$first_group) {
             $group .= "</optgroup>\n";
         }
         if ($nb_in_group) {
             echo $group;
         }
         echo "<option value='all' ";
         if (is_array($p['field']) && isset($p['field'][$i]) && $p['field'][$i] == "all") {
             echo "selected";
         }
         echo ">" . $LANG['common'][66] . "</option>";
         echo "</select>\n";
         echo "</td><td class='left'>";
         echo "<div id='SearchSpan{$itemtype}{$i}'>\n";
         $_POST['itemtype'] = $itemtype;
         $_POST['num'] = $i;
         $_POST['field'] = $selected;
         $_POST['searchtype'] = is_array($p['searchtype']) && isset($p['searchtype'][$i]) ? $p['searchtype'][$i] : "";
         $_POST['value'] = is_array($p['contains']) && isset($p['contains'][$i]) ? stripslashes($p['contains'][$i]) : "";
         include GLPI_ROOT . "/ajax/searchoption.php";
         echo "</div>\n";
         $params = array('field' => '__VALUE__', 'itemtype' => $itemtype, 'num' => $i, 'value' => $_POST["value"], 'searchtype' => $_POST["searchtype"]);
         ajaxUpdateItemOnSelectEvent("Search{$itemtype}{$i}", "SearchSpan{$itemtype}{$i}", $CFG_GLPI["root_doc"] . "/ajax/searchoption.php", $params, false);
         echo "</td></tr>\n";
     }
     $metanames = array();
     if (is_array($linked) && count($linked) > 0) {
         for ($i = 0; $i < $_SESSION["glpisearchcount2"][$itemtype]; $i++) {
             echo "<tr><td class='left' colspan='2'>";
             $rand = mt_rand();
             echo "<table width='100%'><tr class='left'><td width='35%'>";
             // Display link item (not for the first item)
             echo "<select name='link2[{$i}]'>";
             echo "<option value='AND' ";
             if (is_array($p['link2']) && isset($p['link2'][$i]) && $p['link2'][$i] == "AND") {
                 echo "selected";
             }
             echo ">AND</option>\n";
             echo "<option value='OR' ";
             if (is_array($p['link2']) && isset($p['link2'][$i]) && $p['link2'][$i] == "OR") {
                 echo "selected";
             }
             echo ">OR</option>\n";
             echo "<option value='AND NOT' ";
             if (is_array($p['link2']) && isset($p['link2'][$i]) && $p['link2'][$i] == "AND NOT") {
                 echo "selected";
             }
             echo ">AND NOT</option>\n";
             echo "<option value='OR NOT' ";
             if (is_array($p['link2']) && isset($p['link2'][$i]) && $p['link2'][$i] == "OR NOT") {
                 echo "selected";
             }
             echo ">OR NOT</option>\n";
             echo "</select>&nbsp;";
             // Display select of the linked item type available
             echo "<select name='itemtype2[{$i}]' id='itemtype2_" . $itemtype . "_" . $i . "_{$rand}'>";
             echo "<option value=''>" . DROPDOWN_EMPTY_VALUE . "</option>";
             foreach ($linked as $key) {
                 if (!isset($metanames[$key])) {
                     $linkitem = new $key();
                     $metanames[$key] = $linkitem->getTypeName();
                 }
                 echo "<option value='{$key}'>" . utf8_substr($metanames[$key], 0, 20) . "</option>\n";
             }
             echo "</select>&nbsp;";
             echo "</td><td>";
             // Ajax script for display search met& item
             echo "<span id='show_" . $itemtype . "_" . $i . "_{$rand}'>&nbsp;</span>\n";
             $params = array('itemtype' => '__VALUE__', 'num' => $i, 'field' => is_array($p['field2']) && isset($p['field2'][$i]) ? $p['field2'][$i] : "", 'value' => is_array($p['contains2']) && isset($p['contains2'][$i]) ? $p['contains2'][$i] : "", 'searchtype2' => is_array($p['searchtype2']) && isset($p['searchtype2'][$i]) ? $p['searchtype2'][$i] : "");
             ajaxUpdateItemOnSelectEvent("itemtype2_" . $itemtype . "_" . $i . "_{$rand}", "show_" . $itemtype . "_" . $i . "_{$rand}", $CFG_GLPI["root_doc"] . "/ajax/updateMetaSearch.php", $params, false);
             if (is_array($p['itemtype2']) && isset($p['itemtype2'][$i]) && !empty($p['itemtype2'][$i])) {
                 $params['itemtype'] = $p['itemtype2'][$i];
                 ajaxUpdateItem("show_" . $itemtype . "_" . $i . "_{$rand}", $CFG_GLPI["root_doc"] . "/ajax/updateMetaSearch.php", $params, false);
                 echo "<script type='text/javascript' >";
                 echo "window.document.getElementById('itemtype2_" . $itemtype . "_" . $i . "_{$rand}').value='" . $p['itemtype2'][$i] . "';";
                 echo "</script>\n";
             }
             echo "</td></tr></table>";
             echo "</td></tr>\n";
         }
     }
     echo "</table>\n";
     echo "</td>\n";
     echo "<td width='150px'>";
     echo "<table width='100%'>";
     // Display sort selection
     /*      echo "<tr><td colspan='2'>".$LANG['search'][4];
           echo "&nbsp;<select name='sort' size='1'>";
           reset($options);
           $first_group=true;
           foreach ($options as $key => $val) {
              if (!is_array($val)) {
                 if (!$first_group) {
                    echo "</optgroup>\n";
                 } else {
                    $first_group=false;
                 }
                 echo "<optgroup label=\"$val\">";
              } else {
                 echo "<option value='$key'";
                 if ($key == $p['sort']) {
                    echo " selected";
                 }
                 echo ">".utf8_substr($val["name"],0,20)."</option>\n";
              }
           }
           if (!$first_group) {
              echo "</optgroup>\n";
           }
           echo "</select> ";
           echo "</td></tr>\n";
     */
     // Display deleted selection
     echo "<tr>";
     // Display submit button
     echo "<td width='80' class='center'>";
     echo "<input type='submit' value=\"" . $LANG['buttons'][0] . "\" class='submit' >";
     echo "</td><td>";
     Bookmark::showSaveButton(BOOKMARK_SEARCH, $itemtype);
     echo "<a href='{$target}?reset=reset' >";
     echo "&nbsp;&nbsp;<img title=\"" . $LANG['buttons'][16] . "\" alt=\"" . $LANG['buttons'][16] . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/reset.png' class='calendrier'></a>";
     echo "</td></tr></table>\n";
     echo "</td></tr>";
     echo "</table>\n";
     // For dropdown
     echo "<input type='hidden' name='itemtype' value='{$itemtype}'>";
     // Reset to start when submit new search
     echo "<input type='hidden' name='start' value='0'>";
     echo "</form>";
 }
 /**
  * Get the search page URL for the current classe
  *
  * @param $full path or relative one
  **/
 function getSearchURL($full = true)
 {
     return getItemTypeSearchURL(get_class($this), $full);
 }
Example #10
0
// Original Author of file: Walid Nouh
// Purpose of file:
// ----------------------------------------------------------------------
define('GLPI_ROOT', '..');
include GLPI_ROOT . "/inc/includes.php";
commonHeader($LANG['common'][12], $_SERVER['PHP_SELF'], "admin", "rule", -1);
echo "<table class='tab_cadre'>";
echo "<tr><th>" . $LANG['rulesengine'][24] . "</th></tr>";
foreach ($CFG_GLPI["rulecollections_types"] as $rulecollectionclass) {
    $rulecollection = new $rulecollectionclass();
    if ($rulecollection->canList()) {
        if ($plug = isPluginItemType($rulecollectionclass)) {
            $function = 'plugin_version_' . strtolower($plug['plugin']);
            $plugname = $function();
            $title = $plugname['name'] . ' - ';
        } else {
            $title = '';
        }
        $title .= $rulecollection->getTitle();
        echo "<tr class='tab_bg_1'><td class='center b'>";
        echo "<a href='" . getItemTypeSearchURL($rulecollection->getRuleClassName()) . "'>";
        echo $title . "</a></td></tr>";
    }
}
if (haveRight("transfer", "r") && isMultiEntitiesMode()) {
    echo "<tr class='tab_bg_1'><td class='center b'>";
    echo "<a href='" . $CFG_GLPI['root_doc'] . "/front/transfer.php'>" . $LANG['transfer'][1] . "</a>";
    echo "</td></tr>";
}
echo "</table>";
commonFooter();
 /**
  *Print out list kb item
  *
  * @param $options : $_GET
  * @param $faq display on faq ?
  **/
 static function showList($options, $faq = 0)
 {
     global $DB, $LANG, $CFG_GLPI;
     // Default values of parameters
     $params["start"] = "0";
     $params["knowbaseitemcategories_id"] = "0";
     $params["contains"] = "";
     $params["target"] = $_SERVER['PHP_SELF'];
     if (is_array($options) && count($options)) {
         foreach ($options as $key => $val) {
             $params[$key] = $val;
         }
     }
     // Lists kb Items
     $where = "";
     $order = "";
     $score = "";
     // Build query
     if (getLoginUserID()) {
         $where = getEntitiesRestrictRequest("", "glpi_knowbaseitems", "", "", true) . " AND ";
     } else {
         // Anonymous access
         if (isMultiEntitiesMode()) {
             $where = " (`glpi_knowbaseitems`.`entities_id` = '0'\n                        AND `glpi_knowbaseitems`.`is_recursive` = '1')\n                        AND ";
         }
     }
     if ($faq) {
         // helpdesk
         $where .= " (`glpi_knowbaseitems`.`is_faq` = '1')\n                      AND ";
     }
     // a search with $contains
     if (strlen($params["contains"]) > 0) {
         $search = unclean_cross_side_scripting_deep($params["contains"]);
         $score = " ,MATCH(glpi_knowbaseitems.question, glpi_knowbaseitems.answer)\n                     AGAINST('{$search}' IN BOOLEAN MODE) AS SCORE ";
         $where_1 = $where . " MATCH(glpi_knowbaseitems.question, glpi_knowbaseitems.answer)\n                    AGAINST('{$search}' IN BOOLEAN MODE) ";
         $order = "ORDER BY `SCORE` DESC";
         // preliminar query to allow alternate search if no result with fulltext
         $query_1 = "SELECT COUNT(`id`)\n                     FROM `glpi_knowbaseitems`\n                     WHERE {$where_1}";
         $result_1 = $DB->query($query_1);
         $numrows_1 = $DB->result($result_1, 0, 0);
         if ($numrows_1 <= 0) {
             // not result this fulltext try with alternate search
             $search1 = array('/\\\\"/', "/\\+/", "/\\*/", "/~/", "/</", "/>/", "/\\(/", "/\\)/", "/\\-/");
             $contains = preg_replace($search1, "", $params["contains"]);
             $where .= " (`glpi_knowbaseitems`.`question` " . makeTextSearch($contains) . "\n                         OR `glpi_knowbaseitems`.`answer` " . makeTextSearch($contains) . ")";
         } else {
             $where = $where_1;
         }
     } else {
         // no search -> browse by category
         $where .= " (`glpi_knowbaseitems`.`knowbaseitemcategories_id`\n                        = '" . $params["knowbaseitemcategories_id"] . "')";
         $order = " ORDER BY `glpi_knowbaseitems`.`question` ASC";
     }
     if (!$params["start"]) {
         $params["start"] = 0;
     }
     $query = "SELECT `glpi_knowbaseitems`.*,\n                       `glpi_knowbaseitemcategories`.`completename` AS category\n                       {$score}\n                FROM `glpi_knowbaseitems`\n                LEFT JOIN `glpi_knowbaseitemcategories`\n                     ON (`glpi_knowbaseitemcategories`.`id`\n                           = `glpi_knowbaseitems`.`knowbaseitemcategories_id`)\n                WHERE {$where}\n                {$order}";
     // Get it from database
     if ($result = $DB->query($query)) {
         $KbCategory = new KnowbaseItemCategory();
         $title = "";
         if ($KbCategory->getFromDB($params["knowbaseitemcategories_id"])) {
             $title = $LANG['common'][36] . " = " . (empty($KbCategory->fields['name']) ? "(" . $params['knowbaseitemcategories_id'] . ")" : $KbCategory->fields['name']);
         }
         initNavigateListItems('KnowbaseItem', $title);
         $numrows = $DB->numrows($result);
         $list_limit = $_SESSION['glpilist_limit'];
         // Limit the result, if no limit applies, use prior result
         if ($numrows > $list_limit && !isset($_GET['export_all'])) {
             $query_limit = $query . " LIMIT " . intval($params["start"]) . ", " . intval($list_limit) . " ";
             $result_limit = $DB->query($query_limit);
             $numrows_limit = $DB->numrows($result_limit);
         } else {
             $numrows_limit = $numrows;
             $result_limit = $result;
         }
         if ($numrows_limit > 0) {
             // Set display type for export if define
             $output_type = HTML_OUTPUT;
             if (isset($_GET["display_type"])) {
                 $output_type = $_GET["display_type"];
             }
             // Pager
             $parameters = "start=" . $params["start"] . "&amp;knowbaseitemcategories_id=" . $params['knowbaseitemcategories_id'] . "&amp;contains=" . $params["contains"] . "&amp;is_faq={$faq}";
             if (isset($options['tickets_id'])) {
                 $parameters .= "&amp;tickets_id=" . $options['tickets_id'];
             }
             if ($output_type == HTML_OUTPUT) {
                 printPager($params['start'], $numrows, getItemTypeSearchURL('KnowbaseItem'), $parameters, 'KnowbaseItem');
             }
             $nbcols = 1;
             // Display List Header
             echo Search::showHeader($output_type, $numrows_limit + 1, $nbcols);
             $header_num = 1;
             echo Search::showHeaderItem($output_type, $LANG['knowbase'][14], $header_num);
             if ($output_type != HTML_OUTPUT) {
                 echo Search::showHeaderItem($output_type, $LANG['knowbase'][15], $header_num);
             }
             echo Search::showHeaderItem($output_type, $LANG['common'][36], $header_num);
             if (isset($options['tickets_id']) && $output_type == HTML_OUTPUT) {
                 echo Search::showHeaderItem($output_type, '&nbsp;', $header_num);
             }
             // Num of the row (1=header_line)
             $row_num = 1;
             for ($i = 0; $i < $numrows_limit; $i++) {
                 $data = $DB->fetch_array($result_limit);
                 addToNavigateListItems('KnowbaseItem', $data["id"]);
                 // Column num
                 $item_num = 1;
                 $row_num++;
                 echo Search::showNewLine($output_type, $i % 2);
                 if ($output_type == HTML_OUTPUT) {
                     if (isset($options['tickets_id'])) {
                         $href = " href='#' onClick=\"var w = window.open('" . $CFG_GLPI["root_doc"] . "/front/popup.php?popup=show_kb&amp;id=" . $data['id'] . "' ,'glpipopup', " . "'height=400, width=1000, top=100, left=100, scrollbars=yes' );w.focus();\"";
                     } else {
                         $href = " href=\"" . $params['target'] . "?id=" . $data["id"] . "\" ";
                     }
                     echo Search::showItem($output_type, "<div class='kb'><a " . ($data['is_faq'] ? " class='pubfaq' " : " class='knowbase' ") . " {$href}>" . resume_text($data["question"], 80) . "</a></div>\n                                          <div class='kb_resume'>" . resume_text(html_clean(unclean_cross_side_scripting_deep($data["answer"])), 600) . "</div>", $item_num, $row_num);
                 } else {
                     echo Search::showItem($output_type, $data["question"], $item_num, $row_num);
                     echo Search::showItem($output_type, html_clean(unclean_cross_side_scripting_deep(html_entity_decode($data["answer"], ENT_QUOTES, "UTF-8"))), $item_num, $row_num);
                 }
                 echo Search::showItem($output_type, $data["category"], $item_num, $row_num);
                 if (isset($options['tickets_id']) && $output_type == HTML_OUTPUT) {
                     $content = "<a href='" . $CFG_GLPI['root_doc'] . "/front/ticket.form.php?load_kb_sol=" . $data['id'] . "&amp;id=" . $options['tickets_id'] . "&amp;forcetab=4'>" . $LANG['job'][24] . "</a>";
                     echo Search::showItem($output_type, $content, $item_num, $row_num);
                 }
                 // End Line
                 echo Search::showEndLine($output_type);
             }
             // Display footer
             if ($output_type == PDF_OUTPUT_LANDSCAPE || $output_type == PDF_OUTPUT_PORTRAIT) {
                 echo Search::showFooter($output_type, Dropdown::getDropdownName("glpi_knowbaseitemcategories", $params['knowbaseitemcategories_id']));
             } else {
                 echo Search::showFooter($output_type);
             }
             echo "<br>";
             if ($output_type == HTML_OUTPUT) {
                 printPager($params['start'], $numrows, getItemTypeSearchURL('KnowbaseItem'), $parameters, 'KnowbaseItem');
             }
         } else {
             if ($params["knowbaseitemcategories_id"] != 0) {
                 echo "<div class='center b'>" . $LANG['search'][15] . "</div>";
             }
         }
     }
 }
 /**
  * Print the HTML array for Items linked to current contract
  *
  *@return Nothing (display)
  *
  **/
 function showItems()
 {
     global $DB, $CFG_GLPI, $LANG;
     $instID = $this->fields['id'];
     if (!$this->can($instID, 'r')) {
         return false;
     }
     $canedit = $this->can($instID, 'w');
     $rand = mt_rand();
     $query = "SELECT DISTINCT `itemtype`\n                FROM `glpi_contracts_items`\n                WHERE `glpi_contracts_items`.`contracts_id` = '{$instID}'\n                ORDER BY `itemtype`";
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     echo "<div class='center'><table class='tab_cadre_fixe'>";
     echo "<tr><th colspan='5'>";
     if ($DB->numrows($result) == 0) {
         echo $LANG['document'][13];
     } else {
         echo $LANG['document'][19];
     }
     echo "</th></tr>";
     if ($canedit) {
         echo "</table></div>";
         echo "<form method='post' name='contract_form{$rand}' id='contract_form{$rand}' action=\"" . $CFG_GLPI["root_doc"] . "/front/contract.form.php\">";
         echo "<div class='spaced'>";
         echo "<table class='tab_cadre_fixe'>";
         // massive action checkbox
         echo "<tr><th>&nbsp;</th>";
     } else {
         echo "<tr>";
     }
     echo "<th>" . $LANG['common'][17] . "</th>";
     echo "<th>" . $LANG['entity'][0] . "</th>";
     echo "<th>" . $LANG['common'][16] . "</th>";
     echo "<th>" . $LANG['common'][19] . "</th>";
     echo "<th>" . $LANG['common'][20] . "</th></tr>";
     $totalnb = 0;
     for ($i = 0; $i < $number; $i++) {
         $itemtype = $DB->result($result, $i, "itemtype");
         if (!class_exists($itemtype)) {
             continue;
         }
         $item = new $itemtype();
         if ($item->canView()) {
             $itemtable = getTableForItemType($itemtype);
             $query = "SELECT `{$itemtable}`.*,\n                             `glpi_contracts_items`.`id` AS IDD,\n                             `glpi_entities`.`id` AS entity\n                      FROM `glpi_contracts_items`,\n                           `{$itemtable}`";
             if ($itemtype != 'Entity') {
                 $query .= " LEFT JOIN `glpi_entities`\n                                 ON (`{$itemtable}`.`entities_id`=`glpi_entities`.`id`) ";
             }
             $query .= " WHERE `{$itemtable}`.`id` = `glpi_contracts_items`.`items_id`\n                              AND `glpi_contracts_items`.`itemtype` = '{$itemtype}'\n                              AND `glpi_contracts_items`.`contracts_id` = '{$instID}'";
             if ($item->maybeTemplate()) {
                 $query .= " AND `{$itemtable}`.`is_template` = '0'";
             }
             $query .= getEntitiesRestrictRequest(" AND", $itemtable, '', '', $item->maybeRecursive()) . "\n                      ORDER BY `glpi_entities`.`completename`, `{$itemtable}`.`name`";
             $result_linked = $DB->query($query);
             $nb = $DB->numrows($result_linked);
             if ($nb > $_SESSION['glpilist_limit']) {
                 echo "<tr class='tab_bg_1'>";
                 if ($canedit) {
                     echo "<td>&nbsp;</td>";
                 }
                 echo "<td class='center'>" . $item->getTypeName() . "&nbsp;:&nbsp;{$nb}</td>";
                 echo "<td class='center' colspan='2'>";
                 echo "<a href='" . getItemTypeSearchURL($itemtype) . "?" . rawurlencode("contains[0]") . "=" . rawurlencode('$$$$' . $instID) . "&amp;" . rawurlencode("field[0]") . "=29&amp;sort=80&amp;order=ASC&amp;is_deleted=0" . "&amp;start=0" . "'>" . $LANG['reports'][57] . "</a></td>";
                 echo "<td class='center'>-</td><td class='center'>-</td></tr>";
             } else {
                 if ($nb > 0) {
                     for ($prem = true; $data = $DB->fetch_assoc($result_linked); $prem = false) {
                         $ID = "";
                         if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) {
                             $ID = " (" . $data["id"] . ")";
                         }
                         $link = getItemTypeFormURL($itemtype);
                         $name = "<a href=\"" . $link . "?id=" . $data["id"] . "\">" . $data["name"] . "{$ID}</a>";
                         echo "<tr class='tab_bg_1'>";
                         if ($canedit) {
                             $sel = "";
                             if (isset($_GET["select"]) && $_GET["select"] == "all") {
                                 $sel = "checked";
                             }
                             echo "<td width='10'>";
                             echo "<input type='checkbox' name='item[" . $data["IDD"] . "]' value='1' {$sel}></td>";
                         }
                         if ($prem) {
                             echo "<td class='center top' rowspan='{$nb}'>" . $item->getTypeName() . ($nb > 1 ? "&nbsp;:&nbsp;{$nb}</td>" : "</td>");
                         }
                         echo "<td class='center'>";
                         echo Dropdown::getDropdownName("glpi_entities", $data['entity']) . "</td>";
                         echo "<td class='center" . (isset($data['is_deleted']) && $data['is_deleted'] ? " tab_bg_2_2'" : "'");
                         echo ">" . $name . "</td>";
                         echo "<td class='center'>" . (isset($data["serial"]) ? "" . $data["serial"] . "" : "-") . "</td>";
                         echo "<td class='center'>" . (isset($data["otherserial"]) ? "" . $data["otherserial"] . "" : "-") . "</td>";
                         echo "</tr>";
                     }
                 }
             }
             $totalnb += $nb;
         }
     }
     echo "<tr class='tab_bg_2'>";
     echo "<td class='center' colspan='2'>" . ($totalnb > 0 ? $LANG['common'][33] . "&nbsp;=&nbsp;{$totalnb}</td>" : "&nbsp;</td>");
     echo "<td colspan='4'>&nbsp;</td></tr> ";
     if ($canedit) {
         if ($this->fields['max_links_allowed'] == 0 || $this->fields['max_links_allowed'] > $totalnb) {
             echo "<tr class='tab_bg_1'><td colspan='4' class='right'>";
             Dropdown::showAllItems("items_id", 0, 0, $this->fields['is_recursive'] ? -1 : $this->fields['entities_id'], $CFG_GLPI["contract_types"]);
             echo "</td><td class='center'>";
             echo "<input type='submit' name='additem' value=\"" . $LANG['buttons'][8] . "\"\n                   class='submit'>";
             echo "</td><td>&nbsp;</td></tr>";
         }
         echo "</table>";
         openArrowMassive("contract_form{$rand}", true);
         echo "<input type='hidden' name='contracts_id' value='{$instID}'>";
         closeArrowMassive('deleteitem', $LANG['buttons'][6]);
     } else {
         echo "</table>";
     }
     echo "</div></form>";
 }