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',
|
element: 'chart-content',
|
||||||
data: {% autoescape on %}{{ morrisjs_data|safe }}{% endautoescape %},
|
data: {% autoescape on %}{{ morrisjs_data|safe }}{% endautoescape %},
|
||||||
xkey: 'x',
|
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 %}],
|
labels: [{% for n in series_names %}"{{ n }}"{% if not forloop.last %}, {% endif %}{% endfor %}],
|
||||||
xLabels: "month"
|
xLabels: "month"
|
||||||
});
|
});
|
||||||
@ -110,7 +110,7 @@ Morris.Bar({
|
|||||||
element: 'chart-content',
|
element: 'chart-content',
|
||||||
data: {% autoescape on %}{{ morrisjs_data|safe }}{% endautoescape %},
|
data: {% autoescape on %}{{ morrisjs_data|safe }}{% endautoescape %},
|
||||||
xkey: 'x',
|
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 %}]
|
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
|
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
|
# Pivot the data so that 'header1' fields are always first column
|
||||||
# in the row, and 'possible_options' are always the 2nd - nth columns.
|
# in the row, and 'possible_options' are always the 2nd - nth columns.
|
||||||
for item in header1:
|
for item in header1:
|
||||||
data = []
|
data = []
|
||||||
for hdr in possible_options:
|
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])
|
data.append(summarytable[item, hdr])
|
||||||
table.append([item] + data)
|
table.append([item] + data)
|
||||||
|
|
||||||
@ -1332,6 +1338,12 @@ def run_report(request, report):
|
|||||||
for series in table:
|
for series in table:
|
||||||
series_names.append(series[0])
|
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', {
|
return render(request, 'helpdesk/report_output.html', {
|
||||||
'title': title,
|
'title': title,
|
||||||
'charttype': charttype,
|
'charttype': charttype,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user