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(); |
Anand Doshi | c3023be | 2012-02-20 16:31:55 +0530 | [diff] [blame] | 32 | |
| 33 | // set interval for updates |
| 34 | erpnext.startup.set_periodic_updates(); |
Rushabh Mehta | ab1148c | 2012-01-31 18:01:16 +0530 | [diff] [blame] | 35 | |
| 36 | // border to the body |
| 37 | // ------------------ |
| 38 | $('footer').html('<div class="erpnext-footer">\ |
| 39 | Powered by <a href="https://erpnext.com">ERPNext</a></div>'); |
Brahma K | d1a2cea | 2011-08-30 09:33:29 +0530 | [diff] [blame] | 40 | } |
Anand Doshi | c3023be | 2012-02-20 16:31:55 +0530 | [diff] [blame] | 41 | |
Rushabh Mehta | 9c7a01a | 2012-01-25 11:04:54 +0530 | [diff] [blame] | 42 | $('#startup_div').toggle(false); |
Brahma K | d1a2cea | 2011-08-30 09:33:29 +0530 | [diff] [blame] | 43 | } |
| 44 | |
Brahma K | d1a2cea | 2011-08-30 09:33:29 +0530 | [diff] [blame] | 45 | // chart of accounts |
| 46 | // ==================================================================== |
| 47 | show_chart_browser = function(nm, chart_type){ |
| 48 | |
| 49 | var call_back = function(){ |
| 50 | if(nm == 'Sales Browser'){ |
| 51 | var sb_obj = new SalesBrowser(); |
| 52 | sb_obj.set_val(chart_type); |
| 53 | } |
| 54 | else if(nm == 'Accounts Browser') |
| 55 | pscript.make_chart(chart_type); |
| 56 | } |
| 57 | loadpage(nm,call_back); |
| 58 | } |
| 59 | |
| 60 | |
| 61 | // Module Page |
| 62 | // ==================================================================== |
| 63 | |
| 64 | ModulePage = function(parent, module_name, module_label, help_page, callback) { |
| 65 | this.parent = parent; |
| 66 | |
| 67 | // add to current page |
| 68 | page_body.cur_page.module_page = this; |
| 69 | |
| 70 | this.wrapper = $a(parent,'div'); |
| 71 | this.module_name = module_name; |
| 72 | this.transactions = []; |
| 73 | this.page_head = new PageHeader(this.wrapper, module_label); |
| 74 | |
| 75 | if(help_page) { |
| 76 | var btn = this.page_head.add_button('Help', function() { loadpage(this.help_page) }, 1, 'ui-icon-help') |
| 77 | btn.help_page = help_page; |
| 78 | } |
| 79 | |
| 80 | if(callback) this.callback = function(){ callback(); } |
| 81 | } |
| 82 | |
Anand Doshi | c3023be | 2012-02-20 16:31:55 +0530 | [diff] [blame] | 83 | // ========== Update Messages ============ |
| 84 | var update_messages = function() { |
| 85 | // Updates Team Messages |
| 86 | |
| 87 | if(inList(['Guest', 'Administrator'], user)) { return; } |
| 88 | |
| 89 | $c_page('home', 'event_updates', 'get_unread_messages', null, |
| 90 | function(r,rt) { |
| 91 | if(!r.exc) { |
| 92 | // This function is defined in toolbar.js |
| 93 | page_body.wntoolbar.set_new_comments(r.message); |
| 94 | } |
| 95 | } |
| 96 | ); |
| 97 | } |
| 98 | |
| 99 | erpnext.startup.set_periodic_updates = function() { |
| 100 | // Set interval for periodic updates of team messages |
| 101 | wn.updates = {}; |
| 102 | |
| 103 | if(wn.updates.id) { |
| 104 | clearInterval(wn.updates.id); |
| 105 | } |
| 106 | |
| 107 | wn.updates.id = setInterval(update_messages, 180000); |
| 108 | } |
| 109 | |
| 110 | // ======================================= |
| 111 | |
Rushabh Mehta | 865c00a | 2012-01-24 14:33:21 +0530 | [diff] [blame] | 112 | // start |
Rushabh Mehta | afaac60 | 2012-02-14 11:44:13 +0530 | [diff] [blame] | 113 | $(document).bind('startup', function() { |
| 114 | erpnext.startup.start(); |
| 115 | }); |