preferred email for payroll
diff --git a/erpnext/hr/doctype/employee/employee.js b/erpnext/hr/doctype/employee/employee.js
index f69f4e5..d0c2fba 100755
--- a/erpnext/hr/doctype/employee/employee.js
+++ b/erpnext/hr/doctype/employee/employee.js
@@ -40,6 +40,28 @@
 				"Ms": "Female"
 			}[this.frm.doc.salutation]);
 		}
+	},
+	
+});
+frappe.ui.form.on('Employee',{
+	prefered_contact_email:function(frm){
+		frm.events.update_contact(frm)
+	},
+	personal_email:function(frm){
+		frm.events.update_contact(frm)
+	},
+	company_email:function(frm){
+		frm.events.update_contact(frm)
+	},
+	user_id:function(frm){
+		frm.events.update_contact(frm)
+	},
+	update_contact:function(frm){
+		for(var i =0, j=frm.fields.length;i<j;i++){
+			if (frm.fields[i].df.label===frm.doc.prefered_contact_email){
+                frm.set_value("prefered_email",frm.fields[i].value)
+			}
+		}
 	}
 });
 cur_frm.cscript = new erpnext.hr.EmployeeController({frm: cur_frm});
diff --git a/erpnext/hr/doctype/employee/employee.json b/erpnext/hr/doctype/employee/employee.json
index 2677ac0..0e71e9b 100644
--- a/erpnext/hr/doctype/employee/employee.json
+++ b/erpnext/hr/doctype/employee/employee.json
@@ -3,11 +3,13 @@
  "allow_import": 1, 
  "allow_rename": 1, 
  "autoname": "naming_series:", 
+ "beta": 0, 
  "creation": "2013-03-07 09:04:18", 
  "custom": 0, 
  "docstatus": 0, 
  "doctype": "DocType", 
  "document_type": "Setup", 
+ "editable_grid": 0, 
  "fields": [
   {
    "allow_on_submit": 0, 
@@ -949,6 +951,59 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "default": "", 
+   "fieldname": "prefered_contact_email", 
+   "fieldtype": "Select", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0,
+   "in_list_view": 0, 
+   "label": "Prefered Contact Email", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "\nCompany Email\nPersonal Email\nUser ID", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "fieldname": "prefered_email", 
+   "fieldtype": "Data", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0,
+   "in_list_view": 0, 
+   "label": "Prefered Email", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Email", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 1, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
    "fieldname": "cell_number", 
    "fieldtype": "Data", 
    "hidden": 0, 
@@ -1954,7 +2009,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2016-04-04 06:44:59.778649", 
+ "modified": "2016-09-19 16:46:48.432197", 
  "modified_by": "Administrator", 
  "module": "HR", 
  "name": "Employee", 
@@ -2022,6 +2077,7 @@
    "write": 1
   }
  ], 
+ "quick_entry": 0, 
  "read_only": 0, 
  "read_only_onload": 0, 
  "search_fields": "employee_name", 
diff --git a/erpnext/hr/doctype/hr_settings/hr_settings.json b/erpnext/hr/doctype/hr_settings/hr_settings.json
index d7892c7..d0f7c20 100644
--- a/erpnext/hr/doctype/hr_settings/hr_settings.json
+++ b/erpnext/hr/doctype/hr_settings/hr_settings.json
@@ -167,7 +167,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "default": "1", 
-   "description": "", 
+   "description": "Emails salary slip to employee based on preferred email selected in Employee", 
    "fieldname": "email_salary_slip_to_employee", 
    "fieldtype": "Check", 
    "hidden": 0, 
@@ -226,7 +226,7 @@
  "issingle": 1, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2016-08-10 12:32:39.780599", 
+ "modified": "2016-09-21 11:28:50.687129", 
  "modified_by": "Administrator", 
  "module": "HR", 
  "name": "HR Settings", 
diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.py b/erpnext/hr/doctype/salary_slip/salary_slip.py
index 1918f92..94a7202 100644
--- a/erpnext/hr/doctype/salary_slip/salary_slip.py
+++ b/erpnext/hr/doctype/salary_slip/salary_slip.py
@@ -335,8 +335,8 @@
 		self.update_status()
 
 	def email_salary_slip(self):
-		receiver = frappe.db.get_value("Employee", self.employee, "company_email") or \
-			frappe.db.get_value("Employee", self.employee, "personal_email")
+		receiver = frappe.db.get_value("Employee", self.employee, "prefered_email")
+
 		if receiver:
 			subj = 'Salary Slip - from {0} to {1}, fiscal year {2}'.format(self.start_date, self.end_date, self.fiscal_year)
 			frappe.sendmail([receiver], subject=subj, message = _("Please see attachment"),
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index c9ae6e0..5ab2dbf 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -330,5 +330,8 @@
 erpnext.patches.v7_1.update_lead_source
 erpnext.patches.v7_1.fix_link_for_customer_from_lead
 erpnext.patches.v7_0.update_mode_of_payment_type
+
+execute:frappe.reload_doctype('Employee')
+execute:frappe.db.sql("update `tabEmployee` set prefered_contact_email = IFNULL(prefered_contact_email,'') ")
 execute:frappe.reload_doctype("Salary Slip")
 execute:frappe.db.sql("update `tabSalary Slip` set posting_date=creation")