moved chart_of_accounts as GridReport
diff --git a/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.js b/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.js
index 0e8e298..2fb6d9b 100644
--- a/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.js
+++ b/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.js
@@ -27,343 +27,246 @@
title: 'Chart of Accounts',
single_column: true
});
-
- erpnext.coa.make_page(wrapper);
- erpnext.coa.load_companies();
-}
-erpnext.coa = {
- make_page: function(wrapper) {
- erpnext.coa.company_select = wrapper.appframe
- .add_select("Company", ["Loading..."])
- .change(function() {
- erpnext.coa.chart = new erpnext.ChartOfAccounts();
+
+ erpnext.coa = new wn.views.GridReport({
+ title: "Chart of Accounts",
+ parent: $(wrapper).find('.layout-main'),
+ appframe: wrapper.appframe,
+ doctypes: ["Company", "Fiscal Year", "Account", "GL Entry"],
+ setup: function() {
+ this.setup_filters();
+ this.setup_columns();
+ },
+ setup_columns: function() {
+ this.columns = [
+ {id: "name", name: "Account", field: "name", width: 300, cssClass: "cell-title",
+ formatter: this.account_formatter},
+ {id: "opening_debit", name: "Opening (Dr)", field: "opening_debit", width: 100,
+ formatter: this.currency_formatter},
+ {id: "opening_credit", name: "Opening (Cr)", field: "opening_credit", width: 100,
+ formatter: this.currency_formatter},
+ {id: "debit", name: "Debit", field: "debit", width: 100,
+ formatter: this.currency_formatter},
+ {id: "credit", name: "Credit", field: "credit", width: 100,
+ formatter: this.currency_formatter},
+ {id: "closing_debit", name: "Closing (Dr)", field: "closing_debit", width: 100,
+ formatter: this.currency_formatter},
+ {id: "closing_credit", name: "Closing (Cr)", field: "closing_credit", width: 100,
+ formatter: this.currency_formatter}
+ ];
+
+ },
+ filters: [
+ {fieldtype:"Select", label: "Company", options:"Company", default_value: "Select Company...",
+ filter: function(val, item, opts) {
+ return item.company == val || val == opts.default_value || item._show;
+ }},
+ {fieldtype:"Select", label: "Fiscal Year", options:"Fiscal Year",
+ default_value: "Select Fiscal Year..."},
+ {fieldtype:"Date", label: "From Date"},
+ {fieldtype:"Label", label: "To"},
+ {fieldtype:"Date", label: "To Date"},
+ {fieldtype:"Button", label: "Refresh", icon:"icon-refresh icon-white", cssClass:"btn-info"},
+ {fieldtype:"Button", label: "Reset Filters"}
+ ],
+ setup_filters: function() {
+ var me = this;
+ // default filters
+ this.init_filter_values();
+ this.filter_inputs.refresh.click(function() { me.set_route(); })
+ this.filter_inputs.reset_filters.click(function() { me.init_filter_values(); me.set_route(); });
+ this.filter_inputs.fiscal_year.change(function() {
+ var fy = $(this).val();
+ $.each(wn.report_dump.data["Fiscal Year"], function(i, v) {
+ if (v.name==fy) {
+ me.filter_inputs.from_date.val(dateutil.str_to_user(v.year_start_date));
+ me.filter_inputs.to_date.val(dateutil.str_to_user(v.year_end_date));
+ }
+ });
+ me.set_route();
});
-
- erpnext.coa.fiscal_year_select = wrapper.appframe
- .add_select("Fiscal Year", ["Loading..."]).css("width", "100px")
- .change(function() {
- var selected_year = $(this).val();
- var fiscal_year = $.map(erpnext.coa.fiscal_years, function(v) {
- return v[0] === selected_year ? v : null;
- });
- erpnext.coa.opening_date.val(dateutil.str_to_user(fiscal_year[1]));
- erpnext.coa.closing_date.val(dateutil.str_to_user(fiscal_year[2]));
- erpnext.coa.refresh_btn.click();
- })
-
- erpnext.coa.opening_date = wrapper.appframe.add_date("Opening Date")
- .val(dateutil.str_to_user(sys_defaults.year_start_date));
-
- var end_date = new Date();
- if(end_date > dateutil.str_to_obj(sys_defaults.year_end_date))
- end_date = sys_defaults.year_end_date;
-
- erpnext.coa.closing_date = wrapper.appframe.add_date("Closing Date")
- .val(dateutil.obj_to_user(end_date));
-
- erpnext.coa.refresh_btn = wrapper.appframe.add_button("Refresh", function() {
- erpnext.coa.chart.refresh();
- }, "icon-refresh");
-
-
-
- erpnext.coa.waiting = $('<div class="well" style="width: 63%; margin: 30px auto;">\
- <p style="text-align: center;">Building Trial Balance Report. \
- Please wait for a few moments</p>\
- <div class="progress progress-striped active">\
- <div class="bar" style="width: 100%"></div></div>')
- .appendTo($(wrapper).find('.layout-main'));
-
- $('<div id="chart-of-accounts" style="height: 500px; border: 1px solid #aaa;">\
- </div>').appendTo($(wrapper).find('.layout-main'));
-
- },
- load_companies: function() {
- wn.call({
- module: "accounts",
- page: "chart_of_accounts",
- method: "get_companies",
- callback: function(r) {
- erpnext.coa.waiting.toggle();
- erpnext.coa.company_select.empty().add_options(r.message.companies)
- .val(sys_defaults.company || r.message.companies[0]).change();
- erpnext.coa.fiscal_year_select.empty()
- .add_options($.map(r.message.fiscal_years, function(v) { return v[0]; }))
- .val(sys_defaults.fiscal_year);
- erpnext.coa.fiscal_years = r.message.fiscal_years;
- }
- });
- }
-};
-
-erpnext.ChartOfAccounts = Class.extend({
- init: function() {
- this.load_slickgrid();
- this.load_data($(erpnext.coa.company_select).val());
- },
- load_slickgrid: function() {
- // load tree
- wn.require('js/lib/slickgrid/slick.grid.css');
- wn.require('js/lib/slickgrid/slick-default-theme.css');
- wn.require('js/lib/slickgrid/jquery.event.drag.min.js');
- wn.require('js/lib/slickgrid/slick.core.js');
- wn.require('js/lib/slickgrid/slick.grid.js');
- wn.require('js/lib/slickgrid/slick.dataview.js');
- wn.dom.set_style('.slick-cell { font-size: 12px; }');
- },
- refresh: function() {
- this.prepare_balances();
- this.render();
- },
- render: function() {
- var me = this;
- erpnext.coa.waiting.toggle(false);
- this.setup_dataview();
-
- var columns = [
- {id: "name", name: "Account", field: "name", width: 300, cssClass: "cell-title",
- formatter: this.account_formatter},
- {id: "opening_debit", name: "Opening (Dr)", field: "opening_debit", width: 100},
- {id: "opening_credit", name: "Opening (Cr)", field: "opening_credit", width: 100},
- {id: "debit", name: "Debit", field: "debit", width: 100},
- {id: "credit", name: "Credit", field: "credit", width: 100},
- {id: "closing_debit", name: "Closing (Dr)", field: "closing_debit", width: 100},
- {id: "closing_credit", name: "Closing (Cr)", field: "closing_credit", width: 100}
- ];
-
- var options = {
- editable: false,
- enableColumnReorder: false
- };
-
- // initialize the grid
- var grid = new Slick.Grid("#chart-of-accounts", this.dataView, columns, options);
- this.add_events(grid);
- this.grid = grid;
- },
- load_data: function(company) {
- var me = this;
- wn.call({
- module: "accounts",
- page: "chart_of_accounts",
- method: "get_chart",
- args: {company: company},
- callback: function(r) {
- me.gl = r.message.gl;
- me.prepare_chart(r.message.chart);
- $.each(me.gl, function(i, v) {
- v[1] = me.accounts[v[1]].name;
- });
- me.refresh();
- }
- })
- },
- prepare_chart: function(indata) {
- var data = [];
- var parent_map = {};
- var data_by_name = {};
- $.each(indata, function(i, v) {
- if(v[0]) {
- var d = {
- "id": v[0],
- "name": v[0],
- "parent": v[1],
- "debit_or_credit": v[2],
+ },
+ init_filter_values: function() {
+ this.filter_inputs.company.val(sys_defaults.company);
+ this.filter_inputs.fiscal_year.val(sys_defaults.fiscal_year);
+ this.filter_inputs.from_date.val(dateutil.str_to_user(sys_defaults.year_start_date));
+ this.filter_inputs.to_date.val(dateutil.str_to_user(sys_defaults.year_end_date));
+ },
+ prepare_data: function() {
+ var data = [];
+ var parent_map = {};
+ var data_by_name = {};
+ $.each(wn.report_dump.data["Account"], function(i, v) {
+ var d = $.extend(copy_dict(v), {
"opening_debit": 0,
"opening_credit": 0,
"debit": 0,
"credit": 0,
"closing_debit": 0,
- "closing_credit": 0,
- "is_pl": v[3]
- };
-
+ "closing_credit": 0
+ });
+
data.push(d);
data_by_name[d.name] = d;
- if(d.parent) {
- parent_map[d.name] = d.parent;
+ if(d.parent_account) {
+ parent_map[d.name] = d.parent_account;
}
- }
- });
- this.set_indent(data, parent_map);
- this.accounts = data;
- this.parent_map = parent_map;
- this.accounts_by_name = data_by_name;
- },
- prepare_balances: function() {
- var gl = this.gl;
- var me = this;
-
- this.opening_date = dateutil.user_to_obj(erpnext.coa.opening_date.val());
- this.closing_date = dateutil.user_to_obj(erpnext.coa.closing_date.val());
- this.set_fiscal_year();
- if (!this.fiscal_year) return;
-
- $.each(this.accounts, function(i, v) {
- v.opening_debit = v.opening_credit = v.debit
- = v.credit = v.closing_debit = v.closing_credit = 0;
- });
-
- $.each(gl, function(i, v) {
- var posting_date = dateutil.str_to_obj(v[0]);
- var account = me.accounts_by_name[v[1]];
- me.update_balances(account, posting_date, v)
- });
-
- this.update_groups();
- this.format_balances();
- },
- update_balances: function(account, posting_date, v) {
- // opening
- if (posting_date < this.opening_date || v[4] === "Y") {
- if (account.is_pl === "Yes" && posting_date <= dateutil.str_to_obj(this.fiscal_year[1])) {
- // balance of previous fiscal_year should
- // not be part of opening of pl account balance
- } else {
- if(account.debit_or_credit=='D') {
- account.opening_debit += (v[2] - v[3]);
+ });
+ this.set_indent(data, parent_map);
+ this.accounts = data;
+ this.parent_map = parent_map;
+ this.accounts_by_name = data_by_name;
+ this.prepare_balances();
+ this.prepare_data_view(this.accounts);
+ },
+ prepare_balances: function() {
+ var gl = wn.report_dump.data['GL Entry'];
+ var me = this;
+
+ this.opening_date = dateutil.user_to_obj(this.filter_inputs.from_date.val());
+ this.closing_date = dateutil.user_to_obj(this.filter_inputs.to_date.val());
+ this.set_fiscal_year();
+ if (!this.fiscal_year) return;
+
+ $.each(this.accounts, function(i, v) {
+ v.opening_debit = v.opening_credit = v.debit
+ = v.credit = v.closing_debit = v.closing_credit = 0;
+ });
+
+ $.each(gl, function(i, v) {
+ var posting_date = dateutil.str_to_obj(v.posting_date);
+ var account = me.accounts_by_name[v.account];
+ me.update_balances(account, posting_date, v)
+ });
+
+ this.update_groups();
+ },
+ update_balances: function(account, posting_date, v) {
+ // opening
+ if (posting_date < this.opening_date || v.is_opening === "Yes") {
+ if (account.is_pl_account === "Yes" &&
+ posting_date <= dateutil.str_to_obj(this.fiscal_year[1])) {
+ // balance of previous fiscal_year should
+ // not be part of opening of pl account balance
} else {
- account.opening_credit += (v[3] - v[2]);
- }
- }
- } else if (this.opening_date <= posting_date && posting_date <= this.closing_date) {
- // in between
- account.debit += v[2];
- account.credit += v[3];
- }
- // closing
- if(account.debit_or_credit=='D') {
- account.closing_debit = account.opening_debit + account.debit - account.credit;
- } else {
- account.closing_credit = account.opening_credit - account.debit + account.credit;
- }
- },
- update_groups: function() {
- // update groups
- var me= this;
- $.each(this.accounts, function(i, account) {
- // update groups
- var parent = me.parent_map[account.name];
- while(parent) {
- parent_account = me.accounts_by_name[parent];
- parent_account.opening_debit += account.opening_debit;
- parent_account.opening_credit += account.opening_credit;
- parent_account.debit += account.debit;
- parent_account.credit += account.credit;
- parent_account.closing_debit += account.closing_debit;
- parent_account.closing_credit += account.closing_credit;
- parent = me.parent_map[parent];
- }
- });
- },
- format_balances: function() {
- // format amount
- $.each(this.accounts, function(i, v) {
- v.opening_debit = fmt_money(v.opening_debit);
- v.opening_credit = fmt_money(v.opening_credit);
- v.debit = fmt_money(v.debit);
- v.credit = fmt_money(v.credit);
- v.closing_debit = fmt_money(v.closing_debit);
- v.closing_credit = fmt_money(v.closing_credit);
- });
- },
- set_fiscal_year: function() {
- if (this.opening_date > this.closing_date) {
- msgprint("Opening Date should be before Closing Date");
- return;
- }
-
- this.fiscal_year = null;
- var me = this;
- $.each(erpnext.coa.fiscal_years, function(i, v) {
- if (me.opening_date >= dateutil.str_to_obj(v[1]) &&
- me.closing_date <= dateutil.str_to_obj(v[2])) {
- me.fiscal_year = v;
- }
- });
-
- if (!this.fiscal_year) {
- msgprint("Opening Date and Closing Date should be within same Fiscal Year");
- return;
- }
- },
- set_indent: function(data, parent_map) {
- $.each(data, function(i, d) {
- var indent = 0;
- var parent = parent_map[d.name];
- if(parent) {
- while(parent) {
- indent++;
- parent = parent_map[parent];
- }
- }
- d.indent = indent;
- });
- },
- setup_dataview: function() {
- var me = this;
- // initialize the model
- this.dataView = new Slick.Data.DataView({ inlineFilters: true });
- this.dataView.beginUpdate();
- this.dataView.setItems(this.accounts);
- this.dataView.setFilter(this.dataview_filter);
- this.dataView.endUpdate();
- },
- dataview_filter: function(item) {
- if (item.parent) {
- var parent = item.parent;
- while (parent) {
- if (erpnext.coa.chart.accounts_by_name[parent]._collapsed) {
- return false;
- }
- parent = erpnext.coa.chart.parent_map[parent];
- }
- }
- return true;
- },
- add_events: function(grid) {
- var me = this;
- grid.onClick.subscribe(function (e, args) {
- if ($(e.target).hasClass("toggle")) {
- var item = me.dataView.getItem(args.row);
- if (item) {
- if (!item._collapsed) {
- item._collapsed = true;
+ if(account.debit_or_credit=='Debit') {
+ account.opening_debit += (v.debit - v.credit);
} else {
- item._collapsed = false;
+ account.opening_credit += (v.credit - v.debit);
}
-
- me.dataView.updateItem(item.id, item);
}
- e.stopImmediatePropagation();
+ } else if (this.opening_date <= posting_date && posting_date <= this.closing_date) {
+ // in between
+ account.debit += v.debit;
+ account.credit += v.credit;
}
- });
-
- this.dataView.onRowsChanged.subscribe(function (e, args) {
- grid.invalidateRows(args.rows);
- grid.render();
- });
-
- this.dataView.onRowCountChanged.subscribe(function (e, args) {
- grid.updateRowCount();
- grid.render();
- });
-
- },
- account_formatter: function (row, cell, value, columnDef, dataContext) {
- value = value.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");
- var data = erpnext.coa.chart.accounts;
- var spacer = "<span style='display:inline-block;height:1px;width:" +
- (15 * dataContext["indent"]) + "px'></span>";
- var idx = erpnext.coa.chart.dataView.getIdxById(dataContext.id);
- if (data[idx + 1] && data[idx + 1].indent > data[idx].indent) {
- if (dataContext._collapsed) {
- return spacer + " <span class='toggle expand'></span> " + value;
+ // closing
+ if(account.debit_or_credit=='Debit') {
+ account.closing_debit = account.opening_debit + account.debit - account.credit;
} else {
- return spacer + " <span class='toggle collapse'></span> " + value;
+ account.closing_credit = account.opening_credit - account.debit + account.credit;
}
- } else {
- return spacer + " <span class='toggle'></span> " + value;
- }
- }
+ },
+ update_groups: function() {
+ // update groups
+ var me= this;
+ $.each(this.accounts, function(i, account) {
+ // update groups
+ var parent = me.parent_map[account.name];
+ while(parent) {
+ parent_account = me.accounts_by_name[parent];
+ parent_account.opening_debit += account.opening_debit;
+ parent_account.opening_credit += account.opening_credit;
+ parent_account.debit += account.debit;
+ parent_account.credit += account.credit;
+ parent_account.closing_debit += account.closing_debit;
+ parent_account.closing_credit += account.closing_credit;
+ parent = me.parent_map[parent];
+ }
+ });
+ },
+
+ set_fiscal_year: function() {
+ if (this.opening_date > this.closing_date) {
+ msgprint("Opening Date should be before Closing Date");
+ return;
+ }
+
+ this.fiscal_year = null;
+ var me = this;
+ $.each(wn.report_dump.data["Fiscal Year"], function(i, v) {
+ if (me.opening_date >= dateutil.str_to_obj(v.year_start_date) &&
+ me.closing_date <= dateutil.str_to_obj(v.year_end_date)) {
+ me.fiscal_year = v;
+ }
+ });
+
+ if (!this.fiscal_year) {
+ msgprint("Opening Date and Closing Date should be within same Fiscal Year");
+ return;
+ }
+ },
+ set_indent: function(data, parent_map) {
+ $.each(data, function(i, d) {
+ var indent = 0;
+ var parent = parent_map[d.name];
+ if(parent) {
+ while(parent) {
+ indent++;
+ parent = parent_map[parent];
+ }
+ }
+ d.indent = indent;
+ });
+ },
+ account_formatter: function (row, cell, value, columnDef, dataContext) {
+ value = value.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");
+ var data = erpnext.coa.accounts;
+ var spacer = "<span style='display:inline-block;height:1px;width:" +
+ (15 * dataContext["indent"]) + "px'></span>";
+ var idx = erpnext.coa.dataView.getIdxById(dataContext.id);
+ if (data[idx + 1] && data[idx + 1].indent > data[idx].indent) {
+ if (dataContext._collapsed) {
+ return spacer + " <span class='toggle expand'></span> " + value;
+ } else {
+ return spacer + " <span class='toggle collapse'></span> " + value;
+ }
+ } else {
+ return spacer + " <span class='toggle'></span> " + value;
+ }
+ },
+ add_grid_events: function() {
+ var me = this;
+ this.grid.onClick.subscribe(function (e, args) {
+ if ($(e.target).hasClass("toggle")) {
+ var item = me.dataView.getItem(args.row);
+ if (item) {
+ if (!item._collapsed) {
+ item._collapsed = true;
+ } else {
+ item._collapsed = false;
+ }
+
+ me.dataView.updateItem(item.id, item);
+ }
+ e.stopImmediatePropagation();
+ }
+ });
+ },
+ custom_dataview_filter: function(item) {
+ if (item.parent_account) {
+ var parent = item.parent_account;
+ while (parent) {
+ if (erpnext.coa.accounts_by_name[parent]._collapsed) {
+ return false;
+ }
+ parent = erpnext.coa.parent_map[parent];
+ }
+ }
+ return true;
+ }
+ });
+}
+
+erpnext.ChartOfAccounts = Class.extend({
});
diff --git a/erpnext/startup/report_data_map.py b/erpnext/startup/report_data_map.py
index 1811aaa..f453938 100644
--- a/erpnext/startup/report_data_map.py
+++ b/erpnext/startup/report_data_map.py
@@ -32,6 +32,6 @@
},
"Fiscal Year": {
"columns": ["name", "year_start_date",
- "adddate(year_start_date, interval 1 year) as year_end_date"]
+ "adddate(adddate(year_start_date, interval 1 year), interval -1 day) as year_end_date"]
}
}
diff --git a/public/js/all-app.js b/public/js/all-app.js
index 89162c6..f32e26e 100644
--- a/public/js/all-app.js
+++ b/public/js/all-app.js
@@ -847,13 +847,13 @@
<span class="appframe-title"></span>\
<span class="close">×</span>\
</div>').appendTo(this.$w);this.$w.find('.close').click(function(){window.history.back();})
-if(title)this.title(title);},title:function(txt){this.clear_breadcrumbs();this.add_breadcrumb(txt);},add_button:function(label,click,icon){this.make_toolbar();args={label:label,icon:''};if(icon){args.icon='<i class="icon '+icon+'"></i>';}
+if(title)this.title(title);},title:function(txt){this.clear_breadcrumbs();this.add_breadcrumb(txt);},add_button:function(label,click,icon){this.add_toolbar();args={label:label,icon:''};if(icon){args.icon='<i class="icon '+icon+'"></i>';}
this.buttons[label]=$(repl('<button class="btn btn-small">\
- %(icon)s %(label)s</button>',args)).click(click).appendTo(this.toolbar);return this.buttons[label];},add_help_button:function(txt){this.make_toolbar();$('<button class="btn btn-small" style="float:right;" button-type="help">\
+ %(icon)s %(label)s</button>',args)).click(click).appendTo(this.toolbar);return this.buttons[label];},add_help_button:function(txt){this.add_toolbar();$('<button class="btn btn-small" style="float:right;" button-type="help">\
<b>?</b></button>').data('help-text',txt).click(function(){msgprint($(this).data('help-text'),'Help');}).appendTo(this.toolbar);},clear_buttons:function(){this.toolbar&&this.toolbar.empty();},add_breadcrumb:function(html){if(!this.$breadcrumbs)
this.$breadcrumbs=$('</span>\
<span class="breadcrumb-area"></span>').appendTo(this.$titlebar);var crumb=$('<span>').html(html);if(!this.$breadcrumbs.find('span').length){crumb.addClass('appframe-title');}
-crumb.appendTo(this.$breadcrumbs);},clear_breadcrumbs:function(){this.$breadcrumbs&&this.$breadcrumbs.empty();},make_toolbar:function(){if(!this.toolbar)
+crumb.appendTo(this.$breadcrumbs);},clear_breadcrumbs:function(){this.$breadcrumbs&&this.$breadcrumbs.empty();},add_toolbar:function(){if(!this.toolbar)
this.$w.append('<div class="appframe-toolbar"></div>');this.toolbar=this.$w.find('.appframe-toolbar');},add_label:function(label){return $("<span class='label'>"+label+" </span>").appendTo(this.toolbar);},add_select:function(label,options){this.add_toolbar();return $("<select style='width: 160px;'>").add_options(options).appendTo(this.toolbar);},add_data:function(label){this.add_toolbar();return $("<input style='width: 100px;' placeholder='"+label+"'>").appendTo(this.toolbar);},add_date:function(label,date){this.add_toolbar();return $("<input style='width: 80px;'>").datepicker({dateFormat:sys_defaults.date_format.replace("yyyy","yy"),changeYear:true,}).val(dateutil.str_to_user(date)||"").appendTo(this.toolbar);},});wn.ui.make_app_page=function(opts){if(opts.single_column){$(opts.parent).html('<div class="layout-wrapper layout-wrapper-appframe">\
<div class="layout-appframe"></div>\
<div class="layout-main"></div>\
@@ -1086,10 +1086,11 @@
input.keypress(function(e){if(e.which==13){me.refresh();}})}
me.filter_inputs[v.fieldname]=input;});},import_slickgrid:function(){wn.require('js/lib/slickgrid/slick.grid.css');wn.require('js/lib/slickgrid/slick-default-theme.css');wn.require('js/lib/slickgrid/jquery.event.drag.min.js');wn.require('js/lib/slickgrid/slick.core.js');wn.require('js/lib/slickgrid/slick.grid.js');wn.require('js/lib/slickgrid/slick.dataview.js');wn.dom.set_style('.slick-cell { font-size: 12px; }');},refresh:function(){this.render();},apply_filters_from_route:function(){var hash=window.location.hash;var me=this;if(hash.indexOf('/')!=-1){$.each(hash.split('/').splice(1).join('/').split('&'),function(i,f){var f=f.split("=");me.filter_inputs[f[0]].val(decodeURIComponent(f[1]));});}},set_route:function(){wn.set_route(wn.container.page.page_name,$.map(this.filter_inputs,function(v){var val=v.val();var opts=v.get(0).opts;if(val&&val!=opts.default_value)
return encodeURIComponent(opts.fieldname)
-+'='+encodeURIComponent(val);}).join('&'))},render:function(){this.waiting.toggle(false);if(!this.grid_wrapper)this.make_grid_wrapper();this.apply_link_formatters();this.prepare_data();this.grid=new Slick.Grid("#"+this.id,this.dataView,this.columns,this.options);this.dataView.onRowsChanged.subscribe(function(e,args){grid.invalidateRows(args.rows);grid.render();});this.dataView.onRowCountChanged.subscribe(function(e,args){grid.updateRowCount();grid.render();});},prepare_data_view:function(items){this.dataView=new Slick.Data.DataView({inlineFilters:true});this.dataView.beginUpdate();this.dataView.setItems(items);this.dataView.setFilter(this.dataview_filter);this.dataView.endUpdate();},export:function(){var me=this;var res=[$.map(this.columns,function(v){return v.name;})];var col_map=$.map(this.columns,function(v){return v.field;});for(var i=0,len=this.dataView.getLength();i<len;i++){var d=this.dataView.getItem(i);var row=[];$.each(col_map,function(i,col){var val=d[col];if(val===null||val===undefined){val=""}
++'='+encodeURIComponent(val);}).join('&'))},render:function(){this.waiting.toggle(false);if(!this.grid_wrapper)this.make_grid_wrapper();this.apply_link_formatters();this.prepare_data();this.grid=new Slick.Grid("#"+this.id,this.dataView,this.columns,this.options);var me=this;this.dataView.onRowsChanged.subscribe(function(e,args){me.grid.invalidateRows(args.rows);me.grid.render();});this.dataView.onRowCountChanged.subscribe(function(e,args){me.grid.updateRowCount();me.grid.render();});this.add_grid_events&&this.add_grid_events();},prepare_data_view:function(items){this.dataView=new Slick.Data.DataView({inlineFilters:true});this.dataView.beginUpdate();this.dataView.setItems(items);this.dataView.setFilter(this.dataview_filter);this.dataView.endUpdate();},export:function(){var me=this;var res=[$.map(this.columns,function(v){return v.name;})];var col_map=$.map(this.columns,function(v){return v.field;});for(var i=0,len=this.dataView.getLength();i<len;i++){var d=this.dataView.getItem(i);var row=[];$.each(col_map,function(i,col){var val=d[col];if(val===null||val===undefined){val=""}
row.push(val);})
res.push(row);}
wn.require("js/lib/downloadify/downloadify.min.js");wn.require("js/lib/downloadify/swfobject.js");var id=wn.dom.set_unique_id();var msgobj=msgprint('<p id="'+id+'">You must have Flash 10 installed to download this file.</p>');Downloadify.create(id,{filename:function(){return me.title+'.csv';},data:function(){return wn.to_csv(res);},swf:'js/lib/downloadify/downloadify.swf',downloadImage:'js/lib/downloadify/download.png',onComplete:function(){msgobj.hide();},onCancel:function(){msgobj.hide();},onError:function(){msgobj.hide();},width:100,height:30,transparent:true,append:false});return false;},options:{editable:false,enableColumnReorder:false},dataview_filter:function(item){var filters=wn.cur_grid_report.filter_inputs;for(i in filters){var filter=filters[i].get(0);if(filter.opts.filter&&!filter.opts.filter($(filter).val(),item,filter.opts)){return false;}}
+if(wn.cur_grid_report.custom_dataview_filter){return wn.cur_grid_report.custom_dataview_filter(item);}
return true;},date_formatter:function(row,cell,value,columnDef,dataContext){return dateutil.str_to_user(value);},currency_formatter:function(row,cell,value,columnDef,dataContext){return repl('<div style="text-align: right; %(_style)s">%(value)s</div>',{_style:dataContext._style||"",value:fmt_money(value)});},text_formatter:function(row,cell,value,columnDef,dataContext){return repl('<span style="%(_style)s" title="%(esc_value)s">%(value)s</span>',{_style:dataContext._style||"",esc_value:cstr(value).replace(/"/g,'\"'),value:cstr(value)});},apply_link_formatters:function(){var me=this;$.each(this.columns,function(i,col){if(col.link_formatter){col.formatter=function(row,cell,value,columnDef,dataContext){if(!value)return"";if(dataContext._show){return repl('<span style="%(_style)s">%(value)s</span>',{_style:dataContext._style||"",value:value});}
var link_formatter=wn.cur_grid_report.columns[cell].link_formatter;var html=repl('<a href="#" \
onclick="wn.cur_grid_report.filter_inputs.%(col_name)s.val(\'%(value)s\'); \
diff --git a/public/js/all-web.js b/public/js/all-web.js
index 807c2cf..7ddc0c8 100644
--- a/public/js/all-web.js
+++ b/public/js/all-web.js
@@ -508,13 +508,13 @@
<span class="appframe-title"></span>\
<span class="close">×</span>\
</div>').appendTo(this.$w);this.$w.find('.close').click(function(){window.history.back();})
-if(title)this.title(title);},title:function(txt){this.clear_breadcrumbs();this.add_breadcrumb(txt);},add_button:function(label,click,icon){this.make_toolbar();args={label:label,icon:''};if(icon){args.icon='<i class="icon '+icon+'"></i>';}
+if(title)this.title(title);},title:function(txt){this.clear_breadcrumbs();this.add_breadcrumb(txt);},add_button:function(label,click,icon){this.add_toolbar();args={label:label,icon:''};if(icon){args.icon='<i class="icon '+icon+'"></i>';}
this.buttons[label]=$(repl('<button class="btn btn-small">\
- %(icon)s %(label)s</button>',args)).click(click).appendTo(this.toolbar);return this.buttons[label];},add_help_button:function(txt){this.make_toolbar();$('<button class="btn btn-small" style="float:right;" button-type="help">\
+ %(icon)s %(label)s</button>',args)).click(click).appendTo(this.toolbar);return this.buttons[label];},add_help_button:function(txt){this.add_toolbar();$('<button class="btn btn-small" style="float:right;" button-type="help">\
<b>?</b></button>').data('help-text',txt).click(function(){msgprint($(this).data('help-text'),'Help');}).appendTo(this.toolbar);},clear_buttons:function(){this.toolbar&&this.toolbar.empty();},add_breadcrumb:function(html){if(!this.$breadcrumbs)
this.$breadcrumbs=$('</span>\
<span class="breadcrumb-area"></span>').appendTo(this.$titlebar);var crumb=$('<span>').html(html);if(!this.$breadcrumbs.find('span').length){crumb.addClass('appframe-title');}
-crumb.appendTo(this.$breadcrumbs);},clear_breadcrumbs:function(){this.$breadcrumbs&&this.$breadcrumbs.empty();},make_toolbar:function(){if(!this.toolbar)
+crumb.appendTo(this.$breadcrumbs);},clear_breadcrumbs:function(){this.$breadcrumbs&&this.$breadcrumbs.empty();},add_toolbar:function(){if(!this.toolbar)
this.$w.append('<div class="appframe-toolbar"></div>');this.toolbar=this.$w.find('.appframe-toolbar');},add_label:function(label){return $("<span class='label'>"+label+" </span>").appendTo(this.toolbar);},add_select:function(label,options){this.add_toolbar();return $("<select style='width: 160px;'>").add_options(options).appendTo(this.toolbar);},add_data:function(label){this.add_toolbar();return $("<input style='width: 100px;' placeholder='"+label+"'>").appendTo(this.toolbar);},add_date:function(label,date){this.add_toolbar();return $("<input style='width: 80px;'>").datepicker({dateFormat:sys_defaults.date_format.replace("yyyy","yy"),changeYear:true,}).val(dateutil.str_to_user(date)||"").appendTo(this.toolbar);},});wn.ui.make_app_page=function(opts){if(opts.single_column){$(opts.parent).html('<div class="layout-wrapper layout-wrapper-appframe">\
<div class="layout-appframe"></div>\
<div class="layout-main"></div>\