Rushabh Mehta | b21eb9a | 2013-02-28 18:42:46 +0530 | [diff] [blame] | 1 | # For license information, please see license.txt |
| 2 | |
| 3 | from __future__ import unicode_literals |
| 4 | import webnotes |
| 5 | |
| 6 | @webnotes.whitelist() |
| 7 | def get_time_log_list(doctype, txt, searchfield, start, page_len, filters): |
Anand Doshi | 9e1d120 | 2013-05-09 19:34:34 +0530 | [diff] [blame] | 8 | return webnotes.conn.get_values("Time Log", filters, ["name", "activity_type", "owner"]) |
| 9 | |
| 10 | @webnotes.whitelist() |
| 11 | def query_task(doctype, txt, searchfield, start, page_len, filters): |
Anand Doshi | 0d50449 | 2013-05-13 15:15:20 +0530 | [diff] [blame] | 12 | from webnotes.widgets.reportview import build_match_conditions |
| 13 | |
Anand Doshi | 9e1d120 | 2013-05-09 19:34:34 +0530 | [diff] [blame] | 14 | search_string = "%%%s%%" % txt |
| 15 | order_by_string = "%s%%" % txt |
Anand Doshi | 0d50449 | 2013-05-13 15:15:20 +0530 | [diff] [blame] | 16 | match_conditions = build_match_conditions("Task") |
| 17 | match_conditions = ("and" + match_conditions) if match_conditions else "" |
| 18 | |
Anand Doshi | 9e1d120 | 2013-05-09 19:34:34 +0530 | [diff] [blame] | 19 | return webnotes.conn.sql("""select name, subject from `tabTask` |
Anand Doshi | 0d50449 | 2013-05-13 15:15:20 +0530 | [diff] [blame] | 20 | where (`%s` like %s or `subject` like %s) %s |
Anand Doshi | 9e1d120 | 2013-05-09 19:34:34 +0530 | [diff] [blame] | 21 | 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 Doshi | 0d50449 | 2013-05-13 15:15:20 +0530 | [diff] [blame] | 27 | (searchfield, "%s", "%s", match_conditions, "%s", |
| 28 | searchfield, "%s", searchfield, "%s", "%s"), |
Anand Doshi | 9e1d120 | 2013-05-09 19:34:34 +0530 | [diff] [blame] | 29 | (search_string, search_string, order_by_string, order_by_string, start, page_len)) |