From 5281e350fb6f3e9bc3e5b89a8d822803f613d1c3 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 10 Jul 2012 18:16:09 +0530 Subject: [PATCH] cost center cleanup --- .../doctype/cost_center/cost_center.js | 60 +++++++++++-------- .../doctype/cost_center/cost_center.txt | 24 +------- public/css/all-app.css | 9 ++- public/css/all-web.css | 2 +- public/js/all-app.js | 22 ++++--- public/js/all-web.js | 2 +- 6 files changed, 59 insertions(+), 60 deletions(-) diff --git a/erpnext/accounts/doctype/cost_center/cost_center.js b/erpnext/accounts/doctype/cost_center/cost_center.js index ade4ee882b..f721e42f2d 100644 --- a/erpnext/accounts/doctype/cost_center/cost_center.js +++ b/erpnext/accounts/doctype/cost_center/cost_center.js @@ -15,6 +15,30 @@ // along with this program. If not, see . +//onload if cost center is group +cur_frm.cscript.onload = function(doc, cdt, cdn) { + if(!doc.__islocal && doc.docstatus == 0){ + get_field(doc.doctype,'group_or_ledger',doc.name).permlevel = 1; + refresh_field('group_or_ledger'); + get_field(doc.doctype,'company_name',doc.name).permlevel = 1; + refresh_field('company_name'); + } + +} + +cur_frm.cscript.refresh = function(doc, cdt, cdn) { + cur_frm.cscript.hide_unhide_group_ledger(doc); + cur_frm.add_custom_button('Back To Chart of Cost Centers', function() { + wn.set_route('Accounts Browser', 'Cost Center'); + }, 'icon-arrow-left') + + var intro_txt = ''; + if(!doc.__islocal && doc.group_or_ledger=='Group') { + intro_txt += '

Note: This is Cost Center is a Group, \ + Accounting Entries are not allowed against groups.

