Ejemplo n.º 1
0
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);
            }
        }
    }
}
Ejemplo n.º 2
0
Archivo: index.php Proyecto: kudin/crm
        if ($result = $res->GetNext()) {
            CIBlockElement::Delete($track);
            $summ = crmEntitiesHelper::recalcTaskTracking($result['PROPERTY_TASK_VALUE']);
            die(json_encode(array('summ' => $summ)));
        } else {
            die(json_encode(array('error' => 'Ошибка доступа к таймингу')));
        }
        break;
    case 'trackTime':
        $task = intval($_REQUEST['task']);
        if ($USER->iAmAProgrammerInTask($task)) {
            $desc = trim(TruncateText($_REQUEST['desc'], 250));
            $time = formatTime($_REQUEST['h'], MAX_TRACKING_TIME);
            if (!$time) {
                die(json_encode(array('error' => 'Введено неверное время')));
            }
            $el = new CIBlockElement();
            if ($newId = $el->Add(array("DATE_ACTIVE_FROM" => ConvertTimeStamp(time(), "SHORT"), "MODIFIED_BY" => $USER->GetID(), "IBLOCK_SECTION_ID" => false, "IBLOCK_ID" => TRACKING_IBLOCK_ID, "NAME" => (strlen($desc) ? $desc : 'Без названия') . ' (' . $time . 'ч.)', "DETAIL_TEXT" => $desc, "ACTIVE" => "Y", "PROPERTY_VALUES" => array("HOURS" => $time, "TASK" => $task)))) {
                $summ = crmEntitiesHelper::recalcTaskTracking($task);
                die(json_encode(array('ok' => $newId, 'summ' => $summ)));
            } else {
                die(json_encode(array('error' => $el->LAST_ERROR)));
            }
        } else {
            die(json_encode(array('error' => 'Ошибка доступа к задаче')));
        }
        break;
    default:
        die(json_encode(array('error' => 'передан неверный параметр')));
        break;
}