Sfoglia il codice sorgente

[FIX] ajustes en el pdf

Rodney Elpidio Enciso Arias 6 anni fa
parent
commit
127bce2c34

+ 61 - 2
static/src/js/reports/report_session.js

@@ -564,8 +564,8 @@ function report_session(reporting){
                     config_id :{halign:'left'},
                     name :{halign:'left'},
                     user_id :{halign:'left'},
-                    start_at :{columnWidth: 30},
-                    stop_at:{columnWidth: 30},
+                    start_at :{halign:'center', columnWidth: 35},
+                    stop_at:{halign:'center', columnWidth: 35},
                     amount_total:{halign:'right',columnWidth: 30},
                 };
                 /*
@@ -573,6 +573,7 @@ function report_session(reporting){
                     LLAMAR FUNCION DE IMPRESION
                 ============================================================
                 */
+                var filter = self.getFilter();
                 var pdf = new model.eiru_reports.ReportPdfWidget(self);
                 pdf.drawPDF(
                     _.flatten(getColumns),
@@ -582,8 +583,66 @@ function report_session(reporting){
                     pdf_type,
                     pdf_name,
                     pdf_columnStyles,
+                    filter,
                 );
             }
         },
+
+        getFilter: function(){
+            var self = this;
+            var company = self.$el.find('#current-company').val();
+            var store = self.$el.find('#current-store').val();
+            var date = self.$el.find('#current-date').val();
+            var desde = self.$el.find('#from').val();
+            var hasta = self.$el.find('#to').val();
+            var filter = [];
+            if(company && company){
+                var ResCompany = _.filter(self.ResCompany, function(item){
+                    return item.id == company;
+                });
+                filter.push({
+                    title:'Empresa',
+                    value: ResCompany[0].name,
+                });
+            };
+            if(store && store != 9999999){
+                var ResStore =  _.filter(self.ResStore,function (item) {
+                    return item.id == store;
+                });
+                filter.push({
+                    title: 'Sucursal',
+                    value:  ResStore[0].name,
+                });
+            };
+            if(date && date != 9999999){
+                moment.locale('es', {
+                    months: 'Enero_Febrero_Marzo_Abril_Mayo_Junio_Julio_Agosto_Septiembre_Octubre_Noviembre_Diciembre'.split('_'),
+                });
+                if(date == 'range'){
+                    filter.push({
+                        title: 'Fecha',
+                        value:  desde + ' al '+ hasta,
+                    });
+                }else{
+                    if(date == 'today'){
+                        var fecha = moment().format('DD/MM/YYYY');
+                    }
+                    if(date == 'yesterday'){
+                        var fecha = moment().add(-1,'days').format('DD/MM/YYYY');
+                    }
+                    if(date == 'currentMonth'){
+                        var fecha = moment().format('MMMM/YYYY');
+                    }
+                    if(date == 'lastMonth'){
+                        var fecha = moment().add(-1,'months').format('MMMM/YYYY');
+                    }
+                    filter.push({
+                        title: 'Fecha',
+                        value:  fecha,
+                    });
+                };
+            };
+            return filter;
+        },
     });
 }

+ 62 - 18
static/src/js/reports/report_session_analytic.js

@@ -566,23 +566,9 @@ function report_session_analytic(reporting){
             var column = table.bootstrapTable('getVisibleColumns');
             var row = table.bootstrapTable('getData');
 
-            var qty = _.reduce(_.map(row, function (map) {
-                return map.qty;
-            }), function (memo, num) {
-                return memo + num;
-            });
-
-            var amount = _.reduce(_.map(row, function (map) {
-                return map.amount;
-            }), function (memo, num) {
-                return memo + num;
-            });
-
             row.push({
-                medic: 'Totales',
-                qty_total: qty,
-                total_amount: accounting.formatMoney(amount, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
-            })
+                config_id : '',
+            });
 
             if (action === 'pdf') {
                 var data = _.map(column, function (val){ return val.field});
@@ -605,14 +591,15 @@ function report_session_analytic(reporting){
                     config_id :{halign:'left'},
                     name :{halign:'left'},
                     user_id :{halign:'left'},
-                    start_at :{columnWidth: 30},
-                    stop_at:{columnWidth: 30},
+                    start_at :{halign:'center', columnWidth: 35},
+                    stop_at:{halign:'center', columnWidth: 35},
                 };
                 /*
                 ============================================================
                     LLAMAR FUNCION DE IMPRESION
                 ============================================================
                 */
+                var filter = self.getFilter();
                 var pdf = new model.eiru_reports.ReportPdfWidget(self);
                 pdf.drawPDF(
                     _.flatten(getColumns),
@@ -622,8 +609,65 @@ function report_session_analytic(reporting){
                     pdf_type,
                     pdf_name,
                     pdf_columnStyles,
+                    filter,
                 );
             }
         },
+        getFilter: function(){
+            var self = this;
+            var company = self.$el.find('#current-company').val();
+            var store = self.$el.find('#current-store').val();
+            var date = self.$el.find('#current-date').val();
+            var desde = self.$el.find('#from').val();
+            var hasta = self.$el.find('#to').val();
+            var filter = [];
+            if(company && company){
+                var ResCompany = _.filter(self.ResCompany, function(item){
+                    return item.id == company;
+                });
+                filter.push({
+                    title:'Empresa',
+                    value: ResCompany[0].name,
+                });
+            };
+            if(store && store != 9999999){
+                var ResStore =  _.filter(self.ResStore,function (item) {
+                    return item.id == store;
+                });
+                filter.push({
+                    title: 'Sucursal',
+                    value:  ResStore[0].name,
+                });
+            };
+            if(date && date != 9999999){
+                moment.locale('es', {
+                    months: 'Enero_Febrero_Marzo_Abril_Mayo_Junio_Julio_Agosto_Septiembre_Octubre_Noviembre_Diciembre'.split('_'),
+                });
+                if(date == 'range'){
+                    filter.push({
+                        title: 'Fecha',
+                        value:  desde + ' al '+ hasta,
+                    });
+                }else{
+                    if(date == 'today'){
+                        var fecha = moment().format('DD/MM/YYYY');
+                    }
+                    if(date == 'yesterday'){
+                        var fecha = moment().add(-1,'days').format('DD/MM/YYYY');
+                    }
+                    if(date == 'currentMonth'){
+                        var fecha = moment().format('MMMM/YYYY');
+                    }
+                    if(date == 'lastMonth'){
+                        var fecha = moment().add(-1,'months').format('MMMM/YYYY');
+                    }
+                    filter.push({
+                        title: 'Fecha',
+                        value:  fecha,
+                    });
+                };
+            };
+            return filter;
+        },
     });
 }