jsSetDropdownValue() static public method

Set dropdown value
static public jsSetDropdownValue ( $id, $value ) : string
$id string id of the dom element
$value string value to set
return string
示例#1
0
 /**
  * Make a select box for all items
  *
  * @since version 0.85
  *
  * @param $options array:
  *   - itemtype_name        : the name of the field containing the itemtype (default 'itemtype')
  *   - items_id_name        : the name of the field containing the id of the selected item
  *                            (default 'items_id')
  *   - itemtypes            : all possible types to search for (default: $CFG_GLPI["state_types"])
  *   - default_itemtype     : the default itemtype to select (don't define if you don't
  *                            need a default) (defaut 0)
  *    - entity_restrict     : restrict entity in searching items (default -1)
  *    - onlyglobal          : don't match item that don't have `is_global` == 1 (false by default)
  *    - checkright          : check to see if we can "view" the itemtype (false by default)
  *    - showItemSpecificity : given an item, the AJAX file to open if there is special
  *                            treatment. For instance, select a Item_Device* for CommonDevice
  *    - emptylabel          : Empty choice's label (default self::EMPTY_VALUE)
  *    - used                : array / Already used items ID: not to display in dropdown (default empty)
  *
  * @return randomized value used to generate HTML IDs
  **/
 static function showSelectItemFromItemtypes(array $options = array())
 {
     global $CFG_GLPI;
     $params = array();
     $params['itemtype_name'] = 'itemtype';
     $params['items_id_name'] = 'items_id';
     $params['itemtypes'] = '';
     $params['default_itemtype'] = 0;
     $params['entity_restrict'] = -1;
     $params['onlyglobal'] = false;
     $params['checkright'] = false;
     $params['showItemSpecificity'] = '';
     $params['emptylabel'] = self::EMPTY_VALUE;
     $params['used'] = array();
     if (is_array($options) && count($options)) {
         foreach ($options as $key => $val) {
             $params[$key] = $val;
         }
     }
     $rand = self::showItemType($params['itemtypes'], array('checkright' => $params['checkright'], 'name' => $params['itemtype_name'], 'emptylabel' => $params['emptylabel']));
     if ($rand) {
         $p = array('idtable' => '__VALUE__', 'name' => $params['items_id_name'], 'entity_restrict' => $params['entity_restrict'], 'showItemSpecificity' => $params['showItemSpecificity']);
         // manage condition
         if ($params['onlyglobal']) {
             $p['condition'] = static::addNewCondition("`is_global` = 1");
         }
         if ($params['used']) {
             $p['used'] = $params['used'];
         }
         $field_id = Html::cleanId("dropdown_" . $params['itemtype_name'] . $rand);
         $show_id = Html::cleanId("show_" . $params['items_id_name'] . $rand);
         Ajax::updateItemOnSelectEvent($field_id, $show_id, $CFG_GLPI["root_doc"] . "/ajax/dropdownAllItems.php", $p);
         echo "<br><span id='{$show_id}'>&nbsp;</span>\n";
         // We check $options as the caller will set $options['default_itemtype'] only if it needs a
         // default itemtype and the default value can be '' thus empty won't be valid !
         if (array_key_exists('default_itemtype', $options)) {
             echo "<script type='text/javascript' >\n";
             echo Html::jsSetDropdownValue($field_id, $params['default_itemtype']);
             echo "</script>\n";
             $p["idtable"] = $params['default_itemtype'];
             Ajax::updateItem($show_id, $CFG_GLPI["root_doc"] . "/ajax/dropdownAllItems.php", $p);
         }
     }
     return $rand;
 }
示例#2
0
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

GLPI is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GLPI. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
/** @file
* @brief
*/
include '../inc/includes.php';
// Send UTF8 Headers
header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();
Session::checkLoginUser();
if (isset($_POST["urgency"]) && isset($_POST["impact"]) && isset($_POST["priority"])) {
    $priority = Ticket::computePriority($_POST["urgency"], $_POST["impact"]);
    if ($_POST["priority"]) {
        echo "<script type='text/javascript' >\n";
        echo Html::jsSetDropdownValue($_POST["priority"], $priority);
        echo "\n</script>";
    } else {
        echo Ticket::getPriorityName($priority);
    }
}
示例#3
0
文件: solution.php 项目: kipman/glpi
GLPI is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GLPI. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
/** @file
* @brief
*/
$AJAX_INCLUDE = 1;
include '../inc/includes.php';
header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();
Session::checkLoginUser();
$rand = mt_rand();
Html::initEditorSystem("solution{$rand}");
if (isset($_POST['value']) && $_POST['value'] > 0) {
    $template = new SolutionTemplate();
    if ($template->getFromDB($_POST['value'])) {
        echo "<textarea id='solution{$rand}' name='solution' rows='12' cols='80'>";
        echo $template->getField('content');
        echo "</textarea>\n";
        echo "<script type='text/javascript'>" . Html::jsSetDropdownValue($_POST["type_id"], $template->getField('solutiontypes_id')) . "</script>";
    }
} else {
    echo "<textarea id='solution{$rand}' name='solution' rows='12' cols='80'></textarea>";
}
示例#4
0
 public static function dropdown($options = array())
 {
     global $DB, $CFG_GLPI;
     $params['itemtype_name'] = 'itemtype';
     $params['items_id_name'] = 'items_id';
     $params['itemtypes'] = array();
     $params['default_itemtype'] = 0;
     $params['entity_restrict'] = -1;
     $params['onlyglobal'] = false;
     $params['checkright'] = false;
     $params['showItemSpecificity'] = '';
     $params['emptylabel'] = '';
     //$p['entity'] = '';
     if (is_array($options) && count($options)) {
         foreach ($options as $key => $val) {
             $p[$key] = $val;
         }
     }
     $rand = mt_rand();
     $query = "select id, name from glpi_plugin_relation_typerelations order by 1";
     $result = $DB->query($query);
     $type_relations = "type_relations" . $p['name'];
     //Desplegable tipos de relaciones
     echo "<select name='_nombresrelaciones' id='nombresrelaciones'>\n";
     if ($DB->numrows($result)) {
         while ($data = $DB->fetch_array($result)) {
             echo "<option value='" . $data[0] . "'>" . $data[1] . "</option>\n";
         }
     }
     echo "</select>\n";
     //Desplegable de las clases
     $query = "select rc.id, rc.classlist, c.viewname FROM glpi_plugin_relation_relationclases rc, glpi_plugin_relation_clases c where rc.classlist=c.name and classname='" . $p['itemtype'] . "' order by 1";
     //echo $query;
     $result = $DB->query($query);
     $arraySelect = array();
     if ($DB->numrows($result)) {
         while ($data = $DB->fetch_array($result)) {
             $arraySelect[] = $data[1];
         }
         $params['itemtypes'] = $arraySelect;
     }
     $rand = Dropdown::showItemType($params['itemtypes'], array('checkright' => $params['checkright'], 'name' => $params['itemtype_name'], 'emptylabel' => $params['emptylabel']));
     if ($rand) {
         $p = array('idtable' => '__VALUE__', 'name' => $params['items_id_name'], 'entity_restrict' => $params['entity_restrict'], 'width' => '120', 'display_emptychoice' => true, 'showItemSpecificity' => $params['showItemSpecificity']);
         if ($params['onlyglobal']) {
             $p['condition'] = "`is_global` = 1";
         }
         $field_id = Html::cleanId("dropdown_" . $params['itemtype_name'] . $rand);
         $show_id = Html::cleanId("show_" . $params['items_id_name'] . $rand);
         Ajax::updateItemOnSelectEvent($field_id, $show_id, $CFG_GLPI["root_doc"] . "/plugins/relation/ajax/dropdownAllItems.php", $p);
         echo "<br><span id='{$show_id}'>&nbsp;</span>\n";
         // We check $options as the caller will set $options['default_itemtype'] only if it needs a
         // default itemtype and the default value can be '' thus empty won't be valid !
         if (array_key_exists('default_itemtype', $options)) {
             echo "<script type='text/javascript' >\n";
             echo Html::jsSetDropdownValue($field_id, $params['default_itemtype']);
             echo "</script>\n";
             $p["idtable"] = $params['default_itemtype'];
             Ajax::updateItem($show_id, $CFG_GLPI["root_doc"] . "/plugins/relation/ajax/dropdownAllItems.php", $p);
         }
     }
     return $rand;
 }