|
@@ -0,0 +1,565 @@
|
|
|
+function report_invoice_difventa (reporting){
|
|
|
+ "use strict";
|
|
|
+
|
|
|
+ var model = openerp;
|
|
|
+
|
|
|
+ reporting.ReportInvoiceDifventaWidget = reporting.Base.extend({
|
|
|
+ template: 'ReportInvoiceDifventa',
|
|
|
+ invoices: [],
|
|
|
+ invoiceLines: [],
|
|
|
+ productProduct:[],
|
|
|
+ Currency:[],
|
|
|
+ rowsData :[],
|
|
|
+ content :[],
|
|
|
+ rowOrigin:[],
|
|
|
+ accountJournal:[],
|
|
|
+ resCompany:[],
|
|
|
+ events:{
|
|
|
+ 'click #toolbar > button' : 'clickOnAction',
|
|
|
+ 'click #X' : 'fectSearch',
|
|
|
+ 'click #A' : 'fectSearch',
|
|
|
+ 'click #B' : 'fectSearch',
|
|
|
+ 'click #C' : 'fectSearch',
|
|
|
+ 'click #D' : 'fectSearch',
|
|
|
+ 'click #Z' : 'fectSearch',
|
|
|
+ 'change #current-store': 'fectSearch',
|
|
|
+ 'change #product': 'fectSearch',
|
|
|
+ 'change #from' : 'fectSearch',
|
|
|
+ 'change #to': 'fectSearch',
|
|
|
+ 'click #volver_btn': 'volver',
|
|
|
+ 'click-row.bs.table #table' : 'ckickAnalysisDetail',
|
|
|
+ },
|
|
|
+ init : function(parent){
|
|
|
+ this._super(parent);
|
|
|
+ },
|
|
|
+ start: function () {
|
|
|
+ var self = this;
|
|
|
+ var table = this.$el.find('#table');
|
|
|
+ table.bootstrapTable({data : self.rowsData});
|
|
|
+ this.fecthFecha();
|
|
|
+ this.submitForm();
|
|
|
+ },
|
|
|
+ ckickAnalysisDetail: function(e, row, $element, field){
|
|
|
+ if (field == 'name'){
|
|
|
+ this.do_action({
|
|
|
+ name : "Variantes de Producto",
|
|
|
+ type : 'ir.actions.act_window',
|
|
|
+ res_model : "product.product",
|
|
|
+ views : [[false,'form']],
|
|
|
+ target : 'new',
|
|
|
+ domain : [['id','=', row.id_product]],
|
|
|
+ context : {},
|
|
|
+ flags : {'form': {'action_buttons': false, 'options': {'mode': 'view'}}},
|
|
|
+ res_id : row.id_product,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (field == 'number'){
|
|
|
+ this.do_action({
|
|
|
+ name : "Factura de Cliente",
|
|
|
+ type : 'ir.actions.act_window',
|
|
|
+ res_model : "account.invoice",
|
|
|
+ views : [[false,'form']],
|
|
|
+ target : 'new',
|
|
|
+ domain : [['type', '=', 'out_invoice'],['id','=', row.id]],
|
|
|
+ context : {},
|
|
|
+ flags : {'form': {'action_buttons': false, 'options': {'mode': 'view'}}},
|
|
|
+ res_id : row.id,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ e.stopImmediatePropagation();
|
|
|
+ },
|
|
|
+ volver: function(){
|
|
|
+ this.$el.find('#volver').empty();
|
|
|
+ this.$el.find('#grafico').empty();
|
|
|
+ this.$el.find('.bootstrap-table').show({
|
|
|
+ effect: 'drop',
|
|
|
+ direction: 'down',
|
|
|
+ duration: 200,
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 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;
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ // Cansultar
|
|
|
+ submitForm: function () {
|
|
|
+ var self = this;
|
|
|
+ this.fetchCurency().then(function(Currency) {
|
|
|
+ self.Currency = Currency;
|
|
|
+ return Currency;
|
|
|
+ }).then(function (Currency) {
|
|
|
+ return self.fecthResStore();
|
|
|
+ }).then(function(ResStore){
|
|
|
+ self.ResStore = ResStore;
|
|
|
+ self.$el.find('#current-store').append('<option value="9999999">Todas las SUC.</option>');
|
|
|
+ _.each(ResStore,function(item){
|
|
|
+ self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
|
|
|
+ });
|
|
|
+ return self.fecthAccountJournal();
|
|
|
+ }).then(function(AccountJournal){
|
|
|
+ self.AccountJournal = AccountJournal;
|
|
|
+ return self.fetchInvoiceV2();
|
|
|
+ }).then(function (invoices){
|
|
|
+ self.invoices = invoices;
|
|
|
+ return self.fetchInvoiceLine(invoices);
|
|
|
+ }).then(function (invoiceLines) {
|
|
|
+ self.invoiceLines = invoiceLines;
|
|
|
+ return self.fecthProduct(invoiceLines);
|
|
|
+ }).then(function(ProductProduct){
|
|
|
+ self.ProductProduct = ProductProduct;
|
|
|
+ return self.fecthCompanyCurrency();
|
|
|
+ }).then(function(resCompany){
|
|
|
+ self.resCompany = resCompany;
|
|
|
+ self.searchProduct();
|
|
|
+ return self.invoice_Currency();
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ fecthResStore: function(){
|
|
|
+ var self = this;
|
|
|
+ var defer = $.Deferred();
|
|
|
+ var field=['id', 'name'];
|
|
|
+ var ResStore = new model.web.Model('res.store');
|
|
|
+ ResStore.query(field).all().then(function(results){
|
|
|
+ defer.resolve(results);
|
|
|
+ });
|
|
|
+ return defer;
|
|
|
+ },
|
|
|
+
|
|
|
+ valorNull:function(dato){
|
|
|
+ var valor ="";
|
|
|
+ if (dato){
|
|
|
+ valor=dato;
|
|
|
+ }
|
|
|
+ return valor;
|
|
|
+ },
|
|
|
+
|
|
|
+ searchProduct: function () {
|
|
|
+ var self = this;
|
|
|
+ var results = self.ProductProduct;
|
|
|
+ results = _.map(results, function (item) {
|
|
|
+ return {
|
|
|
+ label: item.id + '- '+ ' [ ' + self.valorNull(item.default_code) + ' - ' + self.valorNull(item.ean13) + ' ] ' + item.name + ' ( ' + self.valorNull(item.attribute_str) + ' ) ' ,
|
|
|
+ value: item.id + '- '+ ' [ ' + self.valorNull(item.default_code) + ' - ' + self.valorNull(item.ean13) + ' ] ' + item.name + ' ( ' + self.valorNull(item.attribute_str) + ' ) '
|
|
|
+ }
|
|
|
+ });
|
|
|
+ self.$('#product').autocomplete({
|
|
|
+ source: results,
|
|
|
+ minLength:0,
|
|
|
+ search: function(event, ui) {
|
|
|
+ if (!(self.$('#product').val())){
|
|
|
+ self.fectSearch();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ close: function( event, ui ) {
|
|
|
+ self.fectSearch();
|
|
|
+ },
|
|
|
+ select: function(event, ui) {
|
|
|
+ self.fectSearch();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ fecthAccountJournal: function(){
|
|
|
+ var self = this;
|
|
|
+ var defer = $.Deferred();
|
|
|
+ var field = ['id', 'name','store_ids'];
|
|
|
+ var domain = [['active','=',true],['type','in',['sale','purchase']]];
|
|
|
+ var AccountJournal = new model.web.Model('account.journal');
|
|
|
+ AccountJournal.query(field).filter(domain).all().then(function(results){
|
|
|
+ defer.resolve(results);
|
|
|
+ });
|
|
|
+ return defer;
|
|
|
+ },
|
|
|
+
|
|
|
+ fecthCompanyCurrency: function(){
|
|
|
+ var self = this;
|
|
|
+ var defer = $.Deferred();
|
|
|
+ var currency = new model.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;
|
|
|
+ },
|
|
|
+
|
|
|
+ // Buscar Cambio de Monedas USD,PYG,ARG,BRL
|
|
|
+ fetchCurency: function () {
|
|
|
+ var defer = $.Deferred();
|
|
|
+ var currency_Rate = new model.web.Model('res.currency.rate');
|
|
|
+ var fields = ['id', 'name', 'currency_id', 'rate', 'create_date'];
|
|
|
+ var domain = [['currency_id', 'in', [166 , 20, 7, 3]]];
|
|
|
+ currency_Rate.query(fields).filter(domain).all().then(function (results) {
|
|
|
+ defer.resolve(results);
|
|
|
+ });
|
|
|
+ return defer;
|
|
|
+ },
|
|
|
+
|
|
|
+ // Invoice (FACTURAS)
|
|
|
+ fetchInvoiceV2: function () {
|
|
|
+ var self = this;
|
|
|
+ var filter ="[['state', 'in',['open','paid']],['type', '=', 'out_invoice']";
|
|
|
+ var journal_ids = _.flatten(_.map(self.AccountJournal, function (item) {
|
|
|
+ return item.id;
|
|
|
+ }));
|
|
|
+ if (journal_ids){
|
|
|
+ filter=filter.concat(",['journal_id', 'in',["+journal_ids+"]]");
|
|
|
+ }
|
|
|
+ filter=filter.concat("]");
|
|
|
+ var field =['id', 'type', 'number', 'origin', 'state', 'journal_id', 'currency_id', 'invoice_line','date_invoice','partner_id'];
|
|
|
+ var defer = $.Deferred();
|
|
|
+ var Invoice = new model.web.Model('account.invoice');
|
|
|
+ Invoice.query(field).filter(filter).all().then(function (results) {
|
|
|
+ defer.resolve(results);
|
|
|
+ });
|
|
|
+ return defer;
|
|
|
+ },
|
|
|
+
|
|
|
+ // Invoice line (Linea de Factura)
|
|
|
+ fetchInvoiceLine: function (invoices) {
|
|
|
+ var defer = $.Deferred();
|
|
|
+ var linesIds = _.flatten(_.map(invoices, function (item) {
|
|
|
+ return item.invoice_line;
|
|
|
+ }));
|
|
|
+ var InvoiceLine = new model.web.Model('account.invoice.line');
|
|
|
+ InvoiceLine.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 ProductProduct = new model.web.Model('product.product');
|
|
|
+ var fields = ['id','name', 'default_code', 'name_template','ean13', 'lst_price','type','attribute_str'];
|
|
|
+ ProductProduct.query(fields).filter([['id', 'in', porductIDS]]).all().then(function (results) {
|
|
|
+ defer.resolve(results)
|
|
|
+ });
|
|
|
+ return defer;
|
|
|
+ },
|
|
|
+
|
|
|
+ // Obtener Monedas de la Factura
|
|
|
+ getCurrency: function (id){
|
|
|
+ return _.find(this.Currency,function (curr) {
|
|
|
+ return _.contains(curr.currency_id,id);
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ // Actualizar cambio de las moneda de Factura
|
|
|
+ invoice_Currency: function(){
|
|
|
+ for (var i = 0; i < this.invoices.length; i++) {
|
|
|
+ var currency_new;
|
|
|
+ var item = this.invoices[i];
|
|
|
+ var id = item.currency_id[0];
|
|
|
+ currency_new = this.getCurrency(id);
|
|
|
+ if (!currency_new){
|
|
|
+ currency_new={};
|
|
|
+ currency_new.rate=1;
|
|
|
+ }
|
|
|
+ this.invoices[i].rate=(currency_new.rate);
|
|
|
+ }
|
|
|
+ return this.fectUtility();
|
|
|
+ },
|
|
|
+
|
|
|
+ // Obtener la Detalles de la Factura
|
|
|
+ getInvoice: function (id_line){
|
|
|
+ return _.find(this.invoices, function (inv) {
|
|
|
+ return _.contains(inv.invoice_line, id_line);
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ // Obtener las lineas de las Facturas
|
|
|
+ getProduct: function(pro_id){
|
|
|
+ var self = this;
|
|
|
+ return _.find(self.ProductProduct, function(prod){
|
|
|
+ return _.contains(pro_id, prod.id);
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ getAccountJournal: function (id) {
|
|
|
+ var self = this;
|
|
|
+ return _.filter(self.AccountJournal,function (item) {
|
|
|
+ return item.id === id;
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ fectUtility: function(){
|
|
|
+ var self = this;
|
|
|
+ var data=[];
|
|
|
+ var item;
|
|
|
+ var invoice;
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ var store_id = self.getAccountJournal(invoice.journal_id[0]);
|
|
|
+ if(store_id.length > 0){
|
|
|
+ data.push({
|
|
|
+ id : invoice.id,
|
|
|
+ number : (invoice.number),
|
|
|
+ id_product : producto.id,
|
|
|
+ name : (item.name),
|
|
|
+ quantity : accounting.formatNumber((item.quantity),0, ".", ","),
|
|
|
+ price_unity : accounting.formatNumber((producto.lst_price),2, ".", ","),
|
|
|
+ standar_price : accounting.formatNumber((item.price_unit / invoice.rate),2, ".", ","),
|
|
|
+ utility : accounting.formatNumber(((item.price_unit / invoice.rate) - (producto.lst_price)),2, ".", ","),
|
|
|
+ utility_porc: accounting.formatNumber(((((item.price_unit / invoice.rate)*100)/(producto.lst_price))-100),0, ".", ","),
|
|
|
+ journal_id :(invoice.journal_id[0]),
|
|
|
+ journal_name :(invoice.journal_id[1]),
|
|
|
+ date_create :moment(invoice.date_invoice).format("DD/MM/YYYY"),
|
|
|
+ date_invoice : (invoice.date_invoice),
|
|
|
+ store_id : store_id[0].store_ids[0],
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ self.content = data;
|
|
|
+ this.loadTable(data);
|
|
|
+ },
|
|
|
+
|
|
|
+ fectSearch: function(){
|
|
|
+ var self = this;
|
|
|
+ var today = moment().format('YYYY-MM-DD');
|
|
|
+ var yesterday = moment().add(-1, 'days').format('YYYY-MM-DD');
|
|
|
+ var month = moment().format('YYYY-MM');
|
|
|
+ var last_month = moment().add(-1, 'months').format('YYYY-MM');
|
|
|
+ var product = this.$el.find('#product').val().split('-');
|
|
|
+ var desde =this.$el.find('#from').val();
|
|
|
+ var hasta =this.$el.find('#to').val();
|
|
|
+ var store = this.$el.find('#current-store').val();
|
|
|
+ var content = self.content;
|
|
|
+
|
|
|
+ if ($('#A').is(":checked")){
|
|
|
+ content = _.filter(content, function (inv){
|
|
|
+ return moment(inv.date_invoice).format('YYYY-MM-DD') == today;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if ($('#B').is(":checked")){
|
|
|
+ content = _.filter(content, function (inv){
|
|
|
+ return moment(inv.date_invoice).format('YYYY-MM-DD') == yesterday;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if ($('#C').is(":checked")){
|
|
|
+ content = _.filter(content, function (inv){
|
|
|
+ return moment(inv.date_invoice).format('YYYY-MM') == month;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if ($('#D').is(":checked")){
|
|
|
+ content = _.filter(content, function (inv){
|
|
|
+ return moment(inv.date_invoice).format('YYYY-MM') == last_month;
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($('#Z').is(":checked")){
|
|
|
+ $('#datepicker').css('display','block');
|
|
|
+ if (desde.length > 0){
|
|
|
+ var date= desde.split('/');
|
|
|
+ content = _.filter(content, function (inv){
|
|
|
+ return inv.date_invoice >= (date[2]+"-"+date[1]+"-"+date[0]);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (hasta.length > 0){
|
|
|
+ var date= hasta.split('/');
|
|
|
+ content = _.filter(content, function (inv){
|
|
|
+ return inv.date_invoice <= (date[2]+"-"+date[1]+"-"+date[0]);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ $('#datepicker').css('display','none');
|
|
|
+ }
|
|
|
+
|
|
|
+ if (product != ""){
|
|
|
+ content = _.filter(content, function(inv){
|
|
|
+ return inv.id_product == product[0];
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ if(store != 9999999){
|
|
|
+ content =_.filter(content, function (inv){
|
|
|
+ return inv.store_id == store;
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ self.loadTable(content)
|
|
|
+ },
|
|
|
+
|
|
|
+ loadTable:function(rowsTable){
|
|
|
+ var self = this;
|
|
|
+ self.rowsData = rowsTable;
|
|
|
+ var table = this.$el.find('#table');
|
|
|
+ table.bootstrapTable('load', rowsTable);
|
|
|
+ },
|
|
|
+
|
|
|
+ getObjetPdf: function(rowsTable){
|
|
|
+ var self = this;
|
|
|
+ var rows=self.rowsData;
|
|
|
+
|
|
|
+ return rows;
|
|
|
+ },
|
|
|
+
|
|
|
+ clickOnAction: function (e) {
|
|
|
+ var self = this;
|
|
|
+ var rowsNew;
|
|
|
+ var action = this.$el.find(e.target).val();
|
|
|
+ var getColumns=[];
|
|
|
+ var rows=[];
|
|
|
+ rowsNew = self.getObjetPdf();
|
|
|
+ var table = this.$el.find("#table");
|
|
|
+ var data2 = table.bootstrapTable('getVisibleColumns');
|
|
|
+ if (action === 'pdf') {
|
|
|
+ var dataNEW = _.map(data2, function (val){ return val.field});
|
|
|
+ _.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
|
|
|
+ }]);
|
|
|
+ });
|
|
|
+ // Llamar al pdf
|
|
|
+ this.drawPDF(_.flatten(getColumns),rows)
|
|
|
+ }
|
|
|
+ if (action === 'chart'){
|
|
|
+ var suc = this.$el.find('#current-journal').val();
|
|
|
+ if (suc == 9999999){
|
|
|
+ self.fectCharFilter();
|
|
|
+ }else{
|
|
|
+ $("#dialog" ).dialog({
|
|
|
+ autoOpen: true,
|
|
|
+ resizable: false,
|
|
|
+ modal: true,
|
|
|
+ title: 'Atención',
|
|
|
+ open: function() {
|
|
|
+ $(this).html('Para Generar el Gráfico debes Seleccionar todas las Sucursales');
|
|
|
+ },
|
|
|
+ show: {
|
|
|
+ effect: "shake",
|
|
|
+ duration: 300
|
|
|
+ },
|
|
|
+ hide: {
|
|
|
+ effect: "fade",
|
|
|
+ duration: 300
|
|
|
+ },
|
|
|
+ buttons: {
|
|
|
+ Aceptar: function() {
|
|
|
+ $(this).dialog('close');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ drawPDF: function (getColumns,rows) {
|
|
|
+ var self = this;
|
|
|
+ var rowsPdf=[];
|
|
|
+ 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 totalPagesExp = "{total_pages_count_string}";
|
|
|
+ var pdfDoc = new jsPDF('l');
|
|
|
+
|
|
|
+ var company = _.map(self.resCompany, function (map) {
|
|
|
+ return map.currency_id[1];
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ pdfDoc.autoTable(getColumns, rows, {
|
|
|
+ styles: { overflow: 'linebreak', fontSize: 8, columnWidth: 'wrap'},
|
|
|
+ columnStyles: {
|
|
|
+ number: {columnWidth: '13px'},
|
|
|
+ date_create :{columnWidth: '13px'},
|
|
|
+ name :{columnWidth: '8px'},
|
|
|
+ quantity :{halign:'right',columnWidth: '5px'},
|
|
|
+ price_unity : {halign:'right',columnWidth: '16px'},
|
|
|
+ standar_price : {halign:'right',columnWidth: '8px'},
|
|
|
+ utility : {halign:'right',columnWidth: '9px'},
|
|
|
+ utility_porc : {halign:'right',columnWidth: '9px'},
|
|
|
+ },
|
|
|
+ margin: { top: 16, horizontal: 7},
|
|
|
+ addPageContent: function (data) {
|
|
|
+ pdfDoc.setFontSize(12);
|
|
|
+ pdfDoc.setFontStyle('bold');
|
|
|
+ pdfDoc.setTextColor(40);
|
|
|
+ pdfDoc.text('Análisis de utilidad - diferencia de precios', data.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, data.settings.margin.left,14);
|
|
|
+ }
|
|
|
+ // FOOTER
|
|
|
+ var str = "Pagina " + data.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, data.settings.margin.left, pdfDoc.internal.pageSize.height - 5);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ if (typeof pdfDoc.putTotalPages === 'function') {
|
|
|
+ pdfDoc.putTotalPages(totalPagesExp);
|
|
|
+ }
|
|
|
+ pdfDoc.save('Análisis de utilidad - diferencia de precios.pdf')
|
|
|
+ },
|
|
|
+
|
|
|
+ });
|
|
|
+}
|