3namespace Bitrix\Report\VisualConstructor\Entity;
5use Bitrix\Main\Entity\Query;
6use Bitrix\Report\VisualConstructor\Category;
7use Bitrix\Report\VisualConstructor\Config\Common;
8use Bitrix\Report\VisualConstructor\Handler\BaseReport;
9use Bitrix\Report\VisualConstructor\Handler\BaseWidget;
10use Bitrix\Report\VisualConstructor\Internal\WidgetConfigurationTable;
11use Bitrix\Report\VisualConstructor\Internal\WidgetTable;
12use Bitrix\Report\VisualConstructor\RuntimeProvider\WidgetProvider;
55 parent::__construct();
75 $attributes = parent::getMapAttributes();
76 $attributes[
'GID'] =
'gId';
77 $attributes[
'BOARD_ID'] =
'boardId';
78 $attributes[
'DASHBOARD_ROW_ID'] =
'rowId';
79 $attributes[
'PARENT_WIDGET_ID'] =
'parentWidgetId';
80 $attributes[
'WIDGET_CLASS'] =
'widgetClass';
81 $attributes[
'CATEGORY_KEY'] =
'categoryKey';
82 $attributes[
'VIEW_KEY'] =
'viewKey';
83 $attributes[
'WEIGHT'] =
'weight';
84 $attributes[
'OWNER_ID'] =
'ownerId';
85 $attributes[
'IS_PATTERN'] =
'isPattern';
96 'type' => Common::MANY_TO_ONE,
98 'inversedBy' =>
'widgets',
100 'field' =>
array(
'rowId',
'id')
103 'configurations' =>
array(
104 'type' => Common::MANY_TO_MANY,
108 'column' =>
array(
'WIDGET' =>
array(
'id',
'WIDGET_ID')),
109 'inverseColumn' =>
array(
'CONFIGURATION_SETTING' =>
array(
'id',
'CONFIGURATION_ID'))
113 'type' => Common::ONE_TO_MANY,
115 'mappedBy' =>
'widget'
117 'parentWidget' =>
array(
118 'type' => Common::MANY_TO_ONE,
120 'inversedBy' =>
'childWidgets',
122 'field' =>
array(
'parentWidgetId',
'id')
128 'childWidgets' =>
array(
129 'type' => Common::ONE_TO_MANY,
131 'mappedBy' =>
'parentWidget',
145 public function delete()
155 return parent::delete();
166 return parent::delete();
178 $this->addReports($report);
181 $report->setWidget($this);
194 if (!$this->widgetHandler)
197 $widgetProvider->addFilter(
'widgetClassName', $this->widgetClass);
198 $widgetHandlerFromEvent = $widgetProvider->execute()->getFirstResult();
199 if ($widgetHandlerFromEvent)
201 $this->widgetHandler =
new $widgetHandlerFromEvent;
206 $this->widgetHandler->fillWidget($this);
247 $result[$report->getGId()] = $report;
260 echo $report->getGId() . PHP_EOL;
261 if($report->getGId() === $reportGId)
314 return 'report_board_' . $this->
getBoardId() .
'_filter';
326 $coreWidget = clone $this;
327 $copyWidget =
new Widget();
328 $copyWidget->setBoardId($coreWidget->getBoardId());
329 $copyWidget->setWidgetClass($coreWidget->getWidgetClass());
330 $copyWidget->setViewKey($coreWidget->getViewKey());
331 $copyWidget->setGId($coreWidget->getGId());
332 $copyWidget->setWeight($coreWidget->getWeight());
333 $copyWidget->setOwnerId(
$USER->getID());
334 if ($coreWidget->getId())
336 $copyWidget->setParentWidgetId($coreWidget->getId());
340 $copyWidget->setParentWidgetId($coreWidget->getId());
343 $reports = $coreWidget->getReports();
349 $report->loadAttribute(
'configurations');
350 $reportCopy = $report->getCopy();
351 $reportCopy->setWidget($copyWidget);
352 $reportCopy->setWidgetId(
null);
353 $copyWidget->addReports($reportCopy);
363 $configuration->setId(
null);
364 $copyWidget->addConfigurations($configuration);
381 $widgets = static::getModelList(
array(
382 'select' =>
array(
'*'),
384 'with' =>
array(
'reports.configurations',
'reports.widget',
'configurations'),
385 'order' =>
array(
'WEIGHT'),
398 ->where(
'IS_PATTERN',
'1')
399 ->where(Query::filter()
400 ->where(Query::filter()
404 ->where(Query::filter()
405 ->where(
'OWNER_ID', 0)
406 ->whereNot(
'CATEGORY_KEY',
'')
409 $widgets = static::getModelList(
array(
410 'select' =>
array(
'*'),
412 'order' =>
array(
'CREATED_DATE' =>
'DESC'),
414 return $widgets ? $widgets :
array();
425 $widget = static::getWidgetById($widgetId);
439 if (!isset($widgets[$widgetId]))
441 $widgets[$widgetId] = static::load(
array(
'ID' => $widgetId),
array(
'row',
'reports.configurations',
'configurations'));
443 return $widgets[$widgetId];
459 $filter->where(
'GID', $widgetGId);
461 $filter->where(
'ROW.DASHBOARD.USER_ID',
$USER->getId());
463 $widget = static::load(
465 array(
'row',
'reports.configurations',
'configurations')
470 $filter->where(
'GID', $widgetGId);
472 $filter->where(
'ROW.DASHBOARD.USER_ID', 0);
473 $widget = static::load(
475 array(
'row',
'reports.configurations',
'configurations')
493 if (mb_strpos(
$params[
'widgetGId'],
'pseudo_') === 0)
495 $widget =
new self();
496 $widget->setViewKey(
$params[
'viewKey']);
497 $widget->setGId(
$params[
'widgetGId']);
498 $widget->setWidgetClass(BaseWidget::getClassName());
505 $widget->setViewKey(
$params[
'viewKey']);
522 array(
'row',
'reports.configurations',
'configurations')
534 $widget = static::load(
535 array(
'ID' => $widgetId),
536 array(
'row',
'reports',
'reports.configurations',
'configurations')
552 $widget = static::load(
555 'ROW.DASHBOARD.USER_ID' =>
$USER->getId()
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
fillReport(Report $report)
loadAttribute($attributeName)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']