/** * Complete Dropdown system using ajax to get datas * * @param $use_ajax Use ajax search system (if not display a standard dropdown) * @param $relativeurl Relative URL to the root directory of GLPI * @param $params Parameters to send to ajax URL * @param $default Default datas t print in case of $use_ajax * @param $rand Random parameter used * **/ function ajaxDropdown($use_ajax, $relativeurl, $params = array(), $default = " ", $rand = 0) { global $CFG_GLPI, $DB, $LANG; $initparams = $params; if ($rand == 0) { $rand = mt_rand(); } if ($use_ajax) { ajaxDisplaySearchTextForDropdown($rand); ajaxUpdateItemOnInputTextEvent("search_{$rand}", "results_{$rand}", $CFG_GLPI["root_doc"] . $relativeurl, $params); } echo "<span id='results_{$rand}'>\n"; if (!$use_ajax) { // Save post datas if exists $oldpost = array(); if (isset($_POST) && count($_POST)) { $oldpost = $_POST; } $_POST = $params; $_POST["searchText"] = $CFG_GLPI["ajax_wildcard"]; include GLPI_ROOT . $relativeurl; // Restore $_POST datas if (count($oldpost)) { $_POST = $oldpost; } } else { echo $default; } echo "</span>\n"; echo "<script type='text/javascript'>"; echo "function update_results_{$rand}() {"; if ($use_ajax) { ajaxUpdateItemJsCode("results_{$rand}", $CFG_GLPI['root_doc'] . $relativeurl, $initparams, true, "search_{$rand}"); } else { $initparams["searchText"] = $CFG_GLPI["ajax_wildcard"]; ajaxUpdateItemJsCode("results_{$rand}", $CFG_GLPI['root_doc'] . $relativeurl, $initparams, true, ""); } echo "}"; echo "</script>"; }
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: Julien Dombre // Purpose of file: // ---------------------------------------------------------------------- define('GLPI_ROOT', '..'); include GLPI_ROOT . "/inc/includes.php"; header("Content-Type: text/html; charset=UTF-8"); header_nocache(); checkLoginUser(); // Make a select box if (isset($_POST["itemtype"]) && Ticket::isPossibleToAssignType($_POST["itemtype"])) { $table = getTableForItemType($_POST["itemtype"]); $rand = mt_rand(); echo " "; ajaxDisplaySearchTextForDropdown($_POST['myname'] . $rand, 8); $paramstrackingdt = array('searchText' => '__VALUE__', 'myname' => $_POST["myname"], 'table' => $table, 'itemtype' => $_POST["itemtype"], 'entity_restrict' => $_POST['entity_restrict']); ajaxUpdateItemOnInputTextEvent("search_" . $_POST['myname'] . $rand, "results_ID{$rand}", $CFG_GLPI["root_doc"] . "/ajax/dropdownFindNum.php", $paramstrackingdt, false); echo "<span id='results_ID{$rand}'>"; echo "<select name='id'><option value='0'>" . DROPDOWN_EMPTY_VALUE . "</option></select>"; echo "</span>\n"; if (!isset($_POST["admin"]) || $_POST["admin"] == 0) { echo "<br>" . $LANG['help'][23]; } }