blob: cbb03a1fba5bb09bf827d7364701915c0af957a8 [file] [log] [blame]
Brahma Kd1a2cea2011-08-30 09:33:29 +05301var current_module;
2var is_system_manager = 0;
3var module_content_dict = {};
4var user_full_nm = {};
5
Rushabh Mehta865c00a2012-01-24 14:33:21 +05306wn.provide('erpnext.startup');
Brahma Kd1a2cea2011-08-30 09:33:29 +05307
Rushabh Mehta865c00a2012-01-24 14:33:21 +05308erpnext.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 Mehta8c309be2012-01-20 13:47:16 +053012
Rushabh Mehta865c00a2012-01-24 14:33:21 +053013erpnext.startup.start = function() {
Rushabh Mehta9c7a01a2012-01-25 11:04:54 +053014 $('#startup_div').html('Starting up...').toggle(true);
15
Rushabh Mehta865c00a2012-01-24 14:33:21 +053016 erpnext.startup.set_globals();
17
18 if(user == 'Guest'){
19 $dh(page_body.left_sidebar);
Rushabh Mehta5b927092012-01-24 15:16:06 +053020 wn.require('erpnext/website/css/website.css');
Rushabh Mehta865c00a2012-01-24 14:33:21 +053021 wn.require('erpnext/website/js/topbar.js');
Rushabh Mehta7018b192012-02-02 13:42:28 +053022 if(wn.boot.custom_css) {
23 set_style(wn.boot.custom_css);
24 }
25 if(wn.boot.website_settings.title_prefix) {
26 wn.title_prefix = wn.boot.website_settings.title_prefix;
27 }
Rushabh Mehta865c00a2012-01-24 14:33:21 +053028 } else {
29 // modules
30 wn.require('erpnext/startup/modules.js');
31 pscript.startup_make_sidebar();
Brahma Kd1a2cea2011-08-30 09:33:29 +053032
Rushabh Mehta865c00a2012-01-24 14:33:21 +053033 // setup toolbar
34 wn.require('erpnext/startup/toolbar.js');
35 erpnext.toolbar.setup();
36 wn.require('erpnext/startup/feature_setup.js');
Rushabh Mehtaab1148c2012-01-31 18:01:16 +053037
38 // border to the body
39 // ------------------
40 $('footer').html('<div class="erpnext-footer">\
41 Powered by <a href="https://erpnext.com">ERPNext</a></div>');
Brahma Kd1a2cea2011-08-30 09:33:29 +053042 }
Rushabh Mehta8c309be2012-01-20 13:47:16 +053043
Rushabh Mehta9c7a01a2012-01-25 11:04:54 +053044 $('#startup_div').toggle(false);
Brahma Kd1a2cea2011-08-30 09:33:29 +053045}
46
Brahma Kd1a2cea2011-08-30 09:33:29 +053047// chart of accounts
48// ====================================================================
49show_chart_browser = function(nm, chart_type){
50
51 var call_back = function(){
52 if(nm == 'Sales Browser'){
53 var sb_obj = new SalesBrowser();
54 sb_obj.set_val(chart_type);
55 }
56 else if(nm == 'Accounts Browser')
57 pscript.make_chart(chart_type);
58 }
59 loadpage(nm,call_back);
60}
61
62
63// Module Page
64// ====================================================================
65
66ModulePage = function(parent, module_name, module_label, help_page, callback) {
67 this.parent = parent;
68
69 // add to current page
70 page_body.cur_page.module_page = this;
71
72 this.wrapper = $a(parent,'div');
73 this.module_name = module_name;
74 this.transactions = [];
75 this.page_head = new PageHeader(this.wrapper, module_label);
76
77 if(help_page) {
78 var btn = this.page_head.add_button('Help', function() { loadpage(this.help_page) }, 1, 'ui-icon-help')
79 btn.help_page = help_page;
80 }
81
82 if(callback) this.callback = function(){ callback(); }
83}
84
Rushabh Mehta865c00a2012-01-24 14:33:21 +053085// start
86erpnext.startup.start();