blob: 9ed20ff73aa9d748b14af8576c77144d6d67c30d [file] [log] [blame]
Rushabh Mehta74506e92013-03-25 17:52:14 +05301# ERPNext: Copyright 2013 Web Notes Technologies Pvt Ltd
2# GNU General Public License. See "license.txt"
3
4
5from __future__ import unicode_literals
6import webnotes
7import home
8
9def boot_session(bootinfo):
10 """boot session - send website info if guest"""
11 import webnotes
12 import webnotes.model.doc
13
14 bootinfo['custom_css'] = webnotes.conn.get_value('Style Settings', None, 'custom_css') or ''
15 bootinfo['website_settings'] = webnotes.model.doc.getsingle('Website Settings')
16
17 if webnotes.session['user']=='Guest':
18 bootinfo['website_menus'] = webnotes.conn.sql("""select label, url, custom_page,
19 parent_label, parentfield
20 from `tabTop Bar Item` where parent='Website Settings' order by idx asc""", as_dict=1)
21 bootinfo['startup_code'] = \
22 webnotes.conn.get_value('Website Settings', None, 'startup_code')
23 else:
24 bootinfo['letter_heads'] = get_letter_heads()
25
26 import webnotes.model.doctype
27 bootinfo['notification_settings'] = webnotes.doc("Notification Control",
28 "Notification Control").get_values()
Rushabh Mehta27c40792013-04-03 15:21:44 +053029
Rushabh Mehta74506e92013-03-25 17:52:14 +053030 # if no company, show a dialog box to create a new company
31 bootinfo['setup_complete'] = webnotes.conn.sql("""select name from
32 tabCompany limit 1""") and 'Yes' or 'No'
33
34 # load subscription info
35 import conf
36 for key in ['max_users', 'expires_on', 'max_space', 'status', 'developer_mode']:
37 if hasattr(conf, key): bootinfo[key] = getattr(conf, key)
38
Anand Doshi5717fe32013-04-17 18:02:52 +053039 bootinfo['docs'] += webnotes.conn.sql("""select name, default_currency, cost_center,
40 cost_center as 'cost_center_other_charges' from `tabCompany`""",
Rushabh Mehta74506e92013-03-25 17:52:14 +053041 as_dict=1, update={"doctype":":Company"})
42
43def get_letter_heads():
44 """load letter heads with startup"""
45 import webnotes
46 ret = webnotes.conn.sql("""select name, content from `tabLetter Head`
47 where ifnull(disabled,0)=0""")
48 return dict(ret)
49