[New Script Report] added report daily time log summary

This commit is contained in:
Nabin Hait 2013-04-03 16:09:50 +05:30
parent dd8e964a17
commit 9274f2772c
2 changed files with 13 additions and 25 deletions

View File

@ -1,21 +1,16 @@
wn.query_reports["Daily Time Log Summary"] = { wn.query_reports["Daily Time Log Summary"] = {
"filters": [ "filters": [
{
"fieldname": "employee_name",
"label":"Employee Name",
"fieldtype": "Data",
},
{ {
"fieldname":"from_date", "fieldname":"from_date",
"label": "From Date", "label": "From Date",
"fieldtype": "Date", "fieldtype": "Datetime",
"default": wn.datetime.get_today() "default": wn.datetime.get_today()
}, },
{ {
"fieldname":"to_date", "fieldname":"to_date",
"label": "To Date", "label": "To Date",
"fieldtype": "Date", "fieldtype": "Datetime",
"default": wn.datetime.get_today() "default": wn.datetime.get_today()
} },
] ]
} }

View File

@ -3,28 +3,26 @@ import webnotes
def execute(filters=None): def execute(filters=None):
if not filters: filters = {} if not filters: filters = {}
columns = ["Employee::150", "From Time::120", "To Time::120", "Hours::70", "Task::150", columns = ["Employee::150", "From Datetime::120", "To Datetime::120", "Hours::70", "Task::150",
"Project:Link/Project:120", "Status::70"] "Project:Link/Project:120", "Status::70"]
profile_map = get_profile_map() profile_map = get_profile_map()
if filters.get("employee_name"):
filters["employee_name"] = "%" + filters.get("employee_name") + "%"
conditions = build_conditions(filters) conditions = build_conditions(filters)
time_logs = webnotes.conn.sql("""select * from `tabTime Log` time_logs = webnotes.conn.sql("""select * from `tabTime Log`
where docstatus < 2 %s order by owner asc""" % (conditions,), filters, as_dict=1) where docstatus < 2 %s order by owner asc""" % (conditions,), filters, as_dict=1)
data = [] data = []
profiles = [] profiles = [time_logs[0].owner]
for tl in time_logs: for tl in time_logs:
employee_name = profile_map[tl.owner]
if employee_name not in profiles:
data.append(employee_name)
profiles.append(employee_name)
data.append(["", tl.from_time, tl.to_time, tl.hours, tl.task, tl.project, tl.status]) if tl.owner not in profiles:
profiles.append(tl.owner)
data.append([])
data.append([profile_map[tl.owner], tl.from_time, tl.to_time, tl.hours,
tl.task, tl.project, tl.status])
return columns, data return columns, data
@ -40,11 +38,6 @@ def get_profile_map():
def build_conditions(filters): def build_conditions(filters):
conditions = "" conditions = ""
if filters.get("employee_name"):
conditions += """ and owner in (select name from `tabProfile`
where concat(first_name, if(last_name, (' ' + last_name), ''))
like %(employee_name)s)"""
if filters.get("from_date"): if filters.get("from_date"):
conditions += " and from_time >= %(from_date)s" conditions += " and from_time >= %(from_date)s"
if filters.get("to_date"): if filters.get("to_date"):