From b57015d7ba5a9a5de7dbc6e6cb41f5c9475dc2ec Mon Sep 17 00:00:00 2001 From: Denis Flaven Date: Fri, 2 Jul 2010 17:10:08 +0000 Subject: [PATCH] New data model integration... SVN:trunk[538] --- application/displayblock.class.inc.php | 2 +- .../itop-tickets-1.0.0/model.itop-tickets.php | 61 ++++++++++++++++++- pages/UI.php | 2 +- 3 files changed, 61 insertions(+), 4 deletions(-) diff --git a/application/displayblock.class.inc.php b/application/displayblock.class.inc.php index 65b1c1a02..51c6484c5 100644 --- a/application/displayblock.class.inc.php +++ b/application/displayblock.class.inc.php @@ -845,7 +845,7 @@ class MenuBlock extends DisplayBlock $aStimuli = Metamodel::EnumStimuli($sClass); foreach($aTransitions as $sStimulusCode => $aTransitionDef) { - $iActionAllowed = UserRights::IsStimulusAllowed($sClass, $sStimulusCode, $oSet); + $iActionAllowed = (get_class($aStimuli[$sStimulusCode]) == 'StimulusUserAction') ? UserRights::IsStimulusAllowed($sClass, $sStimulusCode, $oSet) : UR_ALLOWED_NO; switch($iActionAllowed) { case UR_ALLOWED_YES: diff --git a/modules/itop-tickets-1.0.0/model.itop-tickets.php b/modules/itop-tickets-1.0.0/model.itop-tickets.php index 56bce2bad..a37be8376 100644 --- a/modules/itop-tickets-1.0.0/model.itop-tickets.php +++ b/modules/itop-tickets-1.0.0/model.itop-tickets.php @@ -259,7 +259,7 @@ class Incident extends Ticket array( "attribute_inherit" => 'new', "attribute_list" => array( - 'agent_id' => OPT_ATT_MUSTCHANGE, + 'agent_id' => OPT_ATT_MANDATORY, 'related_problem_id' => OPT_ATT_NORMAL, 'related_change_id' => OPT_ATT_NORMAL, ), @@ -316,6 +316,51 @@ class Incident extends Ticket MetaModel::Init_DefineTransition("resolved", "ev_close", array("target_state"=>"closed", "actions"=>array(), "user_restriction"=>null)); } + public function ComputeSLT($sMetric = 'TTO') + { + $sOQL = "SELECT SLT JOIN lnkSLTToSLA AS L1 ON L1.slt_id=SLT.id JOIN SLA ON L1.sla_id = SLA.id JOIN lnkContractToSLA AS L2 ON L2.sla_id = SLA.id JOIN CustomerContract ON L2.contract_id = CustomerContract.id + WHERE SLT.ticket_priority = :priority AND SLA.service_id = :service_id AND SLT.metric = :metric AND CustomerContract.customer_id = :customer_id"; + $oSLTSet = new DBObjectSet(DBObjectSearch::FromOQL($sOQL), + array(), + array( + 'priority' => $this->Get('priority'), + 'service_id' => $this->Get('service_id'), + 'metric' => $sMetric, + 'customer_id' => $this->Get('customer_id'), + ) + ); + + $iMinDuration = PHP_INT_MAX; + $sSLTName = ''; + + while($oSLT = $oSLTSet->Fetch()) + { + $iDuration = $oSLT->Get('value'); + $sUnit = $oSLT->Get('value_unit'); + switch($sUnit) + { + case 'days': + $iDuration = $iDuration * 24; // 24 hours in 1 days + // Fall though + + case 'hours': + $iDuration = $iDuration * 60; // 60 minutes in 1 hour + // Fall though + + case 'minutes': + $iDuration = $iDuration * 60; + } + if ($iDuration < $iMinDuration) + { + $iMinDuration = $iDuration; + $sSLTName = $oSLT->GetName(); + } + } + if ($iMinDuration == PHP_INT_MAX) $iMinDuration = null; + return array('SLT' => $sSLTName, 'value' => $iMinDuration); + } + + public function ComputeValues() { $iKey = $this->GetKey(); @@ -354,8 +399,20 @@ class Incident extends Ticket ) ), ); - $iPriority = $aPriorities[$this->Get('impact')][$this->Get('urgency')]; + $iPriority = 1; //$aPriorities[$this->Get('impact')][$this->Get('urgency')]; $this->Set('priority', $iPriority); + + // Compute the SLA deadlines + + $aSLT = $this->ComputeSLT('TTO'); + $iStartDate = $this->Get('start_date'); + //echo "

TTO: SLT found: {$aSLT['SLT']}, value: {$aSLT['value']}

\n"; + $this->Set('escalation_deadline', $iStartDate + $aSLT['value']); + $aSLT = $this->ComputeSLT('TTR'); + //echo "

TTR: SLT found: {$aSLT['SLT']}, value: {$aSLT['value']}

\n"; + $iStartDate = $this->Get('start_date'); + $this->Set('closure_deadline', $iStartDate + $aSLT['value']); + } } class Change extends Ticket diff --git a/pages/UI.php b/pages/UI.php index c1b0d1941..79bccef97 100644 --- a/pages/UI.php +++ b/pages/UI.php @@ -581,7 +581,7 @@ try // Split the text on the blanks and treat this as a search for AND AND $aFullTextNeedles = explode(' ', $sFullText); } - foreach(MetaModel::GetClasses('bizmodel') as $sClassName) + foreach(MetaModel::GetClasses('searchable') as $sClassName) { $oFilter = new DBObjectSearch($sClassName); foreach($aFullTextNeedles as $sSearchText)