- Fixed Trac #177: Icons for everything ! For Incidents, User Requests and Changes the icon depends on the state of the object.

SVN:trunk[762]
This commit is contained in:
Denis Flaven
2010-09-05 09:13:28 +00:00
parent b49373b959
commit 573e7f4e31
21 changed files with 231 additions and 4 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@@ -41,6 +41,7 @@ abstract class Change extends Ticket
"db_key_field" => "id",
"db_finalclass_field" => "",
"display_template" => "",
"icon" => "../modules/itop-change-mgmt-1.0.0/images/change.png",
);
MetaModel::Init_Params($aParams);
MetaModel::Init_InheritAttributes();
@@ -296,6 +297,55 @@ abstract class Change extends Ticket
$sName = sprintf('C-%06d', $iKey);
$this->Set('ref', $sName);
}
/**
* Get the icon representing this object
* @param boolean $bImgTag If true the result is a full IMG tag (or an emtpy string if no icon is defined)
* @return string Either the full IMG tag ($bImgTag == true) or just the path to the icon file
*/
public function GetIcon($bImgTag = true)
{
$sStatus = $this->Get('status');
switch($this->GetState())
{
case 'approved':
case 'implemented':
case 'monitored':
$sIconName = self::MakeIconFromName('change-approved.png');
break;
case 'rejected':
case 'notapproved':
$sIconName = self::MakeIconFromName('change-rejected.png');
break;
case 'closed':
$sIcon = self::MakeIconFromName('change-closed.png');
break;
default:
$sIcon = MetaModel::GetClassIcon(get_class($this), $bImgTag);
}
return $sIcon;
}
protected static function MakeIconFromName($sIconName, $bImgTag = true)
{
$sIcon = '';
if ($sIconName != '')
{
$sPath = '../modules/itop-change-mgmt-1.0.0/images/'.$sIconName;
if ($bImgTag)
{
$sIcon = "<img src=\"$sPath\" style=\"vertical-align:middle;\"/>";
}
else
{
$sIcon = $sPath;
}
}
return $sIcon;
}
}
class RoutineChange extends Change

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

View File

@@ -38,6 +38,7 @@ class Incident extends ResponseTicket
"db_key_field" => "id",
"db_finalclass_field" => "",
"display_template" => "",
"icon" => "../modules/itop-incident-mgmt-1.0.0/images/incident.png",
);
MetaModel::Init_Params($aParams);
MetaModel::Init_InheritAttributes();
@@ -93,6 +94,93 @@ class Incident extends ResponseTicket
}
parent::OnInsert();
}
/**
* Get the icon representing this object
* @param boolean $bImgTag If true the result is a full IMG tag (or an emtpy string if no icon is defined)
* @return string Either the full IMG tag ($bImgTag == true) or just the path to the icon file
*/
public function GetIcon($bImgTag = true)
{
$sStatus = $this->Get('status');
switch($this->GetState())
{
case 'escalated_tto':
case 'escalated_ttr':
$sIconName = self::MakeIconFromName('incident-escalated.png');
break;
case 'resolved':
case 'closed':
$sIcon = self::MakeIconFromName('incident-closed.png');
break;
case 'new':
$sIcon = self::MakeIconFromName('incident.png');
$oEscalationDeadline = $this->Get('tto_escalation_deadline');
if ($oEscalationDeadline != null)
{
// A SLA is running
$iStartDate = AttributeDateTime::GetAsUnixSeconds($this->Get('start_date'));
$iEscalationDeadline = AttributeDateTime::GetAsUnixSeconds($oEscalationDeadline);
$ratio = ($iEscalationDeadline - time())/($iEscalationDeadline - $iStartDate);
if ($ratio <= 0)
{
$sIcon = self::MakeIconFromName('incident-escalated.png');
}
else if ($ratio <= 0.25)
{
$sIcon = self::MakeIconFromName('incident-deadline.png');
}
}
break;
case 'assigned':
$sIcon = self::MakeIconFromName('incident.png');
$oEscalationDeadline = $this->Get('ttr_escalation_deadline');
if ($oEscalationDeadline != null)
{
// A SLA is running
$iStartDate = AttributeDateTime::GetAsUnixSeconds($this->Get('start_date'));
$iEscalationDeadline = AttributeDateTime::GetAsUnixSeconds($oEscalationDeadline);
$ratio = ($iEscalationDeadline - time())/($iEscalationDeadline - $iStartDate);
if ($ratio <= 0)
{
$sIcon = self::MakeIconFromName('incident-escalated.png');
}
else if ($ratio <= 0.25)
{
$sIcon = self::MakeIconFromName('incident-deadline.png');
}
}
break;
default:
$sIcon = MetaModel::GetClassIcon(get_class($this), $bImgTag);
}
return $sIcon;
}
protected static function MakeIconFromName($sIconName, $bImgTag = true)
{
$sIcon = '';
if ($sIconName != '')
{
$sPath = '../modules/itop-incident-mgmt-1.0.0/images/'.$sIconName;
if ($bImgTag)
{
$sIcon = "<img src=\"$sPath\" style=\"vertical-align:middle;\"/>";
}
else
{
$sIcon = $sPath;
}
}
return $sIcon;
}
}
class lnkTicketToIncident extends cmdbAbstractObject

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

@@ -46,6 +46,7 @@ class KnownError extends cmdbAbstractObject
"db_key_field" => "id",
"db_finalclass_field" => "",
"display_template" => "",
"icon" => "../modules/itop-knownerror-mgmt-1.0.0/images/known-error.png",
);
MetaModel::Init_Params($aParams);
MetaModel::Init_InheritAttributes();

View File

@@ -107,7 +107,7 @@ Dict::Add('EN US', 'English', 'English', array(
'Class:Problem/Attribute:impact/Value:2+' => '',
'Class:Problem/Attribute:impact/Value:3' => 'A Department',
'Class:Problem/Attribute:impact/Value:3+' => '',
'Class:Problem/Attribute:urgency' => 'urgency',
'Class:Problem/Attribute:urgency' => 'Urgency',
'Class:Problem/Attribute:urgency+' => '',
'Class:Problem/Attribute:urgency/Value:1' => 'Low',
'Class:Problem/Attribute:urgency/Value:1+' => 'Low',
@@ -115,7 +115,7 @@ Dict::Add('EN US', 'English', 'English', array(
'Class:Problem/Attribute:urgency/Value:2+' => 'Medium',
'Class:Problem/Attribute:urgency/Value:3' => 'High',
'Class:Problem/Attribute:urgency/Value:3+' => 'High',
'Class:Problem/Attribute:priority' => 'priority',
'Class:Problem/Attribute:priority' => 'Priority',
'Class:Problem/Attribute:priority+' => '',
'Class:Problem/Attribute:priority/Value:1' => 'Low',
'Class:Problem/Attribute:priority/Value:1+' => '',

View File

@@ -38,6 +38,7 @@ class Problem extends Ticket
"db_key_field" => "id",
"db_finalclass_field" => "",
"display_template" => "",
"icon" => "../modules/itop-problem-mgmt-1.0.0/images/problem.png",
);
MetaModel::Init_Params($aParams);
MetaModel::Init_InheritAttributes();

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@@ -38,6 +38,7 @@ class UserRequest extends ResponseTicket
"db_key_field" => "id",
"db_finalclass_field" => "",
"display_template" => "",
"icon" => "../modules/itop-request-mgmt-1.0.0/images/user-request.png",
);
MetaModel::Init_Params($aParams);
MetaModel::Init_InheritAttributes();
@@ -84,6 +85,92 @@ class UserRequest extends ResponseTicket
$this->Set('ref', $sName);
return parent::ComputeValues();
}
/**
* Get the icon representing this object
* @param boolean $bImgTag If true the result is a full IMG tag (or an emtpy string if no icon is defined)
* @return string Either the full IMG tag ($bImgTag == true) or just the path to the icon file
*/
public function GetIcon($bImgTag = true)
{
$sStatus = $this->Get('status');
switch($this->GetState())
{
case 'escalated_tto':
case 'escalated_ttr':
$sIconName = self::MakeIconFromName('user-request-escalated.png');
break;
case 'resolved':
case 'closed':
$sIcon = self::MakeIconFromName('user-request-closed.png');
break;
case 'new':
$sIcon = self::MakeIconFromName('user-request.png');
$oEscalationDeadline = $this->Get('tto_escalation_deadline');
if ($oEscalationDeadline != null)
{
// A SLA is running
$iStartDate = AttributeDateTime::GetAsUnixSeconds($this->Get('start_date'));
$iEscalationDeadline = AttributeDateTime::GetAsUnixSeconds($oEscalationDeadline);
$ratio = ($iEscalationDeadline - time())/($iEscalationDeadline - $iStartDate);
if ($ratio <= 0)
{
$sIcon = self::MakeIconFromName('user-request-escalated.png');
}
else if ($ratio <= 0.25)
{
$sIcon = self::MakeIconFromName('user-request-deadline.png');
}
}
break;
case 'assigned':
$sIcon = self::MakeIconFromName('user-request.png');
$oEscalationDeadline = $this->Get('ttr_escalation_deadline');
if ($oEscalationDeadline != null)
{
// A SLA is running
$iStartDate = AttributeDateTime::GetAsUnixSeconds($this->Get('start_date'));
$iEscalationDeadline = AttributeDateTime::GetAsUnixSeconds($oEscalationDeadline);
$ratio = ($iEscalationDeadline - time())/($iEscalationDeadline - $iStartDate);
if ($ratio <= 0)
{
$sIcon = self::MakeIconFromName('user-request-escalated.png');
}
else if ($ratio <= 0.25)
{
$sIcon = self::MakeIconFromName('user-request-deadline.png');
}
}
break;
default:
$sIcon = MetaModel::GetClassIcon(get_class($this), $bImgTag);
}
return $sIcon;
}
protected static function MakeIconFromName($sIconName, $bImgTag = true)
{
$sIcon = '';
if ($sIconName != '')
{
$sPath = '../modules/itop-request-mgmt-1.0.0/images/'.$sIconName;
if ($bImgTag)
{
$sIcon = "<img src=\"$sPath\" style=\"vertical-align:middle;\"/>";
}
else
{
$sIcon = $sPath;
}
}
return $sIcon;
}
}
$oMyMenuGroup = new MenuGroup('RequestManagement', 30 /* fRank */);

View File

@@ -49,7 +49,7 @@ Dict::Add('EN US', 'English', 'English', array(
'Class:Ticket/Attribute:ref+' => '',
'Class:Ticket/Attribute:title' => 'Title',
'Class:Ticket/Attribute:title+' => '',
'Class:Ticket/Attribute:description' => 'description',
'Class:Ticket/Attribute:description' => 'Description',
'Class:Ticket/Attribute:description+' => '',
'Class:Ticket/Attribute:ticket_log' => 'Log',
'Class:Ticket/Attribute:ticket_log+' => '',
@@ -255,7 +255,7 @@ Dict::Add('EN US', 'English', 'English', array(
'Class:ResponseTicket/Stimulus:ev_reassign+' => '',
'Class:ResponseTicket/Stimulus:ev_timeout' => 'Escalation',
'Class:ResponseTicket/Stimulus:ev_timeout+' => '',
'Class:ResponseTicket/Stimulus:ev_resolve' => 'Mark a resolved',
'Class:ResponseTicket/Stimulus:ev_resolve' => 'Mark as resolved',
'Class:ResponseTicket/Stimulus:ev_resolve+' => '',
'Class:ResponseTicket/Stimulus:ev_close' => 'Close',
'Class:ResponseTicket/Stimulus:ev_close+' => '',