is::GetList

  1. Bitrix24 API (v. 23.675.0)
  2. tasks
  3. is
  4. GetList
  • Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/classes/general/taskelapsed.php
  • Класс: \is
  • Вызов: is::GetList
static function GetList($arOrder, $arFilter, $arParams = array())
{
	global $DB;

	/** @noinspection PhpDeprecationInspection */
	$arSqlSearch = static::GetFilter($arFilter);

	if (isset($arParams['skipJoinUsers']) && $arParams['skipJoinUsers'])
		$bJoinUsers = false;
	else
		$bJoinUsers = true;

	$strSql = "
		SELECT
			TE.*,
			" . $DB->DateToCharFunction("TE.CREATED_DATE", "FULL") . " AS CREATED_DATE, "
			. $DB->DateToCharFunction("TE.DATE_START", "FULL") . " AS DATE_START, "
			. $DB->DateToCharFunction("TE.DATE_STOP", "FULL") . " AS DATE_STOP ";

	if ($bJoinUsers)
	{
		$strSql .= " ,
			U.NAME AS USER_NAME,
			U.LAST_NAME AS USER_LAST_NAME,
			U.SECOND_NAME AS USER_SECOND_NAME,
			U.LOGIN AS USER_LOGIN ";
	}

	$strSql .= "
		FROM
			b_tasks_elapsed_time TE ";

	if ($bJoinUsers)
	{
		$strSql .= " INNER JOIN
			b_user U
		ON
			U.ID = TE.USER_ID
		";
	}

	if ( ! empty($arSqlSearch) )
		$strSql .= "WHERE " . implode(" AND ", $arSqlSearch);

	if (!is_array($arOrder))
		$arOrder = array("CREATED_DATE" => "ASC");

	if ( ! empty($arOrder) )
	{
		foreach ($arOrder as $by => $order)
		{
			$by = mb_strtolower($by);
			$order = mb_strtolower($order);
			if ($order != "asc")
				$order = "desc";

			if ($by == "id")
				$arSqlOrder[] = " TE.ID ".$order." ";
			elseif ($by == "user" || $by == "user_id")
				$arSqlOrder[] = " TE.USER_ID ".$order." ";
			elseif ($by == "field")
				$arSqlOrder[] = " TE.FIELD ".$order." ";
			elseif ($by == "minutes")
				$arSqlOrder[] = " TE.MINUTES ".$order." ";
			elseif ($by == "seconds")
				$arSqlOrder[] = " TE.SECONDS ".$order." ";
			elseif ($by == "rand")
				$arSqlOrder[] = CTasksTools::getRandFunction();
			else
				$arSqlOrder[] = " TE.CREATED_DATE ".$order." ";
		}

		DelDuplicateSort($arSqlOrder);
		$strSql .= " ORDER BY " . implode(', ', $arSqlOrder);
	}

	return $DB->Query($strSql, false, "File: ".__FILE__."
Line: ".__LINE__); }

Добавить комментарий