static function getMap()
{
/**
* @global CDatabase $DB
*/
global $DB;
// this is required only for getting STATUS_PSEUDO
// avoid using this field :(
$userId = (int) \Bitrix\Tasks\Util\User::getId();
return array_merge(parent::getMap(), array(
'DESCRIPTION_TR' => array(
'data_type' => 'string',
'expression' => array(
self::getDbTruncTextFunction('mysql', '%s'),
'DESCRIPTION'
)
),
'STATUS_PSEUDO' => array(
'data_type' => 'string',
'expression' => array(
"CASE
WHEN
%s < ".$DB->currentTimeFunction()." AND %s != '4' AND %s != '5' ".($userId ? " AND (%s != '7' OR %s != ".$userId.")" : "")."
THEN
'-1'
ELSE
%s
END",
'DEADLINE', 'STATUS', 'STATUS', 'STATUS', 'RESPONSIBLE_ID', 'STATUS'
)
),
'CREATED_BY_USER' => array(
'data_type' => 'Bitrix\Main\User',
'reference' => array(
'=this.CREATED_BY' => 'ref.ID'
)
),
'CHANGED_BY_USER' => array(
'data_type' => 'Bitrix\Main\User',
'reference' => array('=this.CHANGED_BY' => 'ref.ID')
),
'STATUS_CHANGED_BY_USER' => array(
'data_type' => 'Bitrix\Main\User',
'reference' => array('=this.STATUS_CHANGED_BY' => 'ref.ID')
),
'CLOSED_BY_USER' => array(
'data_type' => 'Bitrix\Main\User',
'reference' => array('=this.CLOSED_BY' => 'ref.ID')
),
'TIME_SPENT_IN_LOGS' => array( // in seconds
'data_type' => 'integer',
'expression' => array(
'(SELECT SUM(SECONDS) FROM b_tasks_elapsed_time WHERE TASK_ID = %s)',
'ID'
)
),
'DURATION' => array( // in minutes (deprecated, use TIME_SPENT_IN_LOGS, which is in seconds, that works correctly in expressions)
'data_type' => 'integer',
'expression' => array(
'ROUND((SELECT SUM(SECONDS)/60 FROM b_tasks_elapsed_time WHERE TASK_ID = %s),0)',
'ID'
)
),
// DURATION_PLAN_MINUTES field - only for old user reports, which use it
'DURATION_PLAN_MINUTES' => array(
'data_type' => 'integer',
'expression' => array(
'ROUND(%s / 60, 0)',
'DURATION_PLAN' // in seconds
)
),
'DURATION_PLAN_HOURS' => array(
'data_type' => 'integer',
'expression' => array(
'ROUND(%s / 3600, 0)',
'DURATION_PLAN' // in seconds
)
),
'IS_OVERDUE' => array(
'data_type' => 'boolean',
'expression' => array(
'CASE WHEN %s IS NOT NULL AND (%s < %s OR (%s IS NULL AND %s < '.$DB->currentTimeFunction().')) THEN 1 ELSE 0 END',
'DEADLINE', 'DEADLINE', 'CLOSED_DATE', 'CLOSED_DATE', 'DEADLINE'
),
'values' => array(0, 1)
),
'IS_OVERDUE_PRCNT' => array(
'data_type' => 'integer',
'expression' => array(
'SUM(%s)/COUNT(%s)*100',
'IS_OVERDUE', 'ID'
)
),
'IS_MARKED' => array(
'data_type' => 'boolean',
'expression' => array(
'CASE WHEN %s IN(\'P\', \'N\') THEN 1 ELSE 0 END',
'MARK'
),
'values' => array(0, 1)
),
'IS_MARKED_PRCNT' => array(
'data_type' => 'integer',
'expression' => array(
'SUM(%s)/COUNT(%s)*100',
'IS_MARKED', 'ID'
)
),
'IS_EFFECTIVE' => array(
'data_type' => 'boolean',
'expression' => array(
'CASE WHEN %s = \'P\' THEN 1 ELSE 0 END',
'MARK'
),
'values' => array(0, 1)
),
'IS_EFFECTIVE_PRCNT' => array(
'data_type' => 'integer',
'expression' => array(
'SUM(%s)/COUNT(%s)*100',
'IS_EFFECTIVE', 'ID'
)
),
'IS_RUNNING' => array(
'data_type' => 'boolean',
'expression' => array(
'CASE WHEN %s IN (3,4) THEN 1 ELSE 0 END',
'STATUS'
),
'values' => array(0, 1)
),
'DECLINE_REASON' => array(
'data_type' => 'text',
),
'DEADLINE_COUNTED' => array(
'data_type' => 'integer',
'required' => true,
),
));
}