mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-14 12:25:09 +00:00
added sample tests
This commit is contained in:
@@ -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='<b>';var bend='</b>';return'<tr><td style="width:50%;">'+(bold?bstart:'')+title+(bold?bend:'')+'</td>'
|
||||
+'<td style="width:25%;text-align:right;">'+doc.currency+'</td>'
|
||||
+'<td style="width:25%;text-align:right;">'+val+'</td>'
|
||||
+'</tr>'}
|
||||
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='<div><table class="noborder" style="width:100%"><tr><td style="width: 60%"></td><td>';out+='<table class="noborder" style="width:100%">'+make_row('Net Total',fmt_money(convert_rate(doc.net_total)),1);if(cl.length){for(var i=0;i<cl.length;i++){if(fmt_money(convert_rate(cl[i].tax_amount))!=0)
|
||||
out+=make_row(cl[i].description,fmt_money(convert_rate(cl[i].tax_amount)),0);}}
|
||||
out+=make_row('Grand Total',fmt_money(doc.grand_total_export),1)+make_row('Rounded Total',fmt_money(doc.rounded_total_export),1)
|
||||
if(doc.in_words_export){out+='</table></td></tr>';out+='<tr><td colspan = "2">';out+='<table><tr><td style="width:25%;"><b>In Words</b></td>'
|
||||
out+='<td style="width:50%;">'+doc.in_words_export+'</td></tr>'}
|
||||
out+='</table></td></tr></table></div>';}
|
||||
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');}
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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;i<items.length;i++){var c=opts[items[i]];this.columns[items[i]]=new List2(this,$td(this.tab,0,i),items[i],c);}
|
||||
this.columns[items[0]].run();}
|
||||
DocColumnView.prototype.make_columns=function(n,parent){var cl=[];for(var i=0;i<n;i++){cl.push(cint(100/n)+'%')}
|
||||
this.tab=make_table(parent,1,n,'100%',cl)
|
||||
this.tab.className='dcv-tab';}
|
||||
DocColumnView.prototype.refresh=function(){this.columns[this.items[0]].run();}
|
||||
function List2(dcv,parent,doctype,opts){this.dcv=dcv;this.doctype=doctype;this.opts=opts;this.dtl=get_doctype_label(doctype);this.make_body(parent);this.selected_item=null;}
|
||||
List2.prototype.make_body=function(parent){this.make_toolbar(parent);this.make_search(parent);this.make_message(parent);this.make_list(parent);this.clear();}
|
||||
List2.prototype.make_toolbar=function(parent){var me=this;this.head=$a(parent,'div','list2-head');$gr(this.head,'#EEE','#CCC');var t=make_table(this.head,1,2,'100%',['60%','40%'],{verticalAlign:'middle'});var span=$a($td(t,0,0),'span','',{cssFloat:'left'},this.dtl);var refresh_icon=$a($td(t,0,0),'div','wn-icon ic-playback_reload',{marginLeft:'7px',cssFloat:'left'});refresh_icon.onclick=function(){me.run();}
|
||||
this.btn=$btn($td(t,0,1),'+ New',function(){me.make_new();},{fontWeight:'bold',cssFloat:'right'},'green');}
|
||||
List2.prototype.make_search=function(parent){var me=this;this.searchbar=$a(parent,'div','list2-search');this.search_inp=$a_input(this.searchbar,'text');this.search_btn=$a(this.searchbar,'img','',{cursor:'pointer',marginLeft:'8px',marginBottom:'-3px'});this.search_btn.src='images/icons/magnifier.png';this.search_btn.onclick=function(){me.run();}}
|
||||
List2.prototype.make_message=function(parent){this.clear_message=$a(parent,'div','help_box',{margin:'4px',display:'none'},(this.opts.filter_by?('Select '+get_doctype_label(this.opts.filter_by[0])+' to see list'):''));this.no_result_message=$a(parent,'div','help_box',{margin:'4px',display:'none'},'No '+this.dtl+' created yet!');}
|
||||
List2.prototype.make_new=function(){var me=this;newdoc(this.doctype,function(dn){if(me.opts.filter_by){var val=me.dcv.columns[me.opts.filter_by[0]].get_selected();if(val)
|
||||
locals[me.doctype][dn][me.opts.filter_by[1]]=val;}});}
|
||||
List2.prototype.clear=function(){$dh(this.lst_area);$ds(this.clear_message)
|
||||
$dh(this.no_result_message);this.clear_next();}
|
||||
List2.prototype.show_list=function(){$ds(this.lst_area);$dh(this.clear_message)
|
||||
$dh(this.no_result_message);}
|
||||
List2.prototype.show_no_result=function(){if(!this.search_inp.value){$dh(this.lst_area);$dh(this.clear_message);$ds(this.no_result_message);}}
|
||||
List2.prototype.clear_next=function(){if(this.opts.next_col&&this.dcv.columns[this.opts.next_col])this.dcv.columns[this.opts.next_col].clear();}
|
||||
List2.prototype.make_list=function(parent){var me=this;this.lst_area=$a(parent,'div','list2-list-area');this.lst=new Listing('Profiles',1);this.lst.opts.hide_refresh=1;this.lst.opts.cell_style={padding:'0px'};this.lst.colwidths=['100%'];this.lst.get_query=function(){var q=me.build_query();this.query=q[0];this.query_max=q[1];}
|
||||
this.lst.make(this.lst_area);this.lst.show_cell=function(cell,ri,ci,d){new List2Item(cell,d[ri],me);}
|
||||
this.lst.onrun=function(){me.show_list();me.clear_next();if(!me.lst.has_data())me.show_no_result();}}
|
||||
List2.prototype.run=function(){$dh(this.lst.results);this.lst.run();}
|
||||
List2.prototype.build_query=function(){var args={fields:this.opts.show_fields.join(', '),doctype:this.doctype,cond:''}
|
||||
var cl=this.build_search_conditions();cl=this.add_filter_condition(cl);if(cl.length)args.cond=' AND '+cl.join(' AND ');var query=repl('SELECT %(fields)s FROM `tab%(doctype)s` WHERE docstatus < 2 %(cond)s',args)
|
||||
var query_max=repl('SELECT COUNT(*) FROM `tab%(doctype)s` WHERE docstatus < 2 %(cond)s',args)
|
||||
return[query,query_max]}
|
||||
List2.prototype.build_search_conditions=function(){var cl=new Array();if(this.opts.conditions){for(var i=0;i<this.opts.conditions.length;i++)cl.push(this.opts.conditions);}
|
||||
if(this.search_inp.value&&this.search_inp.value!='Search'){for(var i=0;i<this.opts.search_fields.length;i++){cl.push(repl('`%(field)s` LIKE "%(txt)s"',{field:this.opts.search_fields[i],txt:'%'+this.search_inp.value+'%'}));}}
|
||||
return cl;}
|
||||
List2.prototype.add_filter_condition=function(cl){if(this.opts.filter_by){cl.push(repl('`%(filter)s` = "%(val)s"',{filter:this.opts.filter_by[1],val:this.dcv.columns[this.opts.filter_by[0]].get_selected()}));}
|
||||
return cl;}
|
||||
List2.prototype.get_selected=function(){if(this.selected_item)return this.selected_item.det[0];else return'';}
|
||||
List2Item=function(cell,det,list2){this.det=det;this.list2=list2;this.make_body(cell);this.show_text();this.show_more_info();}
|
||||
List2Item.prototype.make_body=function(cell){var me=this;this.body=$a(cell,'div','list2-item-div')
|
||||
if(me.list2.opts.next_col){this.make_with_icon();}else{this.content=this.body;}
|
||||
this.body.onclick=function(){me.select();if(me.list2.opts.next_col)me.list2.dcv.columns[me.list2.opts.next_col].run();}}
|
||||
List2Item.prototype.make_with_icon=function(){var t=make_table(this.body,1,2,'100%',['','18px'])
|
||||
$y($td(t,0,1),{verticalAlign:'middle'})
|
||||
var img=$a($td(t,0,1),'img');img.src='images/icons/control_play.png';this.content=$td(t,0,0);}
|
||||
List2Item.prototype.show_text=function(){var me=this;this.label=$a(this.content,'div','list2-item-title','',this.det[0]);var span=$a(this.label,'span','link_type list2-edit-link','','[Edit]');span.onclick=function(){loaddoc(me.list2.doctype,me.det[0]);}}
|
||||
List2Item.prototype.show_more_info=function(){var det=this.det;if(det.length>1){var l=[];for(var i=1;i<det.length;i++){if(det[i]&&det[i]!=det[0])l.push(det[i]);}
|
||||
if(l.length)
|
||||
this.more_info=$a(this.content,'div','list2-item-more-info','',l.join(', '))}}
|
||||
List2Item.prototype.select=function(){if(this.list2.selected_item)this.list2.selected_item.deselect();this.body.className='list2-item-div list2-item-selected';this.list2.selected_item=this;}
|
||||
List2Item.prototype.deselect=function(){this.body.className='list2-item-div';}
|
||||
@@ -1,75 +0,0 @@
|
||||
|
||||
pscript['onload_Permission Engine']=function(){var h=new PageHeader('pe_header','Permissions Manager','Set specific permissions for Roles')
|
||||
if(!pscript.perm_engine)pscript.perm_engine=new pscript.PermEngine();}
|
||||
pscript.PermEngine=function(){this.wrapper=$i('perm_engine_div');this.head=$a(this.wrapper,'div');this.body=$a(this.wrapper,'div');this.footer=$a(this.wrapper,'div');var lab=$a(this.body,'div','',{backgroundColor:'#FFD',padding:'8px',margin:'16px 0px'});lab.innerHTML='Please select the item for which you want to set permissions';this.make_head();this.load_options();}
|
||||
pscript.PermEngine.prototype.make_head=function(){var me=this;var make_select=function(label){var w=$a(me.head,'div','',{margin:'8px 0px'});var t=make_table(w,1,2,'300px',['50%','50%']);$td(t,0,0).innerHTML=label;var s=$a($td(t,0,1),'select','',{width:'140px'});s.wrapper=w;return s;}
|
||||
var make_button=function(label,parent,green){return $btn(parent,label,null,{margin:'8px 0px',display:'none'},(green?'green':null));}
|
||||
this.type_select=make_select('Set Permissions For');this.type_select.onchange=function(){me.get_permissions();}
|
||||
this.add_button=make_button('+ Add A New Rule',this.head,0);this.add_button.onclick=function(){me.add_permission();}
|
||||
this.update_button=make_button('Update',this.footer,1);this.update_button.onclick=function(){me.update_permissions();}}
|
||||
pscript.PermEngine.prototype.add_permission=function(){var me=this;if(!this.add_permission_dialog){var d=new Dialog(400,400,'Add Permission');d.make_body([['Select','Role'],['Select','Level'],['Button','Add']])
|
||||
add_sel_options(d.widgets['Role'],this.roles,'');add_sel_options(d.widgets['Level'],[0,1,2,3,4,5,6,7,8,9],0);d.widgets['Add'].onclick=function(){if(!sel_val(d.widgets['Role'])){msgprint('Please select Role');return;}
|
||||
var callback=function(r,rt){me.get_permissions();d.hide();}
|
||||
$c_obj('Permission Control','add_permission',JSON.stringify([sel_val(me.type_select),sel_val(d.widgets['Role']),sel_val(d.widgets['Level'])]),callback);}
|
||||
this.add_permission_dialog=d;}
|
||||
this.add_permission_dialog.show();}
|
||||
pscript.PermEngine.prototype.hide_fields=function(){$dh(this.role_select.wrapper);this.type_select.disabled=false;this.body.innerHTML='';}
|
||||
pscript.PermEngine.prototype.load_options=function(){var me=this;$dh(me.update_button);$dh(me.add_button);$c_obj('Permission Control','get_doctype_list','',function(r,rt){me.roles=r.message.roles;empty_select(me.type_select);add_sel_options(me.type_select,add_lists([''],r.message.doctypes));});}
|
||||
pscript.PermEngine.prototype.get_permissions=function(){var me=this;if(!sel_val(me.type_select)){msgprint('Please select a type first!');return;}
|
||||
$c_obj('Permission Control','get_permissions',sel_val(me.type_select),function(r,rt){if(r.message.perms.length)me.get_results(r.message);else me.body.innerHTML='<div style = "color : red; margin:8px 0px;">No Records Found</div>'});}
|
||||
pscript.PermEngine.prototype.get_results=function(r){var perms=r.perms;var me=this;var doctype=sel_val(me.type_select);$ds(me.update_button);$ds(me.add_button);this.body.innerHTML=''
|
||||
pscript.all_checkboxes=[];pscript.all_matches=[];var head=$a(this.body,'h3');head.innerHTML='Rules for '+doctype;var permt=make_table(me.body,perms.length+1,9,'80%',[],{border:'1px solid #AAA',padding:'3px',verticalAlign:'middle',height:'30px'});var col_labels=['Role','Level','Read','Write','Create','Submit','Cancel','Amend','Restrict By']
|
||||
for(var n=0;n<col_labels.length;n++){$y($td(permt,0,n),{backgroundColor:'#DDD',width:(n==0?'30%':(n==8?'21%':'7%'))})
|
||||
$td(permt,0,n).innerHTML=col_labels[n];$td(permt,0,n).fieldname=col_labels[n].toLowerCase();}
|
||||
for(var j=0;j<perms.length;j++){var plevel=$a($td(permt,j+1,1),'span','link_type');plevel.innerHTML=perms[j].permlevel;plevel.doctype=doctype;plevel.value=perms[j].permlevel;plevel.onclick=function(){me.get_fields(this.doctype,this.value)}
|
||||
$td(permt,j+1,0).innerHTML=perms[j].role;}
|
||||
for(var l=0;l<perms.length;l++){for(var m=0;m<6;m++){var chk=$a_input($td(permt,l+1,m+2),'checkbox');var val=perms[l][$td(permt,0,m+2).fieldname];if(val==1)chk.checked=1;else chk.checked=0;chk.doctype=doctype;chk.permlevel=perms[l].permlevel;chk.perm_type=col_labels[m+2].toLowerCase();chk.role=perms[l].role;pscript.all_checkboxes.push(chk);}}
|
||||
me.add_match_select(r,perms,permt,doctype);}
|
||||
pscript.PermEngine.prototype.add_match_select=function(r,perms,permt,doctype){var me=this;for(var i=0;i<perms.length;i++){if(perms[i].permlevel==0){var sel=$a($td(permt,i+1,8),'select','',{width:'100%'});add_sel_options(sel,r.fields);sel.details=perms[i];sel.details.parent=doctype;sel.onchange=function(){if(sel_val(this)&&sel_val(this)!='owner')$ds(this.div);else $dh(this.div);}
|
||||
var div=$a($td(permt,i+1,8),'div','link_type',{marginTop:'2px',fontSize:'10px',display:'none'});div.onclick=function(){this.details.match=sel_val(this.sel);me.show_match_dialog(this.details);}
|
||||
div.innerHTML='Set Users / Roles';div.details=perms[i];sel.div=div;div.sel=sel;if(perms[i].match){sel.value=perms[i].match;$ds(div);}
|
||||
pscript.all_matches.push(sel);}}}
|
||||
pscript.PermEngine.prototype.show_match_dialog=function(details){if(!this.match_defaults_dialog){var d=new Dialog(750,500,'Permission Applies To');d.make_body([['HTML','Body']]);var w=d.widgets['Body'];$y(w,{height:'350px',overflow:'auto'});this.match_defaults_dialog=d;}
|
||||
this.match_defaults_dialog.show();var me=this;var callback=function(r,rt){me.render_match_dialog(r,details);}
|
||||
$c_obj('Permission Control','get_defaults',details.match+'~~~'+(this.profiles?'No':'Yes'),callback);}
|
||||
pscript.PermEngine.prototype.render_match_dialog=function(r,details){var d=this.match_defaults_dialog;var w=d.widgets['Body'];w.innerHTML='<div style="background-color:#FFD; padding: 4px; color: #440; margin-bottom:16px">Please Note: Any action will also affect other permissions with similar rules!</div>'
|
||||
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;i<dl.length;i++){new MatchDefaultValue(this,w,dl[i],details.match);}
|
||||
this.add_new_match_row(details.match);}
|
||||
pscript.PermEngine.prototype.add_new_match_row=function(fieldname){new MatchDefaultValue(this,this.match_defaults_dialog.widgets['Body'],null,fieldname,1);}
|
||||
MatchDefaultValue=function(pe,parent,details,fieldname,editable){this.pe=pe;this.wrapper=$a(parent,'div','',{margin:'4px'});this.clear();this.details=details;this.fieldname=fieldname;this.render(editable);}
|
||||
MatchDefaultValue.prototype.clear=function(){this.wrapper.innerHTML='';this.tab=make_table(this.wrapper,1,3,'90%',['40%','40%','20%'],{verticalAlign:'middle',padding:'3px'});}
|
||||
MatchDefaultValue.prototype.render=function(editable){if(editable){this.render_editable();}else{this.render_static();}}
|
||||
MatchDefaultValue.prototype.render_editable=function(){var me=this;this.profile_or_role=$a($td(this.tab,0,0),'select','',{width:'60px',marginRight:'8px'});add_sel_options(this.profile_or_role,['Profile','Role'],'Profile');this.profile_or_role.onchange=function(){if(sel_val(this)=='Profile'){$di(me.profile_sel);$dh(me.role_sel);}
|
||||
else{$dh(me.profile_sel);$di(me.role_sel);}}
|
||||
this.role_sel=$a($td(this.tab,0,0),'select','',{width:'100px',display:'none'});add_sel_options(this.role_sel,this.pe.roles);this.profile_sel=$a($td(this.tab,0,0),'select','',{width:'100px'});add_sel_options(this.profile_sel,this.pe.profiles);this.options_sel=$a($td(this.tab,0,1),'select','',{width:'120px'});add_sel_options(this.options_sel,this.pe.options);var span=$a($td(this.tab,0,2),'span','link_type',{marginLeft:'8px'});span.innerHTML='Add'
|
||||
span.onclick=function(){me.save();}}
|
||||
MatchDefaultValue.prototype.render_static=function(){var me=this;$td(this.tab,0,0).innerHTML=this.details.parenttype;$td(this.tab,0,0).innerHTML+=' '+this.details.parent;$td(this.tab,0,1).innerHTML=this.details.defvalue;var span=$a($td(this.tab,0,2),'span','link_type',{marginLeft:'8px'});span.innerHTML='Cancel'
|
||||
span.onclick=function(){me.delete_def();}}
|
||||
MatchDefaultValue.prototype.delete_def=function(){var me=this;this.wrapper.innerHTML='<div style="color: #888; padding: 3px;">Deleting...</div>';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='<div style="color: #888; padding: 3px;">Adding...</div>';}
|
||||
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','<div id="perm_engine_get_fields"></div>'],['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.length;n++){$a_input(($td(table,0,n)),'data');$td(table,0,n).innerHTML='<b>'+col_labels[n]+'</b>';$td(table,0,n).fieldname=col_labels[n].toLowerCase();}
|
||||
for(var i=0;i<keys(fields_dict).length;i++){for(var j=0;j<4;j++){$a_input(($td(table,i+1,j)),'data');$td(table,i+1,j).innerHTML=cstr(fields_dict[i][$td(table,0,j).fieldname])}}}
|
||||
$i('perm_engine_get_fields').innerHTML='<b>'+dt+' Fields at Level '+permlevel+':</b><br><br>';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;k<child_tables.length;k++){var tab_fields_det=table_fields_dict[child_tables[k]];if(keys(tab_fields_det).length>0){$i('perm_engine_get_fields').innerHTML+='<br><b>'+child_tables[k]+' Fields at Level '+permlevel+':</b><br><br>'
|
||||
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;i<pscript.all_matches.length;i++){var s=pscript.all_matches[i];if(sel_val(s))
|
||||
add_to_out(s.details.parent,s.details.permlevel,s.details.role,'match',sel_val(s));}
|
||||
var args="{'perm_dict': "+JSON.stringify(out)+"}"
|
||||
$c_obj('Permission Control','update_permissions',args,function(r,rt){});}
|
||||
pscript.PermEngine.prototype.update_page_roles=function(){var me=this;var out={};for(i in pscript.all_pg_checkboxes){c=pscript.all_pg_checkboxes[i];out[c.page_name]=c.checked?1:0}
|
||||
var args="{'page_role_dict': "+JSON.stringify(out)+", 'role': '"+sel_val(me.role_select)+"'}"
|
||||
$c_obj('Permission Control','update_page_role',args,function(r,rt){});}
|
||||
pscript.PermEngine.prototype.reset_perm_engine=function(){this.type_select.selectedIndex=0;this.load_options();}
|
||||
@@ -1,32 +0,0 @@
|
||||
|
||||
pscript.onload_Setup=function(){var parent=$i('setup_div');add_space_holder(parent);var callback=function(r,rt){parent.page_head=new PageHeader(parent,'Setup');var setup_data=new SetupData(r.message);pscript.setup_make_sections(setup_data);remove_space_holder();}
|
||||
$c_obj('Setup Wizard Control','get_country','',callback);}
|
||||
pscript.setup_set_height=function(){var parent=$i('setup_div');$y(parent.tray.body,{height:get_window_height()-parent.page_head.wrapper.offsetHeight+'px',overflow:'auto'})}
|
||||
pscript.setup_make_sections=function(setup_data){var parent=$i('setup_div');parent.tray=new TrayPage(parent)
|
||||
var lst=[setup_data.system,setup_data.general,setup_data.accounts,setup_data.selling,setup_data.buying,setup_data.stock,setup_data.hr,setup_data.maintenance,setup_data.production];for(var s=0;s<lst.length;s++){var lbl=keys(lst[s])[0];var ti=parent.tray.add_item(lbl,null,null,1)
|
||||
new SetupItem(ti.body,lbl,lst[s][lbl]);if(s==0)ti.expand();}
|
||||
setTimeout(pscript.setup_set_height,100);resize_observers.push(pscript.setup_set_height);}
|
||||
SetupItem=function(parent,lbl,link_list){this.icons={'System':'back_img Setup','General':'back_img Home','Accounts':'back_img Accounts','Selling':'back_img Selling','Stock':'back_img Stock','Buying':'back_img Buying','Maintenance':'back_img Maintenance','Production':'back_img Production','HR':'back_img HR'};this.make_item_body(parent,lbl,link_list);}
|
||||
SetupItem.prototype.make_item_body=function(parent,lbl,link_list){this.link_area=parent;this.render_item_body(lbl,link_list);}
|
||||
SetupItem.prototype.render_item_body=function(lbl,link_list){var me=this;link_list.sort(function(a,b){return a[0]>b[0];});for(var i=0;i<link_list.length;i++){var wrapper=$a(this.link_area,'div','',{marginBottom:'4px',padding:'2px'});$(wrapper).hover(function(){$y(this,{backgroundColor:'#EEF'})},function(){$y(this,{backgroundColor:''})})
|
||||
var tab=make_table($a(wrapper,'div'),1,2,'100%',[200/7+'%',500/7+'%'])
|
||||
var dt=$a($td(tab,0,0),'span','link_type');dt.innerHTML=link_list[i][0];dt.label=link_list[i][0];dt.arg=link_list[i][1];dt.nm=link_list[i][2];if(dt.arg==1)dt.cn=link_list[i][3];else if(dt.arg==2)dt.cb=link_list[i][3];dt.onclick=function(){me.link_action(this)}
|
||||
$y($td(tab,0,1),{color:'#777'});$td(tab,0,1).innerHTML=link_list[i][4];}}
|
||||
SetupItem.prototype.link_action=function(obj){var me=this;var obj=obj;if(obj.arg==1){if(in_list(profile.can_read,obj.nm)){if(obj.cn!='')
|
||||
loaddocbrowser(obj.nm,obj.nm,obj.cn);else
|
||||
loaddocbrowser(obj.nm);}
|
||||
else
|
||||
msgprint('No read permission',1);}
|
||||
else if(obj.arg==2){me.show_page(obj);}
|
||||
else if(obj.arg==3){newdoc(obj.nm);}}
|
||||
SetupItem.prototype.show_page=function(obj){var me=obj;var callback=function(r,rt)
|
||||
{if(r.message){if(me.cb=='')
|
||||
loadpage(me.nm);else
|
||||
show_chart_browser(me.nm,me.cb);}
|
||||
else
|
||||
msgprint('No read permission',1);}
|
||||
$c_obj('Setup Wizard Control','get_page_lst',me.nm,callback);}
|
||||
SetupData=function(cnty){this.system={'System':[['Global Defaults',3,'Manage Account','','Set global default values'],['Manage Series',3,'Naming Series','','Manage numbering series for transactions'],['Custom Field',1,'Custom Field','dt'+NEWLINE+'label'+NEWLINE+'fieldtype'+NEWLINE+'options','Add and manage custom fields on forms'],['Email Settings',3,'Email Settings','','Outgoing email server and address'],['Notification Settings',3,'Notification Control','','Automatic emails set at selected events'],['Company',1,'Company','id'+NEWLINE+'is_active'+NEWLINE+'email','Manage list of companies'],['Fiscal Year',1,'Fiscal Year','id'+NEWLINE+'company'+NEWLINE+'is_active'+NEWLINE+'year','Manage list of fiscal years'],['Personalize',3,'Personalize','','Set your banner'],['Manage Trash',2,'Trash','','Restore trashed items'],['Import Data',2,'Import Data','','Import data from CSV files'],['Manage Users',2,'My Company','','Add / remove users and manage their roles'],['Web Forms',2,'Webforms','','Code to embed forms in yor website'],['Permissions Manager',2,'Permission Engine','','Manage all permissions from one tool (beta)'],['Property Setter',1,'Property Setter','','Customize properties of a Form (DocType) or Field'],['Letter Head',1,'Letter Head','','Manage different letter heads for Prints'],['SMS Settings',3,'SMS Settings','','Integrate your personalized SMS gateway which support http web service'],['SMS Center',3,'SMS Center','','Send mass sms to your leads, contacts and partners']]};this.general={'General':[['Authorization Rule',1,'Authorization Rule','','Set rules based on amounts'],['Print Heading',1,'Print Heading','','Manage headings for printing transactions'],['Term',1,'Term','','Manage template of standard Terms for order / invoices etc'],['Currency',1,'Currency','','Manage list of currencies'],['Country',1,'Country','','Country master'],['State',1,'State','','State master'],['Activty Type',1,'Activity Type','','Types of activities that you can select in your Timesheet'],['City',1,'City','','City master']]};this.selling={'Selling':[['Customer Group',2,'Sales Browser','Customer Group','Manage customer categories'],['Territory',2,'Sales Browser','Territory','Manage sales territories'],['Customer',1,'Customer','customer_group'+NEWLINE+'country','Customer master'],['Sales Person',2,'Sales Browser','Sales Person','Manage sales persons'],['Sales Partner',1,'Sales Partner','','Manage sales partners'],['Campaign',1,'Campaign','id'+NEWLINE+'campaign_name'+NEWLINE+'description','Manage sales / marketing campaigns'],['Sales BOM',1,'Sales BOM','id'+NEWLINE+'is_active'+NEWLINE+'new_item_name'+NEWLINE+'description'+NEWLINE+'item_group','Manage Sales Bill of Material (Main item + accessories)'],['Price List',1,'Price List','','Price list master']]};this.accounts={'Accounts':[['Chart of Accounts',2,'Accounts Browser','Account','Manage chart of accounts'],['Chart of Cost Centers',2,'Accounts Browser','Cost Center','Manage chart of cost centers'],['POS Setting',1,'POS Setting','','Manage Point of Sales default Settings.']]};if(cnty=='India'){var lst1=[['TDS Rate Chart',1,'TDS Rate Chart','','TDS rate master'],['TDS Category',1,'TDS Category','id'+NEWLINE+'module','TDS categories']];for(var i=0;i<lst1.length;i++)
|
||||
this.accounts['Accounts'].push(lst1[i]);}
|
||||
var lst=[['Monthly Distribution',1,'Budget Distribution','id'+NEWLINE+'fiscal_year'+NEWLINE+'distribution_id','Manage budget distributions (seasonalities)'],['Sales Other Charges',1,'Other Charges','','Manage your charge structures (taxes + charges) for sales'],['Purchase Other Charges',1,'Purchase Other Charges','','Manage your charge structures (taxes + charges) for purchase'],['Mode of Payment',1,'Mode of Payment','','Mode of payment master']];for(var i=0;i<lst.length;i++)
|
||||
this.accounts['Accounts'].push(lst[i]);this.stock={'Stock':[['Item Group',2,'Sales Browser','Item Group','Manage item classifications'],['Item',1,'Item','name'+NEWLINE+'item_group'+NEWLINE+'description','Item master'],['Brand',1,'Brand','id'+NEWLINE+'description','Brand master'],['Batch',1,'Batch','name'+NEWLINE+'start_date'+NEWLINE+'item'+NEWLINE+'expiry_date','Manage batches'],['Price List',1,'Price List','','Price list master'],['UOM',1,'UOM','','Unit of measure (UOM) master'],['Warehouse Type',1,'Warehouse Type','','Warehouse classifications'],['Warehouse',1,'Warehouse','','Warehouse master']]};this.buying={'Buying':[['Supplier Type',1,'Supplier Type','','Manage supplier classifications'],['Supplier',1,'Supplier','id'+NEWLINE+'supplier_type'+NEWLINE+'supplier_status'+NEWLINE+'company','Supplier master']]};this.maintenance={'Maintenance':[['Serial No',1,'Serial No','item_code'+NEWLINE+'status'+NEWLINE+'pr_no'+NEWLINE+'delivery_note_no'+NEWLINE+'customer_name','Manage unique serial numbers for items'],['Purpose of Service',1,'Purpose of Service','','Purpose of service master']]};this.production={'Production':[['Bill of Materials',1,'Bill Of Materials','id'+NEWLINE+'item'+NEWLINE+'description'+NEWLINE+'operating_cost'+NEWLINE+'maintained_by','Muti-level bill of materials and operations'],['Workstation',1,'Workstation','id'+NEWLINE+'workstation_name'+NEWLINE+'warehouse'+NEWLINE+'description','Workstation master']]};this.hr={'HR':[['Department',1,'Department','','Company department master'],['Designation',1,'Designation','','Company designation master'],['Branch',1,'Branch','','Manage branches for your company'],['Grade',1,'Grade','','Manage employee grades'],['Employment Type',1,'Employment Type','','Manage types of employment'],['Employee',1,'Employee','employee_name'+NEWLINE+'employment_type'+NEWLINE+'status'+NEWLINE+'branch'+NEWLINE+'designation'+NEWLINE+'department'+NEWLINE+'grade'+NEWLINE+'reports_to','Employee master'],['Earning Type',1,'Earning Type','taxable'+NEWLINE+'exemption_limit','Types of salary earning master'],['Deduction Type',1,'Deduction Type','','Types of salary deduction master'],['Expense Type',1,'Expense Type','','Types of expense master'],['Salary Structure',1,'Salary Structure','employee'+NEWLINE+'is_active'+NEWLINE+'fiscal_year'+NEWLINE+'from_date'+NEWLINE+'ctc'+NEWLINE+'total_earning'+NEWLINE+'total_deduction'+NEWLINE+'total','Salary structure template'],['Holiday List',1,'Holiday List','fiscal_year','List of holidays'],['Leave Type',1,'Leave Type','max_days_allowed'+NEWLINE+'is_carry_forward'+NEWLINE+'is_encash','Leave type master'],['KRA Template',1,'KRA Template','','Template of Key Result Areas (KRAs)']]};}
|
||||
Reference in New Issue
Block a user