2018-11-12 11:35:31 +00:00
|
|
|
// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
|
|
|
|
// For license information, please see license.txt
|
|
|
|
/* eslint-disable */
|
|
|
|
|
|
|
|
frappe.query_reports["Stock Analytics"] = {
|
|
|
|
"filters": [
|
|
|
|
{
|
|
|
|
fieldname: "item_group",
|
|
|
|
label: __("Item Group"),
|
|
|
|
fieldtype: "Link",
|
|
|
|
options:"Item Group",
|
|
|
|
default: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
fieldname: "item_code",
|
|
|
|
label: __("Item"),
|
|
|
|
fieldtype: "Link",
|
|
|
|
options:"Item",
|
|
|
|
default: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
fieldname: "value_quantity",
|
|
|
|
label: __("Value Or Qty"),
|
|
|
|
fieldtype: "Select",
|
|
|
|
options: [
|
|
|
|
{ "value": "Value", "label": __("Value") },
|
|
|
|
{ "value": "Quantity", "label": __("Quantity") }
|
|
|
|
],
|
|
|
|
default: "Value",
|
|
|
|
reqd: 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
fieldname: "brand",
|
|
|
|
label: __("Brand"),
|
|
|
|
fieldtype: "Link",
|
|
|
|
options:"Brand",
|
|
|
|
default: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
fieldname: "warehouse",
|
|
|
|
label: __("Warehouse"),
|
|
|
|
fieldtype: "Link",
|
|
|
|
options:"Warehouse",
|
|
|
|
default: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
fieldname: "from_date",
|
|
|
|
label: __("From Date"),
|
|
|
|
fieldtype: "Date",
|
|
|
|
default: frappe.defaults.get_global_default("year_start_date"),
|
|
|
|
reqd: 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
fieldname:"to_date",
|
|
|
|
label: __("To Date"),
|
|
|
|
fieldtype: "Date",
|
|
|
|
default: frappe.defaults.get_global_default("year_end_date"),
|
|
|
|
reqd: 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
fieldname: "range",
|
|
|
|
label: __("Range"),
|
|
|
|
fieldtype: "Select",
|
|
|
|
options: [
|
|
|
|
{ "value": "Weekly", "label": __("Weekly") },
|
|
|
|
{ "value": "Monthly", "label": __("Monthly") },
|
|
|
|
{ "value": "Quarterly", "label": __("Quarterly") },
|
|
|
|
{ "value": "Yearly", "label": __("Yearly") }
|
|
|
|
],
|
|
|
|
default: "Monthly",
|
|
|
|
reqd: 1
|
|
|
|
}
|
|
|
|
],
|
2018-11-30 10:50:48 +00:00
|
|
|
after_datatable_render: function(datatable_obj) {
|
|
|
|
$(datatable_obj.wrapper).find(".dt-row-0").find('input[type=checkbox]').click();
|
|
|
|
},
|
2018-11-12 11:35:31 +00:00
|
|
|
get_datatable_options(options) {
|
|
|
|
return Object.assign(options, {
|
|
|
|
checkboxColumn: true,
|
|
|
|
events: {
|
|
|
|
onCheckRow: function(data) {
|
|
|
|
row_name = data[2].content;
|
2018-11-26 11:22:15 +00:00
|
|
|
row_values = data.slice(7).map(function (column) {
|
2018-11-12 11:35:31 +00:00
|
|
|
return column.content;
|
|
|
|
})
|
|
|
|
entry = {
|
|
|
|
'name':row_name,
|
|
|
|
'values':row_values
|
|
|
|
}
|
|
|
|
|
|
|
|
let raw_data = frappe.query_report.chart.data;
|
|
|
|
let new_datasets = raw_data.datasets;
|
|
|
|
|
|
|
|
var found = false;
|
|
|
|
|
|
|
|
for(var i=0; i < new_datasets.length;i++){
|
|
|
|
if(new_datasets[i].name == row_name){
|
|
|
|
found = true;
|
|
|
|
new_datasets.splice(i,1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!found){
|
|
|
|
new_datasets.push(entry);
|
|
|
|
}
|
|
|
|
|
|
|
|
let new_data = {
|
|
|
|
labels: raw_data.labels,
|
|
|
|
datasets: new_datasets
|
|
|
|
}
|
2018-11-26 11:22:15 +00:00
|
|
|
|
2018-11-12 11:35:31 +00:00
|
|
|
setTimeout(() => {
|
|
|
|
frappe.query_report.chart.update(new_data)
|
2018-11-29 03:04:47 +00:00
|
|
|
},500)
|
2018-11-26 11:22:15 +00:00
|
|
|
|
|
|
|
|
2018-11-12 11:35:31 +00:00
|
|
|
setTimeout(() => {
|
|
|
|
frappe.query_report.chart.draw(true);
|
2018-11-29 03:04:47 +00:00
|
|
|
}, 1000)
|
2018-11-12 11:35:31 +00:00
|
|
|
|
|
|
|
frappe.query_report.raw_chart_data = new_data;
|
|
|
|
},
|
|
|
|
}
|
2018-11-29 03:04:47 +00:00
|
|
|
});
|
|
|
|
}
|
2018-11-12 11:35:31 +00:00
|
|
|
}
|