brotherton-erpnext/erpnext/projects/utils.py

32 lines
1.2 KiB
Python
Raw Normal View History

2013-11-20 07:29:58 +00:00
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
2013-02-28 13:12:46 +00:00
# For license information, please see license.txt
from __future__ import unicode_literals
2014-02-14 10:17:51 +00:00
import frappe
2013-02-28 13:12:46 +00:00
2014-02-14 10:17:51 +00:00
@frappe.whitelist()
2013-02-28 13:12:46 +00:00
def get_time_log_list(doctype, txt, searchfield, start, page_len, filters):
2014-02-14 10:17:51 +00:00
return frappe.conn.get_values("Time Log", filters, ["name", "activity_type", "owner"])
2014-02-14 10:17:51 +00:00
@frappe.whitelist()
def query_task(doctype, txt, searchfield, start, page_len, filters):
2014-02-14 10:17:51 +00:00
from frappe.widgets.reportview import build_match_conditions
search_string = "%%%s%%" % txt
order_by_string = "%s%%" % txt
match_conditions = build_match_conditions("Task")
match_conditions = ("and" + match_conditions) if match_conditions else ""
2014-02-14 10:17:51 +00:00
return frappe.conn.sql("""select name, subject from `tabTask`
where (`%s` like %s or `subject` like %s) %s
order by
case when `subject` like %s then 0 else 1 end,
case when `%s` like %s then 0 else 1 end,
`%s`,
subject
limit %s, %s""" %
(searchfield, "%s", "%s", match_conditions, "%s",
searchfield, "%s", searchfield, "%s", "%s"),
(search_string, search_string, order_by_string, order_by_string, start, page_len))