diff --git a/patches/patch_list.py b/patches/patch_list.py index 28d735c43d..0b7092c76d 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -234,5 +234,6 @@ patch_list = [ 'execute:webnotes.reload_doc("selling", "Print Format", "Quotation Classic") # 2013-04-02', 'execute:webnotes.reload_doc("selling", "Print Format", "Quotation Modern") # 2013-04-02', 'execute:webnotes.reload_doc("selling", "Print Format", "Quotation Spartan") # 2013-04-02', + "execute:webnotes.delete_doc('Search Criteria', 'time_log_summary')" ] \ No newline at end of file diff --git a/projects/page/projects_home/projects_home.js b/projects/page/projects_home/projects_home.js index d9476e93f0..0e7ccff89e 100644 --- a/projects/page/projects_home/projects_home.js +++ b/projects/page/projects_home/projects_home.js @@ -62,8 +62,8 @@ wn.module_page["Projects"] = [ icon: "icon-list", items: [ { - "label":wn._("Time Log Summary"), - route: "Report2/Time Log/Time Log Summary", + "label":wn._("Daily Time Log Summary"), + route: "query-report/Daily Time Log Summary", doctype: "Time Log" }, ] diff --git a/projects/report/time_log_summary/__init__.py b/projects/report/daily_time_log_summary/__init__.py similarity index 100% rename from projects/report/time_log_summary/__init__.py rename to projects/report/daily_time_log_summary/__init__.py diff --git a/projects/report/daily_time_log_summary/daily_time_log_summary.js b/projects/report/daily_time_log_summary/daily_time_log_summary.js new file mode 100644 index 0000000000..7eb3acb0a8 --- /dev/null +++ b/projects/report/daily_time_log_summary/daily_time_log_summary.js @@ -0,0 +1,21 @@ +wn.query_reports["Daily Time Log Summary"] = { + "filters": [ + { + "fieldname": "employee_name", + "label":"Employee Name", + "fieldtype": "Data", + }, + { + "fieldname":"from_date", + "label": "From Date", + "fieldtype": "Date", + "default": wn.datetime.get_today() + }, + { + "fieldname":"to_date", + "label": "To Date", + "fieldtype": "Date", + "default": wn.datetime.get_today() + } + ] +} \ No newline at end of file diff --git a/projects/report/daily_time_log_summary/daily_time_log_summary.py b/projects/report/daily_time_log_summary/daily_time_log_summary.py new file mode 100644 index 0000000000..ac51ebf9ed --- /dev/null +++ b/projects/report/daily_time_log_summary/daily_time_log_summary.py @@ -0,0 +1,53 @@ +from __future__ import unicode_literals +import webnotes + +def execute(filters=None): + if not filters: filters = {} + columns = ["Profile:Link:150", "From Time::120", "To Time::120", "Hours::70", "Task::150", + "Project:Link/Project:100", "Status::70"] + + profile_map = get_profile_map() + + if filters.get("employee_name"): + filters["employee_name"] = "%" + filters.get("employee_name") + "%" + + conditions = build_conditions(filters) + time_logs = webnotes.conn.sql("""select * from `tabTime Log` + where docstatus < 2 %s order by owner asc""" % (conditions,), filters, as_dict=1) + + data = [] + profiles = [] + + 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]) + + return columns, data + +def get_profile_map(): + profiles = webnotes.conn.sql("""select name, + concat(first_name, if(last_name, (' ' + last_name), '')) as fullname + from tabProfile""", as_dict=1) + profile_map = {} + for p in profiles: + profile_map.setdefault(p.name, []).append(p.fullname) + + return profile_map + +def build_conditions(filters): + 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"): + conditions += " and from_time >= %(from_date)s" + if filters.get("to_date"): + conditions += " and to_time <= %(to_date)s" + + return conditions \ No newline at end of file diff --git a/projects/report/daily_time_log_summary/daily_time_log_summary.txt b/projects/report/daily_time_log_summary/daily_time_log_summary.txt new file mode 100644 index 0000000000..5bf3e6d57e --- /dev/null +++ b/projects/report/daily_time_log_summary/daily_time_log_summary.txt @@ -0,0 +1,21 @@ +[ + { + "creation": "2013-04-03 11:27:52", + "docstatus": 0, + "modified": "2013-04-03 11:48:07", + "modified_by": "Administrator", + "owner": "Administrator" + }, + { + "doctype": "Report", + "is_standard": "Yes", + "name": "__common__", + "ref_doctype": "Time Log", + "report_name": "Daily Time Log Summary", + "report_type": "Script Report" + }, + { + "doctype": "Report", + "name": "Daily Time Log Summary" + } +] \ No newline at end of file diff --git a/projects/report/time_log_summary/time_log_summary.txt b/projects/report/time_log_summary/time_log_summary.txt deleted file mode 100644 index 3925a2dd80..0000000000 --- a/projects/report/time_log_summary/time_log_summary.txt +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "creation": "2013-03-01 17:36:35", - "docstatus": 0, - "modified": "2013-03-01 18:17:13", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Report", - "is_standard": "Yes", - "json": "{\"filters\":[],\"columns\":[[\"name\",\"Time Log\"],[\"status\",\"Time Log\"],[\"from_time\",\"Time Log\"],[\"hours\",\"Time Log\"],[\"activity_type\",\"Time Log\"],[\"owner\",\"Time Log\"],[\"billable\",\"Time Log\"],[\"time_log_batch\",\"Time Log\"],[\"sales_invoice\",\"Time Log\"]],\"sort_by\":\"Time Log.name\",\"sort_order\":\"desc\",\"sort_by_next\":\"\",\"sort_order_next\":\"desc\"}", - "name": "__common__", - "ref_doctype": "Time Log", - "report_name": "Time Log Summary", - "report_type": "Report Builder" - }, - { - "doctype": "Report", - "name": "Time Log Summary" - } -] \ No newline at end of file