'; + } + cur_frm.set_intro(intro_txt); +} //Account filtering for cost center cur_frm.fields_dict['budget_details'].grid.get_field('account').get_query = function(doc) { @@ -38,39 +62,26 @@ cur_frm.cscript.company_name = function(doc,cdt,cdn){ get_server_fields('get_abbr','','',doc,cdt,cdn,1); } -//onload if cost center is group -cur_frm.cscript.onload = function(doc, cdt, cdn) { - - if(!doc.__islocal && doc.docstatus == 0){ - get_field(doc.doctype,'group_or_ledger',doc.name).permlevel = 1; - refresh_field('group_or_ledger'); - get_field(doc.doctype,'company_name',doc.name).permlevel = 1; - refresh_field('company_name'); - } - -} - -cur_frm.cscript.refresh = function(doc, cdt, cdn) { - cur_frm.cscript.hide_unhide_group_ledger(doc); -} - // Hide/unhide group or ledger // ----------------------------------------- cur_frm.cscript.hide_unhide_group_ledger = function(doc) { - hide_field(['convert_to_group', 'convert_to_ledger']); - if (cstr(doc.group_or_ledger) == 'Group') unhide_field('convert_to_ledger'); - else if (cstr(doc.group_or_ledger) == 'Ledger') unhide_field('convert_to_group'); + if (cstr(doc.group_or_ledger) == 'Group') { + cur_frm.add_custom_button('Convert to Ledger', + function() { cur_frm.cscript.convert_to_ledger(); }, 'icon-retweet') + } else if (cstr(doc.group_or_ledger) == 'Ledger') { + cur_frm.add_custom_button('Convert to Group', + function() { cur_frm.cscript.convert_to_group(); }, 'icon-retweet') + } } // Convert group to ledger // ----------------------------------------- cur_frm.cscript.convert_to_ledger = function(doc, cdt, cdn) { - $c_obj(make_doclist(cdt,cdn),'convert_group_to_ledger','',function(r,rt) { + $c_obj(cur_frm.get_doclist(),'convert_group_to_ledger','',function(r,rt) { if(r.message == 1) { - doc.group_or_ledger = 'Ledger'; refresh_field('group_or_ledger'); - cur_frm.cscript.hide_unhide_group_ledger(doc); + cur_frm.cscript.hide_unhide_group_ledger(cur_frm.get_doc()); } }); } @@ -78,11 +89,10 @@ cur_frm.cscript.convert_to_ledger = function(doc, cdt, cdn) { // Convert ledger to group // ----------------------------------------- cur_frm.cscript.convert_to_group = function(doc, cdt, cdn) { - $c_obj(make_doclist(cdt,cdn),'convert_ledger_to_group','',function(r,rt) { + $c_obj(cur_frm.get_doclist(),'convert_ledger_to_group','',function(r,rt) { if(r.message == 1) { - doc.group_or_ledger = 'Group'; refresh_field('group_or_ledger'); - cur_frm.cscript.hide_unhide_group_ledger(doc); + cur_frm.cscript.hide_unhide_group_ledger(cur_frm.get_doc()); } }); } diff --git a/erpnext/accounts/doctype/cost_center/cost_center.txt b/erpnext/accounts/doctype/cost_center/cost_center.txt index 9152f04847..aea5fbb9d6 100644 --- a/erpnext/accounts/doctype/cost_center/cost_center.txt +++ b/erpnext/accounts/doctype/cost_center/cost_center.txt @@ -5,7 +5,7 @@ { 'creation': '2012-07-03 13:30:47', 'docstatus': 0, - 'modified': '2012-07-10 16:37:55', + 'modified': '2012-07-10 18:06:51', 'modified_by': u'Administrator', 'owner': u'Administrator' }, @@ -226,28 +226,6 @@ 'trigger': u'Client' }, - # DocField - { - 'colour': u'White:FFF', - 'doctype': u'DocField', - 'fieldname': u'convert_to_group', - 'fieldtype': u'Button', - 'label': u'Convert to Group', - 'permlevel': 0, - 'trigger': u'Client' - }, - - # DocField - { - 'colour': u'White:FFF', - 'doctype': u'DocField', - 'fieldname': u'convert_to_ledger', - 'fieldtype': u'Button', - 'label': u'Convert to Ledger', - 'permlevel': 0, - 'trigger': u'Client' - }, - # DocField { 'colour': u'White:FFF', diff --git a/public/css/all-app.css b/public/css/all-app.css index b699bef973..afeae01e0e 100644 --- a/public/css/all-app.css +++ b/public/css/all-app.css @@ -2059,7 +2059,7 @@ div.fix_ff_cursor { overflow: auto; } div.comment { color: #444; } .small { - font-size: 11px; + font-size: 12px; } .help { @@ -2319,6 +2319,13 @@ div.form-title { margin-right: 7px; } +div.form-intro-area { + background-color: #ffe; + padding: 9px 9px 0px 9px; + border: 1px dashed #fc7; + margin-bottom: 15px; +} + div.form-section-head { margin: 11px -15px 3px -15px; border-top: 1px solid #ccc; diff --git a/public/css/all-web.css b/public/css/all-web.css index 332471b01b..a3b6de5ce2 100644 --- a/public/css/all-web.css +++ b/public/css/all-web.css @@ -1920,7 +1920,7 @@ div.fix_ff_cursor { overflow: auto; } div.comment { color: #444; } .small { - font-size: 11px; + font-size: 12px; } .help { diff --git a/public/js/all-app.js b/public/js/all-app.js index d7ab9a8e1c..d7cfcd121f 100644 --- a/public/js/all-app.js +++ b/public/js/all-app.js @@ -855,7 +855,7 @@ wn.ui.AppFrame=Class.extend({init:function(parent,title){this.buttons={};this.$w ×\ ').appendTo(this.$w);this.$w.find('.close').click(function(){window.history.back();}) if(title)this.title(title);},title:function(txt){this.$titlebar.find('.appframe-title').html(txt);},add_button:function(label,click,icon){if(!this.$w.find('.appframe-toolbar').length) -this.$w.append('
');args={label:label,icon:''};if(icon){args.icon='';} +this.$w.append('
');args={label:label,icon:''};if(icon){args.icon='';} this.buttons[label]=$(repl('',args)).click(click).appendTo(this.$w.find('.appframe-toolbar'));return this.buttons[label];},clear_buttons:function(){this.$w.find('.appframe-toolbar').empty();}});wn.ui.make_app_page=function(opts){if(opts.single_column){$(opts.parent).html('
\
\ @@ -1743,11 +1743,13 @@ this.setup_print();} _f.Frm.prototype.setup_sidebar=function(){this.sidebar=new wn.widgets.form.sidebar.Sidebar(this);} _f.Frm.prototype.setup_footer=function(){var me=this;var f=this.page_layout.footer;f.save_area=$a(this.page_layout.footer,'div','',{display:'none',marginTop:'11px'});f.help_area=$a(this.page_layout.footer,'div');var b=$btn(f.save_area,'Save',function(){cur_frm.save('Save');},{marginLeft:'0px'},'green');f.show_save=function(){$ds(me.page_layout.footer.save_area);} f.hide_save=function(){$dh(me.page_layout.footer.save_area);}} +_f.Frm.prototype.set_intro=function(txt){if(!this.intro_area){this.intro_area=$('
').insertBefore(this.page_layout.body.firstChild);} +if(txt){this.intro_area.html(txt);}else{this.intro_area.remove();this.intro_area=null;}} _f.Frm.prototype.setup_fields_std=function(){var fl=wn.meta.docfield_list[this.doctype];fl.sort(function(a,b){return a.idx-b.idx});if(fl[0]&&fl[0].fieldtype!="Section Break"||get_url_arg('embed')){this.layout.addrow();if(fl[0].fieldtype!="Column Break"){var c=this.layout.addcell();$y(c.wrapper,{padding:'8px'});}} var sec;for(var i=0;i