Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
RuntimeFiltersForPortletView.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  {
45  public function getTitle()
46  {
47  return Zurmo::t('Core', 'Filters');
48  }
49 
53  public function renderContent()
54  {
55  OperatorStaticDropDownElement::registerOnLoadAndOnChangeScript();
56  return $this->renderForm();
57  }
58 
62  public static function getFormId()
63  {
64  return 'edit-form';
65  }
66 
70  protected function renderForm()
71  {
72  $content = $this->renderRefreshLink();
73  $content .= '<div class="wrapper">';
74  $content .= '<div class="wide form">';
75  $content .= '<div class="left-column full-width">';
76  $clipWidget = new ClipWidget();
77  list($form, $formStart) = $clipWidget->renderBeginWidget(
78  'WizardActiveForm',
79  array('id' => static::getFormId(),
80  'action' => $this->getFormActionUrl(),
81  'enableAjaxValidation' => true,
82  'clientOptions' => $this->getClientOptions(),
83  'modelClassNameForError' => $this->getWizardFormClassName())
84  );
85  $content .= $formStart;
86  $rowCount = 0;
87  $items = $this->renderItems($rowCount, $form);
88  $itemsContent = $this->getNonSortableListContent($items);
89  $content .= ZurmoHtml::tag('div', array('class' => 'dynamic-rows'), $itemsContent);
90  $content .= $this->renderViewToolBarContainer($form);
91  $formEnd = $clipWidget->renderEndWidget();
92  $content .= $formEnd;
93  $content .= '</div></div>';
94  $content .= $this->renderModalContainer();
95  $content .= '</div>';
96  return $content;
97  }
98 
102  protected function getWizardFormClassName()
103  {
104  return ReportToWizardFormAdapter::getFormClassNameByType($this->params['relationModel']->getType());
105  }
106 
112  protected function renderItems(& $rowCount, WizardActiveForm $form)
113  {
114  assert('is_int($rowCount)');
115  $items = array();
116  $wizardFormClassName = $this->getWizardFormClassName();
118  $trackableStructurePosition = false; //can we set this to false without jacking things up?
119  $report = $this->params["relationModel"];
120  if (null != $stickyData = StickyReportUtil::getDataByKey($report->id))
121  {
122  StickyReportUtil::resolveStickyDataToReport($report, $stickyData);
123  }
124  foreach ($report->getFilters() as $filterForReportForm)
125  {
126  if ($filterForReportForm->availableAtRunTime)
127  {
128  $nodeIdWithoutTreeType = $filterForReportForm->attributeIndexOrDerivedType;
130  resolveInputPrefixData($wizardFormClassName,
131  $treeType, $rowCount);
132  $adapter = new RuntimeReportAttributeToElementAdapter($inputPrefixData, $filterForReportForm,
133  $form, $treeType);
134  $view = new AttributeRowForReportComponentView($adapter,
135  $rowCount, $inputPrefixData,
137  resolveAttributeByNodeId($nodeIdWithoutTreeType),
138  (bool)$trackableStructurePosition, false, null);
139  $view->addWrapper = false;
140  $items[] = array('content' => $view->render());
141  }
142  $rowCount++;
143  }
144  return $items;
145  }
146 
151  protected function getNonSortableListContent(Array $items)
152  {
153  $content = null;
154  foreach ($items as $item)
155  {
156  $content .= ZurmoHtml::tag('li', array(), $item['content']);
157  }
158  return ZurmoHtml::tag('ul', array(), $content);
159  }
160 
164  protected function getClientOptions()
165  {
166  return array(
167  'validateOnSubmit' => true,
168  'validateOnChange' => false,
169  'beforeValidate' => 'js:$(this).beforeValidateAction',
170  'afterValidate' => 'js:$(this).afterValidateAjaxAction',
171  'afterValidateAjax' => $this->renderConfigSaveAjax(static::getFormId()),
172  );
173  }
174 
178  protected function getFormActionUrl()
179  {
180  return Yii::app()->createUrl('reports/default/applyRuntimeFilters',
181  array('id' => $this->params["relationModel"]->getId()));
182  }
183 
188  protected function renderConfigSaveAjax($formName)
189  {
190  return "$('#apply-runtime-filters').removeClass('loading');
191  $('#apply-runtime-filters').removeClass('loading-ajax-submit');
192  $('#ReportResultsGridForPortletView').find('.refreshPortletLink').click();
193  $('#ReportChartForPortletView').find('.refreshPortletLink').click();
194  $('#ReportSQLForPortletView').find('.refreshPortletLink').click();
195  ";
196  }
197 
202  protected function renderViewToolBarContainer($form)
203  {
204  $content = '<div class="view-toolbar-container clearfix">';
205  $content .= '<div class="form-toolbar">';
206  $content .= $this->renderViewToolBarLinks($form);
207  $content .= '</div></div>';
208  return $content;
209  }
210 
215  protected function renderViewToolBarLinks($form)
216  {
217  $params = array();
218  $params['label'] = Zurmo::t('Core', 'Apply');
219  $params['htmlOptions'] = array('id' => 'apply-runtime-filters',
220  'onclick' => 'js:$(this).addClass("attachLoadingTarget");');
221  $resetElement = new RefreshRuntimeFiltersAjaxLinkActionElement(null, null,
222  $this->params['relationModel']->getId(), array());
223  $applyElement = new SaveButtonActionElement(null, null, null, $params);
224  return $resetElement->render() . $applyElement->render();
225  }
226 
227  protected function renderModalContainer()
228  {
229  return ZurmoHtml::tag('div', array(
230  'id' => ModelElement::MODAL_CONTAINER_PREFIX . '-' . $this->getFormId()
231  ), '');
232  }
233  }
234 ?>
getId()
Definition: View.php:155
renderItems(&$rowCount, WizardActiveForm $form)
static resolveStickyDataToReport(Report $report, array $stickyData)
static resolveInputPrefixData($formModelClassName, $treeType, $rowNumber)
static getDataByKey($key)
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.