blob: 57993de2405642c400c9e570d3c685db8ae5707c [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();
Rushabh Mehtac5471dd2012-02-22 12:07:42 +053017
18 if(wn.boot.custom_css) {
19 set_style(wn.boot.custom_css);
20 }
21
Rushabh Mehta865c00a2012-01-24 14:33:21 +053022 if(user == 'Guest'){
Rushabh Mehta7018b192012-02-02 13:42:28 +053023 if(wn.boot.website_settings.title_prefix) {
24 wn.title_prefix = wn.boot.website_settings.title_prefix;
25 }
Rushabh Mehta865c00a2012-01-24 14:33:21 +053026 } else {
Rushabh Mehta865c00a2012-01-24 14:33:21 +053027 // setup toolbar
Rushabh Mehta865c00a2012-01-24 14:33:21 +053028 erpnext.toolbar.setup();
Anand Doshic3023be2012-02-20 16:31:55 +053029
30 // set interval for updates
31 erpnext.startup.set_periodic_updates();
Rushabh Mehtaab1148c2012-01-31 18:01:16 +053032
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 Kd1a2cea2011-08-30 09:33:29 +053037 }
Anand Doshic3023be2012-02-20 16:31:55 +053038
Rushabh Mehta9c7a01a2012-01-25 11:04:54 +053039 $('#startup_div').toggle(false);
Brahma Kd1a2cea2011-08-30 09:33:29 +053040}
41
Brahma Kd1a2cea2011-08-30 09:33:29 +053042// chart of accounts
43// ====================================================================
44show_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
61ModulePage = 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
Anand Doshic3023be2012-02-20 16:31:55 +053080// ========== Update Messages ============
81var update_messages = function() {
82 // Updates Team Messages
83
84 if(inList(['Guest', 'Administrator'], user)) { return; }
85
86 $c_page('home', 'event_updates', 'get_unread_messages', null,
87 function(r,rt) {
88 if(!r.exc) {
89 // This function is defined in toolbar.js
90 page_body.wntoolbar.set_new_comments(r.message);
91 }
92 }
93 );
94}
95
96erpnext.startup.set_periodic_updates = function() {
97 // Set interval for periodic updates of team messages
98 wn.updates = {};
99
100 if(wn.updates.id) {
101 clearInterval(wn.updates.id);
102 }
103
104 wn.updates.id = setInterval(update_messages, 180000);
105}
106
107// =======================================
108
Rushabh Mehta865c00a2012-01-24 14:33:21 +0530109// start
Rushabh Mehtaafaac602012-02-14 11:44:13 +0530110$(document).bind('startup', function() {
Rushabh Mehtad0251332012-02-21 17:26:50 +0530111 erpnext.startup.start();
Rushabh Mehtaafaac602012-02-14 11:44:13 +0530112});