|
@@ -16,51 +16,158 @@ function dashboard_reporting_widget (instance, widget) {
|
|
|
|
|
|
grid: {},
|
|
|
start: function () {
|
|
|
- this.$el.find('.grid-stack.dashboard').gridstack({
|
|
|
+ this.$el.find('.grid-stack.reporting-dashboard').gridstack({
|
|
|
animate: true,
|
|
|
});
|
|
|
- this.grid = this.$el.find('.grid-stack.dashboard').data('gridstack');
|
|
|
+ this.grid = this.$el.find('.grid-stack.reporting-dashboard').data('gridstack');
|
|
|
this.renderWidgets();
|
|
|
},
|
|
|
renderWidgets: function () {
|
|
|
- var self = this;
|
|
|
+ var self = this;
|
|
|
|
|
|
- // var wChartInvoice = new widgets.ChartInvoiceWidget(self);
|
|
|
- // wChartInvoice.renderElement();
|
|
|
- // wChartInvoice.start();
|
|
|
- // self.grid.addWidget(wChartInvoice.$el, 0, 0, wChartInvoice.size.width, wChartInvoice.size.height, true);
|
|
|
-
|
|
|
- //Ranking pos orders Salesman
|
|
|
- // var wChartPosOrderSalesman = new widgets.ChartPosOrderSalesmanWidget(self);
|
|
|
- // wChartPosOrderSalesman.renderElement();
|
|
|
- // wChartPosOrderSalesman.start();
|
|
|
- // self.grid.addWidget(wChartPosOrderSalesman.$el, 0, 0, wChartPosOrderSalesman.size.width, wChartPosOrderSalesman.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){
|
|
|
+ var chart = _.flatten(_.filter(ChartList,function (inv) {
|
|
|
+ return inv.name == 'ChartInvoice';
|
|
|
+ }));
|
|
|
+ if(chart.length > 0){
|
|
|
+ wChartInvoice.renderElement();
|
|
|
+ wChartInvoice.start();
|
|
|
+ self.grid.addWidget(wChartInvoice.$el, 0, 0, wChartInvoice.size.width, wChartInvoice.size.height, true);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ });
|
|
|
|
|
|
- // ventas
|
|
|
+ // *************************** Historico de ventas
|
|
|
var wChartPosOrder = new widgets.ChartPosOrderWidget(self);
|
|
|
- wChartPosOrder.renderElement();
|
|
|
- wChartPosOrder.start();
|
|
|
- self.grid.addWidget(wChartPosOrder.$el, 0, 0, wChartPosOrder.size.width, wChartPosOrder.size.height, true);
|
|
|
+ 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){
|
|
|
+ var chart = _.flatten(_.filter(ChartList,function (inv) {
|
|
|
+ return inv.name == 'ChartPosOrder';
|
|
|
+ }));
|
|
|
+ if(chart.length > 0){
|
|
|
+ wChartPosOrder.renderElement();
|
|
|
+ wChartPosOrder.start();
|
|
|
+ self.grid.addWidget(wChartPosOrder.$el, 0, 0, wChartPosOrder.size.width, wChartPosOrder.size.height, true);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ });
|
|
|
|
|
|
- // Compras Gastos
|
|
|
- var wChartPurchaseExpense = new widgets.ChartPurchaseExpenseWidget(self);
|
|
|
- wChartPurchaseExpense.renderElement();
|
|
|
- wChartPurchaseExpense.start();
|
|
|
- self.grid.addWidget(wChartPurchaseExpense.$el, 0, 0, wChartPurchaseExpense.size.width, wChartPurchaseExpense.size.height, true);
|
|
|
-
|
|
|
- // Ranking de clientes
|
|
|
+ // *************************** Ranking de clientes
|
|
|
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 Ventas de Producto por Mes - Point Of Sale
|
|
|
+ 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){
|
|
|
+ var chart = _.flatten(_.filter(ChartList,function (inv) {
|
|
|
+ return inv.name == 'ChartPosOrderCustomer';
|
|
|
+ }));
|
|
|
+ if(chart.length > 0){
|
|
|
+ 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.renderElement();
|
|
|
- wChartPosOrderProduct.start();
|
|
|
- self.grid.addWidget(wChartPosOrderProduct.$el, 0, 0, wChartPosOrderProduct.size.width, wChartPosOrderProduct.size.height, true);
|
|
|
-
|
|
|
-
|
|
|
+ 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){
|
|
|
+ var chart = _.flatten(_.filter(ChartList,function (inv) {
|
|
|
+ return inv.name == 'ChartPosOrderProduct';
|
|
|
+ }));
|
|
|
+ if(chart.length > 0){
|
|
|
+ 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){
|
|
|
+ var chart = _.flatten(_.filter(ChartList,function (inv) {
|
|
|
+ return inv.name == 'ChartPosOrderSalesman';
|
|
|
+ }));
|
|
|
+ if(chart.length > 0){
|
|
|
+ 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){
|
|
|
+ var chart = _.flatten(_.filter(ChartList,function (inv) {
|
|
|
+ return inv.name == 'ChartPurchaseExpense';
|
|
|
+ }));
|
|
|
+ if(chart.length > 0){
|
|
|
+ wChartPurchaseExpense.renderElement();
|
|
|
+ wChartPurchaseExpense.start();
|
|
|
+ self.grid.addWidget(wChartPurchaseExpense.$el, 0, 0, wChartPurchaseExpense.size.width, wChartPurchaseExpense.size.height, true);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ });
|
|
|
}
|
|
|
});
|
|
|
}
|