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

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