diff --git a/accounts/doctype/ledger_balance_export/ledger_balance_export.comp.js b/accounts/doctype/ledger_balance_export/ledger_balance_export.comp.js deleted file mode 100644 index 73f48b51c0..0000000000 --- a/accounts/doctype/ledger_balance_export/ledger_balance_export.comp.js +++ /dev/null @@ -1,2 +0,0 @@ - -cur_frm.cscript['Export Report']=function(doc,cdt,cdn){$c_obj_csv(make_doclist(cdt,cdn),'get_report_data','');} \ No newline at end of file diff --git a/accounts/page/accounts_browser/accounts_browser.comp.js b/accounts/page/accounts_browser/accounts_browser.comp.js deleted file mode 100644 index 77948cfde2..0000000000 --- a/accounts/page/accounts_browser/accounts_browser.comp.js +++ /dev/null @@ -1,44 +0,0 @@ - -pscript['onload_Accounts Browser']=function(){var parent=$i('ab_body');parent.innerHTML='Please select your chart: ' -var sel=$a(parent,'select');add_sel_options(sel,['Account','Cost Center'],'Account');var btn=$btn(parent,'Go',function(){pscript.make_chart(sel_val(sel));},{marginTop:'8px'});} -pscript.make_chart=function(b){pscript.chart_type=b;$i('ab_header').innerHTML='';$i('ab_body').innerHTML='';var comment=$a($i('ab_body'),'div','comment',{marginBottom:"8px"});comment.innerHTML="Note: Explore and click on the tree node to add a new child";var select_area=$a('ab_body','div','',{margin:'8px 0px'});var ac_main_grid=make_table($i('ab_body'),1,2,'100%',['60%','40%'],{border:"0px",padding:"4px",tableLayout:"fixed",borderCollapse:"collapse"});$y($td(ac_main_grid,0,0),{border:"1px solid #dddddd",padding:"8px"});pscript.account_tree=$a($td(ac_main_grid,0,0),'div');$y($td(ac_main_grid,0,1),{border:"1px solid #DDD"});pscript.la=$a($td(ac_main_grid,0,1),'div');pscript.acc_period_bal=$a($td(ac_main_grid,0,1),'div');if(pscript.chart_type=='Account'){var footer=$a($i('ab_body'),'div','',{backgroundColor:"#FFD",padding:"8px",color:"#444",fontSize:"12px",marginTop:"14px"});var help1=$a(footer,'span');help1.innerHTML="Note: To create accounts for Customers and Suppliers, please create Customer and Supplier" -+" Masters. This will ensure that the accounts are linked to your Selling and Buying Processes. The Account Heads for Customer and Supplier will automatically be created."} -var h1='Chart of '+pscript.chart_type+'s';if(pscript.chart_type=='Account')var d='accounting';else var d='cost center';var desc='Manage multiple companies and the '+d+' structures of each company.';$i('ab_body').page_head=new PageHeader('ab_header',h1,desc);var tab=make_table(select_area,1,2,null,[],{verticalAlign:'middle',padding:'2px'});$td(tab,0,0).innerHTML='Select Company'.bold();var sel=$a($td(tab,0,1),'select','',{width:'160px'});var set_tree=function(){if(pscript.ac_tree){pscript.ac_tree.body.innerHTML='';} -pscript.make_ac_tree();var cn=sel_val(sel);var n=pscript.ac_tree.addNode(null,cn,null,pscript.ac_tree.std_onclick,pscript.ac_tree.std_onexp);n.rec={};n.rec.name='Root Node';n.rec.account_name=cn;n.rec.cost_center_name=cn;pscript.set_ac_head('',n.rec);$ds(pscript.ac_head_area);} -add_sel_options(sel,['Loading...']);var callback=function(r,rt){empty_select(sel);add_sel_options(sel,r.message.cl,sys_defaults.company);set_tree();sel.onchange=function(){set_tree();}} -$c_obj('GL Control','get_companies','',callback);pscript.ab_company_sel=sel;pscript.make_ac_head();pscript.make_group_area();pscript.make_ledger_area();pscript.make_new_acc_dialog();pscript.make_new_comp();pscript.make_new_cost_center_dialog();} -pscript.make_new_comp=function(){$i('ab_body').page_head.add_button('New Company',function(){new_doc('Company');},0,'ui-icon-plus');} -pscript.make_ac_tree=function(){var type=pscript.chart_type;var tree=new Tree(pscript.account_tree,'90%');pscript.ac_tree=tree;tree.std_onclick=function(node){pscript.cur_node=node;pscript.set_ac_head(node.parent_account,node.rec,type);} -tree.std_onexp=function(node){if(node.expanded_once)return;$ds(node.loading_div);var callback=function(r,rt){$dh(node.loading_div);var n=tree.allnodes[r.message.parent_acc_name];var cl=r.message.cl;if(type=='Account'){for(var i=0;iRefresh Tree';ref_btn.onclick=function(){pscript.cur_node.clear_child_nodes();pscript.cur_node.expand();} -pscript.group_area.ref_btn=ref_btn;pscript.acc_add_btn=$btn(pscript.group_area,'+ Add a child Account',function(){pscript.new_acc_dialog.show();});pscript.cc_add_btn=$btn(pscript.group_area,'+ Add a child Cost Center',null);pscript.cc_add_btn.onclick=function(){pscript.cc_dialog.widgets['Create'].onclick=function(){if(!pscript.cc_dialog.widgets['New Cost Center Name'].value){msgprint('Please enter New Cost Center Name');return;} -if(!sel_val(pscript.cc_dialog.widgets['Group or Ledger'])){msgprint('Please specify cost center is group or ledger');return;} -args={'cost_center_name':pscript.cc_dialog.widgets['New Cost Center Name'].value,'parent_cost_center':pscript.cur_node.rec.name,'group_or_ledger':sel_val(pscript.cc_dialog.widgets['Group or Ledger']),'company_name':sel_val(pscript.ab_company_sel),'company_abbr':'','old_parent':''} -$c_obj('GL Control','add_cc',docstring(args),function(r,rt){pscript.cc_dialog.widgets['New Cost Center Name'].value='';pscript.cc_dialog.hide();pscript.group_area.ref_btn.onclick();});} -pscript.new_cost_center_dialog.show();}} -pscript.make_ledger_area=function(){pscript.ledger_area=$a(pscript.la,'div','ac_ledger');pscript.gl_rep=$a(pscript.ledger_area,'div','',{fontSize:'14px',marginBottom:'8px',fontWeight:'bold'});pscript.gl_rep.innerHTML='Open Ledger';pscript.gl_rep.onclick=function(){pscript.make_report('gl');}} -pscript.make_report=function(flag){if(flag=='gl'){var callback=function(report){report.set_filter('GL Entry','Account',pscript.cur_node.rec.name) -report.dt.run();} -loadreport('GL Entry','General Ledger',callback);}} -pscript.make_new_acc_dialog=function(){var d=new Dialog(300,400,'Create A New Account');d.make_body([['HTML','Heading'],['Data','New Account Name'],['Select','Group or Ledger','Specify whether the new account is a Ledger or Group'],['Select','Account Type','[Optional] Specify the type of this account'],['Data','Tax Rate','Specify the default tax rate'],['Select','Master Type','Specify the master type of this account'],['Button','Create']]);add_sel_options(d.widgets['Group or Ledger'],['Group','Ledger'],'Group');add_sel_options(d.widgets['Account Type'],['','Fixed Asset Account','Bank or Cash','Expense Account','Tax','Income Account','Chargeable'],'');add_sel_options(d.widgets['Master Type'],['NA','Supplier','Customer','Employee'],'NA');d.widgets['Group or Ledger'].onchange=function(){if(sel_val(this)=='Ledger')$ds(d.rows['Account Type']);else $dh(d.rows['Account Type']);} -d.widgets['Account Type'].onchange=function(){if(sel_val(this)=='Tax'||sel_val(this)=='Chargeable')$ds(d.rows['Tax Rate']);else $dh(d.rows['Tax Rate']);} -d.onshow=function(){$dh(this.rows['Account Type']);$dh(this.rows['Tax Rate']);this.widgets['Group or Ledger'].selectedIndex=0;this.widgets['Account Type'].selectedIndex=0;this.widgets['Master Type'].selectedIndex=0;d.widgets['New Account Name'].value='';d.widgets['Tax Rate'].value='';} -d.widgets['Create'].onclick=function(){if(!d.widgets['New Account Name'].value){msgprint('Please enter New Account Name');return;} -if(!sel_val(d.widgets['Master Type'])){msgprint('Please enter master type of this new account');return;} -args={'account_name':d.widgets['New Account Name'].value,'parent_account':pscript.cur_node.rec.name,'group_or_ledger':sel_val(d.widgets['Group or Ledger']),'company':sel_val(pscript.ab_company_sel),'account_type':sel_val(d.widgets['Account Type']),'tax_rate':d.widgets['Tax Rate'].value,'master_type':sel_val(d.widgets['Master Type'])} -$c_obj('GL Control','add_ac',docstring(args),function(r,rt){d.hide();pscript.group_area.ref_btn.onclick();});} -pscript.new_acc_dialog=d;} -pscript.make_new_cost_center_dialog=function(){pscript.cc_dialog=new Dialog(300,400,'Create A New Cost Center');pscript.cc_dialog.make_body([['HTML','Heading'],['Data','New Cost Center Name'],['Select','Group or Ledger','Specify whether the new cost center is a Ledger or Group'],['Button','Create']]);add_sel_options(pscript.cc_dialog.widgets['Group or Ledger'],['Group','Ledger'],'Group');pscript.new_cost_center_dialog=pscript.cc_dialog;} \ No newline at end of file diff --git a/crm/doctype/enquiry/enquiry.comp.js b/crm/doctype/enquiry/enquiry.comp.js deleted file mode 100644 index fc4baa4ed8..0000000000 --- a/crm/doctype/enquiry/enquiry.comp.js +++ /dev/null @@ -1,38 +0,0 @@ - -$import(SMS Control) -cur_frm.cscript.refresh=function(doc,cdt,cdn){if(!doc.docstatus){hide_field(['Update Follow up']);hide_field(['email_id1','cc_to','subject','message','Attachment Html','Create New File','enquiry_attachment_detail','Send Email']);} -else{unhide_field(['Update Follow up']);unhide_field(['email_id1','cc_to','subject','message','Attachment Html','Create New File','enquiry_attachment_detail','Send Email']);} -cur_frm.clear_custom_buttons();if(doc.docstatus==1){cur_frm.add_custom_button('Create Quotation',cur_frm.cscript['Create Quotation']);cur_frm.add_custom_button('Enquiry Lost',cur_frm.cscript['Declare Enquiry Lost']);cur_frm.add_custom_button('Send SMS',cur_frm.cscript['Send SMS']);}} -cur_frm.cscript.onload=function(doc,cdt,cdn){if(!doc.enquiry_from)hide_field(['customer','customer_address','contact_person','customer_name','lead','lead_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);if(!doc.status)set_multiple(cdt,cdn,{status:'Draft'});if(!doc.date)doc.transaction_date=date.obj_to_str(new Date());if(!doc.company&&sys_defaults.company)set_multiple(cdt,cdn,{company:sys_defaults.company});if(!doc.fiscal_year&&sys_defaults.fiscal_year)set_multiple(cdt,cdn,{fiscal_year:sys_defaults.fiscal_year});if(doc.enquiry_from){if(doc.enquiry_from=='Customer'){hide_field(['lead','lead_name']);} -else if(doc.enquiry_from=='Lead'){hide_field(['customer','customer_address','contact_person','customer_name','contact_display','customer_group']);}} -if(doc.enquiry_from=='Lead'&&doc.lead){cur_frm.cscript.lead(doc,cdt,cdn);} -cur_frm.cscript.set_fetch();} -cur_frm.cscript.set_fetch=function(){cur_frm.add_fetch('item_code','item_name','item_name');cur_frm.add_fetch('item_code','stock_uom','uom');cur_frm.add_fetch('item_code','description','description');cur_frm.add_fetch('item_code','item_group','item_group');cur_frm.add_fetch('item_code','brand','brand');} -cur_frm.cscript.enquiry_from=function(doc,cdt,cdn){cur_frm.cscript.lead_cust_show(doc,cdt,cdn);} -cur_frm.cscript.lead_cust_show=function(doc,cdt,cdn){if(doc.enquiry_from=='Lead'){unhide_field(['lead']);hide_field(['lead_name','customer','customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);doc.lead=doc.lead_name=doc.customer=doc.customer_address=doc.contact_person=doc.address_display=doc.contact_display=doc.contact_mobile=doc.contact_email=doc.territory=doc.customer_group="";} -else if(doc.enquiry_from=='Customer'){unhide_field(['customer']);hide_field(['lead','lead_name','address_display','contact_display','contact_mobile','contact_email','territory']);doc.lead=doc.lead_name=doc.customer=doc.customer_address=doc.contact_person=doc.address_display=doc.contact_display=doc.contact_mobile=doc.contact_email=doc.territory=doc.customer_group="";}} -cur_frm.cscript.customer=function(doc,dt,dn){if(doc.customer)get_server_fields('get_default_customer_address',JSON.stringify({customer:doc.customer}),'',doc,dt,dn,1);if(doc.customer)unhide_field(['customer_name','customer_address','contact_person','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);} -cur_frm.cscript.customer_address=cur_frm.cscript.contact_person=function(doc,dt,dn){if(doc.customer)get_server_fields('get_customer_address',JSON.stringify({customer:doc.customer,address:doc.customer_address,contact:doc.contact_person}),'',doc,dt,dn,1);} -cur_frm.fields_dict.customer_address.on_new=function(dn){locals['Address'][dn].customer=locals[cur_frm.doctype][cur_frm.docname].customer;locals['Address'][dn].customer_name=locals[cur_frm.doctype][cur_frm.docname].customer_name;} -cur_frm.fields_dict.contact_person.on_new=function(dn){locals['Contact'][dn].customer=locals[cur_frm.doctype][cur_frm.docname].customer;locals['Contact'][dn].customer_name=locals[cur_frm.doctype][cur_frm.docname].customer_name;} -cur_frm.fields_dict['customer_address'].get_query=function(doc,cdt,cdn){return'SELECT name,address_line1,city FROM tabAddress WHERE customer = "'+doc.customer+'" AND docstatus != 2 AND name LIKE "%s" ORDER BY name ASC LIMIT 50';} -cur_frm.fields_dict['contact_person'].get_query=function(doc,cdt,cdn){return'SELECT name,CONCAT(first_name," ",ifnull(last_name,"")) As FullName,department,designation FROM tabContact WHERE customer = "'+doc.customer+'" AND docstatus != 2 AND name LIKE "%s" ORDER BY name ASC LIMIT 50';} -cur_frm.fields_dict['lead'].get_query=function(doc,cdt,cdn){return'SELECT `tabLead`.name, `tabLead`.lead_name FROM `tabLead` WHERE `tabLead`.%(key)s LIKE "%s" ORDER BY `tabLead`.`name` ASC LIMIT 50';} -cur_frm.cscript.lead=function(doc,cdt,cdn){if(doc.lead)get_server_fields('get_lead_details',doc.lead,'',doc,cdt,cdn,1);if(doc.lead)unhide_field(['lead_name','address_display','contact_mobile','contact_email','territory']);} -cur_frm.fields_dict['enquiry_details'].grid.get_field('item_code').get_query=function(doc,cdt,cdn){if(doc.enquiry_type=='Maintenance') -return'SELECT tabItem.name,tabItem.item_name,tabItem.description FROM tabItem WHERE tabItem.is_service_item="Yes" AND (ifnull(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` > NOW() OR `tabItem`.`end_of_life`="0000-00-00") AND tabItem.%(key)s LIKE "%s" LIMIT 50';else -return'SELECT tabItem.name,tabItem.item_name,tabItem.description FROM tabItem WHERE tabItem.is_sales_item="Yes" AND (ifnull(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` > NOW() OR `tabItem`.`end_of_life`="0000-00-00") AND tabItem.%(key)s LIKE "%s" LIMIT 50';} -cur_frm.cscript.item_code=function(doc,cdt,cdn){var d=locals[cdt][cdn];if(d.item_code){get_server_fields('get_item_details',d.item_code,'enquiry_details',doc,cdt,cdn,1);}} -cur_frm.cscript['Create New File']=function(doc){var fl=LocalDB.create('File');fl=locals['File'][fl];loaddoc('File',fl.name);} -cur_frm.cscript['Update Follow up']=function(doc,cdt,cdn){$c_obj(make_doclist(doc.doctype,doc.name),'update_follow_up','',function(r,rt){refresh_field('follow_up');doc.__unsaved=0;cur_frm.refresh_header();});} -cur_frm.cscript['Create Quotation']=function(){n=createLocal("Quotation");$c('dt_map',args={'docs':compress_doclist([locals["Quotation"][n]]),'from_doctype':'Enquiry','to_doctype':'Quotation','from_docname':cur_frm.docname,'from_to_list':"[['Enquiry', 'Quotation'],['Enquiry Detail','Quotation Detail']]"},function(r,rt){loaddoc("Quotation",n);});} -cur_frm.cscript['Declare Enquiry Lost']=function(){var e_lost_dialog;set_e_lost_dialog=function(){e_lost_dialog=new Dialog(400,150,'Add Enquiry Lost Reason');e_lost_dialog.make_body([['HTML','Message','
Please add enquiry lost reason
'],['Text','Enquiry Lost Reason'],['HTML','Response','
'],['HTML','Add Reason','
']]);var add_reason_btn1=$a($i(e_lost_dialog.widgets['Add Reason']),'button','button');add_reason_btn1.innerHTML='Add';add_reason_btn1.onclick=function(){e_lost_dialog.add();} -var add_reason_btn2=$a($i(e_lost_dialog.widgets['Add Reason']),'button','button');add_reason_btn2.innerHTML='Cancel';$y(add_reason_btn2,{marginLeft:'4px'});add_reason_btn2.onclick=function(){e_lost_dialog.hide();} -e_lost_dialog.onshow=function(){e_lost_dialog.widgets['Enquiry Lost Reason'].value='';$i('update_enquiry_dialog_response').innerHTML='';} -e_lost_dialog.add=function(){$i('update_enquiry_dialog_response').innerHTML='Processing...';var arg=strip(e_lost_dialog.widgets['Enquiry Lost Reason'].value);var call_back=function(r,rt){if(r.message=='true'){$i('update_enquiry_dialog_response').innerHTML='Done';e_lost_dialog.hide();}} -if(arg){$c_obj(make_doclist(cur_frm.doc.doctype,cur_frm.doc.name),'declare_enquiry_lost',arg,call_back);} -else{msgprint("Please add enquiry lost reason");}}} -if(!e_lost_dialog){set_e_lost_dialog();} -e_lost_dialog.show();} -cur_frm.fields_dict['territory'].get_query=function(doc,cdt,cdn){return'SELECT `tabTerritory`.`name`,`tabTerritory`.`parent_territory` FROM `tabTerritory` WHERE `tabTerritory`.`is_group` = "No" AND `tabTerritory`.`docstatus`!= 2 AND `tabTerritory`.%(key)s LIKE "%s" ORDER BY `tabTerritory`.`name` ASC LIMIT 50';} -cur_frm.cscript.validate=function(doc,cdt,cdn){} \ No newline at end of file diff --git a/crm/doctype/lead/lead.comp.js b/crm/doctype/lead/lead.comp.js deleted file mode 100644 index e960c44668..0000000000 --- a/crm/doctype/lead/lead.comp.js +++ /dev/null @@ -1,18 +0,0 @@ - -$import(SMS Control) -cur_frm.cscript.onload=function(doc,cdt,cdn){if(user=='Guest'){hide_field(['status','naming_series','order_lost_reason','customer','rating','fax','website','territory','TerritoryHelp','address_line1','address_line2','city','state','country','pincode','address','lead_owner','market_segment','industry','campaign_name','interested_in','company','fiscal_year','contact_by','contact_date','last_contact_date','contact_date_ref','to_discuss','More Info','follow_up','Communication History','cc_to','subject','message','Attachment Html','Create New File','lead_attachment_detail','Send Email','Email','Create Customer','Create Enquiry','Next Steps','transaction_date','type','source']);doc.source='Website';} -if(!doc.status)set_multiple(dt,dn,{status:'Open'});if(!doc.date){doc.date=date.obj_to_str(new Date());} -if(user=='Guest')doc.naming_series='WebLead';cur_frm.add_fetch('customer','customer_name','company_name');} -cur_frm.cscript.refresh=function(doc,cdt,cdn){cur_frm.clear_custom_buttons() -if(!doc.__islocal&&!in_list(['Converted','Lead Lost'],doc.status)){cur_frm.add_custom_button('Create Customer',cur_frm.cscript['Create Customer']);cur_frm.add_custom_button('Create Enquiry',cur_frm.cscript['Create Enquiry']);cur_frm.add_custom_button('Send SMS',cur_frm.cscript['Send SMS']);}} -cur_frm.cscript.status=function(doc,cdt,cdn){cur_frm.cscript.refresh(doc,cdt,cdn);} -cur_frm.cscript.TerritoryHelp=function(doc,dt,dn){var call_back=function(){var sb_obj=new SalesBrowser();sb_obj.set_val('Territory');} -loadpage('Sales Browser',call_back);} -cur_frm.cscript['Create New File']=function(doc){new_doc("File");} -cur_frm.cscript.item_code=function(doc,cdt,cdn){var d=locals[cdt][cdn];if(d.item_code){get_server_fields('get_item_detail',d.item_code,'lead_item_detail',doc,cdt,cdn,1);}} -cur_frm.cscript['Create Customer']=function(){var doc=cur_frm.doc;$c('runserverobj',args={'method':'check_status','docs':compress_doclist([doc])},function(r,rt){if(r.message=='Converted'){msgprint("This lead is already converted to customer");} -else{n=createLocal("Customer");$c('dt_map',args={'docs':compress_doclist([locals["Customer"][n]]),'from_doctype':'Lead','to_doctype':'Customer','from_docname':doc.name,'from_to_list':"[['Lead', 'Customer']]"},function(r,rt){loaddoc("Customer",n);});}});} -cur_frm.cscript['Send Email']=function(doc,cdt,cdn){if(doc.__islocal!=1){$c_obj(make_doclist(doc.doctype,doc.name),'send_mail','',function(r,rt){});}else{msgprint("Please save lead first before sending email")}} -cur_frm.cscript['Create Enquiry']=function(){var doc=cur_frm.doc;$c('runserverobj',args={'method':'check_status','docs':compress_doclist([doc])},function(r,rt){if(r.message=='Converted'){msgprint("This lead is now converted to customer. Please create enquiry on behalf of customer");} -else{n=createLocal("Enquiry");$c('dt_map',args={'docs':compress_doclist([locals["Enquiry"][n]]),'from_doctype':'Lead','to_doctype':'Enquiry','from_docname':doc.name,'from_to_list':"[['Lead', 'Enquiry']]"},function(r,rt){loaddoc("Enquiry",n);});}});} -cur_frm.fields_dict['territory'].get_query=function(doc,cdt,cdn){return'SELECT `tabTerritory`.`name`,`tabTerritory`.`parent_territory` FROM `tabTerritory` WHERE `tabTerritory`.`is_group` = "No" AND `tabTerritory`.`docstatus`!= 2 AND `tabTerritory`.%(key)s LIKE "%s" ORDER BY `tabTerritory`.`name` ASC LIMIT 50';} \ No newline at end of file diff --git a/crm/doctype/quotation/quotation.comp.js b/crm/doctype/quotation/quotation.comp.js deleted file mode 100644 index 2808e4961c..0000000000 --- a/crm/doctype/quotation/quotation.comp.js +++ /dev/null @@ -1,40 +0,0 @@ - -cur_frm.cscript.tname="Quotation Detail";cur_frm.cscript.fname="quotation_details";cur_frm.cscript.other_fname="other_charges";cur_frm.cscript.sales_team_fname="sales_team";$import(Sales Common) -$import(Other Charges) -$import(SMS Control) -cur_frm.cscript.onload=function(doc,cdt,cdn){if(!doc.quotation_to)hide_field(['customer','customer_address','contact_person','customer_name','lead','lead_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);if(!doc.price_list_name)set_multiple(cdt,cdn,{price_list_name:sys_defaults.price_list_name});if(!doc.status)set_multiple(cdt,cdn,{status:'Draft'});if(!doc.transaction_date)set_multiple(cdt,cdn,{transaction_date:get_today()});if(!doc.conversion_rate)set_multiple(cdt,cdn,{conversion_rate:'1.00'});if(!doc.currency&&sys_defaults.currency)set_multiple(cdt,cdn,{currency:sys_defaults.currency});if(!doc.company&&sys_defaults.company)set_multiple(cdt,cdn,{company:sys_defaults.company});if(!doc.fiscal_year&&sys_defaults.fiscal_year)set_multiple(cdt,cdn,{fiscal_year:sys_defaults.fiscal_year});if(doc.__islocal&&!getchildren('RV Tax Detail',doc.name,'other_charges',doc.doctype).length)cur_frm.cscript.load_taxes(doc,cdt,cdn);if(doc.__islocal==1){cur_frm.cscript.price_list_name(doc,cdt,cdn);} -if(doc.quotation_to){if(doc.quotation_to=='Customer'){hide_field(['lead','lead_name']);} -else if(doc.quotation_to=='Lead'){hide_field(['customer','customer_address','contact_person','customer_name','contact_display','customer_group']);}}} -cur_frm.cscript.lead_cust_show=function(doc,cdt,cdn){if(doc.quotation_to=='Lead'){unhide_field(['lead']);hide_field(['lead_name','customer','customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);doc.lead=doc.lead_name=doc.customer=doc.customer_address=doc.contact_person=doc.address_display=doc.contact_display=doc.contact_mobile=doc.contact_email=doc.territory=doc.customer_group="";} -else if(doc.quotation_to=='Customer'){unhide_field(['customer']);hide_field(['lead','lead_name','address_display','contact_display','contact_mobile','contact_email','territory']);doc.lead=doc.lead_name=doc.customer=doc.customer_address=doc.contact_person=doc.address_display=doc.contact_display=doc.contact_mobile=doc.contact_email=doc.territory=doc.customer_group="";}} -cur_frm.cscript.quotation_to=function(doc,cdt,cdn){cur_frm.cscript.lead_cust_show(doc,cdt,cdn);} -cur_frm.cscript.refresh=function(doc,cdt,cdn){cur_frm.clear_custom_buttons();if(doc.docstatus==1&&doc.status!='Order Lost'){cur_frm.add_custom_button('Make Sales Order',cur_frm.cscript['Make Sales Order']);cur_frm.add_custom_button('Set as Lost',cur_frm.cscript['Declare Order Lost']);cur_frm.add_custom_button('Send SMS',cur_frm.cscript['Send SMS']);} -if(!doc.docstatus)hide_field(['Update Follow up']);else unhide_field(['Update Follow up']);} -cur_frm.cscript.customer=function(doc,dt,dn){if(doc.customer)get_server_fields('get_default_customer_address',JSON.stringify({customer:doc.customer}),'',doc,dt,dn,1);if(doc.customer)unhide_field(['customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);} -cur_frm.cscript.customer_address=cur_frm.cscript.contact_person=function(doc,dt,dn){if(doc.customer)get_server_fields('get_customer_address',JSON.stringify({customer:doc.customer,address:doc.customer_address,contact:doc.contact_person}),'',doc,dt,dn,1);} -cur_frm.fields_dict.customer_address.on_new=function(dn){locals['Address'][dn].customer=locals[cur_frm.doctype][cur_frm.docname].customer;locals['Address'][dn].customer_name=locals[cur_frm.doctype][cur_frm.docname].customer_name;} -cur_frm.fields_dict.contact_person.on_new=function(dn){locals['Contact'][dn].customer=locals[cur_frm.doctype][cur_frm.docname].customer;locals['Contact'][dn].customer_name=locals[cur_frm.doctype][cur_frm.docname].customer_name;} -cur_frm.fields_dict['customer_address'].get_query=function(doc,cdt,cdn){return'SELECT name,address_line1,city FROM tabAddress WHERE customer = "'+doc.customer+'" AND docstatus != 2 AND name LIKE "%s" ORDER BY name ASC LIMIT 50';} -cur_frm.fields_dict['contact_person'].get_query=function(doc,cdt,cdn){return'SELECT name,CONCAT(first_name," ",ifnull(last_name,"")) As FullName,department,designation FROM tabContact WHERE customer = "'+doc.customer+'" AND docstatus != 2 AND name LIKE "%s" ORDER BY name ASC LIMIT 50';} -cur_frm.fields_dict['lead'].get_query=function(doc,cdt,cdn){return'SELECT `tabLead`.name, `tabLead`.lead_name FROM `tabLead` WHERE `tabLead`.%(key)s LIKE "%s" ORDER BY `tabLead`.`name` ASC LIMIT 50';} -cur_frm.cscript.lead=function(doc,cdt,cdn){if(doc.lead)get_server_fields('get_lead_details',doc.lead,'',doc,cdt,cdn,1);if(doc.lead)unhide_field(['lead_name','address_display','contact_mobile','contact_email','territory']);} -cur_frm.fields_dict['enq_no'].get_query=function(doc,cdt,cdn){var cond='';var cond1='';if(doc.order_type)cond='ifnull(`tabEnquiry`.enquiry_type, "") = "'+doc.order_type+'" AND';if(doc.customer)cond1='`tabEnquiry`.customer = "'+doc.customer+'" AND';else if(doc.lead)cond1='`tabEnquiry`.lead = "'+doc.lead+'" AND';return repl('SELECT `tabEnquiry`.`name` FROM `tabEnquiry` WHERE `tabEnquiry`.`docstatus` = 1 AND `tabEnquiry`.status = "Submitted" AND %(cond)s %(cond1)s `tabEnquiry`.`name` LIKE "%s" ORDER BY `tabEnquiry`.`name` ASC LIMIT 50',{cond:cond,cond1:cond1});} -cur_frm.cscript['Make Sales Order']=function(){var doc=cur_frm.doc;if(doc.docstatus==1){var n=createLocal("Sales Order");$c('dt_map',args={'docs':compress_doclist([locals["Sales Order"][n]]),'from_doctype':'Quotation','to_doctype':'Sales Order','from_docname':doc.name,'from_to_list':"[['Quotation', 'Sales Order'], ['Quotation Detail', 'Sales Order Detail'],['RV Tax Detail','RV Tax Detail'], ['Sales Team', 'Sales Team'], ['TC Detail', 'TC Detail']]"},function(r,rt){loaddoc("Sales Order",n);});}} -cur_frm.cscript['Pull Enquiry Detail']=function(doc,cdt,cdn){var callback=function(r,rt){if(r.message){doc.quotation_to=r.message;if(doc.quotation_to=='Lead'){unhide_field(['lead','lead_name','address_display','contact_mobile','contact_email','territory']);} -else if(doc.quotation_to=='Customer'){unhide_field(['customer','customer_address','contact_person','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);} -refresh_many(['quotation_details','quotation_to','customer','customer_address','contact_person','lead','lead_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group','order_type']);}} -$c_obj(make_doclist(doc.doctype,doc.name),'pull_enq_details','',callback);} -cur_frm.cscript['Update Follow up']=function(doc){$c_obj(make_doclist(doc.doctype,doc.name),'update_followup_details','',function(r,rt){refresh_field('follow_up');doc.__unsaved=0;cur_frm.refresh_header();});} -cur_frm.cscript['Declare Order Lost']=function(){var qtn_lost_dialog;set_qtn_lost_dialog=function(doc,cdt,cdn){qtn_lost_dialog=new Dialog(400,400,'Add Quotation Lost Reason');qtn_lost_dialog.make_body([['HTML','Message','
Please add quotation lost reason
'],['Text','Quotation Lost Reason'],['HTML','Response','
'],['HTML','Add Reason','
']]);var add_reason_btn1=$a($i(qtn_lost_dialog.widgets['Add Reason']),'button','button');add_reason_btn1.innerHTML='Add';add_reason_btn1.onclick=function(){qtn_lost_dialog.add();} -var add_reason_btn2=$a($i(qtn_lost_dialog.widgets['Add Reason']),'button','button');add_reason_btn2.innerHTML='Cancel';$y(add_reason_btn2,{marginLeft:'4px'});add_reason_btn2.onclick=function(){qtn_lost_dialog.hide();} -qtn_lost_dialog.onshow=function(){qtn_lost_dialog.widgets['Quotation Lost Reason'].value='';$i('update_quotation_dialog_response').innerHTML='';} -qtn_lost_dialog.add=function(){$i('update_quotation_dialog_response').innerHTML='Processing...';var arg=strip(qtn_lost_dialog.widgets['Quotation Lost Reason'].value);var call_back=function(r,rt){if(r.message=='true'){$i('update_quotation_dialog_response').innerHTML='Done';qtn_lost_dialog.hide();}} -if(arg)$c_obj(make_doclist(cur_frm.doc.doctype,cur_frm.doc.name),'declare_order_lost',arg,call_back);else msgprint("Please add Quotation lost reason");}} -if(!qtn_lost_dialog){set_qtn_lost_dialog(doc,cdt,cdn);} -qtn_lost_dialog.show();} -cur_frm.cscript['Get Report']=function(doc,cdt,cdn){var callback=function(report){report.set_filter('Sales Order Detail','Quotation No.',doc.name) -report.dt.run();} -loadreport('Sales Order Detail','Itemwise Sales Details',callback);} -cur_frm.cscript.quot_to_validate=function(doc,cdt,cdn){if(doc.quotation_to=='Lead'){if(!doc.lead){alert("Lead is mandatory.");validated=false;}} -else if(doc.quotation_to=='Customer'){if(!doc.customer){alert("Customer is mandatory.");validated=false;}}} -cur_frm.cscript.validate=function(doc,cdt,cdn){cur_frm.cscript.quot_to_validate(doc,cdt,cdn);} \ No newline at end of file diff --git a/crm/doctype/sales_common/sales_common.comp.js b/crm/doctype/sales_common/sales_common.comp.js deleted file mode 100644 index c03d5df7a7..0000000000 --- a/crm/doctype/sales_common/sales_common.comp.js +++ /dev/null @@ -1,74 +0,0 @@ - -cur_frm.cscript.load_taxes=function(doc,cdt,cdn){if(doc.customer)return;$c_obj([doc],'load_default_taxes','',function(r,rt){refresh_field('other_charges');});} -cur_frm.add_fetch('company','default_currency','currency');cur_frm.cscript.customer=function(doc,cdt,cdn){if(doc.customer){if(!doc.company){msgprint("Please select company to proceed");doc.customer='';refresh_field('customer');}else{var callback=function(r,rt){cur_frm.refresh();} -$c_obj(make_doclist(doc.doctype,doc.name),'get_customer_details','',callback);}}} -cur_frm.cscript.TerritoryHelp=function(doc,dt,dn){var call_back=function(){var sb_obj=new SalesBrowser();sb_obj.set_val('Territory');} -loadpage('Sales Browser',call_back);} -cur_frm.cscript.CGHelp=function(doc,dt,dn){var call_back=function(){var sb_obj=new SalesBrowser();sb_obj.set_val('Customer Group');} -loadpage('Sales Browser',call_back);} -cur_frm.cscript.currency=function(doc,cdt,cdn){cur_frm.cscript.price_list_name(doc,cdt,cdn);} -cur_frm.cscript.price_list_name=function(doc,cdt,cdn){var fname=cur_frm.cscript.fname;if(doc.price_list_name&&doc.currency){$c_obj(make_doclist(doc.doctype,doc.name),'get_adj_percent','',function(r,rt){refresh_field(fname);var doc=locals[cdt][cdn];cur_frm.cscript.recalc(doc,3);});}} -cur_frm.cscript.conversion_rate=function(doc,cdt,cdn){cur_frm.cscript.recalc(doc,3);} -cur_frm.fields_dict[cur_frm.cscript.fname].grid.get_field("item_code").get_query=function(doc,cdt,cdn){if(doc.order_type=='Maintenance') -return'SELECT tabItem.name,tabItem.item_name,tabItem.description FROM tabItem WHERE tabItem.is_service_item="Yes" AND tabItem.docstatus != 2 AND (ifnull(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` > NOW() OR `tabItem`.`end_of_life`="0000-00-00") AND tabItem.%(key)s LIKE "%s" LIMIT 50';else -return'SELECT tabItem.name,tabItem.item_name,tabItem.description FROM tabItem WHERE tabItem.is_sales_item="Yes" AND tabItem.docstatus != 2 AND (ifnull(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` > NOW() OR `tabItem`.`end_of_life`="0000-00-00") AND tabItem.%(key)s LIKE "%s" LIMIT 50';} -cur_frm.cscript.item_code=function(doc,cdt,cdn){var fname=cur_frm.cscript.fname;var d=locals[cdt][cdn];if(d.item_code){if(!doc.company){msgprint("Please select company to proceed");d.item_code='';refresh_field('item_code',d.name,fname);}else{var callback=function(r,rt){cur_frm.cscript.recalc(doc,1);} -get_server_fields('get_item_details',d.item_code,fname,doc,cdt,cdn,1,callback);}} -if(cur_frm.cscript.custom_item_code){cur_frm.cscript.custom_item_code(doc,cdt,cdn);}} -cur_frm.cscript.qty=function(doc,cdt,cdn){cur_frm.cscript.recalc(doc,1);} -cur_frm.cscript.adj_rate=function(doc,cdt,cdn){cur_frm.cscript.recalc(doc,1);} -cur_frm.cscript.ref_rate=function(doc,cdt,cdn){var d=locals[cdt][cdn];set_multiple(cur_frm.cscript.tname,d.name,{'export_rate':flt(d.ref_rate)*(100-flt(d.adj_rate))/100},cur_frm.cscript.fname);cur_frm.cscript.recalc(doc,3);} -cur_frm.cscript.basic_rate=function(doc,cdt,cdn){var fname=cur_frm.cscript.fname;var d=locals[cdt][cdn];;if(!d.qty) -{d.qty=1;refresh_field('qty',d.name,fname);} -cur_frm.cscript.recalc(doc,2);} -cur_frm.cscript.export_rate=function(doc,cdt,cdn){cur_frm.cscript.recalc(doc,3);} -cur_frm.fields_dict.charge.get_query=function(doc){return'SELECT DISTINCT `tabOther Charges`.name FROM `tabOther Charges` WHERE `tabOther Charges`.company = "'+doc.company+'" AND `tabOther Charges`.company is not NULL AND `tabOther Charges`.docstatus != 2 AND `tabOther Charges`.%(key)s LIKE "%s" ORDER BY `tabOther Charges`.name LIMIT 50';} -cur_frm.cscript['Get Charges']=function(doc,cdt,cdn){$c_obj(make_doclist(doc.doctype,doc.name),'get_other_charges','',function(r,rt){cur_frm.cscript['Calculate Charges'](doc,cdt,cdn);});} -cur_frm.cscript.recalc=function(doc,n){if(!n)n=0;doc=locals[doc.doctype][doc.name];var tname=cur_frm.cscript.tname;var fname=cur_frm.cscript.fname;var sales_team=cur_frm.cscript.sales_team_fname;var other_fname=cur_frm.cscript.other_fname;if(!flt(doc.conversion_rate)){doc.conversion_rate=1;refresh_field('conversion_rate');} -if(n>0)cur_frm.cscript.update_fname_table(doc,tname,fname,n);if(flt(doc.net_total)>0){var cl=getchildren('RV Tax Detail',doc.name,other_fname,doc.doctype);for(var i=0;i2)alert("You cannot enter more than 2 nos. for division");var id1=cint(row[0].replace(/^\s+|\s+$/g,""));var id2=cint(row[1].replace(/^\s+|\s+$/g,""));tax_amount=flt(tax[id1-1].total_amount)/flt(tax[id2-1].total_amount);} -return tax_amount} -else if(tax[t].charge_type=='On Previous Row Total'){if(flt(print_amt)==1){doc.sales_tax_rate+=flt(rate);refresh_field('sales_tax_rate');return} -var row=cint(tax[t].row_id);return tax_amount=flt(rate)*(flt(tax[row-1].total_tax_amount)+flt(tax[row-1].total_amount))/100;}} -cur_frm.cscript.update_fname_table=function(doc,tname,fname,n){doc=locals[doc.doctype][doc.name] -var net_total=0 -var cl=getchildren(tname,doc.name,fname);for(var i=0;i0) -set_multiple(tname,cl[i].name,{'export_rate':flt(flt(cl[i].ref_rate)*(100-flt(cl[i].adj_rate))/100)},fname);set_multiple(tname,cl[i].name,{'export_amount':flt(flt(cl[i].qty)*flt(cl[i].export_rate)),'basic_rate':flt(flt(cl[i].export_rate)*flt(doc.conversion_rate)),'amount':flt((flt(cl[i].export_rate)*flt(doc.conversion_rate))*flt(cl[i].qty))},fname);} -else if(n==2){if(flt(cl[i].ref_rate)>0) -set_multiple(tname,cl[i].name,{'adj_rate':100-flt(flt(cl[i].basic_rate)*100/(flt(cl[i].ref_rate)*flt(doc.conversion_rate)))},fname);set_multiple(tname,cl[i].name,{'amount':flt(flt(cl[i].qty)*flt(cl[i].basic_rate)),'export_rate':flt(flt(cl[i].basic_rate)/flt(doc.conversion_rate)),'export_amount':flt((flt(cl[i].basic_rate)/flt(doc.conversion_rate))*flt(cl[i].qty))},fname);} -else if(n==3){set_multiple(tname,cl[i].name,{'basic_rate':flt(flt(cl[i].export_rate)*flt(doc.conversion_rate))},fname);set_multiple(tname,cl[i].name,{'amount':flt(flt(cl[i].basic_rate)*flt(cl[i].qty)),'export_amount':flt(flt(cl[i].export_rate)*flt(cl[i].qty))},fname);if(cl[i].ref_rate>0) -set_multiple(tname,cl[i].name,{'adj_rate':100-flt(flt(cl[i].export_rate)*100/flt(cl[i].ref_rate)),'base_ref_rate':flt(flt(cl[i].ref_rate)*flt(doc.conversion_rate))},fname);} -net_total+=flt(flt(cl[i].qty)*flt(cl[i].basic_rate));} -doc.net_total=net_total;refresh_field('net_total');} -cur_frm.cscript.get_item_wise_tax_detail=function(doc,rate,cl,i,tax,t){doc=locals[doc.doctype][doc.name];var detail='';detail=cl[i].item_code+" : "+cstr(rate)+NEWLINE;return detail;} -cur_frm.cscript['Re-Calculate Values']=function(doc,cdt,cdn){cur_frm.cscript['Calculate Charges'](doc,cdt,cdn);} -cur_frm.cscript['Calculate Charges']=function(doc,cdt,cdn){var other_fname=cur_frm.cscript.other_fname;var cl=getchildren('RV Tax Detail',doc.name,other_fname,doc.doctype);for(var i=0;i100){alert("Commision rate cannot be greater than 100.");doc.total_commission=0;doc.commission_rate=0;} -else -doc.total_commission=doc.net_total*doc.commission_rate/100;refresh_many(['total_commission','commission_rate']);} -cur_frm.cscript.total_commission=function(doc,cdt,cdn){if(doc.net_total){if(doc.net_total1?'s':'');} -this.render_points(points);if(user!='Guest'&&!in_list(voted,user)&&user!=owner){this.vote_up=$a(this.wrapper,'img','images/ui/vote_up.gif',{margin:'0px 0px -2px 7px',cursor:'pointer'});this.vote_down=$a(this.wrapper,'img','images/ui/vote_down.gif',{margin:'0px 0px -3px 0px',cursor:'pointer'});this.vote_up.title='Vote Up';this.vote_down.title='Vote Down';var callback=function(r,rt){if(r.exc){msgprint(r.exc);return;} -$dh(me.vote_up);$dh(me.vote_down);me.render_points(r.message);} -this.vote_up.onclick=function(){$c_page('knowledge_base','questions','vote',{vote:'up',dn:dn,dt:dt},callback);} -this.vote_down.onclick=function(){$c_page('knowledge_base','questions','vote',{vote:'down',dn:dn,dt:dt},callback);}}} -EditableText=function(args){$.extend(this,args);var me=this;this.display=$a(me.parent,'div',me.disp_class,'',me.text);this.input=$a(me.parent,'textarea',me.inp_class,{display:'none'});var div=$a(me.parent,'div','',{marginTop:'5px',height:'23px'});this.edit_btn=$a(div,'span','',{color:'#333',marginLeft:'-2px',cursor:'pointer',padding:'3px',backgroundColor:'#ddd',cssFloat:'left'});$br(this.edit_btn,'3px') -$a(this.edit_btn,'div','wn-icon ic-pencil',{marginBottom:'-2px',cssFloat:'left'});$a(this.edit_btn,'span','link_type',{marginLeft:'3px',color:'#555',fontSize:'11px'},'Edit');this.edit_btn.onclick=function(){me.input.value=me.display.innerHTML;me.show_as_input();} -this.save_btn=$btn(div,'Save',function(){var v=me.rich_text?wn.tinymce.get_value(me.input):me.input.value;if(!v){msgprint('Please write something!');return;} -me.save_btn.set_working();$c_page('knowledge_base','question_view','update_item',{dt:me.dt,dn:me.dn,fn:me.fieldname,text:v},function(r,rt){me.save_btn.done_working();if(r.exc){msgprint(r.exc);return;} -me.display.innerHTML=v;me.show_as_text();});},{display:'none'});this.cancel_btn=$a(div,'span','link_type',{color:'#555',display:'none'},'Cancel',{marginLeft:'7px'});this.cancel_btn.onclick=function(){me.show_as_text();} -this.show_as_text=function(){$ds(me.display);$ds(me.edit_btn);if(me.rich_text) -wn.tinymce.remove(me.input);$dh(me.input);$dh(me.save_btn);$dh(me.cancel_btn);} -this.show_as_input=function(){$ds(me.input);$ds(me.save_btn);$ds(me.cancel_btn);$dh(me.edit_btn);$dh(me.display);if(me.rich_text) -wn.tinymce.add_simple(me.input,'300px');}} \ No newline at end of file diff --git a/knowledge_base/page/question_view/question_view.comp.js b/knowledge_base/page/question_view/question_view.comp.js deleted file mode 100644 index 6f6d5bfe25..0000000000 --- a/knowledge_base/page/question_view/question_view.comp.js +++ /dev/null @@ -1,24 +0,0 @@ - -pscript['onload_question-view']=function(){var w=page_body.pages['question-view'];w.className='layout_wrapper';new PageHeader(w,'Knowledge Base');w.link=$ln($a(w,'div'),'< Back to all questions',function(){loadpage('questions');}) -w.body=$a(w,'div','qv-body');} -pscript['refresh_question-view']=function(){var qid=window.location.hash.split('/')[1];if(qid){pscript.question_view(qid);}} -pscript.question_view=function(qid,qtext){var w=page_body.pages['question-view'];new KBQuestionView(w,qid,qtext);} -KBQuestionView=function(w,qid,qtext){var me=this;w.body.innerHTML='';w.question_area=$a(w.body,'div','social qv-question-wrapper');w.answer_area=$a(w.body,'div','social qv-answer-wrapper');w.add_answer_link=$a(w.body,'div','',{margin:'3px 0px'});w.add_answer_area=$a(w.body,'div','qv-add-answer');this.make_question=function(){new EditableText({parent:w.question_area,dt:'Question',dn:qid,fieldname:'question',text:qtext,inp_class:'qv-input',disp_class:'qv-text'});} -this.make_answer_list=function(){this.ans_list=new KBAnswerList({parent:w.answer_area,qid:qid})} -this.make_add_answer=function(){$c_page('knowledge_base','question_view','has_answered',qid,function(r,rt){if(r.message=='No'){me.make_answer_box_link();}});} -this.make_answer_box_link=function(){$a(w.add_answer_link,'span','link_type',null,'+ Add your answer',function(){$dh(w.add_answer_link);me.make_answer_box();});} -this.make_answer_box=function(){$ds(w.add_answer_area);$a(w.add_answer_area,'h3','',{},'Add Your Answer') -this.input=$a(w.add_answer_area,'textarea');wn.tinymce.add_simple(this.input);this.btn=$btn($a(w.add_answer_area,'div'),'Post',function(){var v=wn.tinymce.get_value(me.input);if(!v){msgprint('Write something!');return;} -me.btn.set_working();$c_page('knowledge_base','question_view','add_answer',{qid:qid,answer:v},function(r,rt){me.btn.done_working();me.ans_list.list.run();$dh(w.add_answer_area);});});} -this.setup=function(){if(qtext){this.make();} -else{$c_page('knowledge_base','question_view','get_question',qid,function(r,rt){qtext=r.message;me.make();});}} -this.make=function(){set_title(qtext);this.make_question();this.make_answer_list();this.make_add_answer();} -this.setup();} -KBAnswerList=function(args){var me=this;$.extend(this,args);this.make_list=function(){this.list=new wn.widgets.Listing({parent:me.parent,as_dict:1,no_results_message:'No answers yet, be the first one to answer!',render_row:function(body,data){new KBAnswer(body,data)},get_query:function(){return repl("SELECT t1.name, t1.owner, t1.answer, t1.points, t1._users_voted, t2.first_name, " -+"t2.last_name, t1.modified from tabAnswer t1, tabProfile t2 " -+"where question='%(qid)s' and t1.owner = t2.name " -+"order by t1.points desc, t1.modified desc",{qid:me.qid})}});this.list.run();} -this.make_list();} -KBAnswer=function(body,data){body.className='qv-answer';new EditableText({parent:body,dt:'Answer',dn:data.name,fieldname:'answer',text:data.answer,inp_class:'qv-ans-input',disp_class:'qv-ans-text',rich_text:1});var div=$a(body,'div','',{}) -new KBItemToolbar({parent:div,det:data,with_tags:0,doctype:'Answer'},null)} -$import(knowledge_base.kb_common); \ No newline at end of file diff --git a/knowledge_base/page/questions/questions.comp.js b/knowledge_base/page/questions/questions.comp.js deleted file mode 100644 index 50c673148f..0000000000 --- a/knowledge_base/page/questions/questions.comp.js +++ /dev/null @@ -1,27 +0,0 @@ - -pscript.onload_questions=function(){var w=page_body.pages['questions'];var tab=make_table(w,1,2,'100%',['75%','25%'],{});var body=$a($td(tab,0,0),'div','layout_wrapper');new PageHeader(body,'Knowledge Base');var kb=new KnowledgeBase(body);$y($td(tab,0,1),{paddingTop:'53px'});this.sidebar=new wn.widgets.PageSidebar($td(tab,0,1),{sections:[{title:'Top Tags',render:function(body){new wn.widgets.TagCloud(body,'Question',function(tag){kb.set_tag_filter(tag)});}}]});set_title('Knowledge Base');} -function KnowledgeBase(w){var me=this;this.sort_by='modified';this.tag_filter_dict={};this.make_search_bar=function(){this.search=$a($a(w,'div','kb-search-wrapper'),'textarea');$(this.search).add_default_text('Enter keywords or a new Question');var div=$a(w,'div','kb-btn-wrapper');$btn(div,'Search',function(){me.run()},{fontSize:'14px'});$btn(div,'Ask',function(){me.ask()},{fontSize:'14px'});} -this.ask=function(){if(this.search.value==$(this.search).attr('default_text')){msgprint('Please enter some text');return;} -this.suggest();} -this.suggest=function(){this.dialog=new wn.widgets.Dialog({title:'Suggest a users',width:400,fields:[{fieldtype:'HTML',options:'Optional: Suggest a few users who can help you answer this question
'},{fieldtype:'Link',fieldname:'profile1',label:'1st User',options:'Profile'},{fieldtype:'Link',fieldname:'profile2',label:'2nd User',options:'Profile'},{fieldtype:'Link',fieldname:'profile3',label:'3rd User',options:'Profile'},{fieldtype:'Button',fieldname:'ask',label:'Add the Question'}]});this.dialog.fields_dict.ask.input.onclick=function(){me.dialog.hide();me.add_question(values(me.dialog.get_values()));} -this.dialog.show();} -this.add_question=function(suggest_list){$c_page('knowledge_base','questions','add_question',{question:this.search.value,suggest:suggest_list},function(r,rt){$(me.search).val('').blur();me.run();})} -this.make_tag_filter_area=function(){this.tag_filters=$a(w,'div','kb-tag-filter-area');$a(this.tag_filters,'span','',{marginRight:'4px',color:'#442'},'Showing for:');this.tag_area=$a(this.tag_filters,'span');} -this.make_list=function(){this.make_tag_filter_area();this.list_area=$a(w,'div','',{marginRight:'13px'}) -this.no_result=$a(w,'div','help_box',{display:'none'},'No questions asked yet! Be the first one to ask') -this.list=new wn.widgets.Listing({parent:this.list_area,no_results_message:'No questions found. Ask a new question!',as_dict:1,get_query:function(){var v=me.search.value==$(me.search).attr('default_text')?'':me.search.value;cond=v?(' and t1.question like "%'+v+'%"'):'';if(me.tag_filter_dict){for(f in me.tag_filter_dict){cond+=' and t1.`_user_tags` like "%'+f+'%"'}} -return repl('select t1.name, t1.owner, t1.question, t1.points, t1.modified, t1._user_tags, ' -+'t1._users_voted, t2.first_name, t2.last_name ' -+'from tabQuestion t1, tabProfile t2 ' -+'where t1.docstatus!=2 ' -+'and t1.owner = t2.name' -+'%(cond)s order by t1.modified desc',{user:user,cond:cond})},render_row:function(parent,data,listing){new KBQuestion(parent,data,me);}});this.list.run();} -this.set_tag_filter=function(tag){if(in_list(keys(me.tag_filter_dict),tag.label))return;var filter_tag=new SingleTag({parent:me.tag_area,label:tag.label,dt:'Question',color:tag.color});filter_tag.remove=function(tag_remove){$(tag_remove.body).fadeOut();delete me.tag_filter_dict[tag_remove.label];if(!keys(me.tag_filter_dict).length){$(me.tag_filters).slideUp();} -me.run();} -me.tag_filter_dict[tag.label]=filter_tag;$ds(me.tag_filters);me.run();} -this.run=function(){this.list.run();} -this.make_search_bar();this.make_list();} -KBQuestion=function(parent,det,kb){this.make=function(){this.wrapper=$a(parent,'div','kb-question-wrapper');this.q_area=$a($a(this.wrapper,'div'),'h3','kb-questions link_type',{display:'inline',textDecoration:'none'},det.question);this.q_area.onclick=function(){var q=this;window.location.href='#!question-view/'+q.id;} -this.q_area.id=det.name;this.q_area.txt=det.question;new KBItemToolbar({parent:this.wrapper,det:det,with_tags:1,doctype:'Question'},kb)} -this.make()} -$import(knowledge_base.kb_common); \ No newline at end of file diff --git a/material_management/doctype/delivery_note/tests.py b/material_management/doctype/delivery_note/tests.py new file mode 100644 index 0000000000..df04c417fa --- /dev/null +++ b/material_management/doctype/delivery_note/tests.py @@ -0,0 +1,25 @@ +import unittest +import webnotes + +from webnotes.model.code import get_obj + +class SubmissionTest(unittest.TestCase): + def setUp(self): + self.dn = webnotes.testing.create('Delivery Note') + self.dn_items = [] + + # get a line item for testing + for d in self.dn.doclist: + if d.doctype=='Delivery Note Detail': + self.dn_items.append(d) + + self.old_bin = get_obj('Warehouse', self.line_item[0].warehouse).get_bin(self.line_item[0].item_code) + self.dn.on_submit() + + def test_bin_is_updated(self): + "tests if bin quantity is affected when on submission" + bin = get_obj('Warehouse', self.line_item.warehouse).get_bin(self.line_item[0].item_code) + self.assertTrue(bin.actual_qty == self.old_bin.actual_qty - self.line_item[0].qty) + + def test_sales_order_is_updated(self): + "tests if" \ No newline at end of file diff --git a/material_management/tests.py b/material_management/tests.py new file mode 100644 index 0000000000..a8c0ffd66d --- /dev/null +++ b/material_management/tests.py @@ -0,0 +1,10 @@ +import unittest + +import sys +sys.path.append('/Users/rushabh/Workbench/www/wnframework/cgi-bin/') +sys.path.append('/Users/rushabh/Workbench/www/erpnext/') + +from material_management.doctype.delivery_note.tests import * + +if __name__ == '__main__': + unittest.main() \ No newline at end of file diff --git a/payroll/doctype/leave_allocation/leave_allocation.comp.js b/payroll/doctype/leave_allocation/leave_allocation.comp.js deleted file mode 100755 index 22b50410ee..0000000000 --- a/payroll/doctype/leave_allocation/leave_allocation.comp.js +++ /dev/null @@ -1,11 +0,0 @@ - -cur_frm.cscript.onload=function(doc,dt,dn){if(!doc.posting_date)set_multiple(dt,dn,{posting_date:get_today()});} -cur_frm.add_fetch('employee','employee_name','employee_name');cur_frm.cscript.employee=function(doc,dt,dn){calculate_total_leaves_allocated(doc,dt,dn);} -cur_frm.cscript.leave_type=function(doc,dt,dn){calculate_total_leaves_allocated(doc,dt,dn);} -cur_frm.cscript.fiscal_year=function(doc,dt,dn){calculate_total_leaves_allocated(doc,dt,dn);} -cur_frm.cscript.carry_forward=function(doc,dt,dn){calculate_total_leaves_allocated(doc,dt,dn);} -cur_frm.cscript.carry_forwarded_leaves=function(doc,dt,dn){set_multiple(dt,dn,{total_leaves_allocated:flt(doc.carry_forwarded_leaves)+flt(doc.new_leaves_allocated)});} -cur_frm.cscript.new_leaves_allocated=function(doc,dt,dn){set_multiple(dt,dn,{total_leaves_allocated:flt(doc.carry_forwarded_leaves)+flt(doc.new_leaves_allocated)});} -calculate_total_leaves_allocated=function(doc,dt,dn){if(cint(doc.carry_forward)==1&&doc.leave_type&&doc.fiscal_year&&doc.employee){var callback=function(){refresh_field('carry_forward');} -get_server_fields('get_carry_forwarded_leaves','','',doc,dt,dn,1,callback);} -else if(cint(doc.carry_forward)==0){set_multiple(dt,dn,{carry_forwarded_leaves:0,total_leaves_allocated:flt(doc.new_leaves_allocated)});}} \ No newline at end of file diff --git a/payroll/doctype/leave_application/leave_application.comp.js b/payroll/doctype/leave_application/leave_application.comp.js deleted file mode 100755 index 53990c27be..0000000000 --- a/payroll/doctype/leave_application/leave_application.comp.js +++ /dev/null @@ -1,14 +0,0 @@ - -cur_frm.cscript.onload=function(doc,dt,dn){if(!doc.posting_date)set_multiple(dt,dn,{posting_date:get_today()});} -cur_frm.add_fetch('employee','employee_name','employee_name');cur_frm.cscript.employee=function(doc,dt,dn){get_leave_balance(doc,dt,dn);} -cur_frm.cscript.fiscal_year=function(doc,dt,dn){get_leave_balance(doc,dt,dn);} -cur_frm.cscript.leave_type=function(doc,dt,dn){get_leave_balance(doc,dt,dn);} -cur_frm.cscript.half_day=function(doc,dt,dn){if(doc.from_date){set_multiple(dt,dn,{to_date:doc.from_date});calculate_total_days(doc,dt,dn);}} -cur_frm.cscript.from_date=function(doc,dt,dn){if(cint(doc.half_day)==1){set_multiple(dt,dn,{to_date:doc.from_date});} -calculate_total_days(doc,dt,dn);} -cur_frm.cscript.to_date=function(doc,dt,dn){if(cint(doc.half_day)==1&&doc.from_date&&doc.from_date!=doc.to_date){msgprint("To Date should be same as From Date for Half Day leave");return;} -if(cint(doc.half_day)==1){set_multiple(dt,dn,{to_date:doc.from_date});} -calculate_total_days(doc,dt,dn);} -get_leave_balance=function(doc,dt,dn){if(doc.employee&&doc.leave_type&&doc.fiscal_year) -get_server_fields('get_leave_balance','','',doc,dt,dn,1);} -calculate_total_days=function(doc,dt,dn){if(doc.from_date&&doc.to_date){if(cint(doc.half_day)==1)set_multiple(dt,dn,{total_leave_days:0.5});else{get_server_fields('get_total_leave_days','','',doc,dt,dn,1);}}} \ No newline at end of file diff --git a/projects/doctype/ticket/ticket.comp.js b/projects/doctype/ticket/ticket.comp.js deleted file mode 100644 index 35972cb828..0000000000 --- a/projects/doctype/ticket/ticket.comp.js +++ /dev/null @@ -1,16 +0,0 @@ - -cur_frm.cscript.onload=function(doc,cdt,cdn){if(!doc.senders_name){doc.senders_name=user_fullname;doc.senders_email=user;refresh_many(['senders_name','senders_email']);} -if(doc.__islocal){doc.status='Open';doc.opening_date=get_today();refresh_many(['status','opening_date']);} -else{if(!doc.opening_date){doc.opening_date=dateutil.str_to_user(only_date(doc.creation));refresh_field('opening_date');}} -if(doc.status=='Open')doc.review_date=doc.closing_date='';else if(doc.status=='Pending Review')doc.closing_date='';refresh_many(['closing_date','review_date']);if(doc.project)cur_frm.cscript.project(doc,cdt,cdn);} -cur_frm.cscript.refresh=function(doc,cdt,cdn){cur_frm.clear_custom_buttons();if(doc.status=='Pending Review'&&(doc.senders_name==user_fullname||doc.senders_email==user)){cur_frm.add_custom_button('Declare Completed',cur_frm.cscript['Declare Completed']);cur_frm.add_custom_button('Reopen Task',cur_frm.cscript['Reopen Task']);} -if(doc.status=='Open'&&!doc.__islocal){cur_frm.add_custom_button('Cancel Task',cur_frm.cscript['Cancel Task']);if(doc.allocated_to==user)cur_frm.add_custom_button('Get Approval',cur_frm.cscript['Get Approval']);}} -cur_frm.fields_dict['project'].get_query=function(doc,cdt,cdn){var cond='';if(doc.customer)cond='ifnull(`tabProject`.customer, "") = "'+doc.customer+'" AND';return repl('SELECT distinct `tabProject`.`name` FROM `tabProject` WHERE %(cond)s `tabProject`.`name` LIKE "%s" ORDER BY `tabProject`.`name` ASC LIMIT 50',{cond:cond});} -cur_frm.cscript.project=function(doc,cdt,cdn){if(doc.project)get_server_fields('get_project_details','','',doc,cdt,cdn,1);} -cur_frm.fields_dict['customer'].get_query=function(doc,cdt,cdn){var cond='';if(doc.project)cond='ifnull(`tabProject`.customer, "") = `tabCustomer`.name AND ifnull(`tabProject`.name, "") = "'+doc.project+'" AND';return repl('SELECT distinct `tabCustomer`.`name` FROM `tabCustomer`, `tabProject` WHERE %(cond)s `tabCustomer`.`name` LIKE "%s" ORDER BY `tabCustomer`.`name` ASC LIMIT 50',{cond:cond});} -cur_frm.cscript.customer=function(doc,cdt,cdn){if(doc.customer)get_server_fields('get_customer_details','','',doc,cdt,cdn,1);else doc.customer_name='';} -cur_frm.cscript.allocated_to=function(doc,cdt,cdn){get_server_fields('get_allocated_to_name','','',doc,cdt,cdn,1);} -cur_frm.cscript['Get Approval']=function(){$c_obj(make_doclist(cur_frm.doc.doctype,cur_frm.doc.name),'set_for_review','',function(r,rt){if(r.message=='true'){doc.status='Pending Review';refresh_many(['review_date','status']);cur_frm.cscript.refresh(cur_frm.doc,cur_frm.doc.doctype,cur_frm.doc.name);}});} -cur_frm.cscript['Reopen Task']=function(){$c_obj(make_doclist(cur_frm.doc.doctype,cur_frm.doc.name),'reopen_task','',function(r,rt){if(r.message=='true'){doc.status='Open';refresh_many(['status']);cur_frm.cscript.refresh(cur_frm.doc,cur_frm.doc.doctype,cur_frm.doc.name);}});} -cur_frm.cscript['Cancel Task']=function(){$c_obj(make_doclist(cur_frm.doc.doctype,cur_frm.doc.name),'cancel_task','',function(r,rt){if(r.message=='true'){doc.status='Cancelled';refresh_many(['status']);cur_frm.cscript.refresh(cur_frm.doc,cur_frm.doc.doctype,cur_frm.doc.name);}});} -cur_frm.cscript['Declare Completed']=function(){$c_obj(make_doclist(cur_frm.doc.doctype,cur_frm.doc.name),'declare_completed','',function(r,rt){if(r.message=='true'){doc.status='Closed';refresh_many(['review_date','closing_date','status']);cur_frm.cscript.refresh(cur_frm.doc,cur_frm.doc.doctype,cur_frm.doc.name);}});} \ No newline at end of file diff --git a/projects/page/projects/projects.comp.js b/projects/page/projects/projects.comp.js deleted file mode 100644 index d2bd8679c9..0000000000 --- a/projects/page/projects/projects.comp.js +++ /dev/null @@ -1,29 +0,0 @@ - -pscript.queries_bg_dict={'Urgent':'RED','High':'ORANGE','Low':'BLUE','Closed':'GREEN','Pending Review':'YELLOW'} -pscript.onload_Projects=function(){var d=$i('projects_div');new PageHeader(d,'Gantt Chart');new GanttChart($a(d,'div','',{margin:'16px'}));} -GanttChart=function(parent){this.wrapper=$a(parent,'div');this.toolbar_area=$a(this.wrapper,'div','',{padding:'16px',border:'1px solid #AAF',});$bg(this.toolbar_area,'#EEF');$br(this.toolbar_area,'3px');this.toolbar_tab=make_table(this.toolbar_area,1,4,'100%',['25%','25%','25%','25%']);this.grid_area=$a(this.wrapper,'div','',{margin:'16px 0px'});this.no_task_message=$a(this.wrapper,'div','help_box',{textAign:'center',fontSize:'14px'},'Select your criteria and click on "Make" to show the Gantt Chart') -this.get_init_data();} -GanttChart.prototype.get_init_data=function(){var me=this;var callback=function(r,rt){me.pl=r.message.pl.sort();me.rl=r.message.rl.sort();me.make_toolbar();} -$c_obj('Project Control','get_init_data','',callback);} -GanttChart.prototype.make_filter=function(label,idx){var w=$a($td(this.toolbar_tab,0,idx),'div','',{marginBottom:'8px'});var l=$a(w,'div','',{fontSize:'11px'});l.innerHTML=label;return w;} -GanttChart.prototype.make_select=function(label,options,idx){var w=this.make_filter(label,idx);var s=$a(w,'select','',{width:'100px'});add_sel_options(s,add_lists(['All'],options));return s;} -GanttChart.prototype.make_date=function(label,idx){var w=this.make_filter(label,idx);var i=$a(w,'input');var user_fmt=locals['Control Panel']['Control Panel'].date_format;if(!this.user_fmt)this.user_fmt='dd-mm-yy';$(i).datepicker({dateFormat:user_fmt.replace('yyyy','yy'),altFormat:'yy-mm-dd',changeYear:true});return i;} -GanttChart.prototype.make_toolbar=function(){this.r_sel=this.make_select('Resource',this.rl,0);this.p_sel=this.make_select('Project',this.pl,1);this.s_date=this.make_date('Start Date',2);this.s_date.value=date.str_to_user(date.month_start());this.e_date=this.make_date('End Date',3);this.e_date.value=date.str_to_user(date.month_end());var me=this;$btn(this.toolbar_area,'Make',function(){me.refresh();},null,'green',1);this.print_btn=$btn(this.toolbar_area,'Print',function(){me.print();},{display:'none'},null);} -GanttChart.prototype.print=function(){$(this.grid_area).printElement();} -GanttChart.prototype.get_data=function(){var me=this;var callback=function(r,rt){me.tasks=r.message;if(me.tasks.length){$dh(me.no_task_message);$ds(me.grid_area);me.show_tasks();$di(me.print_btn);}else{$dh(me.grid_area);$ds(me.no_task_message);$dh(me.print_btn);me.no_task_message.innerHTML='Nothing allocated for the above criteria'}} -$c_obj('Project Control','get_tasks',[date.user_to_str(this.s_date.value),date.user_to_str(this.e_date.value),sel_val(this.p_sel),sel_val(this.r_sel)].join('~~~'),callback)} -GanttChart.prototype.make_grid=function(){this.grid_area.innerHTML='';this.grid=new GanttGrid(this,this.s_date.value,this.e_date.value);} -GanttChart.prototype.refresh=function(){this.get_data();} -GanttChart.prototype.show_tasks=function(){this.make_grid();for(var i=0;i=100)x2=100;$y(this.body,{top:idx*40+14+'px',left:x1+'%',width:(x2-x1)+'%',zIndex:1,cursor:'pointer'}) -if(idx){var d1=$a(grid.task_area,'div','',{borderBottom:'1px solid #AAA',position:'absolute',width:'100%',top:(idx*40)+'px'});var d2=$a(grid.y_labels,'div','',{borderBottom:'1px solid #AAA',position:'absolute',width:'100%',top:(idx*40)+'px'});} -this.make_tooltip(data);} -GanttTask.prototype.make_tooltip=function(d){var t='
';if(d[0])t+='Task: '+d[0];if(d[5])t+='
Priority: '+d[5];if(d[6])t+='
Status: '+d[6];if(d[1])t+='
Allocated To: '+d[1];if(d[2])t+='
Project: '+d[2];if(d[3])t+='
From: '+date.str_to_user(d[3]);if(d[4])t+='
To: '+date.str_to_user(d[4]);t+='
';$(this.body).qtip({content:t,position:{corner:{tooltip:'topMiddle',target:'bottomMiddle'}},style:{border:{width:5,radius:10},padding:10,tip:true,name:'green'}})} \ No newline at end of file diff --git a/setup/doctype/other_charges/other_charges.comp.js b/setup/doctype/other_charges/other_charges.comp.js deleted file mode 100644 index 403a4ce875..0000000000 --- a/setup/doctype/other_charges/other_charges.comp.js +++ /dev/null @@ -1,29 +0,0 @@ - -cur_frm.cscript.onload=function(doc,cdt,cdn){} -cur_frm.pformat.other_charges=function(doc){var make_row=function(title,val,bold){var bstart='';var bend='';return''+(bold?bstart:'')+title+(bold?bend:'')+'' -+''+doc.currency+'' -+''+val+'' -+''} -function convert_rate(val){var new_val=flt(val)/flt(doc.conversion_rate);return new_val;} -out='';if(!doc.print_without_amount){var cl=getchildren('RV Tax Detail',doc.name,'other_charges');var out='
';out+=''+make_row('Net Total',fmt_money(convert_rate(doc.net_total)),1);if(cl.length){for(var i=0;i'} -out+='
';} -return out;} -cur_frm.cscript.charge_type=function(doc,cdt,cdn){var d=locals[cdt][cdn];if(d.idx==1&&(d.charge_type=='On Previous Row Amount'||d.charge_type=='On Previous Row Total')){alert("You cannot select Charge Type as 'On Previous Row Amount' or 'On Previous Row Total' for first row");d.charge_type='';} -validated=false;refresh_field('charge_type',d.name,'other_charges');cur_frm.cscript.row_id(doc,cdt,cdn);cur_frm.cscript.rate(doc,cdt,cdn);cur_frm.cscript.tax_amount(doc,cdt,cdn);} -cur_frm.cscript.row_id=function(doc,cdt,cdn){var d=locals[cdt][cdn];if(!d.charge_type&&d.row_id){alert("Please select Charge Type first");d.row_id='';} -else if((d.charge_type=='Actual'||d.charge_type=='On Net Total')&&d.row_id){alert("You can Enter Row only if your Charge Type is 'On Previous Row Amount' or ' Previous Row Total'");d.row_id='';} -else if((d.charge_type=='On Previous Row Amount'||d.charge_type=='On Previous Row Total')&&d.row_id){if(d.row_id>=d.idx){alert("You cannot Enter Row no. greater than or equal to current row no. for this Charge type");d.row_id='';}} -validated=false;refresh_field('row_id',d.name,'other_charges');} -cur_frm.fields_dict['other_charges'].grid.get_field("account_head").get_query=function(doc,cdt,cdn){return'SELECT tabAccount.name FROM tabAccount WHERE tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus != 2 AND (tabAccount.account_type = "Tax" OR tabAccount.account_type = "Chargeable") AND tabAccount.company = "'+doc.company+'" AND tabAccount.name LIKE "%s"'} -cur_frm.cscript.account_head=function(doc,cdt,cdn){var d=locals[cdt][cdn];if(!d.charge_type&&d.account_head){alert("Please select Charge Type first");validated=false;d.account_head='';} -else if(d.account_head&&d.charge_type){arg="{'charge_type' : '"+d.charge_type+"', 'account_head' : '"+d.account_head+"'}";get_server_fields('get_rate',arg,'other_charges',doc,cdt,cdn,1);} -refresh_field('account_head',d.name,'other_charges');} -cur_frm.cscript.rate=function(doc,cdt,cdn){var d=locals[cdt][cdn];if(!d.charge_type&&d.rate){alert("Please select Charge Type first");d.rate='';} -validated=false;refresh_field('rate',d.name,'other_charges');} -cur_frm.cscript.tax_amount=function(doc,cdt,cdn){var d=locals[cdt][cdn];if(!d.charge_type&&d.tax_amount){alert("Please select Charge Type first");d.tax_amount='';} -else if(d.charge_type&&d.tax_amount){alert("You cannot directly enter Amount and if your Charge Type is Actual enter your amount in Rate");d.tax_amount='';} -validated=false;refresh_field('tax_amount',d.name,'other_charges');} \ No newline at end of file diff --git a/setup/doctype/setup_control/setup_control.py b/setup/doctype/setup_control/setup_control.py index dee01b2f6b..284e2a8a36 100644 --- a/setup/doctype/setup_control/setup_control.py +++ b/setup/doctype/setup_control/setup_control.py @@ -145,7 +145,7 @@ class DocType: pr = Document('Profile') pr.first_name = user_fname pr.last_name = user_lname - pr.email = user_email + pr.name = pr.email = user_email pr.enabled = 1 pr.save(1) self.add_roles(pr) @@ -158,9 +158,9 @@ class DocType: d.save(1) # Add roles to Administrator profile - pr_obj = get_obj('Profile','Administrator') + pr = Document('Profile','Administrator') for r in roles_list: - d = addchild(pr_obj.doc,'userroles', 'UserRole', 1) + d = addchild(pr,'userroles', 'UserRole', 1) d.role = r d.save(1) diff --git a/setup/page/people/people.comp.js b/setup/page/people/people.comp.js deleted file mode 100644 index 8938b6a73a..0000000000 --- a/setup/page/people/people.comp.js +++ /dev/null @@ -1,50 +0,0 @@ - -pscript.onload_people=function(){make_customer_tab($i('crm_home'));} -function make_customer_tab(parent){new DocColumnView('Customers',parent,['Customer Group','Customer','Contact'],{'Customer Group':{show_fields:['name'],create_fields:['name'],search_fields:['name'],next_col:'Customer'},'Customer':{show_fields:['name','customer_name'],create_fields:['name','customer_name'],search_fields:['customer_name'],filter_by:['Customer Group','customer_group'],next_col:'Contact'},'Contact':{show_fields:['name','first_name','last_name'],create_fields:['name','first_name','last_name'],search_fields:['first_name','last_name'],conditions:['is_customer=1'],filter_by:['Customer','customer']},})} -function DocColumnView(title,parent,items,opts){this.columns={};this.items=items;this.page_head=new PageHeader(parent,title);this.make_columns(items.length,parent);for(var i=0;i1){var l=[];for(var i=1;iPlease Note: Any action will also affect other permissions with similar rules!' -var t=make_table($a(w,'div','',{borderBottom:'1px solid #AAA'}),1,3,'90%',['40%','40%','20%'],{fontWeight:'bold',padding:'3px',fontSize:'14px'});$td(t,0,0).innerHTML='Who?';$td(t,0,1).innerHTML='Is allowed if '+details.match+' equals';var dl=r.message.dl;this.options=r.message.ol;if(!this.profiles){this.profiles=r.message.pl;} -for(var i=0;iDeleting...';var callback=function(r,rt){$dh(me.wrapper);if(r.exc)msgprint('There were errors!')} -$c_obj('Permission Control','delete_default',[this.details.parent,this.fieldname,this.details.defvalue].join('~~~'),callback)} -MatchDefaultValue.prototype.save=function(){var me=this;var callback=function(r,rt){me.details=r.message;me.clear();me.render();me.pe.add_new_match_row(me.fieldname);} -if(sel_val(this.profile_or_role)=='Profile'){var parent=sel_val(this.profile_sel);var parenttype='Profile';} -else{var parent=sel_val(this.role_sel);var parenttype='Role';} -if(!sel_val(this.options_sel)||!parent){msgprint("Please select all values");return;} -$c_obj('Permission Control','add_default',[parent,parenttype,this.fieldname,sel_val(this.options_sel)].join('~~~'),callback);this.wrapper.innerHTML='
Adding...
';} -pscript.PermEngine.prototype.make_fields_dialog=function(){if(!pscript.get_field_dialog){pscript.get_field_dialog=new Dialog(750,500,'Fields');pscript.get_field_dialog.make_body([['HTML','Fields','
'],['Button','OK']]);} -else $i('perm_engine_get_fields').innerHTML='';} -pscript.PermEngine.prototype.get_fields=function(dt,permlevel){var me=this;var callback=function(r,rt){var parent_fields_dict=r.message.parent_fields_dict;var table_fields_dict=r.message.table_fields_dict;me.make_fields_dialog();me.make_fields_table(dt,parent_fields_dict,table_fields_dict,permlevel);pscript.get_field_dialog.show();pscript.get_field_dialog.widgets['OK'].onclick=function(){pscript.get_field_dialog.hide();}} -var args="{'dt':'"+dt+"','permlevel':"+permlevel+"}" -$c_obj('Permission Control','get_fields',args,callback);} -pscript.PermEngine.prototype.make_fields_table=function(dt,parent_fields_dict,table_fields_dict,permlevel){var make_grid=function(table,fields_dict){var col_labels=['Label','Fieldtype','Fieldname','Options'];for(var n=0;n'+col_labels[n]+'';$td(table,0,n).fieldname=col_labels[n].toLowerCase();} -for(var i=0;i

';var parent_field_table=make_table('perm_engine_get_fields',keys(parent_fields_dict).length+1,4,'100%',['25%','25%','25%','25%'],{border:'1px solid #AAA',padding:'2px'});make_grid(parent_field_table,parent_fields_dict);child_tables=keys(table_fields_dict) -if(child_tables.length>0){for(var k=0;k0){$i('perm_engine_get_fields').innerHTML+='
'+child_tables[k]+' Fields at Level '+permlevel+':

' -var child_field_table=make_table('perm_engine_get_fields',keys(tab_fields_det).length+1,4,'100%',['25%','25%','25%','25%'],{border:'1px solid #AAA',padding:'2px'});make_grid(child_field_table,tab_fields_det);}}}} -pscript.PermEngine.prototype.update_permissions=function(){var me=this;var out={};var add_to_out=function(doctype,permlevel,role,key,value){if(!out[doctype])out[doctype]={};if(!out[doctype][permlevel])out[doctype][permlevel]={};if(!out[doctype][permlevel][role])out[doctype][permlevel][role]={};out[doctype][permlevel][role][key]=value;} -for(i in pscript.all_checkboxes){c=pscript.all_checkboxes[i];add_to_out(c.doctype,c.permlevel,c.role,c.perm_type,c.checked?1:0);} -for(var i=0;ib[0];});for(var i=0;i