[design] Fixed Grid Reports

This commit is contained in:
Anand Doshi 2015-01-01 16:25:43 +05:30
parent 90e270a8aa
commit 3f5e95a99e
8 changed files with 68 additions and 90 deletions

View File

@ -9,7 +9,7 @@ frappe.pages['financial-analytics'].onload = function(wrapper) {
title: __('Financial Analytics'),
single_column: true
});
erpnext.trial_balance = new erpnext.FinancialAnalytics(wrapper, 'Financial Analytics');
erpnext.financial_analytics = new erpnext.FinancialAnalytics(wrapper, 'Financial Analytics');
frappe.add_breadcrumbs("Accounts")
}
@ -41,14 +41,11 @@ erpnext.FinancialAnalytics = erpnext.AccountTreeGrid.extend({
{fieldtype:"Select", label: __("Fiscal Year"), link:"Fiscal Year", fieldname: "fiscal_year",
default_value: __("Select Fiscal Year...")},
{fieldtype:"Date", label: __("From Date"), fieldname: "from_date"},
{fieldtype:"Label", label: __("To")},
{fieldtype:"Date", label: __("To Date"), fieldname: "to_date"},
{fieldtype:"Select", label: __("Range"), fieldname: "range",
options:[{label: __("Daily"), value: "Daily"}, {label: __("Weekly"), value: "Weekly"},
{label: __("Monthly"), value: "Monthly"}, {label: __("Quarterly"), value: "Quarterly"},
{label: __("Yearly"), value: "Yearly"}]},
{fieldtype:"Button", label: __("Refresh"), icon:"icon-refresh icon-white"},
{fieldtype:"Button", label: __("Reset Filters"), icon: "icon-filter"}
{label: __("Yearly"), value: "Yearly"}]}
],
setup_columns: function() {
var std_columns = [

View File

@ -98,14 +98,11 @@ erpnext.PurchaseAnalytics = frappe.views.TreeGridReport.extend({
{fieldtype:"Select", label: __("Company"), link:"Company", fieldname: "company",
default_value: __("Select Company...")},
{fieldtype:"Date", label: __("From Date"), fieldname: "from_date"},
{fieldtype:"Label", label: __("To")},
{fieldtype:"Date", label: __("To Date"), fieldname: "to_date"},
{fieldtype:"Select", label: __("Range"), fieldname: "range",
options:[{label: __("Daily"), value: "Daily"}, {label: __("Weekly"), value: "Weekly"},
{label: __("Monthly"), value: "Monthly"}, {label: __("Quarterly"), value: "Quarterly"},
{label: __("Yearly"), value: "Yearly"}]},
{fieldtype:"Button", label: __("Refresh"), icon:"icon-refresh icon-white"},
{fieldtype:"Button", label: __("Reset Filters"), icon: "icon-filter"}
{label: __("Yearly"), value: "Yearly"}]}
],
setup_filters: function() {
var me = this;

View File

@ -67,10 +67,7 @@ erpnext.AccountTreeGrid = frappe.views.TreeGridReport.extend({
default_value: __("Select Fiscal Year...")},
{fieldtype: "Date", label: __("From Date"), fieldname: "from_date"},
{fieldtype: "Label", label: __("To")},
{fieldtype: "Date", label: __("To Date"), fieldname: "to_date"},
{fieldtype: "Button", label: __("Refresh"), icon:"icon-refresh icon-white",
cssClass:"btn-primary"},
{fieldtype: "Button", label: __("Reset Filters"), icon: "icon-filter"},
{fieldtype: "Date", label: __("To Date"), fieldname: "to_date"}
],
setup_filters: function() {
this._super();

View File

@ -62,12 +62,9 @@ erpnext.StockAnalytics = erpnext.StockGridReport.extend({
{fieldtype:"Select", label: __("Warehouse"), link:"Warehouse", fieldname: "warehouse",
default_value: __("Select Warehouse...")},
{fieldtype:"Date", label: __("From Date"), fieldname: "from_date"},
{fieldtype:"Label", label: __("To")},
{fieldtype:"Date", label: __("To Date"), fieldname: "to_date"},
{fieldtype:"Select", label: __("Range"), fieldname: "range",
options:["Daily", "Weekly", "Monthly", "Quarterly", "Yearly"]},
{fieldtype:"Button", label: __("Refresh"), icon:"icon-refresh icon-white"},
{fieldtype:"Button", label: __("Reset Filters"), icon: "icon-filter"}
options:["Daily", "Weekly", "Monthly", "Quarterly", "Yearly"]}
],
setup_filters: function() {
var me = this;

View File

@ -105,9 +105,7 @@ erpnext.SalesAnalytics = frappe.views.TreeGridReport.extend({
{fieldtype:"Select", label: __("Range"), fieldname: "range",
options:[{label: __("Daily"), value: "Daily"}, {label: __("Weekly"), value: "Weekly"},
{label: __("Monthly"), value: "Monthly"}, {label: __("Quarterly"), value: "Quarterly"},
{label: __("Yearly"), value: "Yearly"}]},
{fieldtype:"Button", fieldname: "refresh", label: __("Refresh"), icon:"icon-refresh"},
{fieldtype:"Button", fieldname: "reset_filters", label: __("Reset Filters"), icon:"icon-filter"}
{label: __("Yearly"), value: "Yearly"}]}
],
setup_filters: function() {
var me = this;

View File

@ -80,12 +80,9 @@ erpnext.StockLedger = erpnext.StockGridReport.extend({
{fieldtype:"Date", label: __("From Date"), filter: function(val, item) {
return dateutil.str_to_obj(val) <= dateutil.str_to_obj(item.posting_date);
}},
{fieldtype:"Label", label: __("To")},
{fieldtype:"Date", label: __("To Date"), filter: function(val, item) {
return dateutil.str_to_obj(val) >= dateutil.str_to_obj(item.posting_date);
}},
{fieldtype:"Button", label: __("Refresh"), icon:"icon-refresh icon-white"},
{fieldtype:"Button", label: __("Reset Filters"), icon: "icon-filter"}
}}
],
setup_filters: function() {

View File

@ -1,13 +1,13 @@
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
frappe.pages['stock-level'].onload = function(wrapper) {
frappe.pages['stock-level'].onload = function(wrapper) {
frappe.ui.make_app_page({
parent: wrapper,
title: __('Stock Level'),
single_column: true
});
new erpnext.StockLevel(wrapper);
@ -20,16 +20,16 @@ frappe.require("assets/erpnext/js/stock_grid_report.js");
erpnext.StockLevel = erpnext.StockGridReport.extend({
init: function(wrapper) {
var me = this;
this._super({
title: __("Stock Level"),
page: wrapper,
parent: $(wrapper).find('.layout-main'),
page: wrapper.page,
doctypes: ["Item", "Warehouse", "Stock Ledger Entry", "Production Order",
doctypes: ["Item", "Warehouse", "Stock Ledger Entry", "Production Order",
"Material Request Item", "Purchase Order Item", "Sales Order Item", "Brand", "Serial No"],
});
this.wrapper.bind("make", function() {
frappe.utils.set_footnote(me, me.wrapper.get(0),
"<ul> \
@ -46,10 +46,10 @@ erpnext.StockLevel = erpnext.StockGridReport.extend({
</ul>");
});
},
setup_columns: function() {
this.columns = [
{id: "item_code", name: __("Item Code"), field: "item_code", width: 160,
{id: "item_code", name: __("Item Code"), field: "item_code", width: 160,
link_formatter: {
filter_input: "item_code",
open_btn: true,
@ -57,61 +57,59 @@ erpnext.StockLevel = erpnext.StockGridReport.extend({
}},
{id: "item_name", name: __("Item Name"), field: "item_name", width: 100,
formatter: this.text_formatter},
{id: "description", name: __("Description"), field: "description", width: 200,
{id: "description", name: __("Description"), field: "description", width: 200,
formatter: this.text_formatter},
{id: "brand", name: __("Brand"), field: "brand", width: 100,
link_formatter: {filter_input: "brand"}},
{id: "warehouse", name: __("Warehouse"), field: "warehouse", width: 100,
link_formatter: {filter_input: "warehouse"}},
{id: "uom", name: __("UOM"), field: "uom", width: 60},
{id: "actual_qty", name: __("Actual Qty"),
{id: "actual_qty", name: __("Actual Qty"),
field: "actual_qty", width: 80, formatter: this.currency_formatter},
{id: "planned_qty", name: __("Planned Qty"),
{id: "planned_qty", name: __("Planned Qty"),
field: "planned_qty", width: 80, formatter: this.currency_formatter},
{id: "requested_qty", name: __("Requested Qty"),
{id: "requested_qty", name: __("Requested Qty"),
field: "requested_qty", width: 80, formatter: this.currency_formatter},
{id: "ordered_qty", name: __("Ordered Qty"),
{id: "ordered_qty", name: __("Ordered Qty"),
field: "ordered_qty", width: 80, formatter: this.currency_formatter},
{id: "reserved_qty", name: __("Reserved Qty"),
{id: "reserved_qty", name: __("Reserved Qty"),
field: "reserved_qty", width: 80, formatter: this.currency_formatter},
{id: "projected_qty", name: __("Projected Qty"),
{id: "projected_qty", name: __("Projected Qty"),
field: "projected_qty", width: 80, formatter: this.currency_formatter},
{id: "re_order_level", name: __("Re-Order Level"),
{id: "re_order_level", name: __("Re-Order Level"),
field: "re_order_level", width: 80, formatter: this.currency_formatter},
{id: "re_order_qty", name: __("Re-Order Qty"),
{id: "re_order_qty", name: __("Re-Order Qty"),
field: "re_order_qty", width: 80, formatter: this.currency_formatter},
];
},
filters: [
{fieldtype:"Link", label: __("Item Code"), link:"Item", default_value: "Select Item...",
filter: function(val, item, opts) {
return item.item_code == val || !val;
}},
{fieldtype:"Select", label: __("Warehouse"), link:"Warehouse",
{fieldtype:"Select", label: __("Warehouse"), link:"Warehouse",
default_value: "Select Warehouse...", filter: function(val, item, opts) {
return item.warehouse == val || val == opts.default_value;
}},
{fieldtype:"Select", label: __("Brand"), link:"Brand",
{fieldtype:"Select", label: __("Brand"), link:"Brand",
default_value: "Select Brand...", filter: function(val, item, opts) {
return val == opts.default_value || item.brand == val;
}},
{fieldtype:"Button", label: __("Refresh"), icon:"icon-refresh icon-white"},
{fieldtype:"Button", label: __("Reset Filters"), icon: "icon-filter"}
}}
],
setup_filters: function() {
var me = this;
this._super();
this.wrapper.bind("apply_filters_from_route", function() { me.toggle_enable_brand(); });
this.filter_inputs.item_code.change(function() { me.toggle_enable_brand(); });
this.trigger_refresh_on_change(["item_code", "warehouse", "brand"]);
},
toggle_enable_brand: function() {
if(!this.filter_inputs.item_code.val()) {
this.filter_inputs.brand.prop("disabled", false);
@ -121,12 +119,12 @@ erpnext.StockLevel = erpnext.StockGridReport.extend({
.prop("disabled", true);
}
},
init_filter_values: function() {
this._super();
this.filter_inputs.warehouse.get(0).selectedIndex = 0;
},
prepare_data: function() {
var me = this;
@ -136,7 +134,7 @@ erpnext.StockLevel = erpnext.StockGridReport.extend({
this.item_by_name = this.make_name_map(frappe.report_dump.data["Item"]);
this.calculate_quantities();
}
this.data = [].concat(this._data);
this.data = $.map(this.data, function(d) {
return me.apply_filters(d) ? d : null;
@ -144,15 +142,15 @@ erpnext.StockLevel = erpnext.StockGridReport.extend({
this.calculate_total();
},
calculate_quantities: function() {
var me = this;
$.each([
["Stock Ledger Entry", "actual_qty"],
["Production Order", "planned_qty"],
["Stock Ledger Entry", "actual_qty"],
["Production Order", "planned_qty"],
["Material Request Item", "requested_qty"],
["Purchase Order Item", "ordered_qty"],
["Sales Order Item", "reserved_qty"]],
["Sales Order Item", "reserved_qty"]],
function(i, v) {
$.each(frappe.report_dump.data[v[0]], function(i, item) {
var row = me.get_row(item.item_code, item.warehouse);
@ -160,7 +158,7 @@ erpnext.StockLevel = erpnext.StockGridReport.extend({
});
}
);
// sort by item, warehouse
this._data = $.map(Object.keys(this.item_warehouse_map).sort(), function(key) {
return me.item_warehouse_map[key];
@ -192,15 +190,15 @@ erpnext.StockLevel = erpnext.StockGridReport.extend({
id: key,
}
this.reset_item_values(row);
row["re_order_level"] = item.re_order_level
row["re_order_qty"] = item.re_order_qty
this.item_warehouse_map[key] = row;
}
return this.item_warehouse_map[key];
},
calculate_total: function() {
var me = this;
// show total if a specific item is selected and warehouse is not filtered
@ -212,7 +210,7 @@ erpnext.StockLevel = erpnext.StockGridReport.extend({
_show: true
};
this.reset_item_values(total);
$.each(this.data, function(i, row) {
$.each(me.columns, function(i, col) {
if (col.formatter==me.currency_formatter) {
@ -220,7 +218,7 @@ erpnext.StockLevel = erpnext.StockGridReport.extend({
}
});
});
this.data = this.data.concat([total]);
}
}

View File

@ -1,18 +1,18 @@
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
frappe.pages['support-analytics'].onload = function(wrapper) {
frappe.pages['support-analytics'].onload = function(wrapper) {
frappe.ui.make_app_page({
parent: wrapper,
title: __('Support Analytics'),
single_column: true
});
});
new erpnext.SupportAnalytics(wrapper);
frappe.add_breadcrumbs("Support")
}
erpnext.SupportAnalytics = frappe.views.GridReportWithPlot.extend({
@ -25,17 +25,14 @@ erpnext.SupportAnalytics = frappe.views.GridReportWithPlot.extend({
doctypes: ["Issue", "Fiscal Year"],
});
},
filters: [
{fieldtype:"Select", label: __("Fiscal Year"), link:"Fiscal Year",
{fieldtype:"Select", label: __("Fiscal Year"), link:"Fiscal Year",
default_value: __("Select Fiscal Year") + "..."},
{fieldtype:"Date", label: __("From Date")},
{fieldtype:"Label", label: __("To")},
{fieldtype:"Date", label: __("To Date")},
{fieldtype:"Select", label: __("Range"),
options:["Daily", "Weekly", "Monthly", "Quarterly", "Yearly"]},
{fieldtype:"Button", label: __("Refresh"), icon:"icon-refresh icon-white"},
{fieldtype:"Button", label: __("Reset Filters"), icon: "icon-filter"}
{fieldtype:"Select", label: __("Range"),
options:["Daily", "Weekly", "Monthly", "Quarterly", "Yearly"]}
],
setup_columns: function() {
@ -44,10 +41,10 @@ erpnext.SupportAnalytics = frappe.views.GridReportWithPlot.extend({
formatter: this.check_formatter},
{id: "status", name: __("Status"), field: "status", width: 100},
];
this.make_date_range_columns();
this.make_date_range_columns();
this.columns = std_columns.concat(this.columns);
},
prepare_data: function() {
// add Opening, Closing, Totals rows
// if filtered by account and / or voucher
@ -57,13 +54,13 @@ erpnext.SupportAnalytics = frappe.views.GridReportWithPlot.extend({
var days_to_close = {status:"Days to Close", "id":"days-to-close",
checked:false};
var total_closed = {};
var hours_to_close = {status:"Hours to Close", "id":"hours-to-close",
var hours_to_close = {status:"Hours to Close", "id":"hours-to-close",
checked:false};
var hours_to_respond = {status:"Hours to Respond", "id":"hours-to-respond",
var hours_to_respond = {status:"Hours to Respond", "id":"hours-to-respond",
checked:false};
var total_responded = {};
$.each(frappe.report_dump.data["Issue"], function(i, d) {
var dateobj = dateutil.str_to_obj(d.creation);
var date = d.creation.split(" ")[0];
@ -76,20 +73,20 @@ erpnext.SupportAnalytics = frappe.views.GridReportWithPlot.extend({
days_to_close[col.field] = flt(days_to_close[col.field])
+ dateutil.get_diff(d.resolution_date, d.creation);
hours_to_close[col.field] = flt(hours_to_close[col.field])
+ dateutil.get_hour_diff(d.resolution_date, d.creation);
}
}
if (d.first_responded_on) {
total_responded[col.field] = flt(total_responded[col.field]) + 1;
hours_to_respond[col.field] = flt(hours_to_respond[col.field])
+ dateutil.get_hour_diff(d.first_responded_on, d.creation);
}
}
});
// make averages
$.each(this.columns, function(i, col) {
if(col.formatter==me.currency_formatter && total_tickets[col.field]) {
@ -97,17 +94,17 @@ erpnext.SupportAnalytics = frappe.views.GridReportWithPlot.extend({
flt(total_closed[col.field]);
hours_to_close[col.field] = flt(hours_to_close[col.field]) /
flt(total_closed[col.field]);
hours_to_respond[col.field] = flt(hours_to_respond[col.field]) /
hours_to_respond[col.field] = flt(hours_to_respond[col.field]) /
flt(total_responded[col.field]);
}
})
this.data = [total_tickets, days_to_close, hours_to_close, hours_to_respond];
},
get_plot_points: function(item, col, idx) {
return [[dateutil.str_to_obj(col.id).getTime(), item[col.field]],
return [[dateutil.str_to_obj(col.id).getTime(), item[col.field]],
[dateutil.user_to_obj(col.name).getTime(), item[col.field]]];
}
});
});