zadanie-4.php 3.94 KB
<?
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/header.php");
$APPLICATION->SetTitle("Задание-4");
?>Задание #4<br>
 <br>
 Реализовать задание #2 и #3 при помощи highload-блоков, вместо инфоблоков.<br>
 <br>
 <?
 \Bitrix\Main\Loader::IncludeModule("highloadblock");
 $HLBLOCK_ID = 4;
 
 $hlblock = \Bitrix\Highloadblock\HighloadBlockTable::getById($HLBLOCK_ID)->fetch();
 $entity = \Bitrix\Highloadblock\HighloadBlockTable::compileEntity($hlblock);
 $entityDataClass = $entity->getDataClass();
 
 $arFilter = Array();
 
 if (($_GET['name_filter']) && (!empty($_GET['name_filter']))) {
   $arFilter["UF_NAME"] =	"%".$_GET['name_filter']."%";
}	
if (($_GET['begin_weight_filter']) && (!empty($_GET['begin_weight_filter']))) {
   $arFilter[">UF_WEIGHT"] = $_GET['begin_weight_filter'];
}
if (($_GET['end_weight_filter']) && (!empty($_GET['end_weight_filter']))) {
   $arFilter["<=UF_WEIGHT"] = $_GET['end_weight_filter'];
} 
if (($_GET['begin_height_filter']) && (!empty($_GET['begin_height_filter']))) {
   $arFilter[">UF_HEIGHT"] = $_GET['begin_height_filter'];
}
if (($_GET['end_height_filter']) && (!empty($_GET['end_height_filter']))) {
   $arFilter["<=UF_HEIGHT"] = $_GET['end_height_filter'];
} 
if (($_GET['begin_birdday_filter']) && (!empty($_GET['begin_birdday_filter']))) {
   $arFilter[">=UF_BIRDDAY"] = ConvertDateTime($_GET['begin_birdday_filter']);
}
if (($_GET['end_birdday_filter']) && (!empty($_GET['end_birdday_filter']))) {
    $arFilter["<=UF_BIRDDAY"] = ConvertDateTime($_GET['end_birdday_filter']);
	
}
$count_el = 3;

// создаем объект пагинации 
$nav = new \Bitrix\Main\UI\PageNavigation("nav-more-notice");
$nav->allowAllRecords(true)
   ->setPageSize($count_el)
   ->initFromUri();
 
 $Filter = array(
 "select" => array("*"),
 "order" => array("ID"=>"DESC"),
 "count_total" => true,
 "offset" => $nav->getOffset(), //смещение
 "limit" => $nav->getLimit(), //лимит
 "filter" => $arFilter,
 );
 
 $result = $entityDataClass::getList($Filter);
 $nav->setRecordCount($result->getCount());
 ?>
 
  <div class="filter">
   <form action="" method="GET">
      <label for="name_filter">Название:</label><input type="text" id="name_filter" name="name_filter" value="<?=$_GET['name_filter']?>"/><br>
      <label for="begin_weight_filter">От (вес):</label><input type="text" id="begin_weight_filter" name="begin_weight_filter" value="<?=$_GET['begin_weight_filter']?>"/>
      <label for="end_weight_filter">До (вес):</label><input type="text" id="end_weight_filter" name="end_weight_filter" value="<?=$_GET['end_weight_filter']?>"/><br>
      <label for="begin_height_filter">От (рост):</label><input type="text" id="begin_height_filter" name="begin_height_filter" value="<?=$_GET['begin_height_filter']?>"/>
      <label for="end_height_filter">До (рост):</label><input type="text" id="end_height_filter" name="end_height_filter" value="<?=$_GET['end_height_filter']?>"/><br>
      <label for="begin_birdday_filter">От (дата):</label><input type="text" id="begin_birdday_filter" name="begin_birdday_filter" value="<?=$_GET['begin_birdday_filter']?>"/>
      <label for="end_birdday_filter">До (дата):</label><input type="text" id="end_birdday_filter" name="end_birdday_filter" value="<?=$_GET['end_birdday_filter']?>"/>
	  <input type="submit" value="Отправить"/>
   </form>
 </div><br><br>
 
 <table style="width:100%">
  <tr>
    <th>ID
	<th>Имя
	<th>Вес
	<th>Рост
	<th>Дата рождения
  </tr>	
 <?
 while ($arRow = $result->Fetch()) {?>
	<tr>
     <td><?=$arRow['ID']?></td>
	 <td><?=$arRow['UF_NAME']?></td>
	 <td><?=$arRow['UF_WEIGHT']?></td>
	 <td><?=$arRow['UF_HEIGHT']?></td>
	 <td><?=$arRow['UF_BIRDDAY']?></td>
   </tr>
	
 <?}?>
 </table>
 <?
 $APPLICATION->IncludeComponent("bitrix:main.pagenavigation", "", Array(
	"NAV_OBJECT" => $nav,
		"SEF_MODE" => "N"
	),
	false
);?>
 
<?require($_SERVER["DOCUMENT_ROOT"]."/bitrix/footer.php");?>