本文整理汇总了PHP中Ajax::updateItemOnSelectEvent方法的典型用法代码示例。如果您正苦于以下问题:PHP Ajax::updateItemOnSelectEvent方法的具体用法?PHP Ajax::updateItemOnSelectEvent怎么用?PHP Ajax::updateItemOnSelectEvent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ajax
的用法示例。
在下文中一共展示了Ajax::updateItemOnSelectEvent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showAllItems
static function showAllItems($myname, $value_type = 0, $value = 0, $entity_restrict = -1, $types, $locations_id = -1, $action = 'showItem')
{
global $DB, $CFG_GLPI;
$rand = mt_rand();
$plugin = new Plugin();
echo "<table border='0'><tr><td>\n";
if ($myname == 'type') {
$newtypes = array_flip($types);
unset($newtypes['Location']);
unset($newtypes['Netpoint']);
if ($plugin->isActivated("resources")) {
unset($newtypes['PluginResourcesResource']);
}
$types = array_flip($newtypes);
}
$rand = Dropdown::showItemTypes($myname, $types, array('emptylabel' => Dropdown::EMPTY_VALUE, 'width' => 150));
$params = array('type' => '__VALUE__', 'value' => $value, 'myname' => $myname, 'action' => $action, 'entity_restrict' => $entity_restrict, 'locations_id' => $locations_id);
Ajax::updateItemOnSelectEvent("dropdown_{$myname}{$rand}", "show_{$myname}{$rand}", $CFG_GLPI["root_doc"] . "/plugins/positions/ajax/dropdownAllItems.php", $params);
echo "</td><td>\n";
echo "<span id='show_{$myname}{$rand}'> </span>\n";
echo "</td></tr></table>\n";
if ($value > 0) {
echo "<script type='text/javascript' >\n";
echo "document.getElementById('item_type{$rand}').value='" . $value_type . "';";
echo "</script>\n";
$params["typetable"] = $value_type;
Ajax::updateItem("show_{$myname}{$rand}", $CFG_GLPI["root_doc"] . "/plugins/positions/ajax/dropdownAllItems.php", $params);
}
return $rand;
}
示例2: itemtypeDropdown
public function itemtypeDropdown()
{
global $CFG_GLPI;
$itemtypes = self::getTypes();
echo "<select name='itemtype' id='tabsitemtype'>";
echo "<option value='0'>" . Dropdown::EMPTY_VALUE . "</option>\n";
foreach ($itemtypes as $key => $value) {
if ($this->fields['id'] > 0 && $this->fields['itemtype'] == $key) {
echo "<option value='{$key}' selected='selected'>{$value}</option>";
} else {
echo "<option value='{$key}'>{$value}</option>";
}
}
echo "</select>";
$params = array('itemtype' => '__VALUE__', 'myname' => 'tabstab', 'value' => $this->fields['tab'], 'id' => $this->fields['id']);
Ajax::updateItemOnSelectEvent('tabsitemtype', 'tabstab', $CFG_GLPI["root_doc"] . "/plugins/custom/ajax/dropdowntab.php", $params);
}
示例3: showAllItems
static function showAllItems($myname, $value_type = 0, $value = 0, $entity_restrict = -1, $types, $locations_id = -1)
{
global $DB, $CFG_GLPI;
$rand = mt_rand();
$plugin = new Plugin();
echo "<table border='0'><tr><td>\n";
echo "<select name='type' id='item_type{$rand}'>\n";
echo "<option value='0;0'>" . Dropdown::EMPTY_VALUE . "</option>\n";
if ($myname == 'type') {
$newtypes = array_flip($types);
unset($newtypes['Location']);
unset($newtypes['Netpoint']);
if ($plugin->isActivated("resources")) {
unset($newtypes['PluginResourcesResource']);
}
$types = array_flip($newtypes);
}
foreach ($types as $type => $label) {
$item = new $label();
if ($myname == 'type') {
$table = getTableForItemType($label . "Type");
} else {
$table = getTableForItemType($label);
}
echo "<option value='" . $label . ";" . $table . "'>" . $item->getTypeName() . "</option>\n";
}
echo "</select>";
$params = array('typetable' => '__VALUE__', 'value' => $value, 'myname' => $myname, 'entity_restrict' => $entity_restrict, 'locations_id' => $locations_id);
Ajax::updateItemOnSelectEvent("item_type{$rand}", "show_{$myname}{$rand}", $CFG_GLPI["root_doc"] . "/plugins/positions/ajax/dropdownAllItems.php", $params);
echo "</td><td>\n";
echo "<span id='show_{$myname}{$rand}'> </span>\n";
echo "</td></tr></table>\n";
if ($value > 0) {
echo "<script type='text/javascript' >\n";
echo "document.getElementById('item_type{$rand}').value='" . $value_type . "';";
echo "</script>\n";
$params["typetable"] = $value_type;
Ajax::updateItem("show_{$myname}{$rand}", $CFG_GLPI["root_doc"] . "/plugins/positions/ajax/dropdownAllItems.php", $params);
}
return $rand;
}
示例4: header
along with GLPI. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
/** @file
* @brief
*/
include '../inc/includes.php';
header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();
Session::checkLoginUser();
// Make a select box
if (isset($_POST["itemtype"]) && CommonITILObject::isPossibleToAssignType($_POST["itemtype"])) {
$table = getTableForItemType($_POST["itemtype"]);
$rand = mt_rand();
// Message for post-only
if (!isset($_POST["admin"]) || $_POST["admin"] == 0) {
echo "<br>" . __('Enter the first letters (user, item name, serial or asset number)');
}
echo "<br>";
$field_id = Html::cleanId("dropdown_" . $_POST['myname'] . $rand);
$p = array('itemtype' => $_POST["itemtype"], 'entity_restrict' => $_POST['entity_restrict'], 'table' => $table, 'myname' => $_POST["myname"]);
if (isset($_POST["used"]) && !empty($_POST["used"])) {
if (isset($_POST["used"][$_POST["itemtype"]])) {
$p["used"] = $_POST["used"][$_POST["itemtype"]];
}
}
echo Html::jsAjaxDropdown($_POST['myname'], $field_id, $CFG_GLPI['root_doc'] . "/ajax/getDropdownFindNum.php", $p);
// Auto update summary of active or just solved tickets
$params = array('items_id' => '__VALUE__', 'itemtype' => $_POST['itemtype']);
Ajax::updateItemOnSelectEvent($field_id, "item_ticket_selection_information", $CFG_GLPI["root_doc"] . "/ajax/ticketiteminformation.php", $params);
}
示例5: showSpecificMassiveActionsParameters
/**
* @see CommonDBTM::showSpecificMassiveActionsParameters()
**/
function showSpecificMassiveActionsParameters($input = array())
{
global $CFG_GLPI;
switch ($input['action']) {
case "change_authtype":
$rand = Auth::dropdown(array('name' => 'authtype'));
$paramsmassaction = array('authtype' => '__VALUE__');
Ajax::updateItemOnSelectEvent("dropdown_authtype{$rand}", "show_massiveaction_field", $CFG_GLPI["root_doc"] . "/ajax/dropdownMassiveActionAuthMethods.php", $paramsmassaction);
echo "<span id='show_massiveaction_field'><br><br>";
echo "<input type='submit' name='massiveaction' class='submit' value='" . _sx('button', 'Post') . "'>";
echo "</span>\n";
return true;
case "add_user_group":
$gu = new Group_User();
return $gu->showSpecificMassiveActionsParameters($input);
case "add_userprofile":
Entity::dropdown(array('entity' => $_SESSION['glpiactiveentities']));
echo ". " . _n('Profile', 'Profiles', 1) . " ";
Profile::dropdownUnder();
echo ". " . __('Recursive') . " ";
Dropdown::showYesNo("is_recursive", 0);
echo "<br><br><input type='submit' name='massiveaction' class='submit' value='" . _sx('button', 'Add') . "'>";
return true;
default:
return parent::showSpecificMassiveActionsParameters($input);
}
return false;
}
示例6: getItemForItemtype
exit;
}
if (!isset($_POST[$item->getRuleIdField()])) {
exit;
}
// Existing action
if ($_POST['ruleactions_id'] > 0) {
$already_used = false;
} else {
// New action
$ra = getItemForItemtype($item->getRuleActionClass());
$used = $ra->getAlreadyUsedForRuleID($_POST[$item->getRuleIdField()], $item->getType());
$already_used = in_array($_POST["field"], $used);
}
echo "<table width='100%'><tr><td width='30%'>";
$action_type = '';
if (isset($_POST["action_type"])) {
$action_type = $_POST["action_type"];
}
$randaction = RuleAction::dropdownActions(array('subtype' => $_POST["sub_type"], 'name' => "action_type", 'field' => $_POST["field"], 'value' => $action_type, 'alreadyused' => $already_used));
echo "</td><td>";
echo "<span id='action_type_span{$randaction}'>\n";
echo "</span>\n";
$paramsaction = array('action_type' => '__VALUE__', 'field' => $_POST["field"], 'sub_type' => $_POST["sub_type"], $item->getForeignKeyField() => $_POST[$item->getForeignKeyField()]);
Ajax::updateItemOnSelectEvent("dropdown_action_type{$randaction}", "action_type_span{$randaction}", $CFG_GLPI["root_doc"] . "/ajax/ruleactionvalue.php", $paramsaction);
if (isset($_POST['value'])) {
$paramsaction['value'] = stripslashes($_POST['value']);
}
Ajax::updateItem("action_type_span{$randaction}", $CFG_GLPI["root_doc"] . "/ajax/ruleactionvalue.php", $paramsaction, "dropdown_action_type{$randaction}");
echo "</td></tr></table>";
}
示例7: key
Session::checkLoginUser();
if (isset($_POST["sub_type"]) && ($rule = getItemForItemtype($_POST["sub_type"]))) {
$criterias = $rule->getAllCriteria();
if (count($criterias)) {
// First include -> first of the predefined array
if (!isset($_POST["criteria"])) {
$_POST["criteria"] = key($criterias);
}
if (isset($criterias[$_POST["criteria"]]['allow_condition'])) {
$allow_condition = $criterias[$_POST["criteria"]]['allow_condition'];
} else {
$allow_condition = array();
}
$condparam = array('criterion' => $_POST["criteria"], 'allow_conditions' => $allow_condition);
if (isset($_POST['condition'])) {
$condparam['value'] = $_POST['condition'];
}
echo "<table width='100%'><tr><td width='30%'>";
$randcrit = RuleCriteria::dropdownConditions($_POST["sub_type"], $condparam);
echo "</td><td>";
echo "<span id='condition_span{$randcrit}'>\n";
echo "</span>\n";
$paramscriteria = array('condition' => '__VALUE__', 'criteria' => $_POST["criteria"], 'sub_type' => $_POST["sub_type"]);
Ajax::updateItemOnSelectEvent("dropdown_condition{$randcrit}", "condition_span{$randcrit}", $CFG_GLPI["root_doc"] . "/ajax/rulecriteriavalue.php", $paramscriteria);
if (isset($_POST['pattern'])) {
$paramscriteria['value'] = stripslashes($_POST['pattern']);
}
Ajax::updateItem("condition_span{$randcrit}", $CFG_GLPI["root_doc"] . "/ajax/rulecriteriavalue.php", $paramscriteria, "dropdown_condition{$randcrit}");
echo "</td></tr></table>";
}
}
示例8: showActorAddForm
/**
* show actor add div
*
* @param $type string actor type
* @param $rand_type integer rand value of div to use
* @param $entities_id integer entity ID
* @param $is_hidden array of hidden fields (if empty consider as not hidden)
* @param $withgroup boolean allow adding a group (true by default)
* @param $withsupplier boolean allow adding a supplier (only one possible in ASSIGN case)
* (false by default)
* @param $inobject boolean display in ITIL object ? (true by default)
*
* @return nothing display
**/
function showActorAddForm($type, $rand_type, $entities_id, $is_hidden = array(), $withgroup = true, $withsupplier = false, $inobject = true)
{
global $CFG_GLPI;
$types = array('' => Dropdown::EMPTY_VALUE, 'user' => __('User'));
if ($withgroup) {
$types['group'] = __('Group');
}
if ($withsupplier && $type == CommonITILActor::ASSIGN) {
$types['supplier'] = __('Supplier');
}
$typename = self::getActorFieldNameType($type);
switch ($type) {
case CommonITILActor::REQUESTER:
if (isset($is_hidden['_users_id_requester']) && $is_hidden['_users_id_requester']) {
unset($types['user']);
}
if (isset($is_hidden['_groups_id_requester']) && $is_hidden['_groups_id_requester']) {
unset($types['group']);
}
break;
case CommonITILActor::OBSERVER:
if (isset($is_hidden['_users_id_observer']) && $is_hidden['_users_id_observer']) {
unset($types['user']);
}
if (isset($is_hidden['_groups_id_observer']) && $is_hidden['_groups_id_observer']) {
unset($types['group']);
}
break;
case CommonITILActor::ASSIGN:
if (isset($is_hidden['_users_id_assign']) && $is_hidden['_users_id_assign']) {
unset($types['user']);
}
if (isset($is_hidden['_groups_id_assign']) && $is_hidden['_groups_id_assign']) {
unset($types['group']);
}
if (isset($types['supplier']) && isset($is_hidden['_suppliers_id_assign']) && $is_hidden['_suppliers_id_assign']) {
unset($types['supplier']);
}
break;
default:
return false;
}
echo "<div " . ($inobject ? "style='display:none'" : '') . " id='itilactor{$rand_type}'>";
$rand = Dropdown::showFromArray("_itil_" . $typename . "[_type]", $types);
$params = array('type' => '__VALUE__', 'actortype' => $typename, 'itemtype' => $this->getType(), 'allow_email' => $type == CommonITILActor::OBSERVER || $type == CommonITILActor::REQUESTER, 'entity_restrict' => $entities_id, 'use_notif' => Entity::getUsedConfig('is_notif_enable_default', $entities_id, '', 1));
Ajax::updateItemOnSelectEvent("dropdown__itil_" . $typename . "[_type]{$rand}", "showitilactor" . $typename . "_{$rand}", $CFG_GLPI["root_doc"] . "/ajax/dropdownItilActors.php", $params);
echo "<span id='showitilactor" . $typename . "_{$rand}'> </span>";
if ($inobject) {
echo "<hr>";
}
echo "</div>";
}
示例9: date
} else {
$end = date("Y-m-d H:i:s", strtotime($begin) + HOUR_TIMESTAMP);
}
echo "<table class='tab_cadre'>";
echo "<tr class='tab_bg_2'><td>" . __('Start date') . "</td><td>";
$rand_begin = Html::showDateTimeField("plan[begin]", array('value' => $begin, 'timestep' => -1, 'maybeempty' => false, 'canedit' => true, 'mindate' => '', 'maxdate' => '', 'mintime' => $CFG_GLPI["planning_begin"], 'maxtime' => $CFG_GLPI["planning_end"]));
echo "</td></tr>\n";
echo "<tr class='tab_bg_2'><td>" . __('Period') . " ";
if (isset($_POST["rand_user"])) {
echo "<span id='user_available" . $_POST["rand_user"] . "'>";
include_once GLPI_ROOT . '/ajax/planningcheck.php';
echo "</span>";
}
echo "</td><td>";
$default_delay = floor((strtotime($end) - strtotime($begin)) / 15 / MINUTE_TIMESTAMP) * 15 * MINUTE_TIMESTAMP;
$rand = Dropdown::showTimeStamp("plan[_duration]", array('min' => 0, 'max' => 50 * HOUR_TIMESTAMP, 'value' => $default_delay, 'emptylabel' => __('Specify an end date')));
echo "<br><div id='date_end{$rand}'></div>";
$params = array('duration' => '__VALUE__', 'end' => $end, 'name' => "plan[end]", 'global_begin' => $CFG_GLPI["planning_begin"], 'global_end' => $CFG_GLPI["planning_end"]);
Ajax::updateItemOnSelectEvent("dropdown_plan[_duration]{$rand}", "date_end{$rand}", $CFG_GLPI["root_doc"] . "/ajax/planningend.php", $params);
if ($default_delay == 0) {
$params['duration'] = 0;
Ajax::updateItem("date_end{$rand}", $CFG_GLPI["root_doc"] . "/ajax/planningend.php", $params);
}
echo "</td></tr>\n";
if ((!isset($_POST["id"]) || $_POST["id"] == 0) && isset($_POST['itemtype']) && PlanningRecall::isAvailable()) {
echo "<tr class='tab_bg_2'><td>" . _x('Planning', 'Reminder') . "</td><td>";
PlanningRecall::dropdown(array('itemtype' => $_POST['itemtype'], 'items_id' => $_POST['items_id']));
echo "</td></tr>";
}
echo "</table>\n";
Html::ajaxFooter();
示例10: showHelpdeskOptions
//.........这里部分代码省略.........
$toadd = array();
if ($ID != 0) {
$toadd = array(self::CONFIG_PARENT => __('Inheritance of the parent entity'));
}
Ticket::dropdownType('tickettype', array('value' => $entity->fields["tickettype"], 'toadd' => $toadd));
if ($entity->fields['tickettype'] == self::CONFIG_PARENT && $ID != 0) {
echo "<font class='green'> ";
echo Ticket::getTicketTypeName(self::getUsedConfig('tickettype', $ID, '', Ticket::INCIDENT_TYPE));
echo "</font>";
}
echo "</td></tr>";
echo "<tr class='tab_bg_1'><td colspan='2'>" . __('Automatic assignment of tickets') . "</td>";
echo "<td colspan='2'>";
$autoassign = self::getAutoAssignMode();
if ($ID == 0) {
unset($autoassign[self::CONFIG_PARENT]);
}
Dropdown::showFromArray('auto_assign_mode', $autoassign, array('value' => $entity->fields["auto_assign_mode"]));
if ($entity->fields['auto_assign_mode'] == self::CONFIG_PARENT && $ID != 0) {
$auto_assign_mode = self::getUsedConfig('auto_assign_mode', $entity->fields['entities_id']);
echo "<font class='green'> ";
echo $autoassign[$auto_assign_mode];
echo "</font>";
}
echo "</td></tr>";
echo "<tr><th colspan='4'>" . __('Automatic closing configuration') . "</th></tr>";
echo "<tr class='tab_bg_1'>" . "<td colspan='2'>" . __('Automatic closing of solved tickets after') . "</td>";
echo "<td colspan='2'>";
$autoclose = array(self::CONFIG_PARENT => __('Inheritance of the parent entity'), self::CONFIG_NEVER => __('Never'), 0 => __('Immediatly'));
if ($ID == 0) {
unset($autoclose[self::CONFIG_PARENT]);
}
Dropdown::showNumber('autoclose_delay', array('value' => $entity->fields['autoclose_delay'], 'min' => 1, 'max' => 99, 'step' => 1, 'toadd' => $autoclose, 'unit' => 'day'));
if ($entity->fields['autoclose_delay'] == self::CONFIG_PARENT && $ID != 0) {
$autoclose_mode = self::getUsedConfig('autoclose_delay', $entity->fields['entities_id'], '', self::CONFIG_NEVER);
echo "<br><font class='green'> ";
if ($autoclose_mode >= 0) {
printf(_n('%d day', '%d days', $autoclose_mode), $autoclose_mode);
} else {
echo $autoclose[$autoclose_mode];
}
echo "</font>";
}
echo "</td></tr>";
echo "<tr><th colspan='4'>" . __('Configuring the satisfaction survey') . "</th></tr>";
echo "<tr class='tab_bg_1'>" . "<td colspan='2'>" . __('Configuring the satisfaction survey') . "</td>";
echo "<td colspan='2'>";
/// no inquest case = rate 0
$typeinquest = array(self::CONFIG_PARENT => __('Inheritance of the parent entity'), 1 => __('Internal survey'), 2 => __('External survey'));
// No inherit from parent for root entity
if ($ID == 0) {
unset($typeinquest[self::CONFIG_PARENT]);
if ($entity->fields['inquest_config'] == self::CONFIG_PARENT) {
$entity->fields['inquest_config'] = 1;
}
}
$rand = Dropdown::showFromArray('inquest_config', $typeinquest, $options = array('value' => $entity->fields['inquest_config']));
echo "</td></tr>\n";
// Do not display for root entity in inherit case
if ($entity->fields['inquest_config'] == self::CONFIG_PARENT && $ID != 0) {
$inquestconfig = self::getUsedConfig('inquest_config', $entity->fields['entities_id']);
$inquestrate = self::getUsedConfig('inquest_config', $entity->fields['entities_id'], 'inquest_rate');
echo "<tr class='tab_bg_1'><td colspan='4' class='green center'>";
if ($inquestrate == 0) {
_e('Disabled');
} else {
echo $typeinquest[$inquestconfig] . '<br>';
$inqconf = self::getUsedConfig('inquest_config', $entity->fields['entities_id'], 'inquest_delay');
printf(_n('%d day', '%d days', $inqconf), $inqconf);
echo "<br>";
//TRANS: %d is the percentage. %% to display %
printf(__('%d%%'), $inquestrate);
if ($inquestconfig == 2) {
echo "<br>";
echo self::getUsedConfig('inquest_config', $entity->fields['entities_id'], 'inquest_URL');
}
}
echo "</td></tr>\n";
}
echo "<tr class='tab_bg_1'><td colspan='4'>";
$_POST = array('inquest_config' => $entity->fields['inquest_config'], 'entities_id' => $ID);
$params = array('inquest_config' => '__VALUE__', 'entities_id' => $ID);
echo "<div id='inquestconfig'>";
include GLPI_ROOT . '/ajax/ticketsatisfaction.php';
echo "</div>\n";
echo "</td></tr>";
if ($canedit) {
echo "<tr class='tab_bg_2'>";
echo "<td class='center' colspan='4'>";
echo "<input type='hidden' name='id' value='" . $entity->fields["id"] . "'>";
echo "<input type='submit' name='update' value=\"" . _sx('button', 'Save') . "\"\n class='submit'>";
echo "</td></tr>";
echo "</table>";
Html::closeForm();
} else {
echo "</table>";
}
echo "</div>";
Ajax::updateItemOnSelectEvent("dropdown_inquest_config{$rand}", "inquestconfig", $CFG_GLPI["root_doc"] . "/ajax/ticketsatisfaction.php", $params);
}
示例11: dropdownNetpoint
/**
* 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 (default 0)
* @param $locations_id default location ID for search (default -1)
* @param $display_comment display the comment near the dropdown (default 1)
* @param $entity_restrict Restrict to a defined entity(default -1)
* @param $devtype (default '')
*
* @return nothing (display the select box)
**/
static function dropdownNetpoint($myname, $value = 0, $locations_id = -1, $display_comment = 1, $entity_restrict = -1, $devtype = '')
{
global $CFG_GLPI;
$rand = mt_rand();
$name = Dropdown::EMPTY_VALUE;
$comment = "";
if (empty($value)) {
$value = 0;
}
if ($value > 0) {
$tmpname = Dropdown::getDropdownName("glpi_netpoints", $value, 1);
if ($tmpname["name"] != " ") {
$name = $tmpname["name"];
$comment = $tmpname["comment"];
}
}
$field_id = Html::cleanId("dropdown_" . $myname . $rand);
$param = array('value' => $value, 'valuename' => $name, 'entity_restrict' => $entity_restrict, 'devtype' => $devtype, 'locations_id' => $locations_id);
echo Html::jsAjaxDropdown($myname, $field_id, $CFG_GLPI['root_doc'] . "/ajax/getDropdownNetpoint.php", $param);
// Display comment
if ($display_comment) {
$comment_id = Html::cleanId("comment_" . $myname . $rand);
Html::showToolTip($comment, array('contentid' => $comment_id));
$item = new self();
if ($item->canCreate()) {
echo "<img alt='' title=\"" . __s('Add') . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/add_dropdown.png' style='cursor:pointer; margin-left:2px;' " . "onClick=\"" . Html::jsGetElementbyID('netpoint' . $rand) . ".dialog('open');\">";
Ajax::createIframeModalWindow('netpoint' . $rand, $item->getFormURL());
}
$paramscomment = array('value' => '__VALUE__', 'table' => "glpi_netpoints");
echo Ajax::updateItemOnSelectEvent($field_id, $comment_id, $CFG_GLPI["root_doc"] . "/ajax/comments.php", $paramscomment, false);
}
return $rand;
}
示例12: header
* @brief
*/
if (strpos($_SERVER['PHP_SELF'], "dropdownSelectSoftware.php")) {
$AJAX_INCLUDE = 1;
include '../inc/includes.php';
header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();
}
Session::checkRight("software", "w");
// Make a select box
$rand = mt_rand();
$where = "";
if (strlen($_POST['searchText']) > 0 && $_POST['searchText'] != $CFG_GLPI["ajax_wildcard"]) {
$where .= " AND `name` " . Search::makeTextSearch($_POST['searchText']) . " ";
}
$where .= getEntitiesRestrictRequest(' AND', 'glpi_softwares', 'entities_id', $_POST["entity_restrict"], true);
$query = "SELECT DISTINCT `glpi_softwares`.`id`,\n `glpi_softwares`.`name`\n FROM `glpi_softwares`\n WHERE `glpi_softwares`.`is_deleted` = '0'\n AND `glpi_softwares`.`is_template` = '0'\n {$where}\n ORDER BY `glpi_softwares`.`name`";
$result = $DB->query($query);
echo "<select name='softwares_id' id='item_type{$rand}'>\n";
echo "<option value='0'>" . Dropdown::EMPTY_VALUE . "</option>\n";
if ($DB->numrows($result)) {
while ($data = $DB->fetch_assoc($result)) {
$softwares_id = $data["id"];
$output = $data["name"];
echo "<option value='{$softwares_id}' title=\"" . Html::cleanInputText($output) . "\">" . Toolbox::substr($output, 0, $_SESSION["glpidropdown_chars_limit"]) . "</option>";
}
}
echo "</select>\n";
$paramsselsoft = array('softwares_id' => '__VALUE__', 'myname' => $_POST["myname"]);
Ajax::updateItemOnSelectEvent("item_type{$rand}", "show_" . $_POST["myname"] . $rand, $CFG_GLPI["root_doc"] . "/ajax/dropdownInstallVersion.php", $paramsselsoft);
echo "<span id='show_" . $_POST["myname"] . "{$rand}'> </span>\n";
示例13: dropdown
/**
* Diplay a dropdown to select an Appliance
*
* Parameters which could be used in options array :
* - name : string / name of the select (default is plugin_appliances_appliances_id)
* - entity : integer or array / restrict to a defined entity or array of entities
* (default '' : current entity)
* - used : array / Already used items ID: not to display in dropdown (default empty)
*
* @param $options possible options
*
* @return nothing (HTML display)
**/
static function dropdown($options = array())
{
global $DB, $CFG_GLPI;
// Defautl values
$p['name'] = 'plugin_appliances_appliances_id';
$p['entity'] = '';
$p['used'] = array();
if (is_array($options) && count($options)) {
foreach ($options as $key => $val) {
$p[$key] = $val;
}
}
$rand = mt_rand();
$where = " WHERE `glpi_plugin_appliances_appliances`.`is_deleted` = '0' " . getEntitiesRestrictRequest("AND", "glpi_plugin_appliances_appliances", '', $p['entity'], true);
if (count($p['used'])) {
$where .= " AND `id` NOT IN ('" . implode("','", $p['used']) . "')";
}
$query = "SELECT *\n FROM `glpi_plugin_appliances_appliancetypes`\n WHERE `id` IN (SELECT DISTINCT `plugin_appliances_appliancetypes_id`\n FROM `glpi_plugin_appliances_appliances` " . $where . ")\n GROUP BY `name`";
$result = $DB->query($query);
echo "<select name='_type' id='type_appliances'>\n";
echo "<option value='0'>" . Dropdown::EMPTY_VALUE . "</option>\n";
while ($data = $DB->fetch_assoc($result)) {
echo "<option value='" . $data['id'] . "'>" . $data['name'] . "</option>\n";
}
echo "</select>\n";
$params = array('type_appliances' => '__VALUE__', 'entity_restrict' => $p['entity'], 'rand' => $rand, 'myname' => $p['name'], 'used' => $p['used']);
Ajax::updateItemOnSelectEvent("type_appliances", "show_" . $p['name'] . $rand, $CFG_GLPI["root_doc"] . "/plugins/appliances/ajax/dropdownTypeAppliances.php", $params);
echo "<span id='show_" . $p['name'] . "{$rand}'>";
$_POST["entity_restrict"] = $p['entity'];
$_POST["type_appliances"] = 0;
$_POST["myname"] = $p['name'];
$_POST["rand"] = $rand;
$_POST["used"] = $p['used'];
include GLPI_ROOT . "/plugins/appliances/ajax/dropdownTypeAppliances.php";
echo "</span>\n";
return $rand;
}
示例14: showGenericSearch
//.........这里部分代码省略.........
$first_group = false;
}
echo "<optgroup label='{$val}'>";
} else {
if (!isset($val['nosearch']) || $val['nosearch'] == false) {
echo "<option title=\"" . Html::cleanInputText($val["name"]) . "\" value='{$key}'";
if (is_array($p['field']) && isset($p['field'][$i]) && $key == $p['field'][$i]) {
echo "selected";
$selected = $key;
}
echo ">" . Toolbox::substr($val["name"], 0, 28) . "</option>\n";
}
}
}
if (!$first_group) {
echo "</optgroup>\n";
}
echo "<option value='all' ";
if (is_array($p['field']) && isset($p['field'][$i]) && $p['field'][$i] == "all") {
echo "selected";
}
echo ">" . __('All') . "</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"]);
Ajax::updateItemOnSelectEvent("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'>";
$rand = mt_rand();
// 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> ";
// Display select of the linked item type available
echo "<select name='itemtype2[{$i}]' id='itemtype2_" . $itemtype . "_" . $i . "_{$rand}'>";
示例15: array
Html::header_nocache();
if (!($item = getItemForItemtype($_POST['itemtype']))) {
exit;
}
$item->checkGlobal(READ);
$group = "";
$values = array();
$searchopt = Search::getCleanedOptions($_POST["itemtype"], READ, false);
echo "<table width='100%'><tr><td width='40%'>";
foreach ($searchopt as $key => $val) {
// print groups
$str_limit = 28;
if (!is_array($val)) {
$group = $val;
} else {
// No search on plugins
if (!isPluginItemType($key) && !isset($val["nometa"])) {
$values[$group][$key] = $val["name"];
}
}
}
$rand = Dropdown::showFromArray("metacriteria[" . $_POST["num"] . "][field]", $values, array('value' => $_POST["field"]));
$field_id = Html::cleanId("dropdown_metacriteria[" . $_POST["num"] . "][field]" . $rand);
echo "</td><td class='left'>";
echo "<span id='Search2Span" . $_POST["itemtype"] . $_POST["num"] . "'>\n";
$_POST['meta'] = 1;
include GLPI_ROOT . "/ajax/searchoption.php";
echo "</span>\n";
$params = array('field' => '__VALUE__', 'itemtype' => $_POST["itemtype"], 'num' => $_POST["num"], 'value' => $_POST["value"], 'searchtype' => $_POST["searchtype"], 'meta' => 1);
Ajax::updateItemOnSelectEvent($field_id, "Search2Span" . $_POST["itemtype"] . $_POST["num"], $CFG_GLPI["root_doc"] . "/ajax/searchoption.php", $params);
echo '</td></tr></table>';