Renamed the report Support Hours to Support Hours Distribution (#9874)

This commit is contained in:
rohitwaghchaure 2017-07-17 14:55:42 +05:30 committed by Makarand Bauskar
parent b994b3dcda
commit ea4497c8d2
8 changed files with 70 additions and 48 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 38 KiB

View File

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

View File

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

View File

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

View File

@ -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": [
{

View File

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

View File

@ -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',
}
}
}