Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
activity.php
1<?php
2
4
10
15class Activity extends Base
16{
17 const VIEW_KEY = 'activity';
19
23 public function __construct()
24 {
25 $this->setLabel(Loc::getMessage('REPORT_ACTIVITY_VIEW_LABEL'));
26 $this->setLogoUri('/bitrix/images/report/visualconstructor/view-activity.jpg');
27 $this->setJsClassName('BX.Report.VisualConstructor.Widget.Content.Activity');
28 $this->setCompatibleDataType(Common::MULTIPLE_BI_GROUPED_REPORT_TYPE);
29 $this->setHeight(380);
30 }
31
32
39 public function collectReportHandlerFormElements($reportHandler)
40 {
41 parent::collectReportHandlerFormElements($reportHandler);
42
44 $whatWillCalculateField = $reportHandler->getFormElement('calculate');
45 if ($whatWillCalculateField)
46 {
47 $labelField = $reportHandler->getWidgetHandler()->getFormElement('label');
48 $labelField->addJsEventListener($whatWillCalculateField, $whatWillCalculateField::JS_EVENT_ON_CHANGE, array(
49 'class' => 'BX.Report.VisualConstructor.FieldEventHandlers.Title',
50 'action' => 'whatWillCalculateChange',
51 ));
52 $whatWillCalculateField->addAssets(array(
53 'js' => array('/bitrix/js/report/js/visualconstructor/fields/reporttitle.js')
54 ));
55 }
56
57 $removeFormElement = $reportHandler->getFormElementByDataAttribute('role', 'report-remove-button');
58 if ($removeFormElement)
59 {
60 $removeFormElement->setDisplay(false);
61 }
62
63 $colorField = $reportHandler->getFormElement('color');
64 $reportHandler->getFormElement('label_color_container_start')->setDisplay(false);
65 $reportHandler->getFormElement('label_color_container_end')->setDisplay(false);
66 $reportHandler->getFormElement('head_container_start')->setDisplay(false);
67 $reportHandler->getFormElement('head_container_end')->setDisplay(false);
68 if ($colorField)
69 {
70 $colorField->setDisplay(false);
71 }
72
73
74 $labelField = $reportHandler->getFormElement('label');
75 if ($labelField)
76 {
77 $labelField->setDisplay(false);
78 }
79 }
80
88 public function handlerFinallyBeforePassToView($dataFromReport)
89 {
90 if ($dataFromReport['items'])
91 {
92 $items = array();
93 foreach ($dataFromReport['items'] as $item)
94 {
95
96 if (!empty($items[$item['firstGroupId']][$item['secondGroupId']]))
97 {
98 $items[$item['firstGroupId']][$item['secondGroupId']]['active'] += (int)$item['value'];
99 }
100 else
101 {
102 $items[$item['firstGroupId']][$item['secondGroupId']] = array(
103 'labelXid' => (int)$item['firstGroupId'] + 1,
104 'labelYid' => (int)$item['secondGroupId'],
105 'active' => (int)$item['value'],
106 );
107 }
108
109 }
110
111 foreach ($items as $firstGroupId => $secondGroup)
112 {
113 foreach ($secondGroup as $secondGroupId => $newItem)
114 {
115 $result['items'][] = $newItem;
116 }
117 }
118 }
119
120
121 $result['config']['labelY'] = $this->getWeekDaysMap();
122 $result['config']['labelX'] = $this->getHourList();
123 return $result;
124 }
125
131 protected function getWeekDaysMap()
132 {
133 return array(
134 array(
135 'id' => 1,
136 'name' => Loc::getMessage('MONDAY'),
137 ),
138 array(
139 'id' => 2,
140 'name' => Loc::getMessage('TUESDAY'),
141 ),
142 array(
143 'id' => 3,
144 'name' => Loc::getMessage('WEDNESDAY'),
145 ),
146 array(
147 'id' => 4,
148 'name' => Loc::getMessage('THURSDAY'),
149 ),
150 array(
151 'id' => 5,
152 'name' => Loc::getMessage('FRIDAY'),
153 ),
154 array(
155 'id' => 6,
156 'name' => Loc::getMessage('SATURDAY'),
157 'light' => true
158 ),
159 array(
160 'id' => 0,
161 'name' => Loc::getMessage('SUNDAY'),
162 'light' => true
163 ),
164 );
165 }
166
167
173 protected function getHourList()
174 {
175 $result = array();
176 for ($i = 1; $i <= 24; $i++)
177 {
178 $hour = array(
179 'id' => $i,
180 'name' => $i
181 );
182 if ($i === 0 || $i === 24 || ($i) % 6 == 0)
183 {
184 $hour['show'] = true;
185 }
186
187 if ($i >= 9 && $i <= 18)
188 {
189 $hour['active'] = true;
190 }
191 $result[] = $hour;
192 }
193 return $result;
194 }
195
202 public function getReportDefaultColor($num)
203 {
204 return '#ffffff';
205 }
206
207}
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
setCompatibleDataType($compatibleDataType)
Definition view.php:121
collectReportHandlerFormElements($reportHandler)
Definition view.php:289