<?
if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true) die();
/** @var CBitrixComponent $this */
/** @var array $arParams */
/** @var array $arResult */
/** @var string $componentPath */
/** @var string $componentName */
/** @var string $componentTemplate */
/** @global CDatabase $DB */
/** @global CUser $USER */
/** @global CMain $APPLICATION */

if($this->StartResultCache(60*60*24, md5(var_export($_POST, true))))
{
	if(CModule::IncludeModule('iblock'))
	{
		$sort = Array("SORT" => "ASC", "NAME" => "ASC");
		$filter = Array("ACTIVE" => "Y", "IBLOCK_ID" => IBLOCK_ID_PROGRAMS, "PROPERTY_PREAPPROVAL_VALUE" => "Да" );
		$options = false;

		$arResult['PROGRAMS'] = [];

		$programs_res = CIBlockElement::GetList($sort, $filter, false, []);
		while ($programs_ob_element = $programs_res->GetNextElement())
		{
			$programs_ar_res = $programs_ob_element->GetFields();
			$programs_ar_res['PROPERTIES'] = $programs_ob_element->GetProperties();

			$arResult['PROGRAMS'][] = [ "CODE" => $programs_ar_res['PROPERTIES']['CODE']['VALUE'], "NAME" => $programs_ar_res['PROPERTIES']['PREAPPROVAL_NAME']['VALUE'] ];
		}

		$this->IncludeComponentTemplate();
	}
}