Timesheet web (#10037)
* [new]Timesheet added
* [new] Customer wise timesheet on webportal added
diff --git a/erpnext/hooks.py b/erpnext/hooks.py
index 860aac2..37fd869 100644
--- a/erpnext/hooks.py
+++ b/erpnext/hooks.py
@@ -109,7 +109,8 @@
},
{"from_route": "/jobs", "to_route": "Job Opening"},
{"from_route": "/admissions", "to_route": "Student Admission"},
- {"from_route": "/boms", "to_route": "BOM"}
+ {"from_route": "/boms", "to_route": "BOM"},
+ {"from_route": "/timesheets", "to_route": "Timesheet"},
]
standard_portal_menu_items = [
@@ -122,13 +123,14 @@
{"title": _("Shipments"), "route": "/shipments", "reference_doctype": "Delivery Note", "role":"Customer"},
{"title": _("Issues"), "route": "/issues", "reference_doctype": "Issue", "role":"Customer"},
{"title": _("Addresses"), "route": "/addresses", "reference_doctype": "Address"},
- {"title": _("Fees"), "route": "/fees", "reference_doctype": "Fees", "role":"Student"}
+ {"title": _("Fees"), "route": "/fees", "reference_doctype": "Fees", "role":"Student"},
+ {"title": _("Timesheets"), "route": "/timesheets", "reference_doctype": "Timesheet", "role":"Customer"}
]
default_roles = [
{'role': 'Customer', 'doctype':'Contact', 'email_field': 'email_id'},
{'role': 'Supplier', 'doctype':'Contact', 'email_field': 'email_id'},
- {'role': 'Student', 'doctype':'Student', 'email_field': 'student_email_id'}
+ {'role': 'Student', 'doctype':'Student', 'email_field': 'student_email_id'},
]
has_website_permission = {
@@ -137,7 +139,8 @@
"Sales Invoice": "erpnext.controllers.website_list_for_contact.has_website_permission",
"Supplier Quotation": "erpnext.controllers.website_list_for_contact.has_website_permission",
"Delivery Note": "erpnext.controllers.website_list_for_contact.has_website_permission",
- "Issue": "erpnext.support.doctype.issue.issue.has_website_permission"
+ "Issue": "erpnext.support.doctype.issue.issue.has_website_permission",
+ "Timesheet": "erpnext.controllers.website_list_for_contact.has_website_permission"
}
dump_report_map = "erpnext.startup.report_data_map.data_map"
diff --git a/erpnext/projects/doctype/timesheet/timesheet.py b/erpnext/projects/doctype/timesheet/timesheet.py
index 6416176..95fd420 100644
--- a/erpnext/projects/doctype/timesheet/timesheet.py
+++ b/erpnext/projects/doctype/timesheet/timesheet.py
@@ -381,3 +381,26 @@
"end": end
}, as_dict=True, update={"allDay": 0})
+def get_timesheets_list(doctype, txt, filters, limit_start, limit_page_length=20, order_by="modified"):
+ user = frappe.session.user
+ # find customer name from contact.
+ customer = frappe.db.sql('''SELECT dl.link_name FROM `tabContact` AS c inner join \
+ `tabDynamic Link` AS dl ON c.first_name=dl.link_name WHERE c.email_id=%s''',user)
+ # find list of Sales Invoice for made for customer.
+ sales_invoice = frappe.db.sql('''SELECT name FROM `tabSales Invoice` WHERE customer = %s''',customer)
+ if customer:
+ # Return timesheet related data to web portal.
+ return frappe. db.sql('''SELECT ts.name, tsd.activity_type, ts.status, ts.total_billable_hours, \
+ tsd.sales_invoice, tsd.project FROM `tabTimesheet` AS ts inner join `tabTimesheet Detail` \
+ AS tsd ON tsd.parent = ts.name where tsd.sales_invoice IN %s order by\
+ end_date asc limit {0} , {1}'''.format(limit_start, limit_page_length), [sales_invoice], as_dict = True)
+
+def get_list_context(context=None):
+ return {
+ "show_sidebar": True,
+ "show_search": True,
+ 'no_breadcrumbs': True,
+ "title": _("Timesheets"),
+ "get_list": get_timesheets_list,
+ "row_template": "templates/includes/timesheet/timesheet_row.html"
+ }
diff --git a/erpnext/templates/includes/timesheet/timesheet_row.html b/erpnext/templates/includes/timesheet/timesheet_row.html
new file mode 100644
index 0000000..e9cfcda
--- /dev/null
+++ b/erpnext/templates/includes/timesheet/timesheet_row.html
@@ -0,0 +1,13 @@
+<div class="web-list-item">
+ <a href="/timesheets?name={{ doc.name | urlencode }}" class="no-decoration">
+ <div class="row">
+ <div class="col-xs-3">
+ <span class="indicator {{ "red" if doc.status=="Cancelled" else "green" if doc.status=="Billed" else "blue" if doc.status=="Submitted" else "darkgrey" }}">{{ doc.name }}</span>
+ </div>
+ <div class="col-xs-3"> Billable Hours: {{ doc.total_billable_hours}} </div>
+ <div class="col-xs-2"> {{ _(doc.sales_invoice) }} </div>
+ <div class="col-xs-2"> {{ _(doc.project) }} </div>
+ <div class="col-xs-2"> {{ _(doc.activity_type) }} </div>
+ </div>
+ </a>
+</div>