forked from extern/django-helpdesk
Display total row in report output.
This commit is contained in:
parent
0774692742
commit
bcec57dafe
@ -96,7 +96,7 @@ Morris.Line({
|
||||
element: 'chart-content',
|
||||
data: {% autoescape on %}{{ morrisjs_data|safe }}{% endautoescape %},
|
||||
xkey: 'x',
|
||||
ykeys: [{% for d in data %}{{ forloop.counter0 }}{% if not forloop.last %}, {% endif %}{% endfor %}],
|
||||
ykeys: [{% for d in data|slice:":-1" %}{{ forloop.counter0 }}{% if not forloop.last %}, {% endif %}{% endfor %}],
|
||||
labels: [{% for n in series_names %}"{{ n }}"{% if not forloop.last %}, {% endif %}{% endfor %}],
|
||||
xLabels: "month"
|
||||
});
|
||||
@ -110,7 +110,7 @@ Morris.Bar({
|
||||
element: 'chart-content',
|
||||
data: {% autoescape on %}{{ morrisjs_data|safe }}{% endautoescape %},
|
||||
xkey: 'x',
|
||||
ykeys: [{% for d in data %}{{ forloop.counter0 }}{% if not forloop.last %}, {% endif %}{% endfor %}],
|
||||
ykeys: [{% for d in data|slice:":-1" %}{{ forloop.counter0 }}{% if not forloop.last %}, {% endif %}{% endfor %}],
|
||||
labels: [{% for n in series_names %}"{{ n }}"{% if not forloop.last %}, {% endif %}{% endfor %}]
|
||||
});
|
||||
|
||||
|
@ -1309,11 +1309,17 @@ def run_report(request, report):
|
||||
|
||||
column_headings = [col1heading] + possible_options
|
||||
|
||||
# Prepare a dict to store totals for each possible option
|
||||
totals = {}
|
||||
# Pivot the data so that 'header1' fields are always first column
|
||||
# in the row, and 'possible_options' are always the 2nd - nth columns.
|
||||
for item in header1:
|
||||
data = []
|
||||
for hdr in possible_options:
|
||||
if hdr not in totals.keys():
|
||||
totals[hdr] = summarytable[item, hdr]
|
||||
else:
|
||||
totals[hdr] += summarytable[item, hdr]
|
||||
data.append(summarytable[item, hdr])
|
||||
table.append([item] + data)
|
||||
|
||||
@ -1332,6 +1338,12 @@ def run_report(request, report):
|
||||
for series in table:
|
||||
series_names.append(series[0])
|
||||
|
||||
# Add total row to table
|
||||
total_data = []
|
||||
for hdr in possible_options:
|
||||
total_data.append(str(totals[hdr]))
|
||||
table.append(['Total'] + total_data)
|
||||
|
||||
return render(request, 'helpdesk/report_output.html', {
|
||||
'title': title,
|
||||
'charttype': charttype,
|
||||
|
Loading…
Reference in New Issue
Block a user