|
@@ -0,0 +1,1575 @@
|
|
|
+function pdf_anillos(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 = 15;
|
|
|
+ var y_position2 = 15;
|
|
|
+
|
|
|
+ //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: 3},
|
|
|
+
|
|
|
+ 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.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, 75, 8, 'S');
|
|
|
+ // Clientes
|
|
|
+ pdfDoc.rect(82, row.y, 70, 8, 'S');
|
|
|
+ // Total de Ventas
|
|
|
+ pdfDoc.rect(152, row.y, 140, 8, 'S');
|
|
|
+
|
|
|
+ pdfDoc.autoTableText("DOCUMENTO", 33, row.y + row.height / 2, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });
|
|
|
+ pdfDoc.autoTableText("CLIENTES", 115, 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, 27, 8, 'S');
|
|
|
+ pdfDoc.autoTableText("NUM", 22, row.y + row.height / 2 + 8, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });
|
|
|
+ // Factura
|
|
|
+ pdfDoc.rect(34, row.y + 8, 21, 8, 'S');
|
|
|
+ pdfDoc.autoTableText("N° Factura", 44, row.y + row.height / 2 + 8, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });
|
|
|
+ // FECHA
|
|
|
+ pdfDoc.rect(55, row.y + 8, 27, 8, 'S');
|
|
|
+ pdfDoc.autoTableText("FECHA", 65, row.y + row.height / 2 + 8, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });
|
|
|
+ // RAZON SOCIAL
|
|
|
+ pdfDoc.rect(82, row.y + 8, 50, 8, 'S');
|
|
|
+ pdfDoc.autoTableText("RAZON SOCIAL", 105, row.y + row.height / 2 + 8, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });
|
|
|
+ // RUC
|
|
|
+ pdfDoc.rect(132, row.y + 8, 19.87, 8, 'S');
|
|
|
+ pdfDoc.autoTableText("RUC", 143, row.y + row.height / 2 + 8, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });
|
|
|
+ // TASA 5%
|
|
|
+ pdfDoc.rect(151.9, row.y + 8, 24.32, 8, 'S');
|
|
|
+ pdfDoc.autoTableText("TASA 5%", 163, row.y + row.height / 2 + 8, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });
|
|
|
+ // GRAVADAS 5%
|
|
|
+ pdfDoc.rect(151.9, row.y + 8, 24.32, 8, 'S');
|
|
|
+ pdfDoc.autoTableText("5%", 163, row.y + row.height / 2 + 8, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });
|
|
|
+ // TASA 10%
|
|
|
+ pdfDoc.rect(151.9, row.y + 8, 24.32, 8, 'S');
|
|
|
+ pdfDoc.autoTableText("TASA 10%", 163, row.y + row.height / 2 + 8, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });
|
|
|
+ // GRAVADAS 10%
|
|
|
+ pdfDoc.rect(151.9, row.y + 8, 24.32, 8, 'S');
|
|
|
+ pdfDoc.autoTableText("10%", 163, row.y + row.height / 2 + 8, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });
|
|
|
+ // %
|
|
|
+ pdfDoc.rect(176.45, row.y + 8, 8.6, 8, 'S');
|
|
|
+ pdfDoc.autoTableText("%", 179.5, row.y + row.height / 2 + 8, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });
|
|
|
+ //IMPUESTOS
|
|
|
+ pdfDoc.rect(184.85, row.y + 8, 24, 8, 'S');
|
|
|
+ pdfDoc.autoTableText("IMPUESTOS", 197, row.y + row.height / 2 + 8, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });
|
|
|
+ // EXENTAS
|
|
|
+ pdfDoc.rect(209, row.y + 8, 21, 8, 'S');
|
|
|
+ pdfDoc.autoTableText("EXENTAS", 220, row.y + row.height / 2 + 8, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });
|
|
|
+ // Ret IVA
|
|
|
+ pdfDoc.rect(230, row.y + 8, 18, 8, 'S');
|
|
|
+ pdfDoc.autoTableText("Ret IVA", 238, row.y + row.height / 2 + 8, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });
|
|
|
+ // Ret Renta
|
|
|
+ pdfDoc.rect(248, row.y + 8, 20, 8, 'S');
|
|
|
+ pdfDoc.autoTableText("Ret RENTA", 258, row.y + row.height / 2 + 8, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });
|
|
|
+ // TOTAL
|
|
|
+ pdfDoc.rect(268, row.y + 8, 24, 8, 'S');
|
|
|
+ pdfDoc.autoTableText("TOTAL", 279, 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, 65, 8, 'S');
|
|
|
+ // Clientes
|
|
|
+ pdfDoc.rect(71.9, row.y, 49.1, 8, 'S');
|
|
|
+ // Total de Ventas
|
|
|
+ pdfDoc.rect(121.1, row.y, 86.6, 8, 'S');
|
|
|
+ pdfDoc.autoTableText("DOCUMENTO", 29, row.y + row.height / 2, {
|
|
|
+ halign: 'center',
|
|
|
+ });
|
|
|
+ pdfDoc.autoTableText(" CLIENTES", 85, row.y + row.height / 2, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });
|
|
|
+ pdfDoc.autoTableText("TOTAL DE VENTAS",167, row.y + row.height / 2, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });
|
|
|
+ // NUM
|
|
|
+ pdfDoc.setFontSize(6);
|
|
|
+ pdfDoc.rect(data.settings.margin.left, row.y + 8, 25, 8, 'S');
|
|
|
+ pdfDoc.autoTableText("NUM", 21, row.y + row.height / 2 + 8, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });
|
|
|
+ // factura
|
|
|
+ pdfDoc.rect(32.15, row.y + 8, 23.7, 8, 'S');
|
|
|
+ pdfDoc.autoTableText("N° Fact.", 42, row.y + row.height / 2 + 8, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });
|
|
|
+ // FECHA
|
|
|
+ pdfDoc.rect(55.7, row.y + 8, 16.2, 8, 'S');
|
|
|
+ pdfDoc.autoTableText("FECHA", 65, row.y + row.height / 2 + 8, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });
|
|
|
+ // RAZON SOCIAL
|
|
|
+ pdfDoc.rect(72, row.y + 8, 32, 8, 'S');
|
|
|
+ pdfDoc.autoTableText("RAZON SOCIAL", 85, row.y + row.height / 2 + 8, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });
|
|
|
+ // RUC
|
|
|
+ pdfDoc.rect(104.2, row.y + 8, 16.8, 8, 'S');
|
|
|
+ pdfDoc.autoTableText("RUC", 111, row.y + row.height / 2 + 8, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });
|
|
|
+ // TASA 5%
|
|
|
+ pdfDoc.rect(121.1, row.y + 8, 15.1, 8, 'S');
|
|
|
+ pdfDoc.autoTableText("TASA 5%", 128, row.y + row.height / 2 + 8, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });
|
|
|
+ // GRAVADAS 5%
|
|
|
+ pdfDoc.rect(136.1, row.y + 8, 13.05, 8, 'S');
|
|
|
+ pdfDoc.autoTableText("IVA 5%", 142, row.y + row.height / 2 + 8, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });
|
|
|
+ // TASA 10%
|
|
|
+ pdfDoc.rect(148.7, row.y + 8, 14.55, 8, 'S');
|
|
|
+ pdfDoc.autoTableText("TASA 10%", 156, row.y + row.height / 2 + 8, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });
|
|
|
+ // GRAVADAS 10%
|
|
|
+ pdfDoc.rect(163.52, row.y + 8, 12.7, 8, 'S');
|
|
|
+ pdfDoc.autoTableText("IVA 10%", 170, row.y + row.height / 2 + 8, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });
|
|
|
+ // EXENTAS
|
|
|
+ pdfDoc.rect(176.5, row.y + 8, 14.7, 8, 'S');
|
|
|
+ pdfDoc.autoTableText("EXENTAS", 183.5, row.y + row.height / 2 + 8, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });
|
|
|
+ // %
|
|
|
+/* pdfDoc.rect(165.5, row.y + 8, 4.6, 8, 'S');
|
|
|
+ pdfDoc.autoTableText("%", 171, row.y + row.height / 2 + 8, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });*/
|
|
|
+ // IMPUESTOS
|
|
|
+ /* pdfDoc.rect(177, row.y + 8, 15, 7.9, 'S');
|
|
|
+ pdfDoc.autoTableText("IMPUESTOS", 185, row.y + row.height / 2 + 8, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });*/
|
|
|
+
|
|
|
+ // Ret IVA
|
|
|
+/* pdfDoc.rect(177.1, row.y + 8, 6.7, 8, 'S');
|
|
|
+ pdfDoc.autoTableText("Ret", 179.3, row.y + row.height / 2 + 8, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });*/
|
|
|
+ /* pdfDoc.autoTableText("IVA", 179.3, row.y + row.height / 2 + 10, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });*/
|
|
|
+ // Ret Renta
|
|
|
+ /* pdfDoc.rect(184, row.y + 8, 7.9, 8, 'S');
|
|
|
+ pdfDoc.autoTableText("Ret", 187.5, row.y + row.height / 2 + 8, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });
|
|
|
+ pdfDoc.autoTableText("Renta", 187.5, row.y + row.height / 2 + 10, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ }); */
|
|
|
+ // TOTAL
|
|
|
+ pdfDoc.rect(190.9, row.y + 8, 17, 8, 'S');
|
|
|
+ pdfDoc.autoTableText("TOTAL", 199, 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');
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+ // ----------------------- purchase libro
|
|
|
+
|
|
|
+ drawPurchaseJournalPDF: 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.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, 75, 8, 'S');
|
|
|
+ // Clientes
|
|
|
+ pdfDoc.rect(82, row.y, 70, 8, 'S');
|
|
|
+ // Total de Ventas
|
|
|
+ pdfDoc.rect(152, row.y, 140, 8, 'S');
|
|
|
+
|
|
|
+ pdfDoc.autoTableText("DOCUMENTO", 33, row.y + row.height / 2, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });
|
|
|
+ pdfDoc.autoTableText("PROVEEDORES", 115, row.y + row.height / 2, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });
|
|
|
+ pdfDoc.autoTableText("TOTAL DE COMPRAS", 210, row.y + row.height / 2, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });
|
|
|
+ // NUM
|
|
|
+ pdfDoc.rect(data.settings.margin.left, row.y + 8, 27, 8, 'S');
|
|
|
+ pdfDoc.autoTableText("NUM", 22, row.y + row.height / 2 + 8, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });
|
|
|
+ // Factura
|
|
|
+ pdfDoc.rect(34, row.y + 8, 21, 8, 'S');
|
|
|
+ pdfDoc.autoTableText("N° Factura", 44, row.y + row.height / 2 + 8, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });
|
|
|
+ // FECHA
|
|
|
+ pdfDoc.rect(55, row.y + 8, 27, 8, 'S');
|
|
|
+ pdfDoc.autoTableText("FECHA", 65, row.y + row.height / 2 + 8, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });
|
|
|
+ // RAZON SOCIAL
|
|
|
+ pdfDoc.rect(82, row.y + 8, 50, 8, 'S');
|
|
|
+ pdfDoc.autoTableText("RAZON SOCIAL", 105, row.y + row.height / 2 + 8, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });
|
|
|
+ // RUC
|
|
|
+ pdfDoc.rect(132, row.y + 8, 19.87, 8, 'S');
|
|
|
+ pdfDoc.autoTableText("RUC", 143, row.y + row.height / 2 + 8, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });
|
|
|
+ // TASA 5%
|
|
|
+ pdfDoc.rect(151.1, row.y + 8, 15.1, 8, 'S');
|
|
|
+ pdfDoc.autoTableText("TASA 5%", 158, row.y + row.height / 2 + 8, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });
|
|
|
+ // GRAVADAS 5%
|
|
|
+ pdfDoc.rect(166.1, row.y + 8, 13.05, 8, 'S');
|
|
|
+ pdfDoc.autoTableText("IVA 5%", 172, row.y + row.height / 2 + 8, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });
|
|
|
+ // TASA 10%
|
|
|
+ pdfDoc.rect(178.7, row.y + 8, 14.55, 8, 'S');
|
|
|
+ pdfDoc.autoTableText("TASA 10%", 186, row.y + row.height / 2 + 8, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });
|
|
|
+ // GRAVADAS 10%
|
|
|
+ pdfDoc.rect(193.52, row.y + 8, 12.7, 8, 'S');
|
|
|
+ pdfDoc.autoTableText("IVA 10%", 200, row.y + row.height / 2 + 8, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });
|
|
|
+ // EXENTAS
|
|
|
+ pdfDoc.rect(206.5, row.y + 8, 14.7, 8, 'S');
|
|
|
+ pdfDoc.autoTableText("EXENTAS", 213.5, row.y + row.height / 2 + 8, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });
|
|
|
+ // Ret IVA
|
|
|
+ pdfDoc.rect(230, row.y + 8, 18, 8, 'S');
|
|
|
+ pdfDoc.autoTableText("Ret IVA", 238, row.y + row.height / 2 + 8, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });
|
|
|
+ // Ret Renta
|
|
|
+ pdfDoc.rect(248, row.y + 8, 20, 8, 'S');
|
|
|
+ pdfDoc.autoTableText("Ret RENTA", 258, row.y + row.height / 2 + 8, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });
|
|
|
+ // TOTAL
|
|
|
+ pdfDoc.rect(268, row.y + 8, 24, 8, 'S');
|
|
|
+ pdfDoc.autoTableText("TOTAL", 279, 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, 65, 8, 'S');
|
|
|
+ // Clientes
|
|
|
+ pdfDoc.rect(71.9, row.y, 49.1, 8, 'S');
|
|
|
+ // Total de Ventas
|
|
|
+ pdfDoc.rect(121.1, row.y, 86.6, 8, 'S');
|
|
|
+ pdfDoc.autoTableText("DOCUMENTO", 29, row.y + row.height / 2, {
|
|
|
+ halign: 'center',
|
|
|
+ });
|
|
|
+ pdfDoc.autoTableText("PROVEEDORES", 85, row.y + row.height / 2, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });
|
|
|
+ pdfDoc.autoTableText("TOTAL DE COMPRAS",167, row.y + row.height / 2, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });
|
|
|
+ // NUM
|
|
|
+ pdfDoc.setFontSize(6);
|
|
|
+ pdfDoc.rect(data.settings.margin.left, row.y + 8, 25, 8, 'S');
|
|
|
+ pdfDoc.autoTableText("NUM", 21, row.y + row.height / 2 + 8, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });
|
|
|
+ // factura
|
|
|
+ pdfDoc.rect(32.15, row.y + 8, 23.7, 8, 'S');
|
|
|
+ pdfDoc.autoTableText("N° Fact.", 42, row.y + row.height / 2 + 8, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });
|
|
|
+ // FECHA
|
|
|
+ pdfDoc.rect(55.7, row.y + 8, 16.2, 8, 'S');
|
|
|
+ pdfDoc.autoTableText("FECHA", 65, row.y + row.height / 2 + 8, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });
|
|
|
+ // RAZON SOCIAL
|
|
|
+ pdfDoc.rect(72, row.y + 8, 32, 8, 'S');
|
|
|
+ pdfDoc.autoTableText("RAZON SOCIAL", 85, row.y + row.height / 2 + 8, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });
|
|
|
+ // RUC
|
|
|
+ pdfDoc.rect(104.2, row.y + 8, 16.8, 8, 'S');
|
|
|
+ pdfDoc.autoTableText("RUC", 111, row.y + row.height / 2 + 8, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });
|
|
|
+ // TASA 5%
|
|
|
+ pdfDoc.rect(121.1, row.y + 8, 15.1, 8, 'S');
|
|
|
+ pdfDoc.autoTableText("TASA 5%", 128, row.y + row.height / 2 + 8, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });
|
|
|
+ // GRAVADAS 5%
|
|
|
+ pdfDoc.rect(136.1, row.y + 8, 13.05, 8, 'S');
|
|
|
+ pdfDoc.autoTableText("IVA 5%", 142, row.y + row.height / 2 + 8, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });
|
|
|
+ // TASA 10%
|
|
|
+ pdfDoc.rect(148.7, row.y + 8, 14.55, 8, 'S');
|
|
|
+ pdfDoc.autoTableText("TASA 10%", 156, row.y + row.height / 2 + 8, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });
|
|
|
+ // GRAVADAS 10%
|
|
|
+ pdfDoc.rect(163.52, row.y + 8, 12.7, 8, 'S');
|
|
|
+ pdfDoc.autoTableText("IVA 10%", 170, row.y + row.height / 2 + 8, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });
|
|
|
+ // EXENTAS
|
|
|
+ pdfDoc.rect(176.5, row.y + 8, 14.7, 8, 'S');
|
|
|
+ pdfDoc.autoTableText("EXENTAS", 183.5, row.y + row.height / 2 + 8, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });
|
|
|
+ // %
|
|
|
+/* pdfDoc.rect(165.5, row.y + 8, 4.6, 8, 'S');
|
|
|
+ pdfDoc.autoTableText("%", 171, row.y + row.height / 2 + 8, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });*/
|
|
|
+ // IMPUESTOS
|
|
|
+ /* pdfDoc.rect(177, row.y + 8, 15, 7.9, 'S');
|
|
|
+ pdfDoc.autoTableText("IMPUESTOS", 185, row.y + row.height / 2 + 8, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });*/
|
|
|
+
|
|
|
+ // Ret IVA
|
|
|
+/* pdfDoc.rect(177.1, row.y + 8, 6.7, 8, 'S');
|
|
|
+ pdfDoc.autoTableText("Ret", 179.3, row.y + row.height / 2 + 8, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });*/
|
|
|
+ /* pdfDoc.autoTableText("IVA", 179.3, row.y + row.height / 2 + 10, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });*/
|
|
|
+ // Ret Renta
|
|
|
+ /* pdfDoc.rect(184, row.y + 8, 7.9, 8, 'S');
|
|
|
+ pdfDoc.autoTableText("Ret", 187.5, row.y + row.height / 2 + 8, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ });
|
|
|
+ pdfDoc.autoTableText("Renta", 187.5, row.y + row.height / 2 + 10, {
|
|
|
+ halign: 'center',
|
|
|
+ valign: 'middle'
|
|
|
+ }); */
|
|
|
+ // TOTAL
|
|
|
+ pdfDoc.rect(190.9, row.y + 8, 17, 8, 'S');
|
|
|
+ pdfDoc.autoTableText("TOTAL", 199, 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');
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+ // ---------------------- fin purchase libro
|
|
|
+
|
|
|
+ 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
|
|
|
+
|
|
|
+ });
|
|
|
+}
|