From 353d408e88d12b6243e7b2b99dd6b89af57b8379 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 19 Nov 2012 17:35:50 +0530 Subject: [PATCH] added get_query for employee related table --- hr/doctype/appraisal/appraisal.js | 2 ++ hr/doctype/attendance/attendance.js | 7 +------ hr/doctype/employee/employee.js | 4 +++- hr/doctype/expense_claim/expense_claim.js | 2 ++ hr/doctype/leave_allocation/leave_allocation.js | 2 ++ hr/doctype/leave_application/leave_application.js | 2 ++ hr/doctype/salary_slip/salary_slip.js | 2 ++ hr/doctype/salary_structure/salary_structure.js | 2 ++ public/js/utils.js | 10 +++++++++- setup/doctype/authorization_rule/authorization_rule.js | 6 ++++-- setup/doctype/sales_person/sales_person.js | 8 ++------ 11 files changed, 31 insertions(+), 16 deletions(-) diff --git a/hr/doctype/appraisal/appraisal.js b/hr/doctype/appraisal/appraisal.js index 3601da9bd0..11fa328e20 100644 --- a/hr/doctype/appraisal/appraisal.js +++ b/hr/doctype/appraisal/appraisal.js @@ -92,3 +92,5 @@ cur_frm.cscript.calculate_total = function(doc,cdt,cdn){ doc.total_score = flt(total); refresh_field('total_score'); } + +cur_frm.fields_dict.employee.get_query = erpnext.utils.employee_query; \ No newline at end of file diff --git a/hr/doctype/attendance/attendance.js b/hr/doctype/attendance/attendance.js index 120a50e318..3ba986891b 100644 --- a/hr/doctype/attendance/attendance.js +++ b/hr/doctype/attendance/attendance.js @@ -22,9 +22,4 @@ cur_frm.cscript.employee = function(doc,cdt,cdn){ refresh_field('employee_name'); } - -//Employee -//----------------------------- -cur_frm.fields_dict['employee'].get_query = function(doc,cdt,cdn) { - return 'SELECT `tabEmployee`.`name`, `tabEmployee`.`employee_name` FROM `tabEmployee` WHERE `tabEmployee`.status = "Active" AND `tabEmployee`.`docstatus`!= 2 AND (`tabEmployee`.`employee_name` LIKE "%s" OR `tabEmployee`.`%(key)s` LIKE "%s") ORDER BY `tabEmployee`.`name` ASC LIMIT 50'; -} +cur_frm.fields_dict.employee.get_query = erpnext.utils.employee_query; \ No newline at end of file diff --git a/hr/doctype/employee/employee.js b/hr/doctype/employee/employee.js index 75866c50bd..eab90cb3df 100644 --- a/hr/doctype/employee/employee.js +++ b/hr/doctype/employee/employee.js @@ -65,4 +65,6 @@ cur_frm.cscript.make_salary_structure = function(doc,dt,dn,det){ loaddoc('Salary Structure', st.name); } -cur_frm.fields_dict.user_id.get_query = erpnext.utils.profile_query; \ No newline at end of file +cur_frm.fields_dict.user_id.get_query = erpnext.utils.profile_query; + +cur_frm.fields_dict.reports_to.get_query = erpnext.utils.employee_query; \ No newline at end of file diff --git a/hr/doctype/expense_claim/expense_claim.js b/hr/doctype/expense_claim/expense_claim.js index d8bee8bc22..5ed0d379b4 100644 --- a/hr/doctype/expense_claim/expense_claim.js +++ b/hr/doctype/expense_claim/expense_claim.js @@ -255,3 +255,5 @@ cur_frm.cscript.on_submit = function(doc, cdt, cdn) { } cur_frm.cscript.notify(doc, args); } + +cur_frm.fields_dict.employee.get_query = erpnext.utils.employee_query; \ No newline at end of file diff --git a/hr/doctype/leave_allocation/leave_allocation.js b/hr/doctype/leave_allocation/leave_allocation.js index bce7af3e4a..a26d211bbd 100755 --- a/hr/doctype/leave_allocation/leave_allocation.js +++ b/hr/doctype/leave_allocation/leave_allocation.js @@ -78,3 +78,5 @@ calculate_total_leaves_allocated = function(doc, dt, dn) { set_multiple(dt,dn,{carry_forwarded_leaves : 0,total_leaves_allocated : flt(doc.new_leaves_allocated)}); } } + +cur_frm.fields_dict.employee.get_query = erpnext.utils.employee_query; \ No newline at end of file diff --git a/hr/doctype/leave_application/leave_application.js b/hr/doctype/leave_application/leave_application.js index b7524c8252..e8952ca710 100755 --- a/hr/doctype/leave_application/leave_application.js +++ b/hr/doctype/leave_application/leave_application.js @@ -99,3 +99,5 @@ calculate_total_days = function(doc, dt, dn) { } } } + +cur_frm.fields_dict.employee.get_query = erpnext.utils.employee_query; \ No newline at end of file diff --git a/hr/doctype/salary_slip/salary_slip.js b/hr/doctype/salary_slip/salary_slip.js index 3e61665a2b..fc58271336 100644 --- a/hr/doctype/salary_slip/salary_slip.js +++ b/hr/doctype/salary_slip/salary_slip.js @@ -138,3 +138,5 @@ cur_frm.cscript.leave_encashment_amount = cur_frm.cscript.arrear_amount; cur_frm.cscript.validate = function(doc, dt, dn) { calculate_all(doc, dt, dn); } + +cur_frm.fields_dict.employee.get_query = erpnext.utils.employee_query; \ No newline at end of file diff --git a/hr/doctype/salary_structure/salary_structure.js b/hr/doctype/salary_structure/salary_structure.js index 27ed19e83f..3692fe890a 100644 --- a/hr/doctype/salary_structure/salary_structure.js +++ b/hr/doctype/salary_structure/salary_structure.js @@ -107,3 +107,5 @@ var calculate_totals = function(doc, cdt, cdn) { cur_frm.cscript.validate = function(doc, cdt, cdn) { calculate_totals(doc, cdt, cdn); } + +cur_frm.fields_dict.employee.get_query = erpnext.utils.employee_query; \ No newline at end of file diff --git a/public/js/utils.js b/public/js/utils.js index 76a443a56a..b84e293540 100644 --- a/public/js/utils.js +++ b/public/js/utils.js @@ -22,5 +22,13 @@ erpnext.utils.profile_query = function() { from `tabProfile` where ifnull(enabled, 0)=1 and docstatus < 2 and \ name not in ('Administrator', 'Guest') and (%(key)s like \"%s\" or \ concat_ws(' ', first_name, middle_name, last_name) like \"%%%s\") \ - limit 50"; + order by name asc limit 50"; +}; + +// employee related get query +erpnext.utils.employee_query = function() { + return "select name, employee_name from `tabEmployee` \ + where status = 'Active' and docstatus < 2 and \ + (employee_name like \"%%%s\" or %(key)s like \"%s\") \ + order by name asc limit 50"; }; \ No newline at end of file diff --git a/setup/doctype/authorization_rule/authorization_rule.js b/setup/doctype/authorization_rule/authorization_rule.js index 8bec206d15..b29d88915e 100644 --- a/setup/doctype/authorization_rule/authorization_rule.js +++ b/setup/doctype/authorization_rule/authorization_rule.js @@ -85,9 +85,9 @@ cur_frm.cscript.transaction = function(doc,cdt,cdn){ } -cur_frm.fields_dict.system_user.get_query = erpnext.profile_query; +cur_frm.fields_dict.system_user.get_query = erpnext.utils.profile_query; -cur_frm.fields_dict.approving_user.get_query = erpnext.profile_query; +cur_frm.fields_dict.approving_user.get_query = erpnext.utils.profile_query; // System Role Trigger // ----------------------- @@ -112,3 +112,5 @@ cur_frm.fields_dict['master_name'].get_query = function(doc){ else return 'SELECT `tabItem`.`name` FROM `tabItem` WHERE `tabItem`.`name` = "cheating done to avoid null" ORDER BY `tabItem`.`name` DESC LIMIT 50'; } + +cur_frm.fields_dict.to_emp.get_query = erpnext.utils.employee_query; \ No newline at end of file diff --git a/setup/doctype/sales_person/sales_person.js b/setup/doctype/sales_person/sales_person.js index 008d30d00c..ba1a339ad2 100644 --- a/setup/doctype/sales_person/sales_person.js +++ b/setup/doctype/sales_person/sales_person.js @@ -38,12 +38,8 @@ cur_frm.fields_dict['parent_sales_person'].get_query = function(doc,cdt,cdn) { return 'SELECT `tabSales Person`.`name`,`tabSales Person`.`parent_sales_person` FROM `tabSales Person` WHERE `tabSales Person`.`is_group` = "Yes" AND `tabSales Person`.`docstatus`!= 2 AND `tabSales Person`.`name` !="'+doc.sales_person_name+'" AND `tabSales Person`.%(key)s LIKE "%s" ORDER BY `tabSales Person`.`name` ASC LIMIT 50'; } -//get query select Territory -cur_frm.fields_dict['territory'].get_query = function(doc,cdt,cdn) { - return 'SELECT `tabTerritory`.`name` FROM `tabTerritory` WHERE `tabTerritory`.`is_group` = "No" AND `tabTerritory`.`docstatus`!= 2 AND `tabTerritory`.%(key)s LIKE "%s" ORDER BY `tabTerritory`.`name` ASC LIMIT 50'; -} - -// ******************** ITEM Group ******************************** cur_frm.fields_dict['target_details'].grid.get_field("item_group").get_query = function(doc, cdt, cdn) { return 'SELECT `tabItem Group`.name FROM `tabItem Group` WHERE `tabItem Group`.is_group="No" AND `tabItem Group`.docstatus != 2 AND `tabItem Group`.%(key)s LIKE "%s" LIMIT 50' } + +cur_frm.fields_dict.employee.get_query = erpnext.utils.employee_query; \ No newline at end of file