Hi,
I must modify a module that shows the sum of different fields in a view, but since the view has a pager and a limit of 15 items per page, I get only the sum of the 15 elements of the page, not of all elements in the DB.
This is the function in the .module file:
function _hotel_data_build_seach_summary($view) {
$trec = $tec = $eb = '';
$node = (array) $view->result[0];
foreach (array_keys($node) as $fieldname) {
if (preg_match('/field_hotel_gt_kz_contrib_amount/', $fieldname)) {
$trec = $fieldname;
}
if (preg_match('/field_hotel_gt_total_amount/', $fieldname)) {
$tec = $fieldname;
}
if (preg_match('/field_hotel_eb_total_value/', $fieldname)) {
$eb = $fieldname;
}
}
if (empty($trec) && empty($tec) && empty($eb)) return NULL;
foreach ($view->result as $cn) {
// Total funding
if ($trec && $cn->{$trec}) {
$goal_keep += $cn->{$trec};
}
// Total costs
if ($tec && $cn->{$tec}) {
$goal_swap += $cn->{$tec};
}
//Total helpers
if ( $eb && $cn->{$eb}) {
$helpers += $cn->{$eb};
}
}
if (empty($goal_keep) && empty($goal_swap) && empty($helpers)) return NULL;