15 $table =
"b_ticket_sla";
16 $isDemo = $isSupportClient = $isSupportTeam = $isAdmin = $isAccess = $userID =
null;
17 CTicket::GetRoles($isDemo, $isSupportClient, $isSupportTeam, $isAdmin, $isAccess, $userID, $checkRights);
20 $validDeadlineSource = !isset(
$arFields[
'DEADLINE_SOURCE']) || in_array(
$arFields[
'DEADLINE_SOURCE'],
array(
'',
'DATE_CREATE'),
true);
27 $DB->Update($table, $arFields_i,
"WHERE ID=".intval($id));
31 $id =
$DB->Insert($table, $arFields_i);
38 $DB->Query(
"DELETE FROM b_ticket_sla_2_user_group WHERE SLA_ID = $id");
41 foreach(
$arFields[
"arGROUPS"] as $groupID)
43 $groupID = intval($groupID);
46 $strSql =
"INSERT INTO b_ticket_sla_2_user_group (SLA_ID, GROUP_ID) VALUES ($id, $groupID)";
55 $DB->Query(
"DELETE FROM b_ticket_sla_2_site WHERE SLA_ID = $id");
63 $strSql =
"INSERT INTO b_ticket_sla_2_site (SLA_ID, SITE_ID) VALUES ($id, '$siteID')";
71 $DB->Query(
"DELETE FROM b_ticket_sla_2_category WHERE SLA_ID = $id");
74 foreach(
$arFields[
"arCATEGORIES"] as $categoryID)
76 $categoryID = intval($categoryID);
77 $strSql =
"INSERT INTO b_ticket_sla_2_category (SLA_ID, CATEGORY_ID) VALUES ($id, $categoryID)";
85 $DB->Query(
"DELETE FROM b_ticket_sla_2_criticality WHERE SLA_ID = $id");
88 foreach(
$arFields[
"arCRITICALITIES"] as $criticalityID)
90 $criticalityID = intval($criticalityID);
91 $strSql =
"INSERT INTO b_ticket_sla_2_criticality (SLA_ID, CRITICALITY_ID) VALUES ($id, $criticalityID)";
99 $DB->Query(
"DELETE FROM b_ticket_sla_2_mark WHERE SLA_ID = $id");
104 $markID = intval($markID);
105 $strSql =
"INSERT INTO b_ticket_sla_2_mark (SLA_ID, MARK_ID) VALUES ($id, $markID)";
150 $FIRST_SITE_ID = $FIRST_SITE_ID <>
'' ?
"'".$DB->ForSql($FIRST_SITE_ID).
"'" :
"null";
151 $DB->Update($table,
array(
"FIRST_SITE_ID" => $FIRST_SITE_ID),
"WHERE ID=".intval($id));
159 $arMsg[] =
array(
"id"=>
"PERMISSION",
"text"=>
GetMessage(
"SUP_ERROR_ACCESS_DENIED"));
163 CSupportTimetableCache::toCache(
array(
"SLA_ID"=> $id ) );
168 public static function Delete($id, $checkRights=
true)
181 $isDemo = $isSupportClient = $isSupportTeam = $isAdmin = $isAccess = $userID =
null;
182 CTicket::GetRoles($isDemo, $isSupportClient, $isSupportTeam, $isAdmin, $isAccess, $userID, $checkRights);
185 $strSql =
"SELECT DISTINCT 'x' FROM b_ticket WHERE SLA_ID = $id";
186 $rs =
$DB->Query($strSql);
189 $DB->Query(
"DELETE FROM b_ticket_sla_2_site WHERE SLA_ID = $id");
190 $DB->Query(
"DELETE FROM b_ticket_sla_2_category WHERE SLA_ID = $id");
191 $DB->Query(
"DELETE FROM b_ticket_sla_2_criticality WHERE SLA_ID = $id");
192 $DB->Query(
"DELETE FROM b_ticket_sla_2_mark WHERE SLA_ID = $id");
193 $DB->Query(
"DELETE FROM b_ticket_sla_2_user_group WHERE SLA_ID = $id");
195 $DB->Query(
"DELETE FROM b_ticket_sla_2_holidays WHERE SLA_ID = $id");
197 $DB->Query(
"DELETE FROM b_ticket_sla WHERE ID = $id");
198 $DB->Query(
"DELETE FROM b_ticket_timetable_cache WHERE SLA_ID = $id");
217 if ($id<=0)
return false;
219 $arSort = $is_filtered =
null;
229 $slaID = intval($slaID);
232 $strSql =
"SELECT * FROM b_ticket_sla_shedule WHERE SLA_ID = $slaID ORDER BY WEEKDAY_NUMBER, MINUTE_FROM, MINUTE_TILL";
233 $rs =
$DB->Query($strSql);
236 if (
$ar[
"OPEN_TIME"]==
"CUSTOM")
238 if (intval(
$ar[
"MINUTE_FROM"])>0)
240 $h_from = floor(
$ar[
"MINUTE_FROM"]/60);
241 $m_from =
$ar[
"MINUTE_FROM"] - $h_from*60;
243 if (intval(
$ar[
"MINUTE_TILL"])>0)
245 $h_till = floor(
$ar[
"MINUTE_TILL"]/60);
246 $m_till =
$ar[
"MINUTE_TILL"] - $h_till*60;
250 "MINUTE_FROM" =>
$ar[
"MINUTE_FROM"],
251 "SECOND_FROM" =>
$ar[
"MINUTE_FROM"]*60,
252 "MINUTE_TILL" =>
$ar[
"MINUTE_TILL"],
253 "SECOND_TILL" =>
$ar[
"MINUTE_TILL"]*60,
254 "FROM" => $h_from.
":".str_pad($m_from, 2, 0),
255 "TILL" => $h_till.
":".str_pad($m_till, 2, 0)
272 $slaID = intval($slaID);
275 $strSql =
"SELECT GROUP_ID FROM b_ticket_sla_2_user_group WHERE SLA_ID = $slaID";
276 $rs =
$DB->Query($strSql);
287 $strSql =
"SELECT SLA_ID, GROUP_ID FROM b_ticket_sla_2_user_group";
288 $rs =
$DB->Query($strSql);
302 $slaID = intval($slaID);
305 $strSql =
"SELECT SITE_ID FROM b_ticket_sla_2_site WHERE SLA_ID = $slaID";
306 $rs =
$DB->Query($strSql);
314 static $GetSiteArrayForAllSLACache;
315 if(
$p !== self::SITE_SLA)
319 if(!is_array($GetSiteArrayForAllSLACache))
322 $GetSiteArrayForAllSLACache =
array();
328 b_ticket_sla_2_site SS
330 $rs =
$DB->Query($strSql);
331 while (
$ar =
$rs->Fetch())
333 $GetSiteArrayForAllSLACache[self::SLA_SITE][
$ar[
"SLA_ID"]][] =
$ar[
"SITE_ID"];
334 $GetSiteArrayForAllSLACache[self::SITE_SLA][
$ar[
"SITE_ID"]][] =
$ar[
"SLA_ID"];
337 return $GetSiteArrayForAllSLACache[
$p];
344 $slaID = intval($slaID);
347 $strSql =
"SELECT CATEGORY_ID FROM b_ticket_sla_2_category WHERE SLA_ID = $slaID";
348 $rs =
$DB->Query($strSql);
358 $slaID = intval($slaID);
361 $strSql =
"SELECT CRITICALITY_ID FROM b_ticket_sla_2_criticality WHERE SLA_ID = $slaID";
362 $rs =
$DB->Query($strSql);
372 $slaID = intval($slaID);
375 $strSql =
"SELECT MARK_ID FROM b_ticket_sla_2_mark WHERE SLA_ID = $slaID";
376 $rs =
$DB->Query($strSql);
388 $arSort =
array(
"FIRST_SITE_ID" =>
"ASC",
"PRIORITY" =>
"ASC");
400 $arrGroups =
array();
402 if ($userID===
false && is_object(
$USER)) $userID =
$USER->GetID();
405 $userID = intval($userID);
406 if ($userID>0) $arrGroups = CUser::GetUserGroup($userID);
407 if (
count($arrGroups)<=0) $arrGroups[] = 2;
409 $arSla2Site =
array();
410 $rs =
$DB->Query(
"SELECT SLA_ID, SITE_ID FROM b_ticket_sla_2_site");
411 while (
$ar =
$rs->Fetch()) $arSla2Site[
$ar[
"SLA_ID"]][] =
$ar[
"SITE_ID"];
417 b_ticket_sla_2_user_group SG
418 INNER JOIN b_ticket_sla S ON (S.ID = SG.SLA_ID)
420 SG.GROUP_ID in (".implode(
",",$arrGroups).
")
422 SG.SLA_ID, S.PRIORITY
426 $rs =
$DB->Query($strSql);
427 while (
$ar =
$rs->Fetch())
429 if (is_array($arSla2Site[
$ar[
"SLA_ID"]]) && (in_array(
$siteID, $arSla2Site[
$ar[
"SLA_ID"]]) || in_array(
"ALL", $arSla2Site[
$ar[
"SLA_ID"]])))
431 $slaID =
$ar[
"SLA_ID"];
438 public static function GetSLA(
$siteID, $userID, $categoryID =
null, $coupon =
"" )
442 $userID = intval($userID);
447 if($arCoupon = $rsCoupon->Fetch())
449 if(intval($arCoupon[
'SLA_ID']) > 0)
451 return intval($arCoupon[
'SLA_ID']);
456 $slaID = COption::GetOptionString(
"support",
"SUPPORT_DEFAULT_SLA_ID" );
458 $OLD_FUNCTIONALITY = COption::GetOptionString(
"support",
"SUPPORT_OLD_FUNCTIONALITY",
"Y" );
459 if( $OLD_FUNCTIONALITY ==
"Y" )
466 if( $categoryID !=
null )
468 $categoryID = intval($categoryID);
470 WHEN SC.SLA_ID IS NOT NULL THEN 1
474 LEFT JOIN b_ticket_sla_2_category SC
476 AND ( SC.CATEGORY_ID = 0 OR SC.CATEGORY_ID = $categoryID )";
490 INNER JOIN b_ticket_sla_2_site SS
492 AND ( SS.SITE_ID = 'ALL' OR SS.SITE_ID = '$siteID' )
493 INNER JOIN b_ticket_sla_2_user_group SG
498 WHERE SG.GROUP_ID IN (
499 SELECT UG.GROUP_ID FROM b_user_group UG
502 AND (UG.DATE_ACTIVE_FROM IS NULL OR UG.DATE_ACTIVE_FROM <= ".$DB->CurrentTimeFunction().
")
503 AND (UG.DATE_ACTIVE_TO IS NULL OR UG.DATE_ACTIVE_TO >= ".
$DB->CurrentTimeFunction().
")
508 PZ.SLA_ID, PZ.PRIORITY1, PZ.PRIORITY2
510 PZ.PRIORITY1 DESC, PZ.PRIORITY2 DESC
514 $rs =
$DB->Query($strSql);
517 if( is_array(
$ar ) && array_key_exists(
"SLA_ID",
$ar ) )
519 $slaID =
$ar[
"SLA_ID"];
static GetRoles(&$isDemo, &$isSupportClient, &$isSupportTeam, &$isAdmin, &$isAccess, &$userID, $checkRights=true)
static PrepareFields($arFields, $table, $id)
static CheckFields($arFields, $id, $arRequired)
static Delete($id, $checkRights=true)
static GetForUser($siteID=false, $userID=false)
static GetSheduleArray($slaID)
static GetSLA( $siteID, $userID, $categoryID=null, $coupon="")
static GetSiteArrayForAllSLA($p=self::SLA_SITE)
static GetSiteArray($slaID)
static GetCategoryArray($slaID)
static GetGroupArrayForAllSLA()
static GetCriticalityArray($slaID)
static Set($arFields, $id, $checkRights=true)
static GetMarkArray($slaID)
static GetDropDown($siteID="")
static GetGroupArray($slaID)
static GetList($arOrder=array(), $arFilter=array())
static GetList(&$arSort, $arFilter=Array(), &$isFiltered)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
GetMessage($name, $aReplace=null)
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"