- Модуль: support
- Путь к файлу: ~/bitrix/modules/support/classes/general/sla.php
- Класс: CAllTicketSLA
- Вызов: CAllTicketSLA::GetSLA
static function GetSLA( $siteID, $userID, $categoryID = null, $coupon = "" )
{
global $DB;
$err_mess = (CAllTicketSLA::err_mess())."
Function: GetSLA
Line: ";
$userID = intval($userID);
if( $coupon <> '' )
{
$rsCoupon = CSupportSuperCoupon::GetList( false, array( 'COUPON' => $coupon ) );
if($arCoupon = $rsCoupon->Fetch())
{
if(intval($arCoupon['SLA_ID']) > 0)
{
return intval($arCoupon['SLA_ID']);
}
}
}
$slaID = COption::GetOptionString( "support", "SUPPORT_DEFAULT_SLA_ID" );
$OLD_FUNCTIONALITY = COption::GetOptionString( "support", "SUPPORT_OLD_FUNCTIONALITY", "Y" );
if( $OLD_FUNCTIONALITY == "Y" )
{
$categoryID = null;
}
$JOIN = "";
$fields = "1";
if( $categoryID != null )
{
$categoryID = intval($categoryID);
$fields = "CASE
WHEN SC.SLA_ID IS NOT NULL THEN 1
ELSE 0
END";
$JOIN .= "
LEFT JOIN b_ticket_sla_2_category SC
ON S.ID = SC.SLA_ID
AND ( SC.CATEGORY_ID = 0 OR SC.CATEGORY_ID = $categoryID )";
}
$strSql = "
SELECT
PZ.SLA_ID
FROM
(
SELECT
SG.SLA_ID SLA_ID,
$fields PRIORITY1,
S.PRIORITY PRIORITY2
FROM
b_ticket_sla S
INNER JOIN b_ticket_sla_2_site SS
ON S.ID = SS.SLA_ID
AND ( SS.SITE_ID = 'ALL' OR SS.SITE_ID = '$siteID' )
INNER JOIN b_ticket_sla_2_user_group SG
ON S.ID = SG.SLA_ID
$JOIN
WHERE SG.GROUP_ID IN (
SELECT UG.GROUP_ID FROM b_user_group UG
WHERE
UG.USER_ID = $userID
AND (UG.DATE_ACTIVE_FROM IS NULL OR UG.DATE_ACTIVE_FROM <= ".$DB->CurrentTimeFunction().")
AND (UG.DATE_ACTIVE_TO IS NULL OR UG.DATE_ACTIVE_TO >= ".$DB->CurrentTimeFunction().")
)
OR SG.GROUP_ID = 2
) PZ
GROUP BY
PZ.SLA_ID, PZ.PRIORITY1, PZ.PRIORITY2
ORDER BY
PZ.PRIORITY1 DESC, PZ.PRIORITY2 DESC
";
$rs = $DB->Query($strSql, false, $err_mess.__LINE__);
if( $ar = $rs->Fetch() )
{
if( is_array( $ar ) && array_key_exists( "SLA_ID", $ar ) )
{
$slaID = $ar["SLA_ID"];
}
}
return $slaID;
}