• Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/internals/counter/user.php
  • Класс: BitrixTasksInternalsCounterUser
  • Вызов: User::calcAccomplicesExpiredSoon
private function calcAccomplicesExpiredSoon($reCache = false)
{
	static $count = null;

	if ($count == null || $reCache)
	{
		$expiredTime = $this->getExpiredTime();
		$expiredSoonTime = $this->getExpiredSoonTime();

		$statusSupposedlyCompleted = CTasks::STATE_SUPPOSEDLY_COMPLETED;
		$statusCompleted = CTasks::STATE_COMPLETED;
		$statusDeferred = CTasks::STATE_DEFERRED;

		$sql = "
			SELECT 
				COUNT(t.ID) as COUNT,
				t.GROUP_ID
			FROM 
				b_tasks as t
				INNER JOIN b_tasks_member as tm
					ON tm.TASK_ID = t.ID AND tm.TYPE = 'A'
			WHERE
				DEADLINE < '{$expiredSoonTime}'
				AND DEADLINE >= '{$expiredTime}'
				
				AND tm.USER_ID = {$this->userId}
				AND t.ZOMBIE = 'N'
				".($this->groupId > 0 ? " AND t.GROUP_ID = {$this->groupId}" : "")."
				AND (
					t.STATUS != {$statusSupposedlyCompleted}
					AND t.STATUS != {$statusCompleted}
					AND	t.STATUS != {$statusDeferred}
				)
			GROUP BY 
				t.GROUP_ID
		";

		$this->changeCounter(
			CounterName::ACCOMPLICES_EXPIRED_SOON,
			Application::getConnection()->query($sql)->fetchAll()
		);
	}
}