• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/classes/general/checklist.php
  • Класс: CCheckList
  • Вызов: CCheckList::GetSectionStat
function GetSectionStat($ID = false)
{
	$arResult = array(
		"CHECK" => 0,
		"CHECK_R" => 0,
		"FAILED" => 0,
		"WAITING" => 0,
		"TOTAL" => 0,
		"REQUIRE_CHECK" => 0,
		"REQUIRE_SKIP" => 0,
		"NOT_REQUIRE_CHECK"=>0,
		"NOT_REQUIRE_SKIP"=>0,
		"CHECKED" => "N",
		"REQUIRE" => 0,
	);

	if (($ID!=false && array_key_exists($ID, $this->checklist["CATEGORIES"])) || $ID == false)
	{
		$arPoints = $this->GetPoints($ID);
		$arSections = $this->checklist["CATEGORIES"];
		if (!empty($arPoints))
			foreach ($arPoints as $arPointFields)
			{
				if ($arPointFields["STATE"]["STATUS"] == "A")
				{
					$arResult["CHECK"]++;
					if (isset($arPointFields['REQUIRE']) && $arPointFields['REQUIRE']=='Y')
						$arResult["CHECK_R"]++;
				}
				if ($arPointFields["STATE"]["STATUS"] == "F")
					$arResult["FAILED"]++;
				if ($arPointFields["STATE"]["STATUS"] == "W")
					$arResult["WAITING"]++;
				if (isset($arPointFields["REQUIRE"]) && $arPointFields["REQUIRE"] == "Y")
				{
					$arResult["REQUIRE"]++;
					if ($arPointFields["STATE"]["STATUS"] == "A")
						$arResult["REQUIRE_CHECK"]++;
					elseif($arPointFields["STATE"]["STATUS"] == "S")
						$arResult["REQUIRE_SKIP"]++;
				}
				else
				{
					if ($arPointFields["STATE"]["STATUS"] == "A")
						$arResult["NOT_REQUIRE_CHECK"]++;
					elseif($arPointFields["STATE"]["STATUS"] == "S")
						$arResult["NOT_REQUIRE_SKIP"]++;
				}
			}
		$arResult["TOTAL"] = count($arPoints);

		if ($ID)
		{
			foreach($arSections as $key => $arFields)
			{
				if (isset($arFields["PARENT"]) && $arFields["PARENT"] == $ID)
				{
					$arSubSectionStat = $this->GetSectionStat($key);
					$arResult["TOTAL"]+=$arSubSectionStat["TOTAL"];
					$arResult["CHECK"]+=$arSubSectionStat["CHECK"];
					$arResult["FAILED"]+=$arSubSectionStat["FAILED"];
					$arResult["WAITING"]+=$arSubSectionStat["WAITING"];
					$arResult["REQUIRE"]+=$arSubSectionStat["REQUIRE"];
					$arResult["REQUIRE_CHECK"]+=$arSubSectionStat["REQUIRE_CHECK"];
					$arResult["REQUIRE_SKIP"]+=$arSubSectionStat["REQUIRE_SKIP"];
				}
			}
		}
		if (
			($arResult["REQUIRE"] > 0 && $arResult["FAILED"] == 0 && $arResult["REQUIRE"] == $arResult["REQUIRE_CHECK"])
			|| ($arResult["REQUIRE"] == 0 && $arResult["FAILED"] == 0 && $arResult["TOTAL"] > 0)
			|| ($arResult["CHECK"] == $arResult["TOTAL"] && $arResult["TOTAL"] > 0)
		)
		{
				$arResult["CHECKED"] = "Y";
		}
	}

	return $arResult;
}