blob: e37a21c2c4960745e1daf27a9e585fe2e11f0271 [file] [log] [blame]
Rushabh Mehtab21eb9a2013-02-28 18:42:46 +05301# For license information, please see license.txt
2
3from __future__ import unicode_literals
4import webnotes
5
6@webnotes.whitelist()
7def get_time_log_list(doctype, txt, searchfield, start, page_len, filters):
Anand Doshi9e1d1202013-05-09 19:34:34 +05308 return webnotes.conn.get_values("Time Log", filters, ["name", "activity_type", "owner"])
9
10@webnotes.whitelist()
11def query_task(doctype, txt, searchfield, start, page_len, filters):
Anand Doshi0d504492013-05-13 15:15:20 +053012 from webnotes.widgets.reportview import build_match_conditions
13
Anand Doshi9e1d1202013-05-09 19:34:34 +053014 search_string = "%%%s%%" % txt
15 order_by_string = "%s%%" % txt
Anand Doshi0d504492013-05-13 15:15:20 +053016 match_conditions = build_match_conditions("Task")
17 match_conditions = ("and" + match_conditions) if match_conditions else ""
18
Anand Doshi9e1d1202013-05-09 19:34:34 +053019 return webnotes.conn.sql("""select name, subject from `tabTask`
Anand Doshi0d504492013-05-13 15:15:20 +053020 where (`%s` like %s or `subject` like %s) %s
Anand Doshi9e1d1202013-05-09 19:34:34 +053021 order by
22 case when `subject` like %s then 0 else 1 end,
23 case when `%s` like %s then 0 else 1 end,
24 `%s`,
25 subject
26 limit %s, %s""" %
Anand Doshi0d504492013-05-13 15:15:20 +053027 (searchfield, "%s", "%s", match_conditions, "%s",
28 searchfield, "%s", searchfield, "%s", "%s"),
Anand Doshi9e1d1202013-05-09 19:34:34 +053029 (search_string, search_string, order_by_string, order_by_string, start, page_len))