Commit d7c323ea authored by Johan Cwiklinski's avatar Johan Cwiklinski Committed by GitHub

Rework ITIL status display (#3820)

parent 1fe474f6
......@@ -5277,6 +5277,49 @@ input[name=as_map]:checked + label {
border: 1px transparent solid;
}
/** ITIL statuses */
.itilstatus {
font-size: 1.4em;
margin-right: .2em;
color: red;
background-color: transparent;
}
.itilstatus.assigned,
.itilstatus.new {
color: #49bf4d;
}
.itilstatus.accepted {
color: green;
}
.itilstatus.test,
.itilstatus.qualif,
.itilstatus.waiting {
color: orange;
}
.itilstatus.approval {
color: #8CABDB;
}
.itilstatus.eval {
color: lightblue;
}
.itilstatus.closed,
.itilstatus.solved,
.itilstatus.observe {
color: black;
}
.itilstatus.planned {
color: #1B2F62;
}
/** /ITIL statuses */
/** Responsive for documentation */
@media screen and (max-width: 900px) {
......
......@@ -873,6 +873,11 @@ class CommonGLPI {
}
echo "<td class='b big'>";
if (!self::isLayoutWithMain() || self::isLayoutExcludedPage()) {
if ($this instanceof CommonITILObject) {
echo "<span class='status'>";
echo $this->getStatusIcon($this->fields['status']);
echo "</span>";
}
echo $name;
}
echo "</td>";
......
......@@ -3259,12 +3259,76 @@ abstract class CommonITILObject extends CommonDBTM {
return $tab;
}
/**
* Get status icon
*
* @since 9.3
*
* @return string
*/
public static function getStatusIcon($status) {
$class = static::getStatusClass($status);
$label = static::getStatus($status);
return "<i class='$class' title='$label'></i>";
}
/**
* Get status class
*
* @since 9.3
*
* @return string
*/
public static function getStatusClass($status) {
$class = null;
switch ($status) {
case self::INCOMING :
$class = 'circle new';
break;
case self::ASSIGNED :
$class = 'circle-o assigned';
break;
case self::PLANNED :
$class = 'calendar planned';
break;
case self::WAITING :
$class = 'circle waiting';
break;
case self::SOLVED :
$class = 'circle-o solved';
break;
case self::CLOSED :
$class = 'circle closed';
break;
case self::ACCEPTED :
$class = 'check-circle accepted';
break;
case self::OBSERVED :
$class = 'eye observe';
break;
case self::EVALUATION :
$class = 'circle-o eval';
break;
case self::APPROVAL :
$class = 'question-circle approval';
break;
case self::TEST :
$class = 'question-circle test';
break;
case self::QUALIFICATION :
$class = 'circle-o qualif';
break;
}
return $class == null ? '' : 'itilstatus fa fa-' . $class;
}
/**
* Get status icon URL
*
* @since 0.84
*
* @deprecated 9.3
*
* @param $status status to get icon URL
*
* @return icon URL
......@@ -3272,6 +3336,8 @@ abstract class CommonITILObject extends CommonDBTM {
static function getStatusIconURL($status) {
global $CFG_GLPI;
Toolbox::deprecated("Use CommonITILObject::getStatusIcon()");
switch ($status) {
case self::INCOMING :
return $CFG_GLPI["root_doc"]."/pics/new.png";
......@@ -5217,9 +5283,7 @@ abstract class CommonITILObject extends CommonDBTM {
// First column
$first_col = sprintf(__('%1$s: %2$s'), __('ID'), $item->fields["id"]);
if ($p['output_type'] == Search::HTML_OUTPUT) {
$first_col .= "<br><img src='".static::getStatusIconURL($item->fields["status"])."'
alt=\"".static::getStatus($item->fields["status"])."\" title=\"".
static::getStatus($item->fields["status"])."\">";
$first_col .= static::getStatusIcon($item->fields["status"]);
} else {
$first_col = sprintf(__('%1$s - %2$s'), $first_col,
static::getStatus($item->fields["status"]));
......
......@@ -1132,9 +1132,7 @@ abstract class CommonITILTask extends CommonDBTM {
$html.= "<img src='".$CFG_GLPI["root_doc"]."/pics/rdv_interv.png' alt='' title=\"".
Html::entities_deep($parent->getTypeName(1))."\">&nbsp;&nbsp;";
$html.= "<img src='".$parent->getStatusIconURL($val["status"])."' alt='".
Html::entities_deep($parent->getStatus($val["status"]))."' title=\"".
Html::entities_deep($parent->getStatus($val["status"]))."\">";
$html.= $parent->getStatusIcon($val['status']);
$html.= "&nbsp;<a id='content_tracking_".$val["id"].$rand."'
href='".Toolbox::getItemTypeFormURL($parenttype)."?id=".$val[$parenttype_fk]."'
style='$styleText'>";
......
......@@ -4877,18 +4877,15 @@ class Search {
case 'glpi_changes.status':
$status = Change::getStatus($data[$num][0]['name']);
return "<img src=\"".Change::getStatusIconURL($data[$num][0]['name'])."\"
alt=\"$status\" title=\"$status\">&nbsp;$status";
return Change::getStatusIcon($data[$num][0]['name']) . "&nbsp;$status";
case 'glpi_problems.status':
$status = Problem::getStatus($data[$num][0]['name']);
return "<img src=\"".Problem::getStatusIconURL($data[$num][0]['name'])."\"
alt=\"$status\" title=\"$status\">&nbsp;$status";
return Problem::getStatusIcon($data[$num][0]['name']) . "&nbsp;$status";
case 'glpi_tickets.status':
$status = Ticket::getStatus($data[$num][0]['name']);
return "<img src=\"".Ticket::getStatusIconURL($data[$num][0]['name'])."\"
alt=\"$status\" title=\"$status\">&nbsp;$status";
return Ticket::getStatusIcon($data[$num][0]['name']) . "&nbsp;$status";
case 'glpi_projectstates.name':
$out = '';
......
......@@ -7492,7 +7492,7 @@ class Ticket extends CommonITILObject {
$html .= "<input type='radio' id='status_radio_$status_key$rand' name='_status'
$checked value='$status_key'>";
$html .= "<label for='status_radio_$status_key$rand'>";
$html .= "<img src='".Ticket::getStatusIconURL($status_key)."' />&nbsp;";
$html .= Ticket::getStatusIcon($status_key) . "&nbsp;";
$html .= $status_label;
$html .= "</label>";
$html .= "</li>";
......
......@@ -171,9 +171,7 @@ class Ticket_Ticket extends CommonDBRelation {
if (is_array($tickets) && count($tickets)) {
foreach ($tickets as $linkID => $data) {
if ($ticket->getFromDB($data['tickets_id'])) {
$icons = "<img src='".Ticket::getStatusIconURL($ticket->fields["status"]).
"' alt=\"".Ticket::getStatus($ticket->fields["status"])."\"
title=\"". Ticket::getStatus($ticket->fields["status"])."\">";
$icons = Ticket::getStatusIcon($ticket->fields['status']);
if ($canupdate) {
if ($tick->getFromDB($ID)
&& ($tick->fields['status'] != CommonITILObject::CLOSED)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment