...Человеческий поиск в разработке...
- Модуль: tasks
- Путь к файлу: ~/bitrix/modules/tasks/classes/general/taskelapsed.php
- Класс: \is
- Вызов: is::Add
function Add($arFields, $arParams = array()) { global $DB; $executiveUserId = null; if (isset($arParams['USER_ID'])) $executiveUserId = (int) $arParams['USER_ID']; elseif ($userId = \Bitrix\Tasks\Util\User::getId()) $executiveUserId = $userId; $occurAsUserId = CTasksTools::getOccurAsUserId(); if ( ! $occurAsUserId ) $occurAsUserId = ($executiveUserId ? $executiveUserId : 1); if ($this->CheckFields($arFields)) { $curDuration = 0; $rsTask = CTasks::getList( array(), array('ID' => $arFields['TASK_ID']), array('ID', 'TIME_SPENT_IN_LOGS') ); if ($rsTask && ($arTask = $rsTask->fetch())) $curDuration = (int) $arTask['TIME_SPENT_IN_LOGS']; // Maintance backward compatibility if (isset($arFields['MINUTES'], $arFields['SECONDS'])) { CTaskAssert::logError('[0x1e85844c] '); CTaskAssert::assert(false); } if (isset($arFields['SECONDS'])) $arFields['MINUTES'] = (int) round($arFields['SECONDS'] / 60, 0); elseif (isset($arFields['MINUTES'])) $arFields['SECONDS'] = 60 * $arFields['MINUTES']; else { CTaskAssert::logError('[0x85bbae77] '); CTaskAssert::assert(false); } foreach(GetModuleEvents('tasks', 'OnBeforeTaskElapsedTimeAdd', true) as $arEvent) { if (ExecuteModuleEventEx($arEvent, array(&$arFields))===false) return false; } $arFields['SOURCE'] = CTaskElapsedItem::SOURCE_MANUAL; if (isset($arParams['SOURCE_SYSTEM']) && ($arParams['SOURCE_SYSTEM'] === 'Y')) $arFields['SOURCE'] = CTaskElapsedItem::SOURCE_SYSTEM; if ($arFields['CREATED_DATE']) $createdDate = Bitrix\Main\Type\DateTime::createFromUserTime($arFields['CREATED_DATE']); else $createdDate = new Bitrix\Main\Type\DateTime(); $addResult = \Bitrix\Tasks\Internals\Task\ElapsedTimeTable::add(array( "CREATED_DATE" => $createdDate, "DATE_START" => Bitrix\Main\Type\DateTime::createFromUserTime($arFields['DATE_START'] ?? null), "DATE_STOP" => Bitrix\Main\Type\DateTime::createFromUserTime($arFields['DATE_STOP'] ?? null), "USER_ID" => $arFields["USER_ID"], "TASK_ID" => $arFields["TASK_ID"], "MINUTES" => $arFields["MINUTES"], "SECONDS" => $arFields["SECONDS"], "SOURCE" => $arFields["SOURCE"], "COMMENT_TEXT" => $arFields["COMMENT_TEXT"], )); $ID = $addResult->isSuccess()? $addResult->getId(): false; $oLog = new CTaskLog(); $oLog->Add(array( 'TASK_ID' => $arFields['TASK_ID'], 'USER_ID' => $occurAsUserId, '~CREATED_DATE' => $DB->currentTimeFunction(), 'FIELD' => 'TIME_SPENT_IN_LOGS', 'FROM_VALUE' => $curDuration, 'TO_VALUE' => $curDuration + (int) $arFields['SECONDS'] )); foreach(GetModuleEvents('tasks', 'OnTaskElapsedTimeAdd', true) as $arEvent) ExecuteModuleEventEx($arEvent, array($ID, $arFields)); return $ID; } return false; }