|
@@ -7,13 +7,7 @@ function dashboard_reporting_widget (instance, widget) {
|
|
|
|
|
|
widget.DashboardReportingWidget = instance.Widget.extend({
|
|
|
template: 'DashboardReportingTemplate',
|
|
|
- widgets: [
|
|
|
- {
|
|
|
- title: 'Clientes',
|
|
|
- name: 'CustomerCounterWidget'
|
|
|
- }
|
|
|
- ],
|
|
|
-
|
|
|
+ widgets: [],
|
|
|
grid: {},
|
|
|
start: function () {
|
|
|
this.$el.find('.grid-stack.reporting-dashboard').gridstack({
|
|
@@ -25,326 +19,164 @@ function dashboard_reporting_widget (instance, widget) {
|
|
|
renderWidgets: function () {
|
|
|
var self = this;
|
|
|
|
|
|
- // *************************** Ventas
|
|
|
- var wWidgetPosOrder = new widgets.WidgetPosOrderWidget(self);
|
|
|
- wWidgetPosOrder.fetchCurrentUser().then(function(CurrentUser){
|
|
|
+ // *************************** Ventas
|
|
|
+ var wUser = new widgets.UserWidget(self);
|
|
|
+ wUser.fetchCurrentUser().then(function(CurrentUser){
|
|
|
return CurrentUser;
|
|
|
}).then(function(CurrentUser){
|
|
|
- wWidgetPosOrder.fetchResUser(CurrentUser).then(function(chart_ids){
|
|
|
+ wUser.fetchResUser(CurrentUser).then(function(chart_ids){
|
|
|
return chart_ids;
|
|
|
}).then(function(chart_ids){
|
|
|
var charts = chart_ids[0].chart_ids;
|
|
|
- wWidgetPosOrder.fetchChartList(charts).then(function(ChartList){
|
|
|
+ wUser.fetchChartList(charts).then(function(ChartList){
|
|
|
return ChartList;
|
|
|
}).then(function(ChartList){
|
|
|
+
|
|
|
+ // *************************** Ventas
|
|
|
var chart = _.flatten(_.filter(ChartList,function (inv) {
|
|
|
return inv.name == 'WidgetPosOrder';
|
|
|
}));
|
|
|
if(chart.length > 0){
|
|
|
+ var wWidgetPosOrder = new widgets.WidgetPosOrderWidget(self);
|
|
|
wWidgetPosOrder.renderElement();
|
|
|
wWidgetPosOrder.start();
|
|
|
self.grid.addWidget(wWidgetPosOrder.$el, 0, 0, wWidgetPosOrder.size.width, wWidgetPosOrder.size.height, true);
|
|
|
}
|
|
|
- });
|
|
|
- });
|
|
|
- });
|
|
|
-
|
|
|
- // *************************** Compras
|
|
|
- var wWidgetPurchase = new widgets.WidgetPurchaseWidget(self);
|
|
|
- wWidgetPurchase.fetchCurrentUser().then(function(CurrentUser){
|
|
|
- return CurrentUser;
|
|
|
- }).then(function(CurrentUser){
|
|
|
- wWidgetPurchase.fetchResUser(CurrentUser).then(function(chart_ids){
|
|
|
- return chart_ids;
|
|
|
- }).then(function(chart_ids){
|
|
|
- var charts = chart_ids[0].chart_ids;
|
|
|
- wWidgetPurchase.fetchChartList(charts).then(function(ChartList){
|
|
|
- return ChartList;
|
|
|
- }).then(function(ChartList){
|
|
|
+
|
|
|
+ // *************************** Compras
|
|
|
var chart = _.flatten(_.filter(ChartList,function (inv) {
|
|
|
return inv.name == 'WidgetPurchase';
|
|
|
}));
|
|
|
if(chart.length > 0){
|
|
|
+ var wWidgetPurchase = new widgets.WidgetPurchaseWidget(self);
|
|
|
wWidgetPurchase.renderElement();
|
|
|
wWidgetPurchase.start();
|
|
|
self.grid.addWidget(wWidgetPurchase.$el, 0, 0, wWidgetPurchase.size.width, wWidgetPurchase.size.height, true);
|
|
|
}
|
|
|
- });
|
|
|
- });
|
|
|
- });
|
|
|
-
|
|
|
- // *************************** Gastos
|
|
|
- var wWidgetExpense = new widgets.WidgetExpenseWidget(self);
|
|
|
- wWidgetExpense.fetchCurrentUser().then(function(CurrentUser){
|
|
|
- return CurrentUser;
|
|
|
- }).then(function(CurrentUser){
|
|
|
- wWidgetExpense.fetchResUser(CurrentUser).then(function(chart_ids){
|
|
|
- return chart_ids;
|
|
|
- }).then(function(chart_ids){
|
|
|
- var charts = chart_ids[0].chart_ids;
|
|
|
- wWidgetExpense.fetchChartList(charts).then(function(ChartList){
|
|
|
- return ChartList;
|
|
|
- }).then(function(ChartList){
|
|
|
+
|
|
|
+ // *************************** Gastos
|
|
|
var chart = _.flatten(_.filter(ChartList,function (inv) {
|
|
|
return inv.name == 'WidgetExpense';
|
|
|
}));
|
|
|
if(chart.length > 0){
|
|
|
+ var wWidgetExpense = new widgets.WidgetExpenseWidget(self);
|
|
|
wWidgetExpense.renderElement();
|
|
|
wWidgetExpense.start();
|
|
|
self.grid.addWidget(wWidgetExpense.$el, 0, 0, wWidgetExpense.size.width, wWidgetExpense.size.height, true);
|
|
|
}
|
|
|
- });
|
|
|
- });
|
|
|
- });
|
|
|
-
|
|
|
|
|
|
- // *************************** Balance
|
|
|
- var wWidgetBalance = new widgets.WidgetBalanceWidget(self);
|
|
|
- wWidgetBalance.fetchCurrentUser().then(function(CurrentUser){
|
|
|
- return CurrentUser;
|
|
|
- }).then(function(CurrentUser){
|
|
|
- wWidgetBalance.fetchResUser(CurrentUser).then(function(chart_ids){
|
|
|
- return chart_ids;
|
|
|
- }).then(function(chart_ids){
|
|
|
- var charts = chart_ids[0].chart_ids;
|
|
|
- wWidgetBalance.fetchChartList(charts).then(function(ChartList){
|
|
|
- return ChartList;
|
|
|
- }).then(function(ChartList){
|
|
|
+ // *************************** Balance
|
|
|
var chart = _.flatten(_.filter(ChartList,function (inv) {
|
|
|
return inv.name == 'WidgetBalance';
|
|
|
}));
|
|
|
if(chart.length > 0){
|
|
|
+ var wWidgetBalance = new widgets.WidgetBalanceWidget(self);
|
|
|
wWidgetBalance.renderElement();
|
|
|
wWidgetBalance.start();
|
|
|
self.grid.addWidget(wWidgetBalance.$el, 0, 0, wWidgetBalance.size.width, wWidgetBalance.size.height, true);
|
|
|
}
|
|
|
- });
|
|
|
- });
|
|
|
- });
|
|
|
|
|
|
- // *************************** Caja Efectivo
|
|
|
- var wWidgetCash = new widgets.WidgetCashWidget(self);
|
|
|
- wWidgetCash.fetchCurrentUser().then(function(CurrentUser){
|
|
|
- return CurrentUser;
|
|
|
- }).then(function(CurrentUser){
|
|
|
- wWidgetCash.fetchResUser(CurrentUser).then(function(chart_ids){
|
|
|
- return chart_ids;
|
|
|
- }).then(function(chart_ids){
|
|
|
- var charts = chart_ids[0].chart_ids;
|
|
|
- wWidgetCash.fetchChartList(charts).then(function(ChartList){
|
|
|
- return ChartList;
|
|
|
- }).then(function(ChartList){
|
|
|
+ // *************************** Caja Efectivo
|
|
|
var chart = _.flatten(_.filter(ChartList,function (inv) {
|
|
|
return inv.name == 'WidgetCash';
|
|
|
}));
|
|
|
if(chart.length > 0){
|
|
|
+ var wWidgetCash = new widgets.WidgetCashWidget(self);
|
|
|
wWidgetCash.renderElement();
|
|
|
wWidgetCash.start();
|
|
|
self.grid.addWidget(wWidgetCash.$el, 0, 0, wWidgetCash.size.width, wWidgetCash.size.height, true);
|
|
|
}
|
|
|
- });
|
|
|
- });
|
|
|
- });
|
|
|
|
|
|
- // *************************** Caja Banco
|
|
|
- var wWidgetBank = new widgets.WidgetBankWidget(self);
|
|
|
- wWidgetBank.fetchCurrentUser().then(function(CurrentUser){
|
|
|
- return CurrentUser;
|
|
|
- }).then(function(CurrentUser){
|
|
|
- wWidgetBank.fetchResUser(CurrentUser).then(function(chart_ids){
|
|
|
- return chart_ids;
|
|
|
- }).then(function(chart_ids){
|
|
|
- var charts = chart_ids[0].chart_ids;
|
|
|
- wWidgetBank.fetchChartList(charts).then(function(ChartList){
|
|
|
- return ChartList;
|
|
|
- }).then(function(ChartList){
|
|
|
+ // *************************** Caja Banco
|
|
|
var chart = _.flatten(_.filter(ChartList,function (inv) {
|
|
|
- return inv.name == 'WidgetCash';
|
|
|
+ return inv.name == 'WidgetBank';
|
|
|
}));
|
|
|
if(chart.length > 0){
|
|
|
+ var wWidgetBank = new widgets.WidgetBankWidget(self);
|
|
|
wWidgetBank.renderElement();
|
|
|
wWidgetBank.start();
|
|
|
self.grid.addWidget(wWidgetBank.$el, 0, 0, wWidgetBank.size.width, wWidgetBank.size.height, true);
|
|
|
}
|
|
|
- });
|
|
|
- });
|
|
|
- });
|
|
|
|
|
|
- // *************************** Ingreso Egreso
|
|
|
- var wChartIngresoEgreso = new widgets.ChartIngresoEgresoWidget(self);
|
|
|
- wChartIngresoEgreso.fetchCurrentUser().then(function(CurrentUser){
|
|
|
- return CurrentUser;
|
|
|
- }).then(function(CurrentUser){
|
|
|
- wChartIngresoEgreso.fetchResUser(CurrentUser).then(function(chart_ids){
|
|
|
- return chart_ids;
|
|
|
- }).then(function(chart_ids){
|
|
|
- var charts = chart_ids[0].chart_ids;
|
|
|
- wChartIngresoEgreso.fetchChartList(charts).then(function(ChartList){
|
|
|
- return ChartList;
|
|
|
- }).then(function(ChartList){
|
|
|
+ // *************************** Ingreso Egreso
|
|
|
var chart = _.flatten(_.filter(ChartList,function (inv) {
|
|
|
return inv.name == 'ChartIngresoEgreso';
|
|
|
}));
|
|
|
if(chart.length > 0){
|
|
|
+ var wChartIngresoEgreso = new widgets.ChartIngresoEgresoWidget(self);
|
|
|
wChartIngresoEgreso.renderElement();
|
|
|
wChartIngresoEgreso.start();
|
|
|
self.grid.addWidget(wChartIngresoEgreso.$el, 0, 0, wChartIngresoEgreso.size.width, wChartIngresoEgreso.size.height, true);
|
|
|
}
|
|
|
- });
|
|
|
- });
|
|
|
- });
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- // **************************** Historico de Facturas
|
|
|
- var wChartInvoice = new widgets.ChartInvoiceWidget(self);
|
|
|
- wChartInvoice.fetchCurrentUser().then(function(CurrentUser){
|
|
|
- return CurrentUser;
|
|
|
- }).then(function(CurrentUser){
|
|
|
- wChartInvoice.fetchResUser(CurrentUser).then(function(chart_ids){
|
|
|
- return chart_ids;
|
|
|
- }).then(function(chart_ids){
|
|
|
- var charts = chart_ids[0].chart_ids;
|
|
|
- wChartInvoice.fetchChartList(charts).then(function(ChartList){
|
|
|
- return ChartList;
|
|
|
- }).then(function(ChartList){
|
|
|
+ // **************************** Historico de Facturas
|
|
|
var chart = _.flatten(_.filter(ChartList,function (inv) {
|
|
|
return inv.name == 'ChartInvoice';
|
|
|
}));
|
|
|
if(chart.length > 0){
|
|
|
+ var wChartInvoice = new widgets.ChartInvoiceWidget(self);
|
|
|
wChartInvoice.renderElement();
|
|
|
wChartInvoice.start();
|
|
|
self.grid.addWidget(wChartInvoice.$el, 0, 0, wChartInvoice.size.width, wChartInvoice.size.height, true);
|
|
|
}
|
|
|
- });
|
|
|
- });
|
|
|
- });
|
|
|
|
|
|
- // *************************** Historico de ventas
|
|
|
- var wChartPosOrder = new widgets.ChartPosOrderWidget(self);
|
|
|
- wChartPosOrder.fetchCurrentUser().then(function(CurrentUser){
|
|
|
- return CurrentUser;
|
|
|
- }).then(function(CurrentUser){
|
|
|
- wChartPosOrder.fetchResUser(CurrentUser).then(function(chart_ids){
|
|
|
- return chart_ids;
|
|
|
- }).then(function(chart_ids){
|
|
|
- var charts = chart_ids[0].chart_ids;
|
|
|
- wChartPosOrder.fetchChartList(charts).then(function(ChartList){
|
|
|
- return ChartList;
|
|
|
- }).then(function(ChartList){
|
|
|
+ // *************************** Historico de ventas
|
|
|
var chart = _.flatten(_.filter(ChartList,function (inv) {
|
|
|
return inv.name == 'ChartPosOrder';
|
|
|
}));
|
|
|
if(chart.length > 0){
|
|
|
+ var wChartPosOrder = new widgets.ChartPosOrderWidget(self);
|
|
|
wChartPosOrder.renderElement();
|
|
|
wChartPosOrder.start();
|
|
|
self.grid.addWidget(wChartPosOrder.$el, 0, 0, wChartPosOrder.size.width, wChartPosOrder.size.height, true);
|
|
|
}
|
|
|
- });
|
|
|
- });
|
|
|
- });
|
|
|
|
|
|
- // *************************** Ranking de clientes
|
|
|
- var wChartPosOrderCustomer = new widgets.ChartPosOrderCustomerWidget(self);
|
|
|
- wChartPosOrderCustomer.fetchCurrentUser().then(function(CurrentUser){
|
|
|
- return CurrentUser;
|
|
|
- }).then(function(CurrentUser){
|
|
|
- wChartPosOrderCustomer.fetchResUser(CurrentUser).then(function(chart_ids){
|
|
|
- return chart_ids;
|
|
|
- }).then(function(chart_ids){
|
|
|
- var charts = chart_ids[0].chart_ids;
|
|
|
- wChartPosOrderCustomer.fetchChartList(charts).then(function(ChartList){
|
|
|
- return ChartList;
|
|
|
- }).then(function(ChartList){
|
|
|
+ // *************************** Ranking de clientes
|
|
|
var chart = _.flatten(_.filter(ChartList,function (inv) {
|
|
|
return inv.name == 'ChartPosOrderCustomer';
|
|
|
}));
|
|
|
if(chart.length > 0){
|
|
|
+ var wChartPosOrderCustomer = new widgets.ChartPosOrderCustomerWidget(self);
|
|
|
wChartPosOrderCustomer.renderElement();
|
|
|
wChartPosOrderCustomer.start();
|
|
|
self.grid.addWidget(wChartPosOrderCustomer.$el, 0, 0, wChartPosOrderCustomer.size.width, wChartPosOrderCustomer.size.height, true);
|
|
|
}
|
|
|
- });
|
|
|
- });
|
|
|
- });
|
|
|
|
|
|
- // *************************** Ranking de Productos
|
|
|
- var wChartPosOrderProduct = new widgets.ChartPosOrderProductWidget(self);
|
|
|
- wChartPosOrderProduct.fetchCurrentUser().then(function(CurrentUser){
|
|
|
- return CurrentUser;
|
|
|
- }).then(function(CurrentUser){
|
|
|
- wChartPosOrderProduct.fetchResUser(CurrentUser).then(function(chart_ids){
|
|
|
- return chart_ids;
|
|
|
- }).then(function(chart_ids){
|
|
|
- var charts = chart_ids[0].chart_ids;
|
|
|
- wChartPosOrderProduct.fetchChartList(charts).then(function(ChartList){
|
|
|
- return ChartList;
|
|
|
- }).then(function(ChartList){
|
|
|
+ // *************************** Ranking de Productos
|
|
|
var chart = _.flatten(_.filter(ChartList,function (inv) {
|
|
|
return inv.name == 'ChartPosOrderProduct';
|
|
|
}));
|
|
|
if(chart.length > 0){
|
|
|
+ var wChartPosOrderProduct = new widgets.ChartPosOrderProductWidget(self);
|
|
|
wChartPosOrderProduct.renderElement();
|
|
|
wChartPosOrderProduct.start();
|
|
|
self.grid.addWidget(wChartPosOrderProduct.$el, 0, 0, wChartPosOrderProduct.size.width, wChartPosOrderProduct.size.height, true);
|
|
|
}
|
|
|
- });
|
|
|
- });
|
|
|
- });
|
|
|
|
|
|
- // *************************** Vendedores
|
|
|
- var wChartPosOrderSalesman = new widgets.ChartPosOrderSalesmanWidget(self);
|
|
|
- wChartPosOrderSalesman.fetchCurrentUser().then(function(CurrentUser){
|
|
|
- return CurrentUser;
|
|
|
- }).then(function(CurrentUser){
|
|
|
- wChartPosOrderSalesman.fetchResUser(CurrentUser).then(function(chart_ids){
|
|
|
- return chart_ids;
|
|
|
- }).then(function(chart_ids){
|
|
|
- var charts = chart_ids[0].chart_ids;
|
|
|
- wChartPosOrderSalesman.fetchChartList(charts).then(function(ChartList){
|
|
|
- return ChartList;
|
|
|
- }).then(function(ChartList){
|
|
|
+ // *************************** Vendedores
|
|
|
var chart = _.flatten(_.filter(ChartList,function (inv) {
|
|
|
return inv.name == 'ChartPosOrderSalesman';
|
|
|
}));
|
|
|
if(chart.length > 0){
|
|
|
+ var wChartPosOrderSalesman = new widgets.ChartPosOrderSalesmanWidget(self);
|
|
|
wChartPosOrderSalesman.renderElement();
|
|
|
wChartPosOrderSalesman.start();
|
|
|
self.grid.addWidget(wChartPosOrderSalesman.$el, 0, 0, wChartPosOrderSalesman.size.width, wChartPosOrderSalesman.size.height, true);
|
|
|
}
|
|
|
- });
|
|
|
- });
|
|
|
- });
|
|
|
-
|
|
|
- // *************************** Compras y Gastos
|
|
|
- var wChartPurchaseExpense = new widgets.ChartPurchaseExpenseWidget(self);
|
|
|
- wChartPurchaseExpense.fetchCurrentUser().then(function(CurrentUser){
|
|
|
- return CurrentUser;
|
|
|
- }).then(function(CurrentUser){
|
|
|
- wChartPurchaseExpense.fetchResUser(CurrentUser).then(function(chart_ids){
|
|
|
- return chart_ids;
|
|
|
- }).then(function(chart_ids){
|
|
|
- var charts = chart_ids[0].chart_ids;
|
|
|
- wChartPurchaseExpense.fetchChartList(charts).then(function(ChartList){
|
|
|
- return ChartList;
|
|
|
- }).then(function(ChartList){
|
|
|
+
|
|
|
+ // *************************** Compras y Gastos
|
|
|
var chart = _.flatten(_.filter(ChartList,function (inv) {
|
|
|
return inv.name == 'ChartPurchaseExpense';
|
|
|
}));
|
|
|
if(chart.length > 0){
|
|
|
+ var wChartPurchaseExpense = new widgets.ChartPurchaseExpenseWidget(self);
|
|
|
wChartPurchaseExpense.renderElement();
|
|
|
wChartPurchaseExpense.start();
|
|
|
self.grid.addWidget(wChartPurchaseExpense.$el, 0, 0, wChartPurchaseExpense.size.width, wChartPurchaseExpense.size.height, true);
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
- });
|
|
|
+ });
|
|
|
}
|
|
|
});
|
|
|
}
|