function showSummary(CommonITILObject $item)
{
global $DB, $CFG_GLPI;
if (!static::canView()) {
return false;
}
$tID = $item->fields['id'];
// Display existing Followups
$showprivate = $this->canViewPrivates();
$caneditall = $this->canEditAll();
$tmp = array($item->getForeignKeyField() => $tID);
$canadd = $this->can(-1, CREATE, $tmp);
$canpurge = $this->canPurgeItem();
$canview = $this->canViewItem();
$RESTRICT = "";
if ($this->maybePrivate() && !$showprivate) {
$RESTRICT = " AND (`is_private` = '0'\n OR `users_id` ='" . Session::getLoginUserID() . "'\n OR `users_id_tech` ='" . Session::getLoginUserID() . "'\n OR `groups_id_tech` IN ('" . implode("','", $_SESSION["glpigroups"]) . "')) ";
}
$query = "SELECT `id`, `date`\n FROM `" . $this->getTable() . "`\n WHERE `" . $item->getForeignKeyField() . "` = '{$tID}'\n {$RESTRICT}\n ORDER BY `date` DESC";
$result = $DB->query($query);
$rand = mt_rand();
if ($caneditall || $canadd || $canpurge) {
echo "<div id='viewfollowup" . $tID . "{$rand}'></div>\n";
}
if ($canadd) {
echo "<script type='text/javascript' >\n";
echo "function viewAddTask" . $item->fields['id'] . "{$rand}() {\n";
$params = array('type' => $this->getType(), 'parenttype' => $item->getType(), $item->getForeignKeyField() => $item->fields['id'], 'id' => -1);
Ajax::updateItemJsCode("viewfollowup" . $item->fields['id'] . "{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params);
echo Html::jsHide('addbutton' . $item->fields['id'] . "{$rand}");
echo "};";
echo "</script>\n";
if (!in_array($item->fields["status"], array_merge($item->getSolvedStatusArray(), $item->getClosedStatusArray()))) {
echo "<div id='addbutton" . $item->fields['id'] . "{$rand}' class='center firstbloc'>" . "<a class='vsubmit' href='javascript:viewAddTask" . $item->fields['id'] . "{$rand}();'>";
echo __('Add a new task') . "</a></div>\n";
}
}
if ($DB->numrows($result) == 0) {
echo "<table class='tab_cadre_fixe'><tr class='tab_bg_2'><th>" . __('No task found.');
echo "</th></tr></table>";
} else {
echo "<table class='tab_cadre_fixehov'>";
$header = "<tr><th> </th><th>" . __('Type') . "</th><th>" . __('Date') . "</th>";
$header .= "<th>" . __('Description') . "</th><th>" . __('Duration') . "</th>";
$header .= "<th>" . __('Writer') . "</th>";
if ($this->maybePrivate() && $showprivate) {
$header .= "<th>" . __('Private') . "</th>";
}
$header .= "<th>" . __('Planning') . "</th></tr>\n";
echo $header;
while ($data = $DB->fetch_assoc($result)) {
if ($this->getFromDB($data['id'])) {
$options = array('parent' => $item, 'rand' => $rand, 'showprivate' => $showprivate);
Plugin::doHook('pre_show_item', array('item' => $this, 'options' => &$options));
$this->showInObjectSumnary($item, $rand, $showprivate);
Plugin::doHook('post_show_item', array('item' => $this, 'options' => $options));
}
}
echo $header;
echo "</table>";
}
}