All Data Structures Functions Variables Pages
MatrixReportDataProvider.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 HEADER_COLUMN_ALIAS_SUFFIX = 'Header';
43 
44  const TOTAL_COLUMN_ALIAS_SUFFIX = 'Total';
45 
46  public static $maximumGroupsCount = 400;
47 
48  protected $haveGrandTotals = true;
49 
54  private $resolvedDisplayAttributes;
55 
60  private $resolvedGroupBys;
61 
65  private $xAxisGroupByDataValues;
66 
70  private $yAxisGroupByDataValues;
71 
76  public static function resolveColumnAliasName($index)
77  {
78  assert('is_int($index)');
79  return DisplayAttributeForReportForm::COLUMN_ALIAS_PREFIX . $index;
80  }
81 
86  public static function resolveHeaderColumnAliasName($columnAliasName)
87  {
88  assert('is_int($columnAliasName) || is_string($columnAliasName)');
89  return $columnAliasName . self::HEADER_COLUMN_ALIAS_SUFFIX;
90  }
91 
96  public static function resolveTotalColumnAliasName($columnAliasName)
97  {
98  assert('is_int($columnAliasName) || is_string($columnAliasName)');
99  return $columnAliasName . self::TOTAL_COLUMN_ALIAS_SUFFIX;
100  }
101 
107  public function __construct(Report $report, array $config = array())
108  {
109  parent::__construct($report, $config);
110  $this->pagination = array('pageSize' => self::$maximumGroupsCount);
111  }
112 
116  public function calculateTotalItemCount()
117  {
118  $selectQueryAdapter = new RedBeanModelSelectQueryAdapter();
119  $sql = $this->makeSqlQueryForFetchingTotalItemCount($selectQueryAdapter);
120  $rows = ZurmoRedBean::getAll($sql);
121  return count($rows);
122  }
123 
128  {
130  }
131 
135  public function resolveDisplayAttributes()
136  {
137  if ($this->resolvedDisplayAttributes == null)
138  {
139  $this->resolvedDisplayAttributes = array();
140  foreach ($this->report->getDisplayAttributes() as $displayAttribute)
141  {
142  $this->resolvedDisplayAttributes[] = $displayAttribute;
143  }
144  foreach ($this->resolveGroupBys() as $groupBy)
145  {
146  $displayAttribute = new DisplayAttributeForReportForm(
147  $groupBy->getModuleClassName(),
148  $groupBy->getModelClassName(),
149  $this->report->getType());
150  $displayAttribute->attributeIndexOrDerivedType = $groupBy->attributeIndexOrDerivedType;
151  $displayAttribute->queryOnly = true;
152  $displayAttribute->madeViaSelectInsteadOfViaModel = true;
153  $this->resolvedDisplayAttributes[] = $displayAttribute;
154  }
155  }
156  return $this->resolvedDisplayAttributes;
157  }
158 
159  protected function getDisplayAttributesForGrandTotals()
160  {
161  $displayAttributes = $this->resolveDisplayAttributes();
162  return $displayAttributes;
163  }
164 
168  public function resolveGroupBys()
169  {
170  if ($this->resolvedGroupBys != null)
171  {
172  return $this->resolvedGroupBys;
173  }
174  $this->resolvedGroupBys = array();
175  foreach ($this->report->getGroupBys() as $groupBy)
176  {
177  if ($groupBy->axis == 'y')
178  {
179  $this->resolvedGroupBys[] = $groupBy;
180  }
181  }
182  foreach ($this->report->getGroupBys() as $groupBy)
183  {
184  if ($groupBy->axis == 'x')
185  {
186  $this->resolvedGroupBys[] = $groupBy;
187  }
188  }
189  return $this->resolvedGroupBys;
190  }
191 
196  {
197  $count = 1;
198  foreach ($this->getXAxisGroupByDataValues() as $groupByValues)
199  {
200  $count = $count * count($groupByValues);
201  }
202  return $count;
203  }
204 
209  {
210  return count($this->getYAxisGroupByDataValues());
211  }
212 
218  {
219  $data = array();
220  $xAxisGroupByDataValues = $this->getXAxisGroupByDataValues();
221  $xAxisGroupByDataValuesCount = count($xAxisGroupByDataValues);
222  $attributeKey = 0;
223  $startingGroupBysIndex = 0;
224  $this->resolveXAxisGroupingsForColumnNames($data, array_values($xAxisGroupByDataValues), $attributeKey,
225  $xAxisGroupByDataValuesCount, $startingGroupBysIndex);
226  return $data;
227  }
228 
233  public function makeAxisCrossingColumnCountAndLeadingHeaderRowsData($forExport = false)
234  {
235  $headerData = array('rows' => array());
236  $headerData['axisCrossingColumnCount'] = count($this->getYAxisGroupBys());
237  $lastSpanCount = $this->getDisplayCalculationsCount();
238  foreach (array_reverse($this->getXAxisGroupByDataValues()) as $attributeIndexOrDerivedType => $groupByValues)
239  {
240  $xAxisDisplayAttribute = $this->getDisplayAttributeByAttribute($attributeIndexOrDerivedType);
241  foreach ($groupByValues as $key => $value)
242  {
243  $groupByValues[$key] = $xAxisDisplayAttribute->resolveValueAsLabelForHeaderCell($value, $forExport);
244  }
245  $headerData['rows'][] = array('groupByValues' => $groupByValues, 'colSpan' => $lastSpanCount);
246  $lastSpanCount = count($groupByValues) * $lastSpanCount;
247  }
248  $headerData['rows'] = array_reverse($headerData['rows']);
249  if ($this->haveGrandTotals)
250  {
251  $headerData['renderTotalColumn'] = true;
252  }
253  return $headerData;
254  }
255 
260  {
261  $displayAttributes = array();
262  foreach ($this->resolveDisplayAttributes() as $displayAttribute)
263  {
264  foreach ($this->getYAxisGroupBys() as $groupBy)
265  {
266  if ($displayAttribute->attributeIndexOrDerivedType ==
267  $groupBy->attributeIndexOrDerivedType)
268  {
269  $displayAttributes[] = $displayAttribute;
270  break;
271  }
272  }
273  }
274  return $displayAttributes;
275  }
276 
284  protected function resolveXAxisGroupingsForColumnNames(& $data, $indexedXAxisGroupByDataValues, & $attributeKey,
285  $xAxisGroupBysCount, $startingIndex)
286  {
287  assert('is_array($data)');
288  assert('is_array($indexedXAxisGroupByDataValues)');
289  assert('is_int($attributeKey)');
290  assert('is_int($xAxisGroupBysCount)');
291  assert('is_int($startingIndex)');
292  if (isset($indexedXAxisGroupByDataValues[$startingIndex]))
293  {
294  foreach ($indexedXAxisGroupByDataValues[$startingIndex] as $value)
295  {
296  $data[$value] = array();
297  if (($startingIndex + 1) == $xAxisGroupBysCount)
298  {
299  foreach ($this->resolveDisplayAttributes() as $displayAttribute)
300  {
301  if ($displayAttribute->queryOnly != true)
302  {
303  $data[$value][$displayAttribute->attributeIndexOrDerivedType] =
304  static::resolveColumnAliasName($attributeKey);
305  $attributeKey++;
306  }
307  }
308  }
309  else
310  {
311  $this->resolveXAxisGroupingsForColumnNames($data[$value], $indexedXAxisGroupByDataValues,
312  $attributeKey, $xAxisGroupBysCount, $startingIndex + 1);
313  }
314  }
315  }
316  }
317 
323  protected function runQueryAndGetResolveResultsData($offset, $limit)
324  {
325  assert('is_int($offset) || $offset == null');
326  assert('is_int($limit) || $limit == null');
327  $selectQueryAdapter = new RedBeanModelSelectQueryAdapter();
328  $sql = $this->makeSqlQueryForFetchingData($selectQueryAdapter,
329  $offset, $limit);
330  $rows = $this->getRowsData($sql);
331  $resultsData = array();
332  $idByOffset = 0;
333  $calculationsCount = $this->getDisplayCalculationsCount();
334  $xAxisGroupByDataValuesCount = $this->getXAxisGroupByDataValuesCount() * $calculationsCount;
335  $xAxisGroupingsColumnNamesData = $this->makeXAxisGroupingsForColumnNamesData();
336  $displayAttributesThatAreYAxisGroupBys = $this->getDisplayAttributesThatAreYAxisGroupBys();
337  $previousYAxisDisplayAttributesUniqueIndex = $this->resolveYAxisDisplayAttributesUniqueIndex(
338  $rows[0], $displayAttributesThatAreYAxisGroupBys);
339  $resultsData[$idByOffset] = new ReportResultsRowData($this->resolveDisplayAttributes(), 0);
340  $this->addDefaultColumnNamesAndValuesToReportResultsRowData($resultsData[$idByOffset],
341  $xAxisGroupByDataValuesCount);
342  $sqlForRowTotals = $this->makeSqlQueryForRowTotals();
343  $rowTotals = ZurmoRedBean::getAll($sqlForRowTotals);
344  foreach ($rows as $row)
345  {
346  $currentYAxisDisplayAttributesUniqueIndex = $this->resolveYAxisDisplayAttributesUniqueIndex(
347  $row, $displayAttributesThatAreYAxisGroupBys);
348  if ($previousYAxisDisplayAttributesUniqueIndex != $currentYAxisDisplayAttributesUniqueIndex)
349  {
350  $idByOffset++;
351  $resultsData[$idByOffset] = new ReportResultsRowData($this->resolveDisplayAttributes(), $idByOffset);
352  $this->addDefaultColumnNamesAndValuesToReportResultsRowData($resultsData[$idByOffset],
353  $xAxisGroupByDataValuesCount);
354  }
355  $tempData = $xAxisGroupingsColumnNamesData;
356  foreach ($this->resolveDisplayAttributes() as $displayAttribute)
357  {
358  $value = $row[$displayAttribute->columnAliasName];
359  if ($this->isDisplayAttributeAnXAxisGroupBy($displayAttribute))
360  {
361  $tempData = $tempData[$value];
362  }
363  elseif ($this->isDisplayAttributeAnYAxisGroupBy($displayAttribute))
364  {
365  $resolvedColumnAliasName = static::resolveHeaderColumnAliasName($displayAttribute->columnAliasName);
366  $resultsData[$idByOffset]->addSelectedColumnNameAndValue($resolvedColumnAliasName, $value);
367  $resultsData[$idByOffset]->addSelectedColumnNameAndLabel($resolvedColumnAliasName, $displayAttribute->resolveValueAsLabelForHeaderCell($value));
368  }
369  }
370  //At this point $tempData is at the final level, where the actual display calculations are located
371  foreach ($this->resolveDisplayAttributes() as $displayAttribute)
372  {
373  if (!$displayAttribute->queryOnly)
374  {
375  $value = $row[$displayAttribute->columnAliasName];
376  $columnAliasName = $tempData[$displayAttribute->attributeIndexOrDerivedType];
377  $resultsData[$idByOffset]->addSelectedColumnNameAndValue($columnAliasName, $value);
378 
379  //Adds the totalRows column
380  $totalValue = $rowTotals[$idByOffset][$displayAttribute->columnAliasName];
381  $resolvedColumnAliasName = static::resolveTotalColumnAliasName($displayAttribute->columnAliasName);
382  $resultsData[$idByOffset]->addSelectedColumnNameAndValue($resolvedColumnAliasName, $totalValue);
383  }
384  }
385  $previousYAxisDisplayAttributesUniqueIndex = $currentYAxisDisplayAttributesUniqueIndex;
386  }
387  $this->resolveRowSpansForResultsData($resultsData);
388  return $resultsData;
389  }
390 
394  protected function resolveRowSpansForResultsData(& $resultsData)
395  {
396  $previousLeadingUniqueIndexData = array();
397  foreach ($resultsData as $dataKey => $reportResultsRowData)
398  {
399  $leadingUniqueIndexData = array();
400  $leadingUniqueIndex = null;
401  foreach ($this->getDisplayAttributesThatAreYAxisGroupBys() as $displayAttribute)
402  {
403  $attributeName = static::resolveHeaderColumnAliasName($displayAttribute->columnAliasName);
404  if ($leadingUniqueIndex != null)
405  {
406  $leadingUniqueIndex .= FormModelUtil::DELIMITER;
407  }
408  $leadingUniqueIndex .= $reportResultsRowData->{$attributeName};
409  $leadingUniqueIndexData[$displayAttribute->columnAliasName] = $leadingUniqueIndex;
410  $rowSpan = 0;
411  if ($dataKey == 0 ||
412  $previousLeadingUniqueIndexData[$displayAttribute->columnAliasName] !=
413  $leadingUniqueIndexData[$displayAttribute->columnAliasName])
414  {
415  $rowSpan = 1;
416  for ($i = ($dataKey + 1); $i < count($resultsData); $i++)
417  {
418  $nextLeadingUniqueIndex = null;
419  foreach ($this->getDisplayAttributesThatAreYAxisGroupBys() as $nextDisplayAttribute)
420  {
421  if ($nextLeadingUniqueIndex != null)
422  {
423  $nextLeadingUniqueIndex .= FormModelUtil::DELIMITER;
424  }
425  $nextAttributeName = static::resolveHeaderColumnAliasName($nextDisplayAttribute->columnAliasName);
426  $nextLeadingUniqueIndex .= $resultsData[$i]->$nextAttributeName;
427  if ($nextDisplayAttribute->attributeIndexOrDerivedType == $displayAttribute->attributeIndexOrDerivedType)
428  {
429  break;
430  }
431  }
432  if ($nextLeadingUniqueIndex == $leadingUniqueIndexData[$displayAttribute->columnAliasName])
433  {
434  $rowSpan++;
435  }
436  else
437  {
438  break;
439  }
440  }
441  }
442  $resultsData[$dataKey]->addSelectedColumnNameAndRowSpan(static::resolveHeaderColumnAliasName(
443  $displayAttribute->columnAliasName), $rowSpan);
444  }
445  $previousLeadingUniqueIndexData = $leadingUniqueIndexData;
446  }
447  }
448 
452  protected function getDisplayCalculationsCount()
453  {
454  $count = 0;
455  foreach ($this->resolveDisplayAttributes() as $displayAttribute)
456  {
457  if (!$displayAttribute->queryOnly)
458  {
459  $count++;
460  }
461  }
462  return $count;
463  }
464 
468  protected function getXAxisGroupByDataValues()
469  {
470  if ($this->xAxisGroupByDataValues == null)
471  {
472  $this->xAxisGroupByDataValues = array();
473  $selectQueryAdapter = new RedBeanModelSelectQueryAdapter();
474  $sql = $this->makeSqlQueryForFetchingData($selectQueryAdapter, null, null);
475  $rows = $this->getRowsData($sql);
476  foreach ($rows as $row)
477  {
478  foreach ($this->getDisplayAttributesThatAreXAxisGroupBys() as $displayAttribute)
479  {
480  if (!isset($this->xAxisGroupByDataValues[$displayAttribute->attributeIndexOrDerivedType]) ||
481  !in_array($row[$displayAttribute->columnAliasName],
482  $this->xAxisGroupByDataValues[$displayAttribute->attributeIndexOrDerivedType]))
483  {
484  $this->xAxisGroupByDataValues[$displayAttribute->attributeIndexOrDerivedType][] =
485  $row[$displayAttribute->columnAliasName];
486  }
487  }
488  }
489  }
490  //Sort for group bys correctly.
491  foreach ($this->getDisplayAttributesThatAreXAxisGroupBys() as $displayAttribute)
492  {
493  if ($displayAttribute->getHeaderSortableType() == DisplayAttributeForReportForm::HEADER_SORTABLE_TYPE_ASORT &&
494  isset($this->xAxisGroupByDataValues[$displayAttribute->attributeIndexOrDerivedType]))
495  {
496  asort($this->xAxisGroupByDataValues[$displayAttribute->attributeIndexOrDerivedType]);
497  }
498  }
499  return $this->xAxisGroupByDataValues;
500  }
501 
505  protected function getYAxisGroupByDataValues()
506  {
507  if ($this->yAxisGroupByDataValues == null)
508  {
509  $this->yAxisGroupByDataValues = array();
510  $selectQueryAdapter = new RedBeanModelSelectQueryAdapter();
511  $sql = $this->makeSqlQueryForFetchingData($selectQueryAdapter, null, null);
512  $rows = $this->getRowsData($sql);
513  foreach ($rows as $row)
514  {
515  foreach ($this->getDisplayAttributesThatAreYAxisGroupBys() as $displayAttribute)
516  {
517  if (!isset($this->yAxisGroupByDataValues[$displayAttribute->attributeIndexOrDerivedType]) ||
518  in_array($row[$displayAttribute->columnAliasName],
519  $this->yAxisGroupByDataValues[$displayAttribute->attributeIndexOrDerivedType]))
520  {
521  $this->yAxisGroupByDataValues[$displayAttribute->attributeIndexOrDerivedType][] =
522  $row[$displayAttribute->columnAliasName];
523  }
524  }
525  }
526  }
527  return $this->yAxisGroupByDataValues;
528  }
529 
534  protected function isReportValidType()
535  {
536  if ($this->report->getType() != Report::TYPE_MATRIX)
537  {
538  throw new NotSupportedException();
539  }
540  }
541 
545  protected function getXAxisGroupBys()
546  {
547  $xAxisGroupBys = array();
548  foreach ($this->report->getGroupBys() as $groupBy)
549  {
550  if ($groupBy->axis == 'x')
551  {
552  $xAxisGroupBys[] = $groupBy;
553  }
554  }
555  return $xAxisGroupBys;
556  }
557 
562  {
563  $displayAttributes = array();
564  foreach ($this->resolveDisplayAttributes() as $displayAttribute)
565  {
566  foreach ($this->getXAxisGroupBys() as $xAxisGroupBy)
567  {
568  if ($displayAttribute->attributeIndexOrDerivedType ==
569  $xAxisGroupBy->attributeIndexOrDerivedType)
570  {
571  $displayAttributes[] = $displayAttribute;
572  break;
573  }
574  }
575  }
576  return $displayAttributes;
577  }
578 
582  protected function getYAxisGroupBys()
583  {
584  $yAxisGroupBys = array();
585  foreach ($this->report->getGroupBys() as $groupBy)
586  {
587  if ($groupBy->axis == 'y')
588  {
589  $yAxisGroupBys[] = $groupBy;
590  }
591  }
592  return $yAxisGroupBys;
593  }
594 
599  protected function isDisplayAttributeAnXAxisGroupBy($displayAttribute)
600  {
601  foreach ($this->getXAxisGroupBys() as $groupBy)
602  {
603  if ($displayAttribute->attributeIndexOrDerivedType ==
604  $groupBy->attributeIndexOrDerivedType)
605  {
606  return true;
607  }
608  }
609  return false;
610  }
611 
616  protected function isDisplayAttributeAnYAxisGroupBy($displayAttribute)
617  {
618  foreach ($this->getYAxisGroupBys() as $groupBy)
619  {
620  if ($displayAttribute->attributeIndexOrDerivedType ==
621  $groupBy->attributeIndexOrDerivedType)
622  {
623  return true;
624  }
625  }
626  return false;
627  }
628 
633  protected function addDefaultColumnNamesAndValuesToReportResultsRowData(ReportResultsRowData $reportResultsRowData, $totalCount)
634  {
635  for ($i = 0; $i < $totalCount; $i++)
636  {
637  $columnAliasName = DisplayAttributeForReportForm::COLUMN_ALIAS_PREFIX . $i;
638  $value = 0;
639  $reportResultsRowData->addSelectedColumnNameAndValue($columnAliasName, $value);
640  }
641  }
642 
648  protected function resolveYAxisDisplayAttributesUniqueIndex($rowData, $displayAttributesThatAreYAxisGroupBys)
649  {
650  $uniqueIndex = null;
651  foreach ($displayAttributesThatAreYAxisGroupBys as $displayAttribute)
652  {
653  if ($uniqueIndex != null)
654  {
655  $uniqueIndex .= FormModelUtil::DELIMITER;
656  }
657  $uniqueIndex .= $rowData[$displayAttribute->columnAliasName];
658  }
659  return $uniqueIndex;
660  }
661 
668  {
669  $builder = new GroupBysReportQueryBuilder($joinTablesAdapter);
670  return $builder->makeQueryContent($this->getYAxisGroupBys());
671  }
672 
673  protected function makeGroupBysContentForGrandTotals(RedBeanModelJoinTablesQueryAdapter $joinTablesAdapter)
674  {
675  $builder = new GroupBysReportQueryBuilder($joinTablesAdapter);
676  return $builder->makeQueryContent($this->getXAxisGroupBys());
677  }
678 
679  protected function getGrandTotalsRowsData()
680  {
681  $headerDataRows = $this->getXAxisGroupByDataValues();
682  $headingColumns = array();
683  $this->resolveHeadingColumns($headerDataRows, $headingColumns);
684  $totalRowsData = parent::getGrandTotalsRowsData();
685  if (empty($totalRowsData))
686  {
687  $totalRowsData = array(array());
688  }
689  $adjustedTotalsRowsData = array();
690  $keys = array_reverse(array_keys($totalRowsData[0]));
691  $keysColumnArray = array();
692  $headingsDepth = count($headerDataRows);
693  for ($i = 0; $i < $headingsDepth; $i++)
694  {
695  $keysColumnArray[] = $keys[$i];
696  }
697  $keys = array_reverse($keysColumnArray);
698  foreach ($headingColumns as $column)
699  {
700  $totalRow = null;
701  foreach ($totalRowsData as $key => $totalRowData)
702  {
703  $found = true;
704  $i = 0;
705  foreach ($column as $row)
706  {
707  $found = $found && ($row == $totalRowData[$keys[$i++]]);
708  }
709  if ($found)
710  {
711  $totalRow = $totalRowData;
712  array_slice($totalRowsData, $key);
713  }
714  }
715  if (isset($totalRow))
716  {
717  $adjustedTotalsRowsData[] = $totalRow;
718  }
719  else
720  {
721  $adjustedTotalsRowsData[] = array();
722  }
723  }
724  return $adjustedTotalsRowsData;
725  }
726 
733  private function resolveHeadingColumns($headerDataRows, & $headingColumns, $prefix = array())
734  {
735  if (empty($headerDataRows))
736  {
737  $headingColumns[] = $prefix;
738  }
739  else
740  {
741  $row = array_shift($headerDataRows);
742  $tempPrefix = $prefix;
743  foreach ($row as $groupByValue)
744  {
745  $tempPrefix[] = $groupByValue;
746  $this->resolveHeadingColumns($headerDataRows, $headingColumns, $tempPrefix);
747  $tempPrefix = $prefix;
748  }
749  }
750  }
751 
752  protected function makeSqlQueryForRowTotals()
753  {
754  $selectQueryAdapter = new RedBeanModelSelectQueryAdapter();
755  $moduleClassName = $this->report->getModuleClassName();
756  $modelClassName = $moduleClassName::getPrimaryModelName();
757  $joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter($modelClassName);
758  $builder = new DisplayAttributesReportQueryBuilder($joinTablesAdapter, $selectQueryAdapter,
759  $this->report->getCurrencyConversionType());
760  $builder->makeQueryContent($this->getDisplayAttributesForGrandTotals());
761  $where = $this->makeFiltersContent($joinTablesAdapter);
762  $orderBy = null;
763  $builder = new GroupBysReportQueryBuilder($joinTablesAdapter);
764  $groupBy = $builder->makeQueryContent($this->getYAxisGroupBys());
765  $offset = null;
766  $limit = null;
767  return SQLQueryUtil::makeQuery($modelClassName::getTableName(),
768  $selectQueryAdapter, $joinTablesAdapter, $offset, $limit, $where, $orderBy, $groupBy);
769  }
770  }
771 ?>
makeSqlQueryForFetchingData(RedBeanModelSelectQueryAdapter $selectQueryAdapter, $offset, $limit)
static resolveTotalColumnAliasName($columnAliasName)
isDisplayAttributeAnXAxisGroupBy($displayAttribute)
addSelectedColumnNameAndValue($columnName, $value)
resolveXAxisGroupingsForColumnNames(&$data, $indexedXAxisGroupByDataValues, &$attributeKey, $xAxisGroupBysCount, $startingIndex)
makeAxisCrossingColumnCountAndLeadingHeaderRowsData($forExport=false)
const TYPE_MATRIX
Definition: Report.php:63
static resolveHeaderColumnAliasName($columnAliasName)
getDisplayAttributeByAttribute($attribute)
addDefaultColumnNamesAndValuesToReportResultsRowData(ReportResultsRowData $reportResultsRowData, $totalCount)
isDisplayAttributeAnYAxisGroupBy($displayAttribute)
__construct(Report $report, array $config=array())
resolveYAxisDisplayAttributesUniqueIndex($rowData, $displayAttributesThatAreYAxisGroupBys)
runQueryAndGetResolveResultsData($offset, $limit)
makeGroupBysContentForCount(RedBeanModelJoinTablesQueryAdapter $joinTablesAdapter)
makeSqlQueryForFetchingTotalItemCount($selectQueryAdapter, $selectJustCount=false)
Generated on Fri Jun 5 2020 07:10:34