diff --git a/erpnext/docs/assets/img/support/support_hours.png b/erpnext/docs/assets/img/support/support_hours.png index 44cfbbbdaa..f2603669f9 100644 Binary files a/erpnext/docs/assets/img/support/support_hours.png and b/erpnext/docs/assets/img/support/support_hours.png differ diff --git a/erpnext/patches.txt b/erpnext/patches.txt index f8267df631..16c5a8713e 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -416,5 +416,6 @@ erpnext.patches.v8_0.update_production_orders erpnext.patches.v8_1.remove_sales_invoice_from_returned_serial_no erpnext.patches.v8_1.allow_invoice_copy_to_edit_after_submit erpnext.patches.v8_1.add_hsn_sac_codes -erpnext.patches.v8_1.update_gst_state +erpnext.patches.v8_1.update_gst_state #17-07-2017 +erpnext.patches.v8_1.removed_report_support_hours erpnext.patches.v8_1.add_indexes_in_transaction_doctypes \ No newline at end of file diff --git a/erpnext/patches/v8_1/removed_report_support_hours.py b/erpnext/patches/v8_1/removed_report_support_hours.py new file mode 100644 index 0000000000..0936b2231b --- /dev/null +++ b/erpnext/patches/v8_1/removed_report_support_hours.py @@ -0,0 +1,14 @@ +# Copyright (c) 2017, Frappe and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import frappe + +def execute(): + frappe.db.sql(""" update `tabAuto Email Report` set report = %s + where name = %s""", ('Support Hour Distribution', 'Support Hours')) + + frappe.db.sql(""" update `tabCustom Role` set report = %s + where report = %s""", ('Support Hour Distribution', 'Support Hours')) + + frappe.delete_doc('Report', 'Support Hours') \ No newline at end of file diff --git a/erpnext/support/report/support_hours/__init__.py b/erpnext/support/report/support_hour_distribution/__init__.py similarity index 100% rename from erpnext/support/report/support_hours/__init__.py rename to erpnext/support/report/support_hour_distribution/__init__.py diff --git a/erpnext/support/report/support_hour_distribution/support_hour_distribution.js b/erpnext/support/report/support_hour_distribution/support_hour_distribution.js new file mode 100644 index 0000000000..ae30b6a550 --- /dev/null +++ b/erpnext/support/report/support_hour_distribution/support_hour_distribution.js @@ -0,0 +1,22 @@ +// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors +// For license information, please see license.txt +/* eslint-disable */ + +frappe.query_reports["Support Hour Distribution"] = { + "filters": [ + { + 'lable': __("From Date"), + 'fieldname': 'from_date', + 'fieldtype': 'Date', + 'default': frappe.datetime.nowdate(), + 'reqd': 1 + }, + { + 'lable': __("To Date"), + 'fieldname': 'to_date', + 'fieldtype': 'Date', + 'default': frappe.datetime.nowdate(), + 'reqd': 1 + } + ] +} diff --git a/erpnext/support/report/support_hours/support_hours.json b/erpnext/support/report/support_hour_distribution/support_hour_distribution.json similarity index 69% rename from erpnext/support/report/support_hours/support_hours.json rename to erpnext/support/report/support_hour_distribution/support_hour_distribution.json index 01e4bb44cb..4d0cb865e3 100644 --- a/erpnext/support/report/support_hours/support_hours.json +++ b/erpnext/support/report/support_hour_distribution/support_hour_distribution.json @@ -1,20 +1,20 @@ { "add_total_row": 0, "apply_user_permissions": 1, - "creation": "2017-06-23 14:21:37.558691", + "creation": "2017-07-13 17:14:40.408706", "disabled": 0, "docstatus": 0, "doctype": "Report", "idx": 0, "is_standard": "Yes", "letter_head": "", - "modified": "2017-06-23 16:33:31.211390", + "modified": "2017-07-13 17:14:40.408706", "modified_by": "Administrator", "module": "Support", - "name": "Support Hours", + "name": "Support Hour Distribution", "owner": "Administrator", "ref_doctype": "Issue", - "report_name": "Support Hours", + "report_name": "Support Hour Distribution", "report_type": "Script Report", "roles": [ { diff --git a/erpnext/support/report/support_hours/support_hours.py b/erpnext/support/report/support_hour_distribution/support_hour_distribution.py similarity index 70% rename from erpnext/support/report/support_hours/support_hours.py rename to erpnext/support/report/support_hour_distribution/support_hour_distribution.py index f1606cd646..e96b7b2104 100644 --- a/erpnext/support/report/support_hours/support_hours.py +++ b/erpnext/support/report/support_hour_distribution/support_hour_distribution.py @@ -23,12 +23,14 @@ def execute(filters=None): filters['periodicity'] = 'Daily' columns = get_columns() - data = get_data(filters) - return columns, data + data, timeslot_wise_count = get_data(filters) + chart = get_chartdata(timeslot_wise_count) + return columns, data, None, chart def get_data(filters): start_date = getdate(filters.from_date) data = [] + time_slot_wise_total_count = {} while(start_date <= getdate(filters.to_date)): hours_count = {'date': start_date} for key, value in time_slots.items(): @@ -36,13 +38,14 @@ def get_data(filters): start_time = get_datetime("{0} {1}".format(start_date.strftime("%Y-%m-%d"), start_time)) end_time = get_datetime("{0} {1}".format(start_date.strftime("%Y-%m-%d"), end_time)) hours_count[key] = get_hours_count(start_time, end_time) + time_slot_wise_total_count[key] = time_slot_wise_total_count.get(key, 0) + hours_count[key] if hours_count: data.append(hours_count) start_date = add_to_date(start_date, days=1) - return data + return data, time_slot_wise_total_count def get_hours_count(start_time, end_time): data = frappe.db.sql(""" select count(*) from `tabIssue` where creation @@ -70,4 +73,25 @@ def get_columns(): "width": 120 }) - return columns \ No newline at end of file + return columns + +def get_chartdata(timeslot_wise_count): + x_interval = ['x'] + total_count = ['Total'] + timeslots = ['12AM - 3AM', '3AM - 6AM', '6AM - 9AM', + '9AM - 12PM', '12PM - 3PM', '3PM - 6PM', '6PM - 9PM', '9PM - 12AM'] + + x_interval.extend(timeslots) + columns = [x_interval] + for data in timeslots: + total_count.append(timeslot_wise_count.get(data, 0)) + columns.append(total_count) + + chart = { + "data": { + 'x': 'x', + 'columns': columns + } + } + chart["chart_type"] = "line" + return chart diff --git a/erpnext/support/report/support_hours/support_hours.js b/erpnext/support/report/support_hours/support_hours.js deleted file mode 100644 index 439b7678ee..0000000000 --- a/erpnext/support/report/support_hours/support_hours.js +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors -// For license information, please see license.txt -/* eslint-disable */ - -frappe.query_reports["Support Hours"] = { - "filters": [ - { - 'lable': __("From Date"), - 'fieldname': 'from_date', - 'fieldtype': 'Date', - 'default': frappe.datetime.nowdate(), - 'reqd': 1 - }, - { - 'lable': __("To Date"), - 'fieldname': 'to_date', - 'fieldtype': 'Date', - 'default': frappe.datetime.nowdate(), - 'reqd': 1 - } - ], - get_chart_data: function(columns, result) { - return { - data: { - x: 'Date', - columns: [ - ['Date'].concat($.map(result, function(d) { return d.date; })), - [columns[3].label].concat($.map(result, function(d) { return d[columns[3].label]; })), - [columns[4].label].concat($.map(result, function(d) { return d[columns[4].label]; })), - [columns[5].label].concat($.map(result, function(d) { return d[columns[5].label]; })), - [columns[6].label].concat($.map(result, function(d) { return d[columns[6].label]; })), - [columns[7].label].concat($.map(result, function(d) { return d[columns[7].label]; })) - ] - }, - chart_type: 'bar', - - } - } -}