2015-03-03 14:55:30 +05:30
|
|
|
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
2013-08-05 14:59:54 +05:30
|
|
|
# License: GNU General Public License v3. See license.txt
|
|
|
|
|
2013-02-28 18:42:46 +05:30
|
|
|
# For license information, please see license.txt
|
|
|
|
|
|
|
|
from __future__ import unicode_literals
|
2014-02-14 15:47:51 +05:30
|
|
|
import frappe
|
2013-02-28 18:42:46 +05:30
|
|
|
|
2014-02-14 15:47:51 +05:30
|
|
|
@frappe.whitelist()
|
2020-08-05 19:42:25 +05:30
|
|
|
@frappe.validate_and_sanitize_search_inputs
|
2013-05-09 19:34:34 +05:30
|
|
|
def query_task(doctype, txt, searchfield, start, page_len, filters):
|
2014-09-09 16:15:35 +05:30
|
|
|
from frappe.desk.reportview import build_match_conditions
|
2015-11-17 18:27:50 +05:30
|
|
|
|
2013-05-09 19:34:34 +05:30
|
|
|
search_string = "%%%s%%" % txt
|
|
|
|
order_by_string = "%s%%" % txt
|
2013-05-13 15:15:20 +05:30
|
|
|
match_conditions = build_match_conditions("Task")
|
|
|
|
match_conditions = ("and" + match_conditions) if match_conditions else ""
|
2015-11-17 18:27:50 +05:30
|
|
|
|
2014-02-26 12:35:33 +05:30
|
|
|
return frappe.db.sql("""select name, subject from `tabTask`
|
2013-05-13 15:15:20 +05:30
|
|
|
where (`%s` like %s or `subject` like %s) %s
|
2013-05-09 19:34:34 +05:30
|
|
|
order by
|
|
|
|
case when `subject` like %s then 0 else 1 end,
|
|
|
|
case when `%s` like %s then 0 else 1 end,
|
|
|
|
`%s`,
|
|
|
|
subject
|
2015-11-17 18:27:50 +05:30
|
|
|
limit %s, %s""" %
|
2018-09-21 10:20:52 +05:30
|
|
|
(searchfield, "%s", "%s", match_conditions, "%s",
|
|
|
|
searchfield, "%s", searchfield, "%s", "%s"),
|
2015-11-17 18:27:50 +05:30
|
|
|
(search_string, search_string, order_by_string, order_by_string, start, page_len))
|