Blame view

zadanie-4.php 3.94 KB
2fe1e5ce8   Андрей Ларионов   Первый коммит на ...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
  <?
  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");?>