[time log] [query] search task based on subject
diff --git a/projects/doctype/time_log/time_log.js b/projects/doctype/time_log/time_log.js
index a602332..22f9610 100644
--- a/projects/doctype/time_log/time_log.js
+++ b/projects/doctype/time_log/time_log.js
@@ -1,5 +1,9 @@
-$.extend(cur_frm.cscript, {
-	refresh: function(doc) {
-		
+wn.provide("erpnext.projects");
+
+erpnext.projects.TimeLog = wn.ui.form.Controller.extend({
+	setup: function() {
+		this.frm.set_query("task", erpnext.queries.task);
 	}
-});
\ No newline at end of file
+});
+
+cur_frm.cscript = new erpnext.projects.TimeLog({frm: cur_frm});
\ No newline at end of file
diff --git a/projects/utils.py b/projects/utils.py
index 7a45b08..70f6995 100644
--- a/projects/utils.py
+++ b/projects/utils.py
@@ -5,4 +5,19 @@
 
 @webnotes.whitelist()
 def get_time_log_list(doctype, txt, searchfield, start, page_len, filters):
-	return webnotes.conn.get_values("Time Log", filters, ["name", "activity_type", "owner"])
\ No newline at end of file
+	return webnotes.conn.get_values("Time Log", filters, ["name", "activity_type", "owner"])
+
+@webnotes.whitelist()
+def query_task(doctype, txt, searchfield, start, page_len, filters):
+	search_string = "%%%s%%" % txt
+	order_by_string = "%s%%" % txt
+	return webnotes.conn.sql("""select name, subject from `tabTask`
+		where `%s` like %s or `subject` like %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", "%s", searchfield, "%s", searchfield, "%s", "%s"),
+		(search_string, search_string, order_by_string, order_by_string, start, page_len))
\ No newline at end of file
diff --git a/public/js/queries.js b/public/js/queries.js
index 9809cd9..24ddc13 100644
--- a/public/js/queries.js
+++ b/public/js/queries.js
@@ -160,4 +160,8 @@
 			: "")
 		+ " LIMIT 50"
 
-}
\ No newline at end of file
+}
+
+erpnext.queries.task = function() {
+	return { query: "projects.utils.query_task" };
+};
\ No newline at end of file