[query report] Formatting & Minor UI Fixes
This commit is contained in:
parent
ea3049995d
commit
af53b85e47
3 changed files with 14 additions and 5 deletions
|
|
@ -17,7 +17,7 @@ wn.form.formatters = {
|
|||
format_number(value, null, decimals)) + "</div>";
|
||||
},
|
||||
Int: function(value) {
|
||||
return value==null ? "": cint(value);
|
||||
return value==null ? "": "<div style='text-align: right'>" + cint(value) + "</div>";
|
||||
},
|
||||
Percent: function(value) {
|
||||
return "<div style='text-align: right'>" + flt(value, 2) + "%" + "</div>";
|
||||
|
|
|
|||
|
|
@ -136,8 +136,9 @@ wn.views.QueryReport = Class.extend({
|
|||
refresh: function() {
|
||||
// Run
|
||||
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...");
|
||||
this.wrapper.find(".results").toggle(false);
|
||||
var filters = {};
|
||||
$.each(this.filters || [], function(i, f) {
|
||||
filters[f.df.fieldname] = f.get_parsed_value();
|
||||
|
|
|
|||
|
|
@ -95,13 +95,21 @@ def run(report_name, filters=None):
|
|||
|
||||
def add_total_row(result, columns):
|
||||
total_row = [""]*len(columns)
|
||||
has_percent = []
|
||||
for row in result:
|
||||
for i, col in enumerate(columns):
|
||||
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(":")
|
||||
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"
|
||||
|
||||
result.append(total_row)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue