Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added flot for graphs in report_grid

  • Loading branch information...
commit 4156523175b9f4b4b8c23af6152b59944c35a24a 1 parent f16b28b
@rmehta rmehta authored
Showing with 667 additions and 491 deletions.
  1. +0 −9 build.json
  2. +0 −272 erpnext/accounts/page/chart_of_accounts/chart_of_accounts.js
  3. +0 −49 erpnext/accounts/page/chart_of_accounts/chart_of_accounts.py
  4. +0 −28 erpnext/accounts/page/chart_of_accounts/chart_of_accounts.txt
  5. 0  erpnext/accounts/page/{chart_of_accounts → financial_analytics}/__init__.py
  6. +226 −0 erpnext/accounts/page/financial_analytics/financial_analytics.js
  7. +28 −0 erpnext/accounts/page/financial_analytics/financial_analytics.txt
  8. +30 −16 erpnext/accounts/page/general_ledger/general_ledger.js
  9. 0  erpnext/accounts/page/{chart_of_accounts/chart_of_accounts.html → trial_balance/__init__.py}
  10. +27 −0 erpnext/accounts/page/trial_balance/trial_balance.js
  11. +28 −0 erpnext/accounts/page/trial_balance/trial_balance.txt
  12. +1 −1  erpnext/projects/page/projects/projects.js
  13. +2 −2 erpnext/startup/event_handlers.py
  14. +5 −0 erpnext/startup/report_data_map.py
  15. +1 −1  erpnext/startup/startup.js
  16. +1 −1  erpnext/utilities/page/questions/questions.js
  17. +13 −11 public/js/all-app.js
  18. +4 −4 public/js/all-web.js
  19. 0  erpnext/accounts/page/chart_of_accounts/chart_of_accounts.css → public/js/app/account_tree_grid.css
  20. +259 −0 public/js/app/account_tree_grid.js
  21. 0  {erpnext/startup/js → public/js/app}/complete_setup.js
  22. 0  {erpnext/projects → public/js/app}/gantt_task.js
  23. 0  {erpnext/utilities/page/kb_common → public/js/app}/kb_common.js
  24. +0 −10 public/js/complete_setup.js
  25. +0 −10 public/js/gantt_task.js
  26. +0 −30 public/js/kb_common.js
  27. +0 −4 public/js/listing.js
  28. +0 −41 public/js/print_query.js
  29. +42 −2 public/js/report-legacy.js
