Framework  3.9
FooterTotalColumn Class Reference
+ Inheritance diagram for FooterTotalColumn:
+ Collaboration diagram for FooterTotalColumn:

Public Member Functions

 FooterTotalColumn ($field, $template="", $style="", $colspan=1, $typeHint=Number)
 
 onStartRow ($item)
 
 format ()
 Renderering function for the footer column. More...
 

Public Attributes

 $total = 0
 
 $template = ""
 
 $field = ""
 

Detailed Description

Definition at line 171 of file data_column.inc.

Member Function Documentation

◆ FooterTotalColumn()

FooterTotalColumn::FooterTotalColumn (   $field,
  $template = "",
  $style = "",
  $colspan = 1,
  $typeHint = Number 
)
Parameters
string$field- the field to be totals
string$template- the formatting template
string$style
number$colspan

Definition at line 184 of file data_column.inc.

185  {
186  $this->field = $field;
187  $this->typeHint = $typeHint;
188 
189  /*
190  * If the calling function puts a "$" before the
191  * field name, then mark this as type currency and
192  * output the "$" before the total.
193  */
194  if (!is_callable($this->field) && strpos($this->field, "$", 0) !== FALSE)
195  {
196  $this->typeHint = Currency;
197  $this->field = substr($this->field, 1);
198  }
199 
200  /*
201  * In case the field has template formatting instructions,
202  * move those out to the template variable so that
203  * the field var is just the field and can be totalled
204  * correctly.
205  */
206  $matches = array();
207  if (preg_match("/:(.*?)}/", $this->field, $matches))
208  {
209  $this->template = $matches[1];
210  $this->field = str_replace($matches[1], "", $this->field);
211  }
212 
213  $this->FooterColumn($style, $colspan);
214  }

◆ format()

FooterTotalColumn::format ( )

Renderering function for the footer column.

Returns
string

Reimplemented from FooterColumn.

Definition at line 233 of file data_column.inc.

234  {
235  if(!$this->typeHint || $this->typeHint == Number)
236  {
237  $renderer = new NumberTypeRenderer();
238  }
239  elseif($this->typeHint == Currency)
240  {
241  $renderer = new CurrencyTypeRenderer();
242  $out = "$";
243  }
244 
245  $out .= $renderer->format($this->total, $this->template);
246  return $out;
247  }

◆ onStartRow()

FooterTotalColumn::onStartRow (   $item)

Definition at line 216 of file data_column.inc.

217  {
218  if (is_callable($this->field))
219  {
220  $val = call_user_func($this->field, $item);
221  }
222  else
223  {
224  $val = $item->format($this->field);
225  }
226 
227  // Make the number a raw number value before adding
228  $val = str_replace(",", "", $val);
229 
230  $this->total += $val;
231  }

Member Data Documentation

◆ $field

FooterTotalColumn::$field = ""

Definition at line 175 of file data_column.inc.

◆ $template

FooterTotalColumn::$template = ""

Definition at line 174 of file data_column.inc.

◆ $total

FooterTotalColumn::$total = 0

Definition at line 173 of file data_column.inc.


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