29 $this->includeComponentTemplate();
34 if (!Loader::includeModule(
'catalog') || !self::checkDocumentReadRights())
36 $this->arResult[
'ERROR_MESSAGES'][] =
Loc::getMessage(
'CATALOG_REPORT_PROFIT_LIST_NO_READ_RIGHTS_ERROR');
37 $this->includeComponentTemplate();
47 $this->arResult[
'GRID'] = $this->getGridData();
48 $this->arResult[
'GRID_FILTER'] = $this->getGridFilter();
52 private function getGridData(): array
61 isset($this->arParams[
'RESULT'][
'data'][
'stub'])
62 && is_array($this->arParams[
'RESULT'][
'data'][
'stub'])
65 $result[
'STUB'] = $this->arParams[
'RESULT'][
'data'][
'stub'];
70 $providerData = $this->arParams[
'RESULT'][
'data'][
'items'];
71 $overallData = $this->arParams[
'RESULT'][
'data'][
'overall'];
73 if (!empty($providerData))
75 foreach($providerData as $storeId => $item)
80 'columns' => $this->prepareItemColumn($item),
84 $result[
'ROWS'][] = $this->prepareOverallTotalRow($overallData);
85 $result[
'ROWS'][] = $this->prepareTotalLinkRow();
88 $result[
'SHOW_PAGINATION'] =
false;
89 $result[
'SHOW_NAVIGATION_PANEL'] =
false;
90 $result[
'SHOW_PAGESIZE'] =
false;
91 $result[
'SHOW_ROW_CHECKBOXES'] =
false;
92 $result[
'SHOW_CHECK_ALL_CHECKBOXES'] =
false;
93 $result[
'SHOW_ACTION_PANEL'] =
false;
94 $result[
'HANDLE_RESPONSE_ERRORS'] =
true;
95 $result[
'SHOW_GRID_SETTINGS_MENU'] =
false;
96 $result[
'ALLOW_STICKED_COLUMNS'] =
true;
101 private function prepareItemColumn(array $item): array
105 $column[
'TITLE'] = $this->prepareTitleViewForColumn($column);
106 if (isset($column[
'STORE_ID']))
108 $column[
'STORE_ID'] = (int)$column[
'STORE_ID'];
113 $column[$totalField] = $this->
formatValue($totalField, $column[
'TOTALS'][$totalField]);
116 unset($column[
'TOTALS']);
121 private function prepareOverallTotalRow(array $overallData): array
123 $overallColumns = [];
124 $overallColumns[
'TITLE'] =
Loc::getMessage(
'CATALOG_REPORT_PROFIT_LIST_OVERALL_TOTAL');
128 $overallColumns[$totalField] = $this->
formatValue($totalField, $overallData[$totalField]);
132 'id' =>
'overallTotal',
133 'data' => $overallData,
134 'columns' => $overallColumns,
138 private function prepareTotalLinkRow(): array
143 'TITLE' =>
Loc::getMessage(
'CATALOG_REPORT_PROFIT_LIST_OPEN_SLIDER_ALL')
148 protected function formatValue(
string $fieldName, $value): ?string
150 return (
string)$value;
153 private function prepareTitleViewForColumn(array $column): string
155 if (!isset($column[
'TITLE'], $column[
'STORE_ID']))
160 if ($column[
'TITLE'])
162 $title = htmlspecialcharsbx($column[
'TITLE']);
166 $title =
Loc::getMessage(
'CATALOG_REPORT_PROFIT_LIST_EMPTY_STORE_NAME');
172 private function getGridFilter(): array
174 return $this->arParams[
'RESULT'][
'data'][
'filter'];
181 return getLocalPath(
'components' . $productGridPath .
'/slider.php');
184 private static function checkDocumentReadRights(): bool
186 return AccessController::getCurrent()->check(ActionDictionary::ACTION_CATALOG_READ);
static getMessage($code, $replace=null, $language=null)