blob: 973b742a4895ce4cf5fd130bab61c0dd9d963e06 [file] [log] [blame]
Rushabh Mehtaad45e312013-11-20 12:59:58 +05301# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
Rushabh Mehtae67d1fb2013-08-05 14:59:54 +05302# License: GNU General Public License v3. See license.txt"
Rushabh Mehta74506e92013-03-25 17:52:14 +05303
4
5from __future__ import unicode_literals
Rushabh Mehta793ba6b2014-02-14 15:47:51 +05306import frappe
Rushabh Mehta74506e92013-03-25 17:52:14 +05307
8def boot_session(bootinfo):
9 """boot session - send website info if guest"""
Rushabh Mehta793ba6b2014-02-14 15:47:51 +053010 import frappe
Rushabh Mehta74506e92013-03-25 17:52:14 +053011
Anand Doshie9baaa62014-02-26 12:35:33 +053012 bootinfo['custom_css'] = frappe.db.get_value('Style Settings', None, 'custom_css') or ''
Rushabh Mehtaf2227d02014-03-31 23:37:40 +053013 bootinfo['website_settings'] = frappe.get_doc('Website Settings')
Rushabh Mehta74506e92013-03-25 17:52:14 +053014
Rushabh Mehta793ba6b2014-02-14 15:47:51 +053015 if frappe.session['user']!='Guest':
Rushabh Mehta74506e92013-03-25 17:52:14 +053016 bootinfo['letter_heads'] = get_letter_heads()
Rushabh Mehta9dd25b32013-09-03 17:36:41 +053017
18 load_country_and_currency(bootinfo)
19
Rushabh Mehtab385ecf2014-03-28 16:44:37 +053020 bootinfo['notification_settings'] = frappe.get_doc("Notification Control",
Rushabh Mehta74506e92013-03-25 17:52:14 +053021 "Notification Control").get_values()
Rushabh Mehta27c40792013-04-03 15:21:44 +053022
Rushabh Mehta74506e92013-03-25 17:52:14 +053023 # if no company, show a dialog box to create a new company
Anand Doshie9baaa62014-02-26 12:35:33 +053024 bootinfo["customer_count"] = frappe.db.sql("""select count(*) from tabCustomer""")[0][0]
Rushabh Mehta2f7e1ab2013-06-26 17:20:12 +053025
26 if not bootinfo["customer_count"]:
Anand Doshie9baaa62014-02-26 12:35:33 +053027 bootinfo['setup_complete'] = frappe.db.sql("""select name from
Rushabh Mehta2f7e1ab2013-06-26 17:20:12 +053028 tabCompany limit 1""") and 'Yes' or 'No'
29
Anand Doshie9baaa62014-02-26 12:35:33 +053030 bootinfo['docs'] += frappe.db.sql("""select name, default_currency, cost_center
Anand Doshiaeef7bd2013-04-19 16:21:55 +053031 from `tabCompany`""", as_dict=1, update={"doctype":":Company"})
Rushabh Mehta9dd25b32013-09-03 17:36:41 +053032
33def load_country_and_currency(bootinfo):
34 if bootinfo.control_panel.country and \
Anand Doshie9baaa62014-02-26 12:35:33 +053035 frappe.db.exists("Country", bootinfo.control_panel.country):
Rushabh Mehtab385ecf2014-03-28 16:44:37 +053036 bootinfo["docs"] += [frappe.get_doc("Country", bootinfo.control_panel.country)]
Rushabh Mehta9dd25b32013-09-03 17:36:41 +053037
Anand Doshie9baaa62014-02-26 12:35:33 +053038 bootinfo["docs"] += frappe.db.sql("""select * from tabCurrency
Rushabh Mehta9dd25b32013-09-03 17:36:41 +053039 where ifnull(enabled,0)=1""", as_dict=1, update={"doctype":":Currency"})
40
Rushabh Mehta74506e92013-03-25 17:52:14 +053041def get_letter_heads():
Rushabh Mehta793ba6b2014-02-14 15:47:51 +053042 import frappe
Anand Doshie9baaa62014-02-26 12:35:33 +053043 ret = frappe.db.sql("""select name, content from `tabLetter Head`
Rushabh Mehta74506e92013-03-25 17:52:14 +053044 where ifnull(disabled,0)=0""")
45 return dict(ret)
Pratik Vyascfed8c42013-09-21 15:16:47 +053046