function showItems($tech)
{
global $DB, $CFG_GLPI;
$rand = mt_rand();
$ID = $this->fields['id'];
if ($tech) {
$types = $CFG_GLPI['linkgroup_tech_types'];
$field = 'groups_id_tech';
$title = __('Managed items');
} else {
$types = $CFG_GLPI['linkgroup_types'];
$field = 'groups_id';
$title = __('Used items');
}
$tree = Session::getSavedOption(__CLASS__, 'tree', 0);
$user = Session::getSavedOption(__CLASS__, 'user', 0);
$type = Session::getSavedOption(__CLASS__, 'onlytype', '');
if (!in_array($type, $types)) {
$type = '';
}
echo "<div class='spaced'>";
// Mini Search engine
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_1'><th colspan='3'>{$title}</tr>";
echo "<tr class='tab_bg_1'><td class='center'>";
echo __('Type') . " ";
Dropdown::showItemType($types, array('value' => $type, 'name' => 'onlytype', 'plural' => true, 'on_change' => 'reloadTab("start=0&onlytype="+this.value)', 'checkright' => true));
if ($this->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;
}
if ($this->getField('is_usergroup')) {
echo "</td><td class='center'>" . User::getTypeName(Session::getPluralNumber()) . " ";
Dropdown::showYesNo('user', $user, -1, array('on_change' => 'reloadTab("start=0&user="+this.value)'));
} else {
$user = 0;
}
echo "</td></tr></table>";
$datas = array();
if ($type) {
$types = array($type);
}
$start = isset($_GET['start']) ? intval($_GET['start']) : 0;
$nb = $this->getDataItems($types, $field, $tree, $user, $start, $datas);
$nbcan = 0;
if ($nb) {
Html::printAjaxPager('', $start, $nb);
Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
echo Html::hidden('field', array('value' => $field, 'data-glpicore-ma-tags' => 'common'));
$massiveactionparams = array('num_displayed' => $nb, 'check_itemtype' => 'Group', 'check_items_id' => $ID, 'container' => 'mass' . __CLASS__ . $rand, 'extraparams' => array('is_tech' => $tech, 'massive_action_fields' => array('field')), 'specific_actions' => array(__CLASS__ . MassiveAction::CLASS_ACTION_SEPARATOR . 'changegroup' => __('Move')));
Html::showMassiveActions($massiveactionparams);
echo "<table class='tab_cadre_fixehov'>";
$header_begin = "<tr><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><th>" . __('Name') . "</th><th>" . __('Entity') . "</th>";
if ($tree || $user) {
$header_end .= "<th>" . sprintf(__('%1$s / %2$s'), self::getTypeName(1), User::getTypeName(1)) . "</th>";
}
$header_end .= "</tr>";
echo $header_begin . $header_top . $header_end;
$tuser = new User();
$group = new Group();
foreach ($datas as $data) {
if (!($item = getItemForItemtype($data['itemtype']))) {
continue;
}
echo "<tr class='tab_bg_1'><td>";
if ($item->canEdit($data['items_id'])) {
Html::showMassiveActionCheckBox($data['itemtype'], $data['items_id']);
}
echo "</td><td>" . $item->getTypeName(1);
echo "</td><td>" . $item->getLink(array('comments' => true));
echo "</td><td>" . Dropdown::getDropdownName("glpi_entities", $item->getEntityID());
if ($tree || $user) {
echo "</td><td>";
if ($grp = $item->getField($field)) {
if ($group->getFromDB($grp)) {
echo $group->getLink(array('comments' => true));
}
} else {
if ($usr = $item->getField(str_replace('groups', 'users', $field))) {
if ($tuser->getFromDB($usr)) {
echo $tuser->getLink(array('comments' => true));
}
}
}
}
echo "</td></tr>";
}
echo $header_begin . $header_bottom . $header_end;
echo "</table>";
} else {
echo "<p class='center b'>" . __('No item found') . "</p>";
}
if ($nb) {
$massiveactionparams['ontop'] = false;
Html::showMassiveActions($massiveactionparams);
}
Html::closeForm();
if ($nb) {
Html::printAjaxPager('', $start, $nb);
}
echo "</div>";
}