|
@@ -0,0 +1,543 @@
|
|
|
+function report_expensesp (reporting){
|
|
|
+ "use strict";
|
|
|
+
|
|
|
+ var instance = openerp;
|
|
|
+
|
|
|
+ reporting.ReposrtExpensespWidget = reporting.Base.extend({
|
|
|
+ template: 'ReposrtExpensesp',
|
|
|
+ invoices: [],
|
|
|
+ invoiceLines: [],
|
|
|
+ Currency:[],
|
|
|
+ resCurrency :[],
|
|
|
+ resCompany:[],
|
|
|
+ productProdcut:[],
|
|
|
+ productCategory:[],
|
|
|
+ accountJournal:[],
|
|
|
+ supplier:[],
|
|
|
+ newInvoice:[],
|
|
|
+ rowsData :[],
|
|
|
+ // event
|
|
|
+ events:{
|
|
|
+ 'click td > button' : 'clickOnAction',
|
|
|
+ 'change #current-journal' : 'factSearch',
|
|
|
+ 'change #current-currency' : 'factSearch',
|
|
|
+ 'change #current-category' : 'factSearch',
|
|
|
+ 'change #customer' : 'factSearch',
|
|
|
+ 'change #from' : 'factSearch',
|
|
|
+ 'change #to' : 'factSearch',
|
|
|
+ 'click #volver_btn' : 'volver',
|
|
|
+ 'click-row.bs.table #table ' : 'ckickAnalysisDetail',
|
|
|
+ },
|
|
|
+ // Initil
|
|
|
+ init : function(parent){
|
|
|
+ this._super(parent);
|
|
|
+ },
|
|
|
+ // start
|
|
|
+ start: function () {
|
|
|
+ var self = this;
|
|
|
+ var table = this.$el.find('#table');
|
|
|
+ table.bootstrapTable({data : self.rowsData});
|
|
|
+ this.fecthFecha();
|
|
|
+ this.submitForm();
|
|
|
+ },
|
|
|
+ // Analisis Detallado
|
|
|
+ ckickAnalysisDetail: function(e, row, $element,field){
|
|
|
+ if (field== 'number'){
|
|
|
+ this.do_action({
|
|
|
+ name:"Listado de Gastos Detallados",
|
|
|
+ type: 'ir.actions.act_window',
|
|
|
+ res_model: "account.invoice",
|
|
|
+ views: [[false,'form']],
|
|
|
+ target: 'new',
|
|
|
+ domain: [['type', '=', 'in_invoice'],['id','=', row.id]],
|
|
|
+ context: {},
|
|
|
+ flags: {'form': {'action_buttons': false, 'options': {'mode': 'view'}}},
|
|
|
+ res_id: row.id,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ e.stopImmediatePropagation();
|
|
|
+ },
|
|
|
+ // volver
|
|
|
+ volver: function(){
|
|
|
+ this.$el.find('#volver').empty();
|
|
|
+ this.$el.find('.bootstrap-table').show({
|
|
|
+ effect: 'drop',
|
|
|
+ direction: 'down',
|
|
|
+ duration: 200,
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // Consultar
|
|
|
+ submitForm: function () {
|
|
|
+ var self = this;
|
|
|
+ self.fetchResCurency().then(function(resCurrency) {
|
|
|
+ return resCurrency;
|
|
|
+ }).then(function (resCurrency) {
|
|
|
+ self.resCurrency = resCurrency;
|
|
|
+ self.$el.find('#current-currency').append('<option value="9999999">Todas las monedas</option>');
|
|
|
+ _.each(resCurrency, function (item) {
|
|
|
+ self.$el.find('#current-currency').append('<option value="' + item.id + '">' + item.name + '</option>');
|
|
|
+ });
|
|
|
+ return self.fetchCurency(resCurrency);
|
|
|
+ }).then(function(Currency){
|
|
|
+ self.Currency = Currency;
|
|
|
+ return self.fetchJournal();
|
|
|
+ }).then(function (journal) {
|
|
|
+ self.accountJournal =journal;
|
|
|
+ self.$el.find('#current-journal').append('<option value="9999999">TODAS LAS SUC.</option>');
|
|
|
+ _.each(journal, function (item) {
|
|
|
+ self.$el.find('#current-journal').append('<option value="' + item.id + '">' + item.name + '</option>');
|
|
|
+ });
|
|
|
+ return self.fetchInvoiceP2();
|
|
|
+ }).then(function (invoices){
|
|
|
+ self.invoices = invoices;
|
|
|
+ return self.fetchInvoiceLines(invoices);
|
|
|
+ }).then(function (invoiceLines) {
|
|
|
+ self.invoiceLines = invoiceLines;
|
|
|
+ return self.fecthProduct(invoiceLines);
|
|
|
+ }).then(function(productProdcut){
|
|
|
+ self.productProdcut = productProdcut;
|
|
|
+ return self.fecthCategory();
|
|
|
+ }).then(function(productCategory){
|
|
|
+ self.productCategory = productCategory;
|
|
|
+ self.$el.find('#current-category').append('<option value="9999999">TODAS LAS CAT.</option>');
|
|
|
+ _.each(productCategory, function (item) {
|
|
|
+ self.$el.find('#current-category').append('<option value="' + item.id + '">' + item.name + '</option>');
|
|
|
+ });
|
|
|
+ return self.fetchSupplier();
|
|
|
+ }).then(function(supplier){
|
|
|
+ self.supplier=supplier;
|
|
|
+ return self.fecthComanyCurrency();
|
|
|
+ }).then(function(resCompany){
|
|
|
+ self.resCompany = resCompany;
|
|
|
+ self.inicializarBuscadorsup();
|
|
|
+ return self.fect_generar(self.invoices);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // Fecha
|
|
|
+ fecthFecha: function() {
|
|
|
+ var to;
|
|
|
+ var dateFormat1 = "mm/dd/yy",
|
|
|
+ from = $( "#from" )
|
|
|
+ .datepicker({
|
|
|
+ dateFormat: "dd/mm/yy",
|
|
|
+ changeMonth: true,
|
|
|
+ numberOfMonths: 1,
|
|
|
+ })
|
|
|
+ .on( "change", function() {
|
|
|
+ to.datepicker( "option", "minDate", getDate(this), "dd/mm/yyyy");
|
|
|
+ });
|
|
|
+ to = $( "#to" ).datepicker({
|
|
|
+ dateFormat: "dd/mm/yy",
|
|
|
+ defaultDate: "+7d",
|
|
|
+ changeMonth: true,
|
|
|
+ numberOfMonths: 1,
|
|
|
+ })
|
|
|
+ .on( "change", function() {
|
|
|
+ from.datepicker( "option", "maxDate", getDate(this));
|
|
|
+ });
|
|
|
+
|
|
|
+ function getDate( element ) {
|
|
|
+ var fechaSel =element.value.split('/');
|
|
|
+ var date;
|
|
|
+ try {
|
|
|
+ date = $.datepicker.parseDate( dateFormat1, (fechaSel[1]+"/"+fechaSel[0]+"/"+fechaSel[2]));
|
|
|
+ } catch( error ) {
|
|
|
+ date = null;
|
|
|
+ }
|
|
|
+ return date;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // Buscar Diario
|
|
|
+ fetchJournal: function () {
|
|
|
+ var self = this;
|
|
|
+ var defer = $.Deferred();
|
|
|
+ var Journal = new instance.web.Model('account.journal');
|
|
|
+ Journal.query(['id', 'name']).filter([['type', '=', 'purchase']]).all().then(function(results){
|
|
|
+ defer.resolve(results);
|
|
|
+ });
|
|
|
+ return defer;
|
|
|
+ },
|
|
|
+ // Buscar Cambio de Monedas USD,PYG,ARG,BRL
|
|
|
+ fetchCurency: function (currency) {
|
|
|
+ var defer = $.Deferred();
|
|
|
+ var currency_id = _.flatten(_.map(currency,function(map){
|
|
|
+ return map.id;
|
|
|
+ }))
|
|
|
+ var currency_Rate = new instance.web.Model('res.currency.rate');
|
|
|
+ var fields = ['id', 'name', 'currency_id', 'rate', 'create_date'];
|
|
|
+ var domain = [['currency_id', 'in', currency_id]];
|
|
|
+ currency_Rate.query(fields).filter(domain).all().then(function (results) {
|
|
|
+ defer.resolve(results);
|
|
|
+ });
|
|
|
+ return defer;
|
|
|
+ },
|
|
|
+
|
|
|
+ // Moneda
|
|
|
+ fetchResCurency: function () {
|
|
|
+ var defer = $.Deferred();
|
|
|
+ var currency = new instance.web.Model('res.currency');
|
|
|
+ var fields = ['id', 'name'];
|
|
|
+ var domain = [['active', '=', true]];
|
|
|
+ currency.query(fields).filter(domain).all().then(function (results) {
|
|
|
+ defer.resolve(results);
|
|
|
+ });
|
|
|
+ return defer;
|
|
|
+ },
|
|
|
+
|
|
|
+ // Invoice (FACTURAS)
|
|
|
+ fetchInvoiceP2: function () {
|
|
|
+ var journal_ids = _.flatten(_.map(this.accountJournal, function (item) {
|
|
|
+ return item.id;
|
|
|
+ }));
|
|
|
+ var filter =[['state', 'in',['open','paid']],['type', '=', 'in_invoice'],['origin', '=', false],['journal_id', 'in',journal_ids]];
|
|
|
+ var field =['id', 'type', 'number', 'origin', 'state', 'journal_id', 'currency_id', 'invoice_line', 'supplier_invoice_number','date_invoice','partner_id','amount_total','user_id'];
|
|
|
+ var defer = $.Deferred();
|
|
|
+ var Invoice = new instance.web.Model('account.invoice');
|
|
|
+ Invoice.query(field).filter(filter).all().then(function (results) {
|
|
|
+ defer.resolve(results);
|
|
|
+ });
|
|
|
+ return defer;
|
|
|
+ },
|
|
|
+
|
|
|
+ // Invoice line (Linea de Factura)
|
|
|
+ fetchInvoiceLines: function (invoices) {
|
|
|
+ var defer = $.Deferred();
|
|
|
+ var linesIds = _.flatten(_.map(invoices, function (item) {
|
|
|
+ return item.invoice_line;
|
|
|
+ }));
|
|
|
+ var InvoiceLines = new instance.web.Model('account.invoice.line');
|
|
|
+ InvoiceLines.query(['id', 'quantity', 'price_unit', 'discount', 'name', 'product_id', 'origin','invoice_id']).filter([['id', 'in', linesIds]]).all().then(function (results) {
|
|
|
+ defer.resolve(results);
|
|
|
+ });
|
|
|
+ return defer;
|
|
|
+ },
|
|
|
+
|
|
|
+ // Product Product
|
|
|
+ fecthProduct: function(invoiceLines){
|
|
|
+ var defer = $.Deferred();
|
|
|
+ var porductIDS = _.flatten(_.map(invoiceLines, function (item) {
|
|
|
+ return item.product_id[0];
|
|
|
+ }));
|
|
|
+ var ProductProdcut = new instance.web.Model('product.product');
|
|
|
+ var fields = ['id', 'default_code', 'name_template', 'standard_price','type','categ_id'];
|
|
|
+ ProductProdcut.query(fields).filter([['id', 'in', porductIDS]]).all().then(function (results) {
|
|
|
+ defer.resolve(results);
|
|
|
+ });
|
|
|
+ return defer;
|
|
|
+ },
|
|
|
+
|
|
|
+ // Obtener las lineas de las Facturas
|
|
|
+ getProduct: function(pro_id){
|
|
|
+ return _.find(this.productProdcut, function(prod){
|
|
|
+ return _.contains(pro_id, prod.id);
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ // Buscar Category
|
|
|
+ fecthCategory: function () {
|
|
|
+ var self = this;
|
|
|
+ var defer = $.Deferred();
|
|
|
+ var productCategory = new instance.web.Model('product.category');
|
|
|
+ productCategory.query(['id', 'name', 'type']).filter([['type', '=', 'normal']]).all().then(function (results) {
|
|
|
+ defer.resolve(results);
|
|
|
+ });
|
|
|
+ return defer;
|
|
|
+ },
|
|
|
+
|
|
|
+ // Obtener Detalles de la Factura
|
|
|
+ getInvoice: function (id_line){
|
|
|
+ return _.find(this.invoices, function (inv) {
|
|
|
+ return _.contains(inv.invoice_line, id_line);
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ // company_curency
|
|
|
+ fecthComanyCurrency: function(){
|
|
|
+ var self = this;
|
|
|
+ var defer = $.Deferred();
|
|
|
+ var currency = new instance.web.Model('res.company');
|
|
|
+ var field=['id', 'currency_id'];
|
|
|
+ var domain=[['id','=',1]];
|
|
|
+ currency.query(field).filter(domain).all().then(function(results){
|
|
|
+ defer.resolve(results);
|
|
|
+ });
|
|
|
+ return defer;
|
|
|
+ },
|
|
|
+
|
|
|
+ // Partner (Proveeedor)
|
|
|
+ fetchSupplier: function() {
|
|
|
+ var self = this;
|
|
|
+ var defer = $.Deferred();
|
|
|
+ var supplier = new instance.web.Model('res.partner');
|
|
|
+ supplier.query(['id', 'name', 'ruc', 'active', 'supplier']).filter([['active', '=', true], ['supplier', '=', true]]).all().then(function (results) {
|
|
|
+ defer.resolve(results);
|
|
|
+ });
|
|
|
+ return defer;
|
|
|
+ },
|
|
|
+ // Obtener el Cambio de la Moneda
|
|
|
+ getCurrency: function (id){
|
|
|
+ return _.find(this.Currency,function (curr) {
|
|
|
+ return _.contains(curr.currency_id,id);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // Verificar si los Valores no son nulos
|
|
|
+ valorNull:function(dato){
|
|
|
+ var valor ="";
|
|
|
+ if (dato){
|
|
|
+ valor=dato;
|
|
|
+ }
|
|
|
+ return valor;
|
|
|
+ },
|
|
|
+ // Buscador
|
|
|
+ inicializarBuscadorsup: function () {
|
|
|
+ var self = this;
|
|
|
+ var results = self.supplier;
|
|
|
+ results = _.map(results, function (item) {
|
|
|
+ return {
|
|
|
+ label: item.id + '-'+ item.name + ' ' + self.valorNull(item.ruc),
|
|
|
+ value: item.id + '-'+ item.name + ' ' + self.valorNull(item.ruc)
|
|
|
+ }
|
|
|
+ });
|
|
|
+ self.$('#customer').autocomplete({
|
|
|
+ source: results,
|
|
|
+ minLength:0,
|
|
|
+ search: function(event, ui) {
|
|
|
+ if (!(self.$('#customer').val())){
|
|
|
+ self.factSearch();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ close: function( event, ui ) {
|
|
|
+ self.factSearch();
|
|
|
+ },
|
|
|
+ select: function(event, ui) {
|
|
|
+ self.factSearch();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // unir los objetos
|
|
|
+ fect_generar: function(){
|
|
|
+ var self = this;
|
|
|
+ var data = [];
|
|
|
+ var invoice;
|
|
|
+ var item;
|
|
|
+ var producto;
|
|
|
+
|
|
|
+ for (var i = 0; i < this.invoiceLines.length; i++) {
|
|
|
+ item = this.invoiceLines[i];
|
|
|
+ invoice = this.getInvoice(item.id);
|
|
|
+ producto =this.getProduct(item.product_id);
|
|
|
+ if (!producto){
|
|
|
+ producto={};
|
|
|
+ producto.standard_price=0;
|
|
|
+ }
|
|
|
+ if (producto.type =="service"){
|
|
|
+ data.push({
|
|
|
+ number : (invoice.number),
|
|
|
+ supplier_invoice_number: self.valorNull(invoice.supplier_invoice_number),
|
|
|
+ name : (producto.name_template),
|
|
|
+ date: moment(invoice.date_invoice).format("DD/MM/YYYY"),
|
|
|
+ date_invoice: invoice.date_invoice,
|
|
|
+ user: invoice.user_id[1],
|
|
|
+ quantity : accounting.formatNumber((item.quantity),2, ".", ","),
|
|
|
+ standar_price : accounting.formatNumber((item.price_unit),0, ".", ","),
|
|
|
+ standar_tot : accounting.formatNumber((item.quantity * item.price_unit),0, ".", ","),
|
|
|
+ journal_id : invoice.journal_id[0],
|
|
|
+ currency_id : invoice.currency_id[0],
|
|
|
+ partner_id : (invoice.partner_id[0]),
|
|
|
+ categ_id : (producto.categ_id[0])
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ self.newInvoice = data;
|
|
|
+ this.loadTable(data);
|
|
|
+ },
|
|
|
+ // Buscar
|
|
|
+ factSearch: function(){
|
|
|
+ var self = this;
|
|
|
+ var desde = this.$el.find('#from').val();
|
|
|
+ var hasta = this.$el.find('#to').val();
|
|
|
+ var suc = this.$el.find('#current-journal').val();
|
|
|
+ var currency = this.$el.find('#current-currency').val();
|
|
|
+ var cat = this.$el.find('#current-category').val();
|
|
|
+ var prov= this.$el.find('#customer').val().split('-');
|
|
|
+ var newInvoice = self.newInvoice;
|
|
|
+ // Buscar por Sucursales
|
|
|
+ if (suc != 9999999){
|
|
|
+ newInvoice=_.filter(newInvoice, function (inv){
|
|
|
+ return inv.journal_id == suc;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // Buscar por fecha Desde
|
|
|
+ if (desde.length > 0){
|
|
|
+ var date= desde.split('/');
|
|
|
+ newInvoice = _.filter(newInvoice, function (inv){
|
|
|
+ return inv.date_invoice >= (date[2]+"-"+date[1]+"-"+date[0]);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // Buscar por Fechas Hasta
|
|
|
+ if (hasta.length > 0){
|
|
|
+ var date= hasta.split('/');
|
|
|
+ newInvoice = _.filter(newInvoice, function (inv){
|
|
|
+ return inv.date_invoice <= (date[2]+"-"+date[1]+"-"+date[0]);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // Buscar por moneda
|
|
|
+ if(currency != 9999999){
|
|
|
+ newInvoice = _.filter(newInvoice,function(inv){
|
|
|
+ return inv.currency_id == currency;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // Buscar por proveedor
|
|
|
+ if (prov != ""){
|
|
|
+ newInvoice = _.filter(newInvoice, function(inv){
|
|
|
+ return inv.partner_id == prov[0];
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (cat != 9999999){
|
|
|
+ newInvoice=_.filter(newInvoice, function (inv){
|
|
|
+ return inv.categ_id == cat;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ self.loadTable(newInvoice)
|
|
|
+ },
|
|
|
+
|
|
|
+ // cargara la tabla
|
|
|
+ loadTable:function(rowsTable){
|
|
|
+ var self = this;
|
|
|
+ self.rowsData = rowsTable;
|
|
|
+ var table = this.$el.find('#table');
|
|
|
+ table.bootstrapTable('load',rowsTable);
|
|
|
+ var pdf_table = rowsTable;
|
|
|
+ },
|
|
|
+
|
|
|
+ getInvoice1 : function(currency_id){
|
|
|
+ var self = this;
|
|
|
+ return _.filter(self.rowsData, function(item){
|
|
|
+ return item.currency_id === currency_id;
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ // Crear Objeto PDF
|
|
|
+ getObjetPdf: function(rowsTable){
|
|
|
+ var self = this;
|
|
|
+ var rows=[];
|
|
|
+ var amount_total=0;
|
|
|
+ var amount=0;
|
|
|
+
|
|
|
+ for (var i = 0; i < self.rowsData.length; i++) {
|
|
|
+ var newInvoice = self.rowsData[i];
|
|
|
+ rows.push({
|
|
|
+ number: newInvoice.number,
|
|
|
+ supplier_invoice_number: self.valorNull(newInvoice.supplier_invoice_number),
|
|
|
+ name: newInvoice.name,
|
|
|
+ quantity : newInvoice.quantity,
|
|
|
+ standar_price : newInvoice.standar_price,
|
|
|
+ standar_tot : newInvoice.standar_tot,
|
|
|
+ date: moment(newInvoice.date_invoice).format("DD/MM/YYYY"),
|
|
|
+ date_invoice: newInvoice.date_invoice,
|
|
|
+ partner_id : newInvoice.partner_id
|
|
|
+ });
|
|
|
+ amount_total+=parseInt(newInvoice.standar_tot.replace(".",""));
|
|
|
+ }
|
|
|
+ rows.push({
|
|
|
+ name : 'Total:',
|
|
|
+ quantity : '',
|
|
|
+ standard_price : '',
|
|
|
+ standar_tot: accounting.formatNumber(amount_total,0,".",","),
|
|
|
+ });
|
|
|
+ return rows;
|
|
|
+ },
|
|
|
+
|
|
|
+ clickOnAction: function (e) {
|
|
|
+ var self = this;
|
|
|
+ var rowsNew;
|
|
|
+ var action = self.$el.find(e.target).val();
|
|
|
+ var table = self.$el.find("#table");
|
|
|
+ var data2 = table.bootstrapTable('getVisibleColumns');
|
|
|
+ var getColumns=[];
|
|
|
+ var rows=[];
|
|
|
+ rowsNew = self.getObjetPdf();
|
|
|
+
|
|
|
+ if (action === 'pdf') {
|
|
|
+ var dataNEW = _.map(data2, function (val){
|
|
|
+ return val.field;
|
|
|
+ console.log(dataNEW);
|
|
|
+ });
|
|
|
+ _.each(rowsNew,function (item){
|
|
|
+ rows.push(_.pick(item, dataNEW));
|
|
|
+ });
|
|
|
+ // Obtener los nombre de la Cabezera
|
|
|
+ _.each(_.map(data2,function(val){
|
|
|
+ return val;
|
|
|
+ }), function(item){
|
|
|
+ getColumns.push([{
|
|
|
+ title: item.title,
|
|
|
+ dataKey: item.field
|
|
|
+ }]);
|
|
|
+ });
|
|
|
+ this.drawPDF(_.flatten(getColumns),rows);
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ // Generar pdfDoc
|
|
|
+ drawPDF:function(getColumns,rows){
|
|
|
+ var self = this;
|
|
|
+ var sucusal = this.sucDescrip = this.$el.find('#current-journal option:selected').text();
|
|
|
+ var desde =(this.$el.find('#from').val());
|
|
|
+ var hasta =(this.$el.find('#to').val());
|
|
|
+ var cat = this.$el.find('#current-category option:selected').text();
|
|
|
+ var totalPagesExp = "{total_pages_count_string}";
|
|
|
+ var pdfDoc = new jsPDF();
|
|
|
+
|
|
|
+ pdfDoc.autoTable(getColumns, rows, {
|
|
|
+ styles: { overflow: 'linebreak', fontSize:8 , columnWidth: 'wrap'},
|
|
|
+ columnStyles:{
|
|
|
+ number : {columnWidth: '8px'},
|
|
|
+ supplier_invoice_number : {columnWidth: '8px'},
|
|
|
+ name : {columnWidth: '8px'},
|
|
|
+ standar_price : {halign:'right',columnWidth: '8px'},
|
|
|
+ quantity :{halign:'right',columnWidth: '6px'},
|
|
|
+ standar_tot : {halign:'right',columnWidth: '8px'},
|
|
|
+ },
|
|
|
+ margin: { top: 16, horizontal: 7},
|
|
|
+
|
|
|
+ addPageContent: function (data2) {
|
|
|
+ pdfDoc.setFontSize(12);
|
|
|
+ pdfDoc.setFontStyle('bold');
|
|
|
+ pdfDoc.setTextColor(40);
|
|
|
+ pdfDoc.text('Histórico de gastos detallados ', data2.settings.margin.left, 10);
|
|
|
+
|
|
|
+ if(desde.length > 0 || hasta.length > 0){
|
|
|
+ var fecha='';
|
|
|
+ if(desde){
|
|
|
+ fecha=fecha.concat(' Desde '+desde);
|
|
|
+ }
|
|
|
+ if (hasta){
|
|
|
+ fecha=fecha.concat(' Hasta '+hasta);
|
|
|
+ }
|
|
|
+ pdfDoc.setFontSize(10);
|
|
|
+ pdfDoc.setFontStyle('bold');
|
|
|
+ pdfDoc.setTextColor(40)
|
|
|
+ pdfDoc.text(fecha, data2.settings.margin.left,14);
|
|
|
+ }
|
|
|
+ // FOOTER
|
|
|
+ var str = "Pagina " + data2.pageCount;
|
|
|
+ // Total page number plugin only available in jspdf v1.0+
|
|
|
+ if (typeof pdfDoc.putTotalPages === 'function') {
|
|
|
+ str = str + " de " + totalPagesExp;
|
|
|
+ }
|
|
|
+ pdfDoc.setFontSize(9);
|
|
|
+ pdfDoc.setFontStyle('bold');
|
|
|
+ pdfDoc.setTextColor(40);
|
|
|
+ pdfDoc.text(str, data2.settings.margin.left, pdfDoc.internal.pageSize.height - 5);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ if (typeof pdfDoc.putTotalPages === 'function') {
|
|
|
+ pdfDoc.putTotalPages(totalPagesExp);
|
|
|
+ }
|
|
|
+ pdfDoc.save('Histórico de gastos detallados.pdf')
|
|
|
+ },
|
|
|
+ });
|
|
|
+}
|