Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
charthandler.php
1<?php
2
4
5use \Bitrix\Catalog\Integration\Report\Handler\BaseHandler;
10
11final class ChartHandler extends BaseHandler
12{
13 public function prepare()
14 {
15 return [
16 'filter' => $this->getFormattedFilter(),
17 'chart' => $this->getChartData(),
18 ];
19 }
20
21 public function getChartData(): array
22 {
23 $filterParams = $this->getFormattedFilter();
24
25 $chartStoreInfo = new ChartStoreInfo(new StoreWithProductsInfoCombiner());
26 $chartStoreInfo->accumulate('SUM_STORED', ...StoreStockSale::getReservedData($filterParams));
27
28 if
29 (
30 isset($filterParams['STORES'])
31 && count($filterParams['STORES']) <= self::MAX_CHART_COLUMNS_COUNT
32 )
33 {
34 $chartData = [
35 'data' => $chartStoreInfo->getCalculatedColumns(),
36 'storesInfo' => [
37 'storeCount' => $chartStoreInfo->getStoresCount(),
38 'cropStoreNamesList' => '',
39 ],
40 'isCommonChart' => false,
41 ];
42 }
43 else
44 {
45 $combinedData = $chartStoreInfo->getCombinedCalculatedColumn(self::MAX_STORES_LIST_CHARS);
46 $chartData = [
47 'data' => [$combinedData],
48 'storesInfo' => [
49 'storeCount' => $chartStoreInfo->getStoresCount(),
50 'cropStoreNamesList' => $combinedData['TITLE'],
51 ],
52 'isCommonChart' => true,
53 ];
54 }
55
56 $chartData['currency'] = CurrencyManager::getBaseCurrency();
57 $chartData['sliderUrl'] = static::formChartSliderUrl('bitrix:catalog.report.store_stock.salechart.stores.grid', $filterParams);
58
59 return $chartData;
60 }
61}