本文整理汇总了PHP中Session::addToNavigateListItems方法的典型用法代码示例。如果您正苦于以下问题:PHP Session::addToNavigateListItems方法的具体用法?PHP Session::addToNavigateListItems怎么用?PHP Session::addToNavigateListItems使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Session
的用法示例。
在下文中一共展示了Session::addToNavigateListItems方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: displayDatas
//.........这里部分代码省略.........
// End Line for column headers
$headers_line .= self::showEndLine($data['display_type']);
$headers_line_top .= $headers_line;
if ($data['display_type'] == self::HTML_OUTPUT) {
$headers_line_bottom .= $headers_line;
}
$headers_line_top .= self::showEndHeader($data['display_type']);
// $headers_line_bottom .= self::showEndHeader($data['display_type']);
echo $headers_line_top;
// Init list of items displayed
if ($data['display_type'] == self::HTML_OUTPUT) {
Session::initNavigateListItems($data['itemtype']);
}
// Num of the row (1=header_line)
$row_num = 1;
$massiveaction_field = 'id';
if ($data['itemtype'] != 'AllAssets' && isset($CFG_GLPI["union_search_type"][$data['itemtype']])) {
$massiveaction_field = 'refID';
}
$typenames = array();
// Display Loop
foreach ($data['data']['rows'] as $rowkey => $row) {
// Column num
$item_num = 1;
$row_num++;
// New line
echo self::showNewLine($data['display_type'], $row_num % 2, $data['search']['is_deleted']);
$current_type = isset($row['TYPE']) ? $row['TYPE'] : $data['itemtype'];
$massiveaction_type = $current_type;
if ($data['itemtype'] != 'AllAssets' && isset($CFG_GLPI["union_search_type"][$data['itemtype']])) {
$massiveaction_type = $data['itemtype'];
}
// Add item in item list
Session::addToNavigateListItems($current_type, $row["id"]);
if ($data['display_type'] == self::HTML_OUTPUT && $showmassiveactions) {
// HTML display - massive modif
$tmpcheck = "";
if ($data['itemtype'] == 'Entity' && !in_array($row["id"], $_SESSION["glpiactiveentities"])) {
$tmpcheck = " ";
} else {
if ($data['item'] instanceof CommonDBTM && $data['item']->maybeRecursive() && !in_array($row["entities_id"], $_SESSION["glpiactiveentities"])) {
$tmpcheck = " ";
} else {
$tmpcheck = Html::getMassiveActionCheckBox($massiveaction_type, $row[$massiveaction_field]);
}
}
echo self::showItem($data['display_type'], $tmpcheck, $item_num, $row_num, "width='10'");
}
// Print other toview items
foreach ($data['data']['cols'] as $colkey => $col) {
if (!$col['meta']) {
echo self::showItem($data['display_type'], $row[$colkey]['displayname'], $item_num, $row_num, self::displayConfigItem($data['itemtype'], $col['id'], $row, $colkey));
} else {
// META case
echo self::showItem($data['display_type'], $row[$colkey]['displayname'], $item_num, $row_num);
}
}
if (isset($CFG_GLPI["union_search_type"][$data['itemtype']])) {
if (!isset($typenames[$row["TYPE"]])) {
if ($itemtmp = getItemForItemtype($row["TYPE"])) {
$typenames[$row["TYPE"]] = $itemtmp->getTypeName();
}
}
echo self::showItem($data['display_type'], $typenames[$row["TYPE"]], $item_num, $row_num);
}
// End Line
示例2: displayValue
function displayValue($output_type, $row)
{
if (!isset($row[$this->name]) || !$row[$this->name]) {
return '';
}
if (!$this->obj || !$this->obj->getFromDB($row[$this->name])) {
return $row[$this->name];
}
if ($this->with_navigate) {
Session::addToNavigateListItems($this->obj->getType(), $row[$this->name]);
}
if ($output_type == Search::HTML_OUTPUT) {
return $this->obj->getLink($this->with_comment);
}
return $this->obj->getNameID();
}
示例3: displayCell
/**
* @param $index
* @param $options array
**/
function displayCell($index, array $options = array())
{
if ($index >= $this->start && $index < $this->start + $this->numberOfLines) {
if ($index == $this->start) {
if ($this->item instanceof CommonDBTM) {
Session::addToNavigateListItems($this->item->getType(), $this->item->getID());
}
echo "\t\t\t<td colspan='" . $this->header->getColSpan() . "'";
if ($this->numberOfLines > 1) {
echo " rowspan='" . $this->numberOfLines . "'";
}
$this->displayEntityAttributs($options);
echo ">";
$this->displayContent();
echo "</td>\n";
}
return true;
}
return false;
}
示例4: showAndAddRuleForm
/**
* @param $item
**/
function showAndAddRuleForm($item)
{
$rand = mt_rand();
$canedit = self::canUpdate();
if ($canedit && $item->getType() == 'Entity') {
$this->showNewRuleForm($item->getField('id'));
}
//Get all rules and actions
$crit = array('field' => getForeignKeyFieldForTable($item->getTable()), 'value' => $item->getField('id'));
$rules = $this->getRulesForCriteria($crit);
$nb = count($rules);
echo "<div class='spaced'>";
if (!$nb) {
echo "<table class='tab_cadre_fixehov'>";
echo "<tr><th>" . __('No item found') . "</th>";
echo "</tr>\n";
echo "</table>\n";
} else {
if ($canedit) {
Html::openMassiveActionsForm('mass' . get_called_class() . $rand);
$massiveactionparams = array('num_displayed' => $nb, 'specific_actions' => array('update' => _x('button', 'Update'), 'purge' => _x('button', 'Delete permanently')));
// 'extraparams'
// => array('rule_class_name' => $this->getRuleClassName()));
Html::showMassiveActions($massiveactionparams);
}
echo "<table class='tab_cadre_fixehov'>";
$header_begin = "<tr>";
$header_top = '';
$header_bottom = '';
$header_end = '';
if ($canedit) {
$header_begin .= "<th width='10'>";
$header_top .= Html::getCheckAllAsCheckbox('mass' . get_called_class() . $rand);
$header_bottom .= Html::getCheckAllAsCheckbox('mass' . get_called_class() . $rand);
$header_end .= "</th>";
}
$header_end .= "<th>" . $this->getTitle() . "</th>";
$header_end .= "<th>" . __('Description') . "</th>";
$header_end .= "<th>" . __('Active') . "</th>";
$header_end .= "</tr>\n";
echo $header_begin . $header_top . $header_end;
Session::initNavigateListItems(get_class($this), sprintf(__('%1$s = %2$s'), $item->getTypeName(1), $item->getName()));
foreach ($rules as $rule) {
Session::addToNavigateListItems(get_class($this), $rule->fields["id"]);
echo "<tr class='tab_bg_1'>";
if ($canedit) {
echo "<td width='10'>";
Html::showMassiveActionCheckBox(__CLASS__, $rule->fields["id"]);
echo "</td>";
echo "<td><a href='" . Toolbox::getItemTypeFormURL(get_class($this)) . "?id=" . $rule->fields["id"] . "&onglet=1'>" . $rule->fields["name"] . "</a></td>";
} else {
echo "<td>" . $rule->fields["name"] . "</td>";
}
echo "<td>" . $rule->fields["description"] . "</td>";
echo "<td>" . Dropdown::getYesNo($rule->fields["is_active"]) . "</td>";
echo "</tr>\n";
}
echo $header_begin . $header_bottom . $header_end;
echo "</table>\n";
if ($canedit) {
$massiveactionparams['ontop'] = false;
Html::showMassiveActions($massiveactionparams);
Html::closeForm();
}
}
echo "</div>";
}
示例5: showForEntity
/**
* Show users of an entity
*
* @param $entity Entity object
**/
static function showForEntity(Entity $entity)
{
global $DB;
$ID = $entity->getField('id');
if (!$entity->can($ID, READ)) {
return false;
}
$canedit = $entity->canEdit($ID);
$canshowuser = User::canView();
$nb_per_line = 3;
$rand = mt_rand();
if ($canedit) {
$headerspan = $nb_per_line * 2;
} else {
$headerspan = $nb_per_line;
}
if ($canedit) {
echo "<div class='firstbloc'>";
echo "<form name='entityuser_form{$rand}' id='entityuser_form{$rand}' method='post' action='";
echo Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_1'><th colspan='6'>" . __('Add an authorization to a user') . "</tr>";
echo "<tr class='tab_bg_1'><td class='tab_bg_2 center'>" . __('User') . " ";
echo "<input type='hidden' name='entities_id' value='{$ID}'>";
User::dropdown(array('right' => 'all'));
echo "</td><td class='tab_bg_2 center'>" . self::getTypeName(1) . "</td><td>";
Profile::dropdownUnder(array('value' => Profile::getDefault()));
echo "</td><td class='tab_bg_2 center'>" . __('Recursive') . "</td><td>";
Dropdown::showYesNo("is_recursive", 0);
echo "</td><td class='tab_bg_2 center'>";
echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
echo "</td></tr>";
echo "</table>";
Html::closeForm();
echo "</div>";
}
$query = "SELECT DISTINCT `glpi_profiles`.`id`, `glpi_profiles`.`name`\n FROM `glpi_profiles_users`\n LEFT JOIN `glpi_profiles`\n ON (`glpi_profiles_users`.`profiles_id` = `glpi_profiles`.`id`)\n LEFT JOIN `glpi_users` ON (`glpi_users`.`id` = `glpi_profiles_users`.`users_id`)\n WHERE `glpi_profiles_users`.`entities_id` = '{$ID}'\n AND `glpi_users`.`is_deleted` = '0'";
$result = $DB->query($query);
$nb = $DB->numrows($result);
echo "<div class='spaced'>";
if ($canedit && $nb) {
Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
$massiveactionparams = array('container' => 'mass' . __CLASS__ . $rand, 'specific_actions' => array('purge' => _x('button', 'Delete permanently')));
Html::showMassiveActions($massiveactionparams);
}
echo "<table class='tab_cadre_fixehov'>";
echo "<thead><tr>";
echo "<th class='noHover' colspan='{$headerspan}'>";
printf(__('%1$s (%2$s)'), _n('User', 'Users', Session::getPluralNumber()), __('D=Dynamic, R=Recursive'));
echo "</th></tr></thead>";
if ($nb) {
Session::initNavigateListItems('User', sprintf(__('%1$s = %2$s'), Entity::getTypeName(1), $entity->getName()));
while ($data = $DB->fetch_assoc($result)) {
echo "<tbody><tr class='noHover'>";
$reduce_header = 0;
if ($canedit && $nb) {
echo "<th width='10'>";
echo Html::checkAllAsCheckbox("profile" . $data['id'] . "_{$rand}");
echo "</th>";
$reduce_header++;
}
echo "<th colspan='" . ($headerspan - $reduce_header) . "'>";
printf(__('%1$s: %2$s'), __('Profile'), $data["name"]);
echo "</th></tr></tbody>";
echo "<tbody id='profile" . $data['id'] . "_{$rand}'>";
$query = "SELECT `glpi_users`.*,\n `glpi_profiles_users`.`id` AS linkID,\n `glpi_profiles_users`.`is_recursive`,\n `glpi_profiles_users`.`is_dynamic`\n FROM `glpi_profiles_users`\n LEFT JOIN `glpi_users`\n ON (`glpi_users`.`id` = `glpi_profiles_users`.`users_id`)\n WHERE `glpi_profiles_users`.`entities_id` = '{$ID}'\n AND `glpi_users`.`is_deleted` = '0'\n AND `glpi_profiles_users`.`profiles_id` = '" . $data['id'] . "'\n ORDER BY `glpi_profiles_users`.`profiles_id`,\n `glpi_users`.`name`,\n `glpi_users`.`realname`,\n `glpi_users`.`firstname`";
$result2 = $DB->query($query);
if ($DB->numrows($result2) > 0) {
$i = 0;
while ($data2 = $DB->fetch_assoc($result2)) {
Session::addToNavigateListItems('User', $data2["id"]);
if ($i % $nb_per_line == 0) {
if ($i != 0) {
echo "</tr>";
}
echo "<tr class='tab_bg_1'>";
}
if ($canedit) {
echo "<td width='10'>";
Html::showMassiveActionCheckBox(__CLASS__, $data2["linkID"]);
echo "</td>";
}
$username = formatUserName($data2["id"], $data2["name"], $data2["realname"], $data2["firstname"], $canshowuser);
if ($data2["is_dynamic"] || $data2["is_recursive"]) {
$username = sprintf(__('%1$s %2$s'), $username, "<span class='b'>(");
if ($data2["is_dynamic"]) {
$username = sprintf(__('%1$s%2$s'), $username, __('D'));
}
if ($data2["is_dynamic"] && $data2["is_recursive"]) {
$username = sprintf(__('%1$s%2$s'), $username, ", ");
}
if ($data2["is_recursive"]) {
$username = sprintf(__('%1$s%2$s'), $username, __('R'));
}
$username = sprintf(__('%1$s%2$s'), $username, ")</span>");
//.........这里部分代码省略.........
示例6: showForComputer
/**
* Print the computers disks
*
* @param $comp Computer object
*
* @return Nothing (call to classes members)
**/
static function showForComputer(Computer $comp)
{
global $DB;
$ID = $comp->fields['id'];
if (!$comp->getFromDB($ID) || !$comp->can($ID, "r")) {
return false;
}
$canedit = $comp->can($ID, "w");
echo "<div class='spaced center'>";
$virtualmachines = getAllDatasFromTable('glpi_computervirtualmachines', "`computers_id` = '{$ID}' AND `is_deleted` = '0'");
echo "<table class='tab_cadre_fixe'>";
Session::initNavigateListItems('ComputerVirtualMachine', sprintf(__('%1$s = %2$s'), __('Computer'), empty($comp->fields['name']) ? "({$ID})" : $comp->fields['name']));
if (empty($virtualmachines)) {
echo "<tr><th>" . __('No virtual machine associated with the computer') . "</th></tr>";
} else {
echo "<tr><th colspan='10'>" . __('List of virtual machines') . "</th></tr>";
echo "<tr><th>" . __('Name') . "</th>";
if (Plugin::haveImport()) {
echo "<th>" . __('Automatic inventory') . "</th>";
}
echo "<th>" . __('Virtualization system') . "</th>";
echo "<th>" . __('Virtualization model') . "</th>";
echo "<th>" . __('State of the virtual machine') . "</th>";
echo "<th>" . __('UUID') . "</th>";
echo "<th>" . _x('quantity', 'Processors number') . "</th>";
echo "<th>" . sprintf(__('%1$s (%2$s)'), __('Memory'), __('Mio')) . "</th>";
echo "<th>" . __('Machine') . "</th>";
echo "</tr>";
$vm = new self();
foreach ($virtualmachines as $virtualmachine) {
$vm->getFromDB($virtualmachine['id']);
echo "<tr class='tab_bg_2'>";
echo "<td>" . $vm->getLink() . "</td>";
if (Plugin::haveImport()) {
echo "<td>";
echo Dropdown::getYesNo($vm->isDynamic());
echo "</td>";
}
echo "<td>";
echo Dropdown::getDropdownName('glpi_virtualmachinetypes', $virtualmachine['virtualmachinetypes_id']);
echo "</td>";
echo "<td>";
echo Dropdown::getDropdownName('glpi_virtualmachinesystems', $virtualmachine['virtualmachinesystems_id']);
echo "</td>";
echo "<td>";
echo Dropdown::getDropdownName('glpi_virtualmachinestates', $virtualmachine['virtualmachinestates_id']);
echo "</td>";
echo "<td>" . $virtualmachine['uuid'] . "</a></td>";
echo "<td>" . $virtualmachine['vcpu'] . "</td>";
echo "<td>" . $virtualmachine['ram'] . "</td>";
echo "<td>";
if ($link_computer = self::findVirtualMachine($virtualmachine)) {
$computer = new Computer();
if ($computer->can($link_computer, 'r')) {
$url = "<a href='computer.form.php?id=" . $link_computer . "'>";
$url .= $computer->fields["name"] . "</a>";
$tooltip = "<table><tr><td>" . __('Name') . "</td><td>" . $computer->fields['name'] . '</td></tr>';
$tooltip .= "<tr><td>" . __('Serial number') . "</td><td>" . $computer->fields['serial'] . '</td></tr>';
$tooltip .= "<tr><td>" . __('Comments') . "</td><td>" . $computer->fields['comment'] . '</td></tr></table>';
$url .= " " . Html::showToolTip($tooltip, array('display' => false));
} else {
$url = $computer->fields['name'];
}
echo $url;
}
echo "</td>";
echo "</tr>";
Session::addToNavigateListItems('ComputerVirtualMachine', $virtualmachine['id']);
}
}
if ($canedit) {
echo "<tr class='tab_bg_1'><td colspan='8' class='center'>";
echo "<a class='vsubmit' href='computervirtualmachine.form.php?computers_id={$ID}'>" . __('Add a virtual machine') . "</a></td></tr>";
}
echo "</table>";
echo "</div>";
}
示例7: showListForItem
//.........这里部分代码省略.........
case 'Supplier':
$restrict = "(`glpi_changes_suppliers`.`suppliers_id` = '" . $item->getID() . "')";
$order = '`glpi_changes`.`date_mod` DESC';
$options['criteria'][0]['field'] = 6;
$options['criteria'][0]['searchtype'] = 'equals';
$options['criteria'][0]['value'] = $item->getID();
$options['criteria'][0]['link'] = 'AND';
break;
case 'Group':
// Mini search engine
if ($item->haveChildren()) {
$tree = Session::getSavedOption(__CLASS__, 'tree', 0);
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_1'><th>" . __('Last changes') . "</th></tr>";
echo "<tr class='tab_bg_1'><td class='center'>";
_e('Child groups');
Dropdown::showYesNo('tree', $tree, -1, array('on_change' => 'reloadTab("start=0&tree="+this.value)'));
} else {
$tree = 0;
}
echo "</td></tr></table>";
if ($tree) {
$restrict = "IN (" . implode(',', getSonsOf('glpi_groups', $item->getID())) . ")";
} else {
$restrict = "='" . $item->getID() . "'";
}
$restrict = "(`glpi_changes_groups`.`groups_id` {$restrict}\n AND `glpi_changes_groups`.`type` = " . CommonITILActor::REQUESTER . ")";
$order = '`glpi_changes`.`date_mod` DESC';
$options['criteria'][0]['field'] = 71;
$options['criteria'][0]['searchtype'] = $tree ? 'under' : 'equals';
$options['criteria'][0]['value'] = $item->getID();
$options['criteria'][0]['link'] = 'AND';
break;
default:
$restrict = "(`items_id` = '" . $item->getID() . "'\n AND `itemtype` = '" . $item->getType() . "')";
$order = '`glpi_changes`.`date_mod` DESC';
break;
}
$query = "SELECT " . self::getCommonSelect() . "\n FROM `glpi_changes`\n LEFT JOIN `glpi_changes_items`\n ON (`glpi_changes`.`id` = `glpi_changes_items`.`changes_id`) " . self::getCommonLeftJoin() . "\n WHERE {$restrict} " . getEntitiesRestrictRequest("AND", "glpi_changes") . "\n ORDER BY {$order}\n LIMIT " . intval($_SESSION['glpilist_limit']);
$result = $DB->query($query);
$number = $DB->numrows($result);
// Ticket for the item
echo "<div class='firstbloc'><table class='tab_cadre_fixe'>";
$colspan = 11;
if (count($_SESSION["glpiactiveentities"]) > 1) {
$colspan++;
}
if ($number > 0) {
Session::initNavigateListItems('Change', sprintf(__('%1$s = %2$s'), $item->getTypeName(1), $item->getName()));
echo "<tr><th colspan='{$colspan}'>";
//TRANS : %d is the number of problems
echo sprintf(_n('Last %d change', 'Last %d changes', $number), $number);
// echo "<span class='small_space'><a href='".$CFG_GLPI["root_doc"]."/front/ticket.php?".
// Toolbox::append_params($options,'&')."'>".__('Show all')."</a></span>";
echo "</th></tr>";
} else {
echo "<tr><th>" . __('No change found.') . "</th></tr>";
}
// Ticket list
if ($number > 0) {
self::commonListHeader(Search::HTML_OUTPUT);
while ($data = $DB->fetch_assoc($result)) {
Session::addToNavigateListItems('Problem', $data["id"]);
self::showShort($data["id"]);
}
self::commonListHeader(Search::HTML_OUTPUT);
}
echo "</table></div>";
// Tickets for linked items
$linkeditems = $item->getLinkedItems();
$restrict = array();
if (count($linkeditems)) {
foreach ($linkeditems as $ltype => $tab) {
foreach ($tab as $lID) {
$restrict[] = "(`itemtype` = '{$ltype}' AND `items_id` = '{$lID}')";
}
}
}
if (count($restrict)) {
$query = "SELECT " . self::getCommonSelect() . "\n FROM `glpi_changes`\n LEFT JOIN `glpi_changes_items`\n ON (`glpi_changes`.`id` = `glpi_changes_items`.`changes_id`) " . self::getCommonLeftJoin() . "\n WHERE " . implode(' OR ', $restrict) . getEntitiesRestrictRequest(' AND ', 'glpi_changes') . "\n ORDER BY `glpi_changes`.`date_mod` DESC\n LIMIT " . intval($_SESSION['glpilist_limit']);
$result = $DB->query($query);
$number = $DB->numrows($result);
echo "<div class='spaced'><table class='tab_cadre_fixe'>";
echo "<tr><th colspan='{$colspan}'>";
_e('Changes on linked items');
echo "</th></tr>";
if ($number > 0) {
self::commonListHeader(Search::HTML_OUTPUT);
while ($data = $DB->fetch_assoc($result)) {
// Session::addToNavigateListItems(TRACKING_TYPE,$data["id"]);
self::showShort($data["id"]);
}
self::commonListHeader(Search::HTML_OUTPUT);
} else {
echo "<tr><th>" . __('No change found.') . "</th></tr>";
}
echo "</table></div>";
}
// Subquery for linked item
}
示例8: getTableGroup
/**
* Get the group of elements regarding given item.
* Two kind of item :
* - Device* feed by a link to the attached item (Computer, Printer ...)
* - Computer, Printer ...: feed by the "global" properties of the CommonDevice
* Then feed with the specificities of the Item_Device elements
* In cas of $item is an instance, then $options contains the type of the item (Computer,
* Printer ...).
*
* @param $item
* @param $table
* @param $options array
* @param $delete_all_column (default NULL)
* @param $common_column
* @param $specific_column
* @param $delete_column (default NULL)
* @param $dynamic_column
**/
function getTableGroup(CommonDBTM $item, HTMLTableMain $table, array $options, HTMLTableSuperHeader $delete_all_column = NULL, HTMLTableSuperHeader $common_column, HTMLTableSuperHeader $specific_column, HTMLTableSuperHeader $delete_column = NULL, $dynamic_column)
{
global $DB;
$is_device = $item instanceof CommonDevice;
if ($is_device) {
$peer_type = $options['itemtype'];
if (empty($peer_type)) {
$column_label = __('Dissociated devices');
$group_name = 'None';
} else {
$column_label = $peer_type::getTypeName(Session::getPluralNumber());
$group_name = $peer_type;
}
$table_group = $table->createGroup($group_name, '');
$peer_column = $table_group->addHeader('item', $column_label, $common_column, NULL);
if (!empty($peer_type)) {
//TRANS : %1$s is the type of the device
// %2$s is the type of the item
// %3$s is the name of the item (used for headings of a list),
$itemtype_nav_title = sprintf(__('%1$s of %2$s: %3$s'), $peer_type::getTypeName(Session::getPluralNumber()), $item->getTypeName(1), $item->getName());
$peer_column->setItemType($peer_type, $itemtype_nav_title);
}
} else {
$peer_type = $this->getDeviceType();
$table_group = $table->createGroup($peer_type, '');
//TRANS : %1$s is the type of the device
// %2$s is the type of the item
// %3$s is the name of the item (used for headings of a list),
$options['itemtype_title'] = sprintf(__('%1$s of %2$s: %3$s'), $peer_type::getTypeName(Session::getPluralNumber()), $item->getTypeName(1), $item->getName());
$peer_type::getHTMLTableHeader($item->getType(), $table_group, $common_column, NULL, $options);
}
$specificity_columns = array();
$link_column = $table_group->addHeader('spec_link', '', $specific_column);
$spec_column = $link_column;
foreach ($this->getSpecificities() as $field => $attributs) {
$spec_column = $table_group->addHeader('spec_' . $field, $attributs['long name'], $specific_column, $spec_column);
$specificity_columns[$field] = $spec_column;
}
$infocom_column = $table_group->addHeader('infocom', Infocom::getTypeName(Session::getPluralNumber()), $specific_column, $spec_column);
$document_column = $table_group->addHeader('document', Document::getTypeName(Session::getPluralNumber()), $specific_column, $spec_column);
if ($item->isDynamic()) {
$dynamics_column = $table_group->addHeader('one', ' ', $dynamic_column, $spec_column);
$previous_column = $dynamics_column;
} else {
$previous_column = $spec_column;
}
if ($options['canedit']) {
$group_checkbox_tag = empty($peer_type) ? '__' : $peer_type;
$content = Html::getCheckbox(array('criterion' => array('tag_for_massive' => $group_checkbox_tag)));
$delete_one = $table_group->addHeader('one', $content, $delete_column, $previous_column);
}
if ($is_device) {
$fk = 'items_id';
// Entity restrict
$leftjoin = '';
$where = "";
if (!empty($peer_type)) {
$leftjoin = "LEFT JOIN `" . getTableForItemType($peer_type) . "`\n ON (`" . $this->getTable() . "`.`items_id` = `" . getTableForItemType($peer_type) . "`.`id`\n AND `" . $this->getTable() . "`.`itemtype` = '{$peer_type}')";
$where = getEntitiesRestrictRequest(" AND", getTableForItemType($peer_type));
}
$query = "SELECT `" . $this->getTable() . "`.*\n FROM `" . $this->getTable() . "`\n {$leftjoin}\n WHERE `" . $this->getDeviceForeignKey() . "` = '" . $item->getID() . "'\n AND `" . $this->getTable() . "`.`itemtype` = '{$peer_type}'\n AND `" . $this->getTable() . "`.`is_deleted` = '0'\n {$where}\n ORDER BY `" . $this->getTable() . "`.`itemtype`, `" . $this->getTable() . "`.`{$fk}`";
} else {
$fk = $this->getDeviceForeignKey();
$query = "SELECT *\n FROM `" . $this->getTable() . "`\n WHERE `itemtype` = '" . $item->getType() . "'\n AND `items_id` = '" . $item->getID() . "'\n AND `is_deleted` = '0'\n ORDER BY {$fk}";
}
if (!empty($peer_type)) {
$peer = new $peer_type();
$peer->getEmpty();
} else {
$peer = NULL;
}
foreach ($DB->request($query) as $link) {
Session::addToNavigateListItems(static::getType(), $link["id"]);
$this->getFromDB($link['id']);
if (is_null($peer) || $link[$fk] != $peer->getID()) {
if ($peer instanceof CommonDBTM) {
$peer->getFromDB($link[$fk]);
}
$current_row = $table_group->createRow();
$peer_group = $peer_type . '_' . $link[$fk] . '_' . mt_rand();
$current_row->setHTMLID($peer_group);
if ($options['canedit']) {
//.........这里部分代码省略.........
示例9: showScripts
function showScripts(PluginDatabasesDatabase $database)
{
global $DB, $CFG_GLPI;
$instID = $database->fields['id'];
if (!$database->can($instID, "r")) {
return false;
}
$rand = mt_rand();
$canedit = $database->can($instID, 'w');
$query = "SELECT `glpi_plugin_databases_scripts`.`name` AS name,\n `glpi_plugin_databases_scripts`.`id`,\n `glpi_plugin_databases_scripts`.`plugin_databases_databases_id`,\n `glpi_plugin_databases_scripts`.`path`,\n `glpi_plugin_databases_scripts`.`comment`,\n `glpi_plugin_databases_scripttypes`.`name` AS type\n FROM `glpi_plugin_databases_scripts` ";
$query .= " LEFT JOIN `glpi_plugin_databases_scripttypes`\n ON (`glpi_plugin_databases_scripttypes`.`id` = `glpi_plugin_databases_scripts`.`plugin_databases_scripttypes_id`)";
$query .= " LEFT JOIN `glpi_plugin_databases_databases`\n ON (`glpi_plugin_databases_databases`.`id` = `glpi_plugin_databases_scripts`.`plugin_databases_databases_id`)";
$query .= " WHERE `glpi_plugin_databases_scripts`.`plugin_databases_databases_id` = '{$instID}'\n ORDER BY `glpi_plugin_databases_scripts`.`name`";
$result = $DB->query($query);
$number = $DB->numrows($result);
echo "<div class='spaced'>";
if ($canedit && $number) {
Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
$massiveactionparams = array();
Html::showMassiveActions(__CLASS__, $massiveactionparams);
}
if ($number != 0) {
echo "<table class='tab_cadre_fixe'>";
echo "<tr>";
if ($canedit && $number) {
echo "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>";
}
echo "<th>" . __('Name') . "</th>";
echo "<th>" . __('Type') . "</th>";
echo "<th>" . __('Path', 'databases') . "</th>";
echo "<th>" . __('Comments') . "</th>";
echo "</tr>";
Session::initNavigateListItems($this->getType(), PluginDatabasesDatabase::getTypeName(2) . " = " . $database->fields["name"]);
$i = 0;
$row_num = 1;
while ($data = $DB->fetch_array($result)) {
Session::addToNavigateListItems($this->getType(), $data['id']);
$i++;
$row_num++;
echo "<tr class='tab_bg_1 center'>";
echo "<td width='10'>";
if ($canedit) {
Html::showMassiveActionCheckBox(__CLASS__, $data["id"]);
}
echo "</td>";
echo "<td class='center'>";
echo "<a href='" . $CFG_GLPI["root_doc"] . "/plugins/databases/front/script.form.php?id=" . $data["id"] . "&plugin_databases_databases_id=" . $data["plugin_databases_databases_id"] . "'>";
echo $data["name"];
if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) {
echo " (" . $data["id"] . ")";
}
echo "</a></td>";
echo "<td class='center'>" . $data["type"] . "</td>";
echo "<td class='left'>" . $data["path"] . "</td>";
echo "<td class='center'>" . nl2br($data["comment"]) . "</td>";
echo "</tr>";
}
echo "</table>";
}
if ($canedit && $number) {
$paramsma['ontop'] = false;
Html::showMassiveActions(__CLASS__, $paramsma);
Html::closeForm();
}
echo "</div>";
}
示例10: showOrderReception
public function showOrderReception($orders_id)
{
global $DB, $CFG_GLPI;
$order_order = new PluginOrderOrder();
$order_item = new PluginOrderOrder_Item();
$reference = new PluginOrderReference();
$order_order->getFromDB($orders_id);
Session::initNavigateListItems($this->getType(), __("Order", "order") . " = " . $order_order->fields["name"]);
$canedit = self::canCreate() && !$order_order->canUpdateOrder() && !$order_order->isCanceled();
$result_ref = $order_item->queryDetail($orders_id);
$numref = $DB->numrows($result_ref);
while ($data_ref = $DB->fetch_array($result_ref)) {
echo "<div class='center'><table class='tab_cadre_fixe'>";
if (!$numref) {
echo "<tr><th>" . __("No item to take delivery of", "order") . "</th></tr></table></div>";
} else {
$references_id = $data_ref["id"];
$typeRef = $data_ref["itemtype"];
$price_taxfree = $data_ref["price_taxfree"];
$discount = $data_ref["discount"];
$item = new $typeRef();
$rand = mt_rand();
echo "<tr><th><ul><li>";
echo "<a href=\"javascript:showHideDiv('reception{$rand}','reception_img{$rand}', '" . $CFG_GLPI['root_doc'] . "/pics/plus.png','" . $CFG_GLPI['root_doc'] . "/pics/moins.png');\">";
echo "<img alt='' name='reception_img{$rand}' src=\"" . $CFG_GLPI['root_doc'] . "/pics/plus.png\">";
echo "</a>";
echo "</li></ul></th>";
echo "<th>" . __("Type") . "</th>";
echo "<th>" . __("Manufacturer") . "</th>";
echo "<th>" . __("Product reference", "order") . "</th>";
echo "<th>" . __("Delivered items", "order") . "</th>";
echo "</tr>";
echo "<tr class='tab_bg_1 center'>";
echo "<td></td>";
echo "<td align='center'>" . $item->getTypeName() . "</td>";
echo "<td align='center'>" . Dropdown::getDropdownName("glpi_manufacturers", $data_ref["manufacturers_id"]) . "</td>";
echo "<td>" . $reference->getReceptionReferenceLink($data_ref) . "</td>";
$total = $order_item->getTotalQuantityByRefAndDiscount($orders_id, $references_id, $data_ref["price_taxfree"], $data_ref["discount"]);
echo "<td>" . $order_item->getDeliveredQuantity($orders_id, $references_id, $data_ref["price_taxfree"], $data_ref["discount"]) . " / " . $total . "</td>";
echo "</tr></table>";
echo "<div class='center' id='reception{$rand}' style='display:none'>";
echo "<form method='post' name='order_reception_form{$rand}' id='order_reception_form{$rand}'" . " action=\"" . Toolbox::getItemTypeFormURL("PluginOrderReception") . "\">";
echo "<table class='tab_cadre_fixe'>";
echo "<tr>";
echo "<th width='15'></th>";
if ($typeRef != 'SoftwareLicense') {
echo "<th>" . __("ID") . "</th>";
}
echo "<th>" . __("Reference") . "</th>";
echo "<th>" . __("Status") . "</th>";
echo "<th>" . __("Delivery date") . "</th>";
echo "<th>" . __("Delivery form") . "</th>";
echo "<th>" . __("Delivery status", "order") . "</th>";
echo "</tr>";
$query = "SELECT `glpi_plugin_order_orders_items`.`id` AS IDD,\n `glpi_plugin_order_references`.`id` AS id,\n `glpi_plugin_order_references`.`templates_id`,\n `glpi_plugin_order_orders_items`.`states_id`,\n `glpi_plugin_order_orders_items`.`comment`,\n `glpi_plugin_order_orders_items`.`plugin_order_deliverystates_id`,\n `glpi_plugin_order_orders_items`.`delivery_date`,\n `glpi_plugin_order_orders_items`.`delivery_number`,\n `glpi_plugin_order_references`.`name`,\n `glpi_plugin_order_references`.`itemtype`,\n `glpi_plugin_order_orders_items`.`items_id`\n FROM `glpi_plugin_order_orders_items`, `glpi_plugin_order_references`\n WHERE `plugin_order_orders_id` = '{$orders_id}'\n AND `glpi_plugin_order_orders_items`.`plugin_order_references_id` = '" . $references_id . "'\n AND `glpi_plugin_order_orders_items`.`plugin_order_references_id` = `glpi_plugin_order_references`.`id`\n AND `glpi_plugin_order_orders_items`.`discount` LIKE '" . $discount . "'\n AND `glpi_plugin_order_orders_items`.`price_taxfree` LIKE '" . $price_taxfree . "' ";
if ($typeRef == 'SoftwareLicense') {
$query .= " GROUP BY `glpi_plugin_order_references`.`name` ";
}
$query .= " ORDER BY `glpi_plugin_order_references`.`name` ";
$result = $DB->query($query);
$num = $DB->numrows($result);
while ($data = $DB->fetch_array($result)) {
$random = mt_rand();
$detailID = $data["IDD"];
Session::addToNavigateListItems($this->getType(), $detailID);
echo "<tr class='tab_bg_2'>";
$status = 1;
if ($typeRef != 'SoftwareLicense') {
$status = $this->checkThisItemStatus($detailID, PluginOrderOrder::ORDER_DEVICE_NOT_DELIVRED);
}
if ($order_order->canDeliver() && $status) {
echo "<td width='15' align='left'>";
$sel = "";
if (isset($_GET["select"]) && $_GET["select"] == "all") {
$sel = "checked";
}
echo "<input type='checkbox' name='item[" . $detailID . "]' value='1' {$sel}>";
echo "</td>";
} else {
echo "<td width='15' align='left'></td>";
}
if ($typeRef != 'SoftwareLicense') {
echo "<td align='center'>" . $data["IDD"] . " ";
Html::showTooltip($data['comment']);
echo "</td>";
}
echo "<td align='center'>" . $reference->getReceptionReferenceLink($data) . "</td>";
echo "<td align='center'>";
$link = Toolbox::getItemTypeFormURL($this->getType());
if ($canedit && $data["states_id"] == PluginOrderOrder::ORDER_DEVICE_DELIVRED) {
echo "<a href=\"" . $link . "?id=" . $data["IDD"] . "\">";
}
echo $this->getReceptionStatus($detailID);
if ($canedit && $data["states_id"] == PluginOrderOrder::ORDER_DEVICE_DELIVRED) {
echo "</a>";
}
echo "</td>";
echo "<td align='center'>" . Html::convDate($data["delivery_date"]) . "</td>";
echo "<td align='center'>" . $data["delivery_number"] . "</td>";
echo "<td align='center'>" . Dropdown::getDropdownName("glpi_plugin_order_deliverystates", $data["plugin_order_deliverystates_id"]) . "</td>";
//.........这里部分代码省略.........
示例11: showList
/**
* Print out list kb item
*
* @param $options $_GET
* @param $type string search type : browse / search (default search)
**/
static function showList($options, $type = 'search')
{
global $DB, $CFG_GLPI;
// Default values of parameters
$params['faq'] = !Session::haveRight(self::$rightname, READ);
$params["start"] = "0";
$params["knowbaseitemcategories_id"] = "0";
$params["contains"] = "";
$params["target"] = $_SERVER['PHP_SELF'];
if (is_array($options) && count($options)) {
foreach ($options as $key => $val) {
$params[$key] = $val;
}
}
$ki = new self();
switch ($type) {
case 'myunpublished':
if (!Session::haveRightsOr(self::$rightname, array(UPDATE, self::PUBLISHFAQ))) {
return false;
}
break;
case 'allunpublished':
if (!Session::haveRight(self::$rightname, self::KNOWBASEADMIN)) {
return false;
}
break;
default:
break;
}
if (!$params["start"]) {
$params["start"] = 0;
}
$query = self::getListRequest($params, $type);
// Get it from database
if ($result = $DB->query($query)) {
$KbCategory = new KnowbaseItemCategory();
$title = "";
if ($KbCategory->getFromDB($params["knowbaseitemcategories_id"])) {
$title = empty($KbCategory->fields['name']) ? "(" . $params['knowbaseitemcategories_id'] . ")" : $KbCategory->fields['name'];
$title = sprintf(__('%1$s: %2$s'), __('Category'), $title);
}
Session::initNavigateListItems('KnowbaseItem', $title);
$numrows = $DB->numrows($result);
$list_limit = $_SESSION['glpilist_limit'];
$showwriter = in_array($type, array('myunpublished', 'allunpublished', 'allmy'));
// Limit the result, if no limit applies, use prior result
if ($numrows > $list_limit && !isset($_GET['export_all'])) {
$query_limit = $query . " LIMIT " . intval($params["start"]) . ", " . intval($list_limit) . " ";
$result_limit = $DB->query($query_limit);
$numrows_limit = $DB->numrows($result_limit);
} else {
$numrows_limit = $numrows;
$result_limit = $result;
}
if ($numrows_limit > 0) {
// Set display type for export if define
$output_type = Search::HTML_OUTPUT;
if (isset($_GET["display_type"])) {
$output_type = $_GET["display_type"];
}
// Pager
$parameters = "start=" . $params["start"] . "&knowbaseitemcategories_id=" . $params['knowbaseitemcategories_id'] . "&contains=" . $params["contains"] . "&is_faq=" . $params['faq'];
if (isset($options['item_itemtype']) && isset($options['item_items_id'])) {
$parameters .= "&item_items_id=" . $options['item_items_id'] . "&item_itemtype=" . $options['item_itemtype'];
}
if ($output_type == Search::HTML_OUTPUT) {
Html::printPager($params['start'], $numrows, Toolbox::getItemTypeSearchURL('KnowbaseItem'), $parameters, 'KnowbaseItem');
}
$nbcols = 1;
// Display List Header
echo Search::showHeader($output_type, $numrows_limit + 1, $nbcols);
echo Search::showNewLine($output_type);
$header_num = 1;
echo Search::showHeaderItem($output_type, __('Subject'), $header_num);
if ($output_type != Search::HTML_OUTPUT) {
echo Search::showHeaderItem($output_type, __('Content'), $header_num);
}
if ($showwriter) {
echo Search::showHeaderItem($output_type, __('Writer'), $header_num);
}
echo Search::showHeaderItem($output_type, __('Category'), $header_num);
if (isset($options['item_itemtype']) && isset($options['item_items_id']) && $output_type == Search::HTML_OUTPUT) {
echo Search::showHeaderItem($output_type, ' ', $header_num);
}
// Num of the row (1=header_line)
$row_num = 1;
for ($i = 0; $i < $numrows_limit; $i++) {
$data = $DB->fetch_assoc($result_limit);
Session::addToNavigateListItems('KnowbaseItem', $data["id"]);
// Column num
$item_num = 1;
$row_num++;
echo Search::showNewLine($output_type, $i % 2);
$item = new self();
//.........这里部分代码省略.........
示例12: showOrderSupplierInfos
public static function showOrderSupplierInfos($ID)
{
//TODO : en cours
global $DB;
$order = new PluginOrderOrder();
$order->getFromDB($ID);
$suppliers_id = $order->fields["suppliers_id"];
Session::initNavigateListItems(__CLASS__, __("Order", "order") . " = " . $order->fields["name"]);
$candelete = $order->can($ID, UPDATE);
$rand = mt_rand();
$link = Toolbox::getItemTypeFormURL(__CLASS__);
echo "<form method='post' name='show_supplierinfos{$rand}' id='show_supplierinfos{$rand}' " . "action=\"" . $link . "\">";
echo "<div class='center'>";
echo "<input type='hidden' name='plugin_order_orders_id' value='" . $ID . "'>";
$table = getTableForItemType(__CLASS__);
$nb_elements = countElementsInTable($table, "`plugin_order_orders_id` = '{$ID}'");
if ($nb_elements > 0) {
echo "<table class='tab_cadre_fixe'>";
echo "<tr><th colspan='4'>" . __("Supplier Detail", "order") . "</th></tr>";
echo "<tr>";
echo "<th> </th>";
echo "<th>" . __("Supplier") . "</th>";
echo "<th>" . __("Quote number", "order") . "</th>";
echo "<th>" . __("Order number") . "</th>";
echo "</tr>";
$datas = getAllDatasFromTable($table, "`plugin_order_orders_id` = '{$ID}'");
foreach ($datas as $data) {
Session::addToNavigateListItems(__CLASS__, $data['id']);
echo "<input type='hidden' name='item[" . $data["id"] . "]' value='" . $ID . "'>";
echo "<tr class='tab_bg_1 center'>";
echo "<td>";
if ($candelete) {
echo "<input type='checkbox' name='check[" . $data["id"] . "]'";
if (isset($_POST['check']) && $_POST['check'] == 'all') {
echo " checked ";
}
echo ">";
}
echo "</td>";
echo "<td><a href='" . $link . "?id=" . $data["id"] . "&plugin_order_orders_id=" . $ID . "'>" . Dropdown::getDropdownName("glpi_suppliers", $data["suppliers_id"]) . "</a></td>";
echo "<td>" . $data["num_quote"] . "</td>";
echo "<td>" . $data["num_order"] . "</td>";
echo "</tr>";
}
echo "</table></div>";
if ($candelete) {
Html::openArrowMassives("show_supplierinfos{$rand}", true);
Html::closeArrowMassives(array('delete' => __("Delete permanently")));
}
}
Html::closeForm();
}
示例13: showForGroup
/**
* Show users of a group
*
* @since version 0.83
*
* @param $group Group object: the group
**/
static function showForGroup(Group $group)
{
global $DB, $CFG_GLPI;
$ID = $group->getID();
if (!User::canView() || !$group->can($ID, READ)) {
return false;
}
// Have right to manage members
$canedit = self::canUpdate();
$rand = mt_rand();
$user = new User();
$crit = Session::getSavedOption(__CLASS__, 'criterion', '');
$tree = Session::getSavedOption(__CLASS__, 'tree', 0);
$used = array();
$ids = array();
// Retrieve member list
$entityrestrict = self::getDataForGroup($group, $used, $ids, $crit, $tree);
if ($canedit) {
self::showAddUserForm($group, $ids, $entityrestrict, $crit);
}
// Mini Search engine
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_1'><th colspan='2'>" . User::getTypeName(Session::getPluralNumber()) . "</th></tr>";
echo "<tr class='tab_bg_1'><td class='center'>";
echo _n('Criterion', 'Criteria', 1) . " ";
$crits = array('' => Dropdown::EMPTY_VALUE, 'is_manager' => __('Manager'), 'is_userdelegate' => __('Delegatee'));
Dropdown::showFromArray('crit', $crits, array('value' => $crit, 'on_change' => 'reloadTab("start=0&criterion="+this.value)'));
if ($group->haveChildren()) {
echo "</td><td class='center'>" . __('Child groups');
Dropdown::showYesNo('tree', $tree, -1, array('on_change' => 'reloadTab("start=0&tree="+this.value)'));
} else {
$tree = 0;
}
echo "</td></tr></table>";
$number = count($used);
$start = isset($_GET['start']) ? intval($_GET['start']) : 0;
if ($start >= $number) {
$start = 0;
}
// Display results
if ($number) {
echo "<div class='spaced'>";
Html::printAjaxPager(sprintf(__('%1$s (%2$s)'), User::getTypeName(Session::getPluralNumber()), __('D=Dynamic')), $start, $number);
Session::initNavigateListItems('User', sprintf(__('%1$s = %2$s'), Group::getTypeName(1), $group->getName()));
if ($canedit) {
Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
$massiveactionparams = array('num_displayed' => min($number - $start, $_SESSION['glpilist_limit']), 'container' => 'mass' . __CLASS__ . $rand);
Html::showMassiveActions($massiveactionparams);
}
echo "<table class='tab_cadre_fixehov table-striped table-hover'>";
$header_begin = "<tr>";
$header_top = '';
$header_bottom = '';
$header_end = '';
if ($canedit) {
$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>" . User::getTypeName(1) . "</th>";
if ($tree) {
$header_end .= "<th>" . Group::getTypeName(1) . "</th>";
}
$header_end .= "<th>" . __('Dynamic') . "</th>";
$header_end .= "<th>" . __('Manager') . "</th>";
$header_end .= "<th>" . __('Delegatee') . "</th></tr>";
echo $header_begin . $header_top . $header_end;
$tmpgrp = new Group();
for ($i = $start, $j = 0; $i < $number && $j < $_SESSION['glpilist_limit']; $i++, $j++) {
$data = $used[$i];
$user->getFromDB($data["id"]);
Session::addToNavigateListItems('User', $data["id"]);
echo "\n<tr class='tab_bg_" . ($user->isDeleted() ? '1_2' : '1') . "'>";
if ($canedit) {
echo "<td width='10'>";
Html::showMassiveActionCheckBox(__CLASS__, $data["linkID"]);
echo "</td>";
}
echo "<td>" . $user->getLink();
if ($tree) {
echo "</td><td>";
if ($tmpgrp->getFromDB($data['groups_id'])) {
echo $tmpgrp->getLink(array('comments' => true));
}
}
echo "</td><td class='center'>";
if ($data['is_dynamic']) {
echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/ok.png' width='14' height='14' alt=\"" . __('Dynamic') . "\">";
}
echo "</td><td class='center'>";
if ($data['is_manager']) {
echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/ok.png' width='14' height='14' alt=\"" . __('Manager') . "\">";
//.........这里部分代码省略.........
示例14: showForTicket
/**
* Show changes for a ticket
*
* @param $ticket Ticket object
**/
static function showForTicket(Ticket $ticket)
{
global $DB, $CFG_GLPI;
$ID = $ticket->getField('id');
if (!$ticket->can($ID, READ)) {
return false;
}
$canedit = $ticket->canEdit($ID);
$rand = mt_rand();
$query = "SELECT DISTINCT `glpi_changes_tickets`.`id` AS linkID,\n `glpi_changes`.*\n FROM `glpi_changes_tickets`\n LEFT JOIN `glpi_changes`\n ON (`glpi_changes_tickets`.`changes_id` = `glpi_changes`.`id`)\n WHERE `glpi_changes_tickets`.`tickets_id` = '{$ID}'\n ORDER BY `glpi_changes`.`name`";
$result = $DB->query($query);
$changes = array();
$used = array();
if ($numrows = $DB->numrows($result)) {
while ($data = $DB->fetch_assoc($result)) {
$changes[$data['id']] = $data;
$used[$data['id']] = $data['id'];
}
}
if ($canedit) {
echo "<div class='firstbloc'>";
echo "<form name='changeticket_form{$rand}' id='changeticket_form{$rand}' method='post'\n action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_2'><th colspan='3'>" . __('Add a change') . "</th></tr>";
echo "<tr class='tab_bg_2'><td>";
echo "<input type='hidden' name='tickets_id' value='{$ID}'>";
Change::dropdown(array('used' => $used, 'entity' => $ticket->getEntityID()));
echo "</td><td class='center'>";
echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
echo "</td><td>";
if (Session::haveRight('change', CREATE)) {
echo "<a href='" . Toolbox::getItemTypeFormURL('Change') . "?tickets_id={$ID}'>";
_e('Create a change from this ticket');
echo "</a>";
}
echo "</td></tr></table>";
Html::closeForm();
echo "</div>";
}
echo "<div class='spaced'>";
if ($canedit && $numrows) {
Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
$massiveactionparams = array('num_displayed' => $numrows, 'container' => 'mass' . __CLASS__ . $rand);
Html::showMassiveActions($massiveactionparams);
}
echo "<table class='tab_cadre_fixehov'>";
echo "<tr class='noHover'><th colspan='12'>" . Change::getTypeName($numrows) . "</th>";
echo "</tr>";
if ($numrows) {
Change::commonListHeader(Search::HTML_OUTPUT, 'mass' . __CLASS__ . $rand);
Session::initNavigateListItems('Change', sprintf(__('%1$s = %2$s'), Ticket::getTypeName(1), $ticket->fields["name"]));
$i = 0;
foreach ($changes as $data) {
Session::addToNavigateListItems('Change', $data["id"]);
Change::showShort($data['id'], array('row_num' => $i, 'type_for_massiveaction' => __CLASS__, 'id_for_massiveaction' => $data['linkID']));
$i++;
}
Change::commonListHeader(Search::HTML_OUTPUT, 'mass' . __CLASS__ . $rand);
}
echo "</table>";
if ($canedit && $numrows) {
$massiveactionparams['ontop'] = false;
Html::showMassiveActions($massiveactionparams);
Html::closeForm();
}
echo "</div>";
}
示例15: showForSoftware
/**
* Show Versions of a software
*
* @param $soft Software object
*
* @return nothing
**/
static function showForSoftware(Software $soft)
{
global $DB, $CFG_GLPI;
$softwares_id = $soft->getField('id');
if (!$soft->can($softwares_id, READ)) {
return false;
}
$canedit = $soft->canEdit($softwares_id);
echo "<div class='spaced'>";
if ($canedit) {
echo "<div class='center firstbloc'>";
echo "<a class='vsubmit' href='softwareversion.form.php?softwares_id={$softwares_id}'>" . _x('button', 'Add a version') . "</a>";
echo "</div>";
}
$query = "SELECT `glpi_softwareversions`.*,\n `glpi_states`.`name` AS sname\n FROM `glpi_softwareversions`\n LEFT JOIN `glpi_states` ON (`glpi_states`.`id` = `glpi_softwareversions`.`states_id`)\n WHERE `softwares_id` = '{$softwares_id}'\n ORDER BY `name`";
Session::initNavigateListItems('SoftwareVersion', sprintf(__('%1$s = %2$s'), Software::getTypeName(1), $soft->getName()));
if ($result = $DB->query($query)) {
if ($DB->numrows($result)) {
echo "<table class='tab_cadre_fixehov'><tr>";
echo "<th>" . self::getTypeName(Session::getPluralNumber()) . "</th>";
echo "<th>" . __('Status') . "</th>";
echo "<th>" . __('Operating system') . "</th>";
echo "<th>" . _n('Installation', 'Installations', Session::getPluralNumber()) . "</th>";
echo "<th>" . __('Comments') . "</th>";
echo "</tr>\n";
for ($tot = $nb = 0; $data = $DB->fetch_assoc($result); $tot += $nb) {
Session::addToNavigateListItems('SoftwareVersion', $data['id']);
$nb = Computer_SoftwareVersion::countForVersion($data['id']);
echo "<tr class='tab_bg_2'>";
echo "<td><a href='softwareversion.form.php?id=" . $data['id'] . "'>";
echo $data['name'] . (empty($data['name']) ? "(" . $data['id'] . ")" : "") . "</a></td>";
echo "<td>" . $data['sname'] . "</td>";
echo "<td class='right'>" . Dropdown::getDropdownName('glpi_operatingsystems', $data['operatingsystems_id']);
echo "</td>";
echo "<td class='numeric'>{$nb}</td>";
echo "<td>" . $data['comment'] . "</td></tr>\n";
}
echo "<tr class='tab_bg_1 noHover'><td class='right b' colspan='3'>" . __('Total') . "</td>";
echo "<td class='numeric b'>{$tot}</td><td></td></tr>";
echo "</table>\n";
} else {
echo "<table class='tab_cadre_fixe'>";
echo "<tr><th>" . __('No item found') . "</th></tr>";
echo "</table>\n";
}
}
echo "</div>";
}