CMS  Version 3.9
ReportTable Class Reference

Public Member Functions

 __construct ($class, $title="", $request=null, $outputFilter=false)
 
 __sleep ()
 
 __wakeup ()
 
 load ($request)
 
 getFields ()
 
 column ($title, $format, $sortable=true, $style="", $type=null, $outputFields=null)
 
 excludeKeyFromJoin ($key)
 
 getTitle ()
 
 searchFields ()
 
 favoriteColumns ()
 
 additionalConstraints ($constraint)
 
 getConstraint ($first, $request)
 
 configureForm ($configurator=null)
 
 footerText ($text="", $style="")
 Adds a text column to the table footer. More...
 
 footerValue ($title, $callback, $style="")
 Adds a value column to the table footer. More...
 
 footerTotal ($title, $field, $style="text-align: right")
 Sums the total for a column. More...
 
 createJoin ($mgr)
 
 filterOutput ($mgr, $class)
 
 createColumns ($mgr, $report)
 

Public Attributes

 $class
 
 $proto
 
 $fields
 
 $title
 
 $form
 
 $constraints
 
 $params
 
 $help
 
 $excludedKeys
 
 $columns = array()
 
 $footerColumns = array()
 
 $totalCallbacks = array()
 
 $outputFilter = null
 

Detailed Description

Definition at line 528 of file report_manager.inc.

Constructor & Destructor Documentation

◆ __construct()

ReportTable::__construct (   $class,
  $title = "",
  $request = null,
  $outputFilter = false 
)

Definition at line 544 of file report_manager.inc.

545  {
546  $this->class = $class;
547  $this->proto = new $class;
548 
549  if ($outputFilter)
550  {
551  $this->outputFilter = new InclusionFilter();
552  $this->outputFilter->add($this->proto->getPrimaryKey());
553  }
554 
555  $this->fields = array();
556  $this->title = $title ? $title : $this->proto->prettifyClassName();
557  $this->constraints = $constraints;
558 
559  if ($request) $this->proto->fromDataSet($request);
560 
561  $this->form = new SearchForm($this->proto);
562  $this->form->id = "custom_report";
563  // JDG 2/2012 - set params here to allow additional parameters
564  // to be set by the calling class
565  $this->params = $this->form->params; //new SearchParameters($this->proto);
566 
567  $this->excludedKeys = array();
568  $this->help = "";
569  }
$bookmark title

Member Function Documentation

◆ __sleep()

ReportTable::__sleep ( )

Definition at line 573 of file report_manager.inc.

574  {
575  return array('class', 'fields', 'title', 'constraints', 'params', 'excludedKeys', 'columns', 'footerColumns', 'totalCallbacks');
576  }

◆ __wakeup()

ReportTable::__wakeup ( )

Definition at line 578 of file report_manager.inc.

579  {
580  $this->proto = new $this->class;
581  $this->form = new SearchForm($this->proto);
582  }

◆ additionalConstraints()

ReportTable::additionalConstraints (   $constraint)

Definition at line 650 of file report_manager.inc.

651  {
652  $this->constraints = $constraint;
653 
654  return $this;
655  }
$constraint

◆ column()

ReportTable::column (   $title,
  $format,
  $sortable = true,
  $style = "",
  $type = null,
  $outputFields = null 
)

Definition at line 598 of file report_manager.inc.

599  {
600  $this->columns[] = new ReportColumn($title, $format, $sortable, $style, $type, $outputFields);
601 
602  return $this;
603  }
$notes columns
Definition: edit.inc:66

◆ configureForm()

ReportTable::configureForm (   $configurator = null)

Definition at line 677 of file report_manager.inc.

678  {
679  if ($configurator) $configurator($this->form);
680  }

◆ createColumns()

ReportTable::createColumns (   $mgr,
  $report 
)

Definition at line 757 of file report_manager.inc.

758  {
759  foreach($this->columns as $column)
760  {
761  if ($mgr->isColumnSelected($column))
762  {
763  $report->column($column->title, $column->format, $column->sortable, $column->style, $column->type);
764 
765  if(array_key_exists($column->title, $this->footerColumns))
766  {
767  $footer = $this->footerColumns[$column->title];
768  $report->footerColumns[] = $footer;
769  if(get_class($footer) == FooterTotalColumn)
770  {
771  $report->totalCallbacks[] = array($footer, onStartRow);
772  }
773  }
774  else
775  {
776  $report->footerColumns[] = new FooterTextColumn(" ");
777  }
778  }
779  }
780  }
$table onStartRow
$report
Definition: save_report.inc:38

◆ createJoin()

ReportTable::createJoin (   $mgr)

Definition at line 727 of file report_manager.inc.

728  {
729  $mgr->join->add($this->class);
730  $this->filterOutput($mgr, $this->class);
731 
732  foreach($this->excludedKeys as $excluded)
733  {
734  $mgr->join->excludeKeyFromJoin($this->class, $excluded);
735  }
736  }
filterOutput($mgr, $class)

◆ excludeKeyFromJoin()

ReportTable::excludeKeyFromJoin (   $key)

Definition at line 605 of file report_manager.inc.

606  {
607  $this->excludedKeys[] = $key;
608  return $this;
609  }

◆ favoriteColumns()

ReportTable::favoriteColumns ( )

Definition at line 635 of file report_manager.inc.

636  {
637  $args = func_get_args();
638  $favorites = array_combine($args, $args);
639  foreach($this->columns as $column)
640  {
641  if (array_key_exists($column->title, $favorites))
642  {
643  $column->favorite = true;
644  }
645  }
646 
647  return $this;
648  }

