- Модуль: support
- Путь к файлу: ~/bitrix/modules/support/classes/mysql/support.php
- Класс: CTicket
- Вызов: CTicket::AutoClose
static function AutoClose()
{
$err_mess = (CTicket::err_mess())."
Function: AutoClose
Line: ";
global $DB;
/*$strSql = "
SELECT
T.ID
FROM
b_ticket T
WHERE
T.AUTO_CLOSE_DAYS > 0
and (T.DATE_CLOSE is null or length(T.DATE_CLOSE)<=0)
and (UNIX_TIMESTAMP(now())-UNIX_TIMESTAMP(T.TIMESTAMP_X))/86400 > T.AUTO_CLOSE_DAYS
";*/
$nowTime = $DB->CharToDateFunction(GetTime(time() + CTimeZone::GetOffset(),"FULL"));
$strSql = "
SELECT
T.ID
FROM
b_ticket T
WHERE
T.AUTO_CLOSE_DAYS > 0
and (T.DATE_CLOSE is null or length(T.DATE_CLOSE)<=0)
and (UNIX_TIMESTAMP($nowTime)-UNIX_TIMESTAMP(T.LAST_MESSAGE_DATE))/86400 > T.AUTO_CLOSE_DAYS
and T.LAST_MESSAGE_BY_SUPPORT_TEAM = 'Y'
";//now()
$rsTickets = $DB->Query($strSql, false, $err_mess.__LINE__);
while ($arTicket = $rsTickets->Fetch())
{
$arFields = array(
"TIMESTAMP_X" => $DB->GetNowFunction(),
"DATE_CLOSE" => $DB->GetNowFunction(),
"MODIFIED_USER_ID" => "null",
"MODIFIED_GUEST_ID" => "null",
"MODIFIED_MODULE_NAME" => "'auto closing'",
//"AUTO_CLOSE_DAYS" => "null",
"AUTO_CLOSED" => "'Y'"
);
$DB->Update("b_ticket",$arFields,"WHERE ID='".$arTicket["ID"]."'",$err_mess.__LINE__);
}
return "CTicket::AutoClose();";
}