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 = 'http://' + r.message; } else if(pscript.is_erpnext_saas) { 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); } // 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(); /* features setup "Dictionary", "Script" Dictionary Format 'projects': { 'Sales Order': { 'fields':['project_name'], 'sales_order_details':['projected_qty'] }, 'Purchase Order': { 'fields':['project_name'] } } // ====================================================================*/ pscript.feature_dict = { 'projects': { 'Bill Of Materials': {'fields':['project_name']}, 'Delivery Note': {'fields':['project_name']}, 'Payable Voucher': {'fields':['project_name']}, 'Production Order': {'fields':['project_name']}, 'Purchase Order': {'fields':['project_name']}, 'Purchase Receipt': {'fields':['project_name']}, 'Receivable Voucher': {'fields':['project_name']}, 'Sales Order': {'fields':['project_name']}, 'Stock Entry': {'fields':['project_name']}, 'Timesheet': {'timesheet_details':['project_name']} }, 'packing_details': { 'Delivery Note': {'fields':['packing_details','print_packing_slip'],'delivery_note_details':['no_of_packs','pack_gross_wt','pack_nett_wt','pack_no','pack_unit']}, 'Sales Order': {'fields':['packing_details']} }, 'discounts': { 'Delivery Note': {'delivery_note_details':['adj_rate']}, 'Quotation': {'quotation_details':['adj_rate']}, 'Receivable Voucher': {'rv_details':['adj_rate']}, 'Sales Order': {'sale_order_details':['adj_rate']} }, 'brands': { 'Delivery Note': {'delivery_note_details':['brand']}, 'Enquiry': {'enquiry_details':['brand']}, 'Indent': {'indent_details':['brand']}, 'Item': {'fields':['brand']}, 'Purchase Order': {'po_details':['brand']}, 'Purchase Receipt': {'purchase_receipt_details':['brand']}, 'Payable Voucher': {'pv_details':['brand']}, 'Quotation': {'quotation_details':['brand']}, 'Receivable Voucher': {'rv_details':['brand']}, 'Sales BOM': {'fields':['new_item_brand']}, 'Sales Order': {'sales_order_details':['brand']}, 'Serial No': {'fields':['brand']} }, 'after_sale_installations': { 'Delivery Note': {'fields':['installation_status','per_installed'],'delivery_note_details':['installed_qty']} }, 'item_batch_nos': { 'Delivery Note': {'delivery_note_details':['batch_no']}, 'Item': {'fields':['has_batch_no']}, 'Purchase Receipt': {'purchase_receipt_details':['batch_no']}, 'QA Inspection Report': {'fields':['batch_no']}, 'Sales and Pruchase Return Wizard': {'return_details':['batch_no']}, 'Receivable Voucher': {'rv_details':['batch_no']}, 'Stock Entry': {'stock_entry_details':['batch_no']}, 'Stock Ledger Entry': {'fields':['batch_no']} }, 'item_serial_nos': { 'Customer Issue': {'fields':['serial_no']}, 'Delivery Note': {'delivery_note_details':['serial_no'],'delivery_note_packing_details':['serial_no']}, 'Installation Note': {'installed_item_details':['serial_no']}, 'Item': {'fields':['has_serial_no']}, 'Maintenance Schedule': {'item_maintenance_details':['serial_no'],'maintenance_schedule_details':['serial_no']}, 'Maintenance Visit': {'maintenance_visit_details':['serial_no']}, 'Purchase Receipt': {'purchase_receipt_details':['serial_no']}, 'QA Inspection Report': {'fields':['item_serial_no']}, 'Sales and Pruchase Return Wizard': {'return_details':['serial_no']}, 'Receivable Voucher': {'rv_details':['serial_no']}, 'Stock Entry': {'stock_entry_details':['serial_no']}, 'Stock Ledger Entry': {'fields':['serial_no']} }, 'item_groups_in_details': { 'Delivery Note': {'delivery_note_details':['item_group']}, 'Enquiry': {'enquiry_details':['item_group']}, 'Indent': {'indent_details':['item_group']}, 'Item': {'fields':['item_group']}, 'Manage Account': {'fields':['default_item_group']}, 'Purchase Order': {'po_details':['item_group']}, 'Purchase Receipt': {'purchase_receipt_details':['item_group']}, 'Purchase Voucher': {'pv_details':['item_group']}, 'Quotation': {'quotation_details':['item_group']}, 'Receivable Voucher': {'rv_details':['item_group']}, 'Sales BOM': {'fields':['serial_no']}, 'Sales Order': {'sales_order_details':['item_group']}, 'Serial No': {'fields':['item_group']}, 'Sales Partner': {'partner_target_details':['item_group']}, 'Sales Person': {'target_details':['item_group']}, 'Territory': {'target_details':['item_group']} }, 'page_break': { 'Delivery Note': {'delivery_note_details':['page_break'],'delivery_note_packing_details':['page_break']}, 'Indent': {'indent_details':['page_break']}, 'Purchase Order': {'po_details':['page_break']}, 'Purchase Receipt': {'purchase_receipt_details':['page_break']}, 'Purchase Voucher': {'pv_details':['page_break']}, 'Quotation': {'quotation_details':['page_break']}, 'Receivable Voucher': {'rv_details':['page_break']}, 'Sales Order': {'sales_order_details':['page_break']} }, 'multi_currency': { 'Delivery Note': {'fields':['currency','conversion_rate']}, 'Payable Voucher': {'fields':['currency','conversion_rate']}, 'POS Setting': {'fields':['currency','conversion_rate']}, 'Purchase Order': {'fields':['currency','conversion_rate']}, 'Purchase Receipt': {'fields':['currency','conversion_rate']}, 'Quotation': {'fields':['currency','conversion_rate']}, 'Receivable Voucher': {'fields':['currency','conversion_rate']}, 'Quotation': {'fields':['currency','conversion_rate']}, 'Item': {'ref_rate_details':['currency']}, 'Sales BOM': {'fields':['currency']}, 'Sales Order': {'fields':['currency','conversion_rate']}, 'Supplier Quotation': {'fields':['currency','conversion_rate']} }, 'exports': { 'Delivery Note': {'fields':['currency','conversion_rate','Note','grand_total_export','in_words_export','rounded_total_export'],'delivery_note_details':['base_ref_rate','export_amount','export_rate',]}, 'POS Setting': {'fields':['currency','conversion_rate']}, 'Quotation': {'fields':['currency','conversion_rate']}, 'Receivable Voucher': {'fields':['currency','conversion_rate']}, 'Quotation': {'fields':['currency','conversion_rate']}, 'Item': {'ref_rate_details':['currency']}, 'Sales BOM': {'fields':['currency']}, 'Sales Order': {'fields':['currency','conversion_rate']}, 'Supplier Quotation': {'fields':['currency','conversion_rate']} }, 'imports': { 'Payable Voucher': {'fields':['currency','conversion_rate']}, 'Purchase Order': {'fields':['currency','conversion_rate']}, 'Purchase Receipt': {'fields':['currency','conversion_rate']}, 'Receivable Voucher': {'fields':['currency','conversion_rate']}, 'Supplier Quotation': {'fields':['currency','conversion_rate']} } } $(document).bind('form_refresh', function() { for(sys_feat in sys_defaults) { if(sys_defaults[sys_feat]=='0' && (sys_feat in pscript.feature_dict)) //"Features to hide" exists { if(cur_frm.doc.doctype in pscript.feature_dict[sys_feat]) { for(fort in pscript.feature_dict[sys_feat][cur_frm.doc.doctype]) { if(fort=='fields') hide_field(pscript.feature_dict[sys_feat][cur_frm.doc.doctype][fort]); else { for(grid_field in pscript.feature_dict[sys_feat][cur_frm.doc.doctype][fort]) if(cur_frm.fields_dict[fort]) cur_frm.fields_dict[fort].grid.set_column_disp(pscript.feature_dict[sys_feat][cur_frm.doc.doctype][fort][grid_field], false); else alert('Grid "'+fort+'" does not exists'); } } } } } }) $(document).bind('form_refresh', function() { })