Ticket
bizmodel,searchable,requestmgmt
false
autoincrement
ticket_request
id
%1$s
images/user-request.png
new
waiting_for_approval
approved
rejected
assigned
pending
escalated_tto
escalated_ttr
resolved
closed
status
new
false
service_request
request_type
service_request
true
list
1
2
3
impact
1
false
list
1
2
3
4
priority
4
false
1
2
3
4
urgency
4
false
mail
phone
portal
origin
phone
true
org_id]]>
approver_id
Person
true
DEL_MANUAL
approver_id
email
org_id]]>
service_id
Service
true
DEL_MANUAL
service_id
name
service_id AND request_type = :this->request_type]]>
servicesubcategory_id
ServiceSubcategory
true
DEL_MANUAL
servicesubcategory_id
name
yes
no
escalation_flag
no
true
list
escalation_reason
true
assignment_date
true
resolution_date
true
last_pending_date
true
ResponseTicketTTO
75
100
ApplyStimulus
ev_timeout
ResponseTicketTTR
75
100
ApplyStimulus
ev_timeout
tto
100_deadline
tto
100_passed
tto
100_overrun
ttr
100_deadline
ttr
100_passed
ttr
100_overrun
time_spent
true
assistance
other
software patch
training
hardware repair
system update
bug fixed
resolution_code
assistance
true
solution
true
pending_reason
true
id AND status NOT IN ('rejected','resolved','closed')]]>
parent_request_id
UserRequest
true
DEL_MANUAL
parent_request_id
ref
parent_incident_id
Incident
true
DEL_MANUAL
parent_incident_id
ref
parent_problem_id
Problem
true
DEL_MANUAL
parent_problem_id
ref
parent_change_id
Change
true
DEL_MANUAL
parent_change_id
ref
UserRequest
parent_request_id
none
0
0
public_log
true
1
2
3
4
user_satisfaction
1
true
status
ev_assign
assigned
SetAssignedDate
ev_timeout
escalated_tto
ev_wait_for_approval
waiting_for_approval
ev_autoresolve
resolved
SetResolveDate
resolveChilds
ev_assign
assigned
SetAssignedDate
ev_pending
pending
SetLastPendingDate
ev_resolve
resolved
SetResolveDate
resolveChilds
ev_reassign
assigned
ev_timeout
escalated_ttr
ev_autoresolve
resolved
SetResolveDate
resolveChilds
ev_pending
pending
SetLastPendingDate
ev_resolve
resolved
SetResolveDate
resolveChilds
ev_reassign
assigned
ev_autoresolve
resolved
SetResolveDate
resolveChilds
ev_approve
approved
ev_reject
rejected
ev_timeout
escalated_tto
ev_assign
assigned
SetAssignedDate
ev_autoresolve
resolved
SetResolveDate
resolveChilds
ev_reopen
new
ev_assign
assigned
ev_autoresolve
resolved
SetResolveDate
resolveChilds
ev_close
closed
SetClosureDate
ev_reopen
assigned
ev_autoresolve
resolved
SetResolveDate
resolveChilds
false
public
LifecycleAction
Set('assignment_date', time());
return true;
}]]>
false
public
LifecycleAction
Set('last_pending_date', time());
return true;
}]]>
false
public
LifecycleAction
Set('resolution_date', time());
$iTimeSpent = time() - AttributeDateTime::GetAsUnixSeconds($this->Get('start_date'));
$this->Set('time_spent', $iTimeSpent);
return true;
}]]>
false
public
LifecycleAction
Set('close_date', time());
return true;
}]]>
false
public
LifecycleAction
Set('approver_id', UserRights::GetUserId());
return true;
}]]>
/** Compute the priority of the ticket based on its impact and urgency
* @return integer The priority of the ticket 1(high) .. 3(low)
*/
false
public
LifecycleAction
array(
1 => 1,
2 => 1,
3 => 2,
4 => 4,
),
// a group
2 => array(
1 => 1,
2 => 2,
3 => 3,
4 => 4,
),
// a departement!
3 => array(
1 => 2,
2 => 3,
3 => 3,
4 => 4,
),
);
$iPriority = $aPriorities[(int)$this->Get('impact')][(int)$this->Get('urgency')];
return $iPriority;
}]]>
false
public
Overload-DBObject
Set('priority', $this->ComputePriority());
$sCurrRef = $this->Get('ref');
if (strlen($sCurrRef) == 0)
{
$iKey = $this->GetKey();
if ($iKey < 0)
{
// Object not yet in the Database
$iKey = MetaModel::GetNextKey(get_class($this));
}
$sName = sprintf('R-%06d', $iKey);
$this->Set('ref', $sName);
}
return parent::ComputeValues();
}]]>
false
public
Overload-cmdbAbstractObject
SetCurrentTab(Dict::S('Class:UserRequest:KnownErrorList'));
$iTicketID = $this->GetKey();;
$oKnownErrorSet = new CMDBObjectSet(DBObjectSearch::FromOQL("SELECT KnownError AS ke JOIN lnkErrorToFunctionalCI AS l1 ON l1.error_id=ke.id JOIN FunctionalCI AS ci ON l1.functionalci_id=ci.id JOIN lnkFunctionalCIToTicket AS l2 ON l2.functionalci_id=ci.id WHERE l2.ticket_id=$iTicketID"));
$iNumberKE=$oKnownErrorSet->count();
if ($iNumberKE > 0)
{
$oPage->SetCurrentTab(Dict::S('Class:UserRequest:KnownErrorList')." ($iNumberKE)");
}
else
{
$oPage->SetCurrentTab(Dict::S('Class:UserRequest:KnownErrorList'));
}
self::DisplaySet($oPage, $oKnownErrorSet, array ('menu' => false));
}
}
}]]>
/**
* 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
*/
false
public
Overload-DBObject
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
$iStartDate = AttributeDateTime::GetAsUnixSeconds($this->Get('start_date'));
$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');
$iEscalationDeadline = $this->Get('ttr_escalation_deadline');
if ($iEscalationDeadline != null)
{
// A SLA is running
$iStartDate = AttributeDateTime::GetAsUnixSeconds($this->Get('start_date'));
$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;
}]]>
true
protected
Overload-DBObject
";
}
else
{
$sIcon = $sPath;
}
}
return $sIcon;
}]]>
false
public
Overload-iDisplay
GetState())
{
case 'new':
case 'approved':
$iEscalationDeadline = $this->Get('tto_escalation_deadline');
if ($iEscalationDeadline != null)
{
// A SLA is running
$iStartDate = AttributeDateTime::GetAsUnixSeconds($this->Get('start_date'));
$ratio = ($iEscalationDeadline - time())/($iEscalationDeadline - $iStartDate);
if ($ratio <= 0)
{
$sHilightClass = HILIGHT_CLASS_CRITICAL;
}
else if ($ratio <= 0.25)
{
$sHilightClass = HILIGHT_CLASS_WARNING;
}
}
break;
case 'assigned':
$iEscalationDeadline = $this->Get('ttr_escalation_deadline');
if ($iEscalationDeadline != null)
{
// A SLA is running
$iStartDate = AttributeDateTime::GetAsUnixSeconds($this->Get('start_date'));
$ratio = ($iEscalationDeadline - time())/($iEscalationDeadline - $iStartDate);
if ($ratio <= 0)
{
$sHilightClass = HILIGHT_CLASS_CRITICAL;
}
else if ($ratio <= 0.25)
{
$sHilightClass = HILIGHT_CLASS_WARNING;
}
}
break;
case 'escalated_tto':
case 'escalated_ttr':
$sHilightClass = HILIGHT_CLASS_CRITICAL;
break;
}
return $sHilightClass;
}]]>
false
public
LifecycleAction
Set("date", time());
$sUserString = CMDBChange::GetCurrentUserName();
$oMyChange->Set("userinfo", $sUserString."(automatic resolution)");
$iChangeId = $oMyChange->DBInsert();
$sOQL = "SELECT UserRequest WHERE parent_request_id=:ticket";
$oChildRequestSet = new DBObjectSet(DBObjectSearch::FromOQL($sOQL),
array(),
array(
'ticket' => $this->GetKey(),
)
);
while($oRequest = $oChildRequestSet->Fetch())
{
if ( $oRequest->Get('status') != 'resolved')
{
$oRequest->set('servicesubcategory_id',$this->Get('servicesubcategory_id'));
$oRequest->set('service_id',$this->Get('service_id'));
$oRequest->set('team_id',$this->Get('team_id'));
$oRequest->set('agent_id',$this->Get('agent_id'));
$oRequest->set('resolution_code',$this->Get('resolution_code'));
$oRequest->set('solution','Automatically resolved by request:[[UserRequest:'.$this->Get('ref').']]');
$oRequest->ApplyStimulus('ev_autoresolve');
$oRequest->DBUpdateTracked($oMyChange);
}
}
return true;
}]]>
false
public
LifecycleAction
Set("date", time());
$sUserString = CMDBChange::GetCurrentUserName();
$oMyChange->Set("userinfo", $sUserString."(automatic update)");
$iChangeId = $oMyChange->DBInsert();
$sOQL = "SELECT UserRequest WHERE parent_request_id=:ticket";
$oChildRequestSet = new DBObjectSet(DBObjectSearch::FromOQL($sOQL),
array(),
array(
'ticket' => $this->GetKey(),
)
);
while($oRequest = $oChildRequestSet->Fetch())
{
$oRequest->set('public_log',$sLogPublic);
$oRequest->DBUpdateTracked($oMyChange);
}
}
$sLogPrivate = utils::ReadPostedParam('attr_private_log', null,false,'raw_data');
if ( $sLogPrivate != null)
{
$oMyChange = MetaModel::NewObject("CMDBChange");
$oMyChange->Set("date", time());
$sUserString = CMDBChange::GetCurrentUserName();
$oMyChange->Set("userinfo", $sUserString."(automatic update)");
$iChangeId = $oMyChange->DBInsert();
$sOQL = "SELECT UserRequest WHERE parent_request_id=:ticket";
$oChildRequestSet = new DBObjectSet(DBObjectSearch::FromOQL($sOQL),
array(),
array(
'ticket' => $this->GetKey(),
)
);
while($oRequest = $oChildRequestSet->Fetch())
{
$oRequest->set('private_log',$sLogPrivate);
$oRequest->DBUpdateTracked($oMyChange);
}
}
return true;
}]]>
false
public
LifecycleAction
Get('contacts_list');
$oToImpact = $this->Get('functionalcis_list');
$oImpactedInfras = DBObjectSet::FromLinkSet($this, 'functionalcis_list', 'functionalci_id');
$aComputed = $oImpactedInfras->GetRelatedObjects('impacts', 10);
if (isset($aComputed['FunctionalCI']) && is_array($aComputed['FunctionalCI']))
{
foreach($aComputed['FunctionalCI'] as $iKey => $oObject)
{
$oNewLink = new lnkFunctionalCIToTicket();
$oNewLink->Set('functionalci_id', $iKey);
$oNewLink->Set('impact', 'potentially impacted (automatically computed)');
$oToImpact->AddObject($oNewLink);
}
}
if (isset($aComputed['Contact']) && is_array($aComputed['Contact']))
{
foreach($aComputed['Contact'] as $iKey => $oObject)
{
$oNewLink = new lnkContactToTicket();
$oNewLink->Set('contact_id', $iKey);
$oNewLink->Set('role', 'contact automatically computed');
$oToNotify->AddObject($oNewLink);
}
}
parent::OnInsert();
}]]>
false
protected
Overload-DBObject
ComputeImpactedItems();
$this->Set('last_update', time());
$this->Set('start_date', time());
}]]>
false
protected
Overload-DBObject
Set('last_update', time());
$this->UpdateChildRequestLog();
}]]>
-
10
-
20
-
30
-
40
-
50
-
10
-
10
-
20
-
30
-
40
-
50
-
60
-
20
-
10
-
20
-
30
-
40
-
50
-
60
-
10
-
10
-
20
-
30
-
40
-
20
-
10
-
20
-
30
-
30
-
10
-
20
-
30
-
40
-
50
-
60
-
70
-
80
-
70
-
10
-
10
-
20
-
30
-
40
-
20
-
10
-
20
-
30
-
40
-
30
-
10
-
20
-
30
-
40
-
10
-
20
-
30
-
40
-
50
-
60
-
70
-
80
-
90
-
100
-
110
-
120
-
130
-
140
-
150
-
160
-
170
-
180
-
190
-
200
-
210
-
220
-
230
-
240
-
10
-
20
-
30
-
40
-
50
-
60