[Fixes]Payroll Fixes
diff --git a/erpnext/hr/doctype/process_payroll/process_payroll.js b/erpnext/hr/doctype/process_payroll/process_payroll.js
index 3265f88..3eb2fa2 100644
--- a/erpnext/hr/doctype/process_payroll/process_payroll.js
+++ b/erpnext/hr/doctype/process_payroll/process_payroll.js
@@ -3,7 +3,7 @@
 
 frappe.ui.form.on("Process Payroll", {
 	onload: function(frm) {
-		frm.doc.posting_date = frm.doc.start_date = frm.doc.end_date = frappe.datetime.nowdate()
+		frm.doc.posting_date = frappe.datetime.nowdate()
 	},
 
 	refresh: function(frm) {
diff --git a/erpnext/hr/doctype/process_payroll/process_payroll.json b/erpnext/hr/doctype/process_payroll/process_payroll.json
index 8e0d395..08dc14c 100644
--- a/erpnext/hr/doctype/process_payroll/process_payroll.json
+++ b/erpnext/hr/doctype/process_payroll/process_payroll.json
@@ -98,7 +98,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
-   "default": "Today", 
+   "default": "", 
    "fieldname": "posting_date", 
    "fieldtype": "Date", 
    "hidden": 0, 
@@ -352,7 +352,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
-   "default": "Today", 
+   "default": "", 
    "fieldname": "start_date", 
    "fieldtype": "Date", 
    "hidden": 0, 
@@ -408,7 +408,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
-   "default": "Today", 
+   "default": "", 
    "fieldname": "end_date", 
    "fieldtype": "Date", 
    "hidden": 0, 
@@ -722,7 +722,7 @@
  "issingle": 1, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2016-11-26 01:14:51.691057", 
+ "modified": "2016-12-14 12:58:16.206040", 
  "modified_by": "Administrator", 
  "module": "HR", 
  "name": "Process Payroll", 
diff --git a/erpnext/hr/doctype/process_payroll/process_payroll.py b/erpnext/hr/doctype/process_payroll/process_payroll.py
index 97e3876..cbed9c3 100644
--- a/erpnext/hr/doctype/process_payroll/process_payroll.py
+++ b/erpnext/hr/doctype/process_payroll/process_payroll.py
@@ -5,9 +5,6 @@
 import frappe
 from frappe.utils import cint, flt, nowdate, add_days, getdate
 from frappe import _
-import collections
-from collections import defaultdict
-from calendar import monthrange
 from erpnext.accounts.utils import get_fiscal_year
 
 from frappe.model.document import Document
@@ -30,8 +27,9 @@
 		sal_struct = frappe.db.sql("""
 				select name from `tabSalary Structure`
 				where docstatus != 2 and is_active = 'Yes' and company = %(company)s and
-				ifnull(salary_slip_based_on_timesheet,0) = %(salary_slip_based_on_timesheet)s""",
-				{"company": self.company, "salary_slip_based_on_timesheet":self.salary_slip_based_on_timesheet})
+				from_date <= %(start_date)s and (to_date is null or to_date >= %(end_date)s) and
+				ifnull(salary_slip_based_on_timesheet,0) = %(salary_slip_based_on_timesheet)s {struct_cond}""".format(struct_cond=struct_cond),
+				{"company": self.company, "start_date": self.start_date, "end_date": self.end_date, "salary_slip_based_on_timesheet":self.salary_slip_based_on_timesheet})
 		
 		if sal_struct:
 			cond += "and t2.parent IN %(sal_struct)s "
@@ -314,7 +312,9 @@
 		frappe.throw(_("Fiscal Year {0} not found").format(year))
 
 @frappe.whitelist()
-def get_start_end_dates(payroll_frequency, start_date, end_date):
+def get_start_end_dates(payroll_frequency = None, start_date = None, end_date = None):
+	if payroll_frequency and not start_date:
+		start_date = nowdate()
 	if payroll_frequency == "Monthly" or payroll_frequency == "Bimonthly":
 		fiscal_year = get_fiscal_year(start_date)[0] or get_fiscal_year(end_date)[0]
 		month = "%02d" % getdate(start_date).month or "%02d" % getdate(end_date).month
diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.json b/erpnext/hr/doctype/salary_slip/salary_slip.json
index 062f41f..24651d1 100644
--- a/erpnext/hr/doctype/salary_slip/salary_slip.json
+++ b/erpnext/hr/doctype/salary_slip/salary_slip.json
@@ -408,7 +408,7 @@
    "precision": "", 
    "print_hide": 0, 
    "print_hide_if_no_value": 0, 
-   "read_only": 1, 
+   "read_only": 0, 
    "remember_last_selected_value": 0, 
    "report_hide": 0, 
    "reqd": 0, 
@@ -421,7 +421,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
-   "default": "Today", 
+   "default": "", 
    "fieldname": "start_date", 
    "fieldtype": "Date", 
    "hidden": 0, 
@@ -450,7 +450,7 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
-   "default": "Today", 
+   "default": "", 
    "depends_on": "", 
    "fieldname": "end_date", 
    "fieldtype": "Date", 
@@ -1361,7 +1361,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2016-12-08 12:03:31.602913", 
+ "modified": "2016-12-14 12:48:44.038588", 
  "modified_by": "Administrator", 
  "module": "HR", 
  "name": "Salary Slip",