function showForm(Printer $item, $options = array())
 {
     global $DB;
     Session::checkRight('plugin_fusioninventory_printer', READ);
     $id = $item->getID();
     if (!($data = $this->find("`printers_id`='" . $id . "'", '', 1))) {
         // Add in database if not exist
         $input = array();
         $input['printers_id'] = $id;
         $_SESSION['glpi_plugins_fusinvsnmp_table'] = 'glpi_printers';
         $ID_tn = $this->add($input);
         $this->getFromDB($ID_tn);
     } else {
         foreach ($data as $datas) {
             $this->fields = $datas;
         }
     }
     // Form printer informations
     echo "<div align='center'>";
     echo "<form method='post' name='snmp_form' id='snmp_form'\n                 action=\"" . $options['target'] . "\">";
     echo "<table class='tab_cadre' cellpadding='5' width='950'>";
     echo "<tr class='tab_bg_1'>";
     echo "<th colspan='4'>";
     echo __('SNMP information', 'fusioninventory');
     echo "</th>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>";
     echo __('Sysdescr', 'fusioninventory');
     echo "</td>";
     echo "<td>";
     echo "<textarea name='sysdescr' cols='45' rows='5'>";
     echo $this->fields['sysdescr'];
     echo "</textarea>";
     echo "</td>";
     echo "<td align='center'>";
     echo __('Last inventory', 'fusioninventory') . "&nbsp;:";
     echo "</td>";
     echo "<td>";
     echo Html::convDateTime($this->fields['last_fusioninventory_update']);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'></td>";
     echo "<td align='center'>";
     echo "</td>";
     echo "<td align='center'>" . __('SNMP authentication', 'fusioninventory') . "&nbsp;:</td>";
     echo "<td align='center'>";
     PluginFusioninventoryConfigSecurity::auth_dropdown($this->fields["plugin_fusioninventory_configsecurities_id"]);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_2 center'>";
     echo "<td colspan='4'>";
     echo "<div align='center'>";
     echo "<input type='hidden' name='id' value='" . $id . "'>";
     echo "<input type='submit' name='update' value=\"" . __('Update') . "\" class='submit' >";
     echo "</td>";
     echo "</tr>";
     echo "</table>";
     Html::closeForm();
     echo "</div>";
 }
 /**
  * Display form for unmanaged device
  *
  * @param $id integer id of the unmanaged device
  * @param $options array
  *
  * @return bool TRUE if form is ok
  *
  **/
 function showForm($id, $options = array())
 {
     $this->initForm($id, $options);
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . __('Name') . "&nbsp;:</td>";
     echo "<td align='center'>";
     Html::autocompletionTextField($this, 'name', array('size' => 35));
     echo "</td>";
     if (Session::isMultiEntitiesMode()) {
         echo "<td align='center'>" . __('Entity') . "&nbsp;:</td>";
         echo "</td>";
         echo "<td align='center'>";
         Dropdown::show("Entity", array('name' => 'entities_id', 'value' => $this->fields["entities_id"]));
         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'>" . __('Type') . "&nbsp;:</td>";
     echo "<td align='center'>";
     $type_list = array();
     $type_list[] = 'Computer';
     $type_list[] = 'NetworkEquipment';
     $type_list[] = 'Printer';
     $type_list[] = 'Peripheral';
     $type_list[] = 'Phone';
     Dropdown::showItemTypes('item_type', $type_list, array('value' => $this->fields["item_type"]));
     echo "</td>";
     echo "<td align='center'>" . __('Alternate username') . "&nbsp;:</td>";
     echo "</td>";
     echo "<td align='center'>";
     Html::autocompletionTextField($this, 'contact', array('size' => 35));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . __('Location') . "&nbsp;:</td>";
     echo "<td align='center'>";
     Dropdown::show("Location", array('name' => "locations_id", 'value' => $this->fields["locations_id"]));
     echo "</td>";
     echo "<td align='center'>" . __('Domain') . "&nbsp;:</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'>" . __('Approved devices', 'fusioninventory') . " :</td>";
     echo "<td align='center'>";
     Dropdown::showYesNo("accepted", $this->fields["accepted"]);
     echo "</td>";
     echo "<td align='center'>" . __('Serial Number') . "&nbsp;:</td>";
     echo "</td>";
     echo "<td align='center'>";
     Html::autocompletionTextField($this, 'serial', array('size' => 35));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . __('Network hub', 'fusioninventory') . " :</td>";
     echo "<td align='center'>";
     echo Dropdown::getYesNo($this->fields["hub"]);
     echo "</td>";
     echo "<td align='center'>" . __('Inventory number') . "&nbsp;:</td>";
     echo "</td>";
     echo "<td align='center'>";
     Html::autocompletionTextField($this, 'otherserial', array('size' => 35));
     echo "</td>";
     echo "</tr>";
     if (!empty($this->fields["ip"]) or !empty($this->fields["mac"])) {
         echo "<tr class='tab_bg_1'>";
         echo "<td align='center'>" . __('IP') . " :</td>";
         echo "<td align='center'>";
         Html::autocompletionTextField($this, 'ip', array('size' => 35));
         echo "</td>";
         echo "<td colspan='2'></td>";
         echo "</tr>";
     }
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center' rowspan='2'>";
     echo __('Sysdescr', 'fusioninventory') . "&nbsp;:";
     echo "</td>";
     echo "<td rowspan='2'>";
     echo "<textarea name='sysdescr'  cols='45' rows='5'>" . $this->fields["sysdescr"] . "</textarea>";
     echo "<td align='center'></td>";
     echo "<td align='center'>";
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . __('SNMP authentication', 'fusioninventory') . "&nbsp;:</td>";
     echo "<td align='center'>";
     PluginFusioninventoryConfigSecurity::auth_dropdown($this->fields['plugin_fusioninventory_configsecurities_id']);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . __('Comments') . " : </td>";
     echo "</td>";
     echo "<td align='middle' colspan='3'>";
     echo "<textarea  cols='80' rows='2' name='comment' >" . $this->fields["comment"] . "</textarea>";
     echo "</td>";
     echo "</tr>";
     $this->showFormButtons($options);
     return TRUE;
 }
 /**
  * @since version 0.85
  *
  * @see CommonDBTM::showMassiveActionsSubForm()
  **/
 static function showMassiveActionsSubForm(MassiveAction $ma)
 {
     switch ($ma->getAction()) {
         case "assign_auth":
             PluginFusioninventoryConfigSecurity::auth_dropdown();
             echo Html::submit(_x('button', 'Post'), array('name' => 'massiveaction'));
             return true;
             break;
     }
 }
 function showNetworkEquipmentInformation(CommonDBTM $item, $options)
 {
     global $DB;
     $id = $item->getID();
     if (!($data = $this->find("`networkequipments_id`='" . $id . "'", '', 1))) {
         // Add in database if not exist
         $input = array();
         $input['networkequipments_id'] = $id;
         $_SESSION['glpi_plugins_fusinvsnmp_table'] = 'glpi_networkequipments';
         $ID_tn = $this->add($input);
         $this->getFromDB($ID_tn);
     } else {
         foreach ($data as $datas) {
             $this->fields = $datas;
         }
     }
     // Form networking informations
     echo "<form name='form' method='post' action='" . $options['target'] . "'>";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr class='tab_bg_1'>";
     echo "<th colspan='4'>";
     echo __('SNMP information', 'fusioninventory');
     echo "</th>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center' rowspan='4'>";
     echo __('Sysdescr', 'fusioninventory') . "&nbsp;:";
     echo "</td>";
     echo "<td rowspan='4'>";
     echo "<textarea name='sysdescr' cols='45' rows='5'>";
     echo $this->fields['sysdescr'];
     echo "</textarea>";
     echo "<td align='center'></td>";
     echo "<td align='center'>";
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . __('SNMP authentication', 'fusioninventory') . "&nbsp;:</td>";
     echo "<td align='center'>";
     PluginFusioninventoryConfigSecurity::auth_dropdown($this->fields['plugin_fusioninventory_configsecurities_id']);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>";
     echo __('CPU usage (in %)', 'fusioninventory') . "&nbsp;:";
     echo "</td>";
     echo "<td>";
     Html::displayProgressBar(250, $this->fields['cpu'], array('simple' => TRUE));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>";
     echo __('Memory usage (in %)', 'fusioninventory') . "&nbsp;:";
     echo "</td>";
     echo "<td>";
     $query2 = "SELECT *\n                 FROM `glpi_networkequipments`\n                 WHERE `id`='" . $id . "';";
     $result2 = $DB->query($query2);
     $data2 = $DB->fetch_assoc($result2);
     $ram_pourcentage = 0;
     if (!empty($data2["ram"]) and !empty($this->fields['memory'])) {
         $ram_pourcentage = ceil(100 * ($data2["ram"] - $this->fields['memory']) / $data2["ram"]);
     }
     if ($data2["ram"] - $this->fields['memory'] < 0 or empty($this->fields['memory'])) {
         echo "<center><strong>" . __('Datas not available', 'fusioninventory') . "</strong></center>";
     } else {
         Html::displayProgressBar(250, $ram_pourcentage, array('title' => " (" . ($data2["ram"] - $this->fields['memory']) . " Mo / " . $data2["ram"] . " Mo)"));
     }
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_2 center'>";
     echo "<td colspan='4'>";
     echo "<input type='hidden' name='id' value='" . $id . "'>";
     echo "<input type='submit' name='update' value=\"" . __('Update') . "\" class='submit' >";
     echo "</td>";
     echo "</tr>";
     echo "</table>";
     Html::closeForm();
 }