Make a good string from the unix timestamp $sec
static public timestampToString ( $time, $display_sec = true, $use_days = true ) : string | ||
$time | integer timestamp | |
$display_sec | boolean display seconds ? (true by default) | |
$use_days | boolean use days for display ? (true by default) | |
return | string |
function displayTotal($output_type) { if ($this->export_timestamp) { return $this->total; } return Html::timestampToString($this->total, $this->withsec); }
static function pdfForTicket(PluginPdfSimplePDF $pdf, Ticket $job, $private) { global $CFG_GLPI, $DB; $ID = $job->getField('id'); //////////////Tasks/////////// $RESTRICT = ""; if (!$private) { // Don't show private' $RESTRICT = " AND `is_private` = '0' "; } else { if (!Session::haveRight("show_full_ticket", "1")) { // No right, only show connected user private one $RESTRICT = " AND (`is_private` = '0'\n OR `users_id` ='" . Session::getLoginUserID() . "' ) "; } } $query = "SELECT *\n FROM `glpi_tickettasks`\n WHERE `tickets_id` = '{$ID}'\n {$RESTRICT}\n ORDER BY `date` DESC"; $result = $DB->query($query); if (!$DB->numrows($result)) { $pdf->setColumnsSize(100); $pdf->displayLine(__('No task found.')); } else { $pdf->displayTitle("<b>" . TicketTask::getTypeName($DB->numrows($result) . "</b>")); $pdf->setColumnsSize(20, 20, 20, 20, 20); $pdf->displayTitle("<b><i>" . __('Type') . "</i></b>", "<b><i>" . __('Date') . "</i></b>", "<b><i>" . __('Duration') . "</i></b>", "<b><i>" . __('Writer') . "</i></b>", "<b><i>" . __('Planning') . "</i></b>"); while ($data = $DB->fetch_array($result)) { $actiontime = Html::timestampToString($data['actiontime'], false); $planification = ''; if (empty($data['begin'])) { if (isset($data["state"])) { $planification = Planning::getState($data["state"]) . "<br>"; } $planification .= _e('None'); } else { if (isset($data["state"])) { $planification = sprintf(__('%1$s: %2$s'), _x('item', 'State'), Planning::getState($data["state"])); } $planificiation = sprintf(__('%1$s - %2$s'), $planification, Html::convDateTime($data["begin"]) . " -> " . Html::convDateTime($data["end"])); $planificiation = sprintf(__('%1$s - %2$s'), $planification, sprintf(__('%1$s %2$s'), __('By'), getUserName($data["users_id_tech"]))); } if ($data['taskcategories_id']) { $lib = Dropdown::getDropdownName('glpi_taskcategories', $data['taskcategories_id']); } else { $lib = ''; } if ($data['is_private']) { $lib = sprintf(__('%1$s (%2$s)'), $lib, __('Private')); } toolbox::logdebug("lib", $data); $pdf->displayLine(Html::clean($lib), Html::convDateTime($data["date"]), Html::timestampToString($data["actiontime"], 0), Html::clean(getUserName($data["users_id"])), Html::clean($planification), 1); $pdf->displayText("<b><i>" . sprintf(__('%1$s: %2$s'), __('Description') . "</i></b>", Html::clean($data["content"]), 1)); } } $pdf->displaySpace(); }
/** * @param $event * @param $options array **/ function getDatasForTemplate($event, $options = array()) { if ($options['diff'] > 1000000000) { $tmp = __("Can't connect to the database."); } else { $tmp = Html::timestampToString($options['diff'], true); } $this->datas['##dbconnection.delay##'] = $tmp . " (" . $options['name'] . ")"; $this->getTags(); foreach ($this->tag_descriptions[NotificationTarget::TAG_LANGUAGE] as $tag => $values) { if (!isset($this->datas[$tag])) { $this->datas[$tag] = $values['label']; } } }
/** * @since version 0.84 * * @param $field * @param $values * @param $options array **/ static function getSpecificValueToDisplay($field, $values, array $options = array()) { if (!is_array($values)) { $values = array($field => $values); } switch ($field) { case 'periodicity': if (preg_match('/([0-9]+)MONTH/', $values[$field], $matches)) { return sprintf(_n('%d month', '%d months', $matches[1]), $matches[1]); } if (preg_match('/([0-9]+)YEAR/', $values[$field], $matches)) { return sprintf(_n('%d year', '%d years', $matches[1]), $matches[1]); } return Html::timestampToString($values[$field], false); break; } return parent::getSpecificValueToDisplay($field, $values, $options); }
static function pdfStat(PluginPdfSimplePDF $pdf, Ticket $job) { $pdf->setColumnsSize(100); $pdf->displayTitle("<b>" . _n('Date', 'Dates', 2) . "</b>"); $pdf->setColumnsSize(50, 50); $pdf->displayLine(sprintf(__('%1$s: %2$s'), __('Opening date'), Html::convDateTime($job->fields['date']))); $pdf->displayLine(sprintf(__('%1$s: %2$s'), __('Due date'), Html::convDateTime($job->fields['due_date']))); if (in_array($job->fields["status"], $job->getSolvedStatusArray()) || in_array($job->fields["status"], $job->getClosedStatusArray())) { $pdf->displayLine(sprintf(__('%1$s: %2$s'), __('Solution date'), Html::convDateTime($job->fields['solvedate']))); } if (in_array($job->fields["status"], $job->getClosedStatusArray())) { $pdf->displayLine(sprintf(__('%1$s: %2$s'), __('Closing date'), Html::convDateTime($job->fields['closedate']))); } $pdf->setColumnsSize(100); $pdf->displayTitle("<b>" . _n('Time', 'Times', 2) . "</b>"); $pdf->setColumnsSize(50, 50); if ($job->fields['takeintoaccount_delay_stat'] > 0) { $pdf->displayLine(sprintf(__('%1$s: %2$s'), __('Take into account'), Html::clean(Html::timestampToString($job->fields['takeintoaccount_delay_stat'], 0)))); } if (in_array($job->fields["status"], $job->getSolvedStatusArray()) || in_array($job->fields["status"], $job->getClosedStatusArray())) { if ($job->fields['solve_delay_stat'] > 0) { $pdf->displayLine(sprintf(__('%1$s: %2$s'), __('Solution'), Html::clean(Html::timestampToString($job->fields['solve_delay_stat'], 0)))); } } if (in_array($job->fields["status"], $job->getClosedStatusArray())) { if ($job->fields['close_delay_stat'] > 0) { $pdf->displayLine(sprintf(__('%1$s: %2$s'), __('Closing'), Html::clean(Html::timestampToString($job->fields['close_delay_stat'], 0)))); } } if ($job->fields['waiting_duration'] > 0) { $pdf->displayLine(sprintf(__('%1$s: %2$s'), __('Pending'), Html::clean(Html::timestampToString($job->fields['waiting_duration'], 0)))); } $pdf->displaySpace(); }
/** * Show projecttasks 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_projecttasks_tickets`.`id` AS linkID,\n `glpi_projecttasks`.*\n FROM `glpi_projecttasks`\n LEFT JOIN `glpi_projecttasks_tickets`\n ON (`glpi_projecttasks_tickets`.`projecttasks_id` = `glpi_projecttasks`.`id`)\n WHERE `glpi_projecttasks_tickets`.`tickets_id` = '{$ID}'\n ORDER BY `glpi_projecttasks`.`name`"; $result = $DB->query($query); $pjtasks = array(); $used = array(); if ($numrows = $DB->numrows($result)) { while ($data = $DB->fetch_assoc($result)) { $pjtasks[$data['id']] = $data; $used[$data['id']] = $data['id']; } } // if ($canedit) { // echo "<div class='firstbloc'>"; // echo "<form name='projecttaskticket_form$rand' id='projecttaskticket_form$rand' // method='post' action='".Toolbox::getItemTypeFormURL(__CLASS__)."'>"; // // echo "<table class='tab_cadre_fixe'>"; // echo "<tr class='tab_bg_2'><th colspan='3'>".__('Add a project task')."</th></tr>"; // // echo "<tr class='tab_bg_2'><td class='right'>"; // echo "<input type='hidden' name='tickets_id' value='$ID'>"; // $condition = "`glpi_projecttasks`.`projectstates_id` <> 3"; // ProjectTask::dropdown(array('used' => $used, // 'entity' => $ticket->getEntityID(), // 'entity_sons' => $ticket->isRecursive(), // 'condition' => $condition, // 'displaywith' => array('id'))); // echo "</td><td width='20%'>"; // // echo "<a href='".Toolbox::getItemTypeFormURL('ProjectTask')."?tickets_id=$ID'>"; // // _e('Create a project task from this ticket'); // // echo "</a>"; // echo "</td><td class='center'>"; // echo "<input type='submit' name='add' value=\""._sx('button', 'Add')."\" class='submit'>"; // echo "</td></tr>"; // // echo "</table>"; // Html::closeForm(); // echo "</div>"; // } echo "<div class='spaced'>"; if ($numrows) { $columns = array('projectname' => Project::getTypeName(Session::getPluralNumber()), 'name' => ProjectTask::getTypeName(Session::getPluralNumber()), 'tname' => __('Type'), 'sname' => __('Status'), 'percent_done' => __('Percent done'), 'plan_start_date' => __('Planned start date'), 'plan_end_date' => __('Planned end date'), 'planned_duration' => __('Planned duration'), '_effect_duration' => __('Effective duration'), 'fname' => __('Father')); if (isset($_GET["order"]) && $_GET["order"] == "DESC") { $order = "DESC"; } else { $order = "ASC"; } if (!isset($_GET["sort"]) || empty($_GET["sort"])) { $_GET["sort"] = "plan_start_date"; } if (isset($_GET["sort"]) && !empty($_GET["sort"]) && isset($columns[$_GET["sort"]])) { $sort = "`" . $_GET["sort"] . "`"; } else { $sort = "`plan_start_date` {$order}, `name`"; } $query = "SELECT `glpi_projecttasks`.*,\n `glpi_projecttasktypes`.`name` AS tname,\n `glpi_projectstates`.`name` AS sname,\n `glpi_projectstates`.`color`,\n `father`.`name` AS fname,\n `father`.`id` AS fID,\n `glpi_projects`.`name` AS projectname,\n `glpi_projects`.`content` AS projectcontent\n FROM `glpi_projecttasks`\n LEFT JOIN `glpi_projecttasktypes`\n ON (`glpi_projecttasktypes`.`id` = `glpi_projecttasks`.`projecttasktypes_id`)\n LEFT JOIN `glpi_projectstates`\n ON (`glpi_projectstates`.`id` = `glpi_projecttasks`.`projectstates_id`)\n LEFT JOIN `glpi_projecttasks` as father\n ON (`father`.`id` = `glpi_projecttasks`.`projecttasks_id`)\n LEFT JOIN `glpi_projecttasks_tickets`\n ON (`glpi_projecttasks_tickets`.`projecttasks_id` = `glpi_projecttasks`.`id`)\n LEFT JOIN `glpi_projects`\n ON (`glpi_projecttasks`.`projects_id` = `glpi_projects`.`id`)\n WHERE `glpi_projecttasks_tickets`.`tickets_id` = '{$ID}'\n ORDER BY {$sort} {$order}"; Session::initNavigateListItems('ProjectTask', sprintf(__('%1$s = %2$s'), $ticket::getTypeName(1), $ticket->getName())); if ($result = $DB->query($query)) { if ($DB->numrows($result)) { echo "<table class='tab_cadre_fixehov'>"; echo "<tr><th colspan='10'>" . ProjectTask::getTypeName($numrows) . "</th>"; echo "</tr>"; $sort_img = "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/" . ($order == "DESC" ? "puce-down.png" : "puce-up.png") . "\" alt='' title=''>"; $header = '<tr>'; foreach ($columns as $key => $val) { // Non order column if ($key[0] == '_') { $header .= "<th>{$val}</th>"; } else { $header .= "<th>" . ($sort == "`{$key}`" ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort={$key}&order=" . ($order == "ASC" ? "DESC" : "ASC") . "&start=0\");'>{$val}</a></th>"; } } $header .= "</tr>\n"; echo $header; while ($data = $DB->fetch_assoc($result)) { Session::addToNavigateListItems('ProjectTask', $data['id']); $rand = mt_rand(); echo "<tr class='tab_bg_2'>"; echo "<td>"; $link = "<a id='Project" . $data["projects_id"] . $rand . "' href='project.form.php?id=" . $data['projects_id'] . "'>" . $data['projectname'] . (empty($data['projectname']) ? "(" . $data['projects_id'] . ")" : "") . "</a>"; echo sprintf(__('%1$s %2$s'), $link, Html::showToolTip($data['projectcontent'], array('display' => false, 'applyto' => "Project" . $data["projects_id"] . $rand))); echo "</td>"; echo "<td>"; $link = "<a id='ProjectTask" . $data["id"] . $rand . "' href='projecttask.form.php?id=" . $data['id'] . "'>" . $data['name'] . (empty($data['name']) ? "(" . $data['id'] . ")" : "") . "</a>"; echo sprintf(__('%1$s %2$s'), $link, Html::showToolTip($data['content'], array('display' => false, 'applyto' => "ProjectTask" . $data["id"] . $rand))); echo "</td>"; echo "<td>" . $data['tname'] . "</td>"; echo "<td"; echo " style=\"background-color:" . $data['color'] . "\""; echo ">" . $data['sname'] . "</td>"; echo "<td>"; echo Dropdown::getValueWithUnit($data["percent_done"], "%"); echo "</td>"; echo "<td>" . Html::convDateTime($data['plan_start_date']) . "</td>"; echo "<td>" . Html::convDateTime($data['plan_end_date']) . "</td>"; echo "<td>" . Html::timestampToString($data['planned_duration'], false) . "</td>"; echo "<td>" . Html::timestampToString(ProjectTask::getTotalEffectiveDuration($data['id']), false) . "</td>"; echo "<td>"; if ($data['projecttasks_id'] > 0) { $father = Dropdown::getDropdownName('glpi_projecttasks', $data['projecttasks_id']); echo "<a id='ProjectTask" . $data["projecttasks_id"] . $rand . "' href='projecttask.form.php?id=" . $data['projecttasks_id'] . "'>" . $father . (empty($father) ? "(" . $data['projecttasks_id'] . ")" : "") . "</a>"; } echo "</td></tr>"; } echo $header; echo "</table>\n"; } else { echo "<table class='tab_cadre_fixe'>"; echo "<tr><th>" . __('No item found') . "</th></tr>"; echo "</table>\n"; } } echo "</div>"; } }
function plugin_fusioninventory_displayMigrationMessage($id, $msg = "") { static $created = 0; static $deb; if ($created != $id) { if (empty($msg)) { $msg = __('Work in progress...'); } echo "<div id='migration_message_{$id}'><p class='center'>{$msg}</p></div>"; $created = $id; $deb = time(); } else { if (empty($msg)) { $msg = __('Task completed.'); } $fin = time(); $tps = Html::timestampToString($fin - $deb); echo "<script type='text/javascript'>document.getElementById('migration_message_{$id}')." . "innerHTML = '<p class=\"center\">{$msg} ({$tps})</p>';</script>\n"; } Html::glpi_flush(); }
/** * Generic Function to display Items * * @param $itemtype item type * @param $ID ID of the SEARCH_OPTION item * @param $data array containing data results * @param $num item num in the request * @param $meta is a meta item ? (default 0) * @param $addobjectparams array added parameters for union search * * @return string to print **/ static function giveItem($itemtype, $ID, array $data, $num, $meta = 0, array $addobjectparams = array()) { global $CFG_GLPI, $DB; $searchopt =& self::getOptions($itemtype); if (isset($CFG_GLPI["union_search_type"][$itemtype]) && $CFG_GLPI["union_search_type"][$itemtype] == $searchopt[$ID]["table"]) { if (isset($searchopt[$ID]['addobjectparams']) && $searchopt[$ID]['addobjectparams']) { return self::giveItem($data["TYPE"], $ID, $data, $num, $meta, $searchopt[$ID]['addobjectparams']); } return self::giveItem($data["TYPE"], $ID, $data, $num, $meta); } if (count($addobjectparams)) { $searchopt[$ID] = array_merge($searchopt[$ID], $addobjectparams); } // Plugin can override core definition for its type if ($plug = isPluginItemType($itemtype)) { $function = 'plugin_' . $plug['plugin'] . '_giveItem'; if (function_exists($function)) { $out = $function($itemtype, $ID, $data, $num); if (!empty($out)) { return $out; } } } $NAME = "ITEM_"; // if ($meta) { // $NAME = "META_"; // } if (isset($searchopt[$ID]["table"])) { $table = $searchopt[$ID]["table"]; $field = $searchopt[$ID]["field"]; $linkfield = $searchopt[$ID]["linkfield"]; /// TODO try to clean all specific cases using SpecificToDisplay switch ($table . '.' . $field) { case "glpi_users.name": // USER search case if ($itemtype != 'User' && isset($searchopt[$ID]["forcegroupby"]) && $searchopt[$ID]["forcegroupby"]) { $out = ""; $count_display = 0; $added = array(); $showuserlink = 0; if (Session::haveRight('user', READ)) { $showuserlink = 1; } for ($k = 0; $k < $data[$num]['count']; $k++) { if (isset($data[$num][$k]['name']) && $data[$num][$k]['name'] > 0 || isset($data[$num][$k][2]) && $data[$num][$k][2] != '') { if ($count_display) { $out .= self::LBBR; } if ($itemtype == 'Ticket') { if (isset($data[$num][$k]['name']) && $data[$num][$k]['name'] > 0) { $userdata = getUserName($data[$num][$k]['name'], 2); $tooltip = ""; if (Session::haveRight('user', READ)) { $tooltip = Html::showToolTip($userdata["comment"], array('link' => $userdata["link"], 'display' => false)); } $out .= sprintf(__('%1$s %2$s'), $userdata['name'], $tooltip); $count_display++; } } else { $out .= getUserName($data[$num][$k]['name'], $showuserlink); $count_display++; } // Manage alternative_email for tickets_users if ($itemtype == 'Ticket' && isset($data[$num][$k][2])) { $split = explode(self::LONGSEP, $data[$num][$k][2]); for ($l = 0; $l < count($split); $l++) { $split2 = explode(" ", $split[$l]); if (count($split2) == 2 && $split2[0] == 0 && !empty($split2[1])) { if ($count_display) { $out .= self::LBBR; } $count_display++; $out .= "<a href='mailto:" . $split2[1] . "'>" . $split2[1] . "</a>"; } } } } } return $out; } if ($itemtype != 'User') { $toadd = ''; if ($itemtype == 'Ticket' && $data[$num][0]['id'] > 0) { $userdata = getUserName($data[$num][0]['id'], 2); $toadd = Html::showToolTip($userdata["comment"], array('link' => $userdata["link"], 'display' => false)); } $usernameformat = formatUserName($data[$num][0]['id'], $data[$num][0]['name'], $data[$num][0]['realname'], $data[$num][0]['firstname'], 1); return sprintf(__('%1$s %2$s'), $usernameformat, $toadd); } break; case "glpi_profiles.name": if ($itemtype == 'User' && $ID == 20) { $out = ""; $count_display = 0; $added = array(); for ($k = 0; $k < $data[$num]['count']; $k++) { if (strlen(trim($data[$num][$k]['name'])) > 0) { $text = sprintf(__('%1$s - %2$s'), $data[$num][$k]['name'], Dropdown::getDropdownName('glpi_entities', $data[$num][$k]['entities_id'])); $comp = ''; if ($data[$num][$k]['is_recursive']) { $comp = __('R'); if ($data[$num][$k]['is_dynamic']) { $comp = sprintf(__('%1$s%2$s'), $comp, ", "); } } if ($data[$num][$k]['is_dynamic']) { $comp = sprintf(__('%1$s%2$s'), $comp, __('D')); } if (!empty($comp)) { $text = sprintf(__('%1$s %2$s'), $text, "(" . $comp . ")"); } if (!in_array($text, $added)) { if ($count_display) { $out .= self::LBBR; } $count_display++; $out .= $text; $added[] = $text; } } } return $out; } break; case "glpi_entities.completename": if ($itemtype == 'User') { $out = ""; $added = array(); $count_display = 0; for ($k = 0; $k < $data[$num]['count']; $k++) { if (strlen(trim($data[$num][$k]['name'])) > 0) { $text = sprintf(__('%1$s - %2$s'), $data[$num][$k]['name'], Dropdown::getDropdownName('glpi_profiles', $data[$num][$k]['profiles_id'])); $comp = ''; if ($data[$num][$k]['is_recursive']) { $comp = __('R'); if ($data[$num][$k]['is_dynamic']) { $comp = sprintf(__('%1$s%2$s'), $comp, ", "); } } if ($data[$num][$k]['is_dynamic']) { $comp = sprintf(__('%1$s%2$s'), $comp, __('D')); } if (!empty($comp)) { $text = sprintf(__('%1$s %2$s'), $text, "(" . $comp . ")"); } if (!in_array($text, $added)) { if ($count_display) { $out .= self::LBBR; } $count_display++; $out .= $text; $added[] = $text; } } } return $out; } break; case "glpi_documenttypes.icon": if (!empty($data[$num][0]['name'])) { return "<img class='middle' alt='' src='" . $CFG_GLPI["typedoc_icon_dir"] . "/" . $data[$num][0]['name'] . "'>"; } return " "; case "glpi_documents.filename": $doc = new Document(); if ($doc->getFromDB($data['id'])) { return $doc->getDownloadLink(); } return NOT_AVAILABLE; case "glpi_tickets_tickets.tickets_id_1": $out = ""; $displayed = array(); for ($k = 0; $k < $data[$num]['count']; $k++) { $linkid = $data[$num][$k]['tickets_id_2'] == $data['id'] ? $data[$num][$k]['name'] : $data[$num][$k]['tickets_id_2']; if ($linkid > 0 && !isset($displayed[$linkid])) { $text = "<a "; $text .= "href=\"" . $CFG_GLPI["root_doc"] . "/front/ticket.form.php?id={$linkid}\">"; $text .= Dropdown::getDropdownName('glpi_tickets', $linkid) . "</a>"; if (count($displayed)) { $out .= self::LBBR; } $displayed[$linkid] = $linkid; $out .= $text; } } return $out; case "glpi_problems.id": if ($searchopt[$ID]["datatype"] == 'count') { if ($data[$num][0]['name'] > 0 && Session::haveRight("problem", Problem::READALL)) { if ($itemtype == 'ITILCategory') { $options['criteria'][0]['field'] = 7; $options['criteria'][0]['searchtype'] = 'equals'; $options['criteria'][0]['value'] = $data['id']; $options['criteria'][0]['link'] = 'AND'; } else { $options['criteria'][0]['field'] = 12; $options['criteria'][0]['searchtype'] = 'equals'; $options['criteria'][0]['value'] = 'all'; $options['criteria'][0]['link'] = 'AND'; $options['metacriteria'][0]['itemtype'] = $itemtype; $options['metacriteria'][0]['field'] = self::getOptionNumber($itemtype, 'name'); $options['metacriteria'][0]['searchtype'] = 'equals'; $options['metacriteria'][0]['value'] = $data['id']; $options['metacriteria'][0]['link'] = 'AND'; } $options['reset'] = 'reset'; $out = "<a id='problem{$itemtype}" . $data['id'] . "' "; $out .= "href=\"" . $CFG_GLPI["root_doc"] . "/front/problem.php?" . Toolbox::append_params($options, '&') . "\">"; $out .= $data[$num][0]['name'] . "</a>"; return $out; } } break; case "glpi_tickets.id": if ($searchopt[$ID]["datatype"] == 'count') { if ($data[$num][0]['name'] > 0 && Session::haveRight("ticket", Ticket::READALL)) { if ($itemtype == 'User') { // Requester if ($ID == 60) { $options['criteria'][0]['field'] = 4; $options['criteria'][0]['searchtype'] = 'equals'; $options['criteria'][0]['value'] = $data['id']; $options['criteria'][0]['link'] = 'AND'; } // Writer if ($ID == 61) { $options['criteria'][0]['field'] = 22; $options['criteria'][0]['searchtype'] = 'equals'; $options['criteria'][0]['value'] = $data['id']; $options['criteria'][0]['link'] = 'AND'; } // Assign if ($ID == 64) { $options['criteria'][0]['field'] = 5; $options['criteria'][0]['searchtype'] = 'equals'; $options['criteria'][0]['value'] = $data['id']; $options['criteria'][0]['link'] = 'AND'; } } else { if ($itemtype == 'ITILCategory') { $options['criteria'][0]['field'] = 7; $options['criteria'][0]['searchtype'] = 'equals'; $options['criteria'][0]['value'] = $data['id']; $options['criteria'][0]['link'] = 'AND'; } else { $options['criteria'][0]['field'] = 12; $options['criteria'][0]['searchtype'] = 'equals'; $options['criteria'][0]['value'] = 'all'; $options['criteria'][0]['link'] = 'AND'; $options['metacriteria'][0]['itemtype'] = $itemtype; $options['metacriteria'][0]['field'] = self::getOptionNumber($itemtype, 'name'); $options['metacriteria'][0]['searchtype'] = 'equals'; $options['metacriteria'][0]['value'] = $data['id']; $options['metacriteria'][0]['link'] = 'AND'; } } $options['reset'] = 'reset'; $out = "<a id='ticket{$itemtype}" . $data['id'] . "' "; $out .= "href=\"" . $CFG_GLPI["root_doc"] . "/front/ticket.php?" . Toolbox::append_params($options, '&') . "\">"; $out .= $data[$num][0]['name'] . "</a>"; return $out; } } break; case "glpi_tickets.due_date": case "glpi_problems.due_date": case "glpi_changes.due_date": // Due date + progress if ($ID == 151) { $out = Html::convDate($data[$num][0]['name']); // No due date in waiting status if ($data[$num][0]['status'] == CommonITILObject::WAITING) { return ''; } if (empty($data[$num][0]['name'])) { return ''; } if ($data[$num][0]['status'] == Ticket::SOLVED || $data[$num][0]['status'] == Ticket::CLOSED) { return $out; } $itemtype = getItemTypeForTable($table); $item = new $itemtype(); $item->getFromDB($data['id']); $percentage = 0; $totaltime = 0; $currenttime = 0; if ($item->isField('slas_id') && $item->fields['slas_id'] != 0) { // Have SLA $sla = new SLA(); $sla->getFromDB($item->fields['slas_id']); $currenttime = $sla->getActiveTimeBetween($item->fields['date'], date('Y-m-d H:i:s')); $totaltime = $sla->getActiveTimeBetween($item->fields['date'], $data[$num][0]['name']); } else { $calendars_id = Entity::getUsedConfig('calendars_id', $item->fields['entities_id']); if ($calendars_id != 0) { // Ticket entity have calendar $calendar = new Calendar(); $calendar->getFromDB($calendars_id); $currenttime = $calendar->getActiveTimeBetween($item->fields['date'], date('Y-m-d H:i:s')); $totaltime = $calendar->getActiveTimeBetween($item->fields['date'], $data[$num][0]['name']); } else { // No calendar $currenttime = strtotime(date('Y-m-d H:i:s')) - strtotime($item->fields['date']); $totaltime = strtotime($data[$num][0]['name']) - strtotime($item->fields['date']); } } if ($totaltime != 0) { $percentage = round(100 * $currenttime / $totaltime); } else { // Total time is null : no active time $percentage = 100; } if ($percentage > 100) { $percentage = 100; } $percentage_text = $percentage; if ($_SESSION['glpiduedatewarning_unit'] == '%') { $less_warn_limit = $_SESSION['glpiduedatewarning_less']; $less_warn = 100 - $percentage; } else { if ($_SESSION['glpiduedatewarning_unit'] == 'hour') { $less_warn_limit = $_SESSION['glpiduedatewarning_less'] * HOUR_TIMESTAMP; $less_warn = $totaltime - $currenttime; } else { if ($_SESSION['glpiduedatewarning_unit'] == 'day') { $less_warn_limit = $_SESSION['glpiduedatewarning_less'] * DAY_TIMESTAMP; $less_warn = $totaltime - $currenttime; } } } if ($_SESSION['glpiduedatecritical_unit'] == '%') { $less_crit_limit = $_SESSION['glpiduedatecritical_less']; $less_crit = 100 - $percentage; } else { if ($_SESSION['glpiduedatecritical_unit'] == 'hour') { $less_crit_limit = $_SESSION['glpiduedatecritical_less'] * HOUR_TIMESTAMP; $less_crit = $totaltime - $currenttime; } else { if ($_SESSION['glpiduedatecritical_unit'] == 'day') { $less_crit_limit = $_SESSION['glpiduedatecritical_less'] * DAY_TIMESTAMP; $less_crit = $totaltime - $currenttime; } } } $color = $_SESSION['glpiduedateok_color']; if ($less_crit < $less_crit_limit) { $color = $_SESSION['glpiduedatecritical_color']; } else { if ($less_warn < $less_warn_limit) { $color = $_SESSION['glpiduedatewarning_color']; } } //Calculate bar progress $out .= "<div class='center' style='background-color: #ffffff; width: 100%;\n border: 1px solid #9BA563; position: relative;' >"; $out .= "<div style='position:absolute;'> " . $percentage_text . "%</div>"; $out .= "<div class='center' style='background-color: " . $color . ";\n width: " . $percentage . "%; height: 12px' ></div>"; $out .= "</div>"; return $out; } break; case "glpi_softwarelicenses.number": if ($data[$num][0]['min'] == -1) { return __('Unlimited'); } if (empty($data[$num][0]['name'])) { return 0; } return $data[$num][0]['name']; case "glpi_auth_tables.name": return Auth::getMethodName($data[$num][0]['name'], $data[$num][0]['auths_id'], 1, $data[$num][0]['ldapname'] . $data[$num][0]['mailname']); case "glpi_reservationitems.comment": if (empty($data[$num][0]['name'])) { return "<a title=\"" . __s('Modify the comment') . "\"\n href='" . $CFG_GLPI["root_doc"] . "/front/reservationitem.form.php?id=" . $data["refID"] . "' >" . __('None') . "</a>"; } return "<a title=\"" . __s('Modify the comment') . "\"\n href='" . $CFG_GLPI["root_doc"] . "/front/reservationitem.form.php?id=" . $data['refID'] . "' >" . Html::resume_text($data[$num][0]['name']) . "</a>"; case 'glpi_crontasks.description': $tmp = new CronTask(); return $tmp->getDescription($data[$num][0]['name']); case 'glpi_changes.status': $status = Change::getStatus($data[$num][0]['name']); return "<img src=\"" . Change::getStatusIconURL($data[$num][0]['name']) . "\"\n alt=\"{$status}\" title=\"{$status}\"> {$status}"; case 'glpi_problems.status': $status = Problem::getStatus($data[$num][0]['name']); return "<img src=\"" . Problem::getStatusIconURL($data[$num][0]['name']) . "\"\n alt=\"{$status}\" title=\"{$status}\"> {$status}"; case 'glpi_tickets.status': $status = Ticket::getStatus($data[$num][0]['name']); return "<img src=\"" . Ticket::getStatusIconURL($data[$num][0]['name']) . "\"\n alt=\"{$status}\" title=\"{$status}\"> {$status}"; case 'glpi_projectstates.name': $out = ''; $query = "SELECT `color`\n FROM `glpi_projectstates`\n WHERE `name` = '" . $data[$num][0]['name'] . "'"; foreach ($DB->request($query) as $color) { $color = $color['color']; $out = "<div style=\"background-color:" . $color . ";\">"; $name = $data[$num][0]['name']; if (isset($data[$num][0]['trans'])) { $name = $data[$num][0]['trans']; } if ($itemtype == 'ProjectState') { $out .= "<a href='" . $CFG_GLPI["root_doc"] . "/front/projectstate.form.php?id=" . $data[$num][0]["id"] . "'>" . $name . "</a></div>"; } else { $out .= $name . "</div>"; } } return $out; case 'glpi_items_tickets.items_id': case 'glpi_items_problems.items_id': if (!empty($data[$num])) { $items = array(); foreach ($data[$num] as $key => $val) { if (is_numeric($key)) { if (!empty($val['itemtype']) && ($item = getItemForItemtype($val['itemtype']))) { if ($item->getFromDB($val['name'])) { $items[] = $item->getLink(array('comments' => true)); } } } } if (!empty($items)) { return implode("<br>", $items); } } return ' '; case 'glpi_items_tickets.itemtype': case 'glpi_items_problems.itemtype': if (!empty($data[$num])) { $itemtypes = array(); foreach ($data[$num] as $key => $val) { if (is_numeric($key)) { if (!empty($val['name'])) { if (substr($val['name'], 0, 6) == 'Plugin') { $plug = new $val['name'](); $name = $plug->getTypeName(); $itemtypes[] = __($name); } else { $itemtypes[] = __($val['name']); } } } } if (!empty($itemtypes)) { return implode("<br>", $itemtypes); } } return ' '; case 'glpi_tickets.name': case 'glpi_problems.name': case 'glpi_changes.name': if (isset($data[$num][0]['content']) && isset($data[$num][0]['id']) && isset($data[$num][0]['status'])) { $link = Toolbox::getItemTypeFormURL($itemtype); $out = "<a id='{$itemtype}" . $data[$num][0]['id'] . "' href=\"" . $link; $out .= strstr($link, '?') ? '&' : '?'; $out .= 'id=' . $data[$num][0]['id']; // Force solution tab if solved if ($item = getItemForItemtype($itemtype)) { if (in_array($data[$num][0]['status'], $item->getSolvedStatusArray())) { $out .= "&forcetab={$itemtype}\$2"; } } $out .= "\">"; $name = $data[$num][0]['name']; if ($_SESSION["glpiis_ids_visible"] || empty($data[$num][0]['name'])) { $name = sprintf(__('%1$s (%2$s)'), $name, $data[$num][0]['id']); } $out .= $name . "</a>"; $hdecode = Html::entity_decode_deep($data[$num][0]['content']); $content = Toolbox::unclean_cross_side_scripting_deep($hdecode); $out = sprintf(__('%1$s %2$s'), $out, Html::showToolTip(nl2br(Html::Clean($content)), array('applyto' => $itemtype . $data[$num][0]['id'], 'display' => false))); return $out; } case 'glpi_ticketvalidations.status': $out = ''; for ($k = 0; $k < $data[$num]['count']; $k++) { if ($data[$num][$k]['name']) { $status = TicketValidation::getStatus($data[$num][$k]['name']); $bgcolor = TicketValidation::getStatusColor($data[$num][$k]['name']); $out .= (empty($out) ? '' : self::LBBR) . "<div style=\"background-color:" . $bgcolor . ";\">" . $status . '</div>'; } } return $out; case 'glpi_ticketsatisfactions.satisfaction': if (self::$output_type == self::HTML_OUTPUT) { return TicketSatisfaction::displaySatisfaction($data[$num][0]['name']); } break; case 'glpi_projects._virtual_planned_duration': return Html::timestampToString(ProjectTask::getTotalPlannedDurationForProject($data["id"]), false); case 'glpi_projects._virtual_effective_duration': return Html::timestampToString(ProjectTask::getTotalEffectiveDurationForProject($data["id"]), false); case 'glpi_cartridgeitems._virtual': return Cartridge::getCount($data["id"], $data[$num][0]['alarm_threshold'], self::$output_type != self::HTML_OUTPUT); case 'glpi_printers._virtual': return Cartridge::getCountForPrinter($data["id"], self::$output_type != self::HTML_OUTPUT); case 'glpi_consumableitems._virtual': return Consumable::getCount($data["id"], $data[$num][0]['alarm_threshold'], self::$output_type != self::HTML_OUTPUT); case 'glpi_links._virtual': $out = ''; $link = new Link(); if (($item = getItemForItemtype($itemtype)) && $item->getFromDB($data['id']) && $link->getfromDB($data[$num][0]['id']) && $item->fields['entities_id'] == $link->fields['entities_id']) { if (count($data[$num])) { $count_display = 0; foreach ($data[$num] as $val) { if (is_array($val)) { $links = Link::getAllLinksFor($item, $val); foreach ($links as $link) { if ($count_display) { $out .= self::LBBR; } $out .= $link; $count_display++; } } } } } return $out; case 'glpi_reservationitems._virtual': if ($data[$num][0]['is_active']) { return "<a href='reservation.php?reservationitems_id=" . $data["refID"] . "' title=\"" . __s('See planning') . "\">" . "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/reservation-3.png\" alt='' title=''></a>"; } else { return " "; } } } //// Default case // Link with plugin tables : need to know left join structure if (isset($table)) { if (preg_match("/^glpi_plugin_([a-z0-9]+)/", $table . '.' . $field, $matches)) { if (count($matches) == 2) { $plug = $matches[1]; $function = 'plugin_' . $plug . '_giveItem'; if (function_exists($function)) { $out = $function($itemtype, $ID, $data, $num); if (!empty($out)) { return $out; } } } } } $unit = ''; if (isset($searchopt[$ID]['unit'])) { $unit = $searchopt[$ID]['unit']; } // Preformat items if (isset($searchopt[$ID]["datatype"])) { switch ($searchopt[$ID]["datatype"]) { case "itemlink": $linkitemtype = getItemTypeForTable($searchopt[$ID]["table"]); $out = ""; $count_display = 0; $separate = self::LBBR; if (isset($searchopt[$ID]['splititems']) && $searchopt[$ID]['splititems']) { $separate = self::LBHR; } for ($k = 0; $k < $data[$num]['count']; $k++) { if (isset($data[$num][$k]['id'])) { if ($count_display) { $out .= $separate; } $count_display++; $page = $linkitemtype::getFormUrl(); $page .= strpos($page, '?') ? '&id' : '?id'; $name = Dropdown::getValueWithUnit($data[$num][$k]['name'], $unit); if ($_SESSION["glpiis_ids_visible"] || empty($data[$num][$k]['name'])) { $name = sprintf(__('%1$s (%2$s)'), $name, $data[$num][$k]['id']); } $out .= "<a id='" . $linkitemtype . "_" . $data['id'] . "_" . $data[$num][$k]['id'] . "' href='{$page}=" . $data[$num][$k]['id'] . "'>" . $name . "</a>"; } } return $out; case "text": $separate = self::LBBR; if (isset($searchopt[$ID]['splititems']) && $searchopt[$ID]['splititems']) { $separate = self::LBHR; } $out = ''; $count_display = 0; for ($k = 0; $k < $data[$num]['count']; $k++) { if (strlen(trim($data[$num][$k]['name'])) > 0) { if ($count_display) { $out .= $separate; } $count_display++; $text = ""; if (isset($searchopt[$ID]['htmltext']) && $searchopt[$ID]['htmltext']) { $text = Html::clean(Toolbox::unclean_cross_side_scripting_deep(nl2br($data[$num][$k]['name']))); } else { $text = nl2br($data[$num][$k]['name']); } if (self::$output_type == self::HTML_OUTPUT && Toolbox::strlen($text) > $CFG_GLPI['cut']) { $rand = mt_rand(); $out .= sprintf(__('%1$s %2$s'), "<span id='text{$rand}'>" . Html::resume_text($text, $CFG_GLPI['cut']) . '</span>', Html::showToolTip($text, array('applyto' => "text{$rand}", 'display' => false))); } else { $out .= $text; } } } return $out; case "date": case "date_delay": $out = ''; for ($k = 0; $k < $data[$num]['count']; $k++) { if (is_null($data[$num][$k]['name']) && isset($searchopt[$ID]['emptylabel']) && $searchopt[$ID]['emptylabel']) { $out .= (empty($out) ? '' : self::LBBR) . $searchopt[$ID]['emptylabel']; } else { $out .= (empty($out) ? '' : self::LBBR) . Html::convDate($data[$num][$k]['name']); } } return $out; case "datetime": $out = ''; for ($k = 0; $k < $data[$num]['count']; $k++) { if (is_null($data[$num][$k]['name']) && isset($searchopt[$ID]['emptylabel']) && $searchopt[$ID]['emptylabel']) { $out .= (empty($out) ? '' : self::LBBR) . $searchopt[$ID]['emptylabel']; } else { $out .= (empty($out) ? '' : self::LBBR) . Html::convDateTime($data[$num][$k]['name']); } } return $out; case "timestamp": $withseconds = false; if (isset($searchopt[$ID]['withseconds'])) { $withseconds = $searchopt[$ID]['withseconds']; } $withdays = true; if (isset($searchopt[$ID]['withdays'])) { $withdays = $searchopt[$ID]['withdays']; } $out = ''; for ($k = 0; $k < $data[$num]['count']; $k++) { $out .= (empty($out) ? '' : '<br>') . Html::timestampToString($data[$num][$k]['name'], $withseconds, $withdays); } return $out; case "email": $out = ''; $count_display = 0; for ($k = 0; $k < $data[$num]['count']; $k++) { if ($count_display) { $out .= self::LBBR; } $count_display++; if (!empty($data[$num][$k]['name'])) { $out .= empty($out) ? '' : self::LBBR; $out .= "<a href='mailto:" . $data[$num][$k]['name'] . "'>" . $data[$num][$k]['name']; $out .= "</a>"; } } return empty($out) ? " " : $out; case "weblink": $orig_link = trim($data[$num][0]['name']); if (!empty($orig_link)) { // strip begin of link $link = preg_replace('/https?:\\/\\/(www[^\\.]*\\.)?/', '', $orig_link); $link = preg_replace('/\\/$/', '', $link); if (Toolbox::strlen($link) > $CFG_GLPI["url_maxlength"]) { $link = Toolbox::substr($link, 0, $CFG_GLPI["url_maxlength"]) . "..."; } return "<a href=\"" . formatOutputWebLink($orig_link) . "\" target='_blank'>{$link}</a>"; } return " "; case "count": case "number": $out = ""; $count_display = 0; for ($k = 0; $k < $data[$num]['count']; $k++) { if (strlen(trim($data[$num][$k]['name'])) > 0) { if ($count_display) { $out .= self::LBBR; } $count_display++; if (isset($searchopt[$ID]['toadd']) && isset($searchopt[$ID]['toadd'][$data[$num][$k]['name']])) { $out .= $searchopt[$ID]['toadd'][$data[$num][$k]['name']]; } else { $number = str_replace(' ', ' ', Html::formatNumber($data[$num][$k]['name'], false, 0)); $out .= Dropdown::getValueWithUnit($number, $unit); } } } return $out; case "decimal": $out = ""; $count_display = 0; for ($k = 0; $k < $data[$num]['count']; $k++) { if (strlen(trim($data[$num][$k]['name'])) > 0) { if ($count_display) { $out .= self::LBBR; } $count_display++; if (isset($searchopt[$ID]['toadd']) && isset($searchopt[$ID]['toadd'][$data[$num][$k]['name']])) { $out .= $searchopt[$ID]['toadd'][$data[$num][$k]['name']]; } else { $number = str_replace(' ', ' ', Html::formatNumber($data[$num][$k]['name'])); $out .= Dropdown::getValueWithUnit($number, $unit); } } } return $out; case "bool": $out = ""; $count_display = 0; for ($k = 0; $k < $data[$num]['count']; $k++) { if (strlen(trim($data[$num][$k]['name'])) > 0) { if ($count_display) { $out .= self::LBBR; } $count_display++; $out .= Dropdown::getValueWithUnit(Dropdown::getYesNo($data[$num][$k]['name']), $unit); } } return $out; case "itemtypename": if ($obj = getItemForItemtype($data[$num][0]['name'])) { return $obj->getTypeName(); } return ""; case "language": if (isset($CFG_GLPI['languages'][$data[$num][0]['name']])) { return $CFG_GLPI['languages'][$data[$num][0]['name']][0]; } return __('Default value'); } } // Manage items with need group by / group_concat $out = ""; $count_display = 0; $separate = self::LBBR; if (isset($searchopt[$ID]['splititems']) && $searchopt[$ID]['splititems']) { $separate = self::LBHR; } for ($k = 0; $k < $data[$num]['count']; $k++) { if (strlen(trim($data[$num][$k]['name'])) > 0) { if ($count_display) { $out .= $separate; } $count_display++; // Get specific display if available $itemtype = getItemTypeForTable($table); if ($item = getItemForItemtype($itemtype)) { $tmpdata = $data[$num][$k]; // Copy name to real field $tmpdata[$field] = $data[$num][$k]['name']; $specific = $item->getSpecificValueToDisplay($field, $tmpdata, array('html' => true, 'searchopt' => $searchopt[$ID])); } if (!empty($specific)) { $out .= $specific; } else { if (isset($searchopt[$ID]['toadd']) && isset($searchopt[$ID]['toadd'][$data[$num][$k]['name']])) { $out .= $searchopt[$ID]['toadd'][$data[$num][$k]['name']]; } else { // Empty is 0 or empty if (empty($split[0]) && isset($searchopt[$ID]['emptylabel'])) { $out .= $searchopt[$ID]['emptylabel']; } else { // Trans field exists if (isset($data[$num][$k]['trans']) && !empty($data[$num][$k]['trans'])) { $out .= Dropdown::getValueWithUnit($data[$num][$k]['trans'], $unit); } else { $out .= Dropdown::getValueWithUnit($data[$num][$k]['name'], $unit); } } } } } } return $out; // Trans in group concat if (count($split) == 3 && !empty($split[1])) { return Dropdown::getValueWithUnit($split[1], $unit); } return Dropdown::getValueWithUnit($split[0], $unit); }
function showStats() { if (!$this->canUpdate() || !isset($this->fields['id'])) { return false; } echo "<div class='center'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr><th colspan='2'>" . _n('Date', 'Dates', Session::getPluralNumber()) . "</th></tr>"; echo "<tr class='tab_bg_2'><td>" . __('Opening date') . "</td>"; echo "<td>" . Html::convDateTime($this->fields['date']) . "</td></tr>"; echo "<tr class='tab_bg_2'><td>" . __('Due date') . "</td>"; echo "<td>" . Html::convDateTime($this->fields['due_date']) . "</td></tr>"; if (in_array($this->fields['status'], array_merge($this->getSolvedStatusArray(), $this->getClosedStatusArray()))) { echo "<tr class='tab_bg_2'><td>" . __('Resolution date') . "</td>"; echo "<td>" . Html::convDateTime($this->fields['solvedate']) . "</td></tr>"; } if (in_array($this->fields['status'], $this->getClosedStatusArray())) { echo "<tr class='tab_bg_2'><td>" . __('Closing date') . "</td>"; echo "<td>" . Html::convDateTime($this->fields['closedate']) . "</td></tr>"; } echo "<tr><th colspan='2'>" . _n('Time', 'Times', Session::getPluralNumber()) . "</th></tr>"; if (isset($this->fields['takeintoaccount_delay_stat'])) { echo "<tr class='tab_bg_2'><td>" . __('Take into account') . "</td><td>"; if ($this->fields['takeintoaccount_delay_stat'] > 0) { echo Html::timestampToString($this->fields['takeintoaccount_delay_stat'], 0); } else { echo ' '; } echo "</td></tr>"; } if (in_array($this->fields['status'], array_merge($this->getSolvedStatusArray(), $this->getClosedStatusArray()))) { echo "<tr class='tab_bg_2'><td>" . __('Resolution') . "</td><td>"; if ($this->fields['solve_delay_stat'] > 0) { echo Html::timestampToString($this->fields['solve_delay_stat'], 0); } else { echo ' '; } echo "</td></tr>"; } if (in_array($this->fields['status'], $this->getClosedStatusArray())) { echo "<tr class='tab_bg_2'><td>" . __('Closure') . "</td><td>"; if ($this->fields['close_delay_stat'] > 0) { echo Html::timestampToString($this->fields['close_delay_stat']); } else { echo ' '; } echo "</td></tr>"; } echo "<tr class='tab_bg_2'><td>" . __('Pending') . "</td><td>"; if ($this->fields['waiting_duration'] > 0) { echo Html::timestampToString($this->fields['waiting_duration'], 0); } else { echo ' '; } echo "</td></tr>"; echo "</table>"; echo "</div>"; }
/** * Show tasks of a project * * @param $item Project or ProjectTask object * * @return nothing **/ static function showFor($item) { global $DB, $CFG_GLPI; $ID = $item->getField('id'); if (!$item->canViewItem()) { return false; } $columns = array('name' => self::getTypeName(Session::getPluralNumber()), 'tname' => __('Type'), 'sname' => __('Status'), 'percent_done' => __('Percent done'), 'plan_start_date' => __('Planned start date'), 'plan_end_date' => __('Planned end date'), 'planned_duration' => __('Planned duration'), '_effect_duration' => __('Effective duration'), 'fname' => __('Father')); if (isset($_GET["order"]) && $_GET["order"] == "DESC") { $order = "DESC"; } else { $order = "ASC"; } if (!isset($_GET["sort"]) || empty($_GET["sort"])) { $_GET["sort"] = "plan_start_date"; } if (isset($_GET["sort"]) && !empty($_GET["sort"]) && isset($columns[$_GET["sort"]])) { $sort = "`" . $_GET["sort"] . "`"; } else { $sort = "`plan_start_date` {$order}, `name`"; } $canedit = false; if ($item->getType() == 'Project') { $canedit = $item->canEdit($ID); } switch ($item->getType()) { case 'Project': $where = "WHERE `glpi_projecttasks`.`projects_id` = '{$ID}'"; break; case 'ProjectTask': $where = "WHERE `glpi_projecttasks`.`projecttasks_id` = '{$ID}'"; break; default: // Not available type return; } echo "<div class='spaced'>"; if ($canedit) { echo "<div class='center firstbloc'>"; echo "<a class='vsubmit' href='projecttask.form.php?projects_id={$ID}'>" . _x('button', 'Add a task') . "</a>"; echo "</div>"; } if ($item->getType() == 'ProjectTask' && $item->can($ID, UPDATE)) { $rand = mt_rand(); echo "<div class='firstbloc'>"; echo "<form name='projecttask_form{$rand}' id='projecttask_form{$rand}' method='post'\n action='" . Toolbox::getItemTypeFormURL('ProjectTask') . "'>"; $projet = $item->fields['projects_id']; echo "<a href='" . Toolbox::getItemTypeFormURL('ProjectTask') . "?projecttasks_id={$ID}&projects_id={$projet}'>"; _e('Create a sub task from this task of project'); echo "</a>"; Html::closeForm(); echo "</div>"; } $addselect = ''; $addjoin = ''; if (Session::haveTranslations('ProjectTaskType', 'name')) { $addselect .= ", `namet2`.`value` AS transname2"; $addjoin .= " LEFT JOIN `glpi_dropdowntranslations` AS namet2\n ON (`namet2`.`itemtype` = 'ProjectTaskType'\n AND `namet2`.`items_id` = `glpi_projecttasks`.`projecttasktypes_id`\n AND `namet2`.`language` = '" . $_SESSION['glpilanguage'] . "'\n AND `namet2`.`field` = 'name')"; } if (Session::haveTranslations('ProjectState', 'name')) { $addselect .= ", `namet3`.`value` AS transname3"; $addjoin .= "LEFT JOIN `glpi_dropdowntranslations` AS namet3\n ON (`namet3`.`itemtype` = 'ProjectState'\n AND `namet3`.`language` = '" . $_SESSION['glpilanguage'] . "'\n AND `namet3`.`field` = 'name')"; $where .= " AND `namet3`.`items_id` = `glpi_projectstates`.`id` "; } $query = "SELECT `glpi_projecttasks`.*,\n `glpi_projecttasktypes`.`name` AS tname,\n `glpi_projectstates`.`name` AS sname,\n `glpi_projectstates`.`color`,\n `father`.`name` AS fname,\n `father`.`id` AS fID\n {$addselect}\n FROM `glpi_projecttasks`\n {$addjoin}\n LEFT JOIN `glpi_projecttasktypes`\n ON (`glpi_projecttasktypes`.`id` = `glpi_projecttasks`.`projecttasktypes_id`)\n LEFT JOIN `glpi_projectstates`\n ON (`glpi_projectstates`.`id` = `glpi_projecttasks`.`projectstates_id`)\n LEFT JOIN `glpi_projecttasks` as father\n ON (`father`.`id` = `glpi_projecttasks`.`projecttasks_id`)\n {$where}\n ORDER BY {$sort} {$order}"; Session::initNavigateListItems('ProjectTask', sprintf(__('%1$s = %2$s'), $item::getTypeName(1), $item->getName())); if ($result = $DB->query($query)) { if ($DB->numrows($result)) { echo "<table class='tab_cadre_fixehov'>"; $sort_img = "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/" . ($order == "DESC" ? "puce-down.png" : "puce-up.png") . "\" alt='' title=''>"; $header = '<tr>'; foreach ($columns as $key => $val) { // Non order column if ($key[0] == '_') { $header .= "<th>{$val}</th>"; } else { $header .= "<th>" . ($sort == "`{$key}`" ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort={$key}&order=" . ($order == "ASC" ? "DESC" : "ASC") . "&start=0\");'>{$val}</a></th>"; } } $header .= "</tr>\n"; echo $header; while ($data = $DB->fetch_assoc($result)) { Session::addToNavigateListItems('ProjectTask', $data['id']); $rand = mt_rand(); echo "<tr class='tab_bg_2'>"; echo "<td>"; $link = "<a id='ProjectTask" . $data["id"] . $rand . "' href='projecttask.form.php?id=" . $data['id'] . "'>" . $data['name'] . (empty($data['name']) ? "(" . $data['id'] . ")" : "") . "</a>"; echo sprintf(__('%1$s %2$s'), $link, Html::showToolTip($data['content'], array('display' => false, 'applyto' => "ProjectTask" . $data["id"] . $rand))); echo "</td>"; $name = !empty($data['transname2']) ? $data['transname2'] : $data['tname']; echo "<td>" . $name . "</td>"; echo "<td"; $statename = !empty($data['transname3']) ? $data['transname3'] : $data['sname']; echo " style=\"background-color:" . $data['color'] . "\""; echo ">" . $statename . "</td>"; echo "<td>"; echo Dropdown::getValueWithUnit($data["percent_done"], "%"); echo "</td>"; echo "<td>" . Html::convDateTime($data['plan_start_date']) . "</td>"; echo "<td>" . Html::convDateTime($data['plan_end_date']) . "</td>"; echo "<td>" . Html::timestampToString($data['planned_duration'], false) . "</td>"; echo "<td>" . Html::timestampToString(self::getTotalEffectiveDuration($data['id']), false) . "</td>"; echo "<td>"; if ($data['projecttasks_id'] > 0) { $father = Dropdown::getDropdownName('glpi_projecttasks', $data['projecttasks_id']); echo "<a id='ProjectTask" . $data["projecttasks_id"] . $rand . "' href='projecttask.form.php?id=" . $data['projecttasks_id'] . "'>" . $father . (empty($father) ? "(" . $data['projecttasks_id'] . ")" : "") . "</a>"; } echo "</td></tr>"; } echo $header; echo "</table>\n"; } else { echo "<table class='tab_cadre_fixe'>"; echo "<tr><th>" . __('No item found') . "</th></tr>"; echo "</table>\n"; } } echo "</div>"; }
/** * @since version 0.90 * * @param $rand **/ function showTimeline($rand) { global $CFG_GLPI, $DB, $autolink_options; //get ticket actors $ticket_users_keys = $this->getTicketActors(); $user = new User(); $group = new Group(); $followup_obj = new TicketFollowup(); $pics_url = $CFG_GLPI['root_doc'] . "/pics/timeline"; $timeline = $this->getTimelineItems(); $autolink_options['strip_protocols'] = false; //display timeline echo "<div class='timeline_history'>"; $tmp = array_values($timeline); $first_item = array_shift($tmp); // show approbation form on top when ticket is solved if ($this->fields["status"] == CommonITILObject::SOLVED) { echo "<div class='approbation_form' id='approbation_form{$rand}'>"; $followup_obj->showApprobationForm($this); echo "</div>"; } // show title for timeline self::showTimelineHeader(); $timeline_index = 0; foreach ($timeline as $item) { $options = array('parent' => $this, 'rand' => $rand); if ($obj = getItemForItemtype($item['type'])) { $obj->fields = $item['item']; } else { $obj = $item; } Plugin::doHook('pre_show_item', array('item' => &$obj, 'options' => &$options)); if (is_array($obj)) { $item_i = $obj['item']; } else { $item_i = $obj->fields; } $date = ""; if (isset($item_i['date'])) { $date = $item_i['date']; } if (isset($item_i['date_mod'])) { $date = $item_i['date_mod']; } // check if curent item user is assignee or requester $user_position = 'left'; if (isset($ticket_users_keys[$item_i['users_id']]) && $ticket_users_keys[$item_i['users_id']] == CommonItilActor::ASSIGN || $item['type'] == 'Assign') { $user_position = 'right'; } //display solution in middle if ($timeline_index == 0 && $item['type'] == "Solution" && $this->fields["status"] == CommonITILObject::SOLVED) { $user_position .= ' middle'; } echo "<div class='h_item {$user_position}'>"; echo "<div class='h_info'>"; echo "<div class='h_date'>" . Html::convDateTime($date) . "</div>"; if ($item_i['users_id'] !== false) { echo "<div class='h_user'>"; if (isset($item_i['users_id']) && $item_i['users_id'] != 0) { $user->getFromDB($item_i['users_id']); echo "<div class='tooltip_picture_border'>"; echo "<img class='user_picture' alt=\"" . __s('Picture') . "\" src='" . User::getThumbnailURLForPicture($user->fields['picture']) . "'>"; echo "</div>"; echo "<span class='h_user_name'>"; $userdata = getUserName($item_i['users_id'], 2); echo $user->getLink() . " "; echo Html::showToolTip($userdata["comment"], array('link' => $userdata['link'])); echo "</span>"; } else { _e("Requester"); } echo "</div>"; // h_user } echo "</div>"; //h_date echo "<div class='h_content " . $item['type'] . (isset($item_i['status']) ? " " . $item_i['status'] : "") . "'" . "id='viewitem" . $item['type'] . $item_i['id'] . $rand . "'>"; if (isset($item_i['can_edit']) && $item_i['can_edit']) { echo "<div class='edit_item_content'></div>"; echo "<span class='cancel_edit_item_content'></span>"; } echo "<div class='displayed_content'>"; if (!in_array($item['type'], array('Document_Item', 'Assign')) && $item_i['can_edit']) { echo "<span class='edit_item' "; echo "onclick='javascript:viewEditSubitem" . $this->fields['id'] . "{$rand}(event, \"" . $item['type'] . "\", " . $item_i['id'] . ", this, \"viewitem" . $item['type'] . $item_i['id'] . $rand . "\")'"; echo "></span>"; } if (isset($item_i['requesttypes_id']) && file_exists("{$pics_url}/" . $item_i['requesttypes_id'] . ".png")) { echo "<img src='{$pics_url}/" . $item_i['requesttypes_id'] . ".png' title='' class='h_requesttype' />"; } if (isset($item_i['content'])) { $content = $item_i['content']; $content = autolink($content, 40); //$content = nl2br($content); $long_text = ""; if (substr_count($content, "<br") > 30 || strlen($content) > 2000) { $long_text = "long_text"; } echo "<div class='item_content {$long_text}'>"; echo "<p>"; if (isset($item_i['state'])) { $onClick = "onclick='change_task_state(" . $item_i['id'] . ", this)'"; if (!$item_i['can_edit']) { $onClick = "style='cursor: not-allowed;'"; } echo "<span class='state state_" . $item_i['state'] . "'\n {$onClick}\n title='" . Planning::getState($item_i['state']) . "'>"; echo "</span>"; } echo $content; echo "</p>"; if (!empty($long_text)) { echo "<p class='read_more'>"; echo "<a class='read_more_button'>.....</a>"; echo "</p>"; } echo "</div>"; } echo "<div class='b_right'>"; if (isset($item_i['solutiontypes_id']) && !empty($item_i['solutiontypes_id'])) { echo Dropdown::getDropdownName("glpi_solutiontypes", $item_i['solutiontypes_id']) . "<br>"; } if (isset($item_i['taskcategories_id']) && !empty($item_i['taskcategories_id'])) { echo Dropdown::getDropdownName("glpi_taskcategories", $item_i['taskcategories_id']) . "<br>"; } if (isset($item_i['requesttypes_id']) && !empty($item_i['requesttypes_id'])) { echo Dropdown::getDropdownName("glpi_requesttypes", $item_i['requesttypes_id']) . "<br>"; } if (isset($item_i['actiontime']) && !empty($item_i['actiontime'])) { echo "<span class='actiontime'>"; echo Html::timestampToString($item_i['actiontime'], false); echo "</span>"; } if (isset($item_i['begin'])) { echo "<span class='planification'>"; echo Html::convDateTime($item_i["begin"]); echo " ⇒ "; echo Html::convDateTime($item_i["end"]); echo "</span>"; } if (isset($item_i['users_id_tech']) && $item_i['users_id_tech'] > 0) { echo "<div class='users_id_tech' id='users_id_tech_" . $item_i['users_id_tech'] . "'>"; $user->getFromDB($item_i['users_id_tech']); echo Html::image($CFG_GLPI['root_doc'] . "/pics/user.png") . " "; $userdata = getUserName($item_i['users_id_tech'], 2); echo $user->getLink() . " "; echo Html::showToolTip($userdata["comment"], array('link' => $userdata['link'])); echo "</div>"; } if (isset($item_i['groups_id_tech']) && $item_i['groups_id_tech'] > 0) { echo "<div class='groups_id_tech'>"; $group->getFromDB($item_i['groups_id_tech']); echo Html::image($CFG_GLPI['root_doc'] . "/pics/group.png") . " "; echo $group->getLink() . " "; echo Html::showToolTip($group->getComments(), array('link' => $group->getLinkURL())); echo "</div>"; } // show "is_private" icon if (isset($item_i['is_private']) && $item_i['is_private']) { echo "<div class='private'>" . __('Private') . "</div>"; } echo "</div>"; // b_right if ($item['type'] == 'Document_Item') { $filename = $item_i['filename']; $ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION)); echo "<img src='"; if (empty($filename)) { $filename = $item_i['name']; } if (file_exists(GLPI_ROOT . "/pics/icones/{$ext}-dist.png")) { echo $CFG_GLPI['root_doc'] . "/pics/icones/{$ext}-dist.png"; } else { echo "{$pics_url}/file.png"; } echo "' title='file' /> "; echo "<a href='" . $CFG_GLPI['root_doc'] . "/front/document.send.php?docid=" . $item_i['id'] . "&tickets_id=" . $this->getID() . "' target='_blank'>{$filename}"; if (in_array($ext, array('jpg', 'jpeg', 'png', 'bmp'))) { echo "<div class='timeline_img_preview'>"; echo "<img src='" . $CFG_GLPI['root_doc'] . "/front/document.send.php?docid=" . $item_i['id'] . "&tickets_id=" . $this->getID() . "'/>"; echo "</div>"; } echo "</a>"; if (!empty($item_i['mime'])) { echo " (" . $item_i['mime'] . ")"; } echo "<a href='" . $CFG_GLPI['root_doc'] . "/front/document.form.php?id=" . $item_i['id'] . "' class='edit_document' title='" . _sx("button", "Update") . "'>"; echo "<img src='{$pics_url}/edit.png' /></a>"; echo "<a href='" . $CFG_GLPI['root_doc'] . "/front/ticket.form.php?delete_document&documents_id=" . $item_i['id'] . "&tickets_id=" . $this->getID() . "' class='delete_document' title='" . _sx("button", "Delete permanently") . "'>"; echo "<img src='{$pics_url}/delete.png' /></a>"; } echo "</div>"; // displayed_content echo "</div>"; //end h_content echo "</div>"; //end h_info $timeline_index++; Plugin::doHook('post_show_item', array('item' => $obj, 'options' => $options)); } // end foreach timeline echo "<div class='break'></div>"; // recall ticket content (not needed in classic and splitted layout) if (!CommonGLPI::isLayoutWithMain()) { echo "<div class='h_item middle'>"; echo "<div class='h_info'>"; echo "<div class='h_date'>" . Html::convDateTime($this->fields['date']) . "</div>"; echo "<div class='h_user'>"; $dem = '0'; foreach ($DB->request("glpi_tickets_users", "`tickets_id` = " . $this->fields['id'] . " AND `type` = 1") as $req) { $dem = $req['users_id']; } if ((!isset($item_i['users_id_recipient']) || $item_i['users_id_recipient'] == 0) && $dem == 0) { _e("Requester"); } else { if (isset($item_i['users_id_recipient']) && $item_i['users_id_recipient'] != 0) { $user->getFromDB($this->fields['users_id_recipient']); } else { if ($dem > 0) { $requester = new User(); if ($requester->getFromDB($dem)) { $user = $requester; } } } echo "<div class='tooltip_picture_border'>"; $picture = ""; if (isset($user->fields['picture'])) { $picture = $user->fields['picture']; } echo "<img class='user_picture' alt=\"" . __s('Picture') . "\" src='" . User::getThumbnailURLForPicture($picture) . "'>"; echo "</div>"; echo $user->getLink(); } echo "</div>"; // h_user echo "</div>"; //h_info echo "<div class='h_content TicketContent'>"; echo "<div class='b_right'>" . __("Ticket recall") . "</div>"; echo "<div class='ticket_title'>"; echo html_entity_decode($this->fields['name']); echo "</div>"; echo "<div class='ticket_description'>"; echo $this->setSimpleTextContent($this->fields['content']); echo "</div>"; echo "</div>"; // h_content TicketContent echo "</div>"; // h_item middle echo "<div class='break'></div>"; } // end timeline echo "</div>"; // h_item $user_position echo "<script type='text/javascript'>read_more();</script>"; }
function showStats() { if (!Session::haveRight('observe_ticket', 1) || !isset($this->fields['id'])) { return false; } echo "<div class='center'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr><th colspan='2'>" . _n('Date', 'Dates', 2) . "</th></tr>"; echo "<tr class='tab_bg_2'><td>" . __('Opening date') . "</td>"; echo "<td>" . Html::convDateTime($this->fields['date']) . "</td></tr>"; echo "<tr class='tab_bg_2'><td>" . __('Due date') . "</td>"; echo "<td>" . Html::convDateTime($this->fields['due_date']) . "</td></tr>"; if ($this->fields['status'] == self::SOLVED || $this->fields['status'] == self::CLOSED) { echo "<tr class='tab_bg_2'><td>" . __('Resolution date') . "</td>"; echo "<td>" . Html::convDateTime($this->fields['solvedate']) . "</td></tr>"; } if ($this->fields['status'] == self::CLOSED) { echo "<tr class='tab_bg_2'><td>" . __('Closing date') . "</td>"; echo "<td>" . Html::convDateTime($this->fields['closedate']) . "</td></tr>"; } echo "<tr><th colspan='2'>" . _n('Time', 'Times', 2) . "</th></tr>"; if (isset($this->fields['takeintoaccount_delay_stat'])) { echo "<tr class='tab_bg_2'><td>" . __('Take into account') . "</td><td>"; if ($this->fields['takeintoaccount_delay_stat'] > 0) { echo Html::timestampToString($this->fields['takeintoaccount_delay_stat'], 0); } else { echo ' '; } echo "</td></tr>"; } if ($this->fields['status'] == self::SOLVED || $this->fields['status'] == self::CLOSED) { echo "<tr class='tab_bg_2'><td>" . __('Resolution') . "</td><td>"; if ($this->fields['solve_delay_stat'] > 0) { echo Html::timestampToString($this->fields['solve_delay_stat'], 0); } else { echo ' '; } echo "</td></tr>"; } if ($this->fields['status'] == self::CLOSED) { echo "<tr class='tab_bg_2'><td>" . __('Closure') . "</td><td>"; if ($this->fields['close_delay_stat'] > 0) { echo Html::timestampToString($this->fields['close_delay_stat']); } else { echo ' '; } echo "</td></tr>"; } echo "<tr class='tab_bg_2'><td>" . __('Pending') . "</td><td>"; if ($this->fields['waiting_duration'] > 0) { echo Html::timestampToString($this->fields['waiting_duration'], 0); } else { echo ' '; } echo "</td></tr>"; echo "</table>"; echo "</div>"; }
/** * @param $sla SLA object **/ function showForSLA(SLA $sla) { global $DB; $ID = $sla->getField('id'); if (!$sla->can($ID, READ)) { return false; } $canedit = $sla->can($ID, UPDATE); $rand = mt_rand(); if ($canedit) { echo "<div class='center first-bloc'>"; echo "<form name='slalevel_form{$rand}' id='slalevel_form{$rand}' method='post' action='"; echo Toolbox::getItemTypeFormURL(__CLASS__) . "'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_1'><th colspan='7'>" . __('Add an escalation level') . "</tr>"; echo "<tr class='tab_bg_2'><td class='center'>" . __('Name') . ""; echo "<input type='hidden' name='slas_id' value='{$ID}'>"; echo "<input type='hidden' name='entities_id' value='" . $sla->getEntityID() . "'>"; echo "<input type='hidden' name='is_recursive' value='" . $sla->isRecursive() . "'>"; echo "<input type='hidden' name='match' value='AND'>"; echo "</td><td><input name='name' value=''>"; echo "</td><td class='center'>" . __('Execution') . "</td><td>"; $resolution_time = $sla->getResolutionTime(); self::dropdownExecutionTime('execution_time', array('max_time' => $resolution_time, 'used' => self::getAlreadyUsedExecutionTime($sla->fields['id']))); echo "</td><td class='center'>" . __('Active') . "</td><td>"; Dropdown::showYesNo("is_active", 1); echo "</td><td class='center'>"; echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>"; echo "</td></tr>"; echo "</table>"; Html::closeForm(); echo "</div>"; } $query = "SELECT *\n FROM `glpi_slalevels`\n WHERE `slas_id` = '{$ID}'\n ORDER BY `execution_time`"; $result = $DB->query($query); $numrows = $DB->numrows($result); 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>"; if ($canedit && $numrows) { echo "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>"; } echo "<th>" . __('Name') . "</th>"; echo "<th>" . __('Execution') . "</th>"; echo "<th>" . __('Active') . "</th>"; echo "</tr>"; Session::initNavigateListItems('SlaLevel', sprintf(__('%1$s = %2$s'), SLA::getTypeName(1), $sla->getName())); while ($data = $DB->fetch_assoc($result)) { Session::addToNavigateListItems('SlaLevel', $data["id"]); echo "<tr class='tab_bg_2'>"; if ($canedit) { echo "<td>" . Html::getMassiveActionCheckBox(__CLASS__, $data["id"]) . "</td>"; } echo "<td>"; if ($canedit) { echo "<a href='" . Toolbox::getItemTypeFormURL('SlaLevel') . "?id=" . $data["id"] . "'>"; } echo $data["name"]; if (empty($data["name"])) { echo "(" . $data['id'] . ")"; } if ($canedit) { echo "</a>"; } echo "</td>"; echo "<td>" . ($data["execution_time"] != 0 ? Html::timestampToString($data["execution_time"], false) : __('Due date')) . "</td>"; echo "<td>" . Dropdown::getYesNo($data["is_active"]) . "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'><td colspan='2'>"; $this->getRuleWithCriteriasAndActions($data['id'], 1, 1); $this->showCriteriasList($data["id"], array('readonly' => true)); echo "</td><td colspan='2'>"; $this->showActionsList($data["id"], array('readonly' => true)); echo "</td></tr>"; } echo "</table>"; if ($canedit && $numrows) { $massiveactionparams['ontop'] = false; Html::showMassiveActions($massiveactionparams); Html::closeForm(); } echo "</div>"; }
/** * @since version 0.90 * * @param $rand **/ function showTimeline($rand) { global $CFG_GLPI, $DB; //get ticket actors $ticket_users_keys = $this->getTicketActors(); $user = new User(); $followup_obj = new TicketFollowup(); $pics_url = $CFG_GLPI['root_doc'] . "/pics/timeline"; $timeline = $this->getTimelineItems(); //include lib for parsing url require GLPI_ROOT . "/lib/urllinker/urllinker.php"; //display timeline echo "<div class='timeline_history'>"; $tmp = array_values($timeline); $first_item = array_shift($tmp); // show approbation form on top when ticket is solved if ($this->fields["status"] == CommonITILObject::SOLVED) { echo "<div class='approbation_form' id='approbation_form{$rand}'>"; $followup_obj->showApprobationForm($this); echo "</div>"; } // show title for timeline self::showTimelineHeader(); $timeline_index = 0; foreach ($timeline as $item) { $item_i = $item['item']; // don't display empty followup (ex : solution approbation) if ($item['type'] == 'TicketFollowup' && empty($item_i['content'])) { continue; } $date = ""; if (isset($item_i['date'])) { $date = $item_i['date']; } if (isset($item_i['date_mod'])) { $date = $item_i['date_mod']; } // check if curent item user is assignee or requester $user_position = 'left'; if (isset($ticket_users_keys[$item_i['users_id']]) && $ticket_users_keys[$item_i['users_id']] == CommonItilActor::ASSIGN || $item['type'] == 'Assign') { $user_position = 'right'; } //display solution in middle if ($timeline_index == 0 && $item['type'] == "Solution" && $this->fields["status"] == CommonITILObject::SOLVED) { $user_position .= ' middle'; } echo "<div class='h_item {$user_position}'>"; echo "<div class='h_info'>"; echo "<div class='h_date'>" . Html::convDateTime($date) . "</div>"; if ($item_i['users_id'] !== false) { echo "<div class='h_user'>"; if (isset($item_i['users_id']) && $item_i['users_id'] != 0) { $user->getFromDB($item_i['users_id']); echo "<div class='tooltip_picture_border'>"; echo "<img class='user_picture' alt=\"" . __s('Picture') . "\" src='" . User::getThumbnailURLForPicture($user->fields['picture']) . "'>"; echo "</div>"; echo $user->getLink(); } else { _e("Requester"); } echo "</div>"; // h_user } echo "</div>"; //h_date echo "<div class='h_content " . $item['type'] . (isset($item_i['status']) ? " " . $item_i['status'] : "") . "'"; if (!in_array($item['type'], array('Document_Item', 'Assign')) && $item_i['can_edit']) { echo " ondblclick='javascript:viewEditSubitem" . $this->fields['id'] . "{$rand}(event, \"" . $item['type'] . "\", " . $item_i['id'] . ", this)'"; } echo ">"; if (isset($item_i['requesttypes_id']) && file_exists("{$pics_url}/" . $item_i['requesttypes_id'] . ".png")) { echo "<img src='{$pics_url}/" . $item_i['requesttypes_id'] . ".png' title='' class='h_requesttype' />"; } if (isset($item_i['content'])) { $content = $item_i['content']; $content = linkUrlsInTrustedHtml($content); //$content = nl2br($content); $long_text = ""; if (substr_count($content, "<br") > 30 || strlen($content) > 2000) { $long_text = "long_text"; } echo "<div class='item_content {$long_text}'>"; echo "<p>{$content}</p>"; if (!empty($long_text)) { echo "<p class='read_more'>"; echo "<a class='read_more_button'>.....</a>"; echo "</p>"; } echo "</div>"; } echo "<div class='b_right'>"; if (isset($item_i['solutiontypes_id']) && !empty($item_i['solutiontypes_id'])) { echo Dropdown::getDropdownName("glpi_solutiontypes", $item_i['solutiontypes_id']) . "<br>"; } if (isset($item_i['taskcategories_id']) && !empty($item_i['taskcategories_id'])) { echo Dropdown::getDropdownName("glpi_taskcategories", $item_i['taskcategories_id']) . "<br>"; } if (isset($item_i['actiontime']) && !empty($item_i['actiontime'])) { echo "<span class='actiontime'>"; echo Html::timestampToString($item_i['actiontime'], false); echo "</span>"; } if (isset($item_i['state'])) { echo "<span class='state state_" . $item_i['state'] . "'>"; echo Planning::getState($item_i['state']); echo "</span>"; } if (isset($item_i['begin'])) { echo "<span class='planification'>"; echo Html::convDateTime($item_i["begin"]); echo " ⇒ "; echo Html::convDateTime($item_i["end"]); echo "</span>"; } if (isset($item_i['users_id_tech'])) { echo "<div class='users_id_tech'>"; $user->getFromDB($item_i['users_id_tech']); echo "<div class='tooltip_picture_border'>"; echo "<img class='user_picture' alt=\"" . __s('Picture') . "\" src='" . User::getThumbnailURLForPicture($user->fields['picture']) . "'>"; echo "</div>"; echo $user->getLink(); echo "</div>"; } // show "is_private" icon if (isset($item_i['is_private']) && $item_i['is_private']) { echo "<div class='private'>" . __('Private') . "</div>"; } echo "</div>"; // b_right if ($item['type'] == 'Document_Item') { $filename = $item_i['filename']; $ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION)); echo "<img src='"; if (empty($filename)) { $filename = $item_i['name']; } if (file_exists(GLPI_ROOT . "/pics/icones/{$ext}-dist.png")) { echo $CFG_GLPI['root_doc'] . "/pics/icones/{$ext}-dist.png"; } else { echo "{$pics_url}/file.png"; } echo "' title='file' /> "; echo "<a href='" . $CFG_GLPI['root_doc'] . "/front/document.send.php?docid=" . $item_i['id'] . "&tickets_id=" . $this->getID() . "' target='_blank'>{$filename}"; if (in_array($ext, array('jpg', 'jpeg', 'png', 'bmp'))) { echo "<div class='timeline_img_preview'>"; echo "<img src='" . $CFG_GLPI['root_doc'] . "/front/document.send.php?docid=" . $item_i['id'] . "&tickets_id=" . $this->getID() . "'/>"; echo "</div>"; } echo "</a>"; if (!empty($item_i['mime'])) { echo " (" . $item_i['mime'] . ")"; } echo "<a href='" . $CFG_GLPI['root_doc'] . "/front/document.form.php?id=" . $item_i['id'] . "' class='edit_document' title='" . _sx("button", "Update") . "'>"; echo "<img src='{$pics_url}/edit.png' /></a>"; echo "<a href='" . $CFG_GLPI['root_doc'] . "/front/ticket.form.php?delete_document&documents_id=" . $item_i['id'] . "&tickets_id=" . $this->getID() . "' class='delete_document' title='" . _sx("button", "Delete permanently") . "'>"; echo "<img src='{$pics_url}/delete.png' /></a>"; } echo "</div>"; //end h_content echo "</div>"; //end h_info $timeline_index++; } // end foreach timeline echo "<div class='break'></div>"; // recall ticket content (not needed in classic and splitted layout) if (!CommonGLPI::isLayoutWithMain()) { echo "<div class='h_item middle'>"; echo "<div class='h_info'>"; echo "<div class='h_date'>" . Html::convDateTime($this->fields['date']) . "</div>"; echo "<div class='h_user'>"; if (isset($item_i['users_id_recipient']) && $item_i['users_id_recipient'] != 0) { $user->getFromDB($this->fields['users_id_recipient']); echo "<div class='tooltip_picture_border'>"; $picture = ""; if (isset($user->fields['picture'])) { $picture = $user->fields['picture']; } echo "<img class='user_picture' alt=\"" . __s('Picture') . "\" src='" . User::getThumbnailURLForPicture($picture) . "'>"; echo "</div>"; echo $user->getLink(); } else { _e("Requester"); } echo "</div>"; // h_user echo "</div>"; //h_info echo "<div class='h_content TicketContent'>"; echo "<div class='b_right'>" . __("Ticket recall") . "</div>"; echo "<div class='ticket_title'>"; echo html_entity_decode($this->fields['name']); echo "</div>"; echo "<div class='ticket_description'>"; echo Toolbox::unclean_cross_side_scripting_deep(Html::entity_decode_deep($this->fields['content'])); echo "</div>"; echo "</div>"; // h_content TicketContent echo "</div>"; // h_item middle echo "<div class='break'></div>"; } // end timeline echo "</div>"; // h_item $user_position echo "<script type='text/javascript'>read_more();</script>"; }
/** * @see NotificationTarget::getDatasForTemplate() **/ function getDatasForTemplate($event, $options = array()) { global $CFG_GLPI, $DB; //----------- Reservation infos -------------- // $events = $this->getAllEvents(); $item = $this->obj; $this->datas['##projecttask.action##'] = $events[$event]; $this->datas['##projecttask.url##'] = $this->formatURL($options['additionnaloption']['usertype'], "ProjectTask_" . $item->getField("id")); $this->datas["##projecttask.name##"] = $item->getField('name'); $this->datas["##projecttask.project##"] = Dropdown::getDropdownName('glpi_projects', $item->getField('projects_id')); $this->datas["##projecttask.projecturl##"] = $this->formatURL($options['additionnaloption']['usertype'], "Project_" . $item->getField("projects_id")); $this->datas["##projecttask.description##"] = $item->getField('content'); $this->datas["##projecttask.comments##"] = $item->getField('comment'); $this->datas["##projecttask.creationdate##"] = Html::convDateTime($item->getField('date')); $this->datas["##projecttask.lastupdatedate##"] = Html::convDateTime($item->getField('date_mod')); $this->datas["##projecttask.percent##"] = Dropdown::getValueWithUnit($item->getField('percent_done'), "%"); $this->datas["##projecttask.planstartdate##"] = Html::convDateTime($item->getField('plan_start_date')); $this->datas["##projecttask.planenddate##"] = Html::convDateTime($item->getField('plan_end_date')); $this->datas["##projecttask.realstartdate##"] = Html::convDateTime($item->getField('real_start_date')); $this->datas["##projecttask.realenddate##"] = Html::convDateTime($item->getField('real_end_date')); $this->datas["##projecttask.plannedduration##"] = Html::timestampToString($item->getField('planned_duration'), false); $this->datas["##projecttask.effectiveduration##"] = Html::timestampToString($item->getField('effective_duration'), false); $ticket_duration = ProjectTask_Ticket::getTicketsTotalActionTime($item->getID()); $this->datas["##projecttask.ticketsduration##"] = Html::timestampToString($ticket_duration, false); $this->datas["##projecttask.totalduration##"] = Html::timestampToString($ticket_duration + $item->getField('effective_duration'), false); $entity = new Entity(); $this->datas["##projecttask.entity##"] = ''; $this->datas["##projecttask.shortentity##"] = ''; if ($entity->getFromDB($this->getEntity())) { $this->datas["##projecttask.entity##"] = $entity->getField('completename'); $this->datas["##projecttask.shortentity##"] = $entity->getField('name'); } $this->datas["##projecttask.father##"] = ''; if ($item->getField('projecttasks_id')) { $this->datas["##projecttask.father##"] = Dropdown::getDropdownName('glpi_projecttasks', $item->getField('projecttasks_id')); } $this->datas["##projecttask.state##"] = ''; if ($item->getField('projectstates_id')) { $this->datas["##projecttask.state##"] = Dropdown::getDropdownName('glpi_projectstates', $item->getField('projectstates_id')); } $this->datas["##projecttask.type##"] = ''; if ($item->getField('projecttasktypes_id')) { $this->datas["##projecttask.type##"] = Dropdown::getDropdownName('glpi_projecttasktypes', $item->getField('projecttasktypes_id')); } $this->datas["##projecttask.createbyuser##"] = ''; if ($item->getField('users_id')) { $user_tmp = new User(); $user_tmp->getFromDB($item->getField('users_id')); $this->datas["##projecttask.createbyuser##"] = $user_tmp->getName(); } // Team infos $restrict = "`projecttasks_id` = '" . $item->getField('id') . "'"; $items = getAllDatasFromTable('glpi_projecttaskteams', $restrict); $this->datas['teammembers'] = array(); if (count($items)) { foreach ($items as $data) { if ($item2 = getItemForItemtype($data['itemtype'])) { if ($item2->getFromDB($data['items_id'])) { $tmp = array(); $tmp['##teammember.itemtype##'] = $item2->getTypeName(); $tmp['##teammember.name##'] = $item2->getName(); $this->datas['teammembers'][] = $tmp; } } } } $this->datas['##projecttask.numberofteammembers##'] = count($this->datas['teammembers']); // Task infos $restrict = "`projecttasks_id`='" . $item->getField('id') . "'"; $restrict .= " ORDER BY `date` DESC, `id` ASC"; $tasks = getAllDatasFromTable('glpi_projecttasks', $restrict); $this->datas['tasks'] = array(); foreach ($tasks as $task) { $tmp = array(); $tmp['##task.creationdate##'] = Html::convDateTime($task['date']); $tmp['##task.lastupdatedate##'] = Html::convDateTime($task['date_mod']); $tmp['##task.name##'] = $task['name']; $tmp['##task.description##'] = $task['content']; $tmp['##task.comments##'] = $task['comment']; $tmp['##task.state##'] = Dropdown::getDropdownName('glpi_projectstates', $task['projectstates_id']); $tmp['##task.type##'] = Dropdown::getDropdownName('glpi_projecttasktypes', $task['projecttasktypes_id']); $tmp['##task.percent##'] = Dropdown::getValueWithUnit($task['percent_done'], "%"); $this->datas["##task.planstartdate##"] = ''; $this->datas["##task.planenddate##"] = ''; $this->datas["##task.realstartdate##"] = ''; $this->datas["##task.realenddate##"] = ''; if (!is_null($task['plan_start_date'])) { $tmp['##task.planstartdate##'] = Html::convDateTime($task['plan_start_date']); } if (!is_null($task['plan_end_date'])) { $tmp['##task.planenddate##'] = Html::convDateTime($task['plan_end_date']); } if (!is_null($task['real_start_date'])) { $tmp['##task.realstartdate##'] = Html::convDateTime($task['real_start_date']); } if (!is_null($task['real_end_date'])) { $tmp['##task.realenddate##'] = Html::convDateTime($task['real_end_date']); } $this->datas['tasks'][] = $tmp; } $this->datas["##projecttask.numberoftasks##"] = count($this->datas['tasks']); // History infos $this->datas['log'] = array(); // Use list_limit_max or load the full history ? foreach (Log::getHistoryData($item, 0, $CFG_GLPI['list_limit_max']) as $data) { $tmp = array(); $tmp["##projecttask.log.date##"] = $data['date_mod']; $tmp["##projecttask.log.user##"] = $data['user_name']; $tmp["##projecttask.log.field##"] = $data['field']; $tmp["##projecttask.log.content##"] = $data['change']; $this->datas['log'][] = $tmp; } $this->datas["##projecttask.numberoflogs##"] = count($this->datas['log']); // Tickets infos $restrict = "`projecttasks_id`='" . $item->getField('id') . "'"; $tickets = getAllDatasFromTable('glpi_projecttasks_tickets', $restrict); $this->datas['tickets'] = array(); if (count($tickets)) { $ticket = new Ticket(); foreach ($tickets as $data) { if ($ticket->getFromDB($data['tickets_id'])) { $tmp = array(); $tmp['##ticket.id##'] = $data['tickets_id']; $tmp['##ticket.date##'] = $ticket->getField('date'); $tmp['##ticket.title##'] = $ticket->getField('name'); $tmp['##ticket.url##'] = $this->formatURL($options['additionnaloption']['usertype'], "Ticket_" . $data['tickets_id']); $tmp['##ticket.content##'] = $ticket->getField('content'); $this->datas['tickets'][] = $tmp; } } } $this->datas['##projecttask.numberoftickets##'] = count($this->datas['tickets']); // Document $query = "SELECT `glpi_documents`.*\n FROM `glpi_documents`\n LEFT JOIN `glpi_documents_items`\n ON (`glpi_documents`.`id` = `glpi_documents_items`.`documents_id`)\n WHERE `glpi_documents_items`.`itemtype` = 'ProjectTask'\n AND `glpi_documents_items`.`items_id` = '" . $item->getField('id') . "'"; $this->datas["documents"] = array(); if ($result = $DB->query($query)) { while ($data = $DB->fetch_assoc($result)) { $tmp = array(); $tmp['##document.id##'] = $data['id']; $tmp['##document.name##'] = $data['name']; $tmp['##document.weblink##'] = $data['link']; $tmp['##document.url##'] = $this->formatURL($options['additionnaloption']['usertype'], "document_" . $data['id']); $downloadurl = "/front/document.send.php?docid=" . $data['id']; $tmp['##document.downloadurl##'] = $this->formatURL($options['additionnaloption']['usertype'], $downloadurl); $tmp['##document.heading##'] = Dropdown::getDropdownName('glpi_documentcategories', $data['documentcategories_id']); $tmp['##document.filename##'] = $data['filename']; $this->datas['documents'][] = $tmp; } } $this->datas["##projecttask.urldocument##"] = $this->formatURL($options['additionnaloption']['usertype'], "ProjectTask_" . $item->getField("id") . '_Document_Item$1'); $this->datas["##projecttask.numberofdocuments##"] = count($this->datas['documents']); // Items infos $restrict = "`projects_id` = '" . $item->getField('id') . "'"; $items = getAllDatasFromTable('glpi_items_projects', $restrict); $this->getTags(); foreach ($this->tag_descriptions[NotificationTarget::TAG_LANGUAGE] as $tag => $values) { if (!isset($this->datas[$tag])) { $this->datas[$tag] = $values['label']; } } }
Html::createProgressBar(__('Work in progress...')); echo "</td></tr>\n"; echo "</table>"; if (!isset($_GET['offset'])) { // First run $offset = $rulecollection->replayRulesOnExistingDB(0, $max, array(), $_POST); $manufacturer = isset($_POST["manufacturer"]) ? $_POST["manufacturer"] : 0; } else { // Next run $offset = $rulecollection->replayRulesOnExistingDB($_GET['offset'], $max, array(), $_GET); $manufacturer = $_GET["manufacturer"]; // global start for stat $start = $_GET["start"]; } if ($offset < 0) { // Work ended $end = explode(" ", microtime()); $duree = round($end[0] + $end[1] - $start); Html::changeProgressBarMessage(sprintf(__('Task completed in %s'), Html::timestampToString($duree))); echo "<a href='" . $_SERVER['PHP_SELF'] . "'>" . __('Back') . "</a>"; } else { // Need more work Html::redirect($_SERVER['PHP_SELF'] . "?start={$start}&replay_rule=1&offset={$offset}&manufacturer=" . "{$manufacturer}"); } Html::footer(true); exit; } } Html::header(Rule::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], 'admin', $rulecollection->menu_type, $rulecollection->menu_option); $rulecollection->display(); Html::footer();
die("** Could not fork\n"); } else { if ($pid) { $pids[$pid] = $pid; if ($verb) { echo "+ {$pid}: started, " . count($pids) . " running\n"; } } else { syncEntity(posix_getpid(), $row, $server, $prof, $verb, $mail); exit(0); } } } while (count($pids) > 0) { $pid = pcntl_wait($status); if ($pid < 0) { die("** Cound not wait\n"); } else { $nb++; unset($pids[$pid]); if ($verb) { echo "+ {$pid}: ended, waiting for " . count($pids) . " running process\n"; } } } $tps = microtime(true) - $tps; if ($nbproc == 1) { printf("%d users synchronized in %s\n", $nb, Html::clean(Html::timestampToString(round($tps, 0), true))); } else { printf("%d entities synchronized in %s\n", $nb, Html::clean(Html::timestampToString(round($tps, 0), true))); }
/** * @param $item CommonITILObject * @param $rand * @param $showprivate (false by default) **/ function showInObjectSumnary(CommonITILObject $item, $rand, $showprivate = false) { global $DB, $CFG_GLPI; $canedit = isset($this->fields['can_edit']) && !$this->fields['can_edit'] ? false : $this->canEdit($this->fields['id']); $canview = $this->canViewItem(); echo "<tr class='tab_bg_"; if ($this->maybePrivate() && $this->fields['is_private'] == 1) { echo "4' "; } else { echo "2' "; } if ($canedit) { echo "style='cursor:pointer' onClick=\"viewEditTask" . $item->fields['id'] . $this->fields['id'] . "{$rand}();\""; } echo " id='viewfollowup" . $this->fields[$item->getForeignKeyField()] . $this->fields["id"] . "{$rand}'>"; if ($canview) { echo "<td>"; switch ($this->fields['state']) { case Planning::INFO: echo Html::image($CFG_GLPI['root_doc'] . "/pics/faqedit.png", array('title' => _n('Information', 'Information', 1))); break; case Planning::TODO: if (empty($this->fields['begin'])) { echo Html::image($CFG_GLPI['root_doc'] . "/pics/redbutton.png", array('title' => __('To do'))); } else { echo Html::image($CFG_GLPI['root_doc'] . "/pics/rdv.png", array('title' => __('Planned'))); } break; case Planning::DONE: echo Html::image($CFG_GLPI['root_doc'] . "/pics/greenbutton.png", array('title' => __('Done'))); break; } echo "</td>"; echo "<td>"; $typename = $this->getTypeName(1); if ($this->fields['taskcategories_id']) { printf(__('%1$s - %2$s'), $typename, Dropdown::getDropdownName('glpi_taskcategories', $this->fields['taskcategories_id'])); } else { echo $typename; } echo "</td>"; echo "<td>"; if ($canedit) { echo "\n<script type='text/javascript' >\n"; echo "function viewEditTask" . $item->fields['id'] . $this->fields["id"] . "{$rand}() {\n"; $params = array('type' => $this->getType(), 'parenttype' => $item->getType(), $item->getForeignKeyField() => $this->fields[$item->getForeignKeyField()], 'id' => $this->fields["id"]); Ajax::updateItemJsCode("viewfollowup" . $item->fields['id'] . "{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params); echo "};"; echo "</script>\n"; } //else echo "--no--"; echo Html::convDateTime($this->fields["date"]) . "</td>"; echo "<td class='left'>" . nl2br(html_entity_decode($this->fields["content"])) . "</td>"; echo "<td>" . Html::timestampToString($this->fields["actiontime"], 0) . "</td>"; echo "<td>" . getUserName($this->fields["users_id"]) . "</td>"; if ($this->maybePrivate() && $showprivate) { echo "<td>" . Dropdown::getYesNo($this->fields["is_private"]) . "</td>"; } echo "<td>"; if (empty($this->fields["begin"])) { if (isset($this->fields["state"])) { echo Planning::getState($this->fields["state"]) . "<br>"; } if ($this->fields["users_id_tech"] || $this->fields["groups_id_tech"]) { if (isset($this->fields["users_id_tech"])) { printf('%1$s %2$s', __('By user'), getUserName($this->fields["users_id_tech"])); } if (isset($this->fields["groups_id_tech"])) { $groupname = sprintf('%1$s %2$s', "<br />" . __('By group'), Dropdown::getDropdownName('glpi_groups', $this->fields["groups_id_tech"])); if ($_SESSION['glpiis_ids_visible']) { $groupname = printf(__('%1$s (%2$s)'), $groupname, $this->fields["groups_id_tech"]); } echo $groupname; } } else { _e('None'); } } else { echo "<table width='100%'>"; if (isset($this->fields["state"])) { echo "<tr><td>" . _x('item', 'State') . "</td><td>"; echo Planning::getState($this->fields["state"]) . "</td></tr>"; } echo "<tr><td>" . __('Begin') . "</td><td>"; echo Html::convDateTime($this->fields["begin"]) . "</td></tr>"; echo "<tr><td>" . __('End') . "</td><td>"; echo Html::convDateTime($this->fields["end"]) . "</td></tr>"; echo "<tr><td>"; if ($this->fields["users_id_tech"]) { printf('%1$s %2$s', __('By user'), getUserName($this->fields["users_id_tech"])); } if ($this->fields["groups_id_tech"]) { $groupname = sprintf('%1$s %2$s', "<br />" . __('By group'), Dropdown::getDropdownName('glpi_groups', $this->fields["groups_id_tech"])); if ($_SESSION['glpiis_ids_visible']) { $groupname = printf(__('%1$s (%2$s)'), $groupname, $this->fields["groups_id_tech"]); } echo $groupname; } if (PlanningRecall::isAvailable() && $_SESSION["glpiactiveprofile"]["interface"] == "central") { echo "<tr><td>" . _x('Planning', 'Reminder') . "</td><td>"; PlanningRecall::specificForm(array('itemtype' => $this->getType(), 'items_id' => $this->fields["id"])); } echo "</td></tr>"; echo "</table>"; } echo "</td></tr>\n"; } }
/** * Used to display each status time used for each group/user * * * @param Ticket $ticket */ static function ShowDetail(Ticket $ticket, $type) { $ptState = new PluginTimelineticketState(); if ($type == 'group') { $ptItem = new PluginTimelineticketAssignGroup(); } else { if ($type == 'user') { $ptItem = new PluginTimelineticketAssignUser(); } } $a_states = $ptState->find("`tickets_id`='" . $ticket->getField('id') . "'", "`date`"); $a_state_delays = array(); $a_state_num = array(); $delay = 0; $list_status = Ticket::getAllStatusArray(); $status = "new"; foreach ($a_states as $array) { $delay += $array['delay']; $a_state_delays[$delay] = $array['old_status']; $a_state_num[] = $delay; } $a_state_num[] = $delay; $last_delay = $delay; $a_groups = $ptItem->find("`tickets_id`='" . $ticket->getField('id') . "'", "`date`"); echo "<table class='tab_cadre_fixe' width='100%'>"; echo "<tr class='tab_bg_1'>"; echo "<th colspan='" . (count($list_status) + 1) . "'>"; _e('Result details'); if ($type == 'group') { echo " (" . __('Groups in charge of the ticket', 'timelineticket') . ")"; } else { if ($type == 'user') { echo " (" . __('Technicians in charge of the ticket', 'timelineticket') . ")"; } } echo "</th>"; echo "</tr>"; echo "</tr>"; echo "<th>"; echo "</th>"; foreach ($list_status as $name) { echo "<th>"; echo $name; echo "</th>"; } echo "</tr>"; if ($type == 'group') { $a_details = PluginTimelineticketToolbox::getDetails($ticket, 'group', false); } else { if ($type == 'user') { $a_details = PluginTimelineticketToolbox::getDetails($ticket, 'user', false); } } foreach ($a_details as $items_id => $a_detail) { $a_status = array(); foreach ($a_detail as $data) { if (!isset($a_status[$data['Status']])) { $a_status[$data['Status']] = 0; } $a_status[$data['Status']] += $data['End'] - $data['Start']; } echo "<tr class='tab_bg_1'>"; if ($type == 'group') { echo "<td>" . Dropdown::getDropdownName("glpi_groups", $items_id) . "</td>"; } else { if ($type == 'user') { echo "<td>" . Dropdown::getDropdownName("glpi_users", $items_id) . "</td>"; } } foreach ($list_status as $status => $name) { echo "<td>"; if (isset($a_status[$status])) { echo Html::timestampToString($a_status[$status], true); } echo "</td>"; } echo "</tr>"; } echo "</table>"; }
foreach ($DB->request($query) as $data) { printf("%4d links for computer #%d\n", $data['cpt'], $data['computers_id']); $query2 = "SELECT `id`, `plugin_ocsinventoryng_ocsservers_id`,\n `ocsid`, `ocs_deviceid`, `computers_id`, `last_update`\n FROM `glpi_plugin_ocsinventoryng_ocslinks`\n WHERE `computers_id` = '" . $data['computers_id'] . "'\n ORDER BY `last_update`"; $i = 1; foreach ($DB->request($query2) as $data2) { $del = $i < $data['cpt']; // Keep the more recent printf("%12d : %s (%d-%d, last=%s) : %s\n", $data2['id'], $data2['ocs_deviceid'], $data2['plugin_ocsinventoryng_ocsservers_id'], $data2['ocsid'], $data2['last_update'], $del ? 'delete' : 'keep'); if ($del) { if (isset($_GET['clean'])) { $query_del = "DELETE\n FROM `glpi_plugin_ocsinventoryng_ocslinks`\n WHERE `id` = '" . $data2["id"] . "'"; if ($DB->query($query_del)) { $nbdel++; } } else { $nbtodo++; } } $i++; } } } $tps = microtime(true) - $tps; printf("\nChecked links : %d\n", $nbchk); if (isset($_GET['clean'])) { printf("Deleted links : %d\n", $nbdel); } else { printf("Corrupt links : %d\n", $nbtodo); } printf("Done in %s\n", Html::timestampToString(round($tps, 0), true));
/** * Display in HTML, delay between master and slave * 1 line per slave is multiple **/ static function showAllReplicateDelay() { $DBslave = self::getDBSlaveConf(); if (is_array($DBslave->dbhost)) { $hosts = $DBslave->dbhost; } else { $hosts = array($DBslave->dbhost); } foreach ($hosts as $num => $name) { $diff = self::getReplicateDelay($num); //TRANS: %s is namez of server Mysql printf(__('%1$s: %2$s'), __('Mysql server'), $name); echo " - "; if ($diff > 1000000000) { echo __("can't connect to the database") . "<br>"; } else { if ($diff) { printf(__('%1$s: %2$s') . "<br>", __('Difference between master and slave'), Html::timestampToString($diff, 1)); } else { printf(__('%1$s: %2$s') . "<br>", __('Difference between master and slave'), __('None')); } } } }
/** * @covers Html::timestampToString */ public function testTimestampToString() { $expected = '0 seconds'; $this->assertEquals($expected, Html::timestampToString(null)); $this->assertEquals($expected, Html::timestampToString('')); $this->assertEquals($expected, Html::timestampToString(0)); $tstamp = 57226; $expected = '15 hours 53 minutes 46 seconds'; $this->assertEquals($expected, Html::timestampToString($tstamp)); $tstamp = -57226; $expected = '- 15 hours 53 minutes 46 seconds'; $this->assertEquals($expected, Html::timestampToString($tstamp)); $tstamp = 1337; $expected = '22 minutes 17 seconds'; $this->assertEquals($expected, Html::timestampToString($tstamp)); $expected = '22 minutes'; $this->assertEquals($expected, Html::timestampToString($tstamp, false)); $tstamp = 54; $expected = '54 seconds'; $this->assertEquals($expected, Html::timestampToString($tstamp)); $this->assertEquals($expected, Html::timestampToString($tstamp, false)); $tstamp = 157226; $expected = '1 days 19 hours 40 minutes 26 seconds'; $this->assertEquals($expected, Html::timestampToString($tstamp)); $expected = '1 days 19 hours 40 minutes'; $this->assertEquals($expected, Html::timestampToString($tstamp, false)); $expected = '43 hours 40 minutes 26 seconds'; $this->assertEquals($expected, Html::timestampToString($tstamp, true, false)); $expected = '43 hours 40 minutes'; $this->assertEquals($expected, Html::timestampToString($tstamp, false, false)); }
function displayValues($services_id, $period, $tooltip = 0) { $a_times = $this->parseEvents($services_id, $period); $displaytime = ''; if ($a_times[0] > 0) { echo "<td style='background-color: rgb(255, 120, 0);-moz-border-radius: 4px;-webkit-border-radius: 4px;-o-border-radius: 4px;padding: 2px;' align='center'>"; if ($tooltip == '1') { $displaytime = ' ' . Html::showToolTip(Html::timestampToString($a_times[0]), array('display' => false)); } else { $displaytime = '<br/>' . Html::timestampToString($a_times[0]); } } else { echo "<td align='center'>"; } echo round(($a_times[1] - $a_times[0]) / $a_times[1] * 100, 3) . "%" . $displaytime; echo "</td>"; }
/** * @param $duree * @param $imported * @param $synchronized * @param $linked * @param $failed * @param $notupdated * @param $notunique * @param $linkedrefused * @param $time **/ function showshowStat($duree, &$imported, &$synchronized, &$linked, &$failed, &$notupdated, &$notunique, &$linkedrefused, &$time) { $title = __('Statistics'); if ($duree < 9999) { $title = sprintf(__('%1$s (%2$s)'), $title, sprintf(_n('%d hour', '%d hours', $duree), $duree)); } echo "<tr><th colspan='16'>" . $title . "</th></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td class='right' colspan='6'>" . __('Minimum') . "<br />" . __('Maximum', 'ocsinventoryng') . "<br />" . __('Average') . "<br />" . __('Total') . "</td>"; echo "<td class='center'>" . $imported->GetMinimum() . "<br />" . $imported->GetMaximum() . "<br />" . round($imported->GetAverage(), 2) . "<br />" . $imported->GetTotal() . "</td>"; echo "<td class='center'>" . $synchronized->GetMinimum() . "<br />" . $synchronized->GetMaximum() . "<br />" . round($synchronized->GetAverage(), 2) . "<br />" . $synchronized->GetTotal() . "</td>"; echo "<td class='center'>" . $linked->GetMinimum() . "<br />" . $linked->GetMaximum() . "<br />" . round($linked->GetAverage(), 2) . "<br />" . $linked->GetTotal() . "</td>"; echo "<td class='center'>" . $failed->GetMinimum() . "<br />" . $failed->GetMaximum() . "<br />" . round($failed->GetAverage(), 2) . "<br /> </td>"; echo "<td class='center'>" . $notupdated->GetMinimum() . "<br />" . $notupdated->GetMaximum() . "<br />" . round($notupdated->GetAverage(), 2) . "<br /> </td>"; echo "<td class='center'>" . $notunique->GetMinimum() . "<br />" . $notunique->GetMaximum() . "<br />" . round($notunique->GetAverage(), 2) . "<br /> </td>"; echo "<td class='center'>" . $linkedrefused->GetMinimum() . "<br />" . $linkedrefused->GetMaximum() . "<br />" . round($linkedrefused->GetAverage(), 2) . "<br /> </td>"; echo "<td class='center'>" . Html::timestampToString($time->GetMinimum()) . "<br />" . Html::timestampToString($time->GetMaximum()) . "<br />" . Html::timestampToString(round($time->GetAverage())) . "<br />" . Html::timestampToString($time->GetTotal()) . "</td>"; if ($time->GetTotal() > 0) { echo "<td class='center' colspan='2'>" . __('Speed') . "<br />" . sprintf(__('%1$s %2$s'), round(($imported->GetTotal() + $synchronized->GetTotal() + $linked->GetTotal() + $failed->GetTotal() + $notunique->getTotal()) / $time->GetTotal(), 2), __('pc/s', 'ocsinventoryng')) . "</td>"; } else { echo "<td> </td><td> </td>"; } echo "</tr>\n"; echo "<tr><th colspan='15'>" . Dropdown::EMPTY_VALUE . "<th></tr>\n"; }
/** * Additional message in global message * * @param $msg text to display **/ function displayMessage($msg) { $now = time(); $tps = Html::timestampToString($now - $this->deb); echo "<script type='text/javascript'>document.getElementById('" . $this->current_message_area_id . "').innerHTML=\"<p class='center'>" . addslashes($msg) . " ({$tps})</p>\";" . "</script>\n"; $this->flushLogDisplayMessage(); $this->lastMessage = array('time' => time(), 'msg' => $msg); Html::glpi_flush(); }
/** * Generic Function to display Items * * @param $itemtype item type * @param $ID ID of the SEARCH_OPTION item * @param $data array containing data results * @param $num item num in the request * @param $meta is a meta item ? (default 0) * @param $addobjectparams array added parameters for union search * * @return string to print **/ static function giveItem($itemtype, $ID, array $data, $num, $meta = 0, array $addobjectparams = array()) { global $CFG_GLPI; $showuserlink = 0; if (Session::haveRight('user', READ)) { $showuserlink = 1; } $searchopt =& self::getOptions($itemtype); if (isset($CFG_GLPI["union_search_type"][$itemtype]) && $CFG_GLPI["union_search_type"][$itemtype] == $searchopt[$ID]["table"]) { if (isset($searchopt[$ID]['addobjectparams']) && $searchopt[$ID]['addobjectparams']) { return self::giveItem($data["TYPE"], $ID, $data, $num, $meta, $searchopt[$ID]['addobjectparams']); } return self::giveItem($data["TYPE"], $ID, $data, $num, $meta); } if (count($addobjectparams)) { $searchopt[$ID] = array_merge($searchopt[$ID], $addobjectparams); } // Plugin can override core definition for its type if ($plug = isPluginItemType($itemtype)) { $function = 'plugin_' . $plug['plugin'] . '_giveItem'; if (function_exists($function)) { $out = $function($itemtype, $ID, $data, $num); if (!empty($out)) { return $out; } } } $NAME = "ITEM_"; if ($meta) { $NAME = "META_"; } $table = $searchopt[$ID]["table"]; $field = $searchopt[$ID]["field"]; $linkfield = $searchopt[$ID]["linkfield"]; /// TODO try to clean all specific cases using SpecificToDisplay switch ($table . '.' . $field) { case "glpi_users.name": // USER search case if ($itemtype != 'User' && isset($searchopt[$ID]["forcegroupby"]) && $searchopt[$ID]["forcegroupby"]) { $out = ""; $split = explode("\$\$\$\$", $data[$NAME . $num]); $count_display = 0; $added = array(); for ($k = 0; $k < count($split); $k++) { if ($split[$k] > 0) { if ($count_display) { $out .= "<br>"; } $count_display++; if ($itemtype == 'Ticket') { $userdata = getUserName($split[$k], 2); $tooltip = ""; if (Session::haveRight('user', READ)) { $tooltip = Html::showToolTip($userdata["comment"], array('link' => $userdata["link"], 'display' => false)); } $out .= sprintf(__('%1$s %2$s'), $userdata['name'], $tooltip); } else { $out .= getUserName($split[$k], $showuserlink); } } } // Manage alternative_email for tickets_users if ($itemtype == 'Ticket' && isset($data[$NAME . $num . '_2'])) { $split = explode("\$\$\$\$", $data[$NAME . $num . '_2']); for ($k = 0; $k < count($split); $k++) { $split2 = explode(" ", $split[$k]); if (count($split2) == 2 && $split2[0] == 0 && !empty($split2[1])) { if ($count_display) { $out .= "<br>"; } $count_display++; $out .= "<a href='mailto:" . $split2[1] . "'>" . $split2[1] . "</a>"; } } } return $out; } if ($itemtype != 'User') { $toadd = ''; if ($itemtype == 'Ticket' && $data[$NAME . $num . "_3"] > 0) { $userdata = getUserName($data[$NAME . $num . "_3"], 2); $toadd = Html::showToolTip($userdata["comment"], array('link' => $userdata["link"], 'display' => false)); } if (Session::haveRight('user', READ)) { $usernameformat = formatUserName($data[$NAME . $num . "_3"], $data[$NAME . $num], $data[$NAME . $num . "_2"], $data[$NAME . $num . "_4"], 1); } else { $usernameformat = formatUserName($data[$NAME . $num . "_3"], $data[$NAME . $num], $data[$NAME . $num . "_2"], $data[$NAME . $num . "_4"], 0); } return sprintf(__('%1$s %2$s'), $usernameformat, $toadd); } break; case "glpi_profiles.interface": return Profile::getInterfaceName($data[$NAME . $num]); case "glpi_profiles.name": if ($itemtype == 'User' && $ID == 20) { $out = ""; $split = explode("\$\$\$\$", $data[$NAME . $num]); $split2 = explode("\$\$\$\$", $data[$NAME . $num . "_2"]); $split3 = explode("\$\$\$\$", $data[$NAME . $num . "_3"]); $split4 = explode("\$\$\$\$", $data[$NAME . $num . "_4"]); $count_display = 0; $added = array(); for ($k = 0; $k < count($split); $k++) { if (strlen(trim($split[$k])) > 0) { $text = sprintf(__('%1$s - %2$s'), $split[$k], Dropdown::getDropdownName('glpi_entities', $split2[$k])); $comp = ''; if ($split3[$k]) { $comp = __(READ); if ($split4[$k]) { $comp = sprintf(__('%1$s%2$s'), $comp, ", "); } } if ($split4[$k]) { $comp = sprintf(__('%1$s%2$s'), $comp, __('D')); } if (!empty($comp)) { $text = sprintf(__('%1$s %2$s'), $text, "(" . $comp . ")"); } if (!in_array($text, $added)) { if ($count_display) { $out .= "<br>"; } $count_display++; $out .= $text; $added[] = $text; } } } return $out; } break; case "glpi_entities.completename": if ($itemtype == 'User') { $out = ""; $split = explode("\$\$\$\$", $data[$NAME . $num]); $split2 = explode("\$\$\$\$", $data[$NAME . $num . "_2"]); $split3 = explode("\$\$\$\$", $data[$NAME . $num . "_3"]); $split4 = explode("\$\$\$\$", $data[$NAME . $num . "_4"]); $added = array(); $count_display = 0; for ($k = 0; $k < count($split); $k++) { if (strlen(trim($split[$k])) > 0) { $text = sprintf(__('%1$s - %2$s'), $split[$k], Dropdown::getDropdownName('glpi_profiles', $split2[$k])); $comp = ''; if ($split3[$k]) { $comp = __(READ); if ($split4[$k]) { $comp = sprintf(__('%1$s%2$s'), $comp, ", "); } } if ($split4[$k]) { $comp = sprintf(__('%1$s%2$s'), $comp, __('D')); } if (!empty($comp)) { $text = sprintf(__('%1$s %2$s'), $text, "(" . $comp . ")"); } if (!in_array($text, $added)) { if ($count_display) { $out .= "<br>"; } $count_display++; $out .= $text; $added[] = $text; } } } return $out; } break; case "glpi_documenttypes.icon": if (!empty($data[$NAME . $num])) { return "<img class='middle' alt='' src='" . $CFG_GLPI["typedoc_icon_dir"] . "/" . $data[$NAME . $num] . "'>"; } return " "; case "glpi_documents.filename": $doc = new Document(); if ($doc->getFromDB($data['id'])) { return $doc->getDownloadLink(); } return NOT_AVAILABLE; case "glpi_deviceharddrives.specificity": case "glpi_devicememories.specificity": case "glpi_deviceprocessors.specificity": return $data[$NAME . $num]; case "glpi_networkports.mac": $out = ""; if ($itemtype == 'Computer') { $displayed = array(); if (!empty($data[$NAME . $num . "_2"])) { $split = explode("\$\$\$\$", $data[$NAME . $num . "_2"]); $count_display = 0; for ($k = 0; $k < count($split); $k++) { $lowstr = Toolbox::strtolower($split[$k]); if (strlen(trim($split[$k])) > 0 && !in_array($lowstr, $displayed)) { if ($count_display) { $out .= "<br>"; } $count_display++; $out .= $split[$k]; $displayed[] = $lowstr; } } if (!empty($data[$NAME . $num])) { $out .= "<br>"; } } if (!empty($data[$NAME . $num])) { $split = explode("\$\$\$\$", $data[$NAME . $num]); $count_display = 0; for ($k = 0; $k < count($split); $k++) { $lowstr = Toolbox::strtolower($split[$k]); if (strlen(trim($split[$k])) > 0 && !in_array($lowstr, $displayed)) { if ($count_display) { $out .= "<br>"; } $count_display++; $out .= $split[$k]; $displayed[] = $lowstr; } } } return $out; } break; case "glpi_contracts.duration": case "glpi_contracts.notice": case "glpi_contracts.periodicity": case "glpi_contracts.billing": if (!empty($data[$NAME . $num])) { $split = explode('$$$$', $data[$NAME . $num]); $output = ""; foreach ($split as $duration) { $output .= (empty($output) ? '' : '<br>') . sprintf(_n('%d month', '%d months', $duration), $duration); } return $output; } return " "; case "glpi_contracts.renewal": return Contract::getContractRenewalName($data[$NAME . $num]); // case "glpi_infocoms.sink_time" : // if (!empty($data[$NAME.$num])) { // $split = explode("$$$$", $data[$NAME.$num]); // $out = ''; // foreach ($split as $val) { // $out .= (empty($out)?'':'<br>'); // if ($val > 0) { // //TRANS: %d is a number of years // $out .= sprintf(_n('%d year', '%d years', $val), $val); // } // } // return $out; // } // return " "; // // case "glpi_infocoms.warranty_duration" : // if (!empty($data[$NAME.$num])) { // $split = explode("$$$$", $data[$NAME.$num]); // $out = ''; // foreach ($split as $val) { // $out .= (empty($out)?'':'<br>'); // if ($val > 0) { // $out .= sprintf(_n('%d month', '%d months', $val), $val); // } // if ($val < 0) { // $out .= __('Lifelong'); // } // } // return $out; // } // return " "; // case "glpi_infocoms.sink_time" : // if (!empty($data[$NAME.$num])) { // $split = explode("$$$$", $data[$NAME.$num]); // $out = ''; // foreach ($split as $val) { // $out .= (empty($out)?'':'<br>'); // if ($val > 0) { // //TRANS: %d is a number of years // $out .= sprintf(_n('%d year', '%d years', $val), $val); // } // } // return $out; // } // return " "; // // case "glpi_infocoms.warranty_duration" : // if (!empty($data[$NAME.$num])) { // $split = explode("$$$$", $data[$NAME.$num]); // $out = ''; // foreach ($split as $val) { // $out .= (empty($out)?'':'<br>'); // if ($val > 0) { // $out .= sprintf(_n('%d month', '%d months', $val), $val); // } // if ($val < 0) { // $out .= __('Lifelong'); // } // } // return $out; // } // return " "; case "glpi_infocoms.sink_type": $split = explode("\$\$\$\$", $data[$NAME . $num]); $out = ''; foreach ($split as $val) { $out .= (empty($out) ? '' : '<br>') . Infocom::getAmortTypeName($val); } return $out; case "glpi_infocoms.alert": if ($data[$NAME . $num] == pow(2, Alert::END)) { return __s('Warranty expiration date'); } return ""; case "glpi_contracts.alert": switch ($data[$NAME . $num]) { case pow(2, Alert::END): return __('End'); case pow(2, Alert::NOTICE): return __('Notice'); case pow(2, Alert::END) + pow(2, Alert::NOTICE): return __('End + Notice'); } return ""; case "glpi_tickets_tickets.tickets_id_1": $out = ""; $split = explode("\$\$\$\$", $data[$NAME . $num]); $split2 = explode("\$\$\$\$", $data[$NAME . $num . "_2"]); $displayed = array(); for ($k = 0; $k < count($split); $k++) { $linkid = $split[$k] == $data['id'] ? $split2[$k] : $split[$k]; if ($linkid > 0 && !isset($displayed[$linkid])) { $text = "<a "; $text .= "href=\"" . $CFG_GLPI["root_doc"] . "/front/ticket.form.php?id={$linkid}\">"; $text .= Dropdown::getDropdownName('glpi_tickets', $linkid) . "</a>"; if (count($displayed)) { $out .= "<br>"; } $displayed[$linkid] = $linkid; $out .= $text; } } return $out; case "glpi_problems.count": if ($data[$NAME . $num] > 0 && Session::haveRight("problem", Problem::READALL)) { if ($itemtype == 'ITILCategory') { $options['field'][0] = 7; $options['searchtype'][0] = 'equals'; $options['contains'][0] = $data['id']; $options['link'][0] = 'AND'; } $options['reset'] = 'reset'; $out = "<a id='problem{$itemtype}" . $data['id'] . "' "; $out .= "href=\"" . $CFG_GLPI["root_doc"] . "/front/problem.php?" . Toolbox::append_params($options, '&') . "\">"; $out .= $data[$NAME . $num] . "</a>"; } else { $out = $data[$NAME . $num]; } return $out; case "glpi_tickets.count": if ($data[$NAME . $num] > 0 && Session::haveRight("ticket", Ticket::READALL)) { if ($itemtype == 'User') { $options['field'][0] = 4; $options['searchtype'][0] = 'equals'; $options['contains'][0] = $data['id']; $options['link'][0] = 'AND'; $options['field'][1] = 22; $options['searchtype'][1] = 'equals'; $options['contains'][1] = $data['id']; $options['link'][1] = 'OR'; $options['field'][2] = 5; $options['searchtype'][2] = 'equals'; $options['contains'][2] = $data['id']; $options['link'][2] = 'OR'; } else { if ($itemtype == 'ITILCategory') { $options['field'][0] = 7; $options['searchtype'][0] = 'equals'; $options['contains'][0] = $data['id']; $options['link'][0] = 'AND'; } else { $options['field'][0] = 12; $options['searchtype'][0] = 'equals'; $options['contains'][0] = 'all'; $options['link'][0] = 'AND'; $options['itemtype2'][0] = $itemtype; $options['field2'][0] = self::getOptionNumber($itemtype, 'name'); $options['searchtype2'][0] = 'equals'; $options['contains2'][0] = $data['id']; $options['link2'][0] = 'AND'; } } $options['reset'] = 'reset'; $out = "<a id='ticket{$itemtype}" . $data['id'] . "' "; $out .= "href=\"" . $CFG_GLPI["root_doc"] . "/front/ticket.php?" . Toolbox::append_params($options, '&') . "\">"; $out .= $data[$NAME . $num] . "</a>"; } else { $out = $data[$NAME . $num]; } return $out; case "glpi_tickets.due_date": // Due date + progress if ($ID == 151) { $out = Html::convDate($data[$NAME . $num]); // No due date in waiting status if ($data[$NAME . $num . '_2'] == CommonITILObject::WAITING) { return ''; } if (empty($data[$NAME . $num])) { return ''; } if ($data[$NAME . $num . '_2'] == Ticket::SOLVED || $data[$NAME . $num . '_2'] == Ticket::CLOSED) { return $data[$NAME . $num]; } $ticket = new Ticket(); $ticket->getFromDB($data['ITEM_0']); $percentage = 0; $totaltime = 0; $currenttime = 0; if ($ticket->fields['slas_id'] != 0) { // Have SLA $sla = new SLA(); $sla->getFromDB($ticket->fields['slas_id']); $currenttime = $sla->getActiveTimeBetween($ticket->fields['date'], date('Y-m-d H:i:s')); $totaltime = $sla->getActiveTimeBetween($ticket->fields['date'], $data[$NAME . $num]); } else { $calendars_id = Entity::getUsedConfig('calendars_id', $ticket->fields['entities_id']); if ($calendars_id != 0) { // Ticket entity have calendar $calendar = new Calendar(); $calendar->getFromDB($calendars_id); $currenttime = $calendar->getActiveTimeBetween($ticket->fields['date'], date('Y-m-d H:i:s')); $totaltime = $calendar->getActiveTimeBetween($ticket->fields['date'], $data[$NAME . $num]); } else { // No calendar $currenttime = strtotime(date('Y-m-d H:i:s')) - strtotime($ticket->fields['date']); $totaltime = strtotime($data[$NAME . $num]) - strtotime($ticket->fields['date']); } } if ($totaltime != 0) { $percentage = round(100 * $currenttime / $totaltime); } else { // Total time is null : no active time $percentage = 100; } if ($percentage > 100) { $percentage = 100; } $percentage_text = $percentage; if ($_SESSION['glpiduedatewarning_unit'] == '%') { $less_warn_limit = $_SESSION['glpiduedatewarning_less']; $less_warn = 100 - $percentage; } else { if ($_SESSION['glpiduedatewarning_unit'] == 'hours') { $less_warn_limit = $_SESSION['glpiduedatewarning_less'] * HOUR_TIMESTAMP; $less_warn = $totaltime - $currenttime; } else { if ($_SESSION['glpiduedatewarning_unit'] == 'days') { $less_warn_limit = $_SESSION['glpiduedatewarning_less'] * DAY_TIMESTAMP; $less_warn = $totaltime - $currenttime; } } } if ($_SESSION['glpiduedatecritical_unit'] == '%') { $less_crit_limit = $_SESSION['glpiduedatecritical_less']; $less_crit = 100 - $percentage; } else { if ($_SESSION['glpiduedatecritical_unit'] == 'hours') { $less_crit_limit = $_SESSION['glpiduedatecritical_less'] * HOUR_TIMESTAMP; $less_crit = $totaltime - $currenttime; } else { if ($_SESSION['glpiduedatecritical_unit'] == 'days') { $less_crit_limit = $_SESSION['glpiduedatecritical_less'] * DAY_TIMESTAMP; $less_crit = $totaltime - $currenttime; } } } $color = $_SESSION['glpiduedateok_color']; if ($less_crit < $less_crit_limit) { $color = $_SESSION['glpiduedatecritical_color']; } else { if ($less_warn < $less_warn_limit) { $color = $_SESSION['glpiduedatewarning_color']; } } //Calculate bar progress $out .= "<div class='center' style='background-color: #ffffff; width: 100%;\n border: 1px solid #9BA563;' >"; $out .= "<div style='position:absolute;'> " . $percentage_text . "%</div>"; $out .= "<div class='center' style='background-color: " . $color . ";\n width: " . $percentage . "%; height: 12px' ></div>"; $out .= "</div>"; return $out; } break; case "glpi_softwarelicenses.number": if ($data[$NAME . $num . "_2"] == -1) { return __('Unlimited'); } if (empty($data[$NAME . $num])) { return 0; } return $data[$NAME . $num]; case "glpi_auth_tables.name": return Auth::getMethodName($data[$NAME . $num], $data[$NAME . $num . "_2"], 1, $data[$NAME . $num . "_3"] . $data[$NAME . $num . "_4"]); case "glpi_reservationitems.comment": if (empty($data[$NAME . $num])) { return "<a title=\"" . __s('Modify the comment') . "\"\n href='" . $CFG_GLPI["root_doc"] . "/front/reservationitem.form.php?id=" . $data["refID"] . "' >" . __('None') . "</a>"; } return "<a title=\"" . __s('Modify the comment') . "\"\n href='" . $CFG_GLPI["root_doc"] . "/front/reservationitem.form.php?id=" . $data['refID'] . "' >" . Html::resume_text($data[$NAME . $num]) . "</a>"; case 'glpi_notifications.mode': return Notification::getMode($data[$NAME . $num]); case 'glpi_notifications.event': $item = NotificationTarget::getInstanceByType($data['itemtype']); if ($item) { $events = $item->getAllEvents(); if (isset($events[$data[$NAME . $num]])) { return $events[$data[$NAME . $num]]; } } return ''; case 'glpi_reminders.state': return Planning::getState($data[$NAME . $num]); case 'glpi_crontasks.description': $tmp = new CronTask(); return $tmp->getDescription($data['id']); case 'glpi_crontasks.state': return CronTask::getStateName($data[$NAME . $num]); case 'glpi_crontasks.mode': return CronTask::getModeName($data[$NAME . $num]); case 'glpi_crontasks.itemtype': if ($plug = isPluginItemType($data[$NAME . $num])) { return $plug['plugin']; } return ''; case 'glpi_changes.status': $status = Change::getStatus($data[$NAME . $num]); return "<img src=\"" . Change::getStatusIconURL($data[$NAME . $num]) . "\"\n alt=\"{$status}\" title=\"{$status}\"> {$status}"; case 'glpi_problems.status': $status = Problem::getStatus($data[$NAME . $num]); return "<img src=\"" . Problem::getStatusIconURL($data[$NAME . $num]) . "\"\n alt=\"{$status}\" title=\"{$status}\"> {$status}"; case 'glpi_tickets.status': $status = Ticket::getStatus($data[$NAME . $num]); return "<img src=\"" . Ticket::getStatusIconURL($data[$NAME . $num]) . "\"\n alt=\"{$status}\" title=\"{$status}\"> {$status}"; case 'glpi_tickets.items_id': if (!empty($data[$NAME . $num . "_2"]) && ($item = getItemForItemtype($data[$NAME . $num . "_2"]))) { if ($item->getFromDB($data[$NAME . $num])) { return $item->getLink(array('comments' => true)); } } return ' '; case 'glpi_tickets.name': if (isset($searchopt[$ID]['forcegroupby']) && $searchopt[$ID]['forcegroupby']) { $split = explode("\$\$\$\$", $data[$NAME . $num]); $out = ''; $link = Toolbox::getItemTypeFormURL('Ticket'); foreach ($split as $val) { if (!empty($val)) { $split2 = self::explodeWithID("\$\$", $val); $out .= "<a id='ticket" . $split2[1] . "' href=\"" . $link; $out .= strstr($link, '?') ? '&' : '?'; $out .= 'id=' . $split2[1]; $out .= "\">"; $name = $split2[0]; if ($_SESSION["glpiis_ids_visible"] || empty($split2[0])) { $name = sprintf(__('%1$s (%2$s)'), $name, $split2[1]); } $out .= $name . "</a><br>"; } } return $out; } $link = Toolbox::getItemTypeFormURL('Ticket'); $out = "<a id='ticket" . $data[$NAME . $num . "_2"] . "' href=\"" . $link; $out .= strstr($link, '?') ? '&' : '?'; $out .= 'id=' . $data[$NAME . $num . "_2"]; // Force solution tab if solved if ($data[$NAME . $num . "_4"] == CommonITILObject::SOLVED) { $out .= "&forcetab=Ticket\$2"; } $out .= "\">"; $name = $data[$NAME . $num]; if ($_SESSION["glpiis_ids_visible"] || empty($data[$NAME . $num])) { $name = sprintf(__('%1$s (%2$s)'), $name, $data[$NAME . $num . "_2"]); } $out .= $name . "</a>"; $out = sprintf(__('%1$s %2$s'), $out, Html::showToolTip(nl2br($data[$NAME . $num . "_3"]), array('applyto' => 'ticket' . $data[$NAME . $num . "_2"], 'display' => false))); return $out; case 'glpi_ticketvalidations.status': $split = explode("\$\$\$\$", $data[$NAME . $num]); $out = ''; foreach ($split as $val) { if (!empty($val)) { $split2 = self::explodeWithID("\$\$", $val); $status = TicketValidation::getStatus($split2[0]); $bgcolor = TicketValidation::getStatusColor($split2[0]); $out .= (empty($out) ? '' : '<br>') . "<div style=\"background-color:" . $bgcolor . ";\">" . $status . '</div>'; } } return $out; case 'glpi_ticketsatisfactions.type': return TicketSatisfaction::getTypeInquestName($data[$NAME . $num]); case 'glpi_ticketsatisfactions.satisfaction': return TicketSatisfaction::displaySatisfaction($data[$NAME . $num]); case 'glpi_notimportedemails.reason': return NotImportedEmail::getReason($data[$NAME . $num]); case 'glpi_notimportedemails.messageid': $clean = array('<' => '', '>' => ''); return strtr($data[$NAME . $num], $clean); } //// Default case // Link with plugin tables : need to know left join structure if (preg_match("/^glpi_plugin_([a-z0-9]+)/", $table . '.' . $field, $matches)) { if (count($matches) == 2) { $plug = $matches[1]; $function = 'plugin_' . $plug . '_giveItem'; if (function_exists($function)) { $out = $function($itemtype, $ID, $data, $num); if (!empty($out)) { return $out; } } } } $unit = ''; if (isset($searchopt[$ID]['unit'])) { $unit = $searchopt[$ID]['unit']; } /// TODO try to use getvalueToDisplay instead of redefine display system // Preformat items if (isset($searchopt[$ID]["datatype"])) { switch ($searchopt[$ID]["datatype"]) { case "itemlink": $linkitemtype = getItemTypeForTable($searchopt[$ID]["table"]); if (isset($data[$NAME . $num . "_2"]) && strlen($data[$NAME . $num . "_2"])) { $link = Toolbox::getItemTypeFormURL($linkitemtype); $out = "<a id='" . $itemtype . "_" . $data[$NAME . $num . "_2"] . "' href=\"" . $link; $out .= strstr($link, '?') ? '&' : '?'; $out .= 'id=' . $data[$NAME . $num . "_2"]; if (isset($searchopt[$ID]['forcetab'])) { $out .= "&forcetab=" . $searchopt[$ID]['forcetab']; } $out .= "\">"; $name = Dropdown::getValueWithUnit($data[$NAME . $num], $unit); if ($_SESSION["glpiis_ids_visible"] || empty($data[$NAME . $num])) { $name = sprintf(__('%1$s (%2$s)'), $name, $data[$NAME . $num . "_2"]); } $out .= $name . "</a>"; return $out; } $out = ""; $split = explode("\$\$\$\$", $data[$NAME . $num]); $count_display = 0; $separate = '<br>'; if (isset($searchopt[$ID]['splititems']) && $searchopt[$ID]['splititems']) { $separate = '<hr>'; } for ($k = 0; $k < count($split); $k++) { if (strlen(trim($split[$k])) > 0) { $split2 = self::explodeWithID("\$\$", $split[$k]); if (isset($split2[1]) && $split2[1] > 0) { if ($count_display) { $out .= $separate; } $count_display++; $page = Toolbox::getItemTypeFormURL($linkitemtype); $page .= strpos($page, '?') ? '&id' : '?id'; $name = Dropdown::getValueWithUnit($split2[0], $unit); if ($_SESSION["glpiis_ids_visible"] || empty($split2[0])) { $name = sprintf(__('%1$s (%2$s)'), $name, $split2[1]); } $out .= "<a id='" . $linkitemtype . "_" . $data['id'] . "_" . $split2[1] . "' href='{$page}=" . $split2[1] . "'>" . $name . "</a>"; } } } return $out; case "text": $separate = '<br>'; if (isset($searchopt[$ID]['splititems']) && $searchopt[$ID]['splititems']) { $separate = '<hr>'; } $split = explode("\$\$\$\$", $data[$NAME . $num]); $out = ''; $count_display = 0; foreach ($split as $val) { if (strlen(trim($val)) > 0) { $split2 = self::explodeWithID("\$\$", $val); if ($count_display) { $out .= $separate; } $count_display++; if (isset($searchopt[$ID]['htmltext']) && $searchopt[$ID]['htmltext']) { $text = Html::clean(Toolbox::unclean_cross_side_scripting_deep(nl2br($split2[0]))); } else { $text = nl2br($split2[0]); } if (self::$output_type == self::HTML_OUTPUT && Toolbox::strlen($text) > $CFG_GLPI['cut']) { $rand = mt_rand(); $out .= sprintf(__('%1$s %2$s'), "<span id='text{$rand}'>" . Html::resume_text($text, $CFG_GLPI['cut']) . '</span>', Html::showToolTip($text, array('applyto' => "text{$rand}", 'display' => false))); } else { $out .= $text; } } } return $out; case "date": case "date_delay": $split = explode("\$\$\$\$", $data[$NAME . $num]); $out = ''; foreach ($split as $val) { $out .= (empty($out) ? '' : '<br>') . Html::convDate($val); } return $out; case "datetime": $split = explode("\$\$\$\$", $data[$NAME . $num]); $out = ''; foreach ($split as $val) { $out .= (empty($out) ? '' : '<br>') . Html::convDateTime($val); } return $out; case "timestamp": $withseconds = false; if (isset($searchopt[$ID]['withseconds'])) { $withseconds = $searchopt[$ID]['withseconds']; } $withdays = true; if (isset($searchopt[$ID]['withdays'])) { $withdays = $searchopt[$ID]['withdays']; } $split = explode("\$\$\$\$", $data[$NAME . $num]); $out = ''; foreach ($split as $val) { $out .= (empty($out) ? '' : '<br>') . Html::timestampToString($val, $withseconds, $withdays); } return $out; case "email": $split = explode('$$$$', $data[$NAME . $num]); $out = ''; $count_display = 0; foreach ($split as $val) { $split2 = self::explodeWithID("\$\$", $val); if ($count_display) { $out .= "<br>"; } $count_display++; if (!empty($val)) { $out .= empty($out) ? '' : '<br>'; $out .= "<a href='mailto:{$split2['0']}'>{$split2['0']}</a>"; } } return empty($out) ? " " : $out; case "weblink": $orig_link = trim($data[$NAME . $num]); if (!empty($orig_link)) { // strip begin of link $link = preg_replace('/https?:\\/\\/(www[^\\.]*\\.)?/', '', $orig_link); $link = preg_replace('/\\/$/', '', $link); if (Toolbox::strlen($link) > $CFG_GLPI["url_maxlength"]) { $link = Toolbox::substr($link, 0, $CFG_GLPI["url_maxlength"]) . "..."; } return "<a href=\"" . formatOutputWebLink($orig_link) . "\" target='_blank'>{$link}</a>"; } return " "; case "number": if (isset($searchopt[$ID]['forcegroupby']) && $searchopt[$ID]['forcegroupby']) { $out = ""; $split = explode("\$\$\$\$", $data[$NAME . $num]); $count_display = 0; for ($k = 0; $k < count($split); $k++) { if (strlen(trim($split[$k])) > 0) { $split2 = self::explodeWithID("\$\$", $split[$k]); if ($count_display) { $out .= "<br>"; } $count_display++; if (isset($searchopt[$ID]['toadd']) && isset($searchopt[$ID]['toadd'][$split2[0]])) { $out .= $searchopt[$ID]['toadd'][$split2[0]]; } else { $number = str_replace(' ', ' ', Html::formatNumber($split2[0], false, 0)); $out .= Dropdown::getValueWithUnit($number, $unit); } } } return $out; } if (isset($searchopt[$ID]['toadd']) && isset($searchopt[$ID]['toadd'][$data[$NAME . $num]])) { return $searchopt[$ID]['toadd'][$data[$NAME . $num]]; } else { $number = str_replace(' ', ' ', Html::formatNumber($data[$NAME . $num], false, 0)); return Dropdown::getValueWithUnit($number, $unit); } case "decimal": if (isset($searchopt[$ID]['forcegroupby']) && $searchopt[$ID]['forcegroupby']) { $out = ""; $split = explode("\$\$\$\$", $data[$NAME . $num]); $count_display = 0; for ($k = 0; $k < count($split); $k++) { if (strlen(trim($split[$k])) > 0) { $split2 = self::explodeWithID("\$\$", $split[$k]); if ($count_display) { $out .= "<br>"; } $count_display++; if (isset($searchopt[$ID]['toadd']) && isset($searchopt[$ID]['toadd'][$split2[0]])) { $out .= $searchopt[$ID]['toadd'][$split2[0]]; } else { $number = str_replace(' ', ' ', Html::formatNumber($split2[0])); $out .= Dropdown::getValueWithUnit($number, $unit); } } } return $out; } $number = str_replace(' ', ' ', Html::formatNumber($data[$NAME . $num])); return Dropdown::getValueWithUnit($number, $unit); case "bool": if (isset($searchopt[$ID]['forcegroupby']) && $searchopt[$ID]['forcegroupby']) { $out = ""; $split = explode("\$\$\$\$", $data[$NAME . $num]); $count_display = 0; for ($k = 0; $k < count($split); $k++) { if (strlen(trim($split[$k])) > 0) { $split2 = self::explodeWithID("\$\$", $split[$k]); if ($count_display) { $out .= "<br>"; } $count_display++; $out .= Dropdown::getValueWithUnit(Dropdown::getYesNo($split2[0]), $unit); } } return $out; } return Dropdown::getValueWithUnit(Dropdown::getYesNo($data[$NAME . $num]), $unit); case "right": return Profile::getRightValue($data[$NAME . $num]); case "itemtypename": if ($obj = getItemForItemtype($data[$NAME . $num])) { return $obj->getTypeName(); } return ""; case "language": if (isset($CFG_GLPI['languages'][$data[$NAME . $num]])) { return $CFG_GLPI['languages'][$data[$NAME . $num]][0]; } return __('Default value'); } } // Manage items with need group by / group_concat if (isset($searchopt[$ID]['forcegroupby']) && $searchopt[$ID]['forcegroupby']) { $out = ""; $split = explode("\$\$\$\$", $data[$NAME . $num]); $count_display = 0; $separate = '<br>'; if (isset($searchopt[$ID]['splititems']) && $searchopt[$ID]['splititems']) { $separate = '<hr>'; } for ($k = 0; $k < count($split); $k++) { if (strlen(trim($split[$k])) > 0) { if ($count_display) { $out .= $separate; } $withoutid = self::explodeWithID("\$\$", $split[$k]); $count_display++; // Get specific display if available $itemtype = getItemTypeForTable($table); if ($item = getItemForItemtype($itemtype)) { $tmpdata = array($field => $withoutid[0]); $specific = $item->getSpecificValueToDisplay($field, $tmpdata, array('html' => true)); } if (!empty($specific)) { $out .= $specific; } else { $out .= Dropdown::getValueWithUnit($withoutid[0], $unit); } } } return $out; } // Get specific display if available $itemtype = getItemTypeForTable($table); if ($item = getItemForItemtype($itemtype)) { $tmpdata = array($field => $data[$NAME . $num]); if (isset($searchopt[$ID]['additionalfields']) && count($searchopt[$ID]['additionalfields'])) { foreach ($searchopt[$ID]['additionalfields'] as $key) { $tmpdata[$key] = $data[$NAME . $num . '_' . $key]; } } $specific = $item->getSpecificValueToDisplay($field, $tmpdata, array('html' => true)); if (!empty($specific)) { return $specific; } } // Manage auto CONCAT id $split = self::explodeWithID('$$', $data[$NAME . $num]); $split[0] = trim($split[0]); if (isset($searchopt[$ID]['toadd']) && isset($searchopt[$ID]['toadd'][$split[0]])) { return $searchopt[$ID]['toadd'][$split[0]]; } // Empty is 0 or empty if (empty($split[0]) && isset($searchopt[$ID]['emptylabel'])) { return $searchopt[$ID]['emptylabel']; } return Dropdown::getValueWithUnit($split[0], $unit); }
/** * @param $itemtype * @param $type * @param $date1 * @param $date2 * @param $start * @param $value array * @param $value2 (default '') * * @since version 0.85 (before show with same parameters) **/ static function showTable($itemtype, $type, $date1, $date2, $start, array $value, $value2 = "") { global $CFG_GLPI; // Set display type for export if define $output_type = Search::HTML_OUTPUT; if (isset($_GET["display_type"])) { $output_type = $_GET["display_type"]; } if ($output_type == Search::HTML_OUTPUT) { // HTML display echo "<div class ='center'>"; } if (is_array($value)) { $end_display = $start + $_SESSION['glpilist_limit']; $numrows = count($value); if (isset($_GET['export_all'])) { $start = 0; $end_display = $numrows; } $nbcols = 8; if ($output_type != Search::HTML_OUTPUT) { // not HTML display $nbcols--; } echo Search::showHeader($output_type, $end_display - $start + 1, $nbcols); $subname = ''; switch ($type) { case 'group_tree': case 'groups_tree_assign': $subname = Dropdown::getDropdownName('glpi_groups', $value2); break; case 'itilcategories_tree': $subname = Dropdown::getDropdownName('glpi_itilcategories', $value2); break; case 'locations_tree': $subname = Dropdown::getDropdownName('glpi_locations', $value2); break; } if ($output_type == Search::HTML_OUTPUT) { // HTML display echo Search::showNewLine($output_type); $header_num = 1; if ($output_type == Search::HTML_OUTPUT && strstr($type, '_tree') && $value2) { // HTML display $link = $_SERVER['PHP_SELF'] . "?date1={$date1}&date2={$date2}&itemtype={$itemtype}&type={$type}" . "&value2=0"; $link = "<a href='{$link}'>" . __('Back') . "</a>"; echo Search::showHeaderItem($output_type, $link, $header_num); } else { echo Search::showHeaderItem($output_type, " ", $header_num); } echo Search::showHeaderItem($output_type, '', $header_num); echo Search::showHeaderItem($output_type, _x('quantity', 'Number'), $header_num, '', 0, '', "colspan='4'"); if ($itemtype == 'Ticket') { echo Search::showHeaderItem($output_type, __('Satisfaction'), $header_num, '', 0, '', "colspan='3'"); } echo Search::showHeaderItem($output_type, __('Average time'), $header_num, '', 0, '', $itemtype == 'Ticket' ? "colspan='3'" : "colspan='2'"); echo Search::showHeaderItem($output_type, __('Real duration of treatment of the ticket'), $header_num, '', 0, '', "colspan='2'"); } echo Search::showNewLine($output_type); $header_num = 1; echo Search::showHeaderItem($output_type, $subname, $header_num); if ($output_type == Search::HTML_OUTPUT) { // HTML display echo Search::showHeaderItem($output_type, "", $header_num); } if ($output_type != Search::HTML_OUTPUT) { echo Search::showHeaderItem($output_type, __('Number of opened tickets'), $header_num); echo Search::showHeaderItem($output_type, __('Number of solved tickets'), $header_num); echo Search::showHeaderItem($output_type, __('Number of late tickets'), $header_num); echo Search::showHeaderItem($output_type, __('Number of closed tickets'), $header_num); } else { echo Search::showHeaderItem($output_type, _nx('ticket', 'Opened', 'Opened', Session::getPluralNumber()), $header_num); echo Search::showHeaderItem($output_type, _nx('ticket', 'Solved', 'Solved', Session::getPluralNumber()), $header_num); echo Search::showHeaderItem($output_type, __('Late'), $header_num); echo Search::showHeaderItem($output_type, __('Closed'), $header_num); } if ($itemtype == 'Ticket') { if ($output_type != Search::HTML_OUTPUT) { echo Search::showHeaderItem($output_type, __('Number of opened satisfaction survey'), $header_num); echo Search::showHeaderItem($output_type, __('Number of answered satisfaction survey'), $header_num); echo Search::showHeaderItem($output_type, __('Average satisfaction'), $header_num); } else { echo Search::showHeaderItem($output_type, _nx('survey', 'Opened', 'Opened', Session::getPluralNumber()), $header_num); echo Search::showHeaderItem($output_type, _nx('survey', 'Answered', 'Answered', Session::getPluralNumber()), $header_num); echo Search::showHeaderItem($output_type, __('Average'), $header_num); } } if ($output_type != Search::HTML_OUTPUT) { if ($itemtype == 'Ticket') { echo Search::showHeaderItem($output_type, __('Average time to take into account'), $header_num); } echo Search::showHeaderItem($output_type, __('Average time to resolution'), $header_num); echo Search::showHeaderItem($output_type, __('Average time to closure'), $header_num); } else { if ($itemtype == 'Ticket') { echo Search::showHeaderItem($output_type, __('Take into account'), $header_num); } echo Search::showHeaderItem($output_type, __('Resolution'), $header_num); echo Search::showHeaderItem($output_type, __('Closure'), $header_num); } if ($output_type != Search::HTML_OUTPUT) { echo Search::showHeaderItem($output_type, __('Average real duration of treatment of the ticket'), $header_num); echo Search::showHeaderItem($output_type, __('Total real duration of treatment of the ticket'), $header_num); } else { echo Search::showHeaderItem($output_type, __('Average'), $header_num); echo Search::showHeaderItem($output_type, __('Total duration'), $header_num); } // End Line for column headers echo Search::showEndLine($output_type); $row_num = 1; for ($i = $start; $i < $numrows && $i < $end_display; $i++) { $row_num++; $item_num = 1; echo Search::showNewLine($output_type, $i % 2); if ($output_type == Search::HTML_OUTPUT && strstr($type, '_tree') && $value[$i]['id'] != $value2) { // HTML display $link = $_SERVER['PHP_SELF'] . "?date1={$date1}&date2={$date2}&itemtype={$itemtype}&type={$type}" . "&value2=" . $value[$i]['id']; $link = "<a href='{$link}'>" . $value[$i]['link'] . "</a>"; echo Search::showItem($output_type, $link, $item_num, $row_num); } else { echo Search::showItem($output_type, $value[$i]['link'], $item_num, $row_num); } if ($output_type == Search::HTML_OUTPUT) { // HTML display $link = ""; if ($value[$i]['id'] > 0) { $link = "<a href='stat.graph.php?id=" . $value[$i]['id'] . "&date1={$date1}&date2={$date2}&itemtype={$itemtype}&type={$type}" . (!empty($value2) ? "&champ={$value2}" : "") . "'>" . "<img src='" . $CFG_GLPI["root_doc"] . "/pics/stats_item.png' alt='' title=''>" . "</a>"; } echo Search::showItem($output_type, $link, $item_num, $row_num); } //le nombre d'intervention - the number of intervention $opened = self::constructEntryValues($itemtype, "inter_total", $date1, $date2, $type, $value[$i]["id"], $value2); $nb_opened = array_sum($opened); echo Search::showItem($output_type, $nb_opened, $item_num, $row_num); //le nombre d'intervention resolues - the number of solved intervention $solved = self::constructEntryValues($itemtype, "inter_solved", $date1, $date2, $type, $value[$i]["id"], $value2); $nb_solved = array_sum($solved); // if (($nb_opened > 0) // && ($nb_solved > 0)) { // //TRANS: %2$d is the percentage. %% to display % // $nb_solved = sprintf(__('%1$s (%2$d%%)'), $nb_solved, // round($nb_solved*100/$nb_opened)); // } echo Search::showItem($output_type, $nb_solved, $item_num, $row_num); //le nombre d'intervention resolues - the number of solved intervention $solved_late = self::constructEntryValues($itemtype, "inter_solved_late", $date1, $date2, $type, $value[$i]["id"], $value2); $nb_solved_late = array_sum($solved_late); // if (($nb_solved > 0) // && ($nb_solved_late > 0)) { // $nb_solved_late = sprintf(__('%1$s (%2$d%%)'), $nb_solved_late, // round($nb_solved_late*100/$nb_solved)); // } echo Search::showItem($output_type, $nb_solved_late, $item_num, $row_num); //le nombre d'intervention closes - the number of closed intervention $closed = self::constructEntryValues($itemtype, "inter_closed", $date1, $date2, $type, $value[$i]["id"], $value2); $nb_closed = array_sum($closed); // if (($nb_opened > 0) // && ($nb_closed > 0)) { // $nb_closed = sprintf(__('%1$s (%2$d%%)'), $nb_closed, // round($nb_closed*100/$nb_opened)); // } echo Search::showItem($output_type, $nb_closed, $item_num, $row_num); if ($itemtype == 'Ticket') { //Satisfaction open $opensatisfaction = self::constructEntryValues($itemtype, "inter_opensatisfaction", $date1, $date2, $type, $value[$i]["id"], $value2); $nb_opensatisfaction = array_sum($opensatisfaction); // if ($nb_opensatisfaction > 0) { // $nb_opensatisfaction = sprintf(__('%1$s (%2$d%%)'), $nb_opensatisfaction, // round($nb_opensatisfaction*100/$nb_closed)); // } echo Search::showItem($output_type, $nb_opensatisfaction, $item_num, $row_num); //Satisfaction answer $answersatisfaction = self::constructEntryValues($itemtype, "inter_answersatisfaction", $date1, $date2, $type, $value[$i]["id"], $value2); $nb_answersatisfaction = array_sum($answersatisfaction); // if ($nb_answersatisfaction > 0) { // $nb_answersatisfaction = sprintf(__('%1$s (%2$d%%)'), $nb_answersatisfaction, // round($nb_answersatisfaction*100/$nb_opensatisfaction)); // } echo Search::showItem($output_type, $nb_answersatisfaction, $item_num, $row_num); //Satisfaction rate $satisfaction = self::constructEntryValues($itemtype, "inter_avgsatisfaction", $date1, $date2, $type, $value[$i]["id"], $value2); foreach ($satisfaction as $key2 => $val2) { $satisfaction[$key2] *= $answersatisfaction[$key2]; } if ($nb_answersatisfaction > 0) { $avgsatisfaction = round(array_sum($satisfaction) / $nb_answersatisfaction, 1); $avgsatisfaction = TicketSatisfaction::displaySatisfaction($avgsatisfaction); } else { $avgsatisfaction = ' '; } echo Search::showItem($output_type, $avgsatisfaction, $item_num, $row_num); //Le temps moyen de prise en compte du ticket - The average time to take a ticket into account $data = self::constructEntryValues($itemtype, "inter_avgtakeaccount", $date1, $date2, $type, $value[$i]["id"], $value2); foreach ($data as $key2 => $val2) { $data[$key2] *= $solved[$key2]; } if ($nb_solved > 0) { $timedisplay = array_sum($data) / $nb_solved; } else { $timedisplay = 0; } if ($output_type == Search::HTML_OUTPUT || $output_type == Search::PDF_OUTPUT_LANDSCAPE || $output_type == Search::PDF_OUTPUT_PORTRAIT) { $timedisplay = Html::timestampToString($timedisplay, 0, false); } echo Search::showItem($output_type, $timedisplay, $item_num, $row_num); } //Le temps moyen de resolution - The average time to resolv $data = self::constructEntryValues($itemtype, "inter_avgsolvedtime", $date1, $date2, $type, $value[$i]["id"], $value2); foreach ($data as $key2 => $val2) { $data[$key2] = round($data[$key2] * $solved[$key2]); } if ($nb_solved > 0) { $timedisplay = array_sum($data) / $nb_solved; } else { $timedisplay = 0; } if ($output_type == Search::HTML_OUTPUT || $output_type == Search::PDF_OUTPUT_LANDSCAPE || $output_type == Search::PDF_OUTPUT_PORTRAIT) { $timedisplay = Html::timestampToString($timedisplay, 0, false); } echo Search::showItem($output_type, $timedisplay, $item_num, $row_num); //Le temps moyen de cloture - The average time to close $data = self::constructEntryValues($itemtype, "inter_avgclosedtime", $date1, $date2, $type, $value[$i]["id"], $value2); foreach ($data as $key2 => $val2) { $data[$key2] = round($data[$key2] * $solved[$key2]); } if ($nb_closed > 0) { $timedisplay = array_sum($data) / $nb_closed; } else { $timedisplay = 0; } if ($output_type == Search::HTML_OUTPUT || $output_type == Search::PDF_OUTPUT_LANDSCAPE || $output_type == Search::PDF_OUTPUT_PORTRAIT) { $timedisplay = Html::timestampToString($timedisplay, 0, false); } echo Search::showItem($output_type, $timedisplay, $item_num, $row_num); //Le temps moyen de l'intervention reelle - The average actiontime to resolv $data = self::constructEntryValues($itemtype, "inter_avgactiontime", $date1, $date2, $type, $value[$i]["id"], $value2); foreach ($data as $key2 => $val2) { if (isset($solved[$key2])) { $data[$key2] *= $solved[$key2]; } else { $data[$key2] *= 0; } } $total_actiontime = array_sum($data); if ($nb_solved > 0) { $timedisplay = $total_actiontime / $nb_solved; } else { $timedisplay = 0; } if ($output_type == Search::HTML_OUTPUT || $output_type == Search::PDF_OUTPUT_LANDSCAPE || $output_type == Search::PDF_OUTPUT_PORTRAIT) { $timedisplay = Html::timestampToString($timedisplay, 0, false); } echo Search::showItem($output_type, $timedisplay, $item_num, $row_num); //Le temps total de l'intervention reelle - The total actiontime to resolv $timedisplay = $total_actiontime; if ($output_type == Search::HTML_OUTPUT || $output_type == Search::PDF_OUTPUT_LANDSCAPE || $output_type == Search::PDF_OUTPUT_PORTRAIT) { $timedisplay = Html::timestampToString($timedisplay, 0, false); } echo Search::showItem($output_type, $timedisplay, $item_num, $row_num); echo Search::showEndLine($output_type); } // Display footer echo Search::showFooter($output_type); } else { _e('No statistics are available'); } if ($output_type == Search::HTML_OUTPUT) { // HTML display echo "</div>"; } }
/** * @param $field * @param $values * @param $options array **/ static function getSpecificValueToDisplay($field, $values, array $options = array()) { if (!is_array($values)) { $values = array($field => $values); } switch ($field) { case 'refresh_rate': return Html::timestampToString($values[$field], false); } return parent::getSpecificValueToDisplay($field, $values, $options); }
function displayMessage($msg) { $msg .= " (" . Html::timestampToString(time() - $this->deb) . ")"; echo str_pad($msg, 100) . "\r"; }
static function showForTicket(Ticket $ticket) { global $DB, $CFG_GLPI; echo "<table class='tab_cadre_fixe'>"; echo "<tr><th>" . __('Summary') . "</th></tr>"; echo "<tr class='tab_bg_1 center'><td>" . _n('Time range', 'Time ranges', 2) . " : "; $calendar = new Calendar(); $calendars_id = Entity::getUsedConfig('calendars_id', $ticket->fields['entities_id']); if ($calendars_id > 0 && $calendar->getFromDB($calendars_id)) { echo $calendar->getLink(); } else { echo NOT_AVAILABLE; } echo "</td></tr>"; PluginTimelineticketState::showHistory($ticket); // Display ticket have Due date if ($ticket->fields['due_date'] && $ticket->fields['status'] != CommonITILObject::WAITING && strtotime(date('Y-m-d H:i:s')) - strtotime($ticket->fields['due_date']) > 0) { $calendar = new Calendar(); $calendars_id = Entity::getUsedConfig('calendars_id', $ticket->fields['entities_id']); if ($calendars_id > 0 && $calendar->getFromDB($calendars_id)) { if ($ticket->fields['closedate']) { $dateend = $calendar->getActiveTimeBetween($ticket->fields['due_date'], $ticket->fields['closedate']); } else { $dateend = $calendar->getActiveTimeBetween($ticket->fields['due_date'], date('Y-m-d H:i:s')); } } else { // cas 24/24 - 7/7 if ($ticket->fields['closedate']) { $dateend = strtotime($ticket->fields['closedate']) - strtotime($ticket->fields['due_date']); } else { $dateend = strtotime(date('Y-m-d H:i:s')) - strtotime($ticket->fields['due_date']); } } echo "<tr>"; echo "<th>" . __('Late') . "</th>"; echo "</tr>"; echo "<tr>"; echo "<td align='center' class='tab_bg_2_2'>" . Html::timestampToString($dateend, true) . "</td>"; echo "</tr>"; } echo "</table>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr>"; echo "<th colspan='2'>" . __('Status') . "</th>"; echo "</tr>"; /* pChart library inclusions */ include GLPI_ROOT . "/plugins/timelineticket/lib/pChart2.1.4/class/pData.class.php"; include GLPI_ROOT . "/plugins/timelineticket/lib/pChart2.1.4/class/pDraw.class.php"; include GLPI_ROOT . "/plugins/timelineticket/lib/pChart2.1.4/class/pImage.class.php"; include GLPI_ROOT . "/plugins/timelineticket/lib/pChart2.1.4/class/pIndicator.class.php"; $a_data = PluginTimelineticketDisplay::getTotaltimeEnddate($ticket); $totaltime = $a_data['totaltime']; $end_date = $a_data['end_date']; $params = array('totaltime' => $totaltime, 'end_date' => $end_date); $ptState = new PluginTimelineticketState(); $ptState->showTimeline($ticket, $params); $ptAssignGroup = new PluginTimelineticketAssignGroup(); $ptAssignGroup->showTimeline($ticket, $params); $ptAssignUser = new PluginTimelineticketAssignUser(); $ptAssignUser->showTimeline($ticket, $params); echo "</table>"; PluginTimelineticketToolbox::ShowDetail($ticket, 'group'); PluginTimelineticketToolbox::ShowDetail($ticket, 'user'); }