/** * Print the HTML array of the Netpoint associated to a Location * *@param $ID of the Location * *@return Nothing (display) **/ function showNetpoints($ID) { global $DB, $CFG_GLPI, $LANG; $netpoint = new Netpoint(); $this->check($ID, 'r'); $canedit = $this->can($ID, 'w'); if (isset($_REQUEST["start"])) { $start = $_REQUEST["start"]; } else { $start = 0; } $number = countElementsInTable('glpi_netpoints', "`locations_id`='{$ID}'"); echo "<br><div class='center'>"; if ($number < 1) { echo "<table class='tab_cadre_fixe'>"; echo "<tr><th colspan>" . $LANG['networking'][51] . " - " . $LANG['search'][15] . "</th></tr>"; echo "</table>\n"; } else { printAjaxPager($this->getTreeLink() . " - " . $LANG['networking'][51], $start, $number); if ($canedit) { echo "<form method='post' name='massiveaction_form' id='massiveaction_form' action='" . $CFG_GLPI["root_doc"] . "/front/massiveaction.php'>"; } echo "<table class='tab_cadre_fixe'><tr>"; if ($canedit) { echo "<th width='10'> </th>"; } echo "<th>" . $LANG['common'][16] . "</th>"; // Name echo "<th>" . $LANG['common'][25] . "</th>"; // Comment echo "</tr>\n"; $crit = array('locations_id' => $ID, 'ORDER' => 'name', 'START' => $start, 'LIMIT' => $_SESSION['glpilist_limit']); initNavigateListItems('Netpoint', $this->getTypeName() . "= " . $this->fields['name']); foreach ($DB->request('glpi_netpoints', $crit) as $data) { addToNavigateListItems('Netpoint', $data["id"]); echo "<tr class='tab_bg_1'>"; if ($canedit) { echo "<td><input type='checkbox' name='item[" . $data["id"] . "]' value='1'></td>"; } echo "<td><a href='" . $netpoint->getFormURL(); echo '?id=' . $data['id'] . "'>" . $data['name'] . "</a></td>"; echo "<td>" . $data['comment'] . "</td>"; echo "</tr>\n"; } echo "</table>\n"; if ($canedit) { openArrowMassive("massiveaction_form", true); echo "<input type='hidden' name='itemtype' value='Netpoint'>"; echo "<input type='hidden' name='action' value='delete'>"; closeArrowMassive('massiveaction', $LANG['buttons'][6]); echo "</form>\n"; } } if ($canedit) { // Minimal form for quick input. echo "<form action='" . $netpoint->getFormURL() . "' method='post'>"; echo "<br><table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_2 center'><td class='b'>" . $LANG['common'][87] . "</td>"; echo "<td>" . $LANG['common'][16] . " : "; autocompletionTextField($this, "name", array('value' => '')); echo "<input type='hidden' name='entities_id' value='" . $_SESSION['glpiactive_entity'] . "'>"; echo "<input type='hidden' name='locations_id' value='{$ID}'></td>"; echo "<td><input type='submit' name='add' value=\"" . $LANG['buttons'][8] . "\" class='submit'>"; echo "</td></tr>\n"; echo "</table></form>\n"; // Minimal form for massive input. echo "<form action='" . $netpoint->getFormURL() . "' method='post'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_2 center'><td class='b'>" . $LANG['common'][87] . "</td>"; echo "<td>" . $LANG['common'][16] . " : "; echo "<input type='text' maxlength='100' size='10' name='_before'> "; Dropdown::showInteger('_from', 0, 0, 400); echo " --> "; Dropdown::showInteger('_to', 0, 0, 400); echo " <input type='text' maxlength='100' size='10' name='_after'><br>"; echo "<input type='hidden' name='entities_id' value='" . $_SESSION['glpiactive_entity'] . "'>"; echo "<input type='hidden' name='locations_id' value='{$ID}'></td>"; echo "<input type='hidden' name='_method' value='addMulti'></td>"; echo "<td><input type='submit' name='execute' value=\"" . $LANG['buttons'][8] . "\"\n class='submit'>"; echo "</td></tr>\n"; echo "</table></form>\n"; } echo "</div>\n"; }
/** * Print out an HTML "<select>" for a dropdown with preselected value * * * @param $myname the name of the HTML select * @param $value the preselected value we want * @param $locations_id default location ID for search * @param $display_comment display the comment near the dropdown * @param $entity_restrict Restrict to a defined entity * @param $devtype * @return nothing (display the select box) * */ static function dropdownNetpoint($myname, $value = 0, $locations_id = -1, $display_comment = 1, $entity_restrict = -1, $devtype = -1) { global $CFG_GLPI, $LANG; $rand = mt_rand(); $name = "------"; $comment = ""; $limit_length = $_SESSION["glpidropdown_chars_limit"]; if (empty($value)) { $value = 0; } if ($value > 0) { $tmpname = Dropdown::getDropdownName("glpi_netpoints", $value, 1); if ($tmpname["name"] != " ") { $name = $tmpname["name"]; $comment = $tmpname["comment"]; $limit_length = max(utf8_strlen($name), $_SESSION["glpidropdown_chars_limit"]); } } $use_ajax = false; if ($CFG_GLPI["use_ajax"]) { if ($locations_id < 0 || $devtype == 'NetworkEquipment') { $nb = countElementsInTableForEntity("glpi_netpoints", $entity_restrict); } else { if ($locations_id > 0) { $nb = countElementsInTable("glpi_netpoints", "locations_id={$locations_id} "); } else { $nb = countElementsInTable("glpi_netpoints", "locations_id=0 " . getEntitiesRestrictRequest(" AND ", "glpi_netpoints", '', $entity_restrict)); } } if ($nb > $CFG_GLPI["ajax_limit_count"]) { $use_ajax = true; } } $params = array('searchText' => '__VALUE__', 'value' => $value, 'locations_id' => $locations_id, 'myname' => $myname, 'limit' => $limit_length, 'comment' => $display_comment, 'rand' => $rand, 'entity_restrict' => $entity_restrict, 'devtype' => $devtype); $default = "<select name='{$myname}'><option value='{$value}'>{$name}</option></select>"; ajaxDropdown($use_ajax, "/ajax/dropdownNetpoint.php", $params, $default, $rand); // Display comment if ($display_comment) { showToolTip($comment); $item = new Netpoint(); if ($item->canCreate()) { echo "<img alt='' title=\"" . $LANG['buttons'][8] . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/add_dropdown.png' style='cursor:pointer; margin-left:2px;' " . "onClick=\"var w = window.open('" . $item->getFormURL() . "?popup=1&rand={$rand}' ,'glpipopup', 'height=400, " . "width=1000, top=100, left=100, scrollbars=yes' );w.focus();\">"; } } return $rand; }