2013-11-20 07:29:58 +00:00
|
|
|
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
2013-08-05 09:29:54 +00:00
|
|
|
# License: GNU General Public License v3. See license.txt
|
2013-01-09 11:09:27 +00:00
|
|
|
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
import webnotes
|
|
|
|
|
2013-06-18 10:16:32 +00:00
|
|
|
for_doctype = {
|
2013-01-10 06:55:25 +00:00
|
|
|
"Support Ticket": {"status":"Open"},
|
|
|
|
"Customer Issue": {"status":"Open"},
|
|
|
|
"Task": {"status":"Open"},
|
|
|
|
"Lead": {"status":"Open"},
|
2013-02-11 09:24:30 +00:00
|
|
|
"Contact": {"status":"Open"},
|
2013-01-10 06:55:25 +00:00
|
|
|
"Opportunity": {"docstatus":0},
|
|
|
|
"Quotation": {"docstatus":0},
|
|
|
|
"Sales Order": {"docstatus":0},
|
|
|
|
"Journal Voucher": {"docstatus":0},
|
|
|
|
"Sales Invoice": {"docstatus":0},
|
|
|
|
"Purchase Invoice": {"docstatus":0},
|
|
|
|
"Leave Application": {"status":"Open"},
|
|
|
|
"Expense Claim": {"approval_status":"Draft"},
|
2013-01-16 06:04:26 +00:00
|
|
|
"Job Applicant": {"status":"Open"},
|
2013-01-10 06:55:25 +00:00
|
|
|
"Purchase Receipt": {"docstatus":0},
|
|
|
|
"Delivery Note": {"docstatus":0},
|
|
|
|
"Stock Entry": {"docstatus":0},
|
2013-02-18 08:19:15 +00:00
|
|
|
"Material Request": {"docstatus":0},
|
2013-01-10 06:55:25 +00:00
|
|
|
"Purchase Order": {"docstatus":0},
|
|
|
|
"Production Order": {"docstatus":0},
|
|
|
|
"BOM": {"docstatus":0},
|
|
|
|
"Timesheet": {"docstatus":0},
|
2013-03-01 12:54:52 +00:00
|
|
|
"Time Log": {"status":"Draft"},
|
|
|
|
"Time Log Batch": {"status":"Draft"},
|
2013-06-18 10:16:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
def get_things_todo():
|
|
|
|
"""Returns a count of incomplete todos"""
|
|
|
|
incomplete_todos = webnotes.conn.sql("""\
|
|
|
|
SELECT COUNT(*) FROM `tabToDo`
|
|
|
|
WHERE IFNULL(checked, 0) = 0
|
|
|
|
AND (owner = %s or assigned_by=%s)""", (webnotes.session.user, webnotes.session.user))
|
|
|
|
return incomplete_todos[0][0]
|
|
|
|
|
|
|
|
def get_todays_events():
|
|
|
|
"""Returns a count of todays events in calendar"""
|
2013-07-26 13:33:04 +00:00
|
|
|
from core.doctype.event.event import get_events
|
2013-06-18 10:16:32 +00:00
|
|
|
from webnotes.utils import nowdate
|
2013-07-26 13:33:04 +00:00
|
|
|
today = nowdate()
|
|
|
|
return len(get_events(today, today))
|
2013-06-18 10:16:32 +00:00
|
|
|
|
|
|
|
def get_unread_messages():
|
|
|
|
"returns unread (docstatus-0 messages for a user)"
|
|
|
|
return webnotes.conn.sql("""\
|
|
|
|
SELECT count(*)
|
|
|
|
FROM `tabComment`
|
|
|
|
WHERE comment_doctype IN ('My Company', 'Message')
|
|
|
|
AND comment_docname = %s
|
|
|
|
AND ifnull(docstatus,0)=0
|
|
|
|
""", webnotes.user.name)[0][0]
|
|
|
|
|
2013-11-18 07:52:07 +00:00
|
|
|
for_module_doctypes = {
|
|
|
|
"ToDo": "To Do",
|
|
|
|
"Event": "Calendar",
|
|
|
|
"Comment": "Messages"
|
|
|
|
}
|
|
|
|
|
2013-06-18 10:16:32 +00:00
|
|
|
for_module = {
|
|
|
|
"To Do": get_things_todo,
|
|
|
|
"Calendar": get_todays_events,
|
|
|
|
"Messages": get_unread_messages
|
|
|
|
}
|