New concept in the XML: HighlightScale to avoid overloading GetIcon and GetHilightClass...

SVN:trunk[3291]
This commit is contained in:
Denis Flaven
2014-07-28 15:16:16 +00:00
parent 357ae4abb1
commit fd9008a163
11 changed files with 604 additions and 581 deletions

View File

@@ -211,19 +211,27 @@
<field id="tto" xsi:type="AttributeStopWatch">
<always_load_in_tables>true</always_load_in_tables>
<states>
<state id="new"/>
<state id="escalated_tto"/>
<state id="new" />
<state id="escalated_tto" />
</states>
<working_time/>
<working_time />
<goal>ResponseTicketTTO</goal>
<thresholds>
<threshold>
<percent>75</percent>
<highlight>
<code>warning</code>
<persistent>false</persistent>
</highlight>
<actions>
</actions>
</actions>
</threshold>
<threshold>
<percent>100</percent>
<highlight>
<code>critical</code>
<persistent>false</persistent>
</highlight>
<actions>
<action>
<verb>ApplyStimulus</verb>
@@ -238,22 +246,30 @@
<field id="ttr" xsi:type="AttributeStopWatch">
<always_load_in_tables>true</always_load_in_tables>
<states>
<state id="new"/>
<state id="escalated_tto"/>
<state id="assigned"/>
<state id="approved"/>
<state id="escalated_ttr"/>
<state id="new" />
<state id="escalated_tto" />
<state id="assigned" />
<state id="approved" />
<state id="escalated_ttr" />
</states>
<working_time/>
<working_time />
<goal>ResponseTicketTTR</goal>
<thresholds>
<threshold>
<percent>75</percent>
<highlight>
<code>critical</code>
<persistent>false</persistent>
</highlight>
<actions>
</actions>
</actions>
</threshold>
<threshold>
<percent>100</percent>
<highlight>
<code>critical</code>
<persistent>false</persistent>
</highlight>
<actions>
<action>
<verb>ApplyStimulus</verb>
@@ -388,6 +404,23 @@
</field>
</fields>
<lifecycle>
<highlight_scale>
<item id="warning">
<rank>1</rank>
<color>HIGHLIGHT_CLASS_WARNING</color>
<icon>images/user-request-deadline.png</icon>
</item>
<item id="critical">
<rank>2</rank>
<color>HIGHLIGHT_CLASS_CRITICAL</color>
<icon>images/user-request-escalated.png</icon>
</item>
<item id="closed">
<rank>3</rank>
<color>HIGHLIGHT_CLASS_NONE</color>
<icon>images/user-request-closed.png</icon>
</item>
</highlight_scale>
<attribute>status</attribute>
<stimuli>
<stimulus id="ev_assign" xsi:type="StimulusUserAction"/>
@@ -523,6 +556,9 @@
</transitions>
</state>
<state id="escalated_tto">
<highlight>
<code>critical</code>
</highlight>
<flags>
<attribute id="ref">
<read_only/>
@@ -742,6 +778,9 @@
</transitions>
</state>
<state id="escalated_ttr">
<highlight>
<code>critical</code>
</highlight>
<flags>
<attribute id="ref">
<read_only/>
@@ -1254,6 +1293,9 @@
</transitions>
</state>
<state id="resolved">
<highlight>
<code>closed</code>
</highlight>
<flags>
<attribute id="ref">
<read_only/>
@@ -1404,6 +1446,9 @@
</transitions>
</state>
<state id="closed">
<highlight>
<code>closed</code>
</highlight>
<flags>
<attribute id="ref">
<read_only/>
@@ -1686,148 +1731,6 @@
}
}]]></code>
</method>
<method id="GetIcon">
<comment>/**&#13;
* Get the icon representing this object&#13;
* @param boolean $bImgTag If true the result is a full IMG tag (or an emtpy string if no icon is defined)&#13;
* @return string Either the full IMG tag ($bImgTag == true) or just the path to the icon file&#13;
*/</comment>
<static>false</static>
<access>public</access>
<type>Overload-DBObject</type>
<code><![CDATA[ public function GetIcon($bImgTag = true)
{
$sStatus = $this->Get('status');
switch($this->GetState())
{
case 'escalated_tto':
case 'escalated_ttr':
$sIcon = self::MakeIconFromName('user-request-escalated.png');
break;
case 'resolved':
case 'closed':
$sIcon = self::MakeIconFromName('user-request-closed.png');
break;
case 'new':
case 'approved':
$sIcon = self::MakeIconFromName('user-request.png');
$iEscalationDeadline = $this->Get('tto_escalation_deadline');
if ($iEscalationDeadline != null)
{
// A SLA is running
$oTTOStopWatch = $this->Get('tto');
if ($oTTOStopWatch->IsThresholdPassed(100))
{
$sIcon = self::MakeIconFromName('user-request-escalated.png');
}
else if ($oTTOStopWatch->IsThresholdPassed(75))
{
$sIcon = self::MakeIconFromName('user-request-deadline.png');
}
}
break;
case 'assigned':
$sIcon = self::MakeIconFromName('user-request.png');
$iEscalationDeadline = $this->Get('ttr_escalation_deadline');
if ($iEscalationDeadline != null)
{
// A SLA is running
$oTTRStopWatch = $this->Get('ttr');
if ($oTTRStopWatch->IsThresholdPassed(100))
{
$sIcon = self::MakeIconFromName('user-request-escalated.png');
}
else if ($oTTRStopWatch->IsThresholdPassed(75))
{
$sIcon = self::MakeIconFromName('user-request-deadline.png');
}
}
break;
default:
$sIcon = MetaModel::GetClassIcon(get_class($this), $bImgTag);
}
return $sIcon;
}]]></code>
</method>
<method id="MakeIconFromName">
<static>true</static>
<access>protected</access>
<type>Overload-DBObject</type>
<code><![CDATA[ protected static function MakeIconFromName($sIconName, $bImgTag = true)
{
$sIcon = '';
if ($sIconName != '')
{
$sPath = '../env-'.utils::GetCurrentEnvironment().'/itop-request-mgmt/images/'.$sIconName;
if ($bImgTag)
{
$sIcon = "<img src=\"$sPath\" style=\"vertical-align:middle;\"/>";
}
else
{
$sIcon = $sPath;
}
}
return $sIcon;
}]]></code>
</method>
<method id="GetHilightClass">
<static>false</static>
<access>public</access>
<type>Overload-iDisplay</type>
<code><![CDATA[ public function GetHilightClass()
{
$sHilightClass = '';
switch($this->GetState())
{
case 'new':
case 'approved':
$iEscalationDeadline = $this->Get('tto_escalation_deadline');
if ($iEscalationDeadline != null)
{
// A SLA is running
$oTTOStopWatch = $this->Get('tto');
if ($oTTOStopWatch->IsThresholdPassed(100))
{
$sHilightClass = HILIGHT_CLASS_CRITICAL;
}
else if ($oTTOStopWatch->IsThresholdPassed(75))
{
$sHilightClass = HILIGHT_CLASS_WARNING;
}
}
break;
case 'assigned':
$iEscalationDeadline = $this->Get('ttr_escalation_deadline');
if ($iEscalationDeadline != null)
{
// A SLA is running
$oTTRStopWatch = $this->Get('ttr');
if ($oTTRStopWatch->IsThresholdPassed(100))
{
$sHilightClass = HILIGHT_CLASS_CRITICAL;
}
else if ($oTTRStopWatch->IsThresholdPassed(75))
{
$sHilightClass = HILIGHT_CLASS_WARNING;
}
}
break;
case 'escalated_tto':
case 'escalated_ttr':
$sHilightClass = HILIGHT_CLASS_CRITICAL;
break;
}
return $sHilightClass;
}]]></code>
</method>
<method id="resolveChilds">
<static>false</static>
<access>public</access>