@@ -17,7 +17,7 @@ wn.form.formatters = { | |||||
format_number(value, null, decimals)) + "</div>"; | format_number(value, null, decimals)) + "</div>"; | ||||
}, | }, | ||||
Int: function(value) { | Int: function(value) { | ||||
return value==null ? "": cint(value); | |||||
return value==null ? "": "<div style='text-align: right'>" + cint(value) + "</div>"; | |||||
}, | }, | ||||
Percent: function(value) { | Percent: function(value) { | ||||
return "<div style='text-align: right'>" + flt(value, 2) + "%" + "</div>"; | return "<div style='text-align: right'>" + flt(value, 2) + "%" + "</div>"; | ||||
@@ -136,8 +136,9 @@ wn.views.QueryReport = Class.extend({ | |||||
refresh: function() { | refresh: function() { | ||||
// Run | // Run | ||||
var me =this; | var me =this; | ||||
this.waiting = wn.messages.waiting(this.wrapper.find(".waiting-area").toggle(true), | |||||
this.waiting = wn.messages.waiting(this.wrapper.find(".waiting-area").empty().toggle(true), | |||||
"Loading Report..."); | "Loading Report..."); | ||||
this.wrapper.find(".results").toggle(false); | |||||
var filters = {}; | var filters = {}; | ||||
$.each(this.filters || [], function(i, f) { | $.each(this.filters || [], function(i, f) { | ||||
filters[f.df.fieldname] = f.get_parsed_value(); | filters[f.df.fieldname] = f.get_parsed_value(); | ||||
@@ -95,13 +95,21 @@ def run(report_name, filters=None): | |||||
def add_total_row(result, columns): | def add_total_row(result, columns): | ||||
total_row = [""]*len(columns) | total_row = [""]*len(columns) | ||||
has_percent = [] | |||||
for row in result: | for row in result: | ||||
for i, col in enumerate(columns): | for i, col in enumerate(columns): | ||||
col = col.split(":") | col = col.split(":") | ||||
if len(col) > 1 and col[1] in ["Currency", "Int", "Float"] and flt(row[i]): | |||||
total_row[i] = flt(total_row[i]) + flt(row[i]) | |||||
if len(col) > 1: | |||||
if col[1] in ["Currency", "Int", "Float", "Percent"] and flt(row[i]): | |||||
total_row[i] = flt(total_row[i]) + flt(row[i]) | |||||
if col[1] == "Percent" and i not in has_percent: | |||||
has_percent.append(i) | |||||
for i in has_percent: | |||||
total_row[i] = total_row[i] / len(result) | |||||
first_col = columns[0].split(":") | first_col = columns[0].split(":") | ||||
if len(first_col) > 1 and first_col[1] not in ["Currency", "Int", "Float"]: | |||||
if len(first_col) > 1 and first_col[1] not in ["Currency", "Int", "Float", "Percent"]: | |||||
total_row[0] = "Total" | total_row[0] = "Total" | ||||
result.append(total_row) | result.append(total_row) | ||||