Beispiel #1
0
 protected function getOwnerTaskId($itemId)
 {
     $item = \CTaskElapsedTime::getList(array(), array('ID' => $itemId), array('skipJoinUsers' => false))->fetch();
     if (is_array($item) && !empty($item)) {
         return $item['TASK_ID'];
     } else {
         $this->add('ITEM_NOT_FOUND', 'Item not found');
     }
     return false;
 }
Beispiel #2
0
 public function stop()
 {
     global $CACHE_MANAGER;
     $arTimer = CTaskTimerCore::stop($this->userId);
     $this->cachedLastTimer = null;
     if ($arTimer !== false && $arTimer['TIMER_ACCUMULATOR'] > 0) {
         /** @noinspection PhpDeprecationInspection */
         $o = new CTaskElapsedTime();
         $o->add(array('USER_ID' => $this->userId, 'TASK_ID' => $arTimer['TASK_ID'], 'SECONDS' => $arTimer['TIMER_ACCUMULATOR'], 'COMMENT_TEXT' => ''), array('SOURCE_SYSTEM' => 'Y'));
         $oTaskItem = CTaskItem::getInstance($arTimer['TASK_ID'], $this->userId);
         $arTask = $oTaskItem->getData(false);
         $arAffectedUsers = array_unique(array_merge(array($this->userId, $arTask['RESPONSIBLE_ID']), (array) $arTask['ACCOMPLICES']));
         foreach ($arAffectedUsers as $userId) {
             $CACHE_MANAGER->ClearByTag('tasks_user_' . $userId);
         }
     }
 }
Beispiel #3
0
 function GetByID($ID)
 {
     /** @noinspection PhpDeprecationInspection */
     return CTaskElapsedTime::GetList(array(), array("ID" => $ID));
 }
Beispiel #4
0
 /**
  * DEPRECATED! Migrated to tasks module.
  *
  * @deprecated
  */
 public static function SetTaskTime($arParams)
 {
     if (!self::$arWasElapedCache[$arParams['TASK_ID']]) {
         $ob = new CTaskElapsedTime();
         $ob->Add(array('USER_ID' => $arParams['USER_ID'], 'TASK_ID' => $arParams['TASK_ID'], 'MINUTES' => intval($arParams['TIME'] / 60), 'COMMENT_TEXT' => GetMessage('TIMEMAN_MODULE_NAME')));
     }
 }
Beispiel #5
0
 protected final function fetchDataFromDb($taskId, $itemId)
 {
     /** @noinspection PhpDeprecationInspection */
     $rsData = CTaskElapsedTime::GetList(array(), array('ID' => (int) $itemId));
     if (is_object($rsData) && ($arData = $rsData->fetch())) {
         return $arData;
     } else {
         throw new Exception();
     }
 }
 protected static function getTimemanCloseDayData($arParams)
 {
     if (CModule::IncludeModule('timeman')) {
         global $USER;
         $arTasks = array();
         $userId = $USER->getId();
         $runningTaskId = null;
         $taskRunTime = null;
         // key features of that info:
         // [REPORT_REQ] => 'A' means that day will be closed right now. other variants - just form show.
         // [INFO][DATE_START] => 1385459336 - unix timestamp of day start
         // [INFO][TIME_START] => 46136 - short timestamp of day start
         // [DURATION]
         // [TIME_LEAKS]
         $arTimemanInfo = CTimeMan::GetRunTimeInfo(true);
         if (!($userId > 0)) {
             foreach ($arTimemanInfo['PLANNER']['DATA']['TASKS'] as $arTask) {
                 $arTask['TIME'] = 0;
                 $arTasks[] = $arTask;
             }
             return array('TASKS' => $arTasks);
         }
         $unixTsDateStart = (int) $arTimemanInfo['INFO']['DATE_START'];
         $oTimer = CTaskTimerManager::getInstance($userId);
         $arTimer = $oTimer->getLastTimer();
         if ($arTimer && $arTimer['TIMER_STARTED_AT'] > 0) {
             $runningTaskId = $arTimer['TASK_ID'];
             if ($arTimer['TIMER_STARTED_AT'] >= $unixTsDateStart) {
                 $taskRunTime = max(0, time() - (int) $arTimer['TIMER_STARTED_AT']);
             } else {
                 $taskRunTime = max(0, time() - $unixTsDateStart);
             }
         }
         $bitrixTimestampDateStart = $unixTsDateStart + CTasksTools::getTimeZoneOffset();
         $dateStartAsString = ConvertTimeStamp($bitrixTimestampDateStart, 'FULL');
         foreach ($arTimemanInfo['PLANNER']['DATA']['TASKS'] as $arTask) {
             $rsElapsedTime = CTaskElapsedTime::getList(array('ID' => 'ASC'), array('TASK_ID' => $arTask['ID'], 'USER_ID' => $userId, '>=CREATED_DATE' => $dateStartAsString), array('skipJoinUsers' => true));
             $arTask['TIME'] = 0;
             while ($arElapsedTime = $rsElapsedTime->fetch()) {
                 $arTask['TIME'] += max(0, $arElapsedTime['SECONDS']);
             }
             if ($runningTaskId && $arTask['ID'] == $runningTaskId) {
                 $arTask['TIME'] += $taskRunTime;
             }
             $arTasks[] = $arTask;
         }
         return array('TASKS' => $arTasks);
     }
 }