From 74baca3a7b4c5c4f6055aaccc3b9df4cab442b65 Mon Sep 17 00:00:00 2001 From: Denis Flaven Date: Mon, 15 Aug 2011 14:06:03 +0000 Subject: [PATCH] Enhanced interface for complex SLA computations... SVN:trunk[1453] --- .../model.itop-sla-computation.php | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/modules/itop-sla-computation/model.itop-sla-computation.php b/modules/itop-sla-computation/model.itop-sla-computation.php index 311b43898..51f07fe88 100644 --- a/modules/itop-sla-computation/model.itop-sla-computation.php +++ b/modules/itop-sla-computation/model.itop-sla-computation.php @@ -63,7 +63,7 @@ class SLAComputation } /** - * Get the date/time correspnding to a given delay in the future from the present + * Get the date/time corresponding to a given delay in the future from the present * considering only the valid (open) hours for a specified ticket * @param $oTicket Ticket The ticket for which to compute the deadline * @param $iDuration integer The duration (in seconds) in the future @@ -78,6 +78,18 @@ class SLAComputation } return self::$m_oAddOn->GetDeadline($oTicket, $iDuration, $oStartDate); } + + /** + * Get duration (considering only open hours) elapsed bewteen two given DateTimes + * @param $oTicket Ticket The ticket for which to compute the deadline + * @param $oStartDate DateTime The starting point for the computation (default = now) + * @param $oEndDate DateTime The ending point for the computation (default = now) + * @return integer The duration (number of seconds) of open hours elapsed between the two dates + */ + public static function GetOpenDuration($oTicket, DateTime $oStartDate, DateTime $oEndDate) + { + return self::$m_oAddOn->GetOpenDuration($oTicket, $oStartDate, $oEndDate); + } } /** @@ -97,7 +109,7 @@ class SLAComputationAddOnAPI } /** - * Get the date/time correspnding to a given delay in the future from the present + * Get the date/time corresponding to a given delay in the future from the present * considering only the valid (open) hours for a specified ticket * @param $oTicket Ticket The ticket for which to compute the deadline * @param $iDuration integer The duration (in seconds) in the future @@ -112,6 +124,18 @@ class SLAComputationAddOnAPI $oResult->modify('+'.$iDuration.' seconds'); return $oResult; } + + /** + * Get duration (considering only open hours) elapsed bewteen two given DateTimes + * @param $oTicket Ticket The ticket for which to compute the duration + * @param $oStartDate DateTime The starting point for the computation (default = now) + * @param $oEndDate DateTime The ending point for the computation (default = now) + * @return integer The duration (number of seconds) of open hours elapsed between the two dates + */ + public static function GetOpenDuration($oTicket, DateTime $oStartDate, DateTime $oEndDate) + { + return abs($oEndDate->format('U') - $oStartDate-format('U')); + } } SLAComputation::SelectModule('SLAComputationAddOnAPI'); ?> \ No newline at end of file