[Fix] Filters to get employee in Payroll

This commit is contained in:
Kanchan Chauhan
2016-11-16 15:29:01 +05:30
parent 535462fc20
commit 7652b857c8
3 changed files with 15 additions and 13 deletions

View File

@@ -32,12 +32,13 @@ def get_filters_cond(doctype, filters, conditions):
# searches for active employees
def employee_query(doctype, txt, searchfield, start, page_len, filters):
conditions = []
return frappe.db.sql("""select name, employee_name from `tabEmployee`
where status = 'Active'
and docstatus < 2
and ({key} like %(txt)s
or employee_name like %(txt)s)
{mcond}
{fcond} {mcond}
order by
if(locate(%(_txt)s, name), locate(%(_txt)s, name), 99999),
if(locate(%(_txt)s, employee_name), locate(%(_txt)s, employee_name), 99999),
@@ -45,6 +46,7 @@ def employee_query(doctype, txt, searchfield, start, page_len, filters):
name, employee_name
limit %(start)s, %(page_len)s""".format(**{
'key': searchfield,
'fcond': get_filters_cond(doctype, filters, conditions),
'mcond': get_match_cond(doctype)
}), {
'txt': "%%%s%%" % txt,