Rushabh Mehta | ad45e31 | 2013-11-20 12:59:58 +0530 | [diff] [blame] | 1 | # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors |
Rushabh Mehta | e67d1fb | 2013-08-05 14:59:54 +0530 | [diff] [blame] | 2 | # License: GNU General Public License v3. See license.txt" |
Rushabh Mehta | 74506e9 | 2013-03-25 17:52:14 +0530 | [diff] [blame] | 3 | |
| 4 | |
| 5 | from __future__ import unicode_literals |
Rushabh Mehta | 793ba6b | 2014-02-14 15:47:51 +0530 | [diff] [blame] | 6 | import frappe |
Rushabh Mehta | 74506e9 | 2013-03-25 17:52:14 +0530 | [diff] [blame] | 7 | |
| 8 | def boot_session(bootinfo): |
| 9 | """boot session - send website info if guest""" |
Rushabh Mehta | 793ba6b | 2014-02-14 15:47:51 +0530 | [diff] [blame] | 10 | import frappe |
| 11 | import frappe.model.doc |
Rushabh Mehta | 74506e9 | 2013-03-25 17:52:14 +0530 | [diff] [blame] | 12 | |
Anand Doshi | e9baaa6 | 2014-02-26 12:35:33 +0530 | [diff] [blame] | 13 | bootinfo['custom_css'] = frappe.db.get_value('Style Settings', None, 'custom_css') or '' |
Rushabh Mehta | 793ba6b | 2014-02-14 15:47:51 +0530 | [diff] [blame] | 14 | bootinfo['website_settings'] = frappe.model.doc.getsingle('Website Settings') |
Rushabh Mehta | 74506e9 | 2013-03-25 17:52:14 +0530 | [diff] [blame] | 15 | |
Rushabh Mehta | 793ba6b | 2014-02-14 15:47:51 +0530 | [diff] [blame] | 16 | if frappe.session['user']!='Guest': |
Rushabh Mehta | 74506e9 | 2013-03-25 17:52:14 +0530 | [diff] [blame] | 17 | bootinfo['letter_heads'] = get_letter_heads() |
Rushabh Mehta | 9dd25b3 | 2013-09-03 17:36:41 +0530 | [diff] [blame] | 18 | |
| 19 | load_country_and_currency(bootinfo) |
| 20 | |
Rushabh Mehta | 793ba6b | 2014-02-14 15:47:51 +0530 | [diff] [blame] | 21 | import frappe.model.doctype |
| 22 | bootinfo['notification_settings'] = frappe.doc("Notification Control", |
Rushabh Mehta | 74506e9 | 2013-03-25 17:52:14 +0530 | [diff] [blame] | 23 | "Notification Control").get_values() |
Rushabh Mehta | 27c4079 | 2013-04-03 15:21:44 +0530 | [diff] [blame] | 24 | |
Rushabh Mehta | 74506e9 | 2013-03-25 17:52:14 +0530 | [diff] [blame] | 25 | # if no company, show a dialog box to create a new company |
Anand Doshi | e9baaa6 | 2014-02-26 12:35:33 +0530 | [diff] [blame] | 26 | bootinfo["customer_count"] = frappe.db.sql("""select count(*) from tabCustomer""")[0][0] |
Rushabh Mehta | 2f7e1ab | 2013-06-26 17:20:12 +0530 | [diff] [blame] | 27 | |
| 28 | if not bootinfo["customer_count"]: |
Anand Doshi | e9baaa6 | 2014-02-26 12:35:33 +0530 | [diff] [blame] | 29 | bootinfo['setup_complete'] = frappe.db.sql("""select name from |
Rushabh Mehta | 2f7e1ab | 2013-06-26 17:20:12 +0530 | [diff] [blame] | 30 | tabCompany limit 1""") and 'Yes' or 'No' |
| 31 | |
Anand Doshi | e9baaa6 | 2014-02-26 12:35:33 +0530 | [diff] [blame] | 32 | bootinfo['docs'] += frappe.db.sql("""select name, default_currency, cost_center |
Anand Doshi | aeef7bd | 2013-04-19 16:21:55 +0530 | [diff] [blame] | 33 | from `tabCompany`""", as_dict=1, update={"doctype":":Company"}) |
Rushabh Mehta | 9dd25b3 | 2013-09-03 17:36:41 +0530 | [diff] [blame] | 34 | |
| 35 | def load_country_and_currency(bootinfo): |
| 36 | if bootinfo.control_panel.country and \ |
Anand Doshi | e9baaa6 | 2014-02-26 12:35:33 +0530 | [diff] [blame] | 37 | frappe.db.exists("Country", bootinfo.control_panel.country): |
Rushabh Mehta | 793ba6b | 2014-02-14 15:47:51 +0530 | [diff] [blame] | 38 | bootinfo["docs"] += [frappe.doc("Country", bootinfo.control_panel.country)] |
Rushabh Mehta | 9dd25b3 | 2013-09-03 17:36:41 +0530 | [diff] [blame] | 39 | |
Anand Doshi | e9baaa6 | 2014-02-26 12:35:33 +0530 | [diff] [blame] | 40 | bootinfo["docs"] += frappe.db.sql("""select * from tabCurrency |
Rushabh Mehta | 9dd25b3 | 2013-09-03 17:36:41 +0530 | [diff] [blame] | 41 | where ifnull(enabled,0)=1""", as_dict=1, update={"doctype":":Currency"}) |
| 42 | |
Rushabh Mehta | 74506e9 | 2013-03-25 17:52:14 +0530 | [diff] [blame] | 43 | def get_letter_heads(): |
Rushabh Mehta | 793ba6b | 2014-02-14 15:47:51 +0530 | [diff] [blame] | 44 | import frappe |
Anand Doshi | e9baaa6 | 2014-02-26 12:35:33 +0530 | [diff] [blame] | 45 | ret = frappe.db.sql("""select name, content from `tabLetter Head` |
Rushabh Mehta | 74506e9 | 2013-03-25 17:52:14 +0530 | [diff] [blame] | 46 | where ifnull(disabled,0)=0""") |
| 47 | return dict(ret) |
Pratik Vyas | cfed8c4 | 2013-09-21 15:16:47 +0530 | [diff] [blame] | 48 | |