Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
MarketingMetricsView.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  {
46  protected $params;
47 
51  protected $controllerId;
52 
56  protected $moduleId;
57 
61  protected $uniqueLayoutId;
62 
66  protected $viewData;
67 
71  protected $formModel;
72 
76  protected $formModelClassName;
77 
78  abstract public function getConfigurationView();
79 
84  public static function getModuleClassName()
85  {
86  throw new NotImplementedException();
87  }
88 
92  public static function canUserConfigure()
93  {
94  return true;
95  }
96 
100  public static function canUserRemove()
101  {
102  return false;
103  }
104 
109  public static function getPortletRulesType()
110  {
111  return 'ModelDetails';
112  }
113 
117  public static function getPortletDescription()
118  {
119  }
120 
124  public function renderPortletHeadContent()
125  {
126  return null;
127  }
128 
132  public static function getDefaultMetadata()
133  {
134  $metadata = array(
135  'perUser' => array(
136  'beginDate' => "eval:DateTimeCalculatorUtil::calculateNewByDaysFromNow(-30,
137  new DateTime(null, new DateTimeZone(Yii::app()->timeZoneHelper->getForCurrentUser())));",
138  'endDate' => "eval:DateTimeCalculatorUtil::calculateNewByDaysFromNow(0,
139  new DateTime(null, new DateTimeZone(Yii::app()->timeZoneHelper->getForCurrentUser())));",
140  'groupBy' => MarketingOverallMetricsForm::GROUPING_TYPE_WEEK,
141  ),
142  );
143  return $metadata;
144  }
145 
152  public function __construct($viewData, $params, $uniqueLayoutId)
153  {
154  assert('is_array($viewData) || $viewData == null');
155  assert('isset($params["portletId"])');
156  assert('isset($params["layoutId"])');
157  assert('is_string($uniqueLayoutId)');
158  $this->moduleId = 'home';
159  $this->viewData = $viewData;
160  $this->params = $params;
161  $this->uniqueLayoutId = $uniqueLayoutId;
162  }
163 
167  public function renderContent()
168  {
169  $content = ZurmoHtml::tag('h3', array(), Zurmo::t('MarketingModule', 'What is going on with Marketing?'));
170  $content .= $this->renderConfigureElementsContent();
171  $content .= $this->renderMetricsWrapperContent();
172  return $content;
173  }
174 
175  public function getPortletParams()
176  {
177  if (isset($this->params['relationModel']) && $this->params['relationModel']->id > 0)
178  {
179  return array('relationModuleId' => $this->params['relationModuleId'],
180  'relationModelId' => $this->params['relationModel']->id);
181  }
182  return array();
183  }
184 
188  protected function renderConfigureElementsContent()
189  {
190  $dateRangeContent = DateTimeUtil::resolveValueForDateLocaleFormattedDisplay($this->resolveForm()->beginDate)
191  . ' - ' .
193  $content = ZurmoHtml::tag('div', array(), $dateRangeContent);
194  $content .= $this->renderGroupByConfigurationForm();
195  return $content;
196  }
197 
201  protected function renderMetricsWrapperContent()
202  {
203  $cssClass = 'third marketing-graph';
204  $content = ZurmoHtml::tag('div', array('class' => $cssClass), $this->renderOverallListPerformanceContent());
205  $content .= ZurmoHtml::tag('div', array('class' => $cssClass), $this->renderEmailsInThisListContent());
206  $content .= ZurmoHtml::tag('div', array('class' => $cssClass), $this->renderListGrowthContent());
207  return ZurmoHtml::tag('div', array('class' => 'graph-container clearfix'), $content);
208  }
209 
214  {
215  $chartDataProvider = $this->resolveChartDataProvider('MarketingListPerformance');
216  $content = ZurmoHtml::tag('h3', array(), $this->getOverallListPerformanceTitle());
218  $chartDataProvider, $this->uniqueLayoutId . 'OverallListPerformance');
219  return $content;
220  }
221 
225  protected function getOverallListPerformanceTitle()
226  {
227  return Zurmo::t('MarketingModule', 'Overall Performance');
228  }
229 
233  protected function renderEmailsInThisListContent()
234  {
235  $chartDataProvider = $this->resolveChartDataProvider('MarketingEmailsInThisList');
236  $content = ZurmoHtml::tag('h3', array(), $this->getEmailsInThisListTitle());
238  $chartDataProvider, $this->uniqueLayoutId . 'EmailsInThisList');
239  return $content;
240  }
241 
245  protected function getEmailsInThisListTitle()
246  {
247  return Zurmo::t('MarketingModule', 'Overall Email Performance');
248  }
249 
253  protected function renderListGrowthContent()
254  {
255  $chartDataProvider = $this->resolveChartDataProvider('MarketingListGrowth');
256  $content = ZurmoHtml::tag('h3', array(), Zurmo::t('MarketingModule', 'List Growth'));
258  $chartDataProvider, $this->uniqueLayoutId . 'ListGrowth');
259  return $content;
260  }
261 
266  protected function resolveChartDataProvider($type)
267  {
268  assert('is_string($type)');
269  $chartDataProvider = ChartDataProviderFactory::createByType($type);
270  $chartDataProvider->setBeginDate($this->resolveForm()->beginDate);
271  $chartDataProvider->setEndDate($this->resolveForm()->endDate);
272  $chartDataProvider->setGroupBy($this->resolveForm()->groupBy);
273  return $chartDataProvider;
274  }
275 
279  protected function getPortletSaveConfigurationUrl()
280  {
281  $getData = GetUtil::getData();
282  $getData['portletId'] = $this->params['portletId'];
283  if (!isset($getData['uniqueLayoutId']))
284  {
285  $getData['uniqueLayoutId'] = $this->params['layoutId'];
286  }
287  $getData['portletParams'] = $this->getPortletParams();
288  return Yii::app()->createUrl('/' . $this->moduleId . '/defaultPortlet/modalConfigSave', $getData);
289  }
290 
294  protected function renderGroupByConfigurationForm()
295  {
296  $clipWidget = new ClipWidget();
297  list($form, $formStart) = $clipWidget->renderBeginWidget(
298  'ZurmoActiveForm',
299  array(
300  'id' => $this->getFormId(),
301  )
302  );
303  $content = $formStart;
304  $content .= $this->renderGroupByConfigurationFormLayout($form);
305  $formEnd = $clipWidget->renderEndWidget();
306  $content .= $formEnd;
308  return $content;
309  }
310 
314  protected function getFormId()
315  {
316  return 'marketing-metrics-group-by-configuration-form-' . $this->uniqueLayoutId;
317  }
318 
323  protected function renderGroupByConfigurationFormLayout($form)
324  {
325  assert('$form instanceof ZurmoActiveForm');
326  $groupByElement = new MarketingMetricsGroupByRadioElement($this->resolveForm(), 'groupBy', $form);
327  return ZurmoHtml::tag('div', array('id' => $this->getFormId() . '_groupBy_area', 'class' => 'mini-pillbox'), $groupByElement->render());
328  }
329 
334  {
335  assert('$form instanceof ZurmoActiveForm');
336  $ajaxSubmitScript = ZurmoHtml::ajax(array(
337  'type' => 'POST',
338  'data' => 'js:$("#' . $form->getId() . '").serialize() + \'&' . get_class($this->resolveForm()) .
339  '[groupBy]=\' + $(this).data("value")',
340  'url' => $this->getPortletSaveConfigurationUrl(),
341  'beforeSend' => 'js:function(){$(this).makeSmallLoadingSpinner(true, ".graph-container");
342  $("#MarketingDashboardView").addClass("loading");}',
343  'complete' => 'function(XMLHttpRequest, textStatus){juiPortlets.refresh();}',
344  'update' => '#' . $this->uniqueLayoutId,
345 
346  ));
347  Yii::app()->clientScript->registerScript($this->uniqueLayoutId . 'groupByChangeScript', "
348  $('." . $this->getFormId() . "marketingMetricsGroupByLink').click(function()
349  {
350  " . $ajaxSubmitScript . "
351  return false;
352  }
353  );
354  ");
355  }
356 
361  protected function resolveForm()
362  {
363  if ($this->formModel !== null)
364  {
365  return $this->formModel;
366  }
367  if ($this->formModelClassName == null)
368  {
369  throw new NotSupportedException();
370  }
371  else
372  {
373  $formModelClassName = $this->formModelClassName;
374  }
375  $formModel = new $formModelClassName();
376  if ($this->viewData!='')
377  {
378  $formModel->setAttributes($this->viewData);
379  }
380  else
381  {
382  $metadata = self::getMetadata();
383  $perUserMetadata = $metadata['perUser'];
384  $this->resolveEvaluateSubString($perUserMetadata, null);
385  $formModel->setAttributes($perUserMetadata);
386  }
387  $this->formModel = $formModel;
388  return $formModel;
389  }
390  }
391 ?>
__construct($viewData, $params, $uniqueLayoutId)
static resolveValueForDateLocaleFormattedDisplay($date, $displayFormat=null)
static renderListGrowthChartContent(MarketingListGrowthChartDataProvider $chartDataProvider, $uniqueId)
static renderEmailsInThisListChartContent(ChartDataProvider $chartDataProvider, $uniqueId)
static renderOverallListPerformanceChartContent(MarketingListPerformanceChartDataProvider $chartDataProvider, $uniqueId)
registerGroupByConfigurationFormLayoutScripts($form)
resolveEvaluateSubString(&$element, $key)
Generated on Fri Jul 10 2020 07:10:33
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.