Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
DisplayAttributeForReportForm.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  const COLUMN_ALIAS_PREFIX = 'col';
43 
44  const HEADER_SORTABLE_TYPE_ASORT = 'asort';
45 
49  public $label;
50 
55  public $columnAliasName;
56 
61  public $queryOnly = false;
62 
68  public $valueUsedAsDrillDownFilter = false;
69 
77  public $madeViaSelectInsteadOfViaModel = false;
78 
82  protected static $count = 0;
83 
90  protected $modelAliasUsingTableAliasName;
91 
95  public static function getType()
96  {
97  return static::TYPE_DISPLAY_ATTRIBUTES;
98  }
99 
107  public function __construct($moduleClassName, $modelClassName, $reportType, $rowKey = 0)
108  {
109  parent::__construct($moduleClassName, $modelClassName, $reportType, $rowKey);
110  $this->columnAliasName = self::COLUMN_ALIAS_PREFIX . static::$count++;
111  }
112 
119  public function attributeNames()
120  {
121  $attributeNames = parent::attributeNames();
122  if (count($attributeNames) != 6)
123  {
124  throw new NotSupportedException();
125  }
126  array_unshift( $attributeNames, array_pop( $attributeNames ) );
127  return $attributeNames;
128  }
129 
133  public function rules()
134  {
135  return array_merge(parent::rules(), array(
136  array('label', 'required'),
137  array('label', 'type', 'type' => 'string'),
138  ));
139  }
140 
145  public function __set($name, $value)
146  {
147  parent::__set($name, $value);
148  if ($name == 'attributeIndexOrDerivedType')
149  {
150  $this->label = $this->getDisplayLabel();
151  }
152  }
153 
157  public static function resetCount()
158  {
159  static::$count = 0;
160  }
161 
165  public function setModelAliasUsingTableAliasName($modelAliasUsingTableAliasName)
166  {
167  assert('is_string($modelAliasUsingTableAliasName)');
168  $this->modelAliasUsingTableAliasName = $modelAliasUsingTableAliasName;
169  }
170 
175  {
176  return $this->modelAliasUsingTableAliasName;
177  }
178 
184  {
185  assert('is_int($key)');
187  if ($modelToReportAdapter->isDisplayAttributeMadeViaSelect($this->getResolvedAttribute()))
188  {
189  return $this->columnAliasName;
190  }
192  }
193 
199  public function isALinkableAttribute()
200  {
201  $resolvedAttribute = $this->getResolvedAttribute();
202  if ($resolvedAttribute == 'name' || $resolvedAttribute == 'FullName')
203  {
204  return true;
205  }
206  return false;
207  }
208 
212  public function getRawValueRelatedAttribute()
213  {
215  return $modelToReportAdapter->getRawValueRelatedAttribute($this->getResolvedAttribute());
216  }
217 
226  public function resolveValueAsLabelForHeaderCell($value, $forExport = false)
227  {
228  $tContent = null;
229  $translatedValue = $value;
230  $resolvedAttribute = $this->getResolvedAttribute();
231  $displayElementType = $this->getDisplayElementType();
233  if ($modelToReportAdapter->getModel()->isAttribute($resolvedAttribute) &&
234  $modelToReportAdapter->getModel()->isRelation($resolvedAttribute) &&
235  !$modelToReportAdapter->getModel()->isOwnedRelation($resolvedAttribute))
236  {
237  $relationModelClassName = $modelToReportAdapter->getModel()->getRelationModelClassName($resolvedAttribute);
238  $relatedModel = $relationModelClassName::getById((int)$value);
239  if ($relatedModel->isAttribute('serializedLabels'))
240  {
241  $translatedValue = $relatedModel->resolveTranslatedNameByLanguage(Yii::app()->language);
242  }
243  }
244  elseif ($displayElementType == 'User')
245  {
246  $user = User::getById((int)$value);
247  $translatedValue = strval($user);
248  }
249  elseif ($displayElementType == 'DropDown')
250  {
254  $customFieldData, Yii::app()->language);
255  if (isset($dataAndLabels[$value]))
256  {
257  $translatedValue = $dataAndLabels[$value];
258  }
259  }
260  elseif ($displayElementType == 'CheckBox')
261  {
262  if ($value)
263  {
264  $translatedValue = Zurmo::t('Core', 'Yes');
265  }
266  elseif ($value == false && $value != '')
267  {
268  $translatedValue = Zurmo::t('Core', 'No');
269  }
270  }
271  elseif ($displayElementType == 'GroupByModifierMonth')
272  {
273  $translatedValue = DateTimeUtil::getMonthName($value);
274  }
275  if ($translatedValue === null)
276  {
277  $translatedValue = '';
278  }
279  if ($this->isALinkableAttribute() && !$forExport)
280  {
281  $modelClassName = get_class($modelToReportAdapter->getModel());
282  $moduleClassName = $modelToReportAdapter->getModuleClassName();
283  if (isset($relationModelClassName))
284  {
285  $modelClassName = $relationModelClassName;
286  }
287  return ReportResultsGridUtil::makeStringForMultipleLinks($value, $modelClassName, $moduleClassName);
288  }
289  return $translatedValue;
290  }
291 
298  public function getHeaderSortableType()
299  {
300  if ($this->attributeIndexOrDerivedType == null)
301  {
302  throw new NotSupportedException();
303  }
305  if ($modelToReportAdapter->isAttributeACalculatedGroupByModifier($this->getResolvedAttribute()))
306  {
307  return self::HEADER_SORTABLE_TYPE_ASORT;
308  }
309  else
310  {
311  return null;
312  }
313  }
314  }
315 ?>
static getDataIndexedByDataAndTranslatedLabelsByLanguage(CustomFieldData $customFieldData, $language)
static resolveAttributeNameByKey($key)
static getMonthName($month)
resolveValueAsLabelForHeaderCell($value, $forExport=false)
__construct($moduleClassName, $modelClassName, $reportType, $rowKey=0)
static getById($id, $modelClassName=null)
static getDataByModelClassNameAndAttributeName($modelClassName, $attributeName)
setModelAliasUsingTableAliasName($modelAliasUsingTableAliasName)
Generated on Sat Oct 31 2020 07:10:29
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.