示例#1
0
文件: functions.php 项目: kudin/crm
function trackStartedTask($stopStartedTask = true)
{
    CModule::IncludeModule('iblock');
    $res = CIBlockElement::GetList(array(), array("IBLOCK_ID" => TASKS_IBLOCK_ID, 'ACTIVE' => 'Y', "PROPERTY_PROGRAMMER" => CUser::GetID(), "PROPERTY_STATUS" => STATUS_LIST_WORK), false, false, array('ID', 'NAME', 'PROPERTY_PROJECT', 'PROPERTY_STATUS_DATE'));
    if ($taskArr = $res->Fetch()) {
        if ($stopStartedTask) {
            CIBlockElement::SetPropertyValuesEx($taskArr['ID'], TASKS_IBLOCK_ID, array('STATUS' => STATUS_LIST_PAUSE));
        }
        $link = TASKS_LIST_URL . $taskArr["PROPERTY_PROJECT_VALUE"] . '/' . $taskArr['ID'] . '/';
        $date = new DateTime($taskArr["PROPERTY_STATUS_DATE_VALUE"]);
        $curdate = new DateTime();
        $diff = $date->diff($curdate);
        $h = $diff->format('%h');
        $i = $diff->format('%i');
        if ($h || $i) {
            $timingText = '';
            if ($h) {
                $timingText = "{$h} ч, ";
            }
            if ($i) {
                $timingText = $timingText . "{$i} мин. ";
            }
            $decTime = $h + $i / 60;
            $decTime = round($decTime, 2);
            $el = new CIBlockElement();
            if ($el->Add(array("DATE_ACTIVE_FROM" => ConvertTimeStamp(time(), "SHORT"), "MODIFIED_BY" => CUser::GetID(), "IBLOCK_SECTION_ID" => false, "IBLOCK_ID" => TRACKING_IBLOCK_ID, "NAME" => 'Без названия' . ' (' . $decTime . 'ч.)', "ACTIVE" => "Y", "PROPERTY_VALUES" => array("HOURS" => $decTime, "TASK" => $taskArr['ID'])))) {
                crmEntitiesHelper::recalcTaskTracking($taskArr['ID']);
                ToolTip::Add("+ {$timingText} в трекер задачи \"<a target=\"_blank\" href=\"{$link}\">{$taskArr['ID']} {$taskArr['NAME']}</a>\"");
            } else {
                ToolTip::AddError($el->LAST_ERROR);
            }
        }
    }
}
示例#2
0
文件: component.php 项目: kudin/crm
            break;
        }
    }
    LocalRedirect($APPLICATION->GetCurDir() . '#comment' . intval($_REQUEST['id']));
}
/* delete comment */
if ($delete_comment = $_REQUEST['delete_comment']) {
    foreach ($arResult['COMMENTS'] as $comment) {
        if ($comment['ID'] == $delete_comment) {
            if ($comment['CREATED_BY'] == $arResult['USER_ID']) {
                $el = new CIBlockElement();
                $res = $el->Update($delete_comment, array("ACTIVE" => 'N'));
                crmEntitiesHelper::recalcCommentsCnt($arParams['ID']);
                $logger->add(array($arResult['TASK']['PROPS']['CUSTOMER']['VALUE'], $arResult['TASK']['PROPS']['PROGRAMMER']['VALUE']), $arParams['ID'], 'delete_comment', strip_tags($comment['~PREVIEW_TEXT']));
                ToolTip::Add('Комментарий удалён');
                crmEntitiesHelper::RecalcLastCommentDateTime($arParams['ID']);
            } else {
                ToolTip::AddError('Ошибка доступа к комментарию');
            }
            break;
        }
    }
    LocalRedirect($APPLICATION->GetCurDir());
}
/* tracking time */
$res = CIBlockElement::GetList(array("ID" => "ASC"), array("PROPERTY_TASK" => $arParams['ID'], "IBLOCK_ID" => TRACKING_IBLOCK_ID, "ACTIVE" => "Y"), false, false, array('DETAIL_TEXT', 'ID', 'DATE_CREATE', 'PROPERTY_HOURS'));
while ($ar_fields = $res->GetNext()) {
    $ar_fields['DATE_CREATE'] = CIBlockFormatProperties::DateFormat($arParams['DATE_FORMAT'], MakeTimeStamp($ar_fields['DATE_CREATE'], CSite::GetDateFormat()));
    $arResult['TRACKING'][] = $ar_fields;
}
$this->IncludeComponentTemplate();