◆ filterOutput()

ReportTable::filterOutput (   $mgr,
  $class 
)

Definition at line 738 of file report_manager.inc.

739  {
740  if ($this->outputFilter)
741  {
742  foreach($this->columns as $column)
743  {
744  if ($mgr->isColumnSelected($column) && is_array($column->outputFields))
745  {
746  foreach($column->outputFields as $field)
747  {
748  $this->outputFilter->add($field);
749  }
750  }
751  }
752 
753  $mgr->join->setFilter($class, $this->outputFilter);
754  }
755  }

◆ footerText()

ReportTable::footerText (   $text = "",
  $style = "" 
)

Adds a text column to the table footer.

Parameters
$titlethe title of the columnn under which the footer value should be displayed
$textthe text to display
$styleany CSS classes or inline styles to apply
Returns
ReportManager returns the current instance, allowing function call chaining for the column definitions.

Definition at line 689 of file report_manager.inc.

690  {
691  $column = new ReportFooterColumn($title, $text, "", $style);
692  $this->footerColumns[$title] = $column;
693 
694  return $column;
695  }

◆ footerTotal()

ReportTable::footerTotal (   $title,
  $field,
  $style = "text-align: right" 
)

Sums the total for a column.

Parameters
$titlethe title of the columnn under which the footer value should be displayed
$fieldthe field to total in the format "{field}"
$styleany CSS classes or inline styles to apply
Returns
DataListView returns the current instance, allowing function call chaining for the column definitions.

Definition at line 719 of file report_manager.inc.

719  : right")
720  {
721  $column = new FooterTotalColumn($field, $template = "", $style);
722  $this->footerColumns[$title] = $column;
723 
724  return $column;
725  }

◆ footerValue()

ReportTable::footerValue (   $title,
  $callback,
  $style = "" 
)

Adds a value column to the table footer.

Parameters
$titlethe title of the columnn under which the footer value should be displayed
$callbackCallback function or object method used to calculate the value for this column.
$styleany CSS classes or inline styles to apply
Returns
ReportManager returns the current instance, allowing function call chaining for the column definitions.

Definition at line 704 of file report_manager.inc.

705  {
706  $column = new FooterValueColumn($callback, $style);
707  $this->footerColumns[$title] = $column;
708 
709  return $column;
710  }

◆ getConstraint()

ReportTable::getConstraint (   $first,
  $request 
)

Definition at line 657 of file report_manager.inc.

658  {
659  $this->params->fromArray($request);
660  $constraint = $this->params->generateConstraint($first);
661 
662  if ($this->constraints)
663  {
664  if ($constraint)
665  {
666  $constraint .= " AND $constraint";
667  }
668  else
669  {
670  $constraint .= ($first ? "WHERE " : " AND ").$this->constraints;
671  }
672  }
673 
674  return $constraint;
675  }

◆ getFields()

ReportTable::getFields ( )

Definition at line 594 of file report_manager.inc.

594 { return $this->fields; }

◆ getTitle()

ReportTable::getTitle ( )

Definition at line 611 of file report_manager.inc.

612  {
613  return $this->title;
614  }

◆ load()

ReportTable::load (   $request)

Definition at line 584 of file report_manager.inc.

585  {
586  if ($request)
587  {
588  $this->proto->fromDataSet($request);
589  $this->params->fromArray($request);
590  $this->form->params->fromArray($request);
591  }
592  }

◆ searchFields()

ReportTable::searchFields ( )

Definition at line 616 of file report_manager.inc.

617  {
618  $filter = new InclusionFilter();
619  for($i = 0; $i < func_num_args(); ++$i)
620  {
621  // JDG 2/2012 - putting func_get_arg inside the explode crashes for me if not
622  $fieldMode = func_get_arg($i);
623  list($field, $searchMode) = explode(":", $fieldMode);
624  $filter->add($field);
625  if ($searchMode)
626  {
627  $this->form->setMatchingMode($searchMode, $field);
628  }
629  }
630 
631  $this->proto->filter = $filter;
632  return $this;
633  }
$filter
Definition: update.inc:44

Member Data Documentation

◆ $class

ReportTable::$class

Definition at line 530 of file report_manager.inc.

◆ $columns

ReportTable::$columns = array()

Definition at line 539 of file report_manager.inc.

◆ $constraints

ReportTable::$constraints

Definition at line 535 of file report_manager.inc.

◆ $excludedKeys

ReportTable::$excludedKeys

Definition at line 538 of file report_manager.inc.

◆ $fields

ReportTable::$fields

Definition at line 532 of file report_manager.inc.

◆ $footerColumns

ReportTable::$footerColumns = array()

Definition at line 540 of file report_manager.inc.

◆ $form

ReportTable::$form

Definition at line 534 of file report_manager.inc.

◆ $help

ReportTable::$help

Definition at line 537 of file report_manager.inc.

◆ $outputFilter

ReportTable::$outputFilter = null

Definition at line 542 of file report_manager.inc.

◆ $params

ReportTable::$params

Definition at line 536 of file report_manager.inc.

◆ $proto

ReportTable::$proto

Definition at line 531 of file report_manager.inc.

◆ $title

ReportTable::$title

Definition at line 533 of file report_manager.inc.

◆ $totalCallbacks

ReportTable::$totalCallbacks = array()

Definition at line 541 of file report_manager.inc.


The documentation for this class was generated from the following file: