|  | @@ -0,0 +1,1158 @@
 | 
	
		
			
				|  |  | +function pdf(reporting) {
 | 
	
		
			
				|  |  | +    "use strict";
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    var model = openerp;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    reporting.ReportPdfWidget = reporting.Base.extend({
 | 
	
		
			
				|  |  | +      drawPDF: function (getColumns,row,ResCompany,pdf_title,pdf_type,pdf_name,pdf_columnStyles,filter) {
 | 
	
		
			
				|  |  | +        var self = this;
 | 
	
		
			
				|  |  | +        var base64Img = 'data:image/png;base64,' + ResCompany.logo;
 | 
	
		
			
				|  |  | +        var hoy = moment().format('DD/MM/YYYY');
 | 
	
		
			
				|  |  | +        var totalPagesExp = "{total_pages_count_string}";
 | 
	
		
			
				|  |  | +        var pdfDoc = new jsPDF(pdf_type);
 | 
	
		
			
				|  |  | +        var y_position = 27;
 | 
	
		
			
				|  |  | +        var y_position2 = 27;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        //LOGO
 | 
	
		
			
				|  |  | +        pdfDoc.addImage(base64Img, 'png', 7, 2, 0, 15);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        //FECHA
 | 
	
		
			
				|  |  | +        pdfDoc.setFontSize(13);
 | 
	
		
			
				|  |  | +        pdfDoc.setFontStyle('normal');
 | 
	
		
			
				|  |  | +        pdfDoc.setTextColor(40)
 | 
	
		
			
				|  |  | +        pdfDoc.text(pdfDoc.internal.pageSize.getWidth() - 35, 12,hoy);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        //TITULO
 | 
	
		
			
				|  |  | +        pdfDoc.setFontSize(15);
 | 
	
		
			
				|  |  | +        pdfDoc.setFontStyle('bold');
 | 
	
		
			
				|  |  | +        pdfDoc.setTextColor('#0288d1');
 | 
	
		
			
				|  |  | +        pdfDoc.autoTableText(pdf_title, pdfDoc.internal.pageSize.getWidth() - 12, 18, {
 | 
	
		
			
				|  |  | +          halign: 'right',
 | 
	
		
			
				|  |  | +          valign: 'middle'
 | 
	
		
			
				|  |  | +        });
 | 
	
		
			
				|  |  | +        pdfDoc.setLineWidth(0.5);
 | 
	
		
			
				|  |  | +        pdfDoc.setDrawColor('#424242');
 | 
	
		
			
				|  |  | +        pdfDoc.line(10, 22, pdfDoc.internal.pageSize.getWidth() - 10 , 22);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        var i=0;
 | 
	
		
			
				|  |  | +        if(pdf_type == 'l'){
 | 
	
		
			
				|  |  | +          var col1_title = 15;
 | 
	
		
			
				|  |  | +          var col1_value = 55;
 | 
	
		
			
				|  |  | +          var col2_title = 150;
 | 
	
		
			
				|  |  | +          var col2_value = 190;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        else{
 | 
	
		
			
				|  |  | +          var col1_title = 10;
 | 
	
		
			
				|  |  | +          var col1_value = 50;
 | 
	
		
			
				|  |  | +          var col2_title = 110;
 | 
	
		
			
				|  |  | +          var col2_value = 150;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if(filter.length >0){
 | 
	
		
			
				|  |  | +          _.each(filter,function(item){
 | 
	
		
			
				|  |  | +            if(i<4){
 | 
	
		
			
				|  |  | +              self.addFilter(pdfDoc,item.title,item.value,col1_title,col1_value,y_position);
 | 
	
		
			
				|  |  | +              y_position = y_position + 5;
 | 
	
		
			
				|  |  | +            }else{
 | 
	
		
			
				|  |  | +              self.addFilter(pdfDoc,item.title,item.value,col2_title,col2_value,y_position2);
 | 
	
		
			
				|  |  | +              y_position2 = y_position2 + 5;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +              i++;
 | 
	
		
			
				|  |  | +          });
 | 
	
		
			
				|  |  | +          pdfDoc.setLineWidth(0.5);
 | 
	
		
			
				|  |  | +          pdfDoc.setDrawColor('#424242');
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +          if(y_position >= y_position2){
 | 
	
		
			
				|  |  | +            y_position = y_position;
 | 
	
		
			
				|  |  | +            pdfDoc.line(10, y_position, pdfDoc.internal.pageSize.getWidth() - 10 , y_position);
 | 
	
		
			
				|  |  | +          }else{
 | 
	
		
			
				|  |  | +            y_position = y_position2;
 | 
	
		
			
				|  |  | +            pdfDoc.line(10, y_position2, pdfDoc.internal.pageSize.getWidth() - 10 , y_position2);
 | 
	
		
			
				|  |  | +          }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        pdfDoc.autoTable(getColumns, row, {
 | 
	
		
			
				|  |  | +            // showHeader: 'firstPage',
 | 
	
		
			
				|  |  | +            startY: y_position + 5,
 | 
	
		
			
				|  |  | +            theme: 'grid',
 | 
	
		
			
				|  |  | +            styles: {
 | 
	
		
			
				|  |  | +                overflow: 'linebreak',
 | 
	
		
			
				|  |  | +                columnWidth: 'auto',
 | 
	
		
			
				|  |  | +                fontSize: 7,
 | 
	
		
			
				|  |  | +            },
 | 
	
		
			
				|  |  | +            headerStyles: {
 | 
	
		
			
				|  |  | +                fillColor: [76, 133, 248],
 | 
	
		
			
				|  |  | +                fontSize: 9
 | 
	
		
			
				|  |  | +            },
 | 
	
		
			
				|  |  | +            columnStyles: pdf_columnStyles,
 | 
	
		
			
				|  |  | +            margin: { horizontal: 7},
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            drawCell: function(cell, opts) {
 | 
	
		
			
				|  |  | +                var rows = opts.table.rows;
 | 
	
		
			
				|  |  | +                if (opts.row.index == rows.length - 1) {
 | 
	
		
			
				|  |  | +                  pdfDoc.setFontStyle('bold');
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            },
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            addPageContent: function (data) {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            //FOOTER
 | 
	
		
			
				|  |  | +                var str = "Página " + data.pageCount;
 | 
	
		
			
				|  |  | +                if (typeof pdfDoc.putTotalPages === 'function') {
 | 
	
		
			
				|  |  | +                    str = str + " de " + totalPagesExp;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                pdfDoc.setFontSize(9);
 | 
	
		
			
				|  |  | +                pdfDoc.setFontStyle('bold');
 | 
	
		
			
				|  |  | +                pdfDoc.setTextColor(40);
 | 
	
		
			
				|  |  | +                var pageHeight = pdfDoc.internal.pageSize.height || pdfDoc.internal.pageSize.getHeight();
 | 
	
		
			
				|  |  | +                pdfDoc.autoTableText(str, pdfDoc.internal.pageSize.getWidth() - 35, pageHeight - 5, {
 | 
	
		
			
				|  |  | +                  halign: 'rigth',
 | 
	
		
			
				|  |  | +                  valign: 'middle'
 | 
	
		
			
				|  |  | +                });
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        });
 | 
	
		
			
				|  |  | +        if (typeof pdfDoc.putTotalPages === 'function') {
 | 
	
		
			
				|  |  | +            pdfDoc.putTotalPages(totalPagesExp);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        row.pop();
 | 
	
		
			
				|  |  | +        if(model.printer_bridge){
 | 
	
		
			
				|  |  | +            var data = pdfDoc.output('datauristring');
 | 
	
		
			
				|  |  | +            model.printer_bridge.print(data);
 | 
	
		
			
				|  |  | +            return;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        pdfDoc.save(pdf_name + hoy + '.pdf');
 | 
	
		
			
				|  |  | +      },
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +      addFilter: function(pdfDoc,title,value,x_position_title,x_position_value,y_position){
 | 
	
		
			
				|  |  | +        pdfDoc.setFontSize(10);
 | 
	
		
			
				|  |  | +        pdfDoc.setTextColor('#424242');
 | 
	
		
			
				|  |  | +        pdfDoc.setFontStyle('bold');
 | 
	
		
			
				|  |  | +        pdfDoc.autoTableText(title+':', x_position_title, y_position, {
 | 
	
		
			
				|  |  | +          halign: 'left',
 | 
	
		
			
				|  |  | +          valign: 'middle'
 | 
	
		
			
				|  |  | +        });
 | 
	
		
			
				|  |  | +        pdfDoc.setFontSize(10);
 | 
	
		
			
				|  |  | +        pdfDoc.setTextColor('#424242');
 | 
	
		
			
				|  |  | +        pdfDoc.setFontStyle('normal');
 | 
	
		
			
				|  |  | +        pdfDoc.autoTableText(value, x_position_value, y_position, {
 | 
	
		
			
				|  |  | +          halign: 'left',
 | 
	
		
			
				|  |  | +          valign: 'middle'
 | 
	
		
			
				|  |  | +        });
 | 
	
		
			
				|  |  | +      },
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        drawStockPDF: function (
 | 
	
		
			
				|  |  | +            index,
 | 
	
		
			
				|  |  | +            getColumns,
 | 
	
		
			
				|  |  | +            row,
 | 
	
		
			
				|  |  | +            ResCompany,
 | 
	
		
			
				|  |  | +            pdf_title,
 | 
	
		
			
				|  |  | +            pdf_type,
 | 
	
		
			
				|  |  | +            pdf_name,
 | 
	
		
			
				|  |  | +            pdf_columnStyles,
 | 
	
		
			
				|  |  | +            current_location) {
 | 
	
		
			
				|  |  | +            var self = this;
 | 
	
		
			
				|  |  | +            var base64Img = 'data:image/png;base64,' + ResCompany.logo;
 | 
	
		
			
				|  |  | +            var hoy = moment().format('DD/MM/YYYY');
 | 
	
		
			
				|  |  | +            var totalPagesExp = "{total_pages_count_string}";
 | 
	
		
			
				|  |  | +            var pdfDoc = new jsPDF(pdf_type);
 | 
	
		
			
				|  |  | +            getColumns.shift();
 | 
	
		
			
				|  |  | +            pdfDoc.autoTable(getColumns, row, {
 | 
	
		
			
				|  |  | +                theme: 'grid',
 | 
	
		
			
				|  |  | +                styles: {
 | 
	
		
			
				|  |  | +                    overflow: 'linebreak',
 | 
	
		
			
				|  |  | +                    columnWidth: 'auto',
 | 
	
		
			
				|  |  | +                    fontSize: 7,
 | 
	
		
			
				|  |  | +                },
 | 
	
		
			
				|  |  | +                headerStyles: {
 | 
	
		
			
				|  |  | +                    fillColor: [76, 133, 248],
 | 
	
		
			
				|  |  | +                    fontSize: 8
 | 
	
		
			
				|  |  | +                },
 | 
	
		
			
				|  |  | +                columnStyles: pdf_columnStyles,
 | 
	
		
			
				|  |  | +                margin: { top: 20, horizontal: 7, bottom: 40,},
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                drawCell: function(cell, data) {
 | 
	
		
			
				|  |  | +                    var rows = data.table.rows;
 | 
	
		
			
				|  |  | +                    if (data.row.index == rows.length - 1) {
 | 
	
		
			
				|  |  | +                        pdfDoc.setFontStyle('bold');
 | 
	
		
			
				|  |  | +                    };
 | 
	
		
			
				|  |  | +                },
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                addPageContent: function (data) {
 | 
	
		
			
				|  |  | +                    pdfDoc.addImage(base64Img, 'png', 7, 2, 0, 15);
 | 
	
		
			
				|  |  | +                    if(pdf_type == 'l'){
 | 
	
		
			
				|  |  | +                        pdfDoc.setFontSize(12);
 | 
	
		
			
				|  |  | +                        pdfDoc.setFontStyle('bold');
 | 
	
		
			
				|  |  | +                        pdfDoc.setTextColor(40);
 | 
	
		
			
				|  |  | +                        pdfDoc.text(pdf_title,130,10);
 | 
	
		
			
				|  |  | +                    }else{
 | 
	
		
			
				|  |  | +                        pdfDoc.setFontSize(12);
 | 
	
		
			
				|  |  | +                        pdfDoc.setFontStyle('bold');
 | 
	
		
			
				|  |  | +                        pdfDoc.setTextColor(40);
 | 
	
		
			
				|  |  | +                        pdfDoc.text(pdf_title,80,10);
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                    if(current_location.length > 0){
 | 
	
		
			
				|  |  | +                        pdfDoc.setFontSize(9);
 | 
	
		
			
				|  |  | +                        pdfDoc.setFontStyle('normal');
 | 
	
		
			
				|  |  | +                        pdfDoc.setTextColor(40)
 | 
	
		
			
				|  |  | +                        pdfDoc.text(pdfDoc.internal.pageSize.getWidth() - 54, 18,"Ubicación: " + current_location[0].parent_name);
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                    pdfDoc.setFontSize(9);
 | 
	
		
			
				|  |  | +                    pdfDoc.setFontStyle('normal');
 | 
	
		
			
				|  |  | +                    pdfDoc.setTextColor(40)
 | 
	
		
			
				|  |  | +                    pdfDoc.text(pdfDoc.internal.pageSize.getWidth() - 55, 14," Fecha de Expedición: " + hoy);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                    /*===========
 | 
	
		
			
				|  |  | +                        FOOTER
 | 
	
		
			
				|  |  | +                    ===========*/
 | 
	
		
			
				|  |  | +                    var str = "Página " + data.pageCount;
 | 
	
		
			
				|  |  | +                    if (typeof pdfDoc.putTotalPages === 'function') {
 | 
	
		
			
				|  |  | +                        str = str + " de " + totalPagesExp;
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                    pdfDoc.setFontSize(9);
 | 
	
		
			
				|  |  | +                    pdfDoc.setFontStyle('bold');
 | 
	
		
			
				|  |  | +                    pdfDoc.setTextColor(40);
 | 
	
		
			
				|  |  | +                    var pageHeight = pdfDoc.internal.pageSize.height || pdfDoc.internal.pageSize.getHeight();
 | 
	
		
			
				|  |  | +                    pdfDoc.text(str, pdfDoc.internal.pageSize.getWidth() - 55, pageHeight - 5);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            });
 | 
	
		
			
				|  |  | +            if (typeof pdfDoc.putTotalPages === 'function') {
 | 
	
		
			
				|  |  | +                pdfDoc.putTotalPages(totalPagesExp);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            row.pop();
 | 
	
		
			
				|  |  | +            if(model.printer_bridge){
 | 
	
		
			
				|  |  | +                var data = pdfDoc.output('datauristring');
 | 
	
		
			
				|  |  | +                model.printer_bridge.print(data);
 | 
	
		
			
				|  |  | +                return;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            pdfDoc.save(pdf_name + hoy + '.pdf');
 | 
	
		
			
				|  |  | +        },
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        drawSaleJournalPDF: function (getColumns,row,ResCompany,pdf_title,pdf_type,pdf_name,pdf_columnStyles,desde,hasta) {
 | 
	
		
			
				|  |  | +            var self = this;
 | 
	
		
			
				|  |  | +            var base64Img = 'data:image/png;base64,' + ResCompany.logo;
 | 
	
		
			
				|  |  | +            var hoy = moment().format('DD/MM/YYYY');
 | 
	
		
			
				|  |  | +            var totalPagesExp = "{total_pages_count_string}";
 | 
	
		
			
				|  |  | +            var pdfDoc = new jsPDF(pdf_type);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            /*
 | 
	
		
			
				|  |  | +            ==============================================
 | 
	
		
			
				|  |  | +                PRIMERA COLUMNA
 | 
	
		
			
				|  |  | +            ==============================================
 | 
	
		
			
				|  |  | +            */
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            // Title
 | 
	
		
			
				|  |  | +            pdfDoc.setFontSize(15);
 | 
	
		
			
				|  |  | +            pdfDoc.setFontStyle('bold');
 | 
	
		
			
				|  |  | +            pdfDoc.setTextColor(40);
 | 
	
		
			
				|  |  | +            pdfDoc.text(pdf_title,7,10);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            // DEL
 | 
	
		
			
				|  |  | +            pdfDoc.setFontSize(10);
 | 
	
		
			
				|  |  | +            pdfDoc.setFontStyle('normal');
 | 
	
		
			
				|  |  | +            pdfDoc.setTextColor(40);
 | 
	
		
			
				|  |  | +            pdfDoc.text('DEL: ' + desde,7,20);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            // AL
 | 
	
		
			
				|  |  | +            pdfDoc.setFontSize(10);
 | 
	
		
			
				|  |  | +            pdfDoc.setFontStyle('normal');
 | 
	
		
			
				|  |  | +            pdfDoc.setTextColor(40);
 | 
	
		
			
				|  |  | +            pdfDoc.text('AL: ' + hasta ,7,24);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            /*
 | 
	
		
			
				|  |  | +            ==============================================
 | 
	
		
			
				|  |  | +                SEGUNDA COLUMNA
 | 
	
		
			
				|  |  | +            ==============================================
 | 
	
		
			
				|  |  | +            */
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            // CODIGO DESDE
 | 
	
		
			
				|  |  | +            pdfDoc.setFontSize(10);
 | 
	
		
			
				|  |  | +            pdfDoc.setFontStyle('normal');
 | 
	
		
			
				|  |  | +            pdfDoc.setTextColor(40);
 | 
	
		
			
				|  |  | +            pdfDoc.text('Código Desde: ' + 1 ,50,20);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            // CODIGO HASTA
 | 
	
		
			
				|  |  | +            pdfDoc.setFontSize(10);
 | 
	
		
			
				|  |  | +            pdfDoc.setFontStyle('normal');
 | 
	
		
			
				|  |  | +            pdfDoc.setTextColor(40);
 | 
	
		
			
				|  |  | +            pdfDoc.text('Código Hasta: ' + (row.length - 1),50,24);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            /*
 | 
	
		
			
				|  |  | +            ==============================================
 | 
	
		
			
				|  |  | +                QUINTA COLUMNA
 | 
	
		
			
				|  |  | +            ==============================================
 | 
	
		
			
				|  |  | +            */
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            // Empresa
 | 
	
		
			
				|  |  | +            pdfDoc.setFontSize(10);
 | 
	
		
			
				|  |  | +            pdfDoc.setFontStyle('normal');
 | 
	
		
			
				|  |  | +            pdfDoc.setTextColor(40);
 | 
	
		
			
				|  |  | +            pdfDoc.text('Empresa: ' + ResCompany.name ,100,20);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            // RUC
 | 
	
		
			
				|  |  | +            pdfDoc.setFontSize(10);
 | 
	
		
			
				|  |  | +            pdfDoc.setFontStyle('normal');
 | 
	
		
			
				|  |  | +            pdfDoc.setTextColor(40);
 | 
	
		
			
				|  |  | +            pdfDoc.text('R.U.C: ' + ResCompany.company_ruc ,100,24);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            /*
 | 
	
		
			
				|  |  | +            ==============================================
 | 
	
		
			
				|  |  | +                CREACION DEL PDF
 | 
	
		
			
				|  |  | +            ==============================================
 | 
	
		
			
				|  |  | +            */
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            pdfDoc.autoTable(getColumns, row, {
 | 
	
		
			
				|  |  | +                showHeader: 'false',
 | 
	
		
			
				|  |  | +                theme: 'grid',
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                drawRow: function (row, data) {
 | 
	
		
			
				|  |  | +                    if(pdf_type == "l"){
 | 
	
		
			
				|  |  | +                        if (row.index === 0) {
 | 
	
		
			
				|  |  | +                            pdfDoc.setTextColor(40);
 | 
	
		
			
				|  |  | +                            pdfDoc.setFontSize(8);
 | 
	
		
			
				|  |  | +                            pdfDoc.setFontStyle('bold');
 | 
	
		
			
				|  |  | +                            // Documento
 | 
	
		
			
				|  |  | +                            pdfDoc.rect(data.settings.margin.left, row.y, 52, 8, 'S');
 | 
	
		
			
				|  |  | +                            // Clientes
 | 
	
		
			
				|  |  | +                            pdfDoc.rect(59, row.y, 72, 8, 'S');
 | 
	
		
			
				|  |  | +                            // Total de Ventas
 | 
	
		
			
				|  |  | +                            pdfDoc.rect(131, row.y, 162, 8, 'S');
 | 
	
		
			
				|  |  | +                            pdfDoc.autoTableText("DOCUMENTO", 33, row.y + row.height / 2, {
 | 
	
		
			
				|  |  | +                                halign: 'center',
 | 
	
		
			
				|  |  | +                                valign: 'middle'
 | 
	
		
			
				|  |  | +                            });
 | 
	
		
			
				|  |  | +                            pdfDoc.autoTableText("CLIENTES", 95, row.y + row.height / 2, {
 | 
	
		
			
				|  |  | +                                halign: 'center',
 | 
	
		
			
				|  |  | +                                valign: 'middle'
 | 
	
		
			
				|  |  | +                            });
 | 
	
		
			
				|  |  | +                            pdfDoc.autoTableText("TOTAL DE VENTAS", 210, row.y + row.height / 2, {
 | 
	
		
			
				|  |  | +                                halign: 'center',
 | 
	
		
			
				|  |  | +                                valign: 'middle'
 | 
	
		
			
				|  |  | +                            });
 | 
	
		
			
				|  |  | +                            // NUM
 | 
	
		
			
				|  |  | +                            pdfDoc.rect(data.settings.margin.left, row.y + 8, 31, 8, 'S');
 | 
	
		
			
				|  |  | +                            pdfDoc.autoTableText("NUM", 22, row.y + row.height / 2 + 8, {
 | 
	
		
			
				|  |  | +                                halign: 'center',
 | 
	
		
			
				|  |  | +                                valign: 'middle'
 | 
	
		
			
				|  |  | +                            });
 | 
	
		
			
				|  |  | +                            // FECHA
 | 
	
		
			
				|  |  | +                            pdfDoc.rect(38, row.y + 8, 21, 8, 'S');
 | 
	
		
			
				|  |  | +                            pdfDoc.autoTableText("FECHA", 47, row.y + row.height / 2 + 8, {
 | 
	
		
			
				|  |  | +                                halign: 'center',
 | 
	
		
			
				|  |  | +                                valign: 'middle'
 | 
	
		
			
				|  |  | +                            });
 | 
	
		
			
				|  |  | +                            // RAZON SOCIAL
 | 
	
		
			
				|  |  | +                            pdfDoc.rect(59, row.y + 8, 52, 8, 'S');
 | 
	
		
			
				|  |  | +                            pdfDoc.autoTableText("RAZON SOCIAL", 83, row.y + row.height / 2 + 8, {
 | 
	
		
			
				|  |  | +                                halign: 'center',
 | 
	
		
			
				|  |  | +                                valign: 'middle'
 | 
	
		
			
				|  |  | +                            });
 | 
	
		
			
				|  |  | +                            // RUC
 | 
	
		
			
				|  |  | +                            pdfDoc.rect(111, row.y + 8, 20, 8, 'S');
 | 
	
		
			
				|  |  | +                            pdfDoc.autoTableText("RUC", 120, row.y + row.height / 2 + 8, {
 | 
	
		
			
				|  |  | +                                halign: 'center',
 | 
	
		
			
				|  |  | +                                valign: 'middle'
 | 
	
		
			
				|  |  | +                            });
 | 
	
		
			
				|  |  | +                            // GRAVADAS
 | 
	
		
			
				|  |  | +                            pdfDoc.rect(131, row.y + 8, 28, 8, 'S');
 | 
	
		
			
				|  |  | +                            pdfDoc.autoTableText("GRAVADAS", 145, row.y + row.height / 2 + 8, {
 | 
	
		
			
				|  |  | +                                halign: 'center',
 | 
	
		
			
				|  |  | +                                valign: 'middle'
 | 
	
		
			
				|  |  | +                            });
 | 
	
		
			
				|  |  | +                            // %
 | 
	
		
			
				|  |  | +                            pdfDoc.rect(159, row.y + 8, 9, 8, 'S');
 | 
	
		
			
				|  |  | +                            pdfDoc.autoTableText("%", 163, row.y + row.height / 2 + 8, {
 | 
	
		
			
				|  |  | +                                halign: 'center',
 | 
	
		
			
				|  |  | +                                valign: 'middle'
 | 
	
		
			
				|  |  | +                            });
 | 
	
		
			
				|  |  | +                            // IMPUESTOS
 | 
	
		
			
				|  |  | +                            pdfDoc.rect(168, row.y + 8, 25, 8, 'S');
 | 
	
		
			
				|  |  | +                            pdfDoc.autoTableText("IMPUESTOS", 180, row.y + row.height / 2 + 8, {
 | 
	
		
			
				|  |  | +                                halign: 'center',
 | 
	
		
			
				|  |  | +                                valign: 'middle'
 | 
	
		
			
				|  |  | +                            });
 | 
	
		
			
				|  |  | +                            // EXENTAS
 | 
	
		
			
				|  |  | +                            pdfDoc.rect(193, row.y + 8, 30, 8, 'S');
 | 
	
		
			
				|  |  | +                            pdfDoc.autoTableText("EXENTAS", 209, row.y + row.height / 2 + 8, {
 | 
	
		
			
				|  |  | +                                halign: 'center',
 | 
	
		
			
				|  |  | +                                valign: 'middle'
 | 
	
		
			
				|  |  | +                            });
 | 
	
		
			
				|  |  | +                            // Ret IVA
 | 
	
		
			
				|  |  | +                            pdfDoc.rect(223, row.y + 8, 20, 8, 'S');
 | 
	
		
			
				|  |  | +                            pdfDoc.autoTableText("Ret IVA", 232, row.y + row.height / 2 + 8, {
 | 
	
		
			
				|  |  | +                                halign: 'center',
 | 
	
		
			
				|  |  | +                                valign: 'middle'
 | 
	
		
			
				|  |  | +                            });
 | 
	
		
			
				|  |  | +                            // Ret Renta
 | 
	
		
			
				|  |  | +                            pdfDoc.rect(243, row.y + 8, 20, 8, 'S');
 | 
	
		
			
				|  |  | +                            pdfDoc.autoTableText("Ret RENTA", 253, row.y + row.height / 2 + 8, {
 | 
	
		
			
				|  |  | +                                halign: 'center',
 | 
	
		
			
				|  |  | +                                valign: 'middle'
 | 
	
		
			
				|  |  | +                            });
 | 
	
		
			
				|  |  | +                            // TOTAL
 | 
	
		
			
				|  |  | +                            pdfDoc.rect(263, row.y + 8, 30, 8, 'S');
 | 
	
		
			
				|  |  | +                            pdfDoc.autoTableText("TOTAL", 276, row.y + row.height / 2 + 8, {
 | 
	
		
			
				|  |  | +                                halign: 'center',
 | 
	
		
			
				|  |  | +                                valign: 'middle'
 | 
	
		
			
				|  |  | +                            });
 | 
	
		
			
				|  |  | +                            data.cursor.y += 16;
 | 
	
		
			
				|  |  | +                        };
 | 
	
		
			
				|  |  | +                    }else{
 | 
	
		
			
				|  |  | +                        if (row.index === 0) {
 | 
	
		
			
				|  |  | +                            pdfDoc.setTextColor(40);
 | 
	
		
			
				|  |  | +                            pdfDoc.setFontSize(8);
 | 
	
		
			
				|  |  | +                            pdfDoc.setFontStyle('bold');
 | 
	
		
			
				|  |  | +                            // Documento
 | 
	
		
			
				|  |  | +                            pdfDoc.rect(data.settings.margin.left, row.y, 43, 8, 'S');
 | 
	
		
			
				|  |  | +                            // Clientes
 | 
	
		
			
				|  |  | +                            pdfDoc.rect(50, row.y, 53, 8, 'S');
 | 
	
		
			
				|  |  | +                            // Total de Ventas
 | 
	
		
			
				|  |  | +                            pdfDoc.rect(103, row.y, 100, 8, 'S');
 | 
	
		
			
				|  |  | +                            pdfDoc.autoTableText("DOCUMENTO", 29, row.y + row.height / 2, {
 | 
	
		
			
				|  |  | +                                halign: 'center',
 | 
	
		
			
				|  |  | +                                valign: 'middle'
 | 
	
		
			
				|  |  | +                            });
 | 
	
		
			
				|  |  | +                            pdfDoc.autoTableText("CLIENTES", 77, row.y + row.height / 2, {
 | 
	
		
			
				|  |  | +                                halign: 'center',
 | 
	
		
			
				|  |  | +                                valign: 'middle'
 | 
	
		
			
				|  |  | +                            });
 | 
	
		
			
				|  |  | +                            pdfDoc.autoTableText("TOTAL DE VENTAS",148, row.y + row.height / 2, {
 | 
	
		
			
				|  |  | +                                halign: 'center',
 | 
	
		
			
				|  |  | +                                valign: 'middle'
 | 
	
		
			
				|  |  | +                            });
 | 
	
		
			
				|  |  | +                            // NUM
 | 
	
		
			
				|  |  | +                            pdfDoc.setFontSize(6);
 | 
	
		
			
				|  |  | +                            pdfDoc.rect(data.settings.margin.left, row.y + 8, 27, 8, 'S');
 | 
	
		
			
				|  |  | +                            pdfDoc.autoTableText("NUM", 21, row.y + row.height / 2 + 8, {
 | 
	
		
			
				|  |  | +                                halign: 'center',
 | 
	
		
			
				|  |  | +                                valign: 'middle'
 | 
	
		
			
				|  |  | +                            });
 | 
	
		
			
				|  |  | +                            // FECHA
 | 
	
		
			
				|  |  | +                            pdfDoc.rect(34, row.y + 8, 16, 8, 'S');
 | 
	
		
			
				|  |  | +                            pdfDoc.autoTableText("FECHA", 42, row.y + row.height / 2 + 8, {
 | 
	
		
			
				|  |  | +                                halign: 'center',
 | 
	
		
			
				|  |  | +                                valign: 'middle'
 | 
	
		
			
				|  |  | +                            });
 | 
	
		
			
				|  |  | +                            // RAZON SOCIAL
 | 
	
		
			
				|  |  | +                            pdfDoc.rect(50, row.y + 8, 35, 8, 'S');
 | 
	
		
			
				|  |  | +                            pdfDoc.autoTableText("RAZON SOCIAL", 68, row.y + row.height / 2 + 8, {
 | 
	
		
			
				|  |  | +                                halign: 'center',
 | 
	
		
			
				|  |  | +                                valign: 'middle'
 | 
	
		
			
				|  |  | +                            });
 | 
	
		
			
				|  |  | +                            // RUC
 | 
	
		
			
				|  |  | +                            pdfDoc.rect(85, row.y + 8, 18, 8, 'S');
 | 
	
		
			
				|  |  | +                            pdfDoc.autoTableText("RUC", 95, row.y + row.height / 2 + 8, {
 | 
	
		
			
				|  |  | +                                halign: 'center',
 | 
	
		
			
				|  |  | +                                valign: 'middle'
 | 
	
		
			
				|  |  | +                            });
 | 
	
		
			
				|  |  | +                            // GRAVADAS
 | 
	
		
			
				|  |  | +                            pdfDoc.rect(103, row.y + 8, 20, 8, 'S');
 | 
	
		
			
				|  |  | +                            pdfDoc.autoTableText("GRAVADAS", 113, row.y + row.height / 2 + 8, {
 | 
	
		
			
				|  |  | +                                halign: 'center',
 | 
	
		
			
				|  |  | +                                valign: 'middle'
 | 
	
		
			
				|  |  | +                            });
 | 
	
		
			
				|  |  | +                            // %
 | 
	
		
			
				|  |  | +                            pdfDoc.rect(123, row.y + 8, 5, 8, 'S');
 | 
	
		
			
				|  |  | +                            pdfDoc.autoTableText("%", 126, row.y + row.height / 2 + 8, {
 | 
	
		
			
				|  |  | +                                halign: 'center',
 | 
	
		
			
				|  |  | +                                valign: 'middle'
 | 
	
		
			
				|  |  | +                            });
 | 
	
		
			
				|  |  | +                            // IMPUESTOS
 | 
	
		
			
				|  |  | +                            pdfDoc.rect(128, row.y + 8, 15, 8, 'S');
 | 
	
		
			
				|  |  | +                            pdfDoc.autoTableText("IMPUESTOS", 136, row.y + row.height / 2 + 8, {
 | 
	
		
			
				|  |  | +                                halign: 'center',
 | 
	
		
			
				|  |  | +                                valign: 'middle'
 | 
	
		
			
				|  |  | +                            });
 | 
	
		
			
				|  |  | +                            // EXENTAS
 | 
	
		
			
				|  |  | +                            pdfDoc.rect(143, row.y + 8, 20, 8, 'S');
 | 
	
		
			
				|  |  | +                            pdfDoc.autoTableText("EXENTAS", 152, row.y + row.height / 2 + 8, {
 | 
	
		
			
				|  |  | +                                halign: 'center',
 | 
	
		
			
				|  |  | +                                valign: 'middle'
 | 
	
		
			
				|  |  | +                            });
 | 
	
		
			
				|  |  | +                            // Ret IVA
 | 
	
		
			
				|  |  | +                            pdfDoc.rect(163, row.y + 8, 10, 8, 'S');
 | 
	
		
			
				|  |  | +                            pdfDoc.autoTableText("Ret", 168, row.y + row.height / 2 + 8, {
 | 
	
		
			
				|  |  | +                                halign: 'center',
 | 
	
		
			
				|  |  | +                                valign: 'middle'
 | 
	
		
			
				|  |  | +                            });
 | 
	
		
			
				|  |  | +                            pdfDoc.autoTableText("IVA", 168, row.y + row.height / 2 + 10, {
 | 
	
		
			
				|  |  | +                                halign: 'center',
 | 
	
		
			
				|  |  | +                                valign: 'middle'
 | 
	
		
			
				|  |  | +                            });
 | 
	
		
			
				|  |  | +                            // Ret Renta
 | 
	
		
			
				|  |  | +                            pdfDoc.rect(173, row.y + 8, 10, 8, 'S');
 | 
	
		
			
				|  |  | +                            pdfDoc.autoTableText("Ret", 179, row.y + row.height / 2 + 8, {
 | 
	
		
			
				|  |  | +                                halign: 'center',
 | 
	
		
			
				|  |  | +                                valign: 'middle'
 | 
	
		
			
				|  |  | +                            });
 | 
	
		
			
				|  |  | +                            pdfDoc.autoTableText("RENTA", 178, row.y + row.height / 2 + 10, {
 | 
	
		
			
				|  |  | +                                halign: 'center',
 | 
	
		
			
				|  |  | +                                valign: 'middle'
 | 
	
		
			
				|  |  | +                            });
 | 
	
		
			
				|  |  | +                            // TOTAL
 | 
	
		
			
				|  |  | +                            pdfDoc.rect(183, row.y + 8, 20, 8, 'S');
 | 
	
		
			
				|  |  | +                            pdfDoc.autoTableText("TOTAL", 192, row.y + row.height / 2 + 8, {
 | 
	
		
			
				|  |  | +                                halign: 'center',
 | 
	
		
			
				|  |  | +                                valign: 'middle'
 | 
	
		
			
				|  |  | +                            });
 | 
	
		
			
				|  |  | +                            data.cursor.y += 16;
 | 
	
		
			
				|  |  | +                        };
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                },
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                drawCell: function(cell, data) {
 | 
	
		
			
				|  |  | +                    var rows = data.table.rows;
 | 
	
		
			
				|  |  | +                    if (data.row.index == rows.length - 1) {
 | 
	
		
			
				|  |  | +                        pdfDoc.setFillColor(200, 200, 255);
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                },
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                styles: {
 | 
	
		
			
				|  |  | +                    overflow: 'linebreak',
 | 
	
		
			
				|  |  | +                    columnWidth: 'auto',
 | 
	
		
			
				|  |  | +                    fontSize: 7,
 | 
	
		
			
				|  |  | +                },
 | 
	
		
			
				|  |  | +                headerStyles: {
 | 
	
		
			
				|  |  | +                    fillColor: [76, 133, 248],
 | 
	
		
			
				|  |  | +                    fontSize: 9
 | 
	
		
			
				|  |  | +                },
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                columnStyles: pdf_columnStyles,
 | 
	
		
			
				|  |  | +                margin: { top: 28, horizontal: 7},
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                addPageContent: function (data) {
 | 
	
		
			
				|  |  | +                    /*===========
 | 
	
		
			
				|  |  | +                        FOOTER
 | 
	
		
			
				|  |  | +                    ===========*/
 | 
	
		
			
				|  |  | +                    var str = "Página " + data.pageCount;
 | 
	
		
			
				|  |  | +                    if (typeof pdfDoc.putTotalPages === 'function') {
 | 
	
		
			
				|  |  | +                        str = str + " de " + totalPagesExp;
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                    pdfDoc.setFontSize(9);
 | 
	
		
			
				|  |  | +                    pdfDoc.setFontStyle('bold');
 | 
	
		
			
				|  |  | +                    pdfDoc.setTextColor(40);
 | 
	
		
			
				|  |  | +                    var pageHeight = pdfDoc.internal.pageSize.height || pdfDoc.internal.pageSize.getHeight();
 | 
	
		
			
				|  |  | +                    pdfDoc.text(str, pdfDoc.internal.pageSize.getWidth() - 55, pageHeight - 5);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            });
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            pdfDoc.setFontSize(9);
 | 
	
		
			
				|  |  | +            pdfDoc.setFontStyle('bold');
 | 
	
		
			
				|  |  | +            pdfDoc.setTextColor(40);
 | 
	
		
			
				|  |  | +            pdfDoc.text('Listado concluido', 7, pdfDoc.autoTable.previous.finalY + 5);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            if (typeof pdfDoc.putTotalPages === 'function') {
 | 
	
		
			
				|  |  | +                pdfDoc.putTotalPages(totalPagesExp);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            row.pop();
 | 
	
		
			
				|  |  | +            if(model.printer_bridge){
 | 
	
		
			
				|  |  | +                var data = pdfDoc.output('datauristring');
 | 
	
		
			
				|  |  | +                model.printer_bridge.print(data);
 | 
	
		
			
				|  |  | +                return;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            pdfDoc.save(pdf_name + hoy + '.pdf');
 | 
	
		
			
				|  |  | +        },
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        drawWithDetails: function (getColumns,row,ResCompany,pdf_title,pdf_type,pdf_name,pdf_columnStyles,amount) {
 | 
	
		
			
				|  |  | +            var self = this;
 | 
	
		
			
				|  |  | +            var base64Img = 'data:image/png;base64,' + ResCompany.logo;
 | 
	
		
			
				|  |  | +            var hoy = moment().format('DD/MM/YYYY');
 | 
	
		
			
				|  |  | +            var totalPagesExp = "{total_pages_count_string}";
 | 
	
		
			
				|  |  | +            var pdfDoc = new jsPDF(pdf_type);
 | 
	
		
			
				|  |  | +            var title = [];
 | 
	
		
			
				|  |  | +            title.push({
 | 
	
		
			
				|  |  | +                title : 'Metodo de Pago',
 | 
	
		
			
				|  |  | +                dataKey: 'name',
 | 
	
		
			
				|  |  | +                align: 'left',
 | 
	
		
			
				|  |  | +            });
 | 
	
		
			
				|  |  | +            title.push({
 | 
	
		
			
				|  |  | +                title : 'Monto',
 | 
	
		
			
				|  |  | +                dataKey: 'amount',
 | 
	
		
			
				|  |  | +                align: 'right',
 | 
	
		
			
				|  |  | +            });
 | 
	
		
			
				|  |  | +            var i = 0;
 | 
	
		
			
				|  |  | +            var position = 25;
 | 
	
		
			
				|  |  | +            _.each(row, function(item){
 | 
	
		
			
				|  |  | +                var docItem = [];
 | 
	
		
			
				|  |  | +                if(item.info != 'undefined'){
 | 
	
		
			
				|  |  | +                    _.each(item.info, function(index){
 | 
	
		
			
				|  |  | +                        docItem.push({
 | 
	
		
			
				|  |  | +                            name: index.journal,
 | 
	
		
			
				|  |  | +                            amount: index.amount_total
 | 
	
		
			
				|  |  | +                        });
 | 
	
		
			
				|  |  | +                    });
 | 
	
		
			
				|  |  | +                };
 | 
	
		
			
				|  |  | +                docItem.push({
 | 
	
		
			
				|  |  | +                    name: 'Total',
 | 
	
		
			
				|  |  | +                    amount: item.amount_total
 | 
	
		
			
				|  |  | +                });
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                if(row.length <= 2 & row.length == i+1){
 | 
	
		
			
				|  |  | +                    return false;
 | 
	
		
			
				|  |  | +                };
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                if(i > 0){
 | 
	
		
			
				|  |  | +                    let first = pdfDoc.autoTable.previous;
 | 
	
		
			
				|  |  | +                    position = first.finalY + 7;
 | 
	
		
			
				|  |  | +                    pdfDoc.rect(7, position - 7, 196, 10, 'S');
 | 
	
		
			
				|  |  | +                };
 | 
	
		
			
				|  |  | +                pdfDoc.setFontSize(10);
 | 
	
		
			
				|  |  | +                pdfDoc.autoTableText(item.store, 102, position - 3, {
 | 
	
		
			
				|  |  | +                    halign: 'center',
 | 
	
		
			
				|  |  | +                    valign: 'middle'
 | 
	
		
			
				|  |  | +                });
 | 
	
		
			
				|  |  | +                pdfDoc.autoTable(title, docItem, {
 | 
	
		
			
				|  |  | +                    showHeader: false,
 | 
	
		
			
				|  |  | +                    startY: position,
 | 
	
		
			
				|  |  | +                    theme: 'grid',
 | 
	
		
			
				|  |  | +                    styles: {
 | 
	
		
			
				|  |  | +                        overflow: 'linebreak',
 | 
	
		
			
				|  |  | +                        columnWidth: 'auto',
 | 
	
		
			
				|  |  | +                        fontSize: 7,
 | 
	
		
			
				|  |  | +                    },
 | 
	
		
			
				|  |  | +                    headerStyles: {
 | 
	
		
			
				|  |  | +                        fillColor: [76, 133, 248],
 | 
	
		
			
				|  |  | +                        fontSize: 9
 | 
	
		
			
				|  |  | +                    },
 | 
	
		
			
				|  |  | +                    columnStyles: {
 | 
	
		
			
				|  |  | +                        name:{halign:'left'},
 | 
	
		
			
				|  |  | +                        amount:{columnWidth: 50, halign:'right'},
 | 
	
		
			
				|  |  | +                    },
 | 
	
		
			
				|  |  | +                    margin: { horizontal: 7},
 | 
	
		
			
				|  |  | +                    drawCell: function(cell, data) {
 | 
	
		
			
				|  |  | +                        var rows = data.table.rows;
 | 
	
		
			
				|  |  | +                        if (data.row.index == rows.length - 1) {
 | 
	
		
			
				|  |  | +                            pdfDoc.setFontStyle('bold');
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                    },
 | 
	
		
			
				|  |  | +                    addPageContent: function (data) {
 | 
	
		
			
				|  |  | +                        if(i == 0){
 | 
	
		
			
				|  |  | +                            pdfDoc.addImage(base64Img, 'png', 7, 2, 0, 15);
 | 
	
		
			
				|  |  | +                            if(pdf_type == 'l'){
 | 
	
		
			
				|  |  | +                                pdfDoc.setFontSize(12);
 | 
	
		
			
				|  |  | +                                pdfDoc.setFontStyle('bold');
 | 
	
		
			
				|  |  | +                                pdfDoc.setTextColor(40);
 | 
	
		
			
				|  |  | +                                pdfDoc.text(pdf_title,130,10);
 | 
	
		
			
				|  |  | +                            }else{
 | 
	
		
			
				|  |  | +                                pdfDoc.setFontSize(12);
 | 
	
		
			
				|  |  | +                                pdfDoc.setFontStyle('bold');
 | 
	
		
			
				|  |  | +                                pdfDoc.setTextColor(40);
 | 
	
		
			
				|  |  | +                                pdfDoc.text(pdf_title,80,10);
 | 
	
		
			
				|  |  | +                            }
 | 
	
		
			
				|  |  | +                            pdfDoc.setFontSize(9);
 | 
	
		
			
				|  |  | +                            pdfDoc.setFontStyle('normal');
 | 
	
		
			
				|  |  | +                            pdfDoc.setTextColor(40)
 | 
	
		
			
				|  |  | +                            pdfDoc.text(pdfDoc.internal.pageSize.getWidth() - 55, 14," Fecha de Expedición: " + hoy);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                            /*===========
 | 
	
		
			
				|  |  | +                                FOOTER
 | 
	
		
			
				|  |  | +                            ===========*/
 | 
	
		
			
				|  |  | +                            var str = "Página " + data.pageCount;
 | 
	
		
			
				|  |  | +                            if (typeof pdfDoc.putTotalPages === 'function') {
 | 
	
		
			
				|  |  | +                                str = str + " de " + totalPagesExp;
 | 
	
		
			
				|  |  | +                            }
 | 
	
		
			
				|  |  | +                            pdfDoc.setFontSize(9);
 | 
	
		
			
				|  |  | +                            pdfDoc.setFontStyle('bold');
 | 
	
		
			
				|  |  | +                            pdfDoc.setTextColor(40);
 | 
	
		
			
				|  |  | +                            var pageHeight = pdfDoc.internal.pageSize.height || pdfDoc.internal.pageSize.getHeight();
 | 
	
		
			
				|  |  | +                            pdfDoc.text(str, pdfDoc.internal.pageSize.getWidth() - 55, pageHeight - 5);
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                });
 | 
	
		
			
				|  |  | +                i++;
 | 
	
		
			
				|  |  | +            });
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            if (typeof pdfDoc.putTotalPages === 'function') {
 | 
	
		
			
				|  |  | +                pdfDoc.putTotalPages(totalPagesExp);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            // row.pop();
 | 
	
		
			
				|  |  | +            if(model.printer_bridge){
 | 
	
		
			
				|  |  | +                var data = pdfDoc.output('datauristring');
 | 
	
		
			
				|  |  | +                model.printer_bridge.print(data);
 | 
	
		
			
				|  |  | +                return;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            pdfDoc.save(pdf_name + hoy + '.pdf');
 | 
	
		
			
				|  |  | +        },
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        drawProfitAndLossPDF: function (
 | 
	
		
			
				|  |  | +            getColumns,
 | 
	
		
			
				|  |  | +            row,
 | 
	
		
			
				|  |  | +            ResCompany,
 | 
	
		
			
				|  |  | +            pdf_title,
 | 
	
		
			
				|  |  | +            pdf_type,
 | 
	
		
			
				|  |  | +            pdf_name,
 | 
	
		
			
				|  |  | +            amount
 | 
	
		
			
				|  |  | +            ) {
 | 
	
		
			
				|  |  | +            var self = this;
 | 
	
		
			
				|  |  | +            var sale = [];
 | 
	
		
			
				|  |  | +            var expense = [];
 | 
	
		
			
				|  |  | +            var column = [];
 | 
	
		
			
				|  |  | +            var base64Img = 'data:image/png;base64,' + ResCompany.logo;
 | 
	
		
			
				|  |  | +            var hoy = moment().format('DD/MM/YYYY');
 | 
	
		
			
				|  |  | +            var totalPagesExp = "{total_pages_count_string}";
 | 
	
		
			
				|  |  | +            var pdfDoc = new jsPDF(pdf_type);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            /*
 | 
	
		
			
				|  |  | +            ============================
 | 
	
		
			
				|  |  | +                VENTAS
 | 
	
		
			
				|  |  | +            ============================
 | 
	
		
			
				|  |  | +            */
 | 
	
		
			
				|  |  | +            var coste = 0;
 | 
	
		
			
				|  |  | +            var profit = 0;
 | 
	
		
			
				|  |  | +            _.each(row, function(item){
 | 
	
		
			
				|  |  | +                if(item.type == 'sale'){
 | 
	
		
			
				|  |  | +                    sale.push({
 | 
	
		
			
				|  |  | +                        name : item.store,
 | 
	
		
			
				|  |  | +                        total : item.amount_total,
 | 
	
		
			
				|  |  | +                    });
 | 
	
		
			
				|  |  | +                };
 | 
	
		
			
				|  |  | +                if(item.expense == true){
 | 
	
		
			
				|  |  | +                    coste = item.amount_total;
 | 
	
		
			
				|  |  | +                };
 | 
	
		
			
				|  |  | +                if(item.profit == true){
 | 
	
		
			
				|  |  | +                    profit = item.amount_total;
 | 
	
		
			
				|  |  | +                };
 | 
	
		
			
				|  |  | +                if(item.expense_detail == true){
 | 
	
		
			
				|  |  | +                    expense.push({
 | 
	
		
			
				|  |  | +                        name : item.store,
 | 
	
		
			
				|  |  | +                        total : item.amount_total,
 | 
	
		
			
				|  |  | +                    });
 | 
	
		
			
				|  |  | +                };
 | 
	
		
			
				|  |  | +            });
 | 
	
		
			
				|  |  | +            column.push({
 | 
	
		
			
				|  |  | +                title : 'Name',
 | 
	
		
			
				|  |  | +                dataKey: 'name',
 | 
	
		
			
				|  |  | +                align: 'left',
 | 
	
		
			
				|  |  | +            });
 | 
	
		
			
				|  |  | +            column.push({
 | 
	
		
			
				|  |  | +                title : 'total',
 | 
	
		
			
				|  |  | +                dataKey: 'total',
 | 
	
		
			
				|  |  | +                align: 'right',
 | 
	
		
			
				|  |  | +            });
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            /*
 | 
	
		
			
				|  |  | +            ==============================
 | 
	
		
			
				|  |  | +                LOGO
 | 
	
		
			
				|  |  | +            ==============================
 | 
	
		
			
				|  |  | +            */
 | 
	
		
			
				|  |  | +            pdfDoc.addImage(base64Img, 'png', 10, 10, 0, 20);
 | 
	
		
			
				|  |  | +            /*
 | 
	
		
			
				|  |  | +            ==============================
 | 
	
		
			
				|  |  | +                FECHA
 | 
	
		
			
				|  |  | +            ==============================
 | 
	
		
			
				|  |  | +            */
 | 
	
		
			
				|  |  | +            pdfDoc.setFontSize(13);
 | 
	
		
			
				|  |  | +            pdfDoc.setFontStyle('normal');
 | 
	
		
			
				|  |  | +            pdfDoc.setTextColor(40)
 | 
	
		
			
				|  |  | +            pdfDoc.text(pdfDoc.internal.pageSize.getWidth() - 32, 12,hoy);
 | 
	
		
			
				|  |  | +            /*
 | 
	
		
			
				|  |  | +            ==============================
 | 
	
		
			
				|  |  | +                TITULO
 | 
	
		
			
				|  |  | +            ==============================
 | 
	
		
			
				|  |  | +            */
 | 
	
		
			
				|  |  | +            pdfDoc.setFontSize(15);
 | 
	
		
			
				|  |  | +            pdfDoc.setFontStyle('bold');
 | 
	
		
			
				|  |  | +            pdfDoc.setTextColor('#0288d1');
 | 
	
		
			
				|  |  | +            pdfDoc.text(pdfDoc.internal.pageSize.getWidth() - 75, 18, pdf_title);
 | 
	
		
			
				|  |  | +            /*
 | 
	
		
			
				|  |  | +            ==============================
 | 
	
		
			
				|  |  | +                DESCRIPCION
 | 
	
		
			
				|  |  | +            ==============================
 | 
	
		
			
				|  |  | +            */
 | 
	
		
			
				|  |  | +            pdfDoc.setFontSize(10);
 | 
	
		
			
				|  |  | +            pdfDoc.setFontStyle('bold');
 | 
	
		
			
				|  |  | +            pdfDoc.setTextColor('#424242');
 | 
	
		
			
				|  |  | +            pdfDoc.text(10, 38, 'Descripción');
 | 
	
		
			
				|  |  | +            /*
 | 
	
		
			
				|  |  | +            ==============================
 | 
	
		
			
				|  |  | +                LINEA
 | 
	
		
			
				|  |  | +            ==============================
 | 
	
		
			
				|  |  | +            */
 | 
	
		
			
				|  |  | +            pdfDoc.setLineWidth(0.5);
 | 
	
		
			
				|  |  | +            pdfDoc.setDrawColor('#424242');
 | 
	
		
			
				|  |  | +            pdfDoc.line(10, 40, pdfDoc.internal.pageSize.getWidth() - 10 , 40);
 | 
	
		
			
				|  |  | +            /*
 | 
	
		
			
				|  |  | +            ==============================
 | 
	
		
			
				|  |  | +                VENTAS
 | 
	
		
			
				|  |  | +            ==============================
 | 
	
		
			
				|  |  | +            */
 | 
	
		
			
				|  |  | +            pdfDoc.setFontSize(10);
 | 
	
		
			
				|  |  | +            pdfDoc.setFontStyle('bold');
 | 
	
		
			
				|  |  | +            pdfDoc.setTextColor('#424242');
 | 
	
		
			
				|  |  | +            pdfDoc.text(10, 45, 'VENTAS');
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            /*
 | 
	
		
			
				|  |  | +            ==============================
 | 
	
		
			
				|  |  | +                PRIMERA TABLA
 | 
	
		
			
				|  |  | +            ==============================
 | 
	
		
			
				|  |  | +            */
 | 
	
		
			
				|  |  | +            pdfDoc.autoTable(column, sale, {
 | 
	
		
			
				|  |  | +                showHeader: false,
 | 
	
		
			
				|  |  | +                theme: 'plain',
 | 
	
		
			
				|  |  | +                styles: {
 | 
	
		
			
				|  |  | +                    overflow: 'linebreak',
 | 
	
		
			
				|  |  | +                    columnWidth: 'auto',
 | 
	
		
			
				|  |  | +                    fontSize: 9,
 | 
	
		
			
				|  |  | +                },
 | 
	
		
			
				|  |  | +                columnStyles: {
 | 
	
		
			
				|  |  | +                    amount:{halign:'left'},
 | 
	
		
			
				|  |  | +                    total:{columnWidth: 50, halign:'right'},
 | 
	
		
			
				|  |  | +                },
 | 
	
		
			
				|  |  | +                margin: { top: 48, horizontal: 20},
 | 
	
		
			
				|  |  | +                drawCell: function(cell, data) {
 | 
	
		
			
				|  |  | +                    var rows = data.table.rows;
 | 
	
		
			
				|  |  | +                    if (data.row.index == rows.length - 1) {
 | 
	
		
			
				|  |  | +                        pdfDoc.setTextColor('#0288d1');
 | 
	
		
			
				|  |  | +                        pdfDoc.setFontStyle('bold');
 | 
	
		
			
				|  |  | +                    };
 | 
	
		
			
				|  |  | +                },
 | 
	
		
			
				|  |  | +            });
 | 
	
		
			
				|  |  | +            /*
 | 
	
		
			
				|  |  | +            ==============================
 | 
	
		
			
				|  |  | +                LINEA
 | 
	
		
			
				|  |  | +            ==============================
 | 
	
		
			
				|  |  | +            */
 | 
	
		
			
				|  |  | +            pdfDoc.setLineWidth(0.5);
 | 
	
		
			
				|  |  | +            pdfDoc.setDrawColor('#424242');
 | 
	
		
			
				|  |  | +            pdfDoc.line(10, pdfDoc.autoTable.previous.finalY + 1, pdfDoc.internal.pageSize.getWidth() - 10 , pdfDoc.autoTable.previous.finalY + 1);
 | 
	
		
			
				|  |  | +            /*
 | 
	
		
			
				|  |  | +            ==============================
 | 
	
		
			
				|  |  | +                COSTE DE VENTAS
 | 
	
		
			
				|  |  | +            ==============================
 | 
	
		
			
				|  |  | +            */
 | 
	
		
			
				|  |  | +            pdfDoc.setFontSize(10);
 | 
	
		
			
				|  |  | +            pdfDoc.setFontStyle('bold');
 | 
	
		
			
				|  |  | +            pdfDoc.setTextColor('#424242');
 | 
	
		
			
				|  |  | +            pdfDoc.text(10, pdfDoc.autoTable.previous.finalY + 7, 'Coste de ventas');
 | 
	
		
			
				|  |  | +            /*
 | 
	
		
			
				|  |  | +            ==============================
 | 
	
		
			
				|  |  | +                COSTE DE VENTAS - valor
 | 
	
		
			
				|  |  | +            ==============================
 | 
	
		
			
				|  |  | +            */
 | 
	
		
			
				|  |  | +            pdfDoc.setFontSize(10);
 | 
	
		
			
				|  |  | +            pdfDoc.setFontStyle('bold');
 | 
	
		
			
				|  |  | +            pdfDoc.setTextColor('#424242');
 | 
	
		
			
				|  |  | +            pdfDoc.text(pdfDoc.internal.pageSize.getWidth() - 35, pdfDoc.autoTable.previous.finalY + 7, coste);
 | 
	
		
			
				|  |  | +            /*
 | 
	
		
			
				|  |  | +            ==============================
 | 
	
		
			
				|  |  | +                LINEA
 | 
	
		
			
				|  |  | +            ==============================
 | 
	
		
			
				|  |  | +            */
 | 
	
		
			
				|  |  | +            pdfDoc.setLineWidth(0.5);
 | 
	
		
			
				|  |  | +            pdfDoc.setDrawColor('#424242');
 | 
	
		
			
				|  |  | +            pdfDoc.line(10, pdfDoc.autoTable.previous.finalY + 10, pdfDoc.internal.pageSize.getWidth() - 10 , pdfDoc.autoTable.previous.finalY + 10);
 | 
	
		
			
				|  |  | +            /*
 | 
	
		
			
				|  |  | +            ==============================
 | 
	
		
			
				|  |  | +                BENEFICIO
 | 
	
		
			
				|  |  | +            ==============================
 | 
	
		
			
				|  |  | +            */
 | 
	
		
			
				|  |  | +            pdfDoc.setFontSize(10);
 | 
	
		
			
				|  |  | +            pdfDoc.setFontStyle('bold');
 | 
	
		
			
				|  |  | +            pdfDoc.setTextColor(40);
 | 
	
		
			
				|  |  | +            pdfDoc.text(10, pdfDoc.autoTable.previous.finalY + 15, 'BENEFICIO BRUTO');
 | 
	
		
			
				|  |  | +            /*
 | 
	
		
			
				|  |  | +            ==============================
 | 
	
		
			
				|  |  | +                BENEFICIO - valor
 | 
	
		
			
				|  |  | +            ==============================
 | 
	
		
			
				|  |  | +            */
 | 
	
		
			
				|  |  | +            pdfDoc.setFontSize(10);
 | 
	
		
			
				|  |  | +            pdfDoc.setFontStyle('bold');
 | 
	
		
			
				|  |  | +            pdfDoc.setTextColor('#0288d1');
 | 
	
		
			
				|  |  | +            pdfDoc.text(pdfDoc.internal.pageSize.getWidth() - 35, pdfDoc.autoTable.previous.finalY + 15, profit);
 | 
	
		
			
				|  |  | +            /*
 | 
	
		
			
				|  |  | +            ==============================
 | 
	
		
			
				|  |  | +                SEGUNDA TABLA
 | 
	
		
			
				|  |  | +            ==============================
 | 
	
		
			
				|  |  | +            */
 | 
	
		
			
				|  |  | +            var dynamic_top = pdfDoc.autoTable.previous.finalY + 25;
 | 
	
		
			
				|  |  | +            pdfDoc.autoTable(column, expense, {
 | 
	
		
			
				|  |  | +                showHeader: false,
 | 
	
		
			
				|  |  | +                theme: 'plain',
 | 
	
		
			
				|  |  | +                styles: {
 | 
	
		
			
				|  |  | +                    overflow: 'linebreak',
 | 
	
		
			
				|  |  | +                    columnWidth: 'auto',
 | 
	
		
			
				|  |  | +                    fontSize: 9,
 | 
	
		
			
				|  |  | +                },
 | 
	
		
			
				|  |  | +                columnStyles: {
 | 
	
		
			
				|  |  | +                    amount:{halign:'left'},
 | 
	
		
			
				|  |  | +                    total:{columnWidth: 50, halign:'right'},
 | 
	
		
			
				|  |  | +                },
 | 
	
		
			
				|  |  | +                startY: pdfDoc.autoTable.previous.finalY + 25,
 | 
	
		
			
				|  |  | +                margin: {
 | 
	
		
			
				|  |  | +                    horizontal: 20
 | 
	
		
			
				|  |  | +                },
 | 
	
		
			
				|  |  | +                drawCell: function(cell, data) {
 | 
	
		
			
				|  |  | +                    var rows = data.table.rows;
 | 
	
		
			
				|  |  | +                    if (data.row.index == rows.length - 1) {
 | 
	
		
			
				|  |  | +                        pdfDoc.setTextColor('#0288d1');
 | 
	
		
			
				|  |  | +                        pdfDoc.setFontStyle('bold');
 | 
	
		
			
				|  |  | +                    };
 | 
	
		
			
				|  |  | +                },
 | 
	
		
			
				|  |  | +                addPageContent: function (data) {
 | 
	
		
			
				|  |  | +                    /*===========
 | 
	
		
			
				|  |  | +                        FOOTER
 | 
	
		
			
				|  |  | +                    ===========*/
 | 
	
		
			
				|  |  | +                    var str = "Página " + data.pageCount;
 | 
	
		
			
				|  |  | +                    if (typeof pdfDoc.putTotalPages === 'function') {
 | 
	
		
			
				|  |  | +                        str = str + " de " + totalPagesExp;
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                    pdfDoc.setFontSize(9);
 | 
	
		
			
				|  |  | +                    pdfDoc.setFontStyle('bold');
 | 
	
		
			
				|  |  | +                    pdfDoc.setTextColor(40);
 | 
	
		
			
				|  |  | +                    var pageHeight = pdfDoc.internal.pageSize.height || pdfDoc.internal.pageSize.getHeight();
 | 
	
		
			
				|  |  | +                    pdfDoc.text(str, pdfDoc.internal.pageSize.getWidth() - 55, pageHeight - 5);
 | 
	
		
			
				|  |  | +                },
 | 
	
		
			
				|  |  | +            });
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            /*
 | 
	
		
			
				|  |  | +            ==============================
 | 
	
		
			
				|  |  | +                LINEA
 | 
	
		
			
				|  |  | +            ==============================
 | 
	
		
			
				|  |  | +            */
 | 
	
		
			
				|  |  | +            pdfDoc.setLineWidth(0.5);
 | 
	
		
			
				|  |  | +            pdfDoc.setDrawColor('#424242');
 | 
	
		
			
				|  |  | +            pdfDoc.line(10, pdfDoc.autoTable.previous.finalY + 10, pdfDoc.internal.pageSize.getWidth() - 10 , pdfDoc.autoTable.previous.finalY + 10);
 | 
	
		
			
				|  |  | +            /*
 | 
	
		
			
				|  |  | +            ==============================
 | 
	
		
			
				|  |  | +                RESULTADO
 | 
	
		
			
				|  |  | +            ==============================
 | 
	
		
			
				|  |  | +            */
 | 
	
		
			
				|  |  | +            pdfDoc.setFontSize(10);
 | 
	
		
			
				|  |  | +            pdfDoc.setFontStyle('bold');
 | 
	
		
			
				|  |  | +            pdfDoc.setTextColor(40);
 | 
	
		
			
				|  |  | +            pdfDoc.text(10, pdfDoc.autoTable.previous.finalY + 15, 'RESULTADO');
 | 
	
		
			
				|  |  | +            /*
 | 
	
		
			
				|  |  | +            ==============================
 | 
	
		
			
				|  |  | +                VALOR FINAL
 | 
	
		
			
				|  |  | +            ==============================
 | 
	
		
			
				|  |  | +            */
 | 
	
		
			
				|  |  | +            pdfDoc.setFontSize(10);
 | 
	
		
			
				|  |  | +            pdfDoc.setFontStyle('bold');
 | 
	
		
			
				|  |  | +            pdfDoc.setTextColor('#0288d1');
 | 
	
		
			
				|  |  | +            pdfDoc.text(pdfDoc.internal.pageSize.getWidth() - 35, pdfDoc.autoTable.previous.finalY + 15, amount);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            if (typeof pdfDoc.putTotalPages === 'function') {
 | 
	
		
			
				|  |  | +                pdfDoc.putTotalPages(totalPagesExp);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            if(model.printer_bridge){
 | 
	
		
			
				|  |  | +                var data = pdfDoc.output('datauristring');
 | 
	
		
			
				|  |  | +                model.printer_bridge.print(data);
 | 
	
		
			
				|  |  | +                return;
 | 
	
		
			
				|  |  | +            };
 | 
	
		
			
				|  |  | +            pdfDoc.save(pdf_name + hoy + '.pdf');
 | 
	
		
			
				|  |  | +        },
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        getPDFFileButton: function  () {
 | 
	
		
			
				|  |  | +            var canvas = $(".reporting-chart").get(0);
 | 
	
		
			
				|  |  | +            var dataURL = canvas.toDataURL();
 | 
	
		
			
				|  |  | +            var pdf = new jsPDF();
 | 
	
		
			
				|  |  | +            pdf.addImage(dataURL, 'JPEG', 10, 10, 190, 70);
 | 
	
		
			
				|  |  | +            pdf.save("chart.pdf");
 | 
	
		
			
				|  |  | +        },
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        // pdf resumen de ventas diarias cod:3
 | 
	
		
			
				|  |  | +        drawPdf3: function (row,ResCompany,pdf_title,pdf_type,pdf_name,pdf_columnStyles,filter) {
 | 
	
		
			
				|  |  | +          var self = this;
 | 
	
		
			
				|  |  | +          var base64Img = 'data:image/png;base64,' + ResCompany.logo;
 | 
	
		
			
				|  |  | +          var hoy = moment().format('DD/MM/YYYY');
 | 
	
		
			
				|  |  | +          var totalPagesExp = "{total_pages_count_string}";
 | 
	
		
			
				|  |  | +          var pdfDoc = new jsPDF(pdf_type);
 | 
	
		
			
				|  |  | +          var title = [];
 | 
	
		
			
				|  |  | +          var currentpage = 0;
 | 
	
		
			
				|  |  | +          var i = 0;
 | 
	
		
			
				|  |  | +          var position = 27;
 | 
	
		
			
				|  |  | +          var y_position2 = 27;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +          title.push({
 | 
	
		
			
				|  |  | +            title : 'Fecha',
 | 
	
		
			
				|  |  | +            dataKey: 'date',
 | 
	
		
			
				|  |  | +            align: 'center',
 | 
	
		
			
				|  |  | +          });
 | 
	
		
			
				|  |  | +          title.push({
 | 
	
		
			
				|  |  | +            title : 'Sucursal',
 | 
	
		
			
				|  |  | +            dataKey: 'store',
 | 
	
		
			
				|  |  | +            align: 'center',
 | 
	
		
			
				|  |  | +          });
 | 
	
		
			
				|  |  | +          title.push({
 | 
	
		
			
				|  |  | +            title : 'Cantidad',
 | 
	
		
			
				|  |  | +            dataKey: 'qty',
 | 
	
		
			
				|  |  | +            align: 'center',
 | 
	
		
			
				|  |  | +          });
 | 
	
		
			
				|  |  | +          title.push({
 | 
	
		
			
				|  |  | +            title : 'Monto de Venta',
 | 
	
		
			
				|  |  | +            dataKey: 'price',
 | 
	
		
			
				|  |  | +            align: 'right',
 | 
	
		
			
				|  |  | +          });
 | 
	
		
			
				|  |  | +          title.push({
 | 
	
		
			
				|  |  | +            title : 'Promedio de Venta Total',
 | 
	
		
			
				|  |  | +            dataKey: 'average',
 | 
	
		
			
				|  |  | +            align: 'right',
 | 
	
		
			
				|  |  | +          });
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +          //LOGO
 | 
	
		
			
				|  |  | +          pdfDoc.addImage(base64Img, 'png', 7, 2, 0, 15);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +          //FECHA
 | 
	
		
			
				|  |  | +          pdfDoc.setFontSize(13);
 | 
	
		
			
				|  |  | +          pdfDoc.setFontStyle('normal');
 | 
	
		
			
				|  |  | +          pdfDoc.setTextColor(40)
 | 
	
		
			
				|  |  | +          pdfDoc.text(pdfDoc.internal.pageSize.getWidth() - 35, 12,hoy);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +          //TITULO
 | 
	
		
			
				|  |  | +          pdfDoc.setFontSize(15);
 | 
	
		
			
				|  |  | +          pdfDoc.setFontStyle('bold');
 | 
	
		
			
				|  |  | +          pdfDoc.setTextColor('#0288d1');
 | 
	
		
			
				|  |  | +          pdfDoc.autoTableText(pdf_title, pdfDoc.internal.pageSize.getWidth() - 12, 18, {
 | 
	
		
			
				|  |  | +            halign: 'right',
 | 
	
		
			
				|  |  | +            valign: 'middle'
 | 
	
		
			
				|  |  | +          });
 | 
	
		
			
				|  |  | +          pdfDoc.setLineWidth(0.5);
 | 
	
		
			
				|  |  | +          pdfDoc.setDrawColor('#424242');
 | 
	
		
			
				|  |  | +          pdfDoc.line(10, 22, pdfDoc.internal.pageSize.getWidth() - 10 , 22);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +          var ii=0;
 | 
	
		
			
				|  |  | +          if(pdf_type == 'l'){
 | 
	
		
			
				|  |  | +            var col1_title = 15;
 | 
	
		
			
				|  |  | +            var col1_value = 55;
 | 
	
		
			
				|  |  | +            var col2_title = 150;
 | 
	
		
			
				|  |  | +            var col2_value = 190;
 | 
	
		
			
				|  |  | +          }
 | 
	
		
			
				|  |  | +          else{
 | 
	
		
			
				|  |  | +            var col1_title = 10;
 | 
	
		
			
				|  |  | +            var col1_value = 50;
 | 
	
		
			
				|  |  | +            var col2_title = 110;
 | 
	
		
			
				|  |  | +            var col2_value = 150;
 | 
	
		
			
				|  |  | +          }
 | 
	
		
			
				|  |  | +          if(filter.length >0){
 | 
	
		
			
				|  |  | +            _.each(filter,function(item){
 | 
	
		
			
				|  |  | +              if(ii<4){
 | 
	
		
			
				|  |  | +                self.addFilter(pdfDoc,item.title,item.value,col1_title,col1_value,position);
 | 
	
		
			
				|  |  | +                position = position + 5;
 | 
	
		
			
				|  |  | +              }else{
 | 
	
		
			
				|  |  | +                self.addFilter(pdfDoc,item.title,item.value,col2_title,col2_value,y_position2);
 | 
	
		
			
				|  |  | +                y_position2 = y_position2 + 5;
 | 
	
		
			
				|  |  | +              }
 | 
	
		
			
				|  |  | +                ii++;
 | 
	
		
			
				|  |  | +            });
 | 
	
		
			
				|  |  | +            pdfDoc.setLineWidth(0.5);
 | 
	
		
			
				|  |  | +            pdfDoc.setDrawColor('#424242');
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            if(position >= y_position2){
 | 
	
		
			
				|  |  | +              position = position;
 | 
	
		
			
				|  |  | +              pdfDoc.line(10, position, pdfDoc.internal.pageSize.getWidth() - 10 , position);
 | 
	
		
			
				|  |  | +            }else{
 | 
	
		
			
				|  |  | +              position = y_position2;
 | 
	
		
			
				|  |  | +              pdfDoc.line(10, y_position2, pdfDoc.internal.pageSize.getWidth() - 10 , y_position2);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +          }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +          _.each(row, function(item){
 | 
	
		
			
				|  |  | +            if(i > 0){
 | 
	
		
			
				|  |  | +              let first = pdfDoc.autoTable.previous;
 | 
	
		
			
				|  |  | +              position = first.finalY + 5;
 | 
	
		
			
				|  |  | +            };
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            var docItem = [];
 | 
	
		
			
				|  |  | +            if(item.info != 'undefined'){
 | 
	
		
			
				|  |  | +              _.each(item.info, function(index){
 | 
	
		
			
				|  |  | +                docItem.push({
 | 
	
		
			
				|  |  | +                  date: index.date,
 | 
	
		
			
				|  |  | +                  store: index.store,
 | 
	
		
			
				|  |  | +                  qty: index.qty,
 | 
	
		
			
				|  |  | +                  price: index.price,
 | 
	
		
			
				|  |  | +                  average: index.average,
 | 
	
		
			
				|  |  | +                })
 | 
	
		
			
				|  |  | +              });
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            pdfDoc.setDrawColor(0);
 | 
	
		
			
				|  |  | +            pdfDoc.setFillColor(76, 133, 248);
 | 
	
		
			
				|  |  | +            pdfDoc.rect(7, position+5, 196, 8, 'F');
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            pdfDoc.setFontSize(9);
 | 
	
		
			
				|  |  | +            pdfDoc.setTextColor(255,255,255)
 | 
	
		
			
				|  |  | +            pdfDoc.setFontStyle('bold');
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            pdfDoc.autoTableText('Vendedor: ', 15, position+9, {
 | 
	
		
			
				|  |  | +              halign: 'left',
 | 
	
		
			
				|  |  | +              valign: 'middle'
 | 
	
		
			
				|  |  | +            });
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            pdfDoc.autoTableText(item.user, 33, position+9, {
 | 
	
		
			
				|  |  | +              halign: 'left',
 | 
	
		
			
				|  |  | +              valign: 'middle'
 | 
	
		
			
				|  |  | +            });
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            pdfDoc.autoTableText('Cantidad: ', 110, position+9, {
 | 
	
		
			
				|  |  | +              halign: 'left',
 | 
	
		
			
				|  |  | +              valign: 'middle'
 | 
	
		
			
				|  |  | +            });
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            pdfDoc.autoTableText(item.qty, 126, position+9, {
 | 
	
		
			
				|  |  | +              halign: 'left',
 | 
	
		
			
				|  |  | +              valign: 'middle'
 | 
	
		
			
				|  |  | +            });
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            pdfDoc.autoTableText('Monto Total: ', 145, position+9, {
 | 
	
		
			
				|  |  | +              halign: 'left',
 | 
	
		
			
				|  |  | +              valign: 'middle'
 | 
	
		
			
				|  |  | +            });
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            pdfDoc.autoTableText(item.price, 165, position+9, {
 | 
	
		
			
				|  |  | +              halign: 'left',
 | 
	
		
			
				|  |  | +              valign: 'middle'
 | 
	
		
			
				|  |  | +            });
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            pdfDoc.autoTable(title, docItem, {
 | 
	
		
			
				|  |  | +              //  showHeader: false,
 | 
	
		
			
				|  |  | +              startY: position+15,
 | 
	
		
			
				|  |  | +              theme: 'grid',
 | 
	
		
			
				|  |  | +              styles: {
 | 
	
		
			
				|  |  | +                overflow: 'linebreak',
 | 
	
		
			
				|  |  | +                fontSize: 8,
 | 
	
		
			
				|  |  | +                margin: 50,
 | 
	
		
			
				|  |  | +                lineWidth: 0.3,
 | 
	
		
			
				|  |  | +                lineColor: [132,132,132]
 | 
	
		
			
				|  |  | +              },
 | 
	
		
			
				|  |  | +              headerStyles: {
 | 
	
		
			
				|  |  | +                fillColor: [255,255,255],
 | 
	
		
			
				|  |  | +                fontSize: 9,
 | 
	
		
			
				|  |  | +                textColor: [0,0,0],
 | 
	
		
			
				|  |  | +                lineWidth: 0.3,
 | 
	
		
			
				|  |  | +                lineColor: [132,132,132]
 | 
	
		
			
				|  |  | +              },
 | 
	
		
			
				|  |  | +              columnStyles: pdf_columnStyles,
 | 
	
		
			
				|  |  | +              margin: 'auto',
 | 
	
		
			
				|  |  | +              tableWidth: 'auto',
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +              addPageContent: function (data) {
 | 
	
		
			
				|  |  | +                // FOOTER
 | 
	
		
			
				|  |  | +                if (currentpage < pdfDoc.internal.getNumberOfPages()) {
 | 
	
		
			
				|  |  | +                  var str = "Página " + pdfDoc.internal.getNumberOfPages();
 | 
	
		
			
				|  |  | +                  str = str + " de " + totalPagesExp;
 | 
	
		
			
				|  |  | +                  pdfDoc.setFontSize(9);
 | 
	
		
			
				|  |  | +                  pdfDoc.setFontStyle('bold');
 | 
	
		
			
				|  |  | +                  pdfDoc.setTextColor(40);
 | 
	
		
			
				|  |  | +                  var pageHeight = pdfDoc.internal.pageSize.height || pdfDoc.internal.pageSize.getHeight();
 | 
	
		
			
				|  |  | +                  pdfDoc.text(str, pdfDoc.internal.pageSize.getWidth() - 55, pageHeight - 5);
 | 
	
		
			
				|  |  | +                  currentpage = pdfDoc.internal.getNumberOfPages();
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +              }
 | 
	
		
			
				|  |  | +            });
 | 
	
		
			
				|  |  | +            i++;
 | 
	
		
			
				|  |  | +          });
 | 
	
		
			
				|  |  | +          if (typeof pdfDoc.putTotalPages === 'function') {
 | 
	
		
			
				|  |  | +            pdfDoc.putTotalPages(totalPagesExp);
 | 
	
		
			
				|  |  | +          }
 | 
	
		
			
				|  |  | +          row.pop();
 | 
	
		
			
				|  |  | +          if(model.printer_bridge){
 | 
	
		
			
				|  |  | +            var data = pdfDoc.output('datauristring');
 | 
	
		
			
				|  |  | +            model.printer_bridge.print(data);
 | 
	
		
			
				|  |  | +            return;
 | 
	
		
			
				|  |  | +          }
 | 
	
		
			
				|  |  | +          pdfDoc.save(pdf_name + hoy + '.pdf');
 | 
	
		
			
				|  |  | +        },
 | 
	
		
			
				|  |  | +        //end cod:3
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    });
 | 
	
		
			
				|  |  | +}
 |