Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
report.php
1<?php
2
4
11
17{
18 protected $gId;
19 protected $widgetId;
22 protected $reportHandler;
23 protected $weight = 0;
24
28 protected $widget;
29
33 public static function getTableClassName()
34 {
36 }
37
44 public static function getMapAttributes()
45 {
46 $attributes = parent::getMapAttributes();
47 $attributes['GID'] = 'gId';
48 $attributes['REPORT_CLASS'] = 'reportClassName';
49 $attributes['WIDGET_ID'] = 'widgetId';
50 $attributes['WEIGHT'] = 'weight';
51
52 return $attributes;
53 }
54
58 public static function getMapReferenceAttributes()
59 {
60 return array(
61 'configurations' => array(
62 'type' => Common::MANY_TO_MANY,
63 'targetEntity' => Configuration::getClassName(),
64 'join' => array(
65 'tableClassName' => ReportConfigurationTable::getClassName(),
66 'column' => array('REPORT' => array('id', 'REPORT_ID')),
67 'inverseColumn' => array('CONFIGURATION_SETTING' => array('id', 'CONFIGURATION_ID'))
68 ),
69 ),
70 'widget' => array(
71 'type' => Common::MANY_TO_ONE,
72 'targetEntity' => Widget::getClassName(),
73 'inversedBy' => 'reports',
74 'join' => array(
75 'field' => array('widgetId', 'id')
76 )
77 ),
78 );
79 }
80
87 public static function getReportByGId($reportGId)
88 {
89 return static::load(
90 array(
91 'GID' => $reportGId
92 ),
93 array('widget', 'configurations')
94 );
95 }
96
102 public function getCopy()
103 {
104 $coreReport = clone $this;
105 $copyReport = new Report();
106 $copyReport->setId(null);
107 $copyReport->setGId($coreReport->getGId());
108 $copyReport->setWeight($coreReport->getWeight());
109 $copyReport->setWidgetId($coreReport->getWidgetId());
110 $copyReport->setReportClassName($coreReport->getReportClassName());
111
112 $configurations = $coreReport->getConfigurations();
113 if (is_array($configurations))
114 {
115 foreach ($configurations as $configuration)
116 {
117 $configuration->setId(null);
118 $copyReport->addConfigurations($configuration);
119 }
120 }
121
122 return $copyReport;
123 }
124
128 public function getWidgetId()
129 {
130 return $this->widgetId;
131 }
132
139 public function setWidgetId($widgetId)
140 {
141 $this->widgetId = $widgetId;
142 }
143
147 public function getReportClassName()
148 {
150 }
151
160 {
161 $this->reportClassName = $reportClassName;
162 }
163
172 public function getReportHandler($isRuntime = false)
173 {
174 if (!$this->reportHandler)
175 {
176 $reportHandlerFromEvent = ReportProvider::getReportHandlerByClassName($this->reportClassName);
177 if ($reportHandlerFromEvent)
178 {
179 $this->reportHandler = new $reportHandlerFromEvent;
180 $this->reportHandler->setView($this->getWidget()->getWidgetHandler()->getView());
181 if (!$isRuntime)
182 {
183 $this->loadAttribute('configurations');
184 }
185 $this->reportHandler->fillReport($this);
186 }
187 else
188 {
189 $this->errors[] = new Error('No such report handler with this class');
190 return null;
191 }
192 }
194 }
195
202 public function setReportHandler(BaseReport $handler)
203 {
204 $this->setReportClassName($handler::getClassName());
205 $this->reportHandler = $handler;
206 }
207
211 public function getWeight()
212 {
213 return $this->weight;
214 }
215
222 public function setWeight($weight)
223 {
224 $this->weight = $weight;
225 }
226
232 public function getWidget()
233 {
237 if (!$this->widget && $this->widgetId)
238 {
239 $this->widget = Widget::loadById($this->widgetId);
240 }
241 return $this->widget;
242 }
243
249 public function setWidget($widget)
250 {
251 $this->widget = $widget;
252 }
253
257 public function getGId()
258 {
259 return $this->gId;
260 }
261
268 public function setGId($gId)
269 {
270 $this->gId = $gId;
271 }
272}