/** * Show the current task sumnary * * @param $item CommonITILObject **/ 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>"; } }
/** * @param $item CommonITILObject * @param $type */ static function alertValidation(CommonITILObject $item, $type) { global $CFG_GLPI; // No alert for new item if ($item->isNewID($item->getID())) { return; } $status = array_merge($item->getClosedStatusArray(), $item->getSolvedStatusArray()); $message = __s("This item is waiting for approval, do you really want to resolve or close it?"); switch ($type) { case 'status': Html::scriptStart(); echo "\$('[name=\"status\"]').change(function() {\n var status_ko = 0;\n var input_status = \$(this).val();\n if (input_status != undefined) {\n if (("; $first = true; foreach ($status as $val) { if (!$first) { echo "||"; } echo "input_status == {$val}"; $first = false; } echo " )\n && input_status != " . $item->fields['status'] . "){\n status_ko = 1;\n }\n }\n if ((status_ko == 1)\n && ('" . $item->fields['global_validation'] . "' == '" . self::WAITING . "')) {\n alert('" . $message . "');\n }\n });"; echo Html::scriptEnd(); break; case 'solution': if (!in_array($item->fields['status'], $status) && $item->fields['global_validation'] == self::WAITING) { Html::displayTitle($CFG_GLPI['root_doc'] . "/pics/warning.png", $message, $message); } break; } }