Exemple #1
0
	function RecalculateSupportDeadlineForOneTicket($arTicket, $arFields = array(), $dateType = array("EVENT"=>array(CTicket::IGNORE)))
	{
		global $DB;
		$err_mess = (CAllTicketReminder::err_mess())."<br>Function: RecalculateSupportDeadlineForOneTicket<br>Line: ";	
		$currDateTS = time() + CTimeZone::GetOffset();
		$ts2010 = mktime(0, 0, 0, 1, 1, 2010);
		$supportDeadlineNotify = 0;
		$ticketID = intval($arTicket["ID"]);
		$slaID = intval($arTicket["SLA_ID"]);
		$periodMin = self::ConvertResponseTimeUnit($arTicket["RESPONSE_TIME"], $arTicket["RESPONSE_TIME_UNIT"]);
		$periodNMin = 0;
		if($ticketID <= 0 || $slaID <= 0 || $periodMin <= 0 || intval($arTicket["D_1_USER_M_AFTER_SUP_M"]) <= 0)
		{
			if($ticketID > 0 && count($arFields) > 0)
			{
				$DB->Update("b_ticket", $arFields, "WHERE ID='" . $ticketID . "'", $err_mess . __LINE__);
			}
			return;
		}
		
		$periodNMinMinus = self::ConvertResponseTimeUnit($arTicket["NOTICE_TIME"], $arTicket["NOTICE_TIME_UNIT"]);
		if($periodNMinMinus > 0 && $periodNMinMinus < $periodMin) 
		{
			$periodNMin = $periodMin - $periodNMinMinus;
		}
		
		$newDate1UserMessAfterSupMessTS = MakeTimeStamp($arTicket["D_1_USER_M_AFTER_SUP_M"]);
		$deadlineSourceDate = MakeTimeStamp($arTicket["DEADLINE_SOURCE_DATE"]);
		if($deadlineSourceDate <= $ts2010)
		{
			if($newDate1UserMessAfterSupMessTS <= $ts2010)
			{
				$deadlineSourceDate = $currDateTS;
			}
			else
			{
				$deadlineSourceDate = $newDate1UserMessAfterSupMessTS;
			}
			$arFields["DEADLINE_SOURCE_DATE"] = $DB->CharToDateFunction(GetTime($deadlineSourceDate,"FULL"));
		}
		$oldPeriodMin = null;
		if(isset($dateType["EVENT"]) && in_array(CTicket::UPDATE, $dateType["EVENT"]))
		{
			if(isset($dateType["OLD_SLA_RESPONSE_TIME"]) && isset($dateType["OLD_SLA_RESPONSE_TIME_UNIT"]))
			{
				$oldPeriodMin = self::ConvertResponseTimeUnit($dateType["OLD_SLA_RESPONSE_TIME"], $dateType["OLD_SLA_RESPONSE_TIME_UNIT"]);
			}

			if(
				in_array(CTicket::REOPEN, $dateType["EVENT"]) ||
				(
					in_array(CTicket::NEW_SLA, $dateType["EVENT"]) &&
					($arTicket["IS_OVERDUE"] != "Y") &&
					($oldPeriodMin != null) &&
					($oldPeriodMin > $periodMin)
				)
			)
			{
				$deadlineSourceDate = $currDateTS;
				$arFields["DEADLINE_SOURCE_DATE"] = $DB->CharToDateFunction(GetTime($deadlineSourceDate,"FULL"));
			}
			elseif(($arTicket["IS_OVERDUE"] != "Y") && ($newDate1UserMessAfterSupMessTS > $deadlineSourceDate))
			{
				$deadlineSourceDate = $newDate1UserMessAfterSupMessTS;
				$arFields["DEADLINE_SOURCE_DATE"] = $arFields["D_1_USER_M_AFTER_SUP_M"];
			}
		}

		$supportDeadlineTS = CSupportTimetableCache::getEndDate($slaID, $periodMin, GetTime($deadlineSourceDate,"FULL"));
		$arFields["SUPPORT_DEADLINE"] = $DB->CharToDateFunction(GetTime($supportDeadlineTS, "FULL"));
		$arFields["IS_OVERDUE"] = (($supportDeadlineTS <= $currDateTS) ? "'Y'" : "'N'");
		if($periodNMin > 0)
		{
			$supportDeadlineNotifyTS = CSupportTimetableCache::getEndDate($slaID, $periodNMin, GetTime($deadlineSourceDate,"FULL"));
			$arFields["SUPPORT_DEADLINE_NOTIFY"] = $DB->CharToDateFunction(GetTime($supportDeadlineNotifyTS, "FULL"));
			$arFields["IS_NOTIFIED"] = (($supportDeadlineNotifyTS <= $currDateTS) ? "'Y'" : "'N'");
		}
		$DB->Update("b_ticket", $arFields, "WHERE ID='" . $ticketID . "'", $err_mess . __LINE__);

	}
