Timesheet web (#10037)

* [new]Timesheet added

* [new] Customer wise timesheet on webportal added
This commit is contained in:
Vishal Dhayagude 2017-07-25 10:53:12 +05:30 committed by Nabin Hait
parent fcaf313c0f
commit edb2749dfd
3 changed files with 43 additions and 4 deletions

View File

@ -109,7 +109,8 @@ website_route_rules = [
}, },
{"from_route": "/jobs", "to_route": "Job Opening"}, {"from_route": "/jobs", "to_route": "Job Opening"},
{"from_route": "/admissions", "to_route": "Student Admission"}, {"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 = [ standard_portal_menu_items = [
@ -122,13 +123,14 @@ standard_portal_menu_items = [
{"title": _("Shipments"), "route": "/shipments", "reference_doctype": "Delivery Note", "role":"Customer"}, {"title": _("Shipments"), "route": "/shipments", "reference_doctype": "Delivery Note", "role":"Customer"},
{"title": _("Issues"), "route": "/issues", "reference_doctype": "Issue", "role":"Customer"}, {"title": _("Issues"), "route": "/issues", "reference_doctype": "Issue", "role":"Customer"},
{"title": _("Addresses"), "route": "/addresses", "reference_doctype": "Address"}, {"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 = [ default_roles = [
{'role': 'Customer', 'doctype':'Contact', 'email_field': 'email_id'}, {'role': 'Customer', 'doctype':'Contact', 'email_field': 'email_id'},
{'role': 'Supplier', '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 = { has_website_permission = {
@ -137,7 +139,8 @@ has_website_permission = {
"Sales Invoice": "erpnext.controllers.website_list_for_contact.has_website_permission", "Sales Invoice": "erpnext.controllers.website_list_for_contact.has_website_permission",
"Supplier Quotation": "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", "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" dump_report_map = "erpnext.startup.report_data_map.data_map"

View File

@ -381,3 +381,26 @@ def get_events(start, end, filters=None):
"end": end "end": end
}, as_dict=True, update={"allDay": 0}) }, 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"
}

View File

@ -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>