33 public static function get($params = [])
35 $filterType = in_array($params[
'TYPE'], self::getTypes(),
true)? $params[
'TYPE']:
self::TYPE_ALL;
36 $filterCallId = $params[
'TYPE'] === self::TYPE_SEARCH? intval($params[
'CALL_ID']): 0;
39 'ID',
'UUID',
'TYPE',
'INITIATOR_ID',
'PROVIDER',
'STATE',
'LOG_URL',
40 'ENTITY_TYPE',
'ENTITY_ID',
41 'START_DATE',
'END_DATE',
42 'CHAT_TITLE' =>
'CHAT.TITLE'
46 new \Bitrix\Main\Entity\ReferenceField(
48 \
Bitrix\Im\Model\ChatTable::class,
50 "=ref.ID" =>
"this.CHAT_ID",
58 if ($filterType == self::TYPE_SEARCH)
61 '=ID' => $filterCallId
66 if ($filterType == self::TYPE_NOW)
69 '!=STATE' => \Bitrix\Im\Call\Call::STATE_FINISHED
73 if ($params[
'LAST_ID'])
75 $filter[
'<ID'] = $params[
'LAST_ID'];
79 $result = \Bitrix\Im\Model\CallTable::getList([
81 'runtime' => $runtime,
83 'order' => [
'ID' =>
'DESC'],
88 while($row = $result->fetch())
92 if (!$call[
'CHAT_TITLE'])
94 $call[
'CHAT_TITLE'] =
User::getInstance($call[
'INITIATOR_ID'])->getLastName(
false);
96 if ($call[
'ENTITY_TYPE'] ===
'chat' && !
Common::isChatId($call[
'ENTITY_ID']))
98 $call[
'CHAT_TITLE'] .=
' -> '.User::getInstance($call[
'ENTITY_ID'])->getLastName(
false);
102 $call[
'CHAT_TITLE'] .=
' -> '.ucfirst($call[
'ENTITY_TYPE']);
106 $call[
'DURATION'] = 0;
110 $call[
'DURATION'] = $endDate - $startDate;
111 $call[
'DURATION_TEXT'] = \CModule::includeModule(
'voximplant') ? \CVoxImplantHistory::convertDurationToText($call[
'DURATION']) : $call[
'DURATION'];
113 $call[
'CONNECTIONS'] = [];
115 $list[$row[
'ID']] = $call;
118 $result = \Bitrix\Im\Model\CallUserTable::getList([
119 'select' => [
'CALL_ID',
'USER_ID',
'STATE',
'LAST_SEEN'],
121 '=CALL_ID' => array_keys($list)
125 while($row = $result->fetch())
129 $connection[
'INITIATOR'] = $list[$row[
'CALL_ID']][
'INITIATOR_ID'] === $row[
'USER_ID'];
130 $connection[
'USER_NAME'] =
User::getInstance($row[
'USER_ID'])->getFullName(
false);
134 if (defined(
'IM_CALL_LOG_PATH'))
136 $connection[
'LOG_URL'] = IM_CALL_LOG_PATH.
"{$row['CALL_ID']}-{$row['USER_ID']}.txt";
140 $connection[
'STAT_URL'] = str_replace(
150 $list[$row[
'CALL_ID']][
'START_DATE']->getTimestamp() * 1000,
151 $list[$row[
'CALL_ID']][
'END_DATE']
152 ? $list[$row[
'CALL_ID']][
'END_DATE']->getTimestamp() * 1000
153 : ($list[$row[
'CALL_ID']][
'START_DATE']->getTimestamp() + 7200) * 1000
160 unset($connection[
'CALL_ID']);
162 $list[$row[
'CALL_ID']][
'CONNECTIONS'][] = $connection;