1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
iblock_catalog_list.php
См. документацию.
1<?php
5
13
14if (!defined('B_ADMIN_IBLOCK_CATALOGS') || B_ADMIN_IBLOCK_CATALOGS != 1 || !defined('B_ADMIN_IBLOCK_CATALOGS_LIST'))
15 return;
16
17$prologAbsent = (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true);
18if (B_ADMIN_IBLOCK_CATALOGS_LIST === false && $prologAbsent)
19 return;
20
22{
23 require_once($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/main/include/prolog_admin_before.php');
24
25 Loader::includeModule('catalog');
26
27 $readOnly = !AccessController::getCurrent()->check(ActionDictionary::ACTION_CATALOG_SETTINGS_ACCESS);
28}
29
30$catalogsAjaxPath = '/bitrix/tools/catalog/iblock_catalog_list.php?lang='.LANGUAGE_ID;
32
33if (isset($_REQUEST['mode']) && ($_REQUEST['mode'] == 'list' || $_REQUEST['mode'] == 'frame'))
34 CFile::DisableJSFunction(true);
35
36require_once($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/iblock/classes/general/subelement.php');
37
38Loc::loadMessages(__FILE__);
39
40$adminListTableID = 'tbl_catalog_iblocks';
41
45$adminList->setDialogParams(array('from_module' => 'catalog'));
46$adminList->setDialogButtons(array());
47unset($hideFields);
48
49if (!isset($by))
50 $by = 'ID';
51if (!isset($order))
52 $order = 'ASC';
53
56
57$adminList->InitFilter($filterFields);
58
59if (!$readOnly && $adminList->EditAction())
60{
61
62}
63
64if (!$readOnly && ($listID = $adminList->GroupAction()))
65{
66
67}
68
71 'id' => 'ID',
72 'content' => 'ID',
73 'sort' => 'ID',
74 'default' => true
75);
77 'id' => 'NAME',
78 'content' => Loc::getMessage('CATALOG_ADM_IBLOCK_CATALOG_HEADER_NAME_NAME'),
79 'title' => Loc::getMessage('CATALOG_ADM_IBLOCK_CATALOG_HEADER_TITLE_NAME'),
80 'sort' => 'NAME',
81 'default' => true
82);
83$headerList['IBLOCK_TYPE_ID'] = array(
84 'id' => 'IBLOCK_TYPE_ID',
85 'content' => Loc::getMessage('CATALOG_ADM_IBLOCK_CATALOG_HEADER_NAME_IBLOCK_TYPE_ID'),
86 'title' => Loc::getMessage('CATALOG_ADM_IBLOCK_CATALOG_HEADER_TITLE_IBLOCK_TYPE_ID'),
87 'sort' => 'IBLOCK_TYPE_ID',
88 'default' => true
89);
91 'id' => 'SORT',
92 'content' => Loc::getMessage('CATALOG_ADM_IBLOCK_CATALOG_HEADER_NAME_SORT'),
93 'title' => Loc::getMessage('CATALOG_ADM_IBLOCK_CATALOG_HEADER_TITLE_SORT'),
94 'sort' => 'SORT',
95 'default' => true
96);
97$headerList['IBLOCK_SITES'] = array(
98 'id' => 'IBLOCK_SITES',
99 'content' => Loc::getMessage('CATALOG_ADM_IBLOCK_CATALOG_HEADER_NAME_IBLOCK_SITES'),
100 'title' => Loc::getMessage('CATALOG_ADM_IBLOCK_CATALOG_HEADER_TITLE_IBLOCK_SITES'),
101 'external' => true,
102 'default' => true
103);
104$headerList['ACTIVE'] = array(
105 'id' => 'ACTIVE',
106 'content' => Loc::getMessage('CATALOG_ADM_IBLOCK_CATALOG_HEADER_NAME_ACTIVE'),
107 'title' => Loc::getMessage('CATALOG_ADM_IBLOCK_CATALOG_HEADER_TITLE_ACTIVE'),
108 'sort' => 'ACTIVE',
109 'default' => true
110);
111$headerList['IS_CATALOG'] = array(
112 'id' => 'IS_CATALOG',
113 'content' => Loc::getMessage('CATALOG_ADM_IBLOCK_CATALOG_HEADER_NAME_IS_CATALOG'),
114 'title' => Loc::getMessage('CATALOG_ADM_IBLOCK_CATALOG_HEADER_TITLE_IS_CATALOG'),
115 'field' => 'CATALOG_IBLOCK.IBLOCK_ID',
116 'sort' => 'CATALOG_IBLOCK.IBLOCK_ID',
117 'default' => true
118);
119$headerList['SKU_IBLOCK'] = array(
120 'id' => 'SKU_IBLOCK',
121 'content' => Loc::getMessage('CATALOG_ADM_IBLOCK_CATALOG_HEADER_NAME_SKU_IBLOCK'),
122 'title' => Loc::getMessage('CATALOG_ADM_IBLOCK_CATALOG_HEADER_TITLE_SKU_IBLOCK'),
123 'field' => 'SKU.IBLOCK_ID',
124 'default' => true
125);
127{
128 $headerList['SUBSCRIPTION'] = array(
129 'id' => 'SUBSCRIPTION',
130 'content' => Loc::getMessage('CATALOG_ADM_IBLOCK_CATALOG_HEADER_NAME_SUBSCRIPTION'),
131 'title' => Loc::getMessage('CATALOG_ADM_IBLOCK_CATALOG_HEADER_TITLE_SUBSCRIPTION'),
132 'field' => 'CATALOG_IBLOCK.SUBSCRIPTION',
133 'sort' => 'CATALOG_IBLOCK.SUBSCRIPTION',
134 'default' => true
135 );
136}
137$headerList['YANDEX_EXPORT'] = array(
138 'id' => 'YANDEX_EXPORT',
139 'content' => Loc::getMessage('CATALOG_ADM_IBLOCK_CATALOG_HEADER_NAME_YANDEX_EXPORT'),
140 'title' => Loc::getMessage('CATALOG_ADM_IBLOCK_CATALOG_HEADER_TITLE_YANDEX_EXPORT'),
141 'field' => 'CATALOG_IBLOCK.YANDEX_EXPORT',
142 'sort' => 'CATALOG_IBLOCK.YANDEX_EXPORT',
143 'default' => true
144);
145$headerList['VAT_ID'] = array(
146 'id' => 'VAT_ID',
147 'content' => Loc::getMessage('CATALOG_ADM_IBLOCK_CATALOG_HEADER_NAME_VAT_ID'),
148 'title' => Loc::getMessage('CATALOG_ADM_IBLOCK_CATALOG_HEADER_TITLE_VAT_ID'),
149 'field' => 'CATALOG_IBLOCK.VAT_ID',
150 'default' => true
151);
152$adminList->AddHeaders($headerList);
153
155 'PRODUCT_IBLOCK_ID' => 'CATALOG_IBLOCK.PRODUCT_IBLOCK_ID'
156);
157if (!$saleRecurring)
158 $hiddenSelectFields['SUBSCRIPTION'] = 'CATALOG_IBLOCK.SUBSCRIPTION';
159
160$selectFields = array_fill_keys($adminList->GetVisibleHeaderColumns(), true);
161$selectFields['ID'] = true;
162$selectFields['IS_CATALOG'] = true;
163$selectFields['SKU_IBLOCK'] = true;
164$selectFieldsMap = array_fill_keys(array_keys($headerList), false);
166
167$catalogEditUrl = '/bitrix/tools/catalog/iblock_catalog_edit.php?lang='.LANGUAGE_ID.'&IBLOCK_ID=';
168
169$vatList = array(0 => Loc::getMessage('CATALOG_ADM_IBLOCK_CATALOG_MESS_NOT_SELECT'));
170if ($selectFieldsMap['VAT_ID'])
171{
172 $vatIterator = Catalog\VatTable::getList(array(
173 'select' => array('ID', 'NAME', 'SORT'),
174 'order' => array('SORT' => 'ASC', 'ID' => 'ASC')
175 ));
176 while ($vat = $vatIterator->fetch())
177 $vatList[$vat['ID']] = $vat['NAME'];
178 unset($vat, $vatIterator);
179}
180
183$navyParams = CDBResult::GetNavParams(CAdminResult::GetNavSize($adminListTableID, array('nPageSize' => 20, 'sNavID' => $adminList->GetListUrl(true))));
184if ($navyParams['SHOW_ALL'])
185{
186 $usePageNavigation = false;
187}
188else
189{
190 $navyParams['PAGEN'] = (int)$navyParams['PAGEN'];
191 $navyParams['SIZEN'] = (int)$navyParams['SIZEN'];
192}
193
195$selectFields = array_keys($selectFields);
196foreach ($selectFields as &$fieldName)
197{
198 if (isset($headerList[$fieldName]['external']))
199 continue;
200 if (!isset($headerList[$fieldName]['field']))
201 $select[] = $fieldName;
202 else
203 $select[$fieldName] = $headerList[$fieldName]['field'];
204}
205unset($fieldName, $selectFields);
206foreach ($hiddenSelectFields as $alias => $field)
207 $select[$alias] = $field;
208unset($alias, $field);
209
211 'select' => $select,
212 'filter' => $filter,
213 'order' => array($by => $order),
214 'runtime' => array(
215 'CATALOG_IBLOCK' => new Main\Entity\ReferenceField(
216 'CATALOG_IBLOCK',
217 'Bitrix\Catalog\CatalogIblock',
218 array('=this.ID' => 'ref.IBLOCK_ID'),
219 array('join_type' => 'LEFT')
220 ),
221 'SKU' => new Main\Entity\ReferenceField(
222 'SKU',
223 'Bitrix\Catalog\CatalogIblock',
224 array('=this.ID' => 'ref.PRODUCT_IBLOCK_ID'),
225 array('join_type' => 'LEFT')
226 )
227 )
228);
230{
231 $getListParams['limit'] = $navyParams['SIZEN'];
232 $getListParams['offset'] = $navyParams['SIZEN']*($navyParams['PAGEN']-1);
233}
236{
237 $countQuery = new Main\Entity\Query(Iblock\IblockTable::getEntity());
238 $countQuery->addSelect(new Main\Entity\ExpressionField('CNT', 'COUNT(1)'));
239 $totalCount = $countQuery->setLimit(null)->setOffset(null)->exec()->fetch();
240 unset($countQuery);
241 $totalCount = (int)$totalCount['CNT'];
242 if ($totalCount > 0)
243 {
244 $totalPages = ceil($totalCount/$navyParams['SIZEN']);
245 if ($navyParams['PAGEN'] > $totalPages)
246 $navyParams['PAGEN'] = $totalPages;
247 $getListParams['limit'] = $navyParams['SIZEN'];
248 $getListParams['offset'] = $navyParams['SIZEN']*($navyParams['PAGEN']-1);
249 }
250 else
251 {
252 $navyParams['PAGEN'] = 1;
253 $getListParams['limit'] = $navyParams['SIZEN'];
254 $getListParams['offset'] = 0;
255 }
256}
257
258$catalogIterator = new CAdminSubResult(Iblock\IblockTable::getList($getListParams), $adminListTableID, $adminList->GetListUrl(true));
260{
261 $catalogIterator->NavStart($getListParams['limit'], $navyParams['SHOW_ALL'], $navyParams['PAGEN']);
262 $catalogIterator->NavRecordCount = $totalCount;
263 $catalogIterator->NavPageCount = $totalPages;
264 $catalogIterator->NavPageNomer = $navyParams['PAGEN'];
265}
266else
267{
268 $catalogIterator->NavStart();
269}
270
274$adminList->NavText($catalogIterator->GetNavPrint(Loc::getMessage('SALE_DISCOUNT_COUPON_LIST_MESS_NAV')));
275while ($catalog = $catalogIterator->Fetch())
276{
277 $catalog['ID'] = (int)$catalog['ID'];
278 $catalog['IS_CATALOG'] = ((int)$catalog['IS_CATALOG'] > 0 ? 'Y' : 'N');
279 $catalog['SKU_IBLOCK'] = (int)$catalog['SKU_IBLOCK'];
280 if ($catalog['SKU_IBLOCK'] > 0)
281 $skuList[$catalog['SKU_IBLOCK']] = $catalog['ID'];
282 else
283 $catalog['SKU_IBLOCK'] = '';
284 $iblockList[] = $catalog['ID'];
285
286 $urlEdit = $catalogEditUrl.$catalog['ID'];
287 $rowList[$catalog['ID']] = $row = &$adminList->AddRow(
288 $catalog['ID'],
289 $catalog,
290 $urlEdit,
291 Loc::getMessage('CATALOG_ADM_IBLOCK_CATALOG_LIST_MESS_EDIT_CATALOG'),
292 true
293 );
294
295 $alert = '';
296 $alertMessages = array();
297 if (!$saleRecurring && $catalog['SUBSCRIPTION'] == 'Y')
298 $alertMessages[] = Loc::getMessage('CATALOG_ADM_IBLOCK_CATALOG_ALERT_SUBSCRIPTION_FEATURE');
299 if ($catalog['SUBSCRIPTION'] == 'Y' && $catalog['SKU_IBLOCK'] > 0)
300 $alertMessages[] = Loc::getMessage('CATALOG_ADM_IBLOCK_CATALOG_ALERT_SUBSCRIPTION_WITH_SKU');
301 if (!empty($alertMessages))
302 $alert = '<span class="row-alert" title="'.htmlspecialcharsbx(implode(' ', $alertMessages)).'"></span>';
303 $row->AddViewField('ID', $alert.$catalog['ID']);
304 unset($alertMessages, $alert);
305
306 if ($selectFieldsMap['NAME'])
307 $row->AddViewField('NAME', $catalog['NAME']);
308 if ($selectFieldsMap['IBLOCK_TYPE_ID'])
309 $row->AddViewField('IBLOCK_TYPE_ID', $catalog['IBLOCK_TYPE_ID']);
310 if ($selectFieldsMap['SORT'])
311 $row->AddViewField('SORT', $catalog['SORT']);
312
313 if ($selectFieldsMap['ACTIVE'])
314 $row->AddCheckField('ACTIVE', false);
315 if ($selectFieldsMap['IS_CATALOG'])
316 $row->AddCheckField('IS_CATALOG', false);
317
318 if ($catalog['IS_CATALOG'] == 'Y')
319 {
320 if ($saleRecurring && $selectFieldsMap['SUBSCRIPTION'])
321 $row->AddCheckField('SUBSCRIPTION', false);
322 if ($selectFieldsMap['YANDEX_EXPORT'])
323 $row->AddCheckField('YANDEX_EXPORT', false);
324 if ($selectFieldsMap['VAT_ID'])
325 $row->AddViewField('VAT_ID', (isset($vatList[$catalog['VAT_ID']]) ? $vatList[$catalog['VAT_ID']] : $vatList[0]));
326 }
327 else
328 {
329 if ($saleRecurring && $selectFieldsMap['SUBSCRIPTION'])
330 $row->AddViewField('SUBSCRIPTION', '');
331 if ($selectFieldsMap['YANDEX_EXPORT'])
332 $row->AddViewField('YANDEX_EXPORT', '');
333 if ($selectFieldsMap['VAT_ID'])
334 $row->AddViewField('VAT_ID', '');
335 }
336
337 $actions = array();
338 $actions[] = array(
339 'ICON' => 'edit',
340 'TEXT' => Loc::getMessage('CATALOG_ADM_IBLOCK_CATALOG_LIST_CONTEXT_EDIT'),
341 'ACTION' => $adminList->getRowAction(CUtil::JSEscape($urlEdit)),
342 'DEFAULT' => true
343 );
344 if (!$readOnly)
345 {
346
347 }
348 $row->AddActions($actions);
349 unset($actions);
350}
351if (isset($row))
352 unset($row);
353
354if (!empty($rowList))
355{
356 if ($selectFieldsMap['IBLOCK_SITES'])
357 {
358 $siteList = array();
359 $sitesIterator = Iblock\IblockSiteTable::getList(array(
360 'select' => array('IBLOCK_ID', 'SITE_ID'),
361 'filter' => array('@IBLOCK_ID' => $iblockList)
362 ));
363 while ($site = $sitesIterator->fetch())
364 {
365 if (!isset($siteList[$site['IBLOCK_ID']]))
366 $siteList[$site['IBLOCK_ID']] = array();
367 $siteList[$site['IBLOCK_ID']][] = $site['SITE_ID'];
368 }
369 unset($site, $sitesIterator);
370 foreach ($siteList as $iblock => $sites)
371 $rowList[$iblock]->AddViewField('IBLOCK_SITES', implode(' ', $sites));
372 unset($iblock, $sites);
373 }
374 if ($selectFieldsMap['SKU_IBLOCK'] && !empty($skuList))
375 {
376 $iblocksIterator = Iblock\IblockTable::getList(array(
377 'select' => array('ID', 'NAME'),
378 'filter' => array('@ID' => array_keys($skuList))
379 ));
380 while ($iblock = $iblocksIterator->fetch())
381 {
382 $parentIblock = $skuList[$iblock['ID']];
383 $rowList[$parentIblock]->AddViewField('SKU_IBLOCK', '['.$iblock['ID'].'] '.$iblock['NAME']);
384 }
385 unset($parentIblock, $iblock, $iblocksIterator);
386 }
387}
388
389$adminList->AddFooter(
390 array(
391 array(
392 'title' => Loc::getMessage('MAIN_ADMIN_LIST_SELECTED'),
393 'value' => $catalogIterator->SelectedRowsCount()
394 ),
395 )
396);
397
398if (!isset($_REQUEST["mode"]) || ($_REQUEST["mode"] != 'excel' && $_REQUEST["mode"] != 'subsettings'))
399{
400 $contextListMenu = array();
401
402 $contextListMenu[] = array(
403 'TEXT' => htmlspecialcharsex(Loc::getMessage('CATALOG_ADM_IBLOCK_CATALOG_LIST_REFRESH')),
404 'TITLE' => Loc::getMessage('CATALOG_ADM_IBLOCK_CATALOG_LIST_REFRESH_TITLE'),
405 'ICON' => 'btn_sub_refresh',
406 'LINK' => "javascript:".$adminList->ActionAjaxReload($adminList->GetListUrl(true)),
407 );
408
409 $adminList->AddAdminContextMenu($contextListMenu);
410 unset($contextListMenu);
411}
412
413$adminList->CheckListMode();
414
415$adminList->DisplayList(B_ADMIN_IBLOCK_CATALOGS_LIST);
416
417if ($prologAbsent)
418 require($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/main/include/epilog_popup_admin.php');
while($arIBlock=$rsIBlocks->Fetch()) $catalogIterator
Определения options.php:1934
Определения loader.php:13
static GetNavSize($table_id=false, $nPageSize=20)
Определения admin_lib.php:2097
Определения subelement.php:52
Определения subelement.php:1861
Определения subelement.php:10
static IsFeatureEnabled($_1488512778)
Определения include.php:116
$sites
Определения clear_component_cache.php:15
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$_REQUEST["admin_mnu_menu_id"]
Определения get_menu.php:8
$readOnly
Определения iblock_catalog_edit.php:19
$vatIterator
Определения iblock_catalog_edit.php:66
$catalog
Определения iblock_catalog_edit.php:135
if(! $catalogEdit->isSuccess()) $iblock
Определения iblock_catalog_edit.php:38
$prologAbsent
Определения iblock_catalog_list.php:17
$catalogEditUrl
Определения iblock_catalog_list.php:167
if($selectFieldsMap['VAT_ID']) $usePageNavigation
Определения iblock_catalog_list.php:181
$skuList
Определения iblock_catalog_list.php:272
$getListParams
Определения iblock_catalog_list.php:210
if($prologAbsent) $catalogsAjaxPath
Определения iblock_catalog_list.php:30
if($usePageNavigation) $totalPages
Определения iblock_catalog_list.php:234
$select
Определения iblock_catalog_list.php:194
$hideFields
Определения iblock_catalog_list.php:42
$hiddenSelectFields
Определения iblock_catalog_list.php:154
$adminSort
Определения iblock_catalog_list.php:43
$navyParams
Определения iblock_catalog_list.php:182
$adminListTableID
Определения iblock_catalog_list.php:40
$adminList
Определения iblock_catalog_list.php:44
if(! $readOnly &&$adminList->EditAction()) if(! $readOnly &&($listID=$adminList->GroupAction()) $headerList)
Определения iblock_catalog_list.php:69
$filter
Определения iblock_catalog_list.php:54
$iblockList
Определения iblock_catalog_list.php:271
$saleRecurring
Определения iblock_catalog_list.php:31
$filterFields
Определения iblock_catalog_list.php:55
$rowList
Определения iblock_catalog_list.php:273
$selectFields
Определения iblock_catalog_list.php:160
$selectFieldsMap
Определения iblock_catalog_list.php:164
$_SERVER["DOCUMENT_ROOT"]
Определения cron_frame.php:9
Определения ufield.php:9
$order
Определения payment.php:8
$vat
Определения template.php:273
$siteList
Определения options.php:47
$totalCount
Определения subscription_card_product.php:51
$site
Определения yandex_run.php:614
$vatList
Определения yandex_run.php:916