Exemple #2
0
 public static function RecalculateSupportDeadlineForOneTicket($arTicket, $arFields = array(), $dateType = array("EVENT" => array(CTicket::IGNORE)))
 {
     global $DB;
     $err_mess = CAllTicketReminder::err_mess() . "<br>Function: RecalculateSupportDeadlineForOneTicket<br>Line: ";
     $currDateTS = time() + CTimeZone::GetOffset();
     $ts2010 = mktime(0, 0, 0, 1, 1, 2010);
     $supportDeadlineNotify = 0;
     $ticketID = intval($arTicket["ID"]);
     $slaID = intval($arTicket["SLA_ID"]);
     $periodMin = self::ConvertResponseTimeUnit($arTicket["RESPONSE_TIME"], $arTicket["RESPONSE_TIME_UNIT"]);
     $periodNMin = 0;
     if ($ticketID <= 0 || $slaID <= 0 || $periodMin <= 0 || intval($arTicket["D_1_USER_M_AFTER_SUP_M"]) <= 0) {
         if ($ticketID > 0 && count($arFields) > 0) {
             $DB->Update("b_ticket", $arFields, "WHERE ID='" . $ticketID . "'", $err_mess . __LINE__);
         }
         return;
     }
     $periodNMinMinus = self::ConvertResponseTimeUnit($arTicket["NOTICE_TIME"], $arTicket["NOTICE_TIME_UNIT"]);
     if ($periodNMinMinus > 0 && $periodNMinMinus < $periodMin) {
         $periodNMin = $periodMin - $periodNMinMinus;
     }
     $newDate1UserMessAfterSupMessTS = MakeTimeStamp($arTicket["D_1_USER_M_AFTER_SUP_M"]);
     $deadlineSourceDate = MakeTimeStamp($arTicket["DEADLINE_SOURCE_DATE"]);
     if ($deadlineSourceDate <= $ts2010) {
         if ($newDate1UserMessAfterSupMessTS <= $ts2010) {
             $deadlineSourceDate = $currDateTS;
         } else {
             $deadlineSourceDate = $newDate1UserMessAfterSupMessTS;
         }
         $arFields["DEADLINE_SOURCE_DATE"] = $DB->CharToDateFunction(GetTime($deadlineSourceDate, "FULL"));
     }
     $oldPeriodMin = null;
     if (isset($dateType["EVENT"]) && in_array(CTicket::UPDATE, $dateType["EVENT"])) {
         if (isset($dateType["OLD_SLA_RESPONSE_TIME"]) && isset($dateType["OLD_SLA_RESPONSE_TIME_UNIT"])) {
             $oldPeriodMin = self::ConvertResponseTimeUnit($dateType["OLD_SLA_RESPONSE_TIME"], $dateType["OLD_SLA_RESPONSE_TIME_UNIT"]);
         }
         if (in_array(CTicket::REOPEN, $dateType["EVENT"]) || in_array(CTicket::NEW_SLA, $dateType["EVENT"]) && $arTicket["IS_OVERDUE"] != "Y" && $oldPeriodMin != null && $oldPeriodMin > $periodMin) {
             $deadlineSourceDate = $currDateTS;
             $arFields["DEADLINE_SOURCE_DATE"] = $DB->CharToDateFunction(GetTime($deadlineSourceDate, "FULL"));
         } elseif ($arTicket["IS_OVERDUE"] != "Y" && $newDate1UserMessAfterSupMessTS > $deadlineSourceDate) {
             $sla = CTicketSLA::getById($slaID)->Fetch();
             if (empty($sla['DEADLINE_SOURCE'])) {
                 // default deadline calculation
                 // date of first client message after support message
                 $deadlineSourceDate = $newDate1UserMessAfterSupMessTS;
                 $arFields["DEADLINE_SOURCE_DATE"] = $arFields["D_1_USER_M_AFTER_SUP_M"];
             }
         }
     }
     $supportDeadlineTS = CSupportTimetableCache::getEndDate($slaID, $periodMin, GetTime($deadlineSourceDate, "FULL"));
     $arFields["SUPPORT_DEADLINE"] = $DB->CharToDateFunction(GetTime($supportDeadlineTS, "FULL"));
     $arFields["IS_OVERDUE"] = $supportDeadlineTS <= $currDateTS ? "'Y'" : "'N'";
     // exec event and confirm if overdue
     if ($arTicket['IS_OVERDUE'] == "N" && $arFields['IS_OVERDUE'] == "'Y'") {
         $rs = GetModuleEvents('support', 'OnBeforeTicketExpire');
         while ($arr = $rs->Fetch()) {
             $arFields = ExecuteModuleEventEx($arr, array($ticketID, $arFields));
             if (!$arFields) {
                 return false;
             }
         }
     }
     if ($periodNMin > 0) {
         $supportDeadlineNotifyTS = CSupportTimetableCache::getEndDate($slaID, $periodNMin, GetTime($deadlineSourceDate, "FULL"));
         $arFields["SUPPORT_DEADLINE_NOTIFY"] = $DB->CharToDateFunction(GetTime($supportDeadlineNotifyTS, "FULL"));
         $arFields["IS_NOTIFIED"] = $supportDeadlineNotifyTS <= $currDateTS ? "'Y'" : "'N'";
         // exec event and confirm if set notified
         if ($arTicket['IS_NOTIFIED'] == "N" && $arFields['IS_NOTIFIED'] == "'Y'") {
             $rs = GetModuleEvents('support', 'OnBeforeTicketNotify');
             while ($arr = $rs->Fetch()) {
                 $arFields = ExecuteModuleEventEx($arr, array($ticketID, $arFields));
                 if (!$arFields) {
                     return false;
                 }
             }
         }
     }
     $DB->Update("b_ticket", $arFields, "WHERE ID='" . $ticketID . "'", $err_mess . __LINE__);
 }
 function RecalculateSupportDeadlineForOneTicket($arTicket, $arFields = array(), $dateType = CTicket::IGNORE)
 {
     global $DB;
     $err_mess = CAllTicketReminder::err_mess() . "<br>Function: RecalculateSupportDeadlineForOneTicket<br>Line: ";
     $currDateTS = time() + CTimeZone::GetOffset();
     $supportDeadlineNotify = 0;
     $ticketID = intval($arTicket["ID"]);
     $slaID = intval($arTicket["SLA_ID"]);
     $periodMin = self::ConvertResponseTimeUnit($arTicket["RESPONSE_TIME"], $arTicket["RESPONSE_TIME_UNIT"]);
     $periodNMin = 0;
     if ($ticketID <= 0 || $slaID <= 0 || $periodMin <= 0 || intval($arTicket["D_1_USER_M_AFTER_SUP_M"]) <= 0) {
         if ($ticketID > 0 && count($arFields) > 0) {
             $DB->Update("b_ticket", $arFields, "WHERE ID='" . $ticketID . "'", $err_mess . __LINE__);
         }
         return;
     }
     $periodNMinMinus = self::ConvertResponseTimeUnit($arTicket["NOTICE_TIME"], $arTicket["NOTICE_TIME_UNIT"]);
     if ($periodNMinMinus > 0 && $periodNMinMinus < $periodMin) {
         $periodNMin = $periodMin - $periodNMinMinus;
     }
     $newDateTS = MakeTimeStamp($arTicket["D_1_USER_M_AFTER_SUP_M"]);
     if ($dateType == CTicket::CURRENT_DATE) {
         $arTicket["D_1_USER_M_AFTER_SUP_M"] = GetTime($currDateTS - $periodNMin * 60, "FULL");
         $arFields["D_1_USER_M_AFTER_SUP_M"] = $DB->CharToDateFunction($arTicket["D_1_USER_M_AFTER_SUP_M"]);
     } elseif ($dateType == CTicket::ADD) {
         $oldDateTS = MakeTimeStamp($arTicket["DATE_OLD"]);
         if ($oldDateTS > $newDateTS) {
             $arTicket["D_1_USER_M_AFTER_SUP_M"] = $arTicket["DATE_OLD"];
             $arFields["D_1_USER_M_AFTER_SUP_M"] = $DB->CharToDateFunction($arTicket["D_1_USER_M_AFTER_SUP_M"]);
         }
     }
     $supportDeadlineTS = CSupportTimetableCache::getEndDate($slaID, $periodMin, $arTicket["D_1_USER_M_AFTER_SUP_M"]);
     $arFields["SUPPORT_DEADLINE"] = $DB->CharToDateFunction(GetTime($supportDeadlineTS, "FULL"));
     $arFields["IS_OVERDUE"] = $supportDeadlineTS <= $currDateTS ? "'Y'" : "'N'";
     if ($periodNMin > 0) {
         $supportDeadlineNotifyTS = CSupportTimetableCache::getEndDate($slaID, $periodNMin, $arTicket["D_1_USER_M_AFTER_SUP_M"]);
         $arFields["SUPPORT_DEADLINE_NOTIFY"] = $DB->CharToDateFunction(GetTime($supportDeadlineNotifyTS, "FULL"));
         $arFields["IS_NOTIFIED"] = $supportDeadlineNotifyTS <= $currDateTS ? "'Y'" : "'N'";
     }
     $DB->Update("b_ticket", $arFields, "WHERE ID='" . $ticketID . "'", $err_mess . __LINE__);
 }