From cfb5466d302750bf55d5fbceaa2a6860066bd7d5 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Fri, 14 Sep 2012 18:12:17 +0530 Subject: [PATCH 1/4] added export to reports using downloadify --- .../page/general_ledger/general_ledger.js | 90 ++++++++++++------- .../home/page/attributions/attributions.html | 1 + erpnext/startup/report_data_map.py | 4 +- public/css/all-app.css | 12 +++ public/css/all-web.css | 12 +++ public/js/all-app.js | 35 ++++++-- public/js/all-web.js | 14 +-- 7 files changed, 116 insertions(+), 52 deletions(-) diff --git a/erpnext/accounts/page/general_ledger/general_ledger.js b/erpnext/accounts/page/general_ledger/general_ledger.js index d395612816..3a17f5c0f8 100644 --- a/erpnext/accounts/page/general_ledger/general_ledger.js +++ b/erpnext/accounts/page/general_ledger/general_ledger.js @@ -6,60 +6,82 @@ wn.pages['general-ledger'].onload = function(wrapper) { }); erpnext.general_ledger = new wn.views.GridReport({ + title: "General Ledger", parent: $(wrapper).find('.layout-main'), appframe: wrapper.appframe, doctypes: ["Company", "Account", "GL Entry"], - filters: [ - {fieldtype:"Select", label: "Company", options:"Company", - filter: function(val, item) { - return item.company == val || val == "Select Company"; - }}, - {fieldtype:"Select", label: "Account", options:"Account", - filter: function(val, item) { - return item.account == val || val == "Select Account"; - }}, - {fieldtype:"Date", label: "From Date"}, - {fieldtype:"Label", label: "To"}, - {fieldtype:"Date", label: "To Date"}, - {fieldtype:"Button", label: "Refresh"}, - ], setup: function() { this.setup_filters(); this.setup_columns(); }, - setup_filters: function() { - var me = this; - // default filters - this.filter_inputs.company.val(sys_defaults.company); - 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)); - this.filter_inputs.refresh.click(function() { me.refresh(); }) - }, setup_columns: function() { this.columns = [ {id: "posting_date", name: "Posting Date", field: "posting_date", width: 100, formatter: this.date_formatter}, - {id: "account", name: "Account", field: "account", width: 240}, + {id: "account", name: "Account", field: "account", width: 240, + link_formatter: { + filter_input: "account", + open_btn: true, + doctype: '"Account"' + }}, {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: "voucher_type", name: "Voucher Type", field: "voucher_type", width: 120}, + {id: "voucher_no", name: "Voucher No", field: "voucher_no", width: 160, + link_formatter: { + filter_input: "voucher_no", + open_btn: true, + doctype: "dataContext.voucher_type" + }}, + {id: "remarks", name: "Remarks", field: "remarks", width: 200, + formatter: this.text_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; + }}, + {fieldtype:"Select", label: "Account", options:"Account", default_value: "Select Account...", + filter: function(val, item, opts) { + return item.account == val || val == opts.default_value; + }}, + {fieldtype:"Data", label: "Voucher No", + filter: function(val, item, opts) { + if(!val) return true; + return item.voucher_no.indexOf(val)!=-1; + }}, + {fieldtype:"Date", label: "From Date", filter: function(val, item) { + return dateutil.user_to_obj(val) <= dateutil.str_to_obj(item.posting_date); + }}, + {fieldtype:"Label", label: "To"}, + {fieldtype:"Date", label: "To Date", filter: function(val, item) { + return dateutil.user_to_obj(val) >= dateutil.str_to_obj(item.posting_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(); }) + }, + 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)); + this.filter_inputs.to_date.val(dateutil.str_to_user(sys_defaults.year_end_date)); + this.filter_inputs.voucher_no.val(""); + this.filter_inputs.account.get(0).selectedIndex = 0; + }, prepare_data: function() { this.prepare_data_view(wn.report_dump.data["GL Entry"]); }, - 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)) { - return false; - } - } - return true; - }, }); - + } diff --git a/erpnext/home/page/attributions/attributions.html b/erpnext/home/page/attributions/attributions.html index 63919d0a29..9952908eda 100644 --- a/erpnext/home/page/attributions/attributions.html +++ b/erpnext/home/page/attributions/attributions.html @@ -43,6 +43,7 @@
  • JQuery.Gantt - Gantt Chart
  • JSON2 - JSON builder, parser
  • JSColor - color picker
  • +
  • Downloadify - Export CSV files from the browser
  • diff --git a/erpnext/startup/report_data_map.py b/erpnext/startup/report_data_map.py index aa23ade521..1811aaaec5 100644 --- a/erpnext/startup/report_data_map.py +++ b/erpnext/startup/report_data_map.py @@ -22,9 +22,9 @@ data_map = { }, "GL Entry": { "columns": ["account", "posting_date", "cost_center", "debit", "credit", "is_opening", - "company"], + "company", "voucher_type", "voucher_no", "remarks"], "conditions": ["ifnull(is_cancelled, 'No')='No'"], - "order_by": "posting_date" + "order_by": "posting_date, account" }, "Company": { "columns": ["name"], diff --git a/public/css/all-app.css b/public/css/all-app.css index 957a8756cf..3d9ba3c0b8 100644 --- a/public/css/all-app.css +++ b/public/css/all-app.css @@ -3536,6 +3536,18 @@ div.appframe-toolbar { border-bottom: 1px solid #ccc; } +div.appframe-toolbar .label { + margin: 2px 2px; +} + +div.appframe-toolbar input, div.appframe-toolbar select { + font-size: 80%; + margin: 2px 2px; +} +div.appframe-toolbar button { + padding: 3px 7px !important; +} + /* diff --git a/public/css/all-web.css b/public/css/all-web.css index fd46111623..e38859e62a 100644 --- a/public/css/all-web.css +++ b/public/css/all-web.css @@ -2570,6 +2570,18 @@ div.appframe-toolbar { border-bottom: 1px solid #ccc; } +div.appframe-toolbar .label { + margin: 2px 2px; +} + +div.appframe-toolbar input, div.appframe-toolbar select { + font-size: 80%; + margin: 2px 2px; +} +div.appframe-toolbar button { + padding: 3px 7px !important; +} + /* diff --git a/public/js/all-app.js b/public/js/all-app.js index 247b7cc263..60a4393b9e 100644 --- a/public/js/all-app.js +++ b/public/js/all-app.js @@ -179,7 +179,7 @@ $(ele).css('-box-shadow','0px 0px '+spread+'px rgba(0,0,0,0.3);')};(function($){ this.selectedIndex=0;return $(this);} $.fn.set_working=function(){var ele=this.get(0);$(ele).attr('disabled','disabled');if(ele.loading_img){$(ele.loading_img).toggle(true);}else{ele.loading_img=$('').insertAfter(ele);}} -$.fn.done_working=function(){var ele=this.get(0);$(ele).attr('disabled',null);if(ele.loading_img){$(ele.loading_img).toggle(false);};}})(jQuery); +$.fn.done_working=function(){var ele=this.get(0);$(ele).attr('disabled',null);if(ele.loading_img){$(ele.loading_img).toggle(false);};}})(jQuery);wn.to_csv=function(data){var res=[];$.each(data,function(i,row){row=$.map(row,function(col){return typeof(col)==="string"?('"'+col.replace(/"/g,'\"')+'"'):col;});res.push(row.join(","));});return res.join("\n");} /* * lib/js/wn/model.js */ @@ -356,8 +356,9 @@ $(page).bind('show',onshow);if(onshow) $(page).bind('hide',onhide);page.label=label;wn.pages[label]=page;return page;},change_to:function(label){if(this.page&&this.page.label==label){return;} var me=this;if(label.tagName){var page=label;}else{var page=wn.pages[label];} if(!page){console.log('Page not found '+label);return;} -if(this.page){$(this.page).toggle(false);$(this.page).trigger('hide');} -this.page=page;$(this.page).fadeIn();this.page._route=window.location.hash;document.title=this.page.label;$(this.page).trigger('show');scroll(0,0);return this.page;}});wn.views.add_module_btn=function(parent,module){$(parent).append(repl('\ %(module)s Home\ ',{module:module,module_small:module.toLowerCase()}));} @@ -393,8 +394,7 @@ msgprint(r.server_messages);} if(r.exc){r.exc=JSON.parse(r.exc);if(r.exc instanceof Array){$.each(r.exc,function(i,v){if(v)console.log(v);})}else{console.log(r.exc);}};if(r['403']){wn.container.change_to('403');} if(r.docs){LocalDB.sync(r.docs);}} wn.request.call=function(opts){wn.request.prepare(opts);var ajax_args={url:opts.url||wn.request.url,data:opts.args,type:opts.type||'POST',dataType:opts.dataType||'json',success:function(r,xhr){wn.request.cleanup(opts,r);opts.success&&opts.success(r,xhr.responseText);},error:function(xhr,textStatus){wn.request.cleanup(opts,{});show_alert('Unable to complete request: '+textStatus) -opts.error&&opts.error(xhr)}};if(opts.progress_bar){var interval=null;$.extend(ajax_args,{xhr:function(){var xhr=jQuery.ajaxSettings.xhr();interval=setInterval(function(){if(xhr.readyState>2){var total=parseInt(xhr.getResponseHeader('Original-Length')||0)||parseInt(xhr.getResponseHeader('Content-Length'));var completed=parseInt(xhr.responseText.length);var percent=(100.0/total*completed).toFixed(2) -opts.progress_bar.css('width',(percent<10?10:percent)+'%');}},50);wn.last_xhr=xhr;return xhr;},complete:function(){opts.progress_bar.css('width','100%');clearInterval(interval);}})} +opts.error&&opts.error(xhr)}};if(opts.progress_bar){var interval=null;$.extend(ajax_args,{xhr:function(){var xhr=jQuery.ajaxSettings.xhr();interval=setInterval(function(){if(xhr.readyState>2){var total=parseInt(xhr.getResponseHeader('Original-Length')||0)||parseInt(xhr.getResponseHeader('Content-Length'));var completed=parseInt(xhr.responseText.length);var percent=(100.0/total*completed).toFixed(2);opts.progress_bar.css('width',(percent<10?10:percent)+'%');}},50);wn.last_xhr=xhr;return xhr;},complete:function(){opts.progress_bar.css('width','100%');clearInterval(interval);}})} $.ajax(ajax_args);} wn.call=function(opts){var args=$.extend({},opts.args) if(opts.module&&opts.page){args.cmd=opts.module+'.page.'+opts.page+'.'+opts.page+'.'+opts.method}else if(opts.method){args.cmd=opts.method;} @@ -609,7 +609,7 @@ msg=JSON.stringify(msg);if(msg.substr(0,8)=='__small:'){show_alert(msg.substr(8) if(!msg_dialog){msg_dialog=new wn.ui.Dialog({title:"Message",onhide:function(){msg_dialog.msg_area.empty();}});msg_dialog.msg_area=$('
    ').appendTo(msg_dialog.body);} if(msg.search(/
    |

    |

  • /)==-1) msg=replace_newlines(msg);msg_dialog.set_title(title||'Message') -msg_dialog.msg_area.append(msg);msg_dialog.show();} +msg_dialog.msg_area.append(msg);msg_dialog.show();return msg_dialog;} var growl_area;function show_alert(txt,id){if(!growl_area){if(!$('#dialog-container').length){$('
    ').appendTo('body');} growl_area=$a($i('dialog-container'),'div','',{position:'fixed',bottom:'8px',right:'8px',width:'320px',zIndex:10});} var wrapper=$a(growl_area,'div','',{position:'relative'});var body=$a(wrapper,'div','notice');var c=$a(body,'i','icon-remove-sign',{cssFloat:'right',cursor:'pointer'});$(c).click(function(){$dh(this.wrapper)});c.wrapper=wrapper;var t=$a(body,'div','',{color:'#FFF'});$(t).html(txt);if(id){$(t).attr('id',id);} @@ -854,7 +854,7 @@ this.buttons[label]=$(repl('',args)).click(click).appendTo(this.toolbar);return this.buttons[label];},add_help_button:function(txt){this.make_toolbar();$('',args)).click(click).appendTo(this.toolbar);return this.buttons[label];},add_help_button:function(txt){this.add_toolbar();$('').data('help-text',txt).click(function(){msgprint($(this).data('help-text'),'Help');}).appendTo(this.toolbar);},clear_buttons:function(){this.toolbar&&this.toolbar.empty();},add_breadcrumb:function(html){if(!this.$breadcrumbs) this.$breadcrumbs=$('\ ').appendTo(this.$titlebar);var crumb=$('').html(html);if(!this.$breadcrumbs.find('span').length){crumb.addClass('appframe-title');} -crumb.appendTo(this.$breadcrumbs);},clear_breadcrumbs:function(){this.$breadcrumbs&&this.$breadcrumbs.empty();},make_toolbar:function(){if(!this.toolbar) +crumb.appendTo(this.$breadcrumbs);},clear_breadcrumbs:function(){this.$breadcrumbs&&this.$breadcrumbs.empty();},add_toolbar:function(){if(!this.toolbar) this.$w.append('
    ');this.toolbar=this.$w.find('.appframe-toolbar');},add_label:function(label){return $(""+label+" ").appendTo(this.toolbar);},add_select:function(label,options){this.add_toolbar();return $("").appendTo(this.toolbar);},add_date:function(label,date){this.add_toolbar();return $("").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('
    \
    \
    \ @@ -1086,10 +1086,11 @@ 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) return encodeURIComponent(opts.fieldname) -+'='+encodeURIComponent(val);}).join('&'))},render:function(){this.waiting.toggle(false);if(!this.grid_wrapper)this.make_grid_wrapper();this.apply_link_formatters();this.prepare_data();this.grid=new Slick.Grid("#"+this.id,this.dataView,this.columns,this.options);this.dataView.onRowsChanged.subscribe(function(e,args){grid.invalidateRows(args.rows);grid.render();});this.dataView.onRowCountChanged.subscribe(function(e,args){grid.updateRowCount();grid.render();});},prepare_data_view:function(items){this.dataView=new Slick.Data.DataView({inlineFilters:true});this.dataView.beginUpdate();this.dataView.setItems(items);this.dataView.setFilter(this.dataview_filter);this.dataView.endUpdate();},export:function(){var me=this;var res=[$.map(this.columns,function(v){return v.name;})];var col_map=$.map(this.columns,function(v){return v.field;});for(var i=0,len=this.dataView.getLength();iYou must have Flash 10 installed to download this file.

    ');Downloadify.create(id,{filename:function(){return me.title+'.csv';},data:function(){return wn.to_csv(res);},swf:'js/lib/downloadify/downloadify.swf',downloadImage:'js/lib/downloadify/download.png',onComplete:function(){msgobj.hide();},onCancel:function(){msgobj.hide();},onError:function(){msgobj.hide();},width:100,height:30,transparent:true,append:false});return false;},options:{editable:false,enableColumnReorder:false},dataview_filter:function(item){var filters=wn.cur_grid_report.filter_inputs;for(i in filters){var filter=filters[i].get(0);if(filter.opts.filter&&!filter.opts.filter($(filter).val(),item,filter.opts)){return false;}} +if(wn.cur_grid_report.custom_dataview_filter){return wn.cur_grid_report.custom_dataview_filter(item);} return true;},date_formatter:function(row,cell,value,columnDef,dataContext){return dateutil.str_to_user(value);},currency_formatter:function(row,cell,value,columnDef,dataContext){return repl('
    %(value)s
    ',{_style:dataContext._style||"",value:fmt_money(value)});},text_formatter:function(row,cell,value,columnDef,dataContext){return repl('%(value)s',{_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('%(value)s',{_style:dataContext._style||"",value:value});} var link_formatter=wn.cur_grid_report.columns[cell].link_formatter;var html=repl('\ ×\
    ').appendTo(this.$w);this.$w.find('.close').click(function(){window.history.back();}) -if(title)this.title(title);},title:function(txt){this.clear_breadcrumbs();this.add_breadcrumb(txt);},add_button:function(label,click,icon){this.make_toolbar();args={label:label,icon:''};if(icon){args.icon='';} +if(title)this.title(title);},title:function(txt){this.clear_breadcrumbs();this.add_breadcrumb(txt);},add_button:function(label,click,icon){this.add_toolbar();args={label:label,icon:''};if(icon){args.icon='';} this.buttons[label]=$(repl('',args)).click(click).appendTo(this.toolbar);return this.buttons[label];},add_help_button:function(txt){this.make_toolbar();$('',args)).click(click).appendTo(this.toolbar);return this.buttons[label];},add_help_button:function(txt){this.add_toolbar();$('').data('help-text',txt).click(function(){msgprint($(this).data('help-text'),'Help');}).appendTo(this.toolbar);},clear_buttons:function(){this.toolbar&&this.toolbar.empty();},add_breadcrumb:function(html){if(!this.$breadcrumbs) this.$breadcrumbs=$('
    \ ').appendTo(this.$titlebar);var crumb=$('').html(html);if(!this.$breadcrumbs.find('span').length){crumb.addClass('appframe-title');} -crumb.appendTo(this.$breadcrumbs);},clear_breadcrumbs:function(){this.$breadcrumbs&&this.$breadcrumbs.empty();},make_toolbar:function(){if(!this.toolbar) +crumb.appendTo(this.$breadcrumbs);},clear_breadcrumbs:function(){this.$breadcrumbs&&this.$breadcrumbs.empty();},add_toolbar:function(){if(!this.toolbar) this.$w.append('
    ');this.toolbar=this.$w.find('.appframe-toolbar');},add_label:function(label){return $(""+label+" ").appendTo(this.toolbar);},add_select:function(label,options){this.add_toolbar();return $("").appendTo(this.toolbar);},add_date:function(label,date){this.add_toolbar();return $("").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('
    \
    \
    \ From 4156523175b9f4b4b8c23af6152b59944c35a24a Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 17 Sep 2012 19:10:36 +0530 Subject: [PATCH 4/4] added flot for graphs in report_grid --- build.json | 9 - .../chart_of_accounts/chart_of_accounts.js | 272 ------------------ .../chart_of_accounts/chart_of_accounts.py | 49 ---- .../chart_of_accounts/chart_of_accounts.txt | 28 -- .../__init__.py | 0 .../financial_analytics.js | 226 +++++++++++++++ .../financial_analytics.txt | 28 ++ .../page/general_ledger/general_ledger.js | 46 +-- .../__init__.py} | 0 .../page/trial_balance/trial_balance.js | 27 ++ .../page/trial_balance/trial_balance.txt | 28 ++ erpnext/projects/page/projects/projects.js | 2 +- erpnext/startup/event_handlers.py | 4 +- erpnext/startup/report_data_map.py | 5 + erpnext/startup/startup.js | 2 +- erpnext/utilities/page/questions/questions.js | 2 +- public/js/all-app.js | 24 +- public/js/all-web.js | 8 +- .../js/app/account_tree_grid.css | 0 public/js/app/account_tree_grid.js | 259 +++++++++++++++++ .../js => public/js/app}/complete_setup.js | 0 .../projects => public/js/app}/gantt_task.js | 0 .../kb_common => public/js/app}/kb_common.js | 0 public/js/complete_setup.js | 10 - public/js/gantt_task.js | 10 - public/js/kb_common.js | 30 -- public/js/listing.js | 4 - public/js/print_query.js | 41 --- public/js/report-legacy.js | 44 ++- 29 files changed, 667 insertions(+), 491 deletions(-) delete mode 100644 erpnext/accounts/page/chart_of_accounts/chart_of_accounts.js delete mode 100644 erpnext/accounts/page/chart_of_accounts/chart_of_accounts.py delete mode 100644 erpnext/accounts/page/chart_of_accounts/chart_of_accounts.txt rename erpnext/accounts/page/{chart_of_accounts => financial_analytics}/__init__.py (100%) create mode 100644 erpnext/accounts/page/financial_analytics/financial_analytics.js create mode 100644 erpnext/accounts/page/financial_analytics/financial_analytics.txt rename erpnext/accounts/page/{chart_of_accounts/chart_of_accounts.html => trial_balance/__init__.py} (100%) create mode 100644 erpnext/accounts/page/trial_balance/trial_balance.js create mode 100644 erpnext/accounts/page/trial_balance/trial_balance.txt rename erpnext/accounts/page/chart_of_accounts/chart_of_accounts.css => public/js/app/account_tree_grid.css (100%) create mode 100644 public/js/app/account_tree_grid.js rename {erpnext/startup/js => public/js/app}/complete_setup.js (100%) rename {erpnext/projects => public/js/app}/gantt_task.js (100%) rename {erpnext/utilities/page/kb_common => public/js/app}/kb_common.js (100%) delete mode 100644 public/js/complete_setup.js delete mode 100644 public/js/gantt_task.js delete mode 100644 public/js/kb_common.js delete mode 100644 public/js/print_query.js diff --git a/build.json b/build.json index 70e00d69aa..420e5f4c25 100644 --- a/build.json +++ b/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", - ] } \ No newline at end of file diff --git a/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.js b/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.js deleted file mode 100644 index 2fb6d9b783..0000000000 --- a/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.js +++ /dev/null @@ -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 . - -/* 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,"&").replace(//g,">"); - var data = erpnext.coa.accounts; - var spacer = ""; - var idx = erpnext.coa.dataView.getIdxById(dataContext.id); - if (data[idx + 1] && data[idx + 1].indent > data[idx].indent) { - if (dataContext._collapsed) { - return spacer + "  " + value; - } else { - return spacer + "  " + value; - } - } else { - return spacer + "  " + value; - } - }, - add_grid_events: function() { - var me = this; - this.grid.onClick.subscribe(function (e, args) { - if ($(e.target).hasClass("toggle")) { - var item = me.dataView.getItem(args.row); - if (item) { - if (!item._collapsed) { - item._collapsed = true; - } else { - item._collapsed = false; - } - - me.dataView.updateItem(item.id, item); - } - e.stopImmediatePropagation(); - } - }); - }, - custom_dataview_filter: function(item) { - if (item.parent_account) { - var parent = item.parent_account; - while (parent) { - if (erpnext.coa.accounts_by_name[parent]._collapsed) { - return false; - } - parent = erpnext.coa.parent_map[parent]; - } - } - return true; - } - }); -} - -erpnext.ChartOfAccounts = Class.extend({ -}); diff --git a/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.py b/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.py deleted file mode 100644 index 59cd460e71..0000000000 --- a/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.py +++ /dev/null @@ -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 diff --git a/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.txt b/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.txt deleted file mode 100644 index e9d5ab5065..0000000000 --- a/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.txt +++ /dev/null @@ -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' - } -] \ No newline at end of file diff --git a/erpnext/accounts/page/chart_of_accounts/__init__.py b/erpnext/accounts/page/financial_analytics/__init__.py similarity index 100% rename from erpnext/accounts/page/chart_of_accounts/__init__.py rename to erpnext/accounts/page/financial_analytics/__init__.py diff --git a/erpnext/accounts/page/financial_analytics/financial_analytics.js b/erpnext/accounts/page/financial_analytics/financial_analytics.js new file mode 100644 index 0000000000..e48ccb4815 --- /dev/null +++ b/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 . + +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("", { + "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(); + }); + } +}) \ No newline at end of file diff --git a/erpnext/accounts/page/financial_analytics/financial_analytics.txt b/erpnext/accounts/page/financial_analytics/financial_analytics.txt new file mode 100644 index 0000000000..834503d1c9 --- /dev/null +++ b/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' + } +] \ No newline at end of file diff --git a/erpnext/accounts/page/general_ledger/general_ledger.js b/erpnext/accounts/page/general_ledger/general_ledger.js index 163306a2f1..7fdf57c517 100644 --- a/erpnext/accounts/page/general_ledger/general_ledger.js +++ b/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; + }) + } }); } diff --git a/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.html b/erpnext/accounts/page/trial_balance/__init__.py similarity index 100% rename from erpnext/accounts/page/chart_of_accounts/chart_of_accounts.html rename to erpnext/accounts/page/trial_balance/__init__.py diff --git a/erpnext/accounts/page/trial_balance/trial_balance.js b/erpnext/accounts/page/trial_balance/trial_balance.js new file mode 100644 index 0000000000..91ab82aa2a --- /dev/null +++ b/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 . + +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'); +} \ No newline at end of file diff --git a/erpnext/accounts/page/trial_balance/trial_balance.txt b/erpnext/accounts/page/trial_balance/trial_balance.txt new file mode 100644 index 0000000000..88b91d62a6 --- /dev/null +++ b/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' + } +] \ No newline at end of file diff --git a/erpnext/projects/page/projects/projects.js b/erpnext/projects/page/projects/projects.js index e67959e7b4..8f91f12fe4 100644 --- a/erpnext/projects/page/projects/projects.js +++ b/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 = $('
    ').appendTo($(wrapper).find('.layout-main')); erpnext.show_task_gantt(gantt_area); diff --git a/erpnext/startup/event_handlers.py b/erpnext/startup/event_handlers.py index c5bcb1b9f6..ffbf11373b 100644 --- a/erpnext/startup/event_handlers.py +++ b/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 diff --git a/erpnext/startup/report_data_map.py b/erpnext/startup/report_data_map.py index f4539382dc..38c2dd25c9 100644 --- a/erpnext/startup/report_data_map.py +++ b/erpnext/startup/report_data_map.py @@ -20,6 +20,11 @@ data_map = { "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"], diff --git a/erpnext/startup/startup.js b/erpnext/startup/startup.js index 67a7486e40..7fb48c12bf 100644 --- a/erpnext/startup/startup.js +++ b/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')) { diff --git a/erpnext/utilities/page/questions/questions.js b/erpnext/utilities/page/questions/questions.js index 22a70d8f41..e2e7ed51da 100644 --- a/erpnext/utilities/page/questions/questions.js +++ b/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'); diff --git a/public/js/all-app.js b/public/js/all-app.js index f32e26e791..5b25f348da 100644 --- a/public/js/all-app.js +++ b/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\ this.$breadcrumbs=$('\ ').appendTo(this.$titlebar);var crumb=$('').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('
    ');this.toolbar=this.$w.find('.appframe-toolbar');},add_label:function(label){return $(""+label+" ").appendTo(this.toolbar);},add_select:function(label,options){this.add_toolbar();return $("").appendTo(this.toolbar);},add_date:function(label,date){this.add_toolbar();return $("").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('
    \ +this.$w.append('
    ');this.toolbar=this.$w.find('.appframe-toolbar');},add_label:function(label){return $(""+label+" ").appendTo(this.toolbar);},add_select:function(label,options){this.add_toolbar();return $("").appendTo(this.toolbar);},add_date:function(label,date){this.add_toolbar();return $("").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('
    \
    \
    \
    ');}else{$(opts.parent).html('
    \ @@ -1072,24 +1072,26 @@ me.list.run();});this.dialog.show();},add_column:function(c){var w=$('
    ').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=$('
    \ +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=$('
    ').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=$('
    \

    Loading Report...

    \
    \ -
    ').appendTo(this.wrapper);},make_grid_wrapper:function(){$('
    \ +
    ').appendTo(this.wrapper);},make_grid_wrapper:function(){$('').appendTo(this.wrapper);$('
    ').appendTo(this.wrapper);this.wrapper.find(".grid-report-export").click(function(){return me.export();});this.grid_wrapper=$("
    ").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){$('').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){$('').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();iYou must have Flash 10 installed to download this file.

    ');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();iYou must have Flash 10 installed to download this file.

    ');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('
    %(value)s
    ',{_style:dataContext._style||"",value:fmt_money(value)});},text_formatter:function(row,cell,value,columnDef,dataContext){return repl('%(value)s',{_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('%(value)s',{_style:dataContext._style||"",value:value});} var link_formatter=wn.cur_grid_report.columns[cell].link_formatter;var html=repl(' \ ' @@ -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('');if(in_list(user_roles,'System Manager')&&(wn.boot.setup_complete=='No')){wn.require("js/complete_setup.js");erpnext.complete_setup.show();} + ERPNext | Attributions and License
    ');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('
    \ Your ERPNext subscription will expire %(expiry_string)s. \ Please renew your subscription to continue using ERPNext \ diff --git a/public/js/all-web.js b/public/js/all-web.js index 7ddc0c83cc..cb25654e02 100644 --- a/public/js/all-web.js +++ b/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\ this.$breadcrumbs=$('\ ').appendTo(this.$titlebar);var crumb=$('').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('
    ');this.toolbar=this.$w.find('.appframe-toolbar');},add_label:function(label){return $(""+label+" ").appendTo(this.toolbar);},add_select:function(label,options){this.add_toolbar();return $("").appendTo(this.toolbar);},add_date:function(label,date){this.add_toolbar();return $("").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('
    \ +this.$w.append('
    ');this.toolbar=this.$w.find('.appframe-toolbar');},add_label:function(label){return $(""+label+" ").appendTo(this.toolbar);},add_select:function(label,options){this.add_toolbar();return $("").appendTo(this.toolbar);},add_date:function(label,date){this.add_toolbar();return $("").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('
    \
    \
    \
    ');}else{$(opts.parent).html('
    \ @@ -699,7 +699,7 @@ if(errfld.length)msgprint('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='\ \ ' @@ -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('');if(in_list(user_roles,'System Manager')&&(wn.boot.setup_complete=='No')){wn.require("js/complete_setup.js");erpnext.complete_setup.show();} + ERPNext | Attributions and License
    ');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('
    \ Your ERPNext subscription will expire %(expiry_string)s. \ Please renew your subscription to continue using ERPNext \ diff --git a/erpnext/accounts/page/chart_of_accounts/chart_of_accounts.css b/public/js/app/account_tree_grid.css similarity index 100% rename from erpnext/accounts/page/chart_of_accounts/chart_of_accounts.css rename to public/js/app/account_tree_grid.css diff --git a/public/js/app/account_tree_grid.js b/public/js/app/account_tree_grid.js new file mode 100644 index 0000000000..c8dd8a5fa3 --- /dev/null +++ b/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 . + +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,"&").replace(//g,">"); + var data = wn.cur_grid_report.accounts; + var spacer = ""; + var idx = wn.cur_grid_report.dataView.getIdxById(dataContext.id); + var account_link = repl('%(value)s', { + value: value, + enc_value: encodeURIComponent(value) + }); + + if (data[idx + 1] && data[idx + 1].indent > data[idx].indent) { + if (dataContext._collapsed) { + return spacer + "  " + account_link; + } else { + return spacer + "  " + account_link; + } + } else { + return spacer + "  " + 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; + } +}); \ No newline at end of file diff --git a/erpnext/startup/js/complete_setup.js b/public/js/app/complete_setup.js similarity index 100% rename from erpnext/startup/js/complete_setup.js rename to public/js/app/complete_setup.js diff --git a/erpnext/projects/gantt_task.js b/public/js/app/gantt_task.js similarity index 100% rename from erpnext/projects/gantt_task.js rename to public/js/app/gantt_task.js diff --git a/erpnext/utilities/page/kb_common/kb_common.js b/public/js/app/kb_common.js similarity index 100% rename from erpnext/utilities/page/kb_common/kb_common.js rename to public/js/app/kb_common.js diff --git a/public/js/complete_setup.js b/public/js/complete_setup.js deleted file mode 100644 index ad0f37f9aa..0000000000 --- a/public/js/complete_setup.js +++ /dev/null @@ -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'],},}); \ No newline at end of file diff --git a/public/js/gantt_task.js b/public/js/gantt_task.js deleted file mode 100644 index 11f2009f03..0000000000 --- a/public/js/gantt_task.js +++ /dev/null @@ -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('
    Loading...
    ') -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('
    No Tasks Yet.
    ');}else{var gantt_area=$('
    ').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');}});} -$('').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);}})} \ No newline at end of file diff --git a/public/js/kb_common.js b/public/js/kb_common.js deleted file mode 100644 index 97ad5deb8e..0000000000 --- a/public/js/kb_common.js +++ /dev/null @@ -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+=' | delete';}} -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('
    \ -
    \ - [edit]\ - \ -

    Formatted as markdown
    \ - \ - Cancel\ -
    ',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);}} \ No newline at end of file diff --git a/public/js/listing.js b/public/js/listing.js index 5954286de5..d40c72f332 100644 --- a/public/js/listing.js +++ b/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],] diff --git a/public/js/print_query.js b/public/js/print_query.js deleted file mode 100644 index c982924676..0000000000 --- a/public/js/print_query.js +++ /dev/null @@ -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.title+'' -+'' -+'' -+(r.header_html?r.header_html:'') -+tl.join('\n
    \n') -+(r.footer_html?r.footer_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.title+'' ++'' ++'' ++(r.header_html?r.header_html:'') ++tl.join('\n
    \n') ++(r.footer_html?r.footer_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