Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
ReportAttributeToElementAdapter.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  protected $showAvailableRuntimeFilter = true;
46 
51  public function getContent()
52  {
53  $this->form->setInputPrefixData($this->inputPrefixData);
54  if ($this->treeType == ComponentForReportForm::TYPE_FILTERS)
55  {
56  $content = $this->getContentForFilter();
57  }
58  elseif ($this->treeType == ComponentForReportForm::TYPE_DISPLAY_ATTRIBUTES)
59  {
60  $content = $this->getContentForDisplayAttribute();
61  }
62  elseif ($this->treeType == ComponentForReportForm::TYPE_ORDER_BYS)
63  {
64  $content = $this->getContentForOrderBy();
65  }
66  elseif ($this->treeType == ComponentForReportForm::TYPE_GROUP_BYS)
67  {
68  $content = $this->getContentForGroupBy();
69  }
71  {
72  $content = $this->getContentForDrillDownDisplayAttribute();
73  }
74  else
75  {
76  throw new NotSupportedException();
77  }
78  $this->form->clearInputPrefixData();
79  return $content;
80  }
81 
86  protected function getContentForFilter()
87  {
88  $params = array('inputPrefix' => $this->inputPrefixData);
89  if ($this->model->hasAvailableOperatorsType() && count($this->model->getOperatorValuesAndLabels()) > 1)
90  {
91  $operatorElement = new OperatorStaticDropDownElement($this->model, 'operator', $this->form, $params);
92  $operatorElement->editableTemplate = '{content}{error}';
93  $operatorContent = $operatorElement->render();
94  }
95  else
96  {
97  $operatorContent = null;
98  }
99  $valueElementType = $this->model->getValueElementType();
100  if ($valueElementType != null)
101  {
102  $valueElementClassName = $valueElementType . 'Element';
103  $valueElement = new $valueElementClassName($this->model, 'value', $this->form, $params);
104  if ($valueElement instanceof NameIdElement)
105  {
106  $valueElement->setIdAttributeId('value');
107  $valueElement->setNameAttributeName('stringifiedModelForValue');
108  }
109  if ($valueElement instanceof MixedNumberTypesElement)
110  {
111  $valueElement->editableTemplate = '<div class="value-data two-value-areas">{content}{error}</div>';
112  }
113  elseif ($valueElement instanceof MixedDateTypesElement)
114  {
115  $valueElement->editableTemplate = '<div class="dynamic-row-operator">{valueType}</div>' .
116  '<div class="value-data one-value-area has-date-inputs">' .
117  '<div class="first-value-area one-value-area">{content}{error}</div></div>';
118  }
119  elseif ($valueElement instanceof MixedLoggedInUserTypesAndUsersElement)
120  {
121  $valueElement->editableTemplate = '<div class="dynamic-row-operator">{valueType}</div>' .
122  '<div class="value-data one-value-area">' .
123  '<div class="first-value-area one-value-area">{content}{error}</div></div>';
124  }
125  else
126  {
127  $startingDivStyleFirstValue = null;
128  if (in_array($this->model->getOperator(), array(OperatorRules::TYPE_IS_NULL, OperatorRules::TYPE_IS_NOT_NULL, OperatorRules::TYPE_IS_EMPTY, OperatorRules::TYPE_IS_NOT_EMPTY)))
129  {
130  $startingDivStyleFirstValue = "display:none;";
131  $valueElement->params['disabled'] = 'disabled';
132  }
133  $valueElement->editableTemplate = '<div class="value-data one-value-area"><div class="first-value-area" style="' .
134  $startingDivStyleFirstValue . '">{content}{error}</div></div>';
135  }
136  $valueContent = $valueElement->render();
137  }
138  else
139  {
140  throw new NotSupportedException();
141  }
142  $content = $this->renderAttributeIndexOrDerivedType();
143  $content .= $this->renderHiddenOperator();
144  self::resolveDivWrapperForContent($this->model->getDisplayLabel(), $content, 'dynamic-row-label');
145  self::resolveDivWrapperForContent($operatorContent, $content, 'dynamic-row-operator');
146  $content .= $valueContent;
147  if ($this->showAvailableRuntimeFilter)
148  {
149  $runTimeElement = new CheckBoxElement($this->model, 'availableAtRunTime',
150  $this->form, $params);
151  $runTimeElement->editableTemplate = '{label}{content}{error}';
152  $runTimeContent = $runTimeElement->render();
153  self::resolveDivWrapperForContent($runTimeContent, $content, 'report-runtime-availability');
154  }
155  return $content;
156  }
157 
163  protected function renderHiddenOperator()
164  {
165  if ($this->model->hasAvailableOperatorsType() && count($this->model->getOperatorValuesAndLabels()) == 1)
166  {
167  $hiddenInputName = Element::resolveInputNamePrefixIntoString(
168  array_merge($this->inputPrefixData, array('operator')));
169  $hiddenInputId = Element::resolveInputIdPrefixIntoString(
170  array_merge($this->inputPrefixData, array('operator')));
171  $idInputHtmlOptions = array('id' => $hiddenInputId);
172  $valuesAndLabels = $this->model->getOperatorValuesAndLabels();
173  return ZurmoHtml::hiddenField($hiddenInputName, key($valuesAndLabels), $idInputHtmlOptions);
174  }
175  }
176 
182  protected function getContentForGroupBy()
183  {
184  if ($this->model->getReportType() == Report::TYPE_ROWS_AND_COLUMNS)
185  {
186  throw new NotSupportedException();
187  }
188  elseif ($this->model->getReportType() == Report::TYPE_MATRIX)
189  {
190  $params = array('inputPrefix' => $this->inputPrefixData);
191  $groupByAxisElement = new GroupByAxisStaticDropDownElement($this->model, 'axis',
192  $this->form, $params);
193  $groupByAxisElement->editableTemplate = '{content}{error}';
194  $groupByAxisElement = $groupByAxisElement->render();
195  }
196  else
197  {
198  $groupByAxisElement = null;
199  }
200  $content = $this->renderAttributeIndexOrDerivedType();
201  self::resolveDivWrapperForContent($this->model->getDisplayLabel(), $content, 'dynamic-row-label');
202  self::resolveDivWrapperForContent($groupByAxisElement, $content, 'dynamic-row-field');
203  return $content;
204  }
205 
211  protected function getContentForOrderBy()
212  {
213  if ($this->model->getReportType() == Report::TYPE_MATRIX)
214  {
215  throw new NotSupportedException();
216  }
217  $params = array('inputPrefix' => $this->inputPrefixData);
218  $directionElement = new OrderByStaticDropDownElement($this->model, 'order', $this->form,
219  $params);
220  $directionElement->editableTemplate = '{content}{error}';
221  $directionElement = $directionElement->render();
222  $content = $this->renderAttributeIndexOrDerivedType();
223  self::resolveDivWrapperForContent($this->model->getDisplayLabel(), $content, 'dynamic-row-label');
224  self::resolveDivWrapperForContent($directionElement, $content, 'dynamic-row-field');
225  return $content;
226  }
227 
231  protected function getContentForDisplayAttribute()
232  {
233  $params = array('inputPrefix' => $this->inputPrefixData);
234  $displayLabelElement = new TextElement($this->model, 'label', $this->form, $params);
235  $displayLabelElement->editableTemplate = '{content}{error}';
236  $displayLabelElement = $displayLabelElement->render();
237  $content = $this->renderAttributeIndexOrDerivedType();
238  self::resolveDivWrapperForContent($this->model->getDisplayLabel(), $content, 'dynamic-row-label');
239  self::resolveDivWrapperForContent($displayLabelElement, $content, 'dynamic-row-field');
240  return $content;
241  }
242 
248  {
249  if ($this->model->getReportType() == Report::TYPE_ROWS_AND_COLUMNS ||
250  $this->model->getReportType() == Report::TYPE_MATRIX)
251  {
252  throw new NotSupportedException();
253  }
254  return $this->getContentForDisplayAttribute();
255  }
256  }
257 ?>
const TYPE_MATRIX
Definition: Report.php:63
const TYPE_ROWS_AND_COLUMNS
Definition: Report.php:51
Generated on Fri Jul 10 2020 07:10:34
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.