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 getMultipleData()
14 {
15 return $this->getCalculatedData();
16 }
17
18 public function getMultipleDemoData()
19 {
20 return [];
21 }
22
23 public function prepare()
24 {
25 return [
26 'filter' => $this->getFormattedFilter(),
27 'chart' => $this->getFormedChartData(),
28 ];
29 }
30
31 private function getFormedChartData(): array
32 {
33 $filterParams = $this->getFormattedFilter();
34
35 $chartStoreInfo = new ChartStoreInfo(new StoreWithProductsInfoCombiner());
36 $chartStoreInfo->accumulate('SUM_SHIPPED', ...StoreStockSale::getShippedData($filterParams));
37 $chartStoreInfo->accumulate('SUM_ARRIVED', ...StoreStockSale::getArrivedData($filterParams));
38
39 if
40 (
41 isset($filterParams['STORES'])
42 && count($filterParams['STORES']) <= self::MAX_CHART_COLUMNS_COUNT
43 )
44 {
45 $chartData = [
46 'data' => $chartStoreInfo->getCalculatedColumns(),
47 'storesInfo' => [
48 'storeCount' => $chartStoreInfo->getStoresCount(),
49 'cropStoreNamesList' => '',
50 ],
51 'isCommonChart' => false,
52 ];
53 }
54 else
55 {
56 $combinedData = $chartStoreInfo->getCombinedCalculatedColumn(self::MAX_STORES_LIST_CHARS);
57 $chartData = [
58 'data' => [$combinedData],
59 'storesInfo' => [
60 'storeCount' => $chartStoreInfo->getStoresCount(),
61 'cropStoreNamesList' => $combinedData['TITLE'],
62 ],
63 'isCommonChart' => true,
64 ];
65 }
66
67 $chartData['currency'] = CurrencyManager::getBaseCurrency();
68 $chartData['sliderUrl'] = static::formChartSliderUrl('bitrix:catalog.report.store_sale.chart.stores.grid', $filterParams);
69
70 return $chartData;
71 }
72}