You are here

function views_aggregator_sum in Views Aggregator Plus 7

Same name and namespace in other branches
  1. 8 views_aggregator_functions.inc \views_aggregator_sum()

Aggregates a field group as the sum of its members.

Parameters

array $groups: An array of groups of rows, each group indexed by group value.

object $field_handler: The handler for the view column to sum groups in.

Return value

array An array of values, one for each group, plus the 'column' group.

1 string reference to 'views_aggregator_sum'
views_aggregator_plugin_style_table::options_form in views/views_aggregator_plugin_style_table.inc
Create the tabular form with the aggregation options.

File

./views_aggregator_functions.inc, line 638
views_aggregator_functions.inc

Code

function views_aggregator_sum($groups, $field_handler) {
  $values = array();
  $sum_column = 0.0;
  foreach ($groups as $group => $rows) {
    $sum = 0.0;
    foreach ($rows as $num => $row) {
      $cell = vap_num(views_aggregator_get_cell($field_handler, $num, FALSE));
      if ($cell !== FALSE) {
        $sum += $cell;
      }
    }
    $values[$group] = $sum;
    $sum_column += $sum;
  }
  $values['column'] = $sum_column;
  return $values;
}