View
9 build.json
@@ -17,13 +17,4 @@
"erpnext/startup/js/feature_setup.js",
"conf.js"
],
- "public/js/kb_common.js": [
- "erpnext/utilities/page/kb_common/kb_common.js",
- ],
- "public/js/complete_setup.js": [
- "erpnext/startup/js/complete_setup.js",
- ],
- "public/js/gantt_task.js": [
- "erpnext/projects/gantt_task.js",
- ]
}
View
272 erpnext/accounts/page/chart_of_accounts/chart_of_accounts.js
@@ -1,272 +0,0 @@
-// ERPNext - web based ERP (http://erpnext.com)
-// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-/* todo
- - load / display chart of accounts
- - settings for company, start date, end data
- - load balances
- - open ledger on link
-*/
-
-wn.pages['chart-of-accounts'].onload = function(wrapper) {
- wn.ui.make_app_page({
- parent: wrapper,
- title: 'Chart of Accounts',
- single_column: true
- });
-
- 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();
- });
- },
- 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
- });
-
- data.push(d);
- data_by_name[d.name] = d;
- 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;
- 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 {
- if(account.debit_or_credit=='Debit') {
- account.opening_debit += (v.debit - v.credit);
- } else {
- account.opening_credit += (v.credit - v.debit);
- }
- }
- } else if (this.opening_date <= posting_date && posting_date <= this.closing_date) {
- // in between
- account.debit += v.debit;
- account.credit += v.credit;
- }
- // closing
- if(account.debit_or_credit=='Debit') {
- 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];
- }
- });
- },
-
- 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,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");
- 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>&nbsp;" + value;
- } else {
- return spacer + " <span class='toggle collapse'></span>&nbsp;" + value;
- }
- } else {
- return spacer + " <span class='toggle'></span>&nbsp;" + 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({
-});
View
49 erpnext/accounts/page/chart_of_accounts/chart_of_accounts.py
@@ -1,49 +0,0 @@
-import webnotes
-
-@webnotes.whitelist()
-def get_chart():
- company = webnotes.form_dict.get('company')
- res = {}
- res["chart"] = webnotes.conn.sql("""select name, parent_account,
- if(debit_or_credit="Debit", "D", ""),
- if(is_pl_account="Yes", "Y", "") from
- tabAccount where company=%s and docstatus < 2 order by lft""", (company, ))
-
- res["gl"] = webnotes.conn.sql("""select posting_date, account, ifnull(debit, 0),
- ifnull(credit, 0), ifnull(is_opening, 'No')
- from `tabGL Entry` where company=%s and ifnull(is_cancelled, "No") = "No"
- order by posting_date""", (company, ), as_list=1)
-
- idx_map = {}
- for i in xrange(len(res["chart"])):
- idx_map[res["chart"][i][0]] = i
-
- for d in res["gl"]:
- d[1] = idx_map[d[1]]
-
- return res
-
-@webnotes.whitelist()
-def get_companies():
- """get a list of companies based on permission"""
-
- # check if match permission exists
- res = webnotes.conn.sql("""select role, `match` from `tabDocPerm`
- where parent='Account' and permlevel=0 and `read`=1""", as_dict=1)
-
- match = any((r["match"] for r in res
- if r["role"] in webnotes.user.roles and r["match"]=="company"))
-
- # if match == company is specified and companies are specified in user defaults
- res = {}
- if match and webnotes.user.get_defaults().get("company"):
- res["companies"] = webnotes.user.get_defaults().get("company")
- else:
- res["companies"] = [r[0] for r in webnotes.conn.sql("""select name from tabCompany
- where docstatus!=2""")]
-
- res["fiscal_years"] = webnotes.conn.sql("""select name, year_start_date,
- adddate(year_start_date, interval 1 year)
- from `tabFiscal Year` where docstatus!=2
- order by year_start_date asc""")
- return res
View
28 erpnext/accounts/page/chart_of_accounts/chart_of_accounts.txt
@@ -1,28 +0,0 @@
-# Page, chart-of-accounts
-[
-
- # These values are common in all dictionaries
- {
- 'creation': '2012-09-12 14:43:52',
- 'docstatus': 0,
- 'modified': '2012-09-12 14:43:53',
- 'modified_by': u'Administrator',
- 'owner': u'Administrator'
- },
-
- # These values are common for all Page
- {
- 'doctype': 'Page',
- 'module': u'Accounts',
- 'name': '__common__',
- 'page_name': u'Chart of Accounts',
- 'standard': u'Yes',
- 'title': u'Chart of Accounts'
- },
-
- # Page, chart-of-accounts
- {
- 'doctype': 'Page',
- 'name': u'chart-of-accounts'
- }
-]
View
0  ...counts/page/chart_of_accounts/__init__.py → ...unts/page/financial_analytics/__init__.py
File renamed without changes
View
226 erpnext/accounts/page/financial_analytics/financial_analytics.js
@@ -0,0 +1,226 @@
+// ERPNext - web based ERP (http://erpnext.com)
+// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+wn.require("js/app/account_tree_grid.js");
+wn.require("js/app/account_tree_grid.css");
+
+wn.pages['financial-analytics'].onload = function(wrapper) {
+ wn.ui.make_app_page({
+ parent: wrapper,
+ title: 'Financial Analytics',
+ single_column: true
+ });
+ erpnext.trial_balance = new erpnext.FinancialAnalytics(wrapper, 'Financial Analytics');
+}
+
+erpnext.FinancialAnalytics = erpnext.AccountTreeGrid.extend({
+ filters: [
+ {fieldtype:"Select", label: "PL or BS", options:["Profit and Loss", "Balance Sheet"],
+ filter: function(val, item, opts) {
+ if(val=='Profit and Loss') {
+ return item.is_pl_account=='Yes' || item._show;
+ } else {
+ return item.is_pl_account=='No' || item._show;
+ }
+ }},
+ {fieldtype:"Select", label: "Company", link:"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", link:"Fiscal Year",
+ default_value: "Select Fiscal Year..."},
+ {fieldtype:"Date", label: "From Date"},
+ {fieldtype:"Label", label: "To"},
+ {fieldtype:"Date", label: "To Date"},
+ {fieldtype:"Select", label: "Range",
+ options:["Daily", "Weekly", "Monthly", "Quarterly", "Yearly"]},
+ {fieldtype:"Button", label: "Refresh", icon:"icon-refresh icon-white", cssClass:"btn-info"},
+ {fieldtype:"Button", label: "Reset Filters"}
+ ],
+ setup_columns: function() {
+ this.columns = [
+ {id: "check", name: "Plot", field: "check", width: 30,
+ formatter: function(row, cell, value, columnDef, dataContext) {
+ return repl("<input type='checkbox' account='%(name)s' \
+ class='plot-check' %(checked)s>", {
+ "name": dataContext.name,
+ "checked": dataContext.checked ? "checked" : ""
+ })
+ }},
+ {id: "name", name: "Account", field: "name", width: 300,
+ formatter: this.account_formatter},
+ ];
+
+ var me = this;
+ var range = this.filter_inputs.range.val();
+ this.from_date = dateutil.user_to_str(this.filter_inputs.from_date.val());
+ this.to_date = dateutil.user_to_str(this.filter_inputs.to_date.val());
+ var date_diff = dateutil.get_diff(this.to_date, this.from_date);
+
+ me.column_map = {};
+ var build_columns = function(condition) {
+ for(var i=0; i < date_diff; i++) {
+ var date = dateutil.add_days(me.from_date, i);
+ if(!condition) condition = function() { return true; }
+
+ if(condition(date)) {
+ me.columns.push({
+ from_date: date,
+ id: date,
+ name: dateutil.str_to_user(date),
+ field: date,
+ formatter: me.currency_formatter,
+ width: 100
+ });
+ }
+ me.last_date = date;
+ me.column_map[date] = me.columns[me.columns.length-1];
+ }
+ }
+
+ if(range=='Daily') {
+ build_columns();
+ } else if(range=='Weekly') {
+ build_columns(function(date) {
+ if(!me.last_date) return true;
+ return !(dateutil.get_diff(date, me.from_date) % 7)
+ });
+ } else if(range=='Monthly') {
+ build_columns(function(date) {
+ if(!me.last_date) return true;
+ return dateutil.str_to_obj(me.last_date).getMonth() != dateutil.str_to_obj(date).getMonth()
+ });
+ } else if(range=='Quarterly') {
+ build_columns(function(date) {
+ if(!me.last_date) return true;
+ return dateutil.str_to_obj(date).getDate()==1 && in_list([0,3,6,9], dateutil.str_to_obj(date).getMonth())
+ });
+ } else if(range=='Yearly') {
+ build_columns(function(date) {
+ if(!me.last_date) return true;
+ return $.map(wn.report_dump.data['Fiscal Year'], function(v) {
+ return date==v.year_start_date ? true : null;
+ }).length;
+ });
+ }
+
+ },
+ init_filter_values: function() {
+ this._super();
+ this.filter_inputs.range.val('Weekly');
+ },
+ prepare_balances: function() {
+ var me = this;
+
+ $.each(wn.report_dump.data['GL Entry'], function(i, gl) {
+ var posting_date = dateutil.str_to_obj(gl.posting_date);
+ var account = me.accounts_by_name[gl.account];
+ var col = me.column_map[gl.posting_date];
+
+ if(col) {
+ if(gl.voucher_type=='Period Closing Voucher') {
+ // period closing voucher not to be added
+ // to profit and loss accounts (else will become zero!!)
+ if(account.is_pl_account!='Yes')
+ me.add_balance(col.field, account, gl);
+ } else {
+ me.add_balance(col.field, account, gl);
+ }
+
+ } else if(account.is_pl_account!='Yes'
+ && (posting_date < dateutil.str_to_obj(me.from_date))) {
+ me.add_balance('opening', account, gl);
+ }
+ });
+
+ // make balances as cumulative
+ if(me.filter_inputs.pl_or_bs.val()=='Balance Sheet') {
+ $.each(me.accounts, function(i, ac) {
+ if((ac.rgt - ac.lft)==1 && ac.is_pl_account!='Yes') {
+ var opening = flt(ac.opening);
+ //if(opening) throw opening;
+ $.each(me.columns, function(i, col) {
+ if(col.formatter==me.currency_formatter) {
+ ac[col.field] = opening + flt(ac[col.field]);
+ opening = ac[col.field];
+ }
+ });
+ }
+ })
+ }
+ this.update_groups();
+ },
+ add_balance: function(field, account, gl) {
+ account[field] = flt(account[field]) +
+ ((account.debit_or_credit == "Debit" ? 1 : -1) * (gl.debit - gl.credit))
+ },
+ init_account: function(d) {
+ var me = this;
+ $.each(this.columns, function(i, col) {
+ if (col.formatter==me.currency_formatter) {
+ d[col.from_date] = 0;
+ }
+ });
+ },
+ init_refresh: function() {
+ var me = this;
+ $.each(this.accounts || [], function(i, account) {
+ account.checked && me.preset_checks.push(account.name);
+ });
+ },
+ init_plot: function() {
+ var me = this;
+ if(this.preset_checks.length) {
+ $.each(me.preset_checks, function(i, name) {
+ me.accounts_by_name[name].checked = true;
+ });
+ } else {
+ $.each(this.accounts, function(i, account) {
+ if(!account.parent_account) {
+ account.checked = true;
+ }
+ });
+ }
+ },
+ get_plot_data: function() {
+ var data = [];
+ var me = this;
+ var pl_or_bs = this.filter_inputs.pl_or_bs.val();
+ $.each(this.accounts, function(i, account) {
+ var show = pl_or_bs == "Profit and Loss" ? account.is_pl_account=="Yes" : account.is_pl_account!="Yes";
+ if (show && account.checked) {
+ data.push({
+ label: account.name,
+ data: $.map(me.columns, function(col, idx) {
+ if(col.formatter==me.currency_formatter)
+ return [[idx, account[col.field]]]
+ })
+ });
+ }
+ });
+
+ return data;
+ },
+ add_grid_events: function() {
+ this._super();
+ var me = this;
+ this.wrapper.find('.plot-check').click(function() {
+ var checked = $(this).attr("checked");
+ me.accounts_by_name[$(this).attr("account")].checked = checked ? true : false;
+ me.render_plot();
+ });
+ }
+})
View
28 erpnext/accounts/page/financial_analytics/financial_analytics.txt
@@ -0,0 +1,28 @@
+# Page, financial-analytics
+[
+
+ # These values are common in all dictionaries
+ {
+ u'creation': '2012-09-17 13:46:47',
+ u'docstatus': 0,
+ u'modified': '2012-09-17 13:46:47',
+ u'modified_by': u'Administrator',
+ u'owner': u'Administrator'
+ },
+
+ # These values are common for all Page
+ {
+ u'doctype': u'Page',
+ 'module': u'Accounts',
+ u'name': u'__common__',
+ 'page_name': u'financial-analytics',
+ 'standard': u'Yes',
+ 'title': u'Financial Analytics'
+ },
+
+ # Page, financial-analytics
+ {
+ u'doctype': u'Page',
+ u'name': u'financial-analytics'
+ }
+]
View
46 erpnext/accounts/page/general_ledger/general_ledger.js
@@ -7,13 +7,11 @@ wn.pages['general-ledger'].onload = function(wrapper) {
erpnext.general_ledger = new wn.views.GridReport({
title: "General Ledger",
+ page: wrapper,
parent: $(wrapper).find('.layout-main'),
appframe: wrapper.appframe,
doctypes: ["Company", "Account", "GL Entry"],
- setup: function() {
- this.setup_filters();
- this.setup_columns();
- },
+
setup_columns: function() {
this.columns = [
{id: "posting_date", name: "Posting Date", field: "posting_date", width: 100,
@@ -41,13 +39,19 @@ wn.pages['general-ledger'].onload = function(wrapper) {
];
},
filters: [
- {fieldtype:"Select", label: "Company", options:"Company", default_value: "Select Company...",
+ {fieldtype:"Select", label: "Company", link:"Company", default_value: "Select Company...",
filter: function(val, item, opts) {
return item.company == val || val == opts.default_value || item._show;
}},
- {fieldtype:"Select", label: "Account", options:"Account", default_value: "Select Account...",
- filter: function(val, item, opts) {
- return item.account == val || val == opts.default_value || item._show;
+ {fieldtype:"Select", label: "Account", link:"Account", default_value: "Select Account...",
+ filter: function(val, item, opts, me) {
+ if(val == opts.default_value || item._show) {
+ return true;
+ } else {
+ // true if GL Entry belongs to selected
+ // account ledger or group
+ return me.is_child_account(val, item.account);
+ }
}},
{fieldtype:"Data", label: "Voucher No",
filter: function(val, item, opts) {
@@ -64,13 +68,6 @@ wn.pages['general-ledger'].onload = function(wrapper) {
{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(); })
- },
init_filter_values: function() {
this.filter_inputs.company.val(sys_defaults.company);
this.filter_inputs.from_date.val(dateutil.str_to_user(sys_defaults.year_start_date));
@@ -78,10 +75,18 @@ wn.pages['general-ledger'].onload = function(wrapper) {
this.filter_inputs.voucher_no.val("");
this.filter_inputs.account.get(0).selectedIndex = 0;
},
+ is_child_account: function(account, item_account) {
+ account = this.account_by_name[account];
+ item_account = this.account_by_name[item_account];
+
+ return (item_account.lft >= account.lft && item_account.rgt <= account.rgt)
+ },
prepare_data: function() {
// add Opening, Closing, Totals rows
// if filtered by account and / or voucher
var data = wn.report_dump.data["GL Entry"];
+ this.make_account_by_name();
+ var me = this;
var account = this.filter_inputs.account.val();
var from_date = dateutil.user_to_obj(this.filter_inputs.from_date.val());
@@ -104,9 +109,11 @@ wn.pages['general-ledger'].onload = function(wrapper) {
}
$.each(data, function(i, item) {
- if((account!=default_account ? item.account==account : true) &&
+ if((account!=default_account ? me.is_child_account(account, item.account) : true) &&
(voucher_no ? item.voucher_no==voucher_no : true)) {
+
var date = dateutil.str_to_obj(item.posting_date);
+
if(date < from_date) {
opening.debit += item.debit;
opening.credit += item.credit;
@@ -132,6 +139,13 @@ wn.pages['general-ledger'].onload = function(wrapper) {
this.prepare_data_view(out);
},
+ make_account_by_name: function() {
+ this.account_by_name = {};
+ var me = this;
+ $.each(wn.report_dump.data['Account'], function(i, v) {
+ me.account_by_name[v.name] = v;
+ })
+ }
});
}
View
0  .../chart_of_accounts/chart_of_accounts.html → ...t/accounts/page/trial_balance/__init__.py
File renamed without changes
View
27 erpnext/accounts/page/trial_balance/trial_balance.js
@@ -0,0 +1,27 @@
+// ERPNext - web based ERP (http://erpnext.com)
+// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+wn.require("js/app/account_tree_grid.js");
+wn.require("js/app/account_tree_grid.css");
+
+wn.pages['trial-balance'].onload = function(wrapper) {
+ wn.ui.make_app_page({
+ parent: wrapper,
+ title: 'Trial Balance',
+ single_column: true
+ });
+ erpnext.trial_balance = new erpnext.AccountTreeGrid(wrapper, 'Trial Balance');
+}
View
28 erpnext/accounts/page/trial_balance/trial_balance.txt
@@ -0,0 +1,28 @@
+# Page, trial-balance
+[
+
+ # These values are common in all dictionaries
+ {
+ u'creation': '2012-09-17 13:47:16',
+ u'docstatus': 0,
+ u'modified': '2012-09-17 13:47:16',
+ u'modified_by': u'Administrator',
+ u'owner': u'Administrator'
+ },
+
+ # These values are common for all Page
+ {
+ u'doctype': u'Page',
+ 'module': u'Accounts',
+ u'name': u'__common__',
+ 'page_name': u'trial-balance',
+ 'standard': u'Yes',
+ 'title': u'Trial Balance'
+ },
+
+ # Page, trial-balance
+ {
+ u'doctype': u'Page',
+ u'name': u'trial-balance'
+ }
+]
View
2  erpnext/projects/page/projects/projects.js
@@ -17,7 +17,7 @@
pscript.onload_Projects = function(wrapper) {
wn.ui.make_app_page({parent:wrapper, title:'Gantt Chart: All Tasks', single_column:true});
if(!erpnext.show_task_gantt)
- wn.require('js/gantt_task.js');
+ wn.require('js/app/gantt_task.js');
var gantt_area = $('<div>').appendTo($(wrapper).find('.layout-main'));
erpnext.show_task_gantt(gantt_area);
View
4 erpnext/startup/event_handlers.py
@@ -87,7 +87,7 @@ def boot_session(bootinfo):
# load subscription info
import conf
- for key in ['max_users', 'expires_on', 'max_space', 'status']:
+ for key in ['max_users', 'expires_on', 'max_space', 'status', 'developer_mode']:
if hasattr(conf, key): bootinfo[key] = getattr(conf, key)
company = webnotes.conn.sql("select name, default_currency from `tabCompany`", as_dict=1)
@@ -96,7 +96,7 @@ def boot_session(bootinfo):
company_dict.setdefault(c['name'], {}).update(c)
bootinfo['company'] = company_dict
-
+
def get_letter_heads():
"""load letter heads with startup"""
import webnotes
View
5 erpnext/startup/report_data_map.py
@@ -20,6 +20,11 @@
"company"],
"order_by": "lft"
},
+ "Cost Center": {
+ "columns": ["name", "parent_cost_center", "lft", "rgt", "debit_or_credit",
+ "company"],
+ "order_by": "lft"
+ },
"GL Entry": {
"columns": ["account", "posting_date", "cost_center", "debit", "credit", "is_opening",
"company", "voucher_type", "voucher_no", "remarks"],
View
2  erpnext/startup/startup.js
@@ -76,7 +76,7 @@ erpnext.startup.start = function() {
// complete registration
if(in_list(user_roles,'System Manager') && (wn.boot.setup_complete=='No')) {
- wn.require("js/complete_setup.js");
+ wn.require("js/app/complete_setup.js");
erpnext.complete_setup.show();
}
if(wn.boot.expires_on && in_list(user_roles, 'System Manager')) {
View
2  erpnext/utilities/page/questions/questions.js
@@ -215,4 +215,4 @@ KBQuestion = function(parent, det, kb) {
this.make()
}
-wn.require('js/kb_common.js');
+wn.require('js/app/kb_common.js');
View
24 public/js/all-app.js
@@ -139,7 +139,7 @@ wn.provide('wn.settings');wn.provide('wn.ui');
*/
wn.require=function(items){if(typeof items==="string"){items=[items];}
var l=items.length;for(var i=0;i<l;i++){var src=items[i];wn.assets.execute(src);}}
-wn.assets={executed_:{},check:function(){if(window._version_number!=localStorage.getItem("_version_number")){localStorage.clear();localStorage.setItem("_version_number",window._version_number)}},exists:function(src){if('localStorage'in window&&localStorage.getItem(src))
+wn.assets={executed_:{},check:function(){if(window._version_number!=localStorage.getItem("_version_number")){localStorage.clear();localStorage.setItem("_version_number",window._version_number)}},exists:function(src){if('localStorage'in window&&localStorage.getItem(src)&&!wn.boot.developer_mode)
return true},add:function(src,txt){if('localStorage'in window){localStorage.setItem(src,txt);}},get:function(src){return localStorage.getItem(src);},extn:function(src){if(src.indexOf('?')!=-1){src=src.split('?').slice(-1)[0];}
return src.split('.').slice(-1)[0];},load:function(src){var t=src;$.ajax({url:t,data:{q:Math.floor(Math.random()*1000)},dataType:'text',success:function(txt){wn.assets.add(src,txt);},async:false})},execute:function(src){if(!wn.assets.exists(src)){wn.assets.load(src);}
var type=wn.assets.extn(src);if(wn.assets.handler[type]){wn.assets.handler[type](wn.assets.get(src),src);wn.assets.executed_[src]=1;}},handler:{js:function(txt,src){wn.dom.eval(txt);},css:function(txt,src){wn.dom.set_style(txt);}}}
@@ -854,7 +854,7 @@ this.buttons[label]=$(repl('<button class="btn btn-small">\
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();},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">\
+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: 100px;'>").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>\
</div>');}else{$(opts.parent).html('<div class="layout-wrapper layout-wrapper-background">\
@@ -1072,24 +1072,26 @@ me.list.run();});this.dialog.show();},add_column:function(c){var w=$('<div style
* lib/js/wn/views/grid_report.js
*/
wn.provide("wn.report_dump");$.extend(wn.report_dump,{data:{},with_data:function(doctypes,callback,progress_bar){var missing=[];$.each(doctypes,function(i,v){if(!wn.report_dump.data[v])missing.push(v);})
-if(missing.length){wn.call({method:"webnotes.widgets.report_dump.get_data",args:{doctypes:missing},callback:function(r){$.each(r.message,function(doctype,doctype_data){var data=[];$.each(doctype_data.data,function(i,d){var row={};$.each(doctype_data.columns,function(idx,col){row[col]=d[idx];});row.id=doctype+"-"+i;data.push(row);});wn.report_dump.data[doctype]=data;});callback();},progress_bar:progress_bar})}else{callback();}}});wn.provide("wn.views");wn.views.GridReport=Class.extend({init:function(opts){this.filter_inputs={};$.extend(this,opts);this.wrapper=$('<div>').appendTo(this.parent);if(this.filters){this.make_filters();}
-this.make_waiting();this.import_slickgrid();var me=this;this.get_data();wn.cur_grid_report=this;},get_data:function(){var me=this;wn.report_dump.with_data(this.doctypes,function(){$.each(me.filter_inputs,function(i,v){var opts=v.get(0).opts;if(opts.fieldtype=="Select"&&inList(me.doctypes,opts.options)){$(v).add_options($.map(wn.report_dump.data[opts.options],function(d){return d.name;}));}});me.setup();me.refresh();},this.wrapper.find(".progress .bar"));},make_waiting:function(){this.waiting=$('<div class="well" style="width: 63%; margin: 30px auto;">\
+if(missing.length){wn.call({method:"webnotes.widgets.report_dump.get_data",args:{doctypes:missing},callback:function(r){$.each(r.message,function(doctype,doctype_data){var data=[];$.each(doctype_data.data,function(i,d){var row={};$.each(doctype_data.columns,function(idx,col){row[col]=d[idx];});row.id=doctype+"-"+i;data.push(row);});wn.report_dump.data[doctype]=data;});callback();},progress_bar:progress_bar})}else{callback();}}});wn.provide("wn.views");wn.views.GridReport=Class.extend({init:function(opts){this.filter_inputs={};this.preset_checks=[];$.extend(this,opts);this.wrapper=$('<div>').appendTo(this.parent);if(this.filters){this.make_filters();}
+this.make_waiting();this.import_slickgrid();var me=this;this.get_data();},get_data:function(){var me=this;wn.report_dump.with_data(this.doctypes,function(){me.setup_filters();me.init_filter_values();me.refresh();},this.wrapper.find(".progress .bar"));},setup_filters:function(){var me=this;$.each(me.filter_inputs,function(i,v){var opts=v.get(0).opts;if(opts.fieldtype=="Select"&&inList(me.doctypes,opts.link)){$(v).add_options($.map(wn.report_dump.data[opts.link],function(d){return d.name;}));}});this.filter_inputs.refresh&&this.filter_inputs.refresh.click(function(){me.set_route();});this.filter_inputs.reset_filters&&this.filter_inputs.reset_filters.click(function(){me.init_filter_values();me.set_route();});},make_waiting:function(){this.waiting=$('<div class="well" style="width: 63%; margin: 30px auto;">\
<p style="text-align: center;">Loading Report...</p>\
<div class="progress progress-striped active">\
- <div class="bar" style="width: 10%"></div></div>').appendTo(this.wrapper);},make_grid_wrapper:function(){$('<div style="text-align: right;"> \
+ <div class="bar" style="width: 10%"></div></div>').appendTo(this.wrapper);},make_grid_wrapper:function(){$('<div class="plot" style="margin-bottom: 15px; display: none; \
+ height: 300px; width: 100%;"></div>').appendTo(this.wrapper);$('<div style="text-align: right;"> \
<a href="#" class="grid-report-print"><i class="icon icon-print"></i> Print</a> \
<span style="color: #aaa; margin: 0px 10px;"> | </span> \
<a href="#" class="grid-report-export"><i class="icon icon-download-alt"></i> Export</a> \
</div>').appendTo(this.wrapper);this.wrapper.find(".grid-report-export").click(function(){return me.export();});this.grid_wrapper=$("<div style='height: 500px; border: 1px solid #aaa; \
- background-color: #eee; margin-top: 15px;'>").appendTo(this.wrapper);this.id=wn.dom.set_unique_id(this.grid_wrapper.get(0));var me=this;$(wn.container.page).bind('show',function(){wn.cur_grid_report=me;me.apply_filters_from_route();me.refresh();});this.apply_filters_from_route();},load_filters:function(callback){callback();},make_filters:function(){var me=this;$.each(this.filters,function(i,v){v.fieldname=v.fieldname||v.label.replace(/ /g,'_').toLowerCase();var input=null;if(v.fieldtype=='Select'){input=me.appframe.add_select(v.label,[v.default_value]);}else if(v.fieldtype=='Button'){input=me.appframe.add_button(v.label);if(v.icon){$('<i class="icon '+v.icon+'"></i>').prependTo(input);}}else if(v.fieldtype=='Date'){input=me.appframe.add_date(v.label);}else if(v.fieldtype=='Label'){input=me.appframe.add_label(v.label);}else if(v.fieldtype=='Data'){input=me.appframe.add_data(v.label);}
+ background-color: #eee; margin-top: 15px;'>").appendTo(this.wrapper);this.id=wn.dom.set_unique_id(this.grid_wrapper.get(0));var me=this;$(this.page).bind('show',function(){wn.cur_grid_report=me;me.apply_filters_from_route();me.refresh();});wn.cur_grid_report=this;this.apply_filters_from_route();},load_filters:function(callback){callback();},make_filters:function(){var me=this;$.each(this.filters,function(i,v){v.fieldname=v.fieldname||v.label.replace(/ /g,'_').toLowerCase();var input=null;if(v.fieldtype=='Select'){input=me.appframe.add_select(v.label,v.options||[v.default_value]);}else if(v.fieldtype=='Button'){input=me.appframe.add_button(v.label);if(v.icon){$('<i class="icon '+v.icon+'"></i>').prependTo(input);}}else if(v.fieldtype=='Date'){input=me.appframe.add_date(v.label);}else if(v.fieldtype=='Label'){input=me.appframe.add_label(v.label);}else if(v.fieldtype=='Data'){input=me.appframe.add_data(v.label);}
if(input){input&&(input.get(0).opts=v);if(v.cssClass){input.addClass(v.cssClass);}
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)
+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.init_refresh&&this.init_refresh();this.waiting.toggle(false);if(!this.grid_wrapper)
+this.make_grid_wrapper();this.setup_columns();this.apply_link_formatters();this.prepare_data();this.init_plot&&this.init_plot();this.render();this.render_plot();},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("=");if(me.filter_inputs[f[0]]){me.filter_inputs[f[0]].val(decodeURIComponent(f[1]));}else{console.log("Invalid filter: "+f[0]);}});}},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);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=""}
++'='+encodeURIComponent(val);}).join('&'))},render:function(){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;})].concat(this.get_view_data());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;},render_plot:function(){if(!this.get_plot_data)return;wn.require('js/lib/flot/jquery.flot.js');$.plot(this.wrapper.find('.plot').toggle(true),this.get_plot_data());},get_view_data:function(){var res=[];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;}}
+return res;},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,wn.cur_grid_report)){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="#" \
@@ -2270,7 +2272,7 @@ me.dialog.clear();me.dialog.show();}});
*/
wn.Application=Class.extend({init:function(){var me=this;if(window.app){wn.call({method:'startup',callback:function(r,rt){wn.provide('wn.boot');wn.boot=r;if(wn.boot.profile.name=='Guest'){window.location='index.html';return;}
me.startup();}})}else{this.startup();}},startup:function(){this.load_bootinfo();this.make_page_container();this.make_nav_bar();this.set_favicon();$(document).trigger('startup');if(wn.boot){wn.route();}
-$(document).trigger('app_ready');},load_bootinfo:function(){if(wn.boot){LocalDB.sync(wn.boot.docs);wn.control_panel=wn.boot.control_panel;this.set_globals();}else{this.set_as_guest();}},set_globals:function(){profile=wn.boot.profile;user=wn.boot.profile.name;user_fullname=wn.user_info(user).fullname;user_defaults=profile.defaults;user_roles=profile.roles;user_email=profile.email;sys_defaults=wn.boot.sysdefaults;},set_as_guest:function(){profile={name:'Guest'};user='Guest';user_fullname='Guest';user_defaults={};user_roles=['Guest'];user_email='';sys_defaults={};},make_page_container:function(){wn.container=new wn.views.Container();wn.views.make_403();wn.views.make_404();},make_nav_bar:function(){if(wn.boot){wn.container.wntoolbar=new wn.ui.toolbar.Toolbar();}},logout:function(){var me=this;me.logged_out=true;wn.call({method:'logout',callback:function(r){if(r.exc){console.log(r.exc);}
+$(document).trigger('app_ready');},load_bootinfo:function(){if(wn.boot){LocalDB.sync(wn.boot.docs);wn.control_panel=wn.boot.control_panel;this.set_globals();if(wn.boot.developer_mode){(console.warn||console.log)("LocalStorage is OFF for developer mode. Please build before going live.");}}else{this.set_as_guest();}},set_globals:function(){profile=wn.boot.profile;user=wn.boot.profile.name;user_fullname=wn.user_info(user).fullname;user_defaults=profile.defaults;user_roles=profile.roles;user_email=profile.email;sys_defaults=wn.boot.sysdefaults;},set_as_guest:function(){profile={name:'Guest'};user='Guest';user_fullname='Guest';user_defaults={};user_roles=['Guest'];user_email='';sys_defaults={};},make_page_container:function(){wn.container=new wn.views.Container();wn.views.make_403();wn.views.make_404();},make_nav_bar:function(){if(wn.boot){wn.container.wntoolbar=new wn.ui.toolbar.Toolbar();}},logout:function(){var me=this;me.logged_out=true;wn.call({method:'logout',callback:function(r){if(r.exc){console.log(r.exc);}
me.redirect_to_login();}})},redirect_to_login:function(){window.location.href='index.html';},set_favicon:function(){var link=$('link[type="image/x-icon"]').remove().attr("href");var favicon='\
<link rel="shortcut icon" href="'+link+'" type="image/x-icon"> \
<link rel="icon" href="'+link+'" type="image/x-icon">'
@@ -2283,7 +2285,7 @@ wn.provide('wn.modules');$.extend(wn.modules,erpnext.modules);wn.modules['Core']
erpnext.startup.start=function(){console.log('Starting up...');$('#startup_div').html('Starting up...').toggle(true);erpnext.startup.set_globals();if(user!='Guest'){if(wn.boot.user_background){erpnext.set_user_background(wn.boot.user_background);}
wn.boot.profile.allow_modules=wn.boot.profile.allow_modules.concat(['To Do','Knowledge Base','Calendar','Activity','Messages'])
erpnext.toolbar.setup();erpnext.startup.set_periodic_updates();$('footer').html('<div class="web-footer erpnext-footer">\
- <a href="#!attributions">ERPNext | Attributions and License</a></div>');if(in_list(user_roles,'System Manager')&&(wn.boot.setup_complete=='No')){wn.require("js/complete_setup.js");erpnext.complete_setup.show();}
+ <a href="#!attributions">ERPNext | Attributions and License</a></div>');if(in_list(user_roles,'System Manager')&&(wn.boot.setup_complete=='No')){wn.require("js/app/complete_setup.js");erpnext.complete_setup.show();}
if(wn.boot.expires_on&&in_list(user_roles,'System Manager')){var today=dateutil.str_to_obj(dateutil.get_today());var expires_on=dateutil.str_to_obj(wn.boot.expires_on);var diff=dateutil.get_diff(expires_on,today);if(0<=diff&&diff<=15){var expiry_string=diff==0?"today":repl("in %(diff)s day(s)",{diff:diff});$('header').append(repl('<div class="expiry-info"> \
Your ERPNext subscription will <b>expire %(expiry_string)s</b>. \
Please renew your subscription to continue using ERPNext \
View
8 public/js/all-web.js
@@ -26,7 +26,7 @@ wn.provide('wn.settings');wn.provide('wn.ui');
*/
wn.require=function(items){if(typeof items==="string"){items=[items];}
var l=items.length;for(var i=0;i<l;i++){var src=items[i];wn.assets.execute(src);}}
-wn.assets={executed_:{},check:function(){if(window._version_number!=localStorage.getItem("_version_number")){localStorage.clear();localStorage.setItem("_version_number",window._version_number)}},exists:function(src){if('localStorage'in window&&localStorage.getItem(src))
+wn.assets={executed_:{},check:function(){if(window._version_number!=localStorage.getItem("_version_number")){localStorage.clear();localStorage.setItem("_version_number",window._version_number)}},exists:function(src){if('localStorage'in window&&localStorage.getItem(src)&&!wn.boot.developer_mode)
return true},add:function(src,txt){if('localStorage'in window){localStorage.setItem(src,txt);}},get:function(src){return localStorage.getItem(src);},extn:function(src){if(src.indexOf('?')!=-1){src=src.split('?').slice(-1)[0];}
return src.split('.').slice(-1)[0];},load:function(src){var t=src;$.ajax({url:t,data:{q:Math.floor(Math.random()*1000)},dataType:'text',success:function(txt){wn.assets.add(src,txt);},async:false})},execute:function(src){if(!wn.assets.exists(src)){wn.assets.load(src);}
var type=wn.assets.extn(src);if(wn.assets.handler[type]){wn.assets.handler[type](wn.assets.get(src),src);wn.assets.executed_[src]=1;}},handler:{js:function(txt,src){wn.dom.eval(txt);},css:function(txt,src){wn.dom.set_style(txt);}}}
@@ -515,7 +515,7 @@ this.buttons[label]=$(repl('<button class="btn btn-small">\
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();},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">\
+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: 100px;'>").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>\
</div>');}else{$(opts.parent).html('<div class="layout-wrapper layout-wrapper-background">\
@@ -699,7 +699,7 @@ if(errfld.length)msgprint('<b>Mandatory fields required in '+
*/
wn.Application=Class.extend({init:function(){var me=this;if(window.app){wn.call({method:'startup',callback:function(r,rt){wn.provide('wn.boot');wn.boot=r;if(wn.boot.profile.name=='Guest'){window.location='index.html';return;}
me.startup();}})}else{this.startup();}},startup:function(){this.load_bootinfo();this.make_page_container();this.make_nav_bar();this.set_favicon();$(document).trigger('startup');if(wn.boot){wn.route();}
-$(document).trigger('app_ready');},load_bootinfo:function(){if(wn.boot){LocalDB.sync(wn.boot.docs);wn.control_panel=wn.boot.control_panel;this.set_globals();}else{this.set_as_guest();}},set_globals:function(){profile=wn.boot.profile;user=wn.boot.profile.name;user_fullname=wn.user_info(user).fullname;user_defaults=profile.defaults;user_roles=profile.roles;user_email=profile.email;sys_defaults=wn.boot.sysdefaults;},set_as_guest:function(){profile={name:'Guest'};user='Guest';user_fullname='Guest';user_defaults={};user_roles=['Guest'];user_email='';sys_defaults={};},make_page_container:function(){wn.container=new wn.views.Container();wn.views.make_403();wn.views.make_404();},make_nav_bar:function(){if(wn.boot){wn.container.wntoolbar=new wn.ui.toolbar.Toolbar();}},logout:function(){var me=this;me.logged_out=true;wn.call({method:'logout',callback:function(r){if(r.exc){console.log(r.exc);}
+$(document).trigger('app_ready');},load_bootinfo:function(){if(wn.boot){LocalDB.sync(wn.boot.docs);wn.control_panel=wn.boot.control_panel;this.set_globals();if(wn.boot.developer_mode){(console.warn||console.log)("LocalStorage is OFF for developer mode. Please build before going live.");}}else{this.set_as_guest();}},set_globals:function(){profile=wn.boot.profile;user=wn.boot.profile.name;user_fullname=wn.user_info(user).fullname;user_defaults=profile.defaults;user_roles=profile.roles;user_email=profile.email;sys_defaults=wn.boot.sysdefaults;},set_as_guest:function(){profile={name:'Guest'};user='Guest';user_fullname='Guest';user_defaults={};user_roles=['Guest'];user_email='';sys_defaults={};},make_page_container:function(){wn.container=new wn.views.Container();wn.views.make_403();wn.views.make_404();},make_nav_bar:function(){if(wn.boot){wn.container.wntoolbar=new wn.ui.toolbar.Toolbar();}},logout:function(){var me=this;me.logged_out=true;wn.call({method:'logout',callback:function(r){if(r.exc){console.log(r.exc);}
me.redirect_to_login();}})},redirect_to_login:function(){window.location.href='index.html';},set_favicon:function(){var link=$('link[type="image/x-icon"]').remove().attr("href");var favicon='\
<link rel="shortcut icon" href="'+link+'" type="image/x-icon"> \
<link rel="icon" href="'+link+'" type="image/x-icon">'
@@ -712,7 +712,7 @@ wn.provide('wn.modules');$.extend(wn.modules,erpnext.modules);wn.modules['Core']
erpnext.startup.start=function(){console.log('Starting up...');$('#startup_div').html('Starting up...').toggle(true);erpnext.startup.set_globals();if(user!='Guest'){if(wn.boot.user_background){erpnext.set_user_background(wn.boot.user_background);}
wn.boot.profile.allow_modules=wn.boot.profile.allow_modules.concat(['To Do','Knowledge Base','Calendar','Activity','Messages'])
erpnext.toolbar.setup();erpnext.startup.set_periodic_updates();$('footer').html('<div class="web-footer erpnext-footer">\
- <a href="#!attributions">ERPNext | Attributions and License</a></div>');if(in_list(user_roles,'System Manager')&&(wn.boot.setup_complete=='No')){wn.require("js/complete_setup.js");erpnext.complete_setup.show();}
+ <a href="#!attributions">ERPNext | Attributions and License</a></div>');if(in_list(user_roles,'System Manager')&&(wn.boot.setup_complete=='No')){wn.require("js/app/complete_setup.js");erpnext.complete_setup.show();}
if(wn.boot.expires_on&&in_list(user_roles,'System Manager')){var today=dateutil.str_to_obj(dateutil.get_today());var expires_on=dateutil.str_to_obj(wn.boot.expires_on);var diff=dateutil.get_diff(expires_on,today);if(0<=diff&&diff<=15){var expiry_string=diff==0?"today":repl("in %(diff)s day(s)",{diff:diff});$('header').append(repl('<div class="expiry-info"> \
Your ERPNext subscription will <b>expire %(expiry_string)s</b>. \
Please renew your subscription to continue using ERPNext \
View
0  ...e/chart_of_accounts/chart_of_accounts.css → public/js/app/account_tree_grid.css
File renamed without changes
View
259 public/js/app/account_tree_grid.js
@@ -0,0 +1,259 @@
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+erpnext.AccountTreeGrid = wn.views.GridReport.extend({
+ init: function(wrapper, title) {
+ this._super({
+ title: title,
+ page: wrapper,
+ parent: $(wrapper).find('.layout-main'),
+ appframe: wrapper.appframe,
+ doctypes: ["Company", "Fiscal Year", "Account", "GL Entry"]
+ });
+ },
+ 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", link:"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", link:"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() {
+ this._super();
+ var me = this;
+ // default filters
+ 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();
+ });
+ },
+ 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 me = this;
+ var data = [];
+ var parent_map = {};
+ var data_by_name = {};
+ $.each(wn.report_dump.data["Account"], function(i, v) {
+ var d = copy_dict(v);
+ me.init_account(d);
+
+ data.push(d);
+ data_by_name[d.name] = d;
+ 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;
+ this.prepare_balances();
+ this.prepare_data_view(this.accounts);
+ },
+ init_account: function(d) {
+ $.extend(d, {
+ "opening_debit": 0,
+ "opening_credit": 0,
+ "debit": 0,
+ "credit": 0,
+ "closing_debit": 0,
+ "closing_credit": 0
+ });
+ },
+ 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 {
+ if(account.debit_or_credit=='Debit') {
+ account.opening_debit += (v.debit - v.credit);
+ } else {
+ account.opening_credit += (v.credit - v.debit);
+ }
+ }
+ } else if (this.opening_date <= posting_date && posting_date <= this.closing_date) {
+ // in between
+ account.debit += v.debit;
+ account.credit += v.credit;
+ }
+ // closing
+ if(account.debit_or_credit=='Debit') {
+ 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];
+ $.each(me.columns, function(c, col) {
+ if (col.formatter == me.currency_formatter) {
+ parent_account[col.field] += account[col.field];
+ }
+ });
+ 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,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");
+ var data = wn.cur_grid_report.accounts;
+ var spacer = "<span style='display:inline-block;height:1px;width:" +
+ (15 * dataContext["indent"]) + "px'></span>";
+ var idx = wn.cur_grid_report.dataView.getIdxById(dataContext.id);
+ var account_link = repl('<a href="#general-ledger/account=%(enc_value)s">%(value)s</a>', {
+ value: value,
+ enc_value: encodeURIComponent(value)
+ });
+
+ if (data[idx + 1] && data[idx + 1].indent > data[idx].indent) {
+ if (dataContext._collapsed) {
+ return spacer + " <span class='toggle expand'></span>&nbsp;" + account_link;
+ } else {
+ return spacer + " <span class='toggle collapse'></span>&nbsp;" + account_link;
+ }
+ } else {
+ return spacer + " <span class='toggle'></span>&nbsp;" + account_link;
+ }
+ },
+ 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 (wn.cur_grid_report.accounts_by_name[parent]._collapsed) {
+ return false;
+ }
+ parent = wn.cur_grid_report.parent_map[parent];
+ }
+ }
+ return true;
+ }
+});
View
0  erpnext/startup/js/complete_setup.js → public/js/app/complete_setup.js
File renamed without changes
View
0  erpnext/projects/gantt_task.js → public/js/app/gantt_task.js
File renamed without changes
View
0  ...ext/utilities/page/kb_common/kb_common.js → public/js/app/kb_common.js
File renamed without changes
View
10 public/js/complete_setup.js
@@ -1,10 +0,0 @@
-
-/*
- * erpnext/startup/js/complete_setup.js
- */
-wn.provide('erpnext.complete_setup');$.extend(erpnext.complete_setup,{show:function(){d=erpnext.complete_setup.prepare_dialog();d.show();},prepare_dialog:function(){var d=new wn.widgets.Dialog({title:"Setup",fields:[{fieldname:'first_name',label:'Your First Name',fieldtype:'Data',reqd:1},{fieldname:'last_name',label:'Your Last Name',fieldtype:'Data'},{fieldname:'company_name',label:'Company Name',fieldtype:'Data',reqd:1,description:'e.g. "My Company LLC"'},{fieldname:'company_abbr',label:'Company Abbreviation',fieldtype:'Data',description:'e.g. "MC"',reqd:1},{fieldname:'fy_start',label:'Financial Year Start Date',fieldtype:'Select',description:'Your financial year begins on"',reqd:1,options:erpnext.complete_setup.fy_start_list.join('\n')},{fieldname:'currency',label:'Default Currency',reqd:1,options:erpnext.complete_setup.currency_list.join('\n'),fieldtype:'Select'},{fieldname:'industry',label:'Industry',reqd:1,options:erpnext.complete_setup.industry_list.join('\n'),fieldtype:'Select'},{fieldname:'country',label:'Country',reqd:1,options:erpnext.complete_setup.country_list.join('\n'),fieldtype:'Select'},{fieldname:'timezone',label:'Time Zone',reqd:1,options:'',fieldtype:'Select'},{fieldname:'update',label:'Setup',fieldtype:'Button'},],});if(user!='Administrator'){$(d.appframe.$titlebar).find('.close').toggle(false);$('header').toggle(false);}
-d.fields_dict.update.input.onclick=function(){var data=d.get_values();if(!data)return;$(this).set_working();$c_obj('Setup Control','setup_account',data,function(r,rt){sys_defaults=r.message;user_fullname=r.message.user_fullname;wn.boot.user_info[user].fullname=user_fullname;d.hide();$('header').toggle(true);wn.container.wntoolbar.set_user_name();});};d.fields_dict.country.input.onchange=function(){var country=d.fields_dict.country.input.value;var $timezone=$(d.fields_dict.timezone.input);$timezone.empty();if(country){var timezone_list=erpnext.complete_setup.timezone_dict[country];if(timezone_list.length>1){timezone_list=[""].concat(timezone_list);}
-$timezone.add_options(timezone_list);}};if(wn.control_panel.company_name){var inp=d.fields_dict.company_name.input;inp.value=wn.control_panel.company_name;inp.disabled=true;}
-if(user_fullname){u=user_fullname.split(' ');if(u[0]){d.fields_dict.first_name.input.value=u[0];}
-if(u[1]){d.fields_dict.last_name.input.value=u[1];}}
-return d;},fy_start_list:['','1st Jan','1st Apr','1st Jul','1st Oct'],currency_list:['','AED','AFN','ALL','AMD','ANG','AOA','ARS','AUD','AZN','BAM','BBD','BDT','BGN','BHD','BIF','BMD','BND','BOB','BRL','BSD','BTN','BYR','BZD','CAD','CDF','CFA','CFP','CHF','CLP','CNY','COP','CRC','CUC','CZK','DJF','DKK','DOP','DZD','EEK','EGP','ERN','ETB','EUR','EURO','FJD','FKP','FMG','GBP','GEL','GHS','GIP','GMD','GNF','GQE','GTQ','GYD','HKD','HNL','HRK','HTG','HUF','IDR','ILS','INR','IQD','IRR','ISK','JMD','JOD','JPY','KES','KGS','KHR','KMF','KPW','KRW','KWD','KYD','KZT','LAK','LBP','LKR','LRD','LSL','LTL','LVL','LYD','MAD','MDL','MGA','MKD','MMK','MNT','MOP','MRO','MUR','MVR','MWK','MXN','MYR','MZM','NAD','NGN','NIO','NOK','NPR','NRs','NZD','OMR','PAB','PEN','PGK','PHP','PKR','PLN','PYG','QAR','RMB','RON','RSD','RUB','RWF','SAR','SCR','SDG','SDR','SEK','SGD','SHP','SOS','SRD','STD','SYP','SZL','THB','TJS','TMT','TND','TRY','TTD','TWD','TZS','UAE','UAH','UGX','USD','USh','UYU','UZS','VEB','VND','VUV','WST','XAF','XCD','XDR','XOF','XPF','YEN','YER','YTL','ZAR','ZMK','ZWR'],industry_list:['','Aerospace and Defence','Agriculture','Apparel','Automobile','Banking','Biotechnology','Chemical','Communications','Consulting','Customer Service','Education','Electronics','Energy','Engineering','Entertainment','Environmental','Finance','Food and Beverage','Government','Healthcare','Hospitality','Information Technology','Insurance','Machinery','Manufacturing','Media','Not For Profit','Recreation','Retail','Shipping','Technology','Telecommunications','Transportation','Trading','Utilities','Other'],country_list:["",'Afghanistan','Albania','Algeria','Andorra','Angola','Antigua and Barbuda','Argentina','Armenia','Australia','Austria','Azerbaijan','Bahamas','Bahrain','Bangladesh','Barbados','Belarus','Belgium','Belize','Benin','Bhutan','Bolivia','Bosnia and Herzegovina','Botswana','Brazil','Brunei Darussalam','Bulgaria','Burkina Faso','Burundi','Cambodia','Cameroon','Canada','Cape Verde','Central African Republic','Chad','Chile','Colombia','Comoros','Costa Rica','Croatia','Cuba','Cyprus','Czech Republic',"C\xc3\xb4te d'Ivoire",'Democratic Republic of the Congo','Denmark','Djibouti','Dominica','Dominican Republic','East Timor','Ecuador','Egypt','El Salvador','Equatorial Guinea','Eritrea','Estonia','Ethiopia','Federated States of Micronesia','Fiji','Finland','France','Gabon','Georgia','Germany','Ghana','Greece','Grenada','Guatemala','Guinea','Guinea-Bissau','Guyana','Haiti','Honduras','Hong Kong','Hungary','Iceland','India','Indonesia','Iran','Iraq','Israel','Italy','Jamaica','Japan','Jordan','Kazakhstan','Kenya','Kingdom of the Netherlands','Kiribati','Kuwait','Kyrgyzstan','Laos','Latvia','Lebanon','Lesotho','Liberia','Libya','Liechtenstein','Lithuania','Luxembourg','Macedonia','Madagascar','Malawi','Malaysia','Maldives','Mali','Malta','Marshall Islands','Mauritania','Mauritius','Mexico','Moldova','Monaco','Mongolia','Montenegro','Morocco','Mozambique','Myanmar','Namibia','Nauru','Nepal','New Zealand','Nicaragua','Niger','Nigeria','North Korea','Norway','Oman','Pakistan','Palau','Panama','Papua New Guinea','Paraguay',"China",'Peru','Philippines','Poland','Portugal','Qatar','Republic of Ireland','Republic of the Congo','Romania','Russia','Rwanda','Saint Kitts and Nevis','Saint Lucia','Saint Vincent and the Grenadines','Samoa','San Marino','Saudi Arabia','Senegal','Serbia','Seychelles','Sierra Leone','Singapore','Slovakia','Slovenia','Solomon Islands','Somalia','South Africa','South Korea','Spain','Sri Lanka','Sudan','Suriname','Swaziland','Sweden','Switzerland','Syria','S\xc3\xa3o Tom\xc3\xa9 and Pr\xc3\xadncipe','Tajikistan','Tanzania','Thailand','The Gambia','Togo','Tonga','Trinidad and Tobago','Tunisia','Turkey','Turkmenistan','Tuvalu','Uganda','Ukraine','United Arab Emirates','United Kingdom','United States','Uruguay','Uzbekistan','Vanuatu','Vatican City','Venezuela','Vietnam','Yemen','Zambia','Zimbabwe'],timezone_dict:{'Afghanistan':['Asia/Kabul'],'Albania':['Europe/Tirane'],'Algeria':['Africa/Algiers'],'Andorra':['Europe/Andorra'],'Angola':['Africa/Luanda'],'Antigua and Barbuda':['America/Antigua'],'Argentina':['America/Argentina/Buenos_Aires','America/Argentina/Cordoba','America/Argentina/Jujuy','America/Argentina/Tucuman','America/Argentina/Catamarca','America/Argentina/La_Rioja','America/Argentina/San_Juan','America/Argentina/Mendoza','America/Argentina/Rio_Gallegos','America/Argentina/Ushuaia'],'Armenia':['Asia/Yerevan'],'Australia':['Australia/Lord_Howe','Australia/Hobart','Australia/Currie','Australia/Melbourne','Australia/Sydney','Australia/Broken_Hill','Australia/Brisbane','Australia/Lindeman','Australia/Adelaide','Australia/Darwin','Australia/Perth'],'Austria':['Europe/Vienna'],'Azerbaijan':['Asia/Baku'],'Bahamas':['America/Nassau'],'Bahrain':['Asia/Bahrain'],'Bangladesh':['Asia/Dhaka'],'Barbados':['America/Barbados'],'Belarus':['Europe/Minsk'],'Belgium':['Europe/Brussels'],'Belize':['America/Belize'],'Benin':['Africa/Porto-Novo'],'Bhutan':['Asia/Thimphu'],'Bolivia':['America/La_Paz'],'Bosnia and Herzegovina':['Europe/Sarajevo'],'Botswana':['Africa/Gaborone'],'Brazil':['America/Noronha','America/Belem','America/Fortaleza','America/Recife','America/Araguaina','America/Maceio','America/Bahia','America/Sao_Paulo','America/Campo_Grande','America/Cuiaba','America/Porto_Velho','America/Boa_Vista','America/Manaus','America/Eirunepe','America/Rio_Branco'],'Brunei Darussalam':['Asia/Brunei'],'Bulgaria':['Europe/Sofia'],'Burkina Faso':['Africa/Ouagadougou'],'Burundi':['Africa/Bujumbura'],'Cambodia':['Asia/Phnom_Penh'],'Cameroon':['Africa/Douala'],'Canada':['America/St_Johns','America/Halifax','America/Glace_Bay','America/Moncton','America/Goose_Bay','America/Blanc-Sablon','America/Montreal','America/Toronto','America/Nipigon','America/Thunder_Bay','America/Pangnirtung','America/Iqaluit','America/Atikokan','America/Rankin_Inlet','America/Winnipeg','America/Rainy_River','America/Cambridge_Bay','America/Regina','America/Swift_Current','America/Edmonton','America/Yellowknife','America/Inuvik','America/Dawson_Creek','America/Vancouver','America/Whitehorse','America/Dawson'],'Cape Verde':['Atlantic/Cape_Verde'],'Central African Republic':['Africa/Bangui'],'Chad':['Africa/Ndjamena'],'China':['Asia/Shanghai','Asia/Harbin','Asia/Chongqing','Asia/Urumqi','Asia/Kashgar'],'Chile':['America/Santiago','Pacific/Easter'],'Colombia':['America/Bogota'],'Comoros':['Indian/Comoro'],'Costa Rica':['America/Costa_Rica'],'Croatia':['Europe/Zagreb'],'Cuba':['America/Havana'],'Cyprus':['Asia/Nicosia'],'Czech Republic':['Europe/Prague'],"C\xc3\xb4te d'Ivoire":['Africa/Abidjan'],'Democratic Republic of the Congo':['Africa/Kinshasa','Africa/Lubumbashi'],'Denmark':['Europe/Copenhagen'],'Djibouti':['Africa/Djibouti'],'Dominica':['America/Dominica'],'Dominican Republic':['America/Santo_Domingo'],'East Timor':['Asia/Dili'],'Ecuador':['America/Guayaquil','Pacific/Galapagos'],'Egypt':['Africa/Cairo'],'El Salvador':['America/El_Salvador'],'Equatorial Guinea':['Africa/Malabo'],'Eritrea':['Africa/Asmera'],'Estonia':['Europe/Tallinn'],'Ethiopia':['Africa/Addis_Ababa'],'Federated States of Micronesia':['Pacific/Truk','Pacific/Ponape','Pacific/Kosrae'],'Fiji':['Pacific/Fiji'],'Finland':['Europe/Helsinki'],'France':['Europe/Paris'],'Gabon':['Africa/Libreville'],'Georgia':['Asia/Tbilisi'],'Germany':['Europe/Berlin'],'Ghana':['Africa/Accra'],'Greece':['Europe/Athens'],'Grenada':['America/Grenada'],'Guatemala':['America/Guatemala'],'Guinea':['Africa/Conakry'],'Guinea-Bissau':['Africa/Bissau'],'Guyana':['America/Guyana'],'Haiti':['America/Guatemala'],'Honduras':['America/Tegucigalpa'],'Hong Kong':['Asia/Hong_Kong'],'Hungary':['Europe/Budapest'],'Iceland':['Atlantic/Reykjavik'],'India':['Asia/Calcutta'],'Indonesia':['Asia/Jakarta','Asia/Pontianak','Asia/Makassar','Asia/Jayapura'],'Iran':['Asia/Tehran'],'Iraq':['Asia/Baghdad'],'Israel':['Asia/Jerusalem'],'Italy':['Europe/Rome'],'Jamaica':['America/Jamaica'],'Japan':['Asia/Tokyo'],'Jordan':['Asia/Amman'],'Kazakhstan':['Asia/Almaty','Asia/Qyzylorda','Asia/Aqtobe','Asia/Aqtau','Asia/Oral'],'Kenya':['Africa/Nairobi'],'Kingdom of the Netherlands':['Europe/Amsterdam'],'Kiribati':['Pacific/Tarawa','Pacific/Enderbury','Pacific/Kiritimati'],'Kuwait':['Asia/Kuwait'],'Kyrgyzstan':['Asia/Bishkek'],'Laos':['Asia/Vientiane'],'Latvia':['Europe/Riga'],'Lebanon':['Asia/Beirut'],'Lesotho':['Africa/Maseru'],'Liberia':['Africa/Monrovia'],'Libya':['Africa/Tripoli'],'Liechtenstein':['Europe/Vaduz'],'Lithuania':['Europe/Vilnius'],'Luxembourg':['Europe/Luxembourg'],'Macedonia':['Europe/Skopje'],'Madagascar':['Indian/Antananarivo'],'Malawi':['Africa/Blantyre'],'Malaysia':['Asia/Kuala_Lumpur','Asia/Kuching'],'Maldives':['Indian/Maldives'],'Mali':['Africa/Bamako'],'Malta':['Europe/Malta'],'Marshall Islands':['Pacific/Majuro','Pacific/Kwajalein'],'Mauritania':['Africa/Nouakchott'],'Mauritius':['Indian/Mauritius'],'Mexico':['America/Mexico_City','America/Cancun','America/Merida','America/Monterrey','America/Mazatlan','America/Chihuahua','America/Hermosillo','America/Tijuana'],'Moldova':['Europe/Chisinau'],'Monaco':['Europe/Monaco'],'Mongolia':['Asia/Ulaanbaatar','Asia/Hovd','Asia/Choibalsan'],'Montenegro':['Europe/Podgorica'],'Morocco':['Africa/Casablanca'],'Mozambique':['Africa/Maputo'],'Myanmar':['Asia/Rangoon'],'Namibia':['Africa/Windhoek'],'Nauru':['Pacific/Nauru'],'Nepal':['Asia/Katmandu'],'New Zealand':['Pacific/Auckland','Pacific/Chatham'],'Nicaragua':['America/Managua'],'Niger':['Africa/Niamey'],'Nigeria':['Africa/Lagos'],'North Korea':['Asia/Pyongyang'],'Norway':['Europe/Oslo'],'Oman':['Asia/Muscat'],'Pakistan':['Asia/Karachi'],'Palau':['Pacific/Palau'],'Panama':['America/Panama'],'Papua New Guinea':['Pacific/Port_Moresby'],'Paraguay':['America/Asuncion'],'Peru':['America/Lima'],'Philippines':['Asia/Manila'],'Poland':['Europe/Warsaw'],'Portugal':['Europe/Lisbon','Atlantic/Madeira','Atlantic/Azores'],'Qatar':['Asia/Qatar'],'Republic of Ireland':['Europe/Dublin'],'Republic of the Congo':['Africa/Brazzaville'],'Romania':['Europe/Bucharest'],'Russia':['Europe/Kaliningrad','Europe/Moscow','Europe/Volgograd','Europe/Samara','Asia/Yekaterinburg','Asia/Omsk','Asia/Novosibirsk','Asia/Krasnoyarsk','Asia/Irkutsk','Asia/Yakutsk','Asia/Vladivostok','Asia/Sakhalin','Asia/Magadan','Asia/Kamchatka','Asia/Anadyr'],'Rwanda':['Africa/Kigali'],'Saint Kitts and Nevis':['America/St_Kitts'],'Saint Lucia':['America/St_Lucia'],'Saint Vincent and the Grenadines':['America/St_Vincent'],'Samoa':['Pacific/Apia'],'San Marino':['Europe/San_Marino'],'Saudi Arabia':['Asia/Riyadh'],'Senegal':['Africa/Dakar'],'Serbia':['Europe/Belgrade'],'Seychelles':['Indian/Mahe'],'Sierra Leone':['Africa/Freetown'],'Singapore':['Asia/Singapore'],'Slovakia':['Europe/Bratislava'],'Slovenia':['Europe/Ljubljana'],'Solomon Islands':['Pacific/Guadalcanal'],'Somalia':['Africa/Mogadishu'],'South Africa':['Africa/Johannesburg'],'South Korea':['Asia/Seoul'],'Spain':['Europe/Madrid','Africa/Ceuta','Atlantic/Canary'],'Sri Lanka':['Asia/Colombo'],'Sudan':['Africa/Khartoum'],'Suriname':['America/Paramaribo'],'Swaziland':['Africa/Mbabane'],'Sweden':['Europe/Stockholm'],'Switzerland':['Europe/Zurich'],'Syria':['Asia/Damascus'],'S\xc3\xa3o Tom\xc3\xa9 and Pr\xc3\xadncipe':['Africa/Sao_Tome'],'Tajikistan':['Asia/Dushanbe'],'Tanzania':['Africa/Dar_es_Salaam'],'Thailand':['Asia/Bangkok'],'The Gambia':['Africa/Banjul'],'Togo':['Africa/Lome'],'Tonga':['Pacific/Tongatapu'],'Trinidad and Tobago':['America/Port_of_Spain'],'Tunisia':['Africa/Tunis'],'Turkey':['Europe/Istanbul'],'Turkmenistan':['Asia/Ashgabat'],'Tuvalu':['Pacific/Funafuti'],'Uganda':['Africa/Kampala'],'Ukraine':['Europe/Kiev','Europe/Uzhgorod','Europe/Zaporozhye','Europe/Simferopol'],'United Arab Emirates':['Asia/Dubai'],'United Kingdom':['Europe/London'],'United States':['America/New_York','America/Detroit','America/Kentucky/Louisville','America/Kentucky/Monticello','America/Indiana/Indianapolis','America/Indiana/Marengo','America/Indiana/Knox','America/Indiana/Vevay','America/Chicago','America/Indiana/Vincennes','America/Indiana/Petersburg','America/Menominee','America/North_Dakota/Center','America/North_Dakota/New_Salem','America/Denver','America/Boise','America/Shiprock','America/Phoenix','America/Los_Angeles','America/Anchorage','America/Juneau','America/Yakutat','America/Nome','America/Adak','Pacific/Honolulu'],'Uruguay':['America/Montevideo'],'Uzbekistan':['Asia/Samarkand','Asia/Tashkent'],'Vanuatu':['Pacific/Efate'],'Vatican City':['Europe/Vatican'],'Venezuela':['America/Caracas'],'Vietnam':['Asia/Saigon'],'Yemen':['Asia/Aden'],'Zambia':['Africa/Lusaka'],'Zimbabwe':['Africa/Harare'],},});
View
10 public/js/gantt_task.js
@@ -1,10 +0,0 @@
-
-/*
- * erpnext/projects/gantt_task.js
- */
-wn.require('js/lib/jQuery.Gantt/css/style.css');wn.require('js/lib/jQuery.Gantt/js/jquery.fn.gantt.min.js');erpnext.show_task_gantt=function(parent,project){$(parent).css('min-height','300px').html('<div class="help-box">Loading...</div>')
-var get_source=function(r){var source=[];$.each(r.message,function(i,v){source.push({name:v.project,desc:v.subject,values:[{label:v.subject,desc:v.description||v.subject,from:'/Date("'+v.exp_start_date+'")/',to:'/Date("'+v.exp_end_date+'")/',customClass:{'Open':'ganttRed','Pending Review':'ganttOrange','Working':'','Completed':'ganttGreen','Cancelled':'ganttGray'}[v.status],dataObj:v}]})});return source}
-wn.call({method:'projects.page.projects.projects.get_tasks',args:{project:project||''},callback:function(r){$(parent).empty();if(!r.message.length){$(parent).html('<div class="help-box">No Tasks Yet.</div>');}else{var gantt_area=$('<div class="gantt">').appendTo(parent);gantt_area.gantt({source:get_source(r),navigate:project?"button":"scroll",scale:"weeks",minScale:"weeks",maxScale:"months",onItemClick:function(data){wn.set_route('Form','Task',data.name);},onAddClick:function(dt,rowId){newdoc('Task');}});}
-$('<button class="btn"><i class="icon icon-plus"></i>\
- Create a new Task</button>').click(function(){wn.model.with_doctype('Task',function(){var new_name=LocalDB.create('Task');if(project)
-locals.Task[new_name].project=project;wn.set_route('Form','Task',new_name);});}).appendTo(parent);}})}
View
30 public/js/kb_common.js
@@ -1,30 +0,0 @@
-
-/*
- * erpnext/utilities/page/kb_common/kb_common.js
- */
-KBItemToolbar=function(args,kb){$.extend(this,args);var me=this;this.make=function(){this.wrapper=$a(this.parent,'div','',{});this.line1=$a(this.wrapper,'div','',{color:'#888',fontSize:'11px',margin:'7px 0px'});this.make_timestamp();this.make_answers();if(this.with_tags)
-this.make_tags();this.setup_del();}
-this.make_timestamp=function(){this.line1.innerHTML=repl('By %(name)s | %(when)s',{name:wn.utils.full_name(this.det.first_name,this.det.last_name),when:wn.datetime.comment_when(this.det.modified)});if(has_common(user_roles,['Administrator','System Manager'])){this.line1.innerHTML+=' | <a style="cursor:pointer;"\
- class="del-link">delete</a>';}}
-this.make_answers=function(){if(this.doctype=='Question'){if(this.det.answers==0){this.line1.innerHTML+=' | no answers';}else if(this.det.answers==1){this.line1.innerHTML+=' | 1 answer';}else{this.line1.innerHTML+=' | '+this.det.answers+' answers';}}}
-this.make_tags=function(){this.line1.innerHTML+=' | '
-this.tags_area=$a(this.line1,'span','kb-tags')
-this.tags=new TagList(this.tags_area,this.det._user_tags&&(this.det._user_tags.split(',')),this.doctype,this.det.name,0,kb.set_tag_filter)}
-this.setup_del=function(){$(this.line1).find('.del-link').click(function(){console.log(1);this.innerHTML='deleting...';this.disabled=1;$c_page('utilities','questions','delete',{dt:me.doctype,dn:me.det.name},function(r,rt){kb.list.run()});});}
-this.make();}
-EditableText=function(args){$.extend(this,args);var me=this;me.$w=$(repl('<div class="ed-text">\
- <div class="ed-text-display %(disp_class)s"></div>\
- <a class="ed-text-edit" style="cursor: pointer; float: right; margin-top: -16px;">[edit]</a>\
- <textarea class="ed-text-input %(inp_class)s hide"></textarea>\
- <div class="help hide"><br>Formatted as <a href="#markdown-reference"\
- target="_blank">markdown</a></div>\
- <button class="btn btn-small btn-info hide ed-text-save">Save</button>\
- <a class="ed-text-cancel hide" style="cursor: pointer;">Cancel</a>\
- </div>',args)).appendTo(me.parent);this.set_display=function(txt){me.$w.find('.ed-text-display').html(wn.markdown(txt));me.text=txt;}
-this.set_display(me.text);if(me.height)me.$w.find('.ed-text-input').css('height',me.height);me.$w.find('.ed-text-edit').click(function(){me.$w.find('.ed-text-input').val(me.text);me.show_as_input();})
-me.$w.find('.ed-text-save').click(function(){var v=me.$w.find('.ed-text-input').val();if(!v){msgprint('Please write something!');return;}
-var btn=this;$(btn).set_working();$c_page('utilities','question_view','update_item',{dt:me.dt,dn:me.dn,fn:me.fieldname,text:v},function(r){$(btn).done_working();if(r.exc){msgprint(r.exc);return;}
-me.set_display(v);me.show_as_text();});})
-me.$w.find('.ed-text-cancel').click(function(){me.show_as_text();})
-this.show_as_text=function(){me.$w.find('.ed-text-display, .ed-text-edit').toggle(true);me.$w.find('.ed-text-input, .ed-text-save, .ed-text-cancel, .help').toggle(false);}
-this.show_as_input=function(){me.$w.find('.ed-text-display, .ed-text-edit').toggle(false);me.$w.find('.ed-text-input, .ed-text-save, .ed-text-cancel, .help').toggle(true);}}
View
4 public/js/listing.js
@@ -11,13 +11,9 @@ if(!this.opts.hide_refresh){make_btn('Refresh','ui-icon-refresh',function(btn){m
if(this.opts.show_new){make_btn('New ','ui-icon-document',function(){new_doc(me.dt);},1);}
if(this.opts.show_report){make_btn('Report Builder','ui-icon-clipboard',function(){loadreport(me.dt,null,null,null,1);},0);}
if(!this.opts.hide_export){make_btn('Export','ui-icon-circle-arrow-e',function(){me.do_export();});}
-if(!this.opts.hide_print){make_btn('Print','ui-icon-print',function(){me.do_print();});}
if(this.opts.show_calc){make_btn('Calc','ui-icon-calculator',function(){me.do_calc();});$dh(me.buttons['Calc'])}
this.loading_img=$a(this.btn_area,'img','',{display:'none',marginBottom:'-2px'});this.loading_img.src='images/lib/ui/button-load.gif';if(!keys(this.buttons).length)
$dh(this.btn_area);}
-Listing.prototype.do_print=function(){this.build_query();if(!this.query){alert('No Query!');return;}
-args={query:this.query,title:this.head_text,colnames:this.colnames,colwidths:this.colwidths,coltypes:this.coltypes,has_index:(this.no_index?0:1),has_headings:1,check_limit:1,is_simple:1}
-wn.require('js/print_query.js');_p.print_query=new _p.PrintQuery();_p.print_query.show_dialog(args);}
Listing.prototype.do_calc=function(){show_calc(this.result_tab,this.colnames,this.coltypes,0)}
Listing.prototype.add_filter=function(label,ftype,options,tname,fname,cond){if(!this.filter_area){alert('[Listing] make() must be called before add_filter');}
var me=this;if(!this.filter_set){var h=$a(this.filter_area,'div','',{fontSize:'14px',fontWeight:'bold',marginBottom:'4px'});h.innerHTML='Filter your search';this.filter_area.div=$a(this.filter_area,'div');this.perm=[[1,1],]
View
41 public/js/print_query.js
@@ -1,41 +0,0 @@
-
-/*
- * lib/js/legacy/widgets/print_query.js
- */
-_p.PrintQuery=function(){this.args={};}
-_p.PrintQuery.prototype.show_dialog=function(args){this.args=args;var me=this;if(!this.dialog){var d=new Dialog(400,300,"Print");d.make_body([['Data','Max rows','Blank to print all rows'],['Data','Rows per page'],['Button','Go'],]);d.widgets['Go'].onclick=function(){d.hide();me.render(cint(d.widgets['Max rows'].value),cint(d.widgets['Rows per page'].value))}
-d.onshow=function(){this.widgets['Rows per page'].value='35';this.widgets['Max rows'].value='500';}
-this.dialog=d;}
-this.dialog.show();}
-_p.PrintQuery.prototype.render=function(max_rows,page_len){var me=this;var args=me.args;if(cint(max_rows)!=0)args.query+=' LIMIT 0,'+cint(max_rows);if(!args.query)return;var callback=function(r,rt){if(!r.values){return;}
-if(!page_len)page_len=r.values.length;if(r.colnames&&r.colnames.length)
-args.colnames=args.has_index?add_lists(['Sr'],r.colnames):r.colnames;if(r.colwidths&&r.colwidths.length)
-args.colwidths=args.has_index?add_lists(['25px'],r.colwidths):r.colwidths;if(r.coltypes)
-args.coltypes=args.has_index?add_lists(['Data'],r.coltypes):r.coltypes;if(args.coltypes){for(var i in args.coltypes)
-if(args.coltypes[i]=='Link')args.coltypes[i]='Data';}
-if(args.colwidths){var tw=0;for(var i=0;i<args.colwidths.length;i++)tw+=cint(args.colwidths[i]?args.colwidths[i]:100);for(var i=0;i<args.colwidths.length;i++)args.colwidths[i]=cint(cint(args.colwidths[i]?args.colwidths[i]:100)/tw*100)+'%';}
-var has_heading=args.colnames?1:0;if(!args.has_headings)has_heading=0;var tl=[]
-for(var st=0;st<r.values.length;st=st+page_len){tl.push(me.build_table(r,st,page_len,has_heading,args.rb))}
-var html='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">'
-+'<html><head>'
-+'<title>'+args.title+'</title>'
-+'<style>'+_p.def_print_style_body+_p.def_print_style_other+'</style>'
-+'</head><body>'
-+(r.header_html?r.header_html:'')
-+tl.join('\n<div style="page-break-after: always;"></div>\n')
-+(r.footer_html?r.footer_html:'')
-+'</body></html>';_p.preview(html);}
-var out_args=copy_dict(args);if(args.is_simple){out_args.simple_query=args.query;delete out_args.query;}
-if(args.filter_values)
-out_args.filter_values=args.filter_values;$c('webnotes.widgets.query_builder.runquery',out_args,callback);}
-_p.PrintQuery.prototype.build_table=function(r,start,page_len,has_heading,rb){var div=document.createElement('div');if(!r.page_template){var head=$a(div,'div',null,{fontSize:'20px',fontWeight:'bold',margin:'16px 0px',borderBottom:'1px solid #CCC',paddingBottom:'8px'});head.innerHTML=args.title;}
-var m=start+page_len;if(m>r.values.length)m=r.values.length
-var t=make_table(div,m+has_heading-start,r.values[0].length+args.has_index,'100%',null);t.className='simpletable';if(args.colwidths)
-$y(t,{tableLayout:'fixed'});if(has_heading){for(var i=0;i<args.colnames.length;i++){$td(t,0,i).innerHTML=args.colnames[i].bold();if(args.colwidths&&args.colwidths[i]){$w($td(t,0,i),args.colwidths[i]);}}}
-for(var ri=start;ri<m;ri++){if(args.has_index)
-$td(t,ri+has_heading-start,0).innerHTML=ri+1;for(var ci=0;ci<r.values[0].length;ci++){if(ri-start==0&&args.colwidths&&args.colwidths[i]){$w($td(t,0,i),args.colwidths[i]);}
-var c=$td(t,ri+has_heading-start,ci+args.has_index)
-c.div=$a(c,'div','',{whiteSpace:'normal'});$s(c.div,r.values[ri][ci],args.coltypes?args.coltypes[ci+args.has_index]:null);}}
-if(r.style){for(var i=0;i<r.style.length;i++){$yt(t,r.style[i][0],r.style[i][1],r.style[i][2]);}}
-if(rb&&rb.aftertableprint){rb.aftertableprint(t);}
-if(r.page_template)return repl(r.page_template,{table:div.innerHTML});else return div.innerHTML;}
View
44 public/js/report-legacy.js
@@ -207,7 +207,7 @@ c.style.color=row.style.color;if(row.style.backgroundColor)
c.style.backgroundColor=row.style.backgroundColor;if(row.style.fontWeight)
c.style.fontWeight=row.style.fontWeight;if(row.style.fontSize)
c.style.fontSize=row.style.fontSize;var w=this.get_col_width(ci);if(w)$w(c,w);c.val=val;var me=this;c.div=$a(c,'div','',{width:(cint(w)-7)+'px'});$s(c.div,val,this.coltypes[ci],this.coloptions[ci])}
-_r.DataTable.prototype.do_print=function(){this._get_query(true);args={query:this.query,title:this.rep_name?this.rep_name:this.dt,colnames:null,colwidhts:null,coltypes:null,has_index:this.has_index,has_headings:this.has_headings,check_limit:1,is_simple:(this.is_simple?'Yes':''),sc_id:(this.search_criteria?this.search_criteria.name:''),filter_values:docstring(this.filter_vals),};wn.require('js/print_query.js');_p.print_query=new _p.PrintQuery();_p.print_query.show_dialog(args);}
+_r.DataTable.prototype.do_print=function(){this._get_query(true);args={query:this.query,title:this.rep_name?this.rep_name:this.dt,colnames:null,colwidhts:null,coltypes:null,has_index:this.has_index,has_headings:this.has_headings,check_limit:1,is_simple:(this.is_simple?'Yes':''),sc_id:(this.search_criteria?this.search_criteria.name:''),filter_values:docstring(this.filter_vals),};_p.print_query=new _p.PrintQuery();_p.print_query.show_dialog(args);}
_r.DataTable.prototype.do_export=function(){this._get_query(true);var me=this;export_query(this.query,function(q){export_csv(q,(me.rep_name?me.rep_name:me.dt),(me.search_criteria?me.search_criteria.name:''),me.is_simple,docstring(me.filter_vals));});}
_r.DataTable.prototype.do_calc=function(){_r.show_calc(this.tab,this.colnames,this.coltypes,1);}
_r.DataTable.prototype.get_col_data=function(colname){var ci=0;if(!this.htab)return[];for(var i=1;i<this.htab.rows[0].cells.length;i++){var hc=this.htab.rows[0].cells[i];if(hc.val==colname){ci=i;break;}}
@@ -233,4 +233,44 @@ cl.push(_r.calc_dialog.colnames[i]);}
if(!cl.length){this.hide();alert("No Numeric Column");return;}
var s=this.widgets['Column'];empty_select(s);add_sel_options(s,cl);if(s.inp)s.inp.value=cl[0];else s.value=cl[0];this.set_calc();}
_r.calc_dialog=d;}
-_r.calc_dialog.datatab=tab;_r.calc_dialog.colnames=colnames;_r.calc_dialog.coltypes=coltypes;_r.calc_dialog.show();}
+_r.calc_dialog.datatab=tab;_r.calc_dialog.colnames=colnames;_r.calc_dialog.coltypes=coltypes;_r.calc_dialog.show();}
+/*
+ * lib/js/legacy/widgets/print_query.js
+ */
+_p.PrintQuery=function(){this.args={};}
+_p.PrintQuery.prototype.show_dialog=function(args){this.args=args;var me=this;if(!this.dialog){var d=new Dialog(400,300,"Print");d.make_body([['Data','Max rows','Blank to print all rows'],['Data','Rows per page'],['Button','Go'],]);d.widgets['Go'].onclick=function(){d.hide();me.render(cint(d.widgets['Max rows'].value),cint(d.widgets['Rows per page'].value))}
+d.onshow=function(){this.widgets['Rows per page'].value='35';this.widgets['Max rows'].value='500';}
+this.dialog=d;}
+this.dialog.show();}
+_p.PrintQuery.prototype.render=function(max_rows,page_len){var me=this;var args=me.args;if(cint(max_rows)!=0)args.query+=' LIMIT 0,'+cint(max_rows);if(!args.query)return;var callback=function(r,rt){if(!r.values){return;}
+if(!page_len)page_len=r.values.length;if(r.colnames&&r.colnames.length)
+args.colnames=args.has_index?add_lists(['Sr'],r.colnames):r.colnames;if(r.colwidths&&r.colwidths.length)
+args.colwidths=args.has_index?add_lists(['25px'],r.colwidths):r.colwidths;if(r.coltypes)
+args.coltypes=args.has_index?add_lists(['Data'],r.coltypes):r.coltypes;if(args.coltypes){for(var i in args.coltypes)
+if(args.coltypes[i]=='Link')args.coltypes[i]='Data';}
+if(args.colwidths){var tw=0;for(var i=0;i<args.colwidths.length;i++)tw+=cint(args.colwidths[i]?args.colwidths[i]:100);for(var i=0;i<args.colwidths.length;i++)args.colwidths[i]=cint(cint(args.colwidths[i]?args.colwidths[i]:100)/tw*100)+'%';}
+var has_heading=args.colnames?1:0;if(!args.has_headings)has_heading=0;var tl=[]
+for(var st=0;st<r.values.length;st=st+page_len){tl.push(me.build_table(r,st,page_len,has_heading,args.rb))}
+var html='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">'
++'<html><head>'
++'<title>'+args.title+'</title>'
++'<style>'+_p.def_print_style_body+_p.def_print_style_other+'</style>'
++'</head><body>'
++(r.header_html?r.header_html:'')
++tl.join('\n<div style="page-break-after: always;"></div>\n')
++(r.footer_html?r.footer_html:'')
++'</body></html>';_p.preview(html);}
+var out_args=copy_dict(args);if(args.is_simple){out_args.simple_query=args.query;delete out_args.query;}
+if(args.filter_values)
+out_args.filter_values=args.filter_values;$c('webnotes.widgets.query_builder.runquery',out_args,callback);}
+_p.PrintQuery.prototype.build_table=function(r,start,page_len,has_heading,rb){var div=document.createElement('div');if(!r.page_template){var head=$a(div,'div',null,{fontSize:'20px',fontWeight:'bold',margin:'16px 0px',borderBottom:'1px solid #CCC',paddingBottom:'8px'});head.innerHTML=args.title;}
+var m=start+page_len;if(m>r.values.length)m=r.values.length
+var t=make_table(div,m+has_heading-start,r.values[0].length+args.has_index,'100%',null);t.className='simpletable';if(args.colwidths)
+$y(t,{tableLayout:'fixed'});if(has_heading){for(var i=0;i<args.colnames.length;i++){$td(t,0,i).innerHTML=args.colnames[i].bold();if(args.colwidths&&args.colwidths[i]){$w($td(t,0,i),args.colwidths[i]);}}}
+for(var ri=start;ri<m;ri++){if(args.has_index)
+$td(t,ri+has_heading-start,0).innerHTML=ri+1;for(var ci=0;ci<r.values[0].length;ci++){if(ri-start==0&&args.colwidths&&args.colwidths[i]){$w($td(t,0,i),args.colwidths[i]);}
+var c=$td(t,ri+has_heading-start,ci+args.has_index)
+c.div=$a(c,'div','',{whiteSpace:'normal'});$s(c.div,r.values[ri][ci],args.coltypes?args.coltypes[ci+args.has_index]:null);}}
+if(r.style){for(var i=0;i<r.style.length;i++){$yt(t,r.style[i][0],r.style[i][1],r.style[i][2]);}}
+if(rb&&rb.aftertableprint){rb.aftertableprint(t);}
+if(r.page_template)return repl(r.page_template,{table:div.innerHTML});else return div.innerHTML;}
Please sign in to comment.
Something went wrong with that request. Please try again.