Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
configuration.php
1<?php
3
5use Bitrix\Report\VisualConstructor\BaseReportHandler;
11
12
17class Configuration extends Base
18{
19
27 public function buildPseudoReportConfigurationAction($params)
28 {
29 if (!isset($params['widgetId']))
30 {
31 $this->addError(new Error('widgetId not exist'));
32 return false;
33 }
34
35 if (!isset($params['viewKey']))
36 {
37 $this->addError(new Error('view key not exist'));
38 return false;
39 }
40
41 $existReportCount = !empty($params['existReportCount']) ? $params['existReportCount'] : 0;
42
43 $componentName = 'bitrix:report.visualconstructor.widget.pseudoconfig';
44 $templateName = '';
45 $widgetParams = array(
46 'widgetGId' => $params['widgetId'],
47 'viewKey' => $params['viewKey'],
48 );
49
50 $reportHandlerClassName = !empty($params['reportHandlerClassName']) ? $params['reportHandlerClassName'] : '__';
51
52 $widget = \Bitrix\Report\VisualConstructor\Entity\Widget::buildPseudoWidget($widgetParams);
53 if ($widget)
54 {
55 $componentParams = array(
56 'WIDGET_ID' => $widget->getGId()
57 );
58
59 if ($reportHandlerClassName == '__')
60 {
61 $reportHandlerClassName = EmptyReport::getClassName();
62 }
63
64 $reportHandler = Report::buildReportHandlerForWidget($reportHandlerClassName, $widget, true);
65 $colorFieldValue = !empty($params['colorFieldValue']) ? $params['colorFieldValue'] : $reportHandler->getView()->getReportDefaultColor($existReportCount + 1);
66
67 $reportHandler->getFormElement('color')->setValue($colorFieldValue);
68 $reportHandler->getFormElement('head_container_start')->addInlineStyle('background-color', $colorFieldValue);
69 $reportHandler->getFormElement('main_container_start')->addInlineStyle('background-color', $colorFieldValue . '5f');
70 $componentParams['REPORT_HANDLER'] = $reportHandler;
71 return new Component($componentName, $templateName, $componentParams);
72 }
73 $this->addError(new Error('No widget with this id'));
74 return false;
75 }
76
83 public function loadWhatWillCalculateByGroupAction($params)
84 {
85 if (!isset($params['widgetId']))
86 {
87 $this->addError(new Error('widgetId not exist'));
88 return false;
89 }
90
91 if (!isset($params['viewKey']))
92 {
93 $this->addError(new Error('view key not exist'));
94 return false;
95 }
96
97 if (!isset($params['reportHandlerClassName']))
98 {
99 $this->addError(new Error('report handler class name not exist'));
100 return false;
101 }
102
103 if (!isset($params['groupBy']))
104 {
105 $this->addError(new Error('groupBy field not exist'));
106 return false;
107 }
108
109 $widgetParams = array(
110 'widgetGId' => $params['widgetId'],
111 'viewKey' => $params['viewKey'],
112 );
113 $groupBy = $params['groupBy'];
114 $reportHandlerClassName = $params['reportHandlerClassName'];
115 $widget = \Bitrix\Report\VisualConstructor\Entity\Widget::buildPseudoWidget($widgetParams);
116 if ($widget)
117 {
118 $reportHandler = ReportProvider::getReportHandlerByClassName($reportHandlerClassName);
119
120 $viewHandler = ViewProvider::getViewByViewKey($widget->getViewKey());
121 $result = array();
122 if ($reportHandler && $viewHandler)
123 {
124 $reportHandler->setView($viewHandler);
125 $whatWillCalculate = $reportHandler->getWhatWillCalculateOptions($groupBy);
126 foreach ($whatWillCalculate as $value => $text)
127 {
128 $result[$value] = $text;
129 }
130 }
131 return $result;
132 }
133 $this->addError(new Error('No widget with this id'));
134 return false;
135
136 }
137
138}