function showForm($p_target, $p_itemtype, $p_items_id) { global $DB, $LANG, $SEARCH_OPTION; echo "<div width='50%'>"; $lockable_fields = PluginFusioninventoryLockable::getLockableFields('', $p_itemtype); $locked = PluginFusioninventoryLock::getLockFields($p_itemtype, $p_items_id); if (count($locked)) { foreach ($locked as $key => $val) { if (!in_array($val, $lockable_fields)) { unset($locked[$key]); } } } else { $locked = array(); } include_once GLPI_ROOT . '/plugins/fusioninventory/inc_constants/mapping.fields.constant.php'; $CommonItem = new CommonItem(); $CommonItem->getFromDB($p_itemtype, $p_items_id); echo "<form method='post' action=\"{$p_target}\">"; echo "<input type='hidden' name='ID' value='{$p_items_id}'>"; echo "<input type='hidden' name='type' value='{$p_itemtype}'>"; echo "<table class='tab_cadre'>"; echo "<tr><th> " . $LANG['plugin_fusioninventory']["functionalities"][73] . " </th>"; echo "<th> " . $LANG['plugin_fusioninventory']["functionalities"][74] . " </th>"; echo "<th> " . $LANG['plugin_fusioninventory']["functionalities"][75] . " </th></tr>"; foreach ($lockable_fields as $key => $val) { if (in_array($val, $locked)) { $checked = 'checked'; } else { $checked = ''; } echo "<tr class='tab_bg_1'><td>" . $FUSIONINVENTORY_MAPPING_FIELDS[$val] . "</td>\n <td>" . $CommonItem->getField($val) . "</td><td align='center'><input type='checkbox' name='lockfield_fusioninventory[" . $val . "]' {$checked}></td></tr>"; } echo "<tr class='tab_bg_2'><td align='center' colspan='3'>\n <input class='submit' type='submit' name='unlock_field_fusioninventory'\n value='" . $LANG['buttons'][7] . "'></td></tr>"; echo "</table>"; echo "</form>"; echo "</div>"; }
function showForm($target, $ID = '') { global $DB, $CFG_GLPI, $LANG; PluginFusioninventoryAuth::checkRight("snmp_networking", "r"); $CommonItem = new CommonItem(); if ($ID != '') { $this->getFromDB($ID); } else { $this->getEmpty(); } echo "<div align='center'><form method='post' name='' id='' action=\"" . $target . "\">"; echo "<table class='tab_cadre_fixe'>"; echo "<tr><th colspan='4'>"; echo $LANG['plugin_fusioninventory']["menu"][4] . " ( " . $LANG['plugin_fusioninventory']["unknown"][3] . " "; $CommonItem->getFromDB(PLUGIN_FUSIONINVENTORY_SNMP_AGENTS, $this->fields["FK_agent"]); echo $CommonItem->getLink(1); echo ") :</th></tr>"; $datestring = $LANG["common"][26] . ": "; $date = convDateTime($this->fields["date_mod"]); echo "<tr>"; echo "<th align='center' width='450' colspan='2'>"; echo $LANG["common"][2] . " " . $this->fields["ID"]; echo "</th>"; echo "<th align='center' colspan='2' width='50'>"; echo $datestring . $date; echo "</th>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td align='center'>" . $LANG["common"][16] . " :</td>"; echo "<td align='center'>"; echo "<input type='text' name='name' value='" . $this->fields["name"] . "' size='35'/>"; echo "</td>"; if (isMultiEntitiesMode()) { echo "<td align='center'>" . $LANG['entity'][0] . " : </td>"; echo "</td>"; echo "<td align='center'>"; Dropdown::show("Entity", array('name' => 'FK_entities', 'value' => $this->fields["FK_entities"])); echo "</td>"; echo "</tr>"; echo "</tr>"; } else { echo "<td align='center'></td>"; echo "</td>"; echo "<td align='center'></td>"; echo "</tr>"; echo "</tr>"; } echo "<tr class='tab_bg_1'>"; echo "<td align='center'>" . $LANG['plugin_fusioninventory']["unknown"][0] . " :</td>"; echo "<td align='center'>"; echo "<input type='text' name='dnsname' value='" . $this->fields["dnsname"] . "' size='35'/>"; echo "</td>"; echo "<td align='center'>" . $LANG['common'][18] . " : </td>"; echo "</td>"; echo "<td align='center'>"; echo "<input type='text' name='contact' value='" . $this->fields["contact"] . "' size='35'/>"; echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td align='center'>" . $LANG['common'][17] . " :</td>"; echo "<td align='center'>"; $type_list[] = COMPUTER_TYPE; $type_list[] = NETWORKING_TYPE; $type_list[] = PRINTER_TYPE; $type_list[] = PERIPHERAL_TYPE; $type_list[] = PHONE_TYPE; // GENERIC OBJECT : Search types in generic object $plugin = new Plugin(); if ($plugin->isActivated('genericobject')) { if (TableExists("glpi_plugin_genericobject_types")) { $query = "SELECT * FROM `glpi_plugin_genericobject_types`\n WHERE `status`='1' "; if ($result = $DB->query($query)) { while ($data = $DB->fetch_array($result)) { $type_list[] = $data['device_type']; } } } } // END GENERIC OBJECT Device::dropdownTypes('type', $this->fields["type"], $type_list); echo "</td>"; echo "<td align='center'>" . $LANG['setup'][89] . " : </td>"; echo "</td>"; echo "<td align='center'>"; Dropdown::show("Domain", array('name' => "domain", 'value' => $this->fields["domain"])); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td align='center'>" . $LANG['common'][15] . " :</td>"; echo "<td align='center'>"; Dropdown::show("Location", array('name' => "location", 'value' => $this->fields["location"])); echo "</td>"; echo "<td align='center'>" . $LANG['common'][19] . " : </td>"; echo "</td>"; echo "<td align='center'>"; echo "<input type='text' name='serial' value='" . $this->fields["serial"] . "' size='35'/>"; echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td align='center'>" . $LANG['plugin_fusioninventory']["unknown"][2] . " :</td>"; echo "<td align='center'>"; Dropdown::showYesNo("accepted", $this->fields["accepted"]); echo "</td>"; echo "<td align='center'>" . $LANG['common'][20] . " : </td>"; echo "</td>"; echo "<td align='center'>"; echo "<input type='text' name='otherserial' value='" . $this->fields["otherserial"] . "' size='35'/>"; echo "</td>"; echo "</tr>"; if (!empty($this->fields["ifaddr"]) or !empty($this->fields["ifmac"])) { echo "<tr class='tab_bg_1'>"; echo "<td align='center'>" . $LANG['networking'][14] . " :</td>"; echo "<td align='center'>"; echo "<input type='text' name='otherserial' value='" . $this->fields["ifaddr"] . "' size='35'/>"; echo "</td>"; echo "<td align='center'>" . $LANG['networking'][15] . " : </td>"; echo "</td>"; echo "<td align='center'>"; echo "<input type='text' name='otherserial' value='" . $this->fields["ifmac"] . "' size='35'/>"; echo "</td>"; echo "</tr>"; } echo "<tr class='tab_bg_1'>"; echo "<td align='center'>" . $LANG['plugin_fusioninventory']["functionalities"][3] . " :</td>"; echo "<td align='center'>"; Dropdown::showYesNo("snmp", $this->fields["snmp"]); echo "</td>"; if ($this->fields["snmp"] == "1") { echo "<td align='center'>" . $LANG['plugin_fusioninventory']["model_info"][4] . " : </td>"; echo "</td>"; echo "<td align='center'>"; Dropdown::show("PluginFusioninventoryModelInfos", array('name' => "FK_model_infos", 'value' => $this->fields["FK_model_infos"])); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td align='center'>" . $LANG['plugin_fusioninventory']["model_info"][3] . " :</td>"; echo "<td align='center'>"; Dropdown::show("PluginFusioninventorySnmpauth", array('name' => "FK_snmp_connection", 'value' => $this->fields["FK_snmp_connection"])); echo "</td>"; } echo "<td align='center'>" . $LANG['common'][25] . " : </td>"; echo "</td>"; echo "<td align='middle'>"; echo "<textarea cols='50' rows='5' name='comments' >" . $this->fields["comments"] . "</textarea>"; echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td align='center'>" . $LANG['plugin_fusioninventory']["unknown"][4] . " :</td>"; echo "<td align='center'>"; echo Dropdown::getYesNo($this->fields["hub"]); echo "</td>"; echo "<td align='center' colspan='2'></td>"; echo "</tr>"; echo "<tr>"; echo "<td class='tab_bg_2' align='center' colspan='4'>\n"; echo "<table width='100%'>"; echo "<tr>"; echo "<td width='33%' align='center'>"; echo "<input type='hidden' name='ID' value={$ID}>"; echo "<input type='submit' name='import' value=\"" . $LANG['buttons'][37] . "\" class='submit'>"; echo "</td>"; echo "<td width='33%' align='center'>"; echo "<input type='hidden' name='ID' value={$ID}>"; echo "<input type='submit' name='update' value=\"" . $LANG['buttons'][7] . "\" class='submit'>"; echo "</td>"; echo "<td width='33%' align='center'>"; echo "<input type='hidden' name='ID' value={$ID}>"; echo "<div class='center'>"; if (PluginFusioninventory::haveRight("unknowndevices", "w")) { if (!$this->fields["deleted"]) { echo "<input type='submit' name='delete' value=\"" . $LANG['buttons'][6] . "\" class='submit'>"; } else { echo "<input type='submit' name='restore' value=\"" . $LANG['buttons'][21] . "\" class='submit'>"; echo " <input type='submit' name='purge' value=\"" . $LANG['buttons'][22] . "\" class='submit'>"; } } echo "</div>"; echo "</td>"; echo "</tr>"; echo "</table>"; echo "</td>"; echo "</tr>"; echo "</table></form></div>"; }
function showForm($input = '') { global $DB, $LANG, $CFG_GLPI, $INFOFORM_PAGES; $CommonItem = new CommonItem(); $np = new Netport(); echo "<table class='tab_cadre' cellpadding='5' width='950'>"; echo "<tr class='tab_bg_1'>"; echo "<th>"; echo $LANG['plugin_fusioninventory']["processes"][1]; echo " <a href='" . GLPI_ROOT . "/plugins/fusioninventory/front/agents.processes.form.php'>(" . $LANG['common'][66] . ")</a>"; echo "</th>"; echo "<th>"; echo $LANG['common'][27]; echo "</th>"; echo "<th>"; echo $LANG['common'][1]; echo "</th>"; echo "<th>"; echo $LANG['joblist'][0]; echo "</th>"; echo "<th>"; echo $LANG['common'][1]; echo "</th>"; echo "</tr>"; if (!isset($input['process_number'])) { $condition = ''; } else { $condition = "WHERE `process_number`='" . $input['process_number'] . "'"; if (isset($input['created'])) { $condition .= " AND `creation`='" . $input['created'] . "' "; } } $query = "SELECT * FROM `" . $this->table . "`\n " . $condition . "\n ORDER BY `date`DESC , `process_number` DESC"; if ($result = $DB->query($query)) { while ($data = $DB->fetch_array($result)) { echo "<tr class='tab_bg_1 center'>"; echo "<td>"; echo "<a href='" . GLPI_ROOT . "/plugins/fusioninventory/front/agents.processes.form.php?h_process_number=" . $data['process_number'] . "'>" . $data['process_number'] . "</a>"; echo "</td>"; echo "<td>"; echo convDateTime($data['date']); echo "</td>"; echo "<td>"; $np->getFromDB($data['FK_port_source']); $CommonItem->getFromDB($np->fields["device_type"], $np->fields["on_device"]); $link1 = $CommonItem->getLink(1); $link = "<a href=\"" . $CFG_GLPI["root_doc"] . "/front/networking.port.php?ID=" . $np->fields["ID"] . "\">"; if (rtrim($np->fields["name"]) != "") { $link .= $np->fields["name"]; } else { $link .= $LANG['common'][0]; } $link .= "</a>"; echo $link . " " . $LANG['networking'][25] . " " . $link1; echo "</td>"; echo "<td>"; if ($data['creation'] == '1') { echo "<img src='" . GLPI_ROOT . "/plugins/fusioninventory/pics/connection_ok.png'/>"; } else { echo "<img src='" . GLPI_ROOT . "/plugins/fusioninventory/pics/connection_notok.png'/>"; } echo "</td>"; echo "<td>"; $np->getFromDB($data['FK_port_destination']); $CommonItem->getFromDB($np->fields["device_type"], $np->fields["on_device"]); $link1 = $CommonItem->getLink(1); $link = "<a href=\"" . $CFG_GLPI["root_doc"] . "/front/networking.port.php?ID=" . $np->fields["ID"] . "\">"; if (rtrim($np->fields["name"]) != "") { $link .= $np->fields["name"]; } else { $link .= $LANG['common'][0]; } $link .= "</a>"; echo $link . " " . $LANG['networking'][25] . " " . $link1; echo "</td>"; echo "</tr>"; } } echo "</table>"; }
function showForm($target, $ID = '') { global $DB, $CFG_GLPI, $LANG; if ($ID != '') { $this->getFromDB($ID); } else { $this->getEmpty(); } $CommonItem = new CommonItem(); $ptcm = new PluginFusioninventoryConfigModules(); echo "<div align='center'><form method='post' name='' id='' action=\"" . $target . "\">"; echo "<table class='tab_cadre' cellpadding='5' width='950'>"; echo "<tr>"; echo "<th colspan='4'>"; echo $LANG['plugin_fusioninventory']["agents"][0]; echo " :</th>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG["common"][16] . " :</td>"; echo "<td align='center'>"; echo "<input type='text' name='name' size='40' value='" . $this->fields["name"] . "'/>"; echo "</td>"; if ($ptcm->getValue('inventoryocs') == "1") { echo "<td>" . $LANG['plugin_fusioninventory']['config'][3] . " :</td>"; echo "<td align='center'>"; Dropdown::showYesNo("module_inventory", $this->fields["module_inventory"]); echo "</td>"; } else { echo "<td colspan='2'></td>"; } echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['plugin_fusioninventory']["agents"][5] . " :</td>"; echo "<td align='center'>"; echo $this->fields["fusioninventory_agent_version"]; echo "</td>"; if ($ptcm->getValue('netdiscovery') == "1") { echo "<td>" . $LANG['plugin_fusioninventory']['config'][4] . " :</td>"; echo "<td align='center'>"; Dropdown::showYesNo("module_netdiscovery", $this->fields["module_netdiscovery"]); echo "</td>"; } else { echo "<td colspan='2'></td>"; } echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['plugin_fusioninventory']["agents"][6] . " :</td>"; echo "<td align='center'>"; Dropdown::showYesNo("lock", $this->fields["lock"]); echo "</td>"; if ($ptcm->getValue('snmp') == "1") { echo "<td>" . $LANG['plugin_fusioninventory']['config'][7] . " :</td>"; echo "<td align='center'>"; Dropdown::showYesNo("module_snmpquery", $this->fields["module_snmpquery"]); echo "</td>"; } else { echo "<td colspan='2'></td>"; } echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['plugin_fusioninventory']["agents"][23] . " :</td>"; echo "<td align='center'>"; if ($this->fields["on_device"] != "0" and $this->fields["on_device"] != "") { $CommonItem->getFromDB(COMPUTER_TYPE, $this->fields["on_device"]); echo $CommonItem->getLink(1); echo "<input type='hidden' name='on_device' value='" . $this->fields["on_device"] . "'/>"; } else { Computer_Item::dropdownConnect(COMPUTER_TYPE, COMPUTER_TYPE, 'on_device', $_SESSION['glpiactive_entity']); } echo "</td>"; if ($ptcm->getValue('wol') == "1") { echo "<td>" . $LANG['plugin_fusioninventory']['config'][6] . " :</td>"; echo "<td align='center'>"; Dropdown::showYesNo("module_wakeonlan", $this->fields["module_wakeonlan"]); echo "</td>"; } else { echo "<td colspan='2'></td>"; } echo "<tr class='tab_bg_1'>"; echo "<td>Token :</td>"; echo "<td align='center' colspan='3'>"; echo $this->fields["token"]; echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_2'>"; if (PluginFusioninventory::haveRight("agents", "w")) { if ($ID == '') { echo "<td align='center' colspan='4'>"; echo "<div align='center'><input type='submit' name='add' value=\"" . $LANG["buttons"][8] . "\" class='submit' >"; echo "</td>"; } else { echo "<td align='center' colspan='2'>"; echo "<input type='hidden' name='ID' value='" . $ID . "'/>"; echo "<div align='center'><input type='submit' name='update' value=\"" . $LANG["buttons"][7] . "\" class='submit' >"; echo "</td>"; echo "<td align='center' colspan='2'>"; echo "<input type='submit' name='delete' value=\"" . $LANG["buttons"][6] . "\" class='submit'>"; echo "</td>"; } } echo "</tr>"; echo "</table></form></div>"; }
static function showHistory($ID_port) { global $DB, $LANG, $INFOFORM_PAGES, $CFG_GLPI; include GLPI_ROOT . "/plugins/fusioninventory/inc_constants/snmp.mapping.constant.php"; $CommonItem = new CommonItem(); $np = new Netport(); $query = "\n SELECT * FROM(\n SELECT * FROM (\n SELECT ID, date as date, process_number as process_number,\n FK_port_source, FK_port_destination,\n creation as Field, NULL as old_value, NULL as new_value\n\n FROM glpi_plugin_fusioninventory_snmphistoryconnections\n WHERE `FK_port_source`='" . $ID_port . "'\n OR `FK_port_destination`='" . $ID_port . "'\n ORDER BY date DESC\n LIMIT 0,30\n )\n AS DerivedTable1\n UNION ALL\n SELECT * FROM (\n SELECT ID, date_mod as date, FK_process as process_number,\n FK_ports AS FK_port_source, NULL as FK_port_destination,\n Field, old_value, new_value\n\n FROM glpi_plugin_fusioninventory_snmphistories\n WHERE `FK_ports`='" . $ID_port . "'\n ORDER BY date DESC\n LIMIT 0,30\n )\n AS DerivedTable2)\n AS MainTable\n ORDER BY date DESC, ID DESC\n LIMIT 0,30"; //echo $query."<br/>"; $text = "<table class='tab_cadre' cellpadding='5' width='950'>"; $text .= "<tr class='tab_bg_1'>"; $text .= "<th colspan='8'>"; $text .= "Historique"; $text .= "</th>"; $text .= "</tr>"; $text .= "<tr class='tab_bg_1'>"; $text .= "<th>" . $LANG['plugin_fusioninventory']["snmp"][50] . "</th>"; $text .= "<th>" . $LANG["common"][1] . "</th>"; $text .= "<th>" . $LANG["event"][18] . "</th>"; $text .= "<th></th>"; $text .= "<th></th>"; $text .= "<th></th>"; $text .= "<th>" . $LANG["common"][27] . "</th>"; $text .= "</tr>"; if ($result = $DB->query($query)) { while ($data = $DB->fetch_array($result)) { $text .= "<tr class='tab_bg_1'>"; if (!empty($data["FK_port_destination"])) { // Connections and disconnections if ($data['Field'] == '1') { $text .= "<td align='center'><img src='" . GLPI_ROOT . "/plugins/fusioninventory/pics/connection_ok.png'/></td>"; } else { $text .= "<td align='center'><img src='" . GLPI_ROOT . "/plugins/fusioninventory/pics/connection_notok.png'/></td>"; } if ($ID_port == $data["FK_port_source"]) { $np->getFromDB($data["FK_port_destination"]); if (isset($np->fields["on_device"])) { $CommonItem->getFromDB($np->fields["device_type"], $np->fields["on_device"]); $link1 = $CommonItem->getLink(1); $link = "<a href=\"" . $CFG_GLPI["root_doc"] . "/front/networking.port.php?ID=" . $np->fields["ID"] . "\">"; if (rtrim($np->fields["name"]) != "") { $link .= $np->fields["name"]; } else { $link .= $LANG['common'][0]; } $link .= "</a>"; $text .= "<td align='center'>" . $link . " " . $LANG['networking'][25] . " " . $link1 . "</td>"; } else { $text .= "<td align='center'><font color='#ff0000'>" . $LANG['common'][28] . "</font></td>"; } } else { if ($ID_port == $data["FK_port_destination"]) { $np->getFromDB($data["FK_port_source"]); if (isset($np->fields["on_device"])) { $CommonItem->getFromDB($np->fields["device_type"], $np->fields["on_device"]); $link1 = $CommonItem->getLink(1); $link = "<a href=\"" . $CFG_GLPI["root_doc"] . "/front/networking.port.php?ID=" . $np->fields["ID"] . "\">"; if (rtrim($np->fields["name"]) != "") { $link .= $np->fields["name"]; } else { $link .= $LANG['common'][0]; } $link .= "</a>"; $text .= "<td align='center'>" . $link . " " . $LANG['networking'][25] . " " . $link1 . "</td>"; } else { $text .= "<td align='center'><font color='#ff0000'>" . $LANG['common'][28] . "</font></td>"; } } } $text .= "<td align='center' colspan='4'></td>"; $text .= "<td align='center'>" . convDateTime($data["date"]) . "</td>"; } else { // Changes values $text .= "<td align='center' colspan='2'></td>"; $text .= "<td align='center'>" . $FUSIONINVENTORY_MAPPING[NETWORKING_TYPE][$data["Field"]]['name'] . "</td>"; $text .= "<td align='center'>" . $data["old_value"] . "</td>"; $text .= "<td align='center'>-></td>"; $text .= "<td align='center'>" . $data["new_value"] . "</td>"; $text .= "<td align='center'>" . convDateTime($data["date"]) . "</td>"; } $text .= "</tr>"; } } /* $pthc = new PluginFusioninventorySnmphistoryconnection; $data_connections = $pthc->find('`FK_port_source`="'.$ID_port.'" OR `FK_port_destination `="'.$ID_port.'"', '`date` DESC', '0,30'); $query = "SELECT * FROM `glpi_plugin_fusioninventory_snmphistories` WHERE `FK_ports`='".$ID_port."' ORDER BY `date_mod` DESC LIMIT 0,30;"; $text = "<table class='tab_cadre' cellpadding='5' width='950'>"; $text .= "<tr class='tab_bg_1'>"; $text .= "<th colspan='8'>"; $text .= "Historique"; $text .= "</th>"; $text .= "</tr>"; $text .= "<tr class='tab_bg_1'>"; $text .= "<th>".$LANG['plugin_fusioninventory']["snmp"][50]."</th>"; $text .= "<th>".$LANG["common"][1]."</th>"; $text .= "<th>".$LANG["networking"][15]."</th>"; $text .= "<th>".$LANG["event"][18]."</th>"; $text .= "<th></th>"; $text .= "<th></th>"; $text .= "<th></th>"; $text .= "<th>".$LANG["common"][27]."</th>"; $text .= "</tr>"; if ($result=$DB->query($query)) { while ($data=$DB->fetch_array($result)) { $text .= "<tr class='tab_bg_1'>"; if (($data["old_device_ID"] != "0") OR ($data["new_device_ID"] != "0")) { // Connections and disconnections if ($data["old_device_ID"] != "0") { $text .= "<td align='center'>".$LANG['plugin_fusioninventory']["history"][2]."</td>"; $CommonItem->getFromDB($data["old_device_type"],$data["old_device_ID"]); $text .= "<td align='center'>".$CommonItem->getLink(1)."</td>"; $text .= "<td align='center'>".$data["old_value"]."</td>"; } else if ($data["new_device_ID"] != "0") { $text .= "<td align='center'>".$LANG['plugin_fusioninventory']["history"][3]."</td>"; $CommonItem->getFromDB($data["new_device_type"],$data["new_device_ID"]); $text .= "<td align='center'>".$CommonItem->getLink(1)."</td>"; $text .= "<td align='center'>".$data["new_value"]."</td>"; } $text .= "<td align='center' colspan='4'></td>"; $text .= "<td align='center'>".convDateTime($data["date_mod"])."</td>"; } else if (($data["old_device_ID"] == "0") AND ($data["new_device_ID"] == "0") AND ($data["Field"] == "0")) { // Unknown Mac address if (!empty($data["old_value"])) { $text .= "<td align='center' background='#cf9b9b' class='tab_bg_1_2'>".$LANG['plugin_fusioninventory']["history"][2]."</td>"; $CommonItem->getFromDB($data["old_device_type"],$data["old_device_ID"]); $text .= "<td align='center' background='#cf9b9b' class='tab_bg_1_2'>".$CommonItem->getLink(1)."</td>"; $text .= "<td align='center' background='#cf9b9b' class='tab_bg_1_2'>".$data["old_value"]."</td>"; } else if (!empty($data["new_value"])) { $text .= "<td align='center' background='#cf9b9b' class='tab_bg_1_2'>".$LANG['plugin_fusioninventory']["history"][3]."</td>"; $CommonItem->getFromDB($data["new_device_type"],$data["new_device_ID"]); $text .= "<td align='center' background='#cf9b9b' class='tab_bg_1_2'>".$CommonItem->getLink(1)."</td>"; $text .= "<td align='center' background='#cf9b9b' class='tab_bg_1_2'>".$data["new_value"]."</td>"; } $text .= "<td align='center' colspan='4' background='#cf9b9b' class='tab_bg_1_2'></td>"; $text .= "<td align='center' background='#cf9b9b' class='tab_bg_1_2'>".convDateTime($data["date_mod"])."</td>"; } else { // Changes values $text .= "<td align='center' colspan='3'></td>"; $text .= "<td align='center'>".$data["Field"]."</td>"; $text .= "<td align='center'>".$data["old_value"]."</td>"; $text .= "<td align='center'>-></td>"; $text .= "<td align='center'>".$data["new_value"]."</td>"; $text .= "<td align='center'>".convDateTime($data["date_mod"])."</td>"; } $text .= "</tr>"; } } */ $text .= "<tr class='tab_bg_1'>"; $text .= "<th colspan='8'>"; $text .= "<a href='" . GLPI_ROOT . "/plugins/fusioninventory/report/switch_ports.history.php?FK_networking_ports=" . $ID_port . "'>Voir l'historique complet</a>"; $text .= "</th>"; $text .= "</tr>"; $text .= "</table>"; return $text; }
function showForm($target, $ID) { global $DB, $CFG_GLPI, $LANG; $history = new PluginFusioninventorySnmphistory(); if (!PluginFusioninventory::haveRight("snmp_networking", "r")) { return false; } if (PluginFusioninventory::haveRight("snmp_networking", "w")) { $canedit = true; } else { $canedit = false; } include GLPI_ROOT . "/plugins/fusioninventory/inc_constants/snmp.mapping.constant.php"; $this->ID = $ID; $nw = new Netwire(); $CommonItem = new CommonItem(); $plugin_fusioninventory_snmp = new PluginFusioninventorySNMP(); echo "<script type='text/javascript' src='" . GLPI_ROOT . "/lib/extjs/adapter/prototype/prototype.js'></script>"; echo "<script type='text/javascript' src='" . GLPI_ROOT . "/lib/extjs/adapter/prototype/effects.js'></script>"; if (!($data = $this->find("`FK_networking`='" . $ID . "'", '', 1))) { // Add in database if not exist $input['FK_networking'] = $ID; $ID_tn = $this->add($input); $this->getFromDB($ID_tn); } else { foreach ($data as $ID_tn => $datas) { $this->fields = $data[$ID_tn]; } } $PID = $this->fields['last_PID_update']; // Form networking informations echo "<div align='center'>\n <form method='post' name='snmp_form' id='snmp_form' action=\"" . $target . "\">"; echo "<table class='tab_cadre' cellpadding='5' width='950'>"; echo "<tr class='tab_bg_1'>"; echo "<th colspan='3'>"; echo $LANG['plugin_fusioninventory']["snmp"][11]; echo "</th>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td align='center'>" . $LANG['plugin_fusioninventory']["profile"][24] . "</td>"; echo "<td align='center'>"; $query_models = "SELECT * \n FROM `glpi_plugin_fusioninventory_model_infos`\n WHERE `device_type`!='2'\n AND `device_type`!='0';"; $result_models = $DB->query($query_models); $exclude_models = array(); while ($data_models = $DB->fetch_array($result_models)) { $exclude_models[] = $data_models['ID']; } Dropdown::show("PluginFusioninventoryModelInfos", array('name' => "model_infos", 'value' => $this->fields['FK_model_infos'], 'comments' => 0, 'used' => $exclude_models)); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td align='center'>" . $LANG['plugin_fusioninventory']["functionalities"][43] . "</td>"; echo "<td align='center'>"; PluginFusioninventorySNMP::auth_dropdown($this->fields['FK_snmp_connection']); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1 center'>"; echo "<td>"; echo " <input type='submit' name='GetRightModel'\n value='" . $LANG['plugin_fusioninventory']["model_info"][13] . "' class='submit'/></td>"; echo "<td>"; echo "<input type='hidden' name='ID' value='" . $ID . "'>"; echo "<input type='submit' name='update' value=\"" . $LANG["buttons"][7] . "\" class='submit' >"; echo "</td>"; echo "</tr>"; echo "</table></form>"; // Remote action of agent $pfit = new PluginFusioninventoryTask(); $pfit->RemoteStateAgent($target, $ID, NETWORKING_TYPE, array('INVENTORY' => 1)); // SNMP Informations // echo "<div align='center'> echo "<form method='post' name='snmp_form' id='snmp_form' action=\"" . $target . "\">"; echo "<table class='tab_cadre' cellpadding='5' width='950'>"; echo "<tr class='tab_bg_1'>"; echo "<th colspan='3'>"; echo $LANG['plugin_fusioninventory']["title"][1]; echo "</th>"; echo "</tr>"; echo "<tr class='tab_bg_1 center'>"; echo "<td colspan='2' height='30'>"; echo $LANG['plugin_fusioninventory']["snmp"][52] . ": " . convDateTime($this->fields['last_fusioninventory_update']); echo "</td>"; echo "</tr>"; // Get link field to detect if cpu, memory and uptime are get onthis network device $Array_Object_TypeNameConstant = $plugin_fusioninventory_snmp->GetLinkOidToFields($ID, NETWORKING_TYPE); $mapping_name = array(); foreach ($Array_Object_TypeNameConstant as $object => $mapping_type_name) { $mapping_name[$mapping_type_name] = "1"; } if (isset($mapping_name['uptime']) and $mapping_name['uptime'] == "1") { echo "<tr class='tab_bg_1 center'>"; echo "<td>" . $LANG['plugin_fusioninventory']["snmp"][12] . "</td>"; echo "<td>"; $sysUpTime = $this->fields['uptime']; if (strstr($sysUpTime, "days")) { list($day, $hour, $minute, $sec, $ticks) = sscanf($sysUpTime, "%d days, %d:%d:%d.%d"); } else { if (strstr($sysUpTime, "hours")) { $day = 0; list($hour, $minute, $sec, $ticks) = sscanf($sysUpTime, "%d hours, %d:%d.%d"); } else { if (strstr($sysUpTime, "minutes")) { $day = 0; $hour = 0; list($minute, $sec, $ticks) = sscanf($sysUpTime, "%d minutes, %d.%d"); } else { if ($sysUpTime == "0") { $day = 0; $hour = 0; $minute = 0; $sec = 0; } else { list($hour, $minute, $sec, $ticks) = sscanf($sysUpTime, "%d:%d:%d.%d"); $day = 0; } } } } echo "<b>{$day}</b> " . $LANG["stats"][31] . " "; echo "<b>{$hour}</b> " . $LANG["job"][21] . " "; echo "<b>{$minute}</b> " . $LANG["job"][22] . " "; echo " " . strtolower($LANG["rulesengine"][42]) . " <b>{$sec}</b> " . $LANG["stats"][34] . " "; echo "</td>"; echo "</tr>"; } if (isset($mapping_name['cpu']) and $mapping_name['cpu'] == "1" or isset($mapping_name['cpuuser']) and $mapping_name['cpuuser'] == "1" and (isset($mapping_name['cpusystem']) and $mapping_name['cpusystem'] == "1")) { echo "<tr class='tab_bg_1 center'>"; echo "<td>" . $LANG['plugin_fusioninventory']["snmp"][13] . "</td>"; echo "<td>"; PluginFusioninventoryDisplay::bar($this->fields['cpu'], '', 'inverse'); echo "</td>"; echo "</tr>"; } if (isset($mapping_name['memory']) and $mapping_name['memory'] == "1") { echo "<tr class='tab_bg_1 center'>"; echo "<td>" . $LANG['plugin_fusioninventory']["snmp"][14] . "</td>"; echo "<td>"; $query2 = "SELECT *\n FROM `glpi_networking`\n WHERE `ID`='" . $ID . "';"; $result2 = $DB->query($query2); $data2 = $DB->fetch_assoc($result2); if (empty($data2["ram"])) { $ram_pourcentage = 0; } else { $ram_pourcentage = ceil(100 * ($data2["ram"] - $this->fields['memory']) / $data2["ram"]); } PluginFusioninventoryDisplay::bar($ram_pourcentage, " (" . ($data2["ram"] - $this->fields['memory']) . " Mo / " . $data2["ram"] . " Mo)", 'inverse'); echo "</td>"; echo "</tr>"; } echo "</table></form>"; // ********************************************************************************************** // // *********************************** METTRE TABLEAU DES PORTS ********************************* // // ********************************************************************************************** // function ByteSize($bytes, $sizeoct = 1024) { $size = $bytes / $sizeoct; if ($size < $sizeoct) { $size = number_format($size, 0); $size .= ' K'; } else { if ($size / $sizeoct < $sizeoct) { $size = number_format($size / $sizeoct, 0); $size .= ' M'; } else { if ($size / $sizeoct / $sizeoct < $sizeoct) { $size = number_format($size / $sizeoct / $sizeoct, 0); $size .= ' G'; } else { if ($size / $sizeoct / $sizeoct / $sizeoct < $sizeoct) { $size = number_format($size / $sizeoct / $sizeoct / $sizeoct, 0); $size .= ' T'; } } } } return $size; } $query = "\n\t\tSELECT *,glpi_plugin_fusioninventory_networking_ports.ifmac as ifmacinternal\n\t\t\n\t\tFROM glpi_plugin_fusioninventory_networking_ports\n\n\t\tLEFT JOIN glpi_networking_ports\n\t\tON glpi_plugin_fusioninventory_networking_ports.FK_networking_ports = glpi_networking_ports.ID \n\t\tWHERE glpi_networking_ports.on_device='" . $ID . "'\n\t\tORDER BY logical_number "; echo "<script type='text/javascript'>\nfunction close_array(id){\n\tdocument.getElementById('plusmoins'+id).innerHTML = '<img src=\\'" . GLPI_ROOT . "/pics/collapse.gif\\''+\n 'onClick=\\'Effect.Fade(\"viewfollowup'+id+'\");appear_array('+id+');\\' />';\n} \nfunction appear_array(id){\n\tdocument.getElementById('plusmoins'+id).innerHTML = '<img src=\\'" . GLPI_ROOT . "/pics/expand.gif\\''+\n 'onClick=\\'Effect.Appear(\"viewfollowup'+id+'\");close_array('+id+');\\' />';\n}\t\t\n\t\t\n\t\t</script>"; echo "<table class='tab_cadre' cellpadding='5' width='1100'>"; echo "<tr class='tab_bg_1'>"; $query_array = "SELECT *\n FROM `glpi_display`\n WHERE `type`='" . PLUGIN_FUSIONINVENTORY_SNMP_NETWORKING_PORTS . "'\n AND `FK_users`='0'\n ORDER BY `rank`;"; $result_array = $DB->query($query_array); echo "<th colspan='" . (mysql_num_rows($result_array) + 2) . "'>"; echo $LANG['plugin_fusioninventory']["snmp"][40]; $result = $DB->query($query); echo ' (' . $DB->numrows($result) . ')'; if ($_SESSION["glpilanguage"] == "fr_FR") { $url_legend = "https://forge.indepnet.net/wiki/fusioninventory/Fr_VI_visualisationsdonnees_2_reseau"; } else { $url_legend = "https://forge.indepnet.net/wiki/fusioninventory/En_VI_visualisationsdonnees_2_reseau"; } echo " <a href='" . $url_legend . "'>[ " . $LANG['plugin_fusioninventory']["functionalities"][6] . " ]</a>"; echo "</th>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo '<th><img alt="Sélectionnez les éléments à afficher par défaut" title="Sélectionnez les éléments à afficher par défaut" src="' . GLPI_ROOT . '/pics/options_search.png" class="pointer" onclick="var w = window.open(\'' . GLPI_ROOT . '/front/popup.php?popup=search_config&type=5157\' ,\'glpipopup\', \'height=400, width=1000, top=100, left=100, scrollbars=yes\' ); w.focus();"></th>'; echo "<th>" . $LANG["common"][16] . "</th>"; $query_array = "SELECT * \n FROM `glpi_display`\n WHERE `type`='5157'\n AND `FK_users`='0'\n ORDER BY `rank`;"; $result_array = $DB->query($query_array); while ($data_array = $DB->fetch_array($result_array)) { echo "<th>"; switch ($data_array['num']) { case 2: echo $LANG['plugin_fusioninventory']["snmp"][42]; break; case 3: echo $LANG['plugin_fusioninventory']["snmp"][43]; break; case 4: echo $LANG['plugin_fusioninventory']["snmp"][44]; break; case 5: echo $LANG['plugin_fusioninventory']["snmp"][45]; break; case 6: echo $LANG['plugin_fusioninventory']["snmp"][46]; break; case 7: echo $LANG['plugin_fusioninventory']["snmp"][47]; break; case 8: echo $LANG['plugin_fusioninventory']["snmp"][48]; break; case 9: echo $LANG['plugin_fusioninventory']["snmp"][49]; break; case 10: echo $LANG['plugin_fusioninventory']["snmp"][51]; break; case 11: echo $LANG['plugin_fusioninventory']["mapping"][115]; break; case 12: echo $LANG["networking"][17]; break; case 13: echo $LANG['plugin_fusioninventory']["snmp"][50]; break; case 14: echo $LANG["networking"][56]; break; case 15: echo $LANG['plugin_fusioninventory']["snmp"][41]; break; } echo "</th>"; } echo "</tr>"; // Fin de l'entête du tableau if ($result) { while ($data = $DB->fetch_array($result)) { $background_img = ""; if ($data["trunk"] == "1" and (strstr($data["ifstatus"], "up") or strstr($data["ifstatus"], "1"))) { $background_img = " style='background-image: url(\"" . GLPI_ROOT . "/plugins/fusioninventory/pics/port_trunk.png\"); '"; } else { if ($data["trunk"] == "-1" and (strstr($data["ifstatus"], "up") or strstr($data["ifstatus"], "1"))) { $background_img = " style='background-image: url(\"" . GLPI_ROOT . "/plugins/fusioninventory/pics/multiple_mac_addresses.png\"); '"; } else { if (strstr($data["ifstatus"], "up") or strstr($data["ifstatus"], "1")) { $background_img = " style='background-image: url(\"" . GLPI_ROOT . "/plugins/fusioninventory/pics/connected_trunk.png\"); '"; } } } echo "<tr class='tab_bg_1 center' height='40'" . $background_img . ">"; echo "<td id='plusmoins" . $data["ID"] . "'><img src='" . GLPI_ROOT . "/pics/expand.gif' onClick='Effect.Appear(\"viewfollowup" . $data["ID"] . "\");close_array(" . $data["ID"] . ");' /></td>"; echo "<td><a href='networking.port.php?ID=" . $data["ID"] . "'>" . $data["name"] . "</a></td>"; $query_array = "SELECT *\n FROM `glpi_display`\n WHERE `type`='5157'\n AND `FK_users`='0'\n ORDER BY `rank`;"; $result_array = $DB->query($query_array); while ($data_array = $DB->fetch_array($result_array)) { switch ($data_array['num']) { case 2: echo "<td>" . $data["ifmtu"] . "</td>"; break; case 3: echo "<td>" . ByteSize($data["ifspeed"], 1000) . "bps</td>"; break; case 4: echo "<td>"; if (strstr($data["ifstatus"], "up") or strstr($data["ifinternalstatus"], "1")) { echo "<img src='" . GLPI_ROOT . "/pics/greenbutton.png'/>"; } else { if (strstr($data["ifstatus"], "down") or strstr($data["ifinternalstatus"], "2")) { echo "<img src='" . GLPI_ROOT . "/pics/redbutton.png'/>"; } else { if (strstr($data["ifstatus"], "testing") or strstr($data["ifinternalstatus"], "3")) { echo "<img src='" . GLPI_ROOT . "/plugins/fusioninventory/pics/yellowbutton.png'/>"; } } } echo "</td>"; break; case 5: echo "<td>" . $data["iflastchange"] . "</td>"; break; case 6: echo "<td>"; if ($data["ifinoctets"] == "0") { echo "-"; } else { echo ByteSize($data["ifinoctets"], 1000) . "o"; } echo "</td>"; break; case 7: if ($data["ifinerrors"] == "0") { echo "<td>-"; } else { echo "<td background='#cf9b9b' class='tab_bg_1_2'>"; echo $data["ifinerrors"]; } echo "</td>"; break; case 8: echo "<td>"; if ($data["ifinoctets"] == "0") { echo "-"; } else { echo ByteSize($data["ifoutoctets"], 1000) . "o"; } echo "</td>"; break; case 9: if ($data["ifouterrors"] == "0") { echo "<td>-"; } else { echo "<td background='#cf9b9b' class='tab_bg_1_2'>"; echo $data["ifouterrors"]; } echo "</td>"; break; case 10: echo "<td>" . $data["portduplex"] . "</td>"; break; case 11: // ** internal mac echo "<td>" . $data["ifmac"] . "</td>"; break; case 12: // ** Mac address and link to device which are connected to this port $opposite_port = $nw->getOppositeContact($data["FK_networking_ports"]); if ($opposite_port != "") { $query_device = "SELECT * \n FROM `glpi_networking_ports`\n WHERE `ID`='" . $opposite_port . "';"; $result_device = $DB->query($query_device); $data_device = $DB->fetch_assoc($result_device); $CommonItem->getFromDB($data_device["device_type"], $data_device["on_device"]); $link1 = $CommonItem->getLink(1); $link = str_replace($CommonItem->getName(0), $data_device["ifmac"], $CommonItem->getLink()); $link2 = str_replace($CommonItem->getName(0), $data_device["ifaddr"], $CommonItem->getLink()); if ($data_device["device_type"] == PLUGIN_FUSIONINVENTORY_MAC_UNKNOWN) { if ($CommonItem->getField("accepted") == "1") { echo "<td style='background:#bfec75'\n class='tab_bg_1_2'>" . $link1; } else { echo "<td background='#cf9b9b'\n class='tab_bg_1_2'>" . $link1; } if (!empty($link)) { echo "<br/>" . $link; } if (!empty($link2)) { echo "<br/>" . $link2; } echo "</td>"; } else { echo "<td>" . $link1; if (!empty($link)) { echo "<br/>" . $link; } if (!empty($link2)) { echo "<br/>" . $link2; } echo "</td>"; } } else { echo "<td></td>"; } break; case 13: // ** Connection status echo "<td>"; if (strstr($data["ifstatus"], "up") or strstr($data["ifstatus"], "1")) { echo "<img src='" . GLPI_ROOT . "/pics/greenbutton.png'/>"; } else { if (strstr($data["ifstatus"], "down") or strstr($data["ifstatus"], "2")) { echo "<img src='" . GLPI_ROOT . "/pics/redbutton.png'/>"; } else { if (strstr($data["ifstatus"], "testing") or strstr($data["ifstatus"], "3")) { echo "<img src='" . GLPI_ROOT . "/plugins/fusioninventory/pics/yellowbutton.png'/>"; } else { if (strstr($data["ifstatus"], "dormant") or strstr($data["ifstatus"], "5")) { echo "<img src='" . GLPI_ROOT . "/plugins/fusioninventory/pics/orangebutton.png'/>"; } } } } echo "</td>"; break; case 14: echo "<td>"; $canedit = haveRight("networking", "w"); $used = array(); $query_vlan = "SELECT * FROM glpi_networking_vlan WHERE FK_port='" . $data["ID"] . "'"; $result_vlan = $DB->query($query_vlan); if ($DB->numrows($result_vlan) > 0) { echo "<table cellpadding='0' cellspacing='0'>"; while ($line = $DB->fetch_array($result_vlan)) { $used[] = $line["FK_vlan"]; $a_vlan = Dropdown::getDropdownName("glpi_dropdown_vlan", $line["FK_vlan"], 1); echo "<tr><td>" . $a_vlan['name'] . " [" . $a_vlan['comments'] . "]"; echo "</td><td>"; if ($canedit) { echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/networking.port.php?unassign_vlan=unassigned&ID=" . $line["ID"] . "'>"; echo "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/delete2.png\" alt='" . $LANG['buttons'][6] . "' title='" . $LANG['buttons'][6] . "'></a>"; } else { echo " "; } echo "</td></tr>"; } echo "</table>"; } else { echo " "; } echo "</td>"; break; case 15: //Port description echo "<td>" . $data["ifdescr"] . "</td>"; break; } } echo "</tr>"; // Historique echo "\n\t\t\t\t<tr style='display: none;' id='viewfollowup" . $data["ID"] . "'>\n\t\t\t\t\t<td colspan='" . (mysql_num_rows($result_array) + 2) . "'>" . PluginFusioninventorySnmphistory::showHistory($data["ID"]) . "</td>\n\t\t\t\t</tr>\n\t\t\t\t"; } } echo "</table>"; }
/** * Show printer graph form * *@param $p_target *@param $p_ID *@return nothing (print the form) **/ function showFormPrinter_graph($p_target, $p_ID) { global $FUSIONINVENTORY_MAPPING, $LANG; include_once GLPI_ROOT . "/plugins/fusioninventory/inc_constants/snmp.mapping.constant.php"; $target = $p_target; $where = ''; $begin = ''; $end = ''; $timeUnit = 'date'; $graphField = 'pages_total'; $printersComp = array(); if (isset($_SESSION['glpi_plugin_fusioninventory_graph_begin'])) { $begin = $_SESSION['glpi_plugin_fusioninventory_graph_begin']; } if ($begin == 'NULL' or $begin == '') { $begin = date("Y-m-01"); } // first day of current month if (isset($_SESSION['glpi_plugin_fusioninventory_graph_end'])) { $end = $_SESSION['glpi_plugin_fusioninventory_graph_end']; } if ($end == 'NULL' or $end == '') { $end = date("Y-m-d"); } // today if (isset($_SESSION['glpi_plugin_fusioninventory_graph_timeUnit'])) { $timeUnit = $_SESSION['glpi_plugin_fusioninventory_graph_timeUnit']; } if (isset($_SESSION['glpi_plugin_fusioninventory_graph_graphField'])) { $graphField = $_SESSION['glpi_plugin_fusioninventory_graph_graphField']; } if (!isset($_SESSION['glpi_plugin_fusioninventory_graph_printersComp'])) { $_SESSION['glpi_plugin_fusioninventory_graph_printersComp'] = array(); } if (isset($_SESSION['glpi_plugin_fusioninventory_graph_printerCompAdd'])) { $printerCompAdd = $_SESSION['glpi_plugin_fusioninventory_graph_printerCompAdd']; if (!key_exists($printerCompAdd, $_SESSION['glpi_plugin_fusioninventory_graph_printersComp'])) { $ci = new CommonItem(); if ($ci->getFromDB(PRINTER_TYPE, $printerCompAdd)) { $_SESSION['glpi_plugin_fusioninventory_graph_printersComp'][$printerCompAdd] = $ci->getField('name'); } } } elseif (isset($_SESSION['glpi_plugin_fusioninventory_graph_printerCompRemove'])) { unset($_SESSION['glpi_plugin_fusioninventory_graph_printersComp'][$_SESSION['glpi_plugin_fusioninventory_graph_printerCompRemove']]); } $printers = $_SESSION['glpi_plugin_fusioninventory_graph_printersComp']; $printersView = $printers; // printers without the current printer if (isset($printersView[$p_ID])) { unset($printersView[$p_ID]); } else { $ci = new CommonItem(); if ($ci->getFromDB(PRINTER_TYPE, $p_ID)) { $printers[$p_ID] = $ci->getField('name'); } } $printersList = ''; foreach ($printers as $printer) { if ($printersList != '') { $printersList .= '<BR>'; } $printersList .= $printer; } $printersIds = ""; foreach (array_keys($printers) as $printerId) { if ($printersIds != '') { $printersIds .= ', '; } $printersIds .= $printerId; } $where = " WHERE `FK_printers` IN(" . $printersIds . ")"; if ($begin != '' || $end != '') { $where .= " AND " . $this->getDateRequest("`date`", $begin, $end); } switch ($timeUnit) { case 'date': $group = "GROUP BY `FK_printers`, `year`, `month`, `date`"; break; case 'week': $group = "GROUP BY `FK_printers`, `year`, `month`, `week`"; break; case 'month': $group = "GROUP BY `FK_printers`, `year`, `month`"; break; case 'year': $group = "GROUP BY `FK_printers`, `year`"; break; } $query = "SELECT `FK_printers`, `date`, WEEK(`date`) AS `week`,\n MONTH(`date`) AS `month`, YEAR(`date`) AS `year`,\n SUM(`{$graphField}`) AS `{$graphField}`\n FROM `glpi_plugin_fusioninventory_printers_history`" . $where . $group . "\n ORDER BY `date`, `FK_printers`"; echo "<form method='post' name='printerGraph_form' id='printerGraph_form'\n action='" . $p_target . "'>"; echo "<table class='tab_cadre_fixe' cellpadding='2'>"; echo "<tr>"; echo "<th colspan='4'>" . $LANG['plugin_fusioninventory']["prt_history"][20] . "</th>"; echo "</tr>"; echo "<tr class='tab_bg_1'><td class='left'>" . $LANG['plugin_fusioninventory']["prt_history"][30] . " :</td><td class='left' colspan='2'>"; $elementsField = array('pages_total' => $FUSIONINVENTORY_MAPPING[PRINTER_TYPE]['pagecountertotalpages']['shortname'], 'pages_n_b' => $FUSIONINVENTORY_MAPPING[PRINTER_TYPE]['pagecounterblackpages']['shortname'], 'pages_color' => $FUSIONINVENTORY_MAPPING[PRINTER_TYPE]['pagecountercolorpages']['shortname'], 'pages_recto_verso' => $FUSIONINVENTORY_MAPPING[PRINTER_TYPE]['pagecounterrectoversopages']['shortname'], 'scanned' => $FUSIONINVENTORY_MAPPING[PRINTER_TYPE]['pagecounterscannedpages']['shortname'], 'pages_total_print' => $FUSIONINVENTORY_MAPPING[PRINTER_TYPE]['pagecountertotalpages_print']['shortname'], 'pages_n_b_print' => $FUSIONINVENTORY_MAPPING[PRINTER_TYPE]['pagecounterblackpages_print']['shortname'], 'pages_color_print' => $FUSIONINVENTORY_MAPPING[PRINTER_TYPE]['pagecountercolorpages_print']['shortname'], 'pages_total_copy' => $FUSIONINVENTORY_MAPPING[PRINTER_TYPE]['pagecountertotalpages_copy']['shortname'], 'pages_n_b_copy' => $FUSIONINVENTORY_MAPPING[PRINTER_TYPE]['pagecounterblackpages_copy']['shortname'], 'pages_color_copy' => $FUSIONINVENTORY_MAPPING[PRINTER_TYPE]['pagecountercolorpages_copy']['shortname'], 'pages_total_fax' => $FUSIONINVENTORY_MAPPING[PRINTER_TYPE]['pagecountertotalpages_fax']['shortname']); Dropdown::showFromArray('graph_graphField', $elementsField, array('value' => $graphField)); echo "</td></tr>\n"; echo "<tr class='tab_bg_1'><td class='left'>" . $LANG['search'][8] . " :</td>\n <td class='left' colspan='2'>"; showDateFormItem("graph_begin", $begin); echo "</td></tr>\n"; echo "<tr class='tab_bg_1'><td class='left'>" . $LANG['search'][9] . " :</td>\n <td class='left' colspan='2'>"; showDateFormItem("graph_end", $end); echo "<tr class='tab_bg_1'><td class='left'>" . $LANG['plugin_fusioninventory']["prt_history"][31] . " :</td>\n <td class='left' colspan='2'>"; $elementsTime = array('date' => $LANG['plugin_fusioninventory']["prt_history"][34], 'week' => $LANG['plugin_fusioninventory']["prt_history"][35], 'month' => $LANG['plugin_fusioninventory']["prt_history"][36], 'year' => $LANG['plugin_fusioninventory']["prt_history"][37]); Dropdown::showFromArray('graph_timeUnit', $elementsTime, array('value' => $timeUnit)); echo "</td></tr>\n"; echo "<tr class='tab_bg_1'><td class='left'>" . $LANG['Menu'][2] . " :</td>\n <td class='left' colspan='2'>"; echo $printersList; echo "</td></tr>\n"; echo "<tr class='tab_bg_2'><td class='center' colspan='3'>\n <input type='submit' class=\"submit\" name='graph_plugin_fusioninventory_printer_period'\n value='" . $LANG["buttons"][7] . "'>"; echo "</td></tr>\n"; echo "<tr class='tab_bg_1'><td class='left'>" . $LANG['plugin_fusioninventory']["prt_history"][32] . " :</td><td class='left'>"; Computer_Item::dropdownConnect(PRINTER_TYPE, PRINTER_TYPE, "graph_printerCompAdd", -1, 0, array_keys($printers)); echo "</td><td class='left'>\n"; echo "<input type='submit' value=\"" . $LANG['buttons'][8] . "\" class='submit' name='graph_plugin_fusioninventory_printer_add'>"; echo "</td></tr>\n"; echo "<tr class='tab_bg_1'><td class='left'>" . $LANG['plugin_fusioninventory']["prt_history"][33] . " :</td>\n <td class='left'>"; $printersTmp = $printersView; $printersTmp[0] = "-----"; asort($printersTmp); Dropdown::showFromArray('graph_printerCompRemove', $printersTmp); echo "</td><td class='left'>\n"; echo "<input type='submit' value=\"" . $LANG['buttons'][6] . "\" class='submit' name='graph_plugin_fusioninventory_printer_remove'>"; echo "</td></tr>\n"; echo "</table>"; echo "</form>"; echo "<div class=center>"; $title = $elementsField[$graphField]; if (count($printers)) { $ptg = new PluginFusioninventoryGraph($query, $graphField, $timeUnit, $printers, $title); } echo '</div>'; }
function plugin_fusioninventory_giveItem($type, $ID, $data, $num) { global $CFG_GLPI, $DB, $INFOFORM_PAGES, $LINK_ID_TABLE, $LANG, $SEARCH_OPTION, $FUSIONINVENTORY_MAPPING; $table = $SEARCH_OPTION[$type][$ID]["table"]; $field = $SEARCH_OPTION[$type][$ID]["field"]; // echo "GiveItem : ".$field."<br/>"; switch ($type) { // * Computer List (front/computer.php) case COMPUTER_TYPE: switch ($table . '.' . $field) { // ** FusionInventory - switch case "glpi_plugin_fusioninventory_networking.ID": $out = ''; include_once GLPI_ROOT . "/inc/networking.class.php"; $netport = new Netport(); $list = explode("\$\$\$\$", $data["ITEM_{$num}"]); foreach ($list as $numtmp => $vartmp) { $netport->getDeviceData($vartmp, NETWORKING_TYPE); $out .= "<a href=\"" . $CFG_GLPI["root_doc"] . "/" . $INFOFORM_PAGES[NETWORKING_TYPE] . "?ID=" . $vartmp . "\">"; $out .= $netport->device_name; $out .= $vartmp; if ($CFG_GLPI["view_ID"]) { $out .= " (" . $vartmp . ")"; } $out .= "</a><br/>"; } return "<center>" . $out . "</center>"; break; // ** FusionInventory - switch port // ** FusionInventory - switch port case "glpi_plugin_fusioninventory_networking_ports.ID": $out = ''; include_once GLPI_ROOT . "/inc/networking.class.php"; if (!empty($data["ITEM_{$num}"])) { $list = explode("\$\$\$\$", $data["ITEM_{$num}"]); $np = new Netport(); foreach ($list as $numtmp => $vartmp) { $np->getFromDB($vartmp); $out .= "<a href='" . GLPI_ROOT . "/front/networking.port.php?ID=" . $vartmp . "'>" . $np->fields["name"] . "</a><br/>"; } } return "<center>" . $out . "</center>"; break; } break; // * Networking List (front/networking.php) // * Networking List (front/networking.php) case NETWORKING_TYPE: switch ($table . '.' . $field) { // ** FusionInventory - last inventory case "glpi_plugin_fusioninventory_networking.FK_networking": $query = "SELECT *\n FROM `glpi_plugin_fusioninventory_networking`\n WHERE `FK_networking` = '" . $data["ID"] . "';"; if ($result = $DB->query($query)) { $data2 = $DB->fetch_array($result); } $last_date = ""; if (isset($data2["last_fusioninventory_update"])) { $last_date = $data2["last_fusioninventory_update"]; } $out = "<div align='center'>" . convDateTime($last_date) . "</div>"; return $out; break; // ** FusionInventory - SNMP models // ** FusionInventory - SNMP models case "glpi_plugin_fusioninventory_model_infos.ID": $plugin_fusioninventory_snmp = new PluginFusioninventorySNMP(); $FK_model_DB = $plugin_fusioninventory_snmp->GetSNMPModel($data["ID"], $type); $out = "<a href=\"" . $CFG_GLPI["root_doc"] . "/plugins/fusioninventory/front/models.form.php?ID=" . $FK_model_DB . "\">"; $out .= Dropdown::getDropdownName("glpi_plugin_fusioninventory_model_infos", $FK_model_DB, 0); $out .= "</a>"; return "<center>" . $out . "</center>"; break; // ** FusionInventory - SNMP authentification // ** FusionInventory - SNMP authentification case "glpi_plugin_fusioninventory_snmpauths.name": $plugin_fusioninventory_snmp = new PluginFusioninventorySnmpauth(); $FK_auth_DB = $plugin_fusioninventory_snmp->GetSNMPAuth($data["ID"], $type); $out = "<a href=\"" . $CFG_GLPI["root_doc"] . "/plugins/fusioninventory/front/snmp_auth.form.php?ID=" . $FK_auth_DB . "\">"; $out .= Dropdown::getDropdownName("glpi_plugin_fusioninventory_snmpauths", $FK_auth_DB, 0); $out .= "</a>"; return "<center>" . $out . "</center>"; break; } break; // * Printer List (front/printer.php) // * Printer List (front/printer.php) case PRINTER_TYPE: switch ($table . '.' . $field) { // ** FusionInventory - switch case "glpi_plugin_fusioninventory_networking.ID": $out = ''; include_once GLPI_ROOT . "/inc/networking.class.php"; $netport = new Netport(); $list = explode("\$\$\$\$", $data["ITEM_{$num}"]); foreach ($list as $numtmp => $vartmp) { $netport->getDeviceData($vartmp, NETWORKING_TYPE); $out .= "<a href=\"" . $CFG_GLPI["root_doc"] . "/" . $INFOFORM_PAGES[NETWORKING_TYPE] . "?ID=" . $vartmp . "\">"; $out .= $netport->device_name; if ($CFG_GLPI["view_ID"]) { $out .= " (" . $vartmp . ")"; } $out .= "</a><br/>"; } return "<center>" . $out . "</center>"; break; // ** FusionInventory - switch port // ** FusionInventory - switch port case "glpi_plugin_fusioninventory_networking_ports.ID": $out = ''; include_once GLPI_ROOT . "/inc/networking.class.php"; if (!empty($data["ITEM_{$num}"])) { $list = explode("\$\$\$\$", $data["ITEM_{$num}"]); $np = new Netport(); foreach ($list as $numtmp => $vartmp) { $np->getFromDB($vartmp); $out .= "<a href='" . GLPI_ROOT . "/front/networking.port.php?ID=" . $vartmp . "'>" . $np->fields["name"] . "</a><br/>"; } } return "<center>" . $out . "</center>"; break; // ** FusionInventory - last inventory // ** FusionInventory - last inventory case "glpi_plugin_fusioninventory_printers.FK_printers": $query = "SELECT *\n FROM `glpi_plugin_fusioninventory_printers`\n WHERE `FK_printers` = '" . $data["ID"] . "';"; if ($result = $DB->query($query)) { $data2 = $DB->fetch_array($result); } $last_date = ""; if (isset($data2["last_fusioninventory_update"])) { $last_date = $data2["last_fusioninventory_update"]; } $out = "<div align='center'>" . convDateTime($last_date) . "</div>"; return $out; break; // ** FusionInventory - SNMP models // ** FusionInventory - SNMP models case "glpi_plugin_fusioninventory_model_infos.ID": $plugin_fusioninventory_snmp = new PluginFusioninventorySNMP(); $FK_model_DB = $plugin_fusioninventory_snmp->GetSNMPModel($data["ID"], $type); $out = "<a href=\"" . $CFG_GLPI["root_doc"] . "/plugins/fusioninventory/front/models.form.php?ID=" . $FK_model_DB . "\">"; $out .= Dropdown::getDropdownName("glpi_plugin_fusioninventory_model_infos", $FK_model_DB, 0); $out .= "</a>"; return "<center>" . $out . "</center>"; break; // ** FusionInventory - SNMP authentification // ** FusionInventory - SNMP authentification case "glpi_plugin_fusioninventory_snmpauths.ID": $plugin_fusioninventory_snmp = new PluginFusioninventorySnmpauth(); $FK_auth_DB = $plugin_fusioninventory_snmp->GetSNMPAuth($data["ID"], $type); $out = "<a href=\"" . $CFG_GLPI["root_doc"] . "/plugins/fusioninventory/front/snmp_auth.form.php?ID=" . $FK_auth_DB . "\">"; $out .= Dropdown::getDropdownName("glpi_plugin_fusioninventory_snmpauths", $FK_auth_DB, 0); $out .= "</a>"; return "<center>" . $out . "</center>"; break; } break; // * Model List (plugins/fusioninventory/front/models.php) // * Model List (plugins/fusioninventory/front/models.php) case PLUGIN_FUSIONINVENTORY_MODEL: switch ($table . '.' . $field) { // ** Name of type of model (network, printer...) case "glpi_plugin_fusioninventory_model_infos.device_type": $out = '<center> '; switch ($data["ITEM_{$num}"]) { case COMPUTER_TYPE: $out .= $LANG["Menu"][0]; break; case NETWORKING_TYPE: $out .= $LANG["Menu"][1]; break; case PRINTER_TYPE: $out .= $LANG["Menu"][2]; break; case PERIPHERAL_TYPE: $out .= $LANG["Menu"][16]; break; case PHONE_TYPE: $out .= $LANG["Menu"][34]; break; } $out .= '</center>'; return $out; break; // ** Display pic / link for exporting model // ** Display pic / link for exporting model case "glpi_plugin_fusioninventory_model_infos.ID": $out = "<div align='center'><form></form><form method='get' action='" . GLPI_ROOT . "/plugins/fusioninventory/front/models.export.php' target='_blank'>\n\t\t\t\t\t\t<input type='hidden' name='model' value='" . $data["ID"] . "' />\n\t\t\t\t\t\t<input name='export' src='" . GLPI_ROOT . "/pics/right.png' title='Exporter' value='Exporter' type='image'>\n\t\t\t\t\t\t</form></div>"; return "<center>" . $out . "</center>"; break; } break; // * Authentification List (plugins/fusioninventory/front/snmp_auth.php) // * Authentification List (plugins/fusioninventory/front/snmp_auth.php) case PLUGIN_FUSIONINVENTORY_SNMP_AUTH: switch ($table . '.' . $field) { // ** Hidden auth passphrase (SNMP v3) case "glpi_plugin_fusioninventory_snmpauths.auth_passphrase": $out = ""; if (empty($data["ITEM_{$num}"])) { } else { $out = "********"; } return $out; break; // ** Hidden priv passphrase (SNMP v3) // ** Hidden priv passphrase (SNMP v3) case "glpi_plugin_fusioninventory_snmpauths.priv_passphrase": $out = ""; if (empty($data["ITEM_{$num}"])) { } else { $out = "********"; } return $out; break; } break; // * Unknown mac addresses connectd on switch - report (plugins/fusioninventory/report/unknown_mac.php) // * Unknown mac addresses connectd on switch - report (plugins/fusioninventory/report/unknown_mac.php) case PLUGIN_FUSIONINVENTORY_MAC_UNKNOWN: switch ($table . '.' . $field) { // ** FusionInventory - switch case "glpi_plugin_fusioninventory_networking.ID": $out = ''; include_once GLPI_ROOT . "/inc/networking.class.php"; $netport = new Netport(); $list = explode("\$\$\$\$", $data["ITEM_{$num}"]); foreach ($list as $numtmp => $vartmp) { $netport->getDeviceData($vartmp, PLUGIN_FUSIONINVENTORY_MAC_UNKNOWN); $out .= "<a href=\"" . $CFG_GLPI["root_doc"] . "/" . $INFOFORM_PAGES[PLUGIN_FUSIONINVENTORY_MAC_UNKNOWN] . "?ID=" . $vartmp . "\">"; $out .= $netport->device_name; if ($CFG_GLPI["view_ID"]) { $out .= " (" . $vartmp . ")"; } $out .= "</a><br/>"; } return "<center>" . $out . "</center>"; break; // ** FusionInventory - switch port // ** FusionInventory - switch port case "glpi_plugin_fusioninventory_networking_ports.ID": $out = ''; include_once GLPI_ROOT . "/inc/networking.class.php"; if (!empty($data["ITEM_{$num}"])) { $list = explode("\$\$\$\$", $data["ITEM_{$num}"]); $np = new Netport(); foreach ($list as $numtmp => $vartmp) { $np->getFromDB($vartmp); $out .= "<a href='" . GLPI_ROOT . "/front/networking.port.php?ID=" . $vartmp . "'>" . $np->fields["name"] . "</a><br/>"; } } return "<center>" . $out . "</center>"; break; case "glpi_plugin_fusioninventory_unknown_device.type": $out = '<center> '; switch ($data["ITEM_{$num}"]) { case COMPUTER_TYPE: $out .= $LANG["Menu"][0]; break; case NETWORKING_TYPE: $out .= $LANG["Menu"][1]; break; case PRINTER_TYPE: $out .= $LANG["Menu"][2]; break; case PERIPHERAL_TYPE: $out .= $LANG["Menu"][16]; break; case PHONE_TYPE: $out .= $LANG["Menu"][34]; break; } $out .= '</center>'; return $out; break; } break; // * // * case PLUGIN_FUSIONINVENTORY_SNMP_NETWORKING_PORTS: switch ($table . '.' . $field) { } break; // * Ports date connection - report (plugins/fusioninventory/report/ports_date_connections.php) // * Ports date connection - report (plugins/fusioninventory/report/ports_date_connections.php) case PLUGIN_FUSIONINVENTORY_SNMP_NETWORKING_PORTS2: switch ($table . '.' . $field) { // ** Name and link of networking device (switch) case "glpi_plugin_fusioninventory_networking_ports.ID": $query = "SELECT `glpi_networking`.`name` AS `name`, `glpi_networking`.`ID` AS `ID`\n FROM `glpi_networking`\n LEFT JOIN `glpi_networking_ports`\n ON `on_device` = `glpi_networking`.`ID`\n LEFT JOIN `glpi_plugin_fusioninventory_networking_ports`\n ON `glpi_networking_ports`.`ID`=`FK_networking_ports`\n WHERE `glpi_plugin_fusioninventory_networking_ports`.`ID`='" . $data["ITEM_{$num}"] . "'\n LIMIT 0,1;"; $result = $DB->query($query); $data2 = $DB->fetch_assoc($result); $out = "<a href='" . GLPI_ROOT . "/front/networking.form.php?ID=" . $data2["ID"] . "'>" . $data2["name"] . "</a>"; return "<center>" . $out . "</center>"; break; // ** Name and link of port of networking device (port of switch) // ** Name and link of port of networking device (port of switch) case "glpi_plugin_fusioninventory_networking_ports.FK_networking_ports": $netport = new Netport(); $netport->getFromDB($data["ITEM_{$num}"]); $name = ""; if (isset($netport->fields["name"])) { $name = $netport->fields["name"]; } $out = "<a href='" . GLPI_ROOT . "/front/networking.port.php?ID=" . $data["ITEM_{$num}"] . "'>" . $name . "</a>"; return "<center>" . $out . "</center>"; break; // ** Location of switch // ** Location of switch case "glpi_dropdown_locations.ID": $out = Dropdown::getDropdownName("glpi_dropdown_locations", $data["ITEM_{$num}"]); return "<center>" . $out . "</center>"; break; } break; // * FusionInventory Agents list (plugins/fusioninventory/front/agents.php) // * FusionInventory Agents list (plugins/fusioninventory/front/agents.php) case PLUGIN_FUSIONINVENTORY_SNMP_AGENTS: break; // * range IP list (plugins/fusioninventory/front/rangeip.php) // * range IP list (plugins/fusioninventory/front/rangeip.php) case PLUGIN_FUSIONINVENTORY_SNMP_RANGEIP: switch ($table . '.' . $field) { // ** Display entity name case "glpi_entities.name": if ($data["ITEM_{$num}"] == '') { $out = Dropdown::getDropdownName("glpi_entities", $data["ITEM_{$num}"]); return "<center>" . $out . "</center>"; } break; } break; // * Detail of ports history (plugins/fusioninventory/report/switch_ports.history.php) // * Detail of ports history (plugins/fusioninventory/report/switch_ports.history.php) case PLUGIN_FUSIONINVENTORY_SNMP_HISTORY: switch ($table . '.' . $field) { // ** Display switch and Port case "glpi_networking_ports.ID": $Array_device = PluginFusioninventoryPort::getUniqueObjectfieldsByportID($data["ITEM_{$num}"]); $CommonItem = new CommonItem(); $CommonItem->getFromDB($Array_device["device_type"], $Array_device["on_device"]); $out = "<div align='center'>" . $CommonItem->getLink(1); $query = "SELECT *\n FROM `glpi_networking_ports`\n WHERE `ID`='" . $data["ITEM_{$num}"] . "';"; $result = $DB->query($query); if ($DB->numrows($result) != "0") { $out .= "<br/><a href='" . GLPI_ROOT . "/front/networking.port.php?ID=" . $data["ITEM_{$num}"] . "'>" . $DB->result($result, 0, "name") . "</a>"; } $out .= "</td>"; return $out; break; // ** Display GLPI field of device // ** Display GLPI field of device case "glpi_plugin_fusioninventory_snmphistories.Field": $out = $FUSIONINVENTORY_MAPPING[NETWORKING_TYPE][$data["ITEM_{$num}"]]['name']; return $out; break; // ** Display Old Value (before changement of value) // ** Display Old Value (before changement of value) case "glpi_plugin_fusioninventory_snmphistories.old_value": // TODO ADD LINK TO DEVICE if (substr_count($data["ITEM_{$num}"], ":") == 5 and empty($data["ITEM_3"])) { return "<center><b>" . $data["ITEM_{$num}"] . "</b></center>"; } break; // ** Display New Value (new value modified) // ** Display New Value (new value modified) case "glpi_plugin_fusioninventory_snmphistories.new_value": if (substr_count($data["ITEM_{$num}"], ":") == 5 and empty($data["ITEM_3"])) { return "<center><b>" . $data["ITEM_{$num}"] . "</b></center>"; } break; } break; } return ""; }