frappe.pages["leaderboard"].on_page_load = function (wrapper) { frappe.leaderboard = new frappe.Leaderboard(wrapper); } frappe.Leaderboard = Class.extend({ init: function (parent) { frappe.ui.make_app_page({ parent: parent, title: "Leaderboard", single_column: false }); this.parent = parent; this.page = this.parent.page; this.page.sidebar.html(`
`); this.$sidebar_list = this.page.sidebar.find('ul'); // const list of doctypes this.doctypes = ["Customer", "Item", "Supplier", "Sales Partner","Sales Person"]; this.timespans = ["Week", "Month", "Quarter", "Year"]; this.filters = { "Customer": ["total_sales_amount", "total_qty_sold", "outstanding_amount", ], "Item": ["total_sales_amount", "total_qty_sold", "total_purchase_amount", "total_qty_purchased", "available_stock_qty", "available_stock_value"], "Supplier": ["total_purchase_amount", "total_qty_purchased", "outstanding_amount"], "Sales Partner": ["total_sales_amount", "total_commission"], "Sales Person": ["total_sales_amount"], }; // for saving current selected filters // TODO: revert to 0 index for doctype and timespan, and remove preset down const _initial_doctype = this.doctypes[0]; const _initial_timespan = this.timespans[0]; const _initial_filter = this.filters[_initial_doctype]; this.options = { selected_doctype: _initial_doctype, selected_filter: _initial_filter, selected_filter_item: _initial_filter[0], selected_timespan: _initial_timespan, }; this.message = null; this.make(); }, make: function () { var me = this; var $container = $(`No Item found