Brahma K | d1a2cea | 2011-08-30 09:33:29 +0530 | [diff] [blame] | 1 | var current_module; |
| 2 | var is_system_manager = 0; |
| 3 | var module_content_dict = {}; |
| 4 | var user_full_nm = {}; |
| 5 | |
Rushabh Mehta | 865c00a | 2012-01-24 14:33:21 +0530 | [diff] [blame] | 6 | wn.provide('erpnext.startup'); |
Brahma K | d1a2cea | 2011-08-30 09:33:29 +0530 | [diff] [blame] | 7 | |
Rushabh Mehta | 865c00a | 2012-01-24 14:33:21 +0530 | [diff] [blame] | 8 | erpnext.startup.set_globals = function() { |
| 9 | pscript.is_erpnext_saas = cint(wn.control_panel.sync_with_gateway) |
| 10 | if(inList(user_roles,'System Manager')) is_system_manager = 1; |
| 11 | } |
Rushabh Mehta | 8c309be | 2012-01-20 13:47:16 +0530 | [diff] [blame] | 12 | |
Rushabh Mehta | 865c00a | 2012-01-24 14:33:21 +0530 | [diff] [blame] | 13 | erpnext.startup.start = function() { |
Rushabh Mehta | 9c7a01a | 2012-01-25 11:04:54 +0530 | [diff] [blame] | 14 | $('#startup_div').html('Starting up...').toggle(true); |
| 15 | |
Rushabh Mehta | 865c00a | 2012-01-24 14:33:21 +0530 | [diff] [blame] | 16 | erpnext.startup.set_globals(); |
| 17 | |
| 18 | if(user == 'Guest'){ |
| 19 | $dh(page_body.left_sidebar); |
Rushabh Mehta | 7018b19 | 2012-02-02 13:42:28 +0530 | [diff] [blame] | 20 | if(wn.boot.custom_css) { |
| 21 | set_style(wn.boot.custom_css); |
| 22 | } |
| 23 | if(wn.boot.website_settings.title_prefix) { |
| 24 | wn.title_prefix = wn.boot.website_settings.title_prefix; |
| 25 | } |
Rushabh Mehta | 865c00a | 2012-01-24 14:33:21 +0530 | [diff] [blame] | 26 | } else { |
| 27 | // modules |
Rushabh Mehta | 865c00a | 2012-01-24 14:33:21 +0530 | [diff] [blame] | 28 | pscript.startup_make_sidebar(); |
Brahma K | d1a2cea | 2011-08-30 09:33:29 +0530 | [diff] [blame] | 29 | |
Rushabh Mehta | 865c00a | 2012-01-24 14:33:21 +0530 | [diff] [blame] | 30 | // setup toolbar |
Rushabh Mehta | 865c00a | 2012-01-24 14:33:21 +0530 | [diff] [blame] | 31 | erpnext.toolbar.setup(); |
Rushabh Mehta | ab1148c | 2012-01-31 18:01:16 +0530 | [diff] [blame] | 32 | |
| 33 | // border to the body |
| 34 | // ------------------ |
| 35 | $('footer').html('<div class="erpnext-footer">\ |
| 36 | Powered by <a href="https://erpnext.com">ERPNext</a></div>'); |
Brahma K | d1a2cea | 2011-08-30 09:33:29 +0530 | [diff] [blame] | 37 | } |
Rushabh Mehta | 8c309be | 2012-01-20 13:47:16 +0530 | [diff] [blame] | 38 | |
Rushabh Mehta | 9c7a01a | 2012-01-25 11:04:54 +0530 | [diff] [blame] | 39 | $('#startup_div').toggle(false); |
Brahma K | d1a2cea | 2011-08-30 09:33:29 +0530 | [diff] [blame] | 40 | } |
| 41 | |
Brahma K | d1a2cea | 2011-08-30 09:33:29 +0530 | [diff] [blame] | 42 | // chart of accounts |
| 43 | // ==================================================================== |
| 44 | show_chart_browser = function(nm, chart_type){ |
| 45 | |
| 46 | var call_back = function(){ |
| 47 | if(nm == 'Sales Browser'){ |
| 48 | var sb_obj = new SalesBrowser(); |
| 49 | sb_obj.set_val(chart_type); |
| 50 | } |
| 51 | else if(nm == 'Accounts Browser') |
| 52 | pscript.make_chart(chart_type); |
| 53 | } |
| 54 | loadpage(nm,call_back); |
| 55 | } |
| 56 | |
| 57 | |
| 58 | // Module Page |
| 59 | // ==================================================================== |
| 60 | |
| 61 | ModulePage = function(parent, module_name, module_label, help_page, callback) { |
| 62 | this.parent = parent; |
| 63 | |
| 64 | // add to current page |
| 65 | page_body.cur_page.module_page = this; |
| 66 | |
| 67 | this.wrapper = $a(parent,'div'); |
| 68 | this.module_name = module_name; |
| 69 | this.transactions = []; |
| 70 | this.page_head = new PageHeader(this.wrapper, module_label); |
| 71 | |
| 72 | if(help_page) { |
| 73 | var btn = this.page_head.add_button('Help', function() { loadpage(this.help_page) }, 1, 'ui-icon-help') |
| 74 | btn.help_page = help_page; |
| 75 | } |
| 76 | |
| 77 | if(callback) this.callback = function(){ callback(); } |
| 78 | } |
| 79 | |
Rushabh Mehta | 865c00a | 2012-01-24 14:33:21 +0530 | [diff] [blame] | 80 | // start |
Rushabh Mehta | afaac60 | 2012-02-14 11:44:13 +0530 | [diff] [blame] | 81 | $(document).bind('startup', function() { |
| 82 | erpnext.startup.start(); |
| 83 | }); |