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