Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
DashboardReportChartForPortletView.php
1 <?php
2  /*********************************************************************************
3  * Zurmo is a customer relationship management program developed by
4  * Zurmo, Inc. Copyright (C) 2017 Zurmo Inc.
5  *
6  * Zurmo is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Affero General Public License version 3 as published by the
8  * Free Software Foundation with the addition of the following permission added
9  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
10  * IN WHICH THE COPYRIGHT IS OWNED BY ZURMO, ZURMO DISCLAIMS THE WARRANTY
11  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
12  *
13  * Zurmo is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Affero General Public License along with
19  * this program; if not, see http://www.gnu.org/licenses or write to the Free
20  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  * 02110-1301 USA.
22  *
23  * You can contact Zurmo, Inc. with a mailing address at 27 North Wacker Drive
24  * Suite 370 Chicago, IL 60606. or at email address contact@zurmo.com.
25  *
26  * The interactive user interfaces in original and modified versions
27  * of this program must display Appropriate Legal Notices, as required under
28  * Section 5 of the GNU Affero General Public License version 3.
29  *
30  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
31  * these Appropriate Legal Notices must retain the display of the Zurmo
32  * logo and Zurmo copyright notice. If the display of the logo is not reasonably
33  * feasible for technical reasons, the Appropriate Legal Notices must display the words
34  * "Copyright Zurmo Inc. 2017. All rights reserved".
35  ********************************************************************************/
36 
41  {
42  private $savedReport;
43 
44  private $warningMessage;
45 
46  private $savedReportHasBeenResolved = false;
47 
52  public static function getPortletRulesType()
53  {
54  return 'Chart';
55  }
56 
57  public static function getDefaultMetadata()
58  {
59  return array(
60  'perUser' => array(
61  'title' => "eval:Zurmo::t('ReportsModule', 'Report Chart')",
62  'reportId' => null,
63  ),
64  'global' => array(),
65  );
66  }
67 
68  public static function canUserConfigure()
69  {
70  return true;
71  }
72 
79  public function __construct($viewData, $params, $uniqueLayoutId)
80  {
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;
88  }
89 
90  public function isUniqueToAPage()
91  {
92  return false;
93  }
94 
98  public function getTitle()
99  {
100  if ($this->getSavedReport() == null)
101  {
102  return Zurmo::t('ReportsModule', 'Report Chart');
103  }
104 
105  return strval($this->getSavedReport());
106  }
107 
108  public function getConfigurationView()
109  {
110  $formModel = new ReportSelectForm();
111  if ($this->viewData != '')
112  {
113  $formModel->setAttributes($this->viewData);
114  }
115  else
116  {
117  $formModel->reportId = $this->getSavedReportId();
118  }
119  if ($this->getSavedReport() != null)
120  {
121  $formModel->reportName = strval($this->getSavedReport());
122  }
123  return new DashboardReportChartConfigView($formModel, $this->params);
124  }
125 
126  public function renderContent()
127  {
128  if ($this->getSavedReportId() == null)
129  {
130  return $this->renderSelectAReportFirstContent();
131  }
132  elseif ($this->getSavedReport() == null)
133  {
134  return $this->renderWarningMessageContent();
135  }
136  $content = parent::renderContent();
137  $this->renderScripts();
138  return $content;
139  }
140 
144  protected function renderSelectAReportFirstContent()
145  {
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>';
149  return $content;
150  }
151 
152  protected function renderWarningMessageContent()
153  {
154  $content = '<div class="general-issue-notice"><span class="icon-notice"></span><p>';
155  $content .= $this->warningMessage;
156  $content .= '</p></div>';
157  return $content;
158  }
159 
160  protected function getSavedReportId()
161  {
162  return $this->resolveViewAndMetadataValueByName('reportId');
163  }
164 
165  protected function renderScripts()
166  {
167  if (!isset($this->params['dataProvider']))
168  {
169  // Begin Not Coding Standard
170  $script = "$(document).ready(function () {
171  $('#" . $this->getRefreshLinkContainerId() . "').find('.refreshPortletLink').click();
172  });";
173  Yii::app()->clientScript->registerScript('loadReportResults-'. $this->uniqueLayoutId, $script);
174  // End Not Coding Standard
175  }
176  }
177 
178  protected function getRefreshLinkContainerId()
179  {
180  return $this->getUniqueChartLayoutId();
181  }
182 
183  protected function getUniqueChartLayoutId()
184  {
185  return $this->uniqueLayoutId . '-chart';
186  }
187 
188  protected function getId()
189  {
190  return $this->getUniqueChartLayoutId();
191  }
192 
193  protected function getSavedReport()
194  {
195  if ($this->savedReport == null && $this->getSavedReportId() != null && !$this->savedReportHasBeenResolved)
196  {
197  $this->resolveSavedReportAndWarningData();
198  }
199  return $this->savedReport;
200  }
201 
202  private function resolveSavedReportAndWarningData()
203  {
204  try
205  {
206  $savedReport = SavedReport::getById((int)$this->getSavedReportId());
207 
209  {
210  $this->warningMessage = Zurmo::t('ReportsModule', 'You have tried to access a report you do not have access to');
211  }
212  else
213  {
215  if ($report->getChart()->type == null)
216  {
217  $this->warningMessage = Zurmo::t('ReportsModule', 'This report does not have a chart to display');
218  }
219  else
220  {
221  $this->savedReport = $savedReport;
222  }
223  }
224  }
225  catch (NotFoundException $e)
226  {
227  $this->warningMessage = Zurmo::t('ReportsModule', 'You have tried to access a report that is no longer available');
228  }
230  {
231  $this->warningMessage = Zurmo::t('ReportsModule', 'You have tried to access a report you do not have access to');
232  }
233  $this->savedReportHasBeenResolved = true;
234  }
235  }
236 ?>
__construct($viewData, $params, $uniqueLayoutId)
static doesCurrentUserHavePermissionOnSecurableItem($securableItem, $permissionToCheck)
static makeReportBySavedReport($savedReport)
static getById($id, $modelClassName=null)
Generated on Sat Nov 28 2020 07:10:46
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.