Ver Fonte

[FIX] actualizado metodo de generacion del pdf

Rodney Elpidio Enciso Arias há 6 anos atrás
pai
commit
dad8fc46c6

+ 88 - 0
static/src/js/reports/report_doctor_ranking.js

@@ -17,6 +17,7 @@ function report_doctor_ranking(reporting){
             'change #current-attribute' : 'updateAttributeSelections',
             'change #current-store' : 'updateJournalSelections',
             'change #current-date' : 'ShowDateRange',
+             'change #current-period' : 'updatePeriodSelections',
         },
 
         init : function(parent){
@@ -537,6 +538,18 @@ function report_doctor_ranking(reporting){
             }
         },
 
+        updatePeriodSelections: function () {
+            var self = this;
+            var period = self.$el.find('#current-period').val();
+            if(period != 9999999){
+                self.$el.find('#current-date').val(9999999);
+                self.$el.find('#current-date').prop('disabled','disabled');
+                self.$el.find('.datepicker').css('display','none');
+            }else{
+                self.$el.find('#current-date').prop('disabled',false);
+            }
+        },
+
         /*====================================================================
             GET RES COMPANY
         ====================================================================*/
@@ -944,6 +957,7 @@ function report_doctor_ranking(reporting){
                     LLAMAR FUNCION DE IMPRESION
                 ============================================================
                 */
+                var filter = self.getFilter();
                 var pdf = new model.eiru_reports.ReportPdfWidget(self);
                 pdf.drawPDF(
                     _.flatten(getColumns),
@@ -953,8 +967,82 @@ function report_doctor_ranking(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 type = self.$el.find('#current-type').val();
+            var period = self.$el.find('#current-period').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(type && type != 9999999){
+                filter.push({
+                    title: 'Tipo de Venta',
+                    value:  $("#current-type option:selected").text(),
+                });
+            };
+            if(period && period != 9999999){
+                var AccountPeriod =  _.filter(self.AccountPeriod,function (item) {
+                    return item.id == period;
+                });
+                filter.push({
+                    title: 'Periodo',
+                    value:  AccountPeriod[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;
+        },
     });
 }

+ 15 - 8
static/src/reports/report_doctor_ranking.xml

@@ -73,14 +73,20 @@
             </div>
 
             <div class="report-form" style="display:none;">
-                <div class="chart-container center-block" style="padding-top:20px; height:300px; padding-bottom:20px;">
-                    <canvas class="reporting-chart"></canvas>
-                </div>
-                <div class="chart-container center-block" style="padding-top:20px; height:300px; padding-bottom:20px;">
-                    <canvas class="reporting-pie-chart"></canvas>
+                <div class="row">
+                    <div class="col-lg-8">
+                        <div class="chart-container" style="padding-top:20px; height:300px;">
+                            <canvas class="reporting-chart"></canvas>
+                        </div>
+                    </div>
+                    <div class="col-lg-4">
+                        <div class="chart-container center-block" style="padding-top:20px; height:300px;">
+                            <canvas class="reporting-pie-chart"></canvas>
+                        </div>
+                    </div>
                 </div>
                 <div id="toolbar">
-                    <button class="oe_button myButton" value="pdf">PDF</button>
+                    <button class="oe_button myButton" value="pdf">Imprimir Informe</button>
                 </div>
                 <div class="container" style="width:95%;">
                     <table id="table"
@@ -117,12 +123,13 @@
 
                 function detailFormatter(index, row) {
                     var html = [];
-                    html.push('<div class="container" style="padding:30px;">');
                     html.push('<div class="panel panel-default">');
+                    html.push('<div class="panel-body">');
                     html.push('<table class="table table-condensed table-no-bordered">');
+                    html.push('<thead style="background:none;"><tr><th style="width:2cm;">Numero</th><th style="text-align:center;">Fecha</th><th>Cliente</th><th style="text-align:right;">Total</th></tr></thead>');
                     if(row.info.length > 0){
                         _.each(row.info,function(item) {
-                            html.push('<tr><td>' + item.number + '</td><td>' + item.date + '</td><td>' + item.customer + '</td><td>' + item.amount + '</td></tr>');
+                            html.push('<tr><td>' + item.number + '</td><td style="text-align:center;">' + item.date + '</td><td>' + item.customer + '</td><td style="text-align:right;">' + item.amount + '</td></tr>');
                         });
                     }
                     html.push('</table>');