瀏覽代碼

New data model integration...

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@538 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 15 年之前
父節點
當前提交
e628a686b6
共有 3 個文件被更改,包括 61 次插入4 次删除
  1. 1 1
      application/displayblock.class.inc.php
  2. 59 2
      modules/itop-tickets-1.0.0/model.itop-tickets.php
  3. 1 1
      pages/UI.php

+ 1 - 1
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:

+ 59 - 2
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 "<p>TTO: SLT found: {$aSLT['SLT']}, value: {$aSLT['value']}</p>\n";
+		$this->Set('escalation_deadline', $iStartDate + $aSLT['value']);
+		$aSLT = $this->ComputeSLT('TTR');
+		//echo "<p>TTR: SLT found: {$aSLT['SLT']}, value: {$aSLT['value']}</p>\n";
+		$iStartDate = $this->Get('start_date');
+		$this->Set('closure_deadline', $iStartDate + $aSLT['value']);
+		
 	}
 }
 class Change extends Ticket

+ 1 - 1
pages/UI.php

@@ -581,7 +581,7 @@ try
 					// Split the text on the blanks and treat this as a search for <word1> AND <word2> AND <word3>
 					$aFullTextNeedles = explode(' ', $sFullText);
 				}
-				foreach(MetaModel::GetClasses('bizmodel') as $sClassName)
+				foreach(MetaModel::GetClasses('searchable') as $sClassName)
 				{
 					$oFilter = new DBObjectSearch($sClassName);
 					foreach($aFullTextNeedles as $sSearchText)