本文整理汇总了PHP中Dropdown::showSelectItemFromItemtypes方法的典型用法代码示例。如果您正苦于以下问题:PHP Dropdown::showSelectItemFromItemtypes方法的具体用法?PHP Dropdown::showSelectItemFromItemtypes怎么用?PHP Dropdown::showSelectItemFromItemtypes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dropdown
的用法示例。
在下文中一共展示了Dropdown::showSelectItemFromItemtypes方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showForProblem
/**
* Print the HTML array for Items linked to a problem
*
* @param $problem Problem object
*
* @return Nothing (display)
**/
static function showForProblem(Problem $problem)
{
global $DB, $CFG_GLPI;
$instID = $problem->fields['id'];
if (!$problem->can($instID, READ)) {
return false;
}
$canedit = $problem->canEdit($instID);
$rand = mt_rand();
$query = "SELECT DISTINCT `itemtype`\n FROM `glpi_items_problems`\n WHERE `glpi_items_problems`.`problems_id` = '{$instID}'\n ORDER BY `itemtype`";
$result = $DB->query($query);
$number = $DB->numrows($result);
if ($canedit) {
echo "<div class='firstbloc'>";
echo "<form name='problemitem_form{$rand}' id='problemitem_form{$rand}' method='post'\n action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_2'><th colspan='2'>" . __('Add an item') . "</th></tr>";
echo "<tr class='tab_bg_1'><td>";
$types = array();
foreach ($problem->getAllTypesForHelpdesk() as $key => $val) {
$types[] = $key;
}
Dropdown::showSelectItemFromItemtypes(array('itemtypes' => $types, 'entity_restrict' => $problem->fields['is_recursive'] ? getSonsOf('glpi_entities', $problem->fields['entities_id']) : $problem->fields['entities_id']));
echo "</td><td class='center' width='30%'>";
echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
echo "<input type='hidden' name='problems_id' value='{$instID}'>";
echo "</td></tr>";
echo "</table>";
Html::closeForm();
echo "</div>";
}
echo "<div class='spaced'>";
if ($canedit && $number) {
Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
$massiveactionparams = array('container' => 'mass' . __CLASS__ . $rand);
Html::showMassiveActions($massiveactionparams);
}
echo "<table class='tab_cadre_fixehov'>";
$header_begin = "<tr>";
$header_top = '';
$header_bottom = '';
$header_end = '';
if ($canedit && $number) {
$header_top .= "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
$header_top .= "</th>";
$header_bottom .= "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
$header_bottom .= "</th>";
}
$header_end .= "<th>" . __('Type') . "</th>";
$header_end .= "<th>" . __('Entity') . "</th>";
$header_end .= "<th>" . __('Name') . "</th>";
$header_end .= "<th>" . __('Serial number') . "</th>";
$header_end .= "<th>" . __('Inventory number') . "</th></tr>";
echo $header_begin . $header_top . $header_end;
$totalnb = 0;
for ($i = 0; $i < $number; $i++) {
$itemtype = $DB->result($result, $i, "itemtype");
if (!($item = getItemForItemtype($itemtype))) {
continue;
}
if ($item->canView()) {
$itemtable = getTableForItemType($itemtype);
$query = "SELECT `{$itemtable}`.*,\n `glpi_items_problems`.`id` AS IDD,\n `glpi_entities`.`id` AS entity\n FROM `glpi_items_problems`,\n `{$itemtable}`";
if ($itemtype != 'Entity') {
$query .= " LEFT JOIN `glpi_entities`\n ON (`{$itemtable}`.`entities_id`=`glpi_entities`.`id`) ";
}
$query .= " WHERE `{$itemtable}`.`id` = `glpi_items_problems`.`items_id`\n AND `glpi_items_problems`.`itemtype` = '{$itemtype}'\n AND `glpi_items_problems`.`problems_id` = '{$instID}'";
if ($item->maybeTemplate()) {
$query .= " AND `{$itemtable}`.`is_template` = '0'";
}
$query .= getEntitiesRestrictRequest(" AND", $itemtable, '', '', $item->maybeRecursive()) . "\n ORDER BY `glpi_entities`.`completename`, `{$itemtable}`.`name`";
$result_linked = $DB->query($query);
$nb = $DB->numrows($result_linked);
for ($prem = true; $data = $DB->fetch_assoc($result_linked); $prem = false) {
$name = $data["name"];
if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) {
$name = sprintf(__('%1$s (%2$s)'), $name, $data["id"]);
}
$link = $itemtype::getFormURLWithID($data['id']);
$namelink = "<a href=\"" . $link . "\">" . $name . "</a>";
echo "<tr class='tab_bg_1'>";
if ($canedit) {
echo "<td width='10'>";
Html::showMassiveActionCheckBox(__CLASS__, $data["IDD"]);
echo "</td>";
}
if ($prem) {
$typename = $item->getTypeName($nb);
echo "<td class='center top' rowspan='{$nb}'>" . ($nb > 1 ? sprintf(__('%1$s: %2$s'), $typename, $nb) : $typename) . "</td>";
}
echo "<td class='center'>";
echo Dropdown::getDropdownName("glpi_entities", $data['entity']) . "</td>";
echo "<td class='center" . (isset($data['is_deleted']) && $data['is_deleted'] ? " tab_bg_2_2'" : "'");
//.........这里部分代码省略.........
示例2: showMassiveActionsSubForm
/**
* @since version 0.85
*
* @see CommonDBTM::showMassiveActionsSubForm()
**/
static function showMassiveActionsSubForm(MassiveAction $ma)
{
global $CFG_GLPI;
$specificities = static::getRelationMassiveActionsSpecificities();
$action = $ma->getAction();
// First, get normalized action : add or remove
if (in_array($action, $specificities['normalized']['add'])) {
$normalized_action = 'add';
} else {
if (in_array($action, $specificities['normalized']['remove'])) {
$normalized_action = 'remove';
} else {
// If we cannot get normalized action, then, its not for this method !
return parent::showMassiveActionsSubForm($ma);
}
}
switch ($normalized_action) {
case 'add':
case 'remove':
// Get the peer number. For Document_Item, it depends of the action's name
$peer_number = static::getRelationMassiveActionsPeerForSubForm($ma);
switch ($peer_number) {
case 1:
$peertype = static::$itemtype_1;
$peers_id = static::$items_id_1;
break;
case 2:
$peertype = static::$itemtype_2;
$peers_id = static::$items_id_2;
break;
default:
exit;
}
if ($normalized_action == 'remove' && $specificities['only_remove_all_at_once']) {
// If we just want to remove all the items, then just set hidden fields
echo Html::hidden('peer_' . $peertype, array('value' => ''));
echo Html::hidden('peer_' . $peers_id, array('value' => -1));
} else {
// Else, it depends if the peer is an itemtype or not
$options = $specificities['select_items_options_' . $peer_number];
// Do we allow to remove all the items at once ? Then, rename the default value !
if ($normalized_action == 'remove' && $specificities['can_remove_all_at_once']) {
$options['emptylabel'] = __('Remove all at once');
}
if (preg_match('/^itemtype/', $peertype)) {
if (count($specificities['itemtypes']) > 0) {
$options['itemtype_name'] = 'peer_' . $peertype;
$options['items_id_name'] = 'peer_' . $peers_id;
$options['itemtypes'] = $specificities['itemtypes'];
// At least, if not forced by user, 'checkright' == true
if (!isset($options['checkright'])) {
$options['checkright'] = true;
}
Dropdown::showSelectItemFromItemtypes($options);
}
} else {
$options['name'] = 'peer_' . $peers_id;
$dropdown_method = $specificities['dropdown_method_' . $peer_number];
$peertype::$dropdown_method($options);
}
}
// Allow any relation to display its own fields (Networkport_Vlan for tagged ...)
static::showRelationMassiveActionsSubForm($ma, $peer_number);
echo "<br><br>" . Html::submit($specificities['button_labels'][$action], array('name' => 'massiveaction'));
return true;
}
return parent::showMassiveActionsSubForm($ma);
}
示例3: showForItem
static function showForItem(CommonGLPI $item, $withtemplate = 0)
{
global $CFG_GLPI;
$is_device = $item instanceof CommonDevice;
$ID = $item->getField('id');
if (!$item->can($ID, READ)) {
return false;
}
$canedit = $withtemplate != 2 && $item->canEdit($ID) && Session::haveRightsOr('device', array(UPDATE, PURGE));
echo "<div class='spaced'>";
$rand = mt_rand();
if ($canedit) {
echo "\n<form id='form_device_add{$rand}' name='form_device_add{$rand}'\n action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "' method='post'>\n";
echo "\t<input type='hidden' name='items_id' value='{$ID}'>\n";
echo "\t<input type='hidden' name='itemtype' value='" . $item->getType() . "'>\n";
}
$table = new HTMLTableMain();
$table->setTitle(_n('Component', 'Components', Session::getPluralNumber()));
if ($canedit) {
$delete_all_column = $table->addHeader('delete all', Html::getCheckAllAsCheckbox("form_device_action{$rand}", '__RAND__'));
$delete_all_column->setHTMLClass('center');
} else {
$delete_all_column = NULL;
}
$column_label = $is_device ? _n('Item', 'Items', Session::getPluralNumber()) : __('Type of component');
$common_column = $table->addHeader('common', $column_label);
$specific_column = $table->addHeader('specificities', __('Specificities'));
$specific_column->setHTMLClass('center');
$dynamic_column = '';
if ($item->isDynamic()) {
$dynamic_column = $table->addHeader('is_dynamic', __('Automatic inventory'));
$dynamic_column->setHTMLClass('center');
}
if ($canedit) {
$massiveactionparams = array('container' => "form_device_action{$rand}", 'fixed' => false, 'display_arrow' => false);
$content = array(array('function' => 'Html::showMassiveActions', 'parameters' => array($massiveactionparams)));
$delete_column = $table->addHeader('delete one', $content);
$delete_column->setHTMLClass('center');
} else {
$delete_column = NULL;
}
$table_options = array('canedit' => $canedit, 'rand' => $rand);
if ($is_device) {
Session::initNavigateListItems(static::getType(), sprintf(__('%1$s = %2$s'), $item->getTypeName(1), $item->getName()));
foreach (array_merge(array(''), self::getConcernedItems()) as $itemtype) {
$table_options['itemtype'] = $itemtype;
$link = getItemForItemtype(static::getType());
$link->getTableGroup($item, $table, $table_options, $delete_all_column, $common_column, $specific_column, $delete_column, $dynamic_column);
}
} else {
$devtypes = array();
foreach (self::getItemAffinities($item->getType()) as $link_type) {
$devtypes[] = $link_type::getDeviceType();
$link = getItemForItemtype($link_type);
Session::initNavigateListItems($link_type, sprintf(__('%1$s = %2$s'), $item->getTypeName(1), $item->getName()));
$link->getTableGroup($item, $table, $table_options, $delete_all_column, $common_column, $specific_column, $delete_column, $dynamic_column);
}
}
if ($canedit) {
echo "<table class='tab_cadre_fixe'><tr class='tab_bg_1'><td>";
echo __('Add a new component') . "</td><td class=left width='70%'>";
if ($is_device) {
Dropdown::showNumber('number_devices_to_add', array('value' => 0, 'min' => 0, 'max' => 10));
} else {
Dropdown::showSelectItemFromItemtypes(array('itemtype_name' => 'devicetype', 'items_id_name' => 'devices_id', 'itemtypes' => $devtypes, 'entity_restrict' => $item->getEntityID(), 'showItemSpecificity' => $CFG_GLPI['root_doc'] . '/ajax/selectUnaffectedOrNewItem_Device.php'));
}
echo "</td><td>";
echo "<input type='submit' class='submit' name='add' value='" . _sx('button', 'Add') . "'>";
echo "</td></tr></table>";
Html::closeForm();
}
if ($canedit) {
echo "\n<form id='form_device_action{$rand}' name='form_device_action{$rand}'\n action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "' method='post'>\n";
echo "\t<input type='hidden' name='items_id' value='{$ID}'>\n";
echo "\t<input type='hidden' name='itemtype' value='" . $item->getType() . "'>\n";
}
$table->display(array('display_super_for_each_group' => false, 'display_title_for_each_group' => false));
if ($canedit) {
// echo "<input type='submit' class='submit' name='updateall' value='" .
// _sx('button', 'Save')."'>";
Html::closeForm();
}
echo "</div>";
// Force disable selected items
$_SESSION['glpimassiveactionselected'] = array();
}
示例4: showTeam
/**
* Show team for a project task
*
* @param $task ProjectTask object
*
* @return boolean
**/
function showTeam(ProjectTask $task)
{
global $DB, $CFG_GLPI;
/// TODO : permit to simple add member of project team ?
$ID = $task->fields['id'];
$canedit = $task->canEdit($ID);
$rand = mt_rand();
$nb = 0;
$nb = $task->getTeamCount();
if ($canedit) {
echo "<div class='firstbloc'>";
echo "<form name='projecttaskteam_form{$rand}' id='projecttaskteam_form{$rand}' ";
echo " method='post' action='" . Toolbox::getItemTypeFormURL('ProjectTaskTeam') . "'>";
echo "<input type='hidden' name='projecttasks_id' value='{$ID}'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_1'><th colspan='2'>" . __('Add a team member') . "</tr>";
echo "<tr class='tab_bg_2'><td>";
$params = array('itemtypes' => ProjectTeam::$available_types, 'entity_restrict' => $task->fields['is_recursive'] ? getSonsOf('glpi_entities', $task->fields['entities_id']) : $task->fields['entities_id']);
$addrand = Dropdown::showSelectItemFromItemtypes($params);
echo "</td>";
echo "<td width='20%'>";
echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
echo "</td>";
echo "</tr>";
echo "</table>";
Html::closeForm();
echo "</div>";
}
echo "<div class='spaced'>";
if ($canedit && $nb) {
Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
$massiveactionparams = array('num_displayed' => $nb, 'container' => 'mass' . __CLASS__ . $rand);
// 'specific_actions'
// => array('delete' => _x('button', 'Delete permanently')) );
//
// if ($this->fields['users_id'] != Session::getLoginUserID()) {
// $massiveactionparams['confirm']
// = __('Caution! You are not the author of this element. Delete targets can result in loss of access to that element.');
// }
Html::showMassiveActions($massiveactionparams);
}
echo "<table class='tab_cadre_fixehov'>";
$header_begin = "<tr>";
$header_top = '';
$header_bottom = '';
$header_end = '';
if ($canedit && $nb) {
$header_top .= "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
$header_top .= "</th>";
$header_bottom .= "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
$header_bottom .= "</th>";
}
$header_end .= "<th>" . __('Type') . "</th>";
$header_end .= "<th>" . _n('Member', 'Members', Session::getPluralNumber()) . "</th>";
$header_end .= "</tr>";
echo $header_begin . $header_top . $header_end;
foreach (ProjectTaskTeam::$available_types as $type) {
if (isset($task->team[$type]) && count($task->team[$type])) {
if ($item = getItemForItemtype($type)) {
foreach ($task->team[$type] as $data) {
$item->getFromDB($data['items_id']);
echo "<tr class='tab_bg_2'>";
if ($canedit) {
echo "<td>";
Html::showMassiveActionCheckBox('ProjectTaskTeam', $data["id"]);
echo "</td>";
}
echo "<td>" . $item->getTypeName(1) . "</td>";
echo "<td>" . $item->getLink() . "</td>";
echo "</tr>";
}
}
}
}
if ($nb) {
echo $header_begin . $header_bottom . $header_end;
}
echo "</table>";
if ($canedit && $nb) {
$massiveactionparams['ontop'] = false;
Html::showMassiveActions($massiveactionparams);
Html::closeForm();
}
echo "</div>";
// Add items
return true;
}
示例5: showPluginFromItems
public function showPluginFromItems($itemtype, $ID, $withtemplate = '')
{
global $DB, $CFG_GLPI;
$item = new $itemtype();
$canread = $item->can($ID, READ);
$canedit = $item->can($ID, UPDATE);
$table = $this->getTable();
$rand = mt_rand();
$PluginConnectionsConnection = new PluginConnectionsConnection();
$entitiesRestrict = getEntitiesRestrictRequest(" AND ", "glpi_plugin_connections_connections", '', '', $PluginConnectionsConnection->maybeRecursive());
if ($canedit) {
echo "<div class='firstbloc'>";
echo "<form name='connection_form{$rand}' id='connection_form{$rand}' method='post'\n action='" . $CFG_GLPI["root_doc"] . "/plugins/connections/front/connection.form.php'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_2'><th colspan='2'>" . __('Add an item') . "</th></tr>";
echo "<tr class='tab_bg_1'><td class='right'>";
Dropdown::showSelectItemFromItemtypes(array('itemtypes' => array('PluginConnectionsConnection'), 'entity_restrict' => $item->fields['is_recursive'] ? getSonsOf('glpi_entities', $item->fields['entities_id']) : $item->fields['entities_id'], 'checkright' => true, 'items_id_name' => 'plugin_connections_connections_id'));
echo "</td><td class='center'>";
echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
echo "<input type='hidden' name='items_id' value='{$ID}'>";
echo "<input type='hidden' name='additem' value='true'>";
echo "<input type='hidden' name='itemtype' value='NetworkEquipment'>";
echo "</td></tr>";
echo "</table>";
Html::closeForm();
echo "</div>";
}
$query = "SELECT t.`id` AS IDD, `glpi_plugin_connections_connections`.*\n FROM `{$table}` t, `glpi_plugin_connections_connections`\n LEFT JOIN `glpi_entities` ON (`glpi_entities`.`id` = `glpi_plugin_connections_connections`.`entities_id`)\n WHERE t.`items_id` = '{$ID}'\n AND t.`itemtype` = '{$itemtype}'\n AND t.`plugin_connections_connections_id` = `glpi_plugin_connections_connections`.`id`\n {$entitiesRestrict}\n ORDER BY `glpi_plugin_connections_connections`.`name` ";
$result = $DB->query($query);
$number = $DB->numrows($result);
echo "<div class='spaced'>";
if ($canedit && $number) {
Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
$massiveactionparams = array('container' => 'mass' . __CLASS__ . $rand);
Html::showMassiveActions($massiveactionparams);
}
echo "<table class='tab_cadre_fixehov'>";
$header_begin = "<tr>";
$header_top = '';
$header_bottom = '';
$header_end = '';
if ($canedit && $number) {
$header_top .= "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
$header_top .= "</th>";
$header_bottom .= "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
$header_bottom .= "</th>";
}
$header_end .= "<th>" . __('Entity') . "</th>";
$header_end .= "<th>" . __('Name') . "</th>";
$header_end .= "<th>" . __('Type of Connections', 'connections') . "</th>";
$header_end .= "<th>" . __('Rates', 'connections') . "</th>";
$header_end .= "<th>" . __('Guaranteed Rates', 'connections') . "</th>";
if ($number) {
echo $header_begin . $header_top . $header_end;
}
while ($data = $DB->fetch_array($result)) {
$name = $data["name"];
if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) {
$name = sprintf(__('%1$s (%2$s)'), $name, $data["id"]);
}
if ($_SESSION['glpiactiveprofile']['interface'] != 'helpdesk') {
$link = PluginConnectionsConnection::getFormURLWithID($data['id']);
$namelink = "<a href=\"" . $link . "\">" . $name . "</a>";
} else {
$namelink = $name;
}
echo "<tr class='tab_bg_1'>";
if ($canedit) {
echo "<td width='10'>";
Html::showMassiveActionCheckBox(__CLASS__, $data["IDD"]);
echo "</td>";
}
echo "<td class='center'>";
echo Dropdown::getDropdownName("glpi_entities", $data['entities_id']) . "</td>";
echo "<td class='center" . (isset($data['is_deleted']) && $data['is_deleted'] ? " tab_bg_2_2'" : "'");
echo ">" . $namelink . "</td>";
echo "<td class='center'>";
echo Dropdown::getDropdownName(getTableForItemType('PluginConnectionsConnectionType'), $data['plugin_connections_connectiontypes_id']) . "</td>";
echo "<td class='center'>";
echo Dropdown::getDropdownName(getTableForItemType('PluginConnectionsConnectionRate'), $data['plugin_connections_connectionrates_id']) . "</td>";
echo "<td class='center'>";
echo Dropdown::getDropdownName(getTableForItemType('PluginConnectionsGuaranteedConnectionRate'), $data['plugin_connections_guaranteedconnectionrates_id']) . "</td>";
echo "</tr>";
}
if ($number) {
echo $header_begin . $header_bottom . $header_end;
}
echo "</table>";
if ($canedit && $number) {
$massiveactionparams['ontop'] = false;
Html::showMassiveActions($massiveactionparams);
Html::closeForm();
}
echo "</div>";
}
示例6: showForContract
/**
* Print the HTML array for Items linked to current contract
*
* @since version 0.84
*
* @param $contract Contract object
*
* @return Nothing (display)
**/
static function showForContract(Contract $contract)
{
global $DB, $CFG_GLPI;
$instID = $contract->fields['id'];
if (!$contract->can($instID, READ)) {
return false;
}
$canedit = $contract->can($instID, UPDATE);
$rand = mt_rand();
$query = "SELECT DISTINCT `itemtype`\n FROM `glpi_contracts_items`\n WHERE `glpi_contracts_items`.`contracts_id` = '{$instID}'\n ORDER BY `itemtype`";
$result = $DB->query($query);
$number = $DB->numrows($result);
$data = array();
$totalnb = 0;
$used = array();
for ($i = 0; $i < $number; $i++) {
$itemtype = $DB->result($result, $i, "itemtype");
if (!($item = getItemForItemtype($itemtype))) {
continue;
}
if ($item->canView()) {
$itemtable = getTableForItemType($itemtype);
$query = "SELECT `{$itemtable}`.*,\n `glpi_contracts_items`.`id` AS IDD,\n `glpi_entities`.`id` AS entity\n FROM `glpi_contracts_items`,\n `{$itemtable}`";
if ($itemtype != 'Entity') {
$query .= " LEFT JOIN `glpi_entities`\n ON (`{$itemtable}`.`entities_id`=`glpi_entities`.`id`) ";
}
$query .= " WHERE `{$itemtable}`.`id` = `glpi_contracts_items`.`items_id`\n AND `glpi_contracts_items`.`itemtype` = '{$itemtype}'\n AND `glpi_contracts_items`.`contracts_id` = '{$instID}'";
if ($item->maybeTemplate()) {
$query .= " AND `{$itemtable}`.`is_template` = '0'";
}
$query .= getEntitiesRestrictRequest(" AND", $itemtable, '', '', $item->maybeRecursive()) . "\n ORDER BY `glpi_entities`.`completename`, `{$itemtable}`.`name`";
$result_linked = $DB->query($query);
$nb = $DB->numrows($result_linked);
if ($nb > $_SESSION['glpilist_limit']) {
$opt = array('order' => 'ASC', 'is_deleted' => 0, 'reset' => 'reset', 'start' => 0, 'sort' => 80, 'criteria' => array(0 => array('value' => '$$$$' . $instID, 'searchtype' => 'contains', 'field' => 29)));
$url = $item::getSearchURL();
$url .= strpos($url, '?') ? '&' : '?';
$url .= Toolbox::append_params($opt);
$link = "<a href='{$url}'>" . __('Device list') . "</a>";
$data[$itemtype] = array('longlist' => true, 'name' => sprintf(__('%1$s: %2$s'), $item->getTypeName($nb), $nb), 'link' => $link);
} else {
if ($nb > 0) {
$data[$itemtype] = array();
while ($objdata = $DB->fetch_assoc($result_linked)) {
$data[$itemtype][$objdata['id']] = $objdata;
$used[$itemtype][$objdata['id']] = $objdata['id'];
}
}
}
$totalnb += $nb;
}
}
if ($canedit && ($contract->fields['max_links_allowed'] == 0 || $contract->fields['max_links_allowed'] > $totalnb)) {
echo "<div class='firstbloc'>";
echo "<form name='contract_form{$rand}' id='contract_form{$rand}' method='post'\n action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_2'><th colspan='2'>" . __('Add an item') . "</th></tr>";
echo "<tr class='tab_bg_1'><td class='right'>";
Dropdown::showSelectItemFromItemtypes(array('itemtypes' => $CFG_GLPI["contract_types"], 'entity_restrict' => $contract->fields['is_recursive'] ? getSonsOf('glpi_entities', $contract->fields['entities_id']) : $contract->fields['entities_id'], 'checkright' => true, 'used' => $used));
echo "</td><td class='center'>";
echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
echo "<input type='hidden' name='contracts_id' value='{$instID}'>";
echo "</td></tr>";
echo "</table>";
Html::closeForm();
echo "</div>";
}
echo "<div class='spaced'>";
if ($canedit && $totalnb) {
Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
$massiveactionparams = array('container' => 'mass' . __CLASS__ . $rand);
Html::showMassiveActions($massiveactionparams);
}
echo "<table class='tab_cadre_fixehov'>";
$header_begin = "<tr>";
$header_top = '';
$header_bottom = '';
$header_end = '';
if ($canedit && $totalnb) {
$header_top .= "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
$header_top .= "</th>";
$header_bottom .= "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
$header_bottom .= "</th>";
}
$header_end .= "<th>" . __('Type') . "</th>";
$header_end .= "<th>" . __('Entity') . "</th>";
$header_end .= "<th>" . __('Name') . "</th>";
$header_end .= "<th>" . __('Serial number') . "</th>";
$header_end .= "<th>" . __('Inventory number') . "</th>";
$header_end .= "<th>" . __('Status') . "</th>";
$header_end .= "</tr>";
//.........这里部分代码省略.........
示例7: showForDocument
/**
* Show items links to a document
*
* @since version 0.84
*
* @param $doc Document object
*
* @return nothing (HTML display)
**/
static function showForDocument(Document $doc)
{
global $DB, $CFG_GLPI;
$instID = $doc->fields['id'];
if (!$doc->can($instID, READ)) {
return false;
}
$canedit = $doc->can($instID, UPDATE);
// for a document,
// don't show here others documents associated to this one,
// it's done for both directions in self::showAssociated
$query = "SELECT DISTINCT `itemtype`\n FROM `glpi_documents_items`\n WHERE `glpi_documents_items`.`documents_id` = '{$instID}'\n AND `glpi_documents_items`.`itemtype` != 'Document'\n ORDER BY `itemtype`";
$result = $DB->query($query);
$number = $DB->numrows($result);
$rand = mt_rand();
if ($canedit) {
echo "<div class='firstbloc'>";
echo "<form name='documentitem_form{$rand}' id='documentitem_form{$rand}' method='post'\n action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_2'><th colspan='2'>" . __('Add an item') . "</th></tr>";
echo "<tr class='tab_bg_1'><td class='right'>";
Dropdown::showSelectItemFromItemtypes(array('itemtypes' => Document::getItemtypesThatCanHave(), 'entity_restrict' => $doc->fields['is_recursive'] ? getSonsOf('glpi_entities', $doc->fields['entities_id']) : $doc->fields['entities_id'], 'checkright' => true));
echo "</td><td class='center'>";
echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
echo "<input type='hidden' name='documents_id' value='{$instID}'>";
echo "</td></tr>";
echo "</table>";
Html::closeForm();
echo "</div>";
}
echo "<div class='spaced'>";
if ($canedit && $number) {
Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
$massiveactionparams = array('container' => 'mass' . __CLASS__ . $rand);
Html::showMassiveActions($massiveactionparams);
}
echo "<table class='tab_cadre_fixehov'>";
$header_begin = "<tr>";
$header_top = '';
$header_bottom = '';
$header_end = '';
if ($canedit && $number) {
$header_top .= "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
$header_top .= "</th>";
$header_bottom .= "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
$header_bottom .= "</th>";
}
$header_end .= "<th>" . __('Type') . "</th>";
$header_end .= "<th>" . __('Name') . "</th>";
$header_end .= "<th>" . __('Entity') . "</th>";
$header_end .= "<th>" . __('Serial number') . "</th>";
$header_end .= "<th>" . __('Inventory number') . "</th>";
$header_end .= "</tr>";
echo $header_begin . $header_top . $header_end;
for ($i = 0; $i < $number; $i++) {
$itemtype = $DB->result($result, $i, "itemtype");
if (!($item = getItemForItemtype($itemtype))) {
continue;
}
if ($item->canView()) {
if ($item instanceof CommonDevice) {
$column = "designation";
} else {
if ($item instanceof Item_Devices) {
$column = "itemtype";
} else {
$column = "name";
}
}
if ($itemtype == 'Ticket') {
$column = "id";
}
$itemtable = getTableForItemType($itemtype);
$query = "SELECT `{$itemtable}`.*,\n `glpi_documents_items`.`id` AS IDD, ";
if ($itemtype == 'KnowbaseItem') {
$query .= "-1 AS entity\n FROM `glpi_documents_items`, `{$itemtable}`\n " . KnowbaseItem::addVisibilityJoins() . "\n WHERE `{$itemtable}`.`id` = `glpi_documents_items`.`items_id`\n AND ";
} else {
$query .= "`glpi_entities`.`id` AS entity\n FROM `glpi_documents_items`, `{$itemtable}`";
if ($itemtype != 'Entity') {
$query .= " LEFT JOIN `glpi_entities`\n ON (`glpi_entities`.`id` = `{$itemtable}`.`entities_id`)";
}
$query .= " WHERE `{$itemtable}`.`id` = `glpi_documents_items`.`items_id`\n AND ";
}
$query .= "`glpi_documents_items`.`itemtype` = '{$itemtype}'\n AND `glpi_documents_items`.`documents_id` = '{$instID}' ";
if ($itemtype == 'KnowbaseItem') {
if (Session::getLoginUserID()) {
$where = "AND " . KnowbaseItem::addVisibilityRestrict();
} else {
// Anonymous access
if (Session::isMultiEntitiesMode()) {
$where = " AND (`glpi_entities_knowbaseitems`.`entities_id` = '0'\n AND `glpi_entities_knowbaseitems`.`is_recursive` = '1')";
//.........这里部分代码省略.........
示例8: showTeam
/**
* Show team for a project
**/
function showTeam(Project $project)
{
global $DB, $CFG_GLPI;
$ID = $project->fields['id'];
$canedit = $project->can($ID, UPDATE);
echo "<div class='center'>";
$rand = mt_rand();
$nb = 0;
$nb = $project->getTeamCount();
if ($canedit) {
echo "<div class='firstbloc'>";
echo "<form name='projectteam_form{$rand}' id='projectteam_form{$rand}' ";
echo " method='post' action='" . Toolbox::getItemTypeFormURL('ProjectTeam') . "'>";
echo "<input type='hidden' name='projects_id' value='{$ID}'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_1'><th colspan='2'>" . __('Add a team member') . "</tr>";
echo "<tr class='tab_bg_2'><td>";
$params = array('itemtypes' => ProjectTeam::$available_types, 'entity_restrict' => $project->fields['is_recursive'] ? getSonsOf('glpi_entities', $project->fields['entities_id']) : $project->fields['entities_id']);
$addrand = Dropdown::showSelectItemFromItemtypes($params);
echo "</td>";
echo "<td width='20%'>";
echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\"\n class='submit'>";
echo "</td>";
echo "</tr>";
echo "</table>";
Html::closeForm();
echo "</div>";
}
echo "<div class='spaced'>";
if ($canedit && $nb) {
Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
$massiveactionparams = array('num_displayed' => $nb, 'container' => 'mass' . __CLASS__ . $rand);
Html::showMassiveActions($massiveactionparams);
}
echo "<table class='tab_cadre_fixehov'>";
$header_begin = "<tr>";
$header_top = '';
$header_bottom = '';
$header_end = '';
if ($canedit && $nb) {
$header_begin .= "<th width='10'>";
$header_top .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
$header_bottom .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
$header_end .= "</th>";
}
$header_end .= "<th>" . __('Type') . "</th>";
$header_end .= "<th>" . _n('Member', 'Members', Session::getPluralNumber()) . "</th>";
$header_end .= "</tr>";
echo $header_begin . $header_top . $header_end;
foreach (ProjectTeam::$available_types as $type) {
if (isset($project->team[$type]) && count($project->team[$type])) {
if ($item = getItemForItemtype($type)) {
foreach ($project->team[$type] as $data) {
$item->getFromDB($data['items_id']);
echo "<tr class='tab_bg_2'>";
if ($canedit) {
echo "<td>";
Html::showMassiveActionCheckBox('ProjectTeam', $data["id"]);
echo "</td>";
}
echo "<td>" . $item->getTypeName(1) . "</td>";
echo "<td>" . $item->getLink() . "</td>";
echo "</tr>";
}
}
}
}
if ($nb) {
echo $header_begin . $header_bottom . $header_end;
}
echo "</table>";
if ($canedit && $nb) {
$massiveactionparams['ontop'] = false;
Html::showMassiveActions($massiveactionparams);
Html::closeForm();
}
echo "</div>";
// Add items
return true;
}
示例9: showMassiveActionsSubForm
/**
* @since version 0.85
*
* @see CommonDBTM::showMassiveActionsSubForm()
**/
static function showMassiveActionsSubForm(MassiveAction $ma)
{
global $CFG_GLPI;
$input = $ma->getInput();
switch ($ma->getAction()) {
case 'give':
if (isset($input["entities_id"])) {
Dropdown::showSelectItemFromItemtypes(array('itemtype_name' => 'give_itemtype', 'items_id_name' => 'give_items_id', 'entity_restrict' => $input["entities_id"], 'itemtypes' => $CFG_GLPI["consumables_types"]));
echo "<br><br>" . Html::submit(_x('button', 'Give'), array('name' => 'massiveaction'));
return true;
}
}
return parent::showMassiveActionsSubForm($ma);
}
示例10: showMassiveActionsSubForm
//.........这里部分代码省略.........
$itemtypes_affect[$itemtype] = $specificities;
continue;
}
if (in_array($action, $specificities['normalized']['unaffect'])) {
$itemtypes_unaffect[$itemtype] = $specificities;
continue;
}
}
if (count($itemtypes_affect) > count($itemtypes_unaffect)) {
$normalized_action = 'affect';
$itemtypes = $itemtypes_affect;
} else {
if (count($itemtypes_affect) < count($itemtypes_unaffect)) {
$normalized_action = 'unaffect';
$itemtypes = $itemtypes_unaffect;
} else {
return parent::showMassiveActionsSubForm($ma);
}
}
switch ($normalized_action) {
case 'unaffect':
foreach ($itemtypes as $itemtype => $specificities) {
if (Toolbox::is_a($itemtype, 'CommonDBRelation')) {
$peer_field = "peer[{$itemtype}]";
if (!$itemtype::$mustBeAttached_1 && !$itemtype::$mustBeAttached_2) {
// Should never occur ... But we must care !
$values = array();
if (empty($itemtype::$itemtype_1) || preg_match('/^itemtype/', $itemtype::$itemtype_1)) {
$values[0] = __('First Item');
} else {
$itemtype_1 = $itemtype::$itemtype_1;
$values[0] = $itemtype_1::getTypeName(Session::getPluralNumber());
}
if (empty($itemtype::$itemtype_2) || preg_match('/^itemtype/', $itemtype::$itemtype_2)) {
$values[1] = __('Second Item');
} else {
$itemtype_2 = $itemtype::$itemtype_2;
$values[1] = $itemtype_2::getTypeName(Session::getPluralNumber());
}
echo sprintf(__('Select a peer for %s:'), $itemtype::getTypeName());
Dropdown::showFromArray($peer_field, $values);
echo "<br>\n";
} else {
if (!$itemtype::$mustBeAttached_1) {
echo "<input type='hidden' name='{$peer_field}' value='0'>";
} else {
if (!$itemtype::$mustBeAttached_2) {
echo "<input type='hidden' name='{$peer_field}' value='1'>";
}
}
}
}
}
echo "<br><br>" . Html::submit(_x('button', 'Dissociate'), array('name' => 'massiveaction'));
return true;
case 'affect':
$peertypes = array();
foreach ($itemtypes as $itemtype => $specificities) {
if (!$specificities['reaffect']) {
continue;
}
if (Toolbox::is_a($itemtype, 'CommonDBRelation')) {
if ($specificities['reaffect'] == 1) {
$peertype = $itemtype::$itemtype_1;
} else {
$peertype = $itemtype::$itemtype_2;
}
} else {
$peertype = $itemtype::$itemtype;
}
if (preg_match('/^itemtype/', $peertype)) {
$peertypes = array_merge($peertypes, $specificities['itemtypes']);
} else {
$peertypes[] = $peertype;
}
}
$peertypes = array_unique($peertypes);
if (count($peertypes) == 0) {
echo __('Unable to reaffect given elements !');
exit;
}
$options = array();
if (count($peertypes) == 1) {
$options['name'] = 'peers_id';
$type_for_dropdown = $peertypes[0];
if (preg_match('/^itemtype/', $peertype)) {
echo Html::hidden('peertype', array('value' => $type_for_dropdown));
}
$type_for_dropdown::dropdown($options);
} else {
$options['itemtype_name'] = 'peertype';
$options['items_id_name'] = 'peers_id';
$options['itemtypes'] = $peertypes;
Dropdown::showSelectItemFromItemtypes($options);
}
echo "<br><br>" . Html::submit(_x('button', 'Associate'), array('name' => 'massiveaction'));
return true;
}
return parent::showMassiveActionsSubForm($ma);
}