'Render the group footer (=group totals)
@param tbody: the TBODY or TABLE to append to
@param group: the group dict
@param level: the grouping level'

def html_render_group_footer(self, tbody, group, level=0):

    columns = self.data.get('c')
    totals = group.get('t')
    if self.group_headers:
        value = self.totals_label
    else:
        v = group.get('v')
        value = ('%s    %s' % (s3_unicode(s3_strip_markup(v)), self.totals_label))
    footer_row = TR(_class=('gi-group-footer    gi-level-%s' % level))
    if (not totals):
        if (not self.group_headers):
            footer_row.append(TD(value, _colspan=len(columns)))
            tbody.append(footer_row)
        return
    if columns:
        label = None
        span = 0
        for column in columns:
            has_value = (column in totals)
            if (label is None):
                if (not has_value):
                    span += 1
                    continue
                else:
                    label = TD(value, _class='gi-group-footer-label', _colspan=span)
                    footer_row.append(label)
            total = (totals[column] if has_value else '')
            footer_row.append(TD(total))
    tbody.append(footer_row)
