Dropdown::dropdownUsedItemTypes PHP Метод

dropdownUsedItemTypes() статический публичный Метод

Make a select box for device type
static public dropdownUsedItemTypes ( $name, $itemtype_ref, $options = [] ) : nothing
$name name of the select box
$itemtype_ref string itemtype reference where to search in itemtype field
$options array of possible options: - may be value (default value) / field (used field to search itemtype)
Результат nothing (print out an HTML select box)
    static function dropdownUsedItemTypes($name, $itemtype_ref, $options = array())
    {
        global $DB;
        $p['value'] = 0;
        $p['field'] = 'itemtype';
        if (is_array($options) && count($options)) {
            foreach ($options as $key => $val) {
                $p[$key] = $val;
            }
        }
        $query = "SELECT DISTINCT `" . $p['field'] . "`\n                FROM `" . getTableForItemType($itemtype_ref) . "`";
        $tabs = array();
        if ($result = $DB->query($query)) {
            while ($data = $DB->fetch_assoc($result)) {
                $tabs[$data[$p['field']]] = $data[$p['field']];
            }
        }
        return self::showItemTypes($name, $tabs, array('value' => $p['value']));
    }

Usage Example

Пример #1
0
             break;
     }
     // Standard datatype usage
     if (!$display && isset($searchopt['datatype'])) {
         switch ($searchopt['datatype']) {
             case "bool":
                 Dropdown::showYesNo($inputname, $_REQUEST['value']);
                 $display = true;
                 break;
             case "right":
                 // No access not displayed because empty not take into account for search
                 Profile::dropdownNoneReadWrite($inputname, $_REQUEST['value'], 1, 1, 1);
                 $display = true;
                 break;
             case "itemtypename":
                 Dropdown::dropdownUsedItemTypes($inputname, getItemTypeForTable($searchopt['table']), array('value' => $_REQUEST['value'], 'comments' => 0));
                 $display = true;
                 break;
         }
     }
     // Standard field usage
     if (!$display) {
         switch ($searchopt['field']) {
             case "name":
             case "completename":
                 Dropdown::show(getItemTypeForTable($searchopt['table']), array('value' => $_REQUEST['value'], 'name' => $inputname, 'comments' => 0));
                 $display = true;
                 break;
         }
     }
 }