Browse Source

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

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@762 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 15 năm trước cách đây
mục cha
commit
7fd72b85a4

BIN
modules/itop-change-mgmt-1.0.0/images/change-approved.png


BIN
modules/itop-change-mgmt-1.0.0/images/change-closed.png


BIN
modules/itop-change-mgmt-1.0.0/images/change-rejected.png


BIN
modules/itop-change-mgmt-1.0.0/images/change.png


+ 50 - 0
modules/itop-change-mgmt-1.0.0/model.itop-change-mgmt.php

@@ -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

BIN
modules/itop-config-mgmt-1.0.0/images/switch.png


BIN
modules/itop-incident-mgmt-1.0.0/images/incident-closed.png


BIN
modules/itop-incident-mgmt-1.0.0/images/incident-deadline.png


BIN
modules/itop-incident-mgmt-1.0.0/images/incident-escalated.png


BIN
modules/itop-incident-mgmt-1.0.0/images/incident.png


+ 88 - 0
modules/itop-incident-mgmt-1.0.0/model.itop-incident-mgmt.php

@@ -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

BIN
modules/itop-knownerror-mgmt-1.0.0/images/known-error.png


+ 1 - 0
modules/itop-knownerror-mgmt-1.0.0/model.itop-knownerror-mgmt.php

@@ -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();

+ 2 - 2
modules/itop-problem-mgmt-1.0.0/en.dict.itop-problem-mgmt.php

@@ -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+' => '',

+ 1 - 0
modules/itop-problem-mgmt-1.0.0/model.itop-problem-mgmt.php

@@ -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();

BIN
modules/itop-request-mgmt-1.0.0/images/user-request-closed.png


BIN
modules/itop-request-mgmt-1.0.0/images/user-request-deadline.png


BIN
modules/itop-request-mgmt-1.0.0/images/user-request-escalated.png


BIN
modules/itop-request-mgmt-1.0.0/images/user-request.png


+ 87 - 0
modules/itop-request-mgmt-1.0.0/model.itop-request-mgmt.php

@@ -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 */);

+ 2 - 2
modules/itop-tickets-1.0.0/en.dict.itop-tickets.php

@@ -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+' => '',