function tasksRenderJSON($arTask, $childrenCount, $arPaths, $bParent = false, $bGant = false, $top = false, $nameTemplate = "", $arAdditionalFields = array(), $bSkipJsMenu = false) { global $USER; $arAllowedTaskActions = array(); if (isset($arTask['META:ALLOWED_ACTIONS'])) { $arAllowedTaskActions = $arTask['META:ALLOWED_ACTIONS']; } elseif ($arTask['ID']) { $oTask = CTaskItem::getInstanceFromPool($arTask['ID'], $USER->getId()); $arAllowedTaskActions = $oTask->getAllowedTaskActionsAsStrings(); $arTask['META:ALLOWED_ACTIONS'] = $arAllowedTaskActions; } $runningTaskId = $runningTaskTimer = null; if ($arTask['ALLOW_TIME_TRACKING'] === 'Y') { $oTimer = CTaskTimerManager::getInstance($USER->getId()); $runningTaskData = $oTimer->getRunningTask(false); $runningTaskId = $runningTaskData['TASK_ID']; $runningTaskTimer = time() - $runningTaskData['TIMER_STARTED_AT']; } ?> { id : <?php echo $arTask["ID"]; ?> , name : "<?php echo CUtil::JSEscape($arTask["TITLE"]); ?> ", <?php if ($arTask["GROUP_ID"]) { ?> projectId : <?php echo $arTask["GROUP_ID"]; ?> , projectName : '<?php echo CUtil::JSEscape($arTask['GROUP_NAME']); ?> ', <?php } ?> status : "<?php echo tasksStatus2String($arTask["STATUS"]); ?> ", realStatus : "<?php echo $arTask["REAL_STATUS"]; ?> ", url: '<?php echo CUtil::JSEscape(CComponentEngine::MakePathFromTemplate($arPaths["PATH_TO_TASKS_TASK"], array("task_id" => $arTask["ID"], "action" => "view"))); ?> ', details: window.top.onDetails, priority : <?php echo $arTask["PRIORITY"]; ?> , mark : <?php echo !$arTask["MARK"] ? "null" : "'" . $arTask["MARK"] . "'"; ?> , responsible: '<?php echo CUtil::JSEscape(tasksFormatNameShort($arTask["RESPONSIBLE_NAME"], $arTask["RESPONSIBLE_LAST_NAME"], $arTask["RESPONSIBLE_LOGIN"], $arTask["RESPONSIBLE_SECOND_NAME"], $nameTemplate)); ?> ', director: '<?php echo CUtil::JSEscape(tasksFormatNameShort($arTask["CREATED_BY_NAME"], $arTask["CREATED_BY_LAST_NAME"], $arTask["CREATED_BY_LOGIN"], $arTask["CREATED_BY_SECOND_NAME"], $nameTemplate)); ?> ', responsibleId : <?php echo $arTask["RESPONSIBLE_ID"]; ?> , directorId : <?php echo $arTask["CREATED_BY"]; ?> , responsible_name: '<?php echo CUtil::JSEscape($arTask["RESPONSIBLE_NAME"]); ?> ', responsible_second_name: '<?php echo CUtil::JSEscape($arTask["RESPONSIBLE_SECOND_NAME"]); ?> ', responsible_last_name: '<?php echo CUtil::JSEscape($arTask["RESPONSIBLE_LAST_NAME"]); ?> ', responsible_login: '******', director_name: '<?php echo CUtil::JSEscape($arTask["CREATED_BY_NAME"]); ?> ', director_second_name: '<?php echo CUtil::JSEscape($arTask["CREATED_BY_SECOND_NAME"]); ?> ', director_last_name: '<?php echo CUtil::JSEscape($arTask["CREATED_BY_LAST_NAME"]); ?> ', director_login: '******', dateCreated : <?php tasksJSDateObject($arTask["CREATED_DATE"], $top); ?> , <?php if ($arTask["START_DATE_PLAN"]) { ?> dateStart : <?php tasksJSDateObject($arTask["START_DATE_PLAN"], $top); ?> ,<?php } else { ?> dateStart: null,<?php } ?> <?php if ($arTask["END_DATE_PLAN"]) { ?> dateEnd : <?php tasksJSDateObject($arTask["END_DATE_PLAN"], $top); ?> ,<?php } else { ?> dateEnd: null,<?php } ?> <?php if ($arTask["DATE_START"]) { ?> dateStarted: <?php tasksJSDateObject($arTask["DATE_START"], $top); ?> ,<?php } ?> dateCompleted : <?php if ($arTask["CLOSED_DATE"]) { tasksJSDateObject($arTask["CLOSED_DATE"], $top); } else { ?> null<?php } ?> , <?php if ($arTask["DEADLINE"]) { ?> dateDeadline : <?php tasksJSDateObject($arTask["DEADLINE"], $top); ?> ,<?php } else { ?> dateDeadline: null,<?php } ?> canEditPlanDates : <?php if ($arAllowedTaskActions['ACTION_EDIT']) { ?> true<?php } else { ?> false<?php } ?> , <?php if ($arTask["PARENT_ID"] && $bParent) { ?> parentTaskId : <?php echo $arTask["PARENT_ID"]; ?> , <?php } ?> <?php if (sizeof($arTask["FILES"])) { $i = 0; ?> files: [ <?php foreach ($arTask["FILES"] as $file) { $i++; ?> { name : '<?php echo CUtil::JSEscape($file["ORIGINAL_NAME"]); ?> ', url : '/bitrix/components/bitrix/tasks.task.detail/show_file.php?fid=<?php echo $file["ID"]; ?> ', size : '<?php echo CUtil::JSEscape(CFile::FormatSize($file["FILE_SIZE"])); ?> ' }<?php if ($i != sizeof($arTask["FILES"])) { ?> ,<?php } ?> <?php } ?> ], <?php } ?> <?php if (count($arTask['ACCOMPLICES']) > 0) { $i = 0; echo 'accomplices: ['; foreach ($arTask['ACCOMPLICES'] as $ACCOMPLICE_ID) { if ($i++) { echo ','; } echo '{ id: ' . (int) $ACCOMPLICE_ID . ' }'; } echo '], '; } ?> <?php if (count($arTask['AUDITORS']) > 0) { $i = 0; echo 'auditors: ['; foreach ($arTask['AUDITORS'] as $AUDITOR_ID) { if ($i++) { echo ','; } echo '{ id: ' . (int) $AUDITOR_ID . ' }'; } echo '], '; } ?> isSubordinate: <?php echo $arTask["SUBORDINATE"] == "Y" ? "true" : "false"; ?> , isInReport: <?php echo $arTask["ADD_IN_REPORT"] == "Y" ? "true" : "false"; ?> , hasChildren : <?php if ((int) $childrenCount > 0) { echo 'true'; } else { echo 'false'; } ?> , childrenCount : <?php echo (int) $childrenCount; ?> , canEditDealine : <?php if ($arAllowedTaskActions['ACTION_EDIT'] || $arAllowedTaskActions['ACTION_CHANGE_DEADLINE']) { echo 'true'; } else { echo 'false'; } ?> , canStartTimeTracking : <?php if ($arAllowedTaskActions['ACTION_START_TIME_TRACKING']) { ?> true<?php } else { ?> false<?php } ?> , ALLOW_TIME_TRACKING : <?php if (isset($arTask['ALLOW_TIME_TRACKING']) && $arTask['ALLOW_TIME_TRACKING'] === 'Y') { echo 'true'; } else { echo 'false'; } ?> , TIMER_RUN_TIME : <?php if ($runningTaskId == $arTask['ID']) { echo (int) $runningTaskTimer; } else { echo 'false'; } ?> , TIME_SPENT_IN_LOGS : <?php echo (int) $arTask['TIME_SPENT_IN_LOGS']; ?> , TIME_ESTIMATE : <?php echo (int) $arTask['TIME_ESTIMATE']; ?> , IS_TASK_TRACKING_NOW : <?php if ($runningTaskId == $arTask['ID']) { echo 'true'; } else { echo 'false'; } ?> , menuItems: [<?php tasksGetItemMenu($arTask, $arPaths, SITE_ID, $bGant, $top, $bSkipJsMenu); ?> ] <?php foreach ($arAdditionalFields as $key => $value) { echo ', ' . $key . ' : ' . $value . "\n"; } ?> } <?php }
?> </span></td> <td class="task-time-author-column"><script type="text/javascript">BX.tooltip(<?php echo $time["USER_ID"]; ?> , "anchor_elapsed_<?php echo $anchor_id; ?> ", "");</script><a id="anchor_elapsed_<?php echo $anchor_id; ?> " class="task-log-author" target="_top" href="<?php echo CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_USER_PROFILE"], array("user_id" => $time["USER_ID"])); ?> "><?php echo tasksFormatNameShort($time["USER_NAME"], $time["USER_LAST_NAME"], $time["USER_LOGIN"], $time["USER_SECOND_NAME"], $arParams["NAME_TEMPLATE"], false); ?> </a></td> <td class="task-time-spent-column"><?php echo floor($time["SECONDS"] / 3600); ?> <span><?php echo GetMessage("TASKS_ELAPSED_H"); ?> </span><?php echo sprintf("%02d", floor($time["SECONDS"] / 60) % 60); ?> <span><?php echo GetMessage("TASKS_ELAPSED_M"); ?> </span><?php
<b><a href="<?php echo CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_TASKS_TASK"], array("task_id" => $arTask["ID"], "action" => "view")); ?> "><?php echo $arTask["TITLE"]; ?> </a></b><br /> <?php if ($arResult["TASK_TYPE"] == "group") { ?> <small><br /><?php echo GetMessage("INTASK_TASKASSIGNEDTO"); ?> : <?php echo tasksFormatNameShort($arTask["RESPONSIBLE_NAME"], $arTask["RESPONSIBLE_LAST_NAME"], $arTask["RESPONSIBLE_LOGIN"], $arTask["RESPONSIBLE_SECOND_NAME"], $arParams["NAME_TEMPLATE"]); ?> </small> <?php } ?> <br clear="left"/> <span class="sonet-forum-post-info"> <span class="sonet-forum-eye"><?php echo GetMessage("INTASK_TASKPRIORITY"); ?> </span>: <?php echo GetMessage("TASKS_PRIORITY_" . $arTask["PRIORITY"]); ?>
// Don't format time, if it's 00:00 if (date('H:i', $arData['FROM_VALUE']) == '00:00') { $strDateFrom = FormatDate(CDatabase::DateFormatToPHP(FORMAT_DATE), $arData['FROM_VALUE']); } else { $strDateFrom = FormatDate(CDatabase::DateFormatToPHP(FORMAT_DATETIME), $arData['FROM_VALUE']); } } if ($arData['TO_VALUE']) { // Don't format time, if it's 00:00 if (date('H:i', $arData['TO_VALUE']) == '00:00') { $strDateTo = FormatDate(CDatabase::DateFormatToPHP(FORMAT_DATE), $arData['TO_VALUE']); } else { $strDateTo = FormatDate(CDatabase::DateFormatToPHP(FORMAT_DATETIME), $arData['TO_VALUE']); } } $arResult = array('td1' => '<span class="task-log-date">' . FormatDateFromDB($arData['CREATED_DATE']) . '</span>', 'td2' => '<a class="task-log-author" target="_top" href="' . CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_USER_PROFILE'], array('user_id' => $authorUserId)) . '">' . htmlspecialcharsbx(tasksFormatNameShort($arCurUserData["NAME"], $arCurUserData["LAST_NAME"], $arCurUserData["LOGIN"], $arCurUserData["SECOND_NAME"], $arParams["NAME_TEMPLATE"])) . '</a>', 'td3' => '<span class="task-log-where">' . GetMessage("TASKS_LOG_DEADLINE") . '</span>', 'td4' => '<span class="task-log-what">' . $strDateFrom . '<span class="task-log-arrow">→</span>' . $strDateTo . '</span>'); header('Content-Type: application/x-javascript; charset=' . LANG_CHARSET); echo CUtil::PhpToJsObject($arResult); } } elseif ($action === 'remove_file') { try { CTaskAssert::log('remove_file: fileId=' . $_POST['fileId'] . ', taskId=' . $_POST['taskId'] . ', userId=' . $loggedInUserId, CTaskAssert::ELL_INFO); CTaskAssert::assert(isset($_POST['fileId'], $_POST['taskId'])); $oTaskItem = new CTaskItem($_POST['taskId'], $loggedInUserId); $oTaskItem->removeAttachedFile($_POST['fileId']); echo 'Success'; } catch (Exception $e) { echo 'Error occured'; CTaskAssert::logWarning('Unable to remove_file: fileId=' . $_POST['fileId'] . ', taskId=' . $_POST['taskId'] . ', userId=' . $loggedInUserId); } } elseif ($action === 'render_task_detail_part') {
?> <tr> <?php foreach ($arExcelFields as $field) { switch ($field) { case 'TITLE': // due to http://jabber.bx/view.php?id=39850 if (preg_match('/^[0-9 \\t]*$/', $arResult["TASKS"][$i][$field])) { $arResult["TASKS"][$i][$field] = "'" . $arResult["TASKS"][$i][$field]; } break; case "RESPONSIBLE_ID": case "CREATED_BY": $rsUser = CUser::GetByID($arResult["TASKS"][$i][$field]); if ($arUser = $rsUser->GetNext()) { $arResult["TASKS"][$i][$field] = tasksFormatNameShort($arUser["NAME"], $arUser["LAST_NAME"], $arUser["LOGIN"], $arUser["SECOND_NAME"], $arParams["NAME_TEMPLATE"]); } break; case "PRIORITY": $arResult["TASKS"][$i][$field] = GetMessage("TASKS_PRIORITY_" . $arResult["TASKS"][$i][$field]); break; case "REAL_STATUS": $arResult["TASKS"][$i][$field] = GetMessage("TASKS_STATUS_" . $arResult["TASKS"][$i][$field]); break; case "MARK": $arResult["TASKS"][$i][$field] = $arResult["TASKS"][$i][$field] ? GetMessage("TASKS_MARK_" . $arResult["TASKS"][$i][$field]) : GetMessage("TASKS_MARK_NONE"); break; case "ADD_IN_REPORT": $arResult["TASKS"][$i][$field] = $arResult["TASKS"][$i][$field] == "Y" ? GetMessage("TASKS_SIDEBAR_IN_REPORT_YES") : GetMessage("TASKS_SIDEBAR_IN_REPORT_NO"); break; case "TIME_ESTIMATE":