- Модуль: support
- Путь к файлу: ~/bitrix/modules/support/classes/general/holidays.php
- Класс: CSupportHolidays
- Вызов: CSupportHolidays::Delete
static function Delete($id, $checkRights=true)
{
$err_mess = (self::err_mess())."
Function: Delete
Line: ";
global $DB, $USER, $APPLICATION;
$id = intval($id);
$table = self::table;
$table_s2h = self::table_s2h;
if ($id <= 0) return false;
$isDemo = null;
$isSupportClient = null;
$isSupportTeam = null;
$isAdmin = null;
$isAccess = null;
$userID = null;
CTicket::GetRoles($isDemo, $isSupportClient, $isSupportTeam, $isAdmin, $isAccess, $userID, $checkRights);
if(!$isAdmin)
{
$arMsg = Array();
$arMsg[] = array("id"=>"PERMISSION", "text"=> GetMessage("SUP_ERROR_ACCESS_DENIED"));
$e = new CAdminException($arMsg);
$APPLICATION->ThrowException($e);
return false;
}
// get affected sla
$affected_sla = array();
$res = $DB->Query("SELECT SLA_ID FROM b_ticket_sla_2_holidays WHERE HOLIDAYS_ID = $id");
while ($row = $res->Fetch())
{
$affected_sla[] = $row['SLA_ID'];
}
// delete
$DB->Query("DELETE FROM $table WHERE ID = $id", false, $err_mess . __LINE__);
$DB->Query("DELETE FROM $table_s2h WHERE HOLIDAYS_ID = $id", false, $err_mess . __LINE__);
// recalculate only affected sla
CSupportTimetableCache::toCache(array("SLA_ID" => $affected_sla));
return true;
}