if(user == 'Guest'){ $dh(page_body.left_sidebar); } var current_module; var is_system_manager = 0; var module_content_dict = {}; var user_full_nm = {}; // check if session user is system manager if(inList(user_roles,'System Manager')) is_system_manager = 1; function startup_setup() { pscript.is_erpnext_saas = cint(locals['Control Panel']['Control Panel'].sync_with_gateway) if(get_url_arg('embed')) { // hide header, footer $dh(page_body.banner_area); $dh(page_body.wntoolbar); $dh(page_body.footer); return; } if(user=='Guest' && !get_url_arg('akey')) { if(pscript.is_erpnext_saas) { window.location.href = 'https://www.erpnext.com'; return; } } // page structure // -------------- $td(page_body.wntoolbar.body_tab,0,0).innerHTML = 'erpnext'; $y($td(page_body.wntoolbar.body_tab,0,0), {width:'140px', color:'#FFF', paddingLeft:'8px', paddingRight:'8px', fontSize:'14px'}) $dh(page_body.banner_area); // sidebar // ------- pscript.startup_make_sidebar(); // border to the body // ------------------ $dh(page_body.footer); // for logout and payment var callback = function(r,rt) { if(r.message){ login_file = r.message; } else { login_file = 'https://www.erpnext.com'; } // setup toolbar pscript.startup_setup_toolbar(); } $c_obj('Home Control', 'get_login_url', '', callback); } // ==================================================================== pscript.startup_make_sidebar = function() { $y(page_body.left_sidebar, {width:(100/6)+'%', paddingTop:'8px'}); var callback = function(r,rt) { // menu var ml = r.message; // clear page_body.left_sidebar.innerHTML = ''; for(var m=0; mNote: These changes will apply to all users!', ml, update_order, 1); } $c_obj('Home Control', 'get_module_order', '', callback) } // ==================================================================== pscript.startup_setup_toolbar = function() { var menu_tab = page_body.wntoolbar.menu_table_right; // Profile // --------- $td(menu_tab,0,0).innerHTML = ''+user_fullname+''; if(pscript.is_erpnext_saas){ // Help // -------------- //var help_url = login_file + '#!helpdesk' $td(menu_tab,0,1).innerHTML = 'Forum'; // Manage account // -------------- if(is_system_manager) { $td(menu_tab,0,3).innerHTML = 'Billing'; } } else{ $dh($td(menu_tab,0,1)); $dh($td(menu_tab,0,3)); } // Live Chat Help // -------------- $td(menu_tab,0,2).innerHTML = 'Chat'; // help // ---- var cell = menu_tab.rows[0].insertCell(3); cell.innerHTML = 'Help'; $y(cell, page_body.wntoolbar.right_table_style); } // ==================================================================== pscript.go_to_account_settings = function() { callback = function(r, rt) { if(r.exc) { msgprint(r.exc); } else { msgprint('' + 'Click here to open Account Settings in a new page') } } $c_page('home', 'my_company', 'get_account_settings_url', '', callback) } // chart of accounts // ==================================================================== show_chart_browser = function(nm, chart_type){ var call_back = function(){ if(nm == 'Sales Browser'){ var sb_obj = new SalesBrowser(); sb_obj.set_val(chart_type); } else if(nm == 'Accounts Browser') pscript.make_chart(chart_type); } loadpage(nm,call_back); } // Module Page // ==================================================================== ModulePage = function(parent, module_name, module_label, help_page, callback) { this.parent = parent; // add to current page page_body.cur_page.module_page = this; this.wrapper = $a(parent,'div'); this.module_name = module_name; this.transactions = []; this.page_head = new PageHeader(this.wrapper, module_label); if(help_page) { var btn = this.page_head.add_button('Help', function() { loadpage(this.help_page) }, 1, 'ui-icon-help') btn.help_page = help_page; } if(callback) this.callback = function(){ callback(); } } // get plural // ==================================================================== get_plural = function(str){ if(str.charAt(str.length-1).toLowerCase() == 'y') return str.substr(0, str.length-1) + 'ies' else return str + 's'; } // set user fullname // ==================================================================== pscript.set_user_fullname = function(ele,username,get_latest){ var set_it = function(){ if(ele) ele.innerHTML = user_full_nm[username]; } if(get_latest){ $c_obj('Home Control','get_user_fullname',username, function(r,rt){ user_full_nm[username] = r.message; set_it(); }); } else{ if(user_full_nm[username]){ set_it(); } else $c_obj('Home Control','get_user_fullname',username, function(r,rt){ user_full_nm[username] = r.message; set_it(); }); } } // ==================================================================== startup_setup();