44 private $warningMessage;
46 private $savedReportHasBeenResolved =
false;
57 public static function getDefaultMetadata()
61 'title' =>
"eval:Zurmo::t('ReportsModule', 'Report Chart')",
68 public static function canUserConfigure()
79 public function __construct($viewData, $params, $uniqueLayoutId)
81 assert(
'is_array($viewData) || $viewData == null');
82 assert(
'isset($params["portletId"])');
83 assert(
'is_string($uniqueLayoutId)');
84 $this->moduleId =
'reports';
85 $this->viewData = $viewData;
86 $this->params = $params;
87 $this->uniqueLayoutId = $uniqueLayoutId;
90 public function isUniqueToAPage()
100 if ($this->getSavedReport() == null)
102 return Zurmo::t(
'ReportsModule',
'Report Chart');
105 return strval($this->getSavedReport());
108 public function getConfigurationView()
111 if ($this->viewData !=
'')
113 $formModel->setAttributes($this->viewData);
117 $formModel->reportId = $this->getSavedReportId();
119 if ($this->getSavedReport() != null)
121 $formModel->reportName = strval($this->getSavedReport());
126 public function renderContent()
128 if ($this->getSavedReportId() == null)
132 elseif ($this->getSavedReport() == null)
134 return $this->renderWarningMessageContent();
136 $content = parent::renderContent();
137 $this->renderScripts();
146 $content =
'<div class="general-issue-notice"><span class="icon-notice"></span><p>';
147 $content .= Zurmo::t(
'ReportsModule',
'Select a report with a chart');
148 $content .=
'</p></div>';
152 protected function renderWarningMessageContent()
154 $content =
'<div class="general-issue-notice"><span class="icon-notice"></span><p>';
155 $content .= $this->warningMessage;
156 $content .=
'</p></div>';
160 protected function getSavedReportId()
162 return $this->resolveViewAndMetadataValueByName(
'reportId');
165 protected function renderScripts()
167 if (!isset($this->params[
'dataProvider']))
170 $script =
"$(document).ready(function () {
171 $('#" . $this->getRefreshLinkContainerId() .
"').find('.refreshPortletLink').click();
173 Yii::app()->clientScript->registerScript(
'loadReportResults-'. $this->uniqueLayoutId, $script);
178 protected function getRefreshLinkContainerId()
180 return $this->getUniqueChartLayoutId();
183 protected function getUniqueChartLayoutId()
185 return $this->uniqueLayoutId .
'-chart';
188 protected function getId()
190 return $this->getUniqueChartLayoutId();
193 protected function getSavedReport()
195 if ($this->savedReport == null && $this->getSavedReportId() != null && !$this->savedReportHasBeenResolved)
197 $this->resolveSavedReportAndWarningData();
199 return $this->savedReport;
202 private function resolveSavedReportAndWarningData()
210 $this->warningMessage = Zurmo::t(
'ReportsModule',
'You have tried to access a report you do not have access to');
215 if ($report->getChart()->type == null)
217 $this->warningMessage = Zurmo::t(
'ReportsModule',
'This report does not have a chart to display');
221 $this->savedReport = $savedReport;
227 $this->warningMessage = Zurmo::t(
'ReportsModule',
'You have tried to access a report that is no longer available');
231 $this->warningMessage = Zurmo::t(
'ReportsModule',
'You have tried to access a report you do not have access to');
233 $this->savedReportHasBeenResolved =
true;
__construct($viewData, $params, $uniqueLayoutId)
static doesCurrentUserHavePermissionOnSecurableItem($securableItem, $permissionToCheck)
static getPortletRulesType()
static makeReportBySavedReport($savedReport)
static getById($id, $modelClassName=null)
renderSelectAReportFirstContent()