blob: 7a0c50cc608d05239f17a3b99abd9a07ce493b6a [file] [log] [blame]
Rushabh Mehtaad45e312013-11-20 12:59:58 +05301# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
Rushabh Mehtae67d1fb2013-08-05 14:59:54 +05302# License: GNU General Public License v3. See license.txt
3
Rushabh Mehtab21eb9a2013-02-28 18:42:46 +05304# For license information, please see license.txt
5
6from __future__ import unicode_literals
7import webnotes
8
9@webnotes.whitelist()
10def get_time_log_list(doctype, txt, searchfield, start, page_len, filters):
Anand Doshi9e1d1202013-05-09 19:34:34 +053011 return webnotes.conn.get_values("Time Log", filters, ["name", "activity_type", "owner"])
12
13@webnotes.whitelist()
14def query_task(doctype, txt, searchfield, start, page_len, filters):
Anand Doshi0d504492013-05-13 15:15:20 +053015 from webnotes.widgets.reportview import build_match_conditions
16
Anand Doshi9e1d1202013-05-09 19:34:34 +053017 search_string = "%%%s%%" % txt
18 order_by_string = "%s%%" % txt
Anand Doshi0d504492013-05-13 15:15:20 +053019 match_conditions = build_match_conditions("Task")
20 match_conditions = ("and" + match_conditions) if match_conditions else ""
21
Anand Doshi9e1d1202013-05-09 19:34:34 +053022 return webnotes.conn.sql("""select name, subject from `tabTask`
Anand Doshi0d504492013-05-13 15:15:20 +053023 where (`%s` like %s or `subject` like %s) %s
Anand Doshi9e1d1202013-05-09 19:34:34 +053024 order by
25 case when `subject` like %s then 0 else 1 end,
26 case when `%s` like %s then 0 else 1 end,
27 `%s`,
28 subject
29 limit %s, %s""" %
Anand Doshi0d504492013-05-13 15:15:20 +053030 (searchfield, "%s", "%s", match_conditions, "%s",
31 searchfield, "%s", searchfield, "%s", "%s"),
Anand Doshi9e1d1202013-05-09 19:34:34 +053032 (search_string, search_string, order_by_string, order_by_string, start, page_len))