mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 02:58:43 +02:00
- 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:
BIN
modules/itop-request-mgmt-1.0.0/images/user-request-closed.png
Normal file
BIN
modules/itop-request-mgmt-1.0.0/images/user-request-closed.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.0 KiB |
BIN
modules/itop-request-mgmt-1.0.0/images/user-request-deadline.png
Normal file
BIN
modules/itop-request-mgmt-1.0.0/images/user-request-deadline.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.8 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.1 KiB |
BIN
modules/itop-request-mgmt-1.0.0/images/user-request.png
Normal file
BIN
modules/itop-request-mgmt-1.0.0/images/user-request.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.2 KiB |
@@ -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 */);
|
||||
|
||||
Reference in New Issue
Block a user