var renderCMP = new RenderCMP(); var renderCIT = new RenderCIT(); var renderARQ = new RenderARQ(); var renderFRN = new RenderFRN(); var renderGeral = new RenderGeral(); var renderPRD = new RenderPRD(); function RenderPRD() { this.renderPrdGrpPraVenda = function (row, column, value, defaultHtml) { var rowData = $('#mainGrid').jqxGrid('getrowdata', row); value = value ? value.toUpperCase() : 'N'; var g = tabelas.get('contahub.entities.GrupoProduto', rowData.grp); var valueG = value; if (g) { valueG = g.grp_venda ? g.grp_venda.toUpperCase() : 'S'; } var html = value=='S' ? '' : ''; html += value + ''; if (value!=valueG) { console.log('1', value, valueG, rowData); html += '|G:'; html += valueG=='S' ? '' : ''; html += valueG + ''; } return grid.replaceInDefaultHTML(defaultHtml, html); } this.renderPrdGrpLocAtivo = function (row, column, value, defaultHtml) { var rowData = $('#mainGrid').jqxGrid('getrowdata', row); value = value ? value.toUpperCase() : 'N'; var l = tabelas.get('contahub.entities.Local', rowData.loc); var g = tabelas.get('contahub.entities.GrupoProduto', rowData.grp); var valueG = value; var valueL = value; if (value=='S') { if (g) { valueG = g.grp_inativo && (g.grp_inativo.toUpperCase()=='S') ? 'N' : 'S'; } if (l) { valueL = l.loc_inativo && (l.loc_inativo.toUpperCase()=='S') ? 'N' : 'S'; } } var html = value=='S' ? '' : ''; html += value + ''; if (value!=valueG) { html += '|G:'; html += valueG=='S' ? '' : ''; html += valueG + ''; } if (value!=valueL) { html += '|Loc:'; html += valueL=='S' ? '' : ''; html += valueL + ''; } return grid.replaceInDefaultHTML(defaultHtml, html); } } function RenderGeral() { this.renderNFe = function(data, type, full, meta) { var s = ''; if (index.nfeDesc) { if (data) { var cor = 'blue'; if (data!=index.nfe) { cor = 'red'; } return '#' + data + ''; } return '-'; } return ''; } } function RenderCIT() { this.descPrdFprObs = function(data, type, full, meta) { var s = ''; var delim = ''; if (full.prd_desc) { s += "" + full.prd_desc + ""; delim = " / "; } if (full.cit_descfornecedor) { s += delim + '' + full.cit_descfornecedor + '' ; if (full.cit_descfornecedor!=full.fpr_desc) { s += ' / ' + full.fpr_desc + '' ; } s += ''; } else if (full.fpr_desc) { s += ' ' + full.fpr_desc + ''; } if (full._obs) { var ss = full._obs; if (ss.indexOf('[p:')!=-1) { var s2 = ss.substring( ss.indexOf('[p:') + 3); var s1 = ss.substring( 0, ss.indexOf('[p:') + 3); var s3 = '-f:'; var s4 = s2.substring( s2.indexOf(s3) + s3.length); var s2 = s2.substring( 0, s2.indexOf(s3) ); var s5 = s4.substring( s4.indexOf(']') ); var s4 = s4.substring( 0, s4.indexOf(']') ); ss = s1 + '' + s2 + '' + s3 + '' + s4 + '' + s5; console.log(s1,s2,s3,s4,s5,ss); } s += ' ' + ss + ''; s = '*' + s; } if (!util.strEmpty(full.cit_obs)) { s += ' ' + '[' + full.cit_obs + ']' + '' ; } if (full.prd_desc) { return s; } if (full.fpr_diluinacompra=='S') { return '(dilui na compra)   ' + s; } return s; } this.qtdUnidFrnPrd = function(data, type, full, meta) { if (full.cit_qtd==full.cit_qtdfornecedor) { if (!(full.prd_unid)) { full.prd_unid = ''; } if ( full.cit_unidfornecedor && full.prd_unid && ( full.cit_unidfornecedor.toUpperCase()==full.prd_unid.toUpperCase() ) ) { return '' + full.cit_qtd + '' + full.prd_unid + ''; } } if (full.cit_qtd) { if (full.cit_qtdfornecedor) { return '' + '' + full.cit_qtdfornecedor + '' + full.cit_unidfornecedor + '' + ' = ' + full.cit_qtd + '' + full.prd_unid + '' ; } return '' + '' + full.cit_qtd + '' + full.prd_unid + '' ; } if (full.cit_qtdfornecedor) { return '' + '' + full.cit_qtdfornecedor + '' + full.cit_unidfornecedor + '' + ' = ?' ; } return '' + '?' ; } this.moneyFrn = function(data, type, full, meta) { var s = render.money(data); return '' + s + ''; } this.custoUnidPrd = function(data, type, full, meta) { if (!full.cit_qtd) { return '?'; } var v1 = util.arred3( full.cit_vrtotal / full.cit_qtd ); var v0 = full.cit_vrunitario; var s = '' + util.money( v1 ,'$') + '/' + full.prd_unid + ''; if (util.money( v0 )!=util.money( v1 ) ) { s = '' + s + ''; } return s; } this.custoUnidFrn = function(data, type, full, meta) { var v1 = full.cit_vrtotal / full.cit_qtd; var v0 = full.cit_vrunitario; if (v0) { var s = '' + util.money( v0 ,'$') + '/' + full.cit_unidfornecedor + ''; if (util.money( v0 )!=util.money( v1 ) ) { s = '' + s + ''; } return s; } var s = '' + util.money( v1 ,'$') + '/' + full.prd_unid + ''; return s; } this.dtExpiracao = function(data, type, full, meta) { if (!full.cit_dtexpiracao) { // if (full.prd_expira=='S') { return 'DEFINIR'; } return ''; } var s = render.dataDDMMMYYYY(full.cit_dtexpiracao); if (full.cit_dtexpiracao < new Date()) { s = '' + s + ''; } return s; } } function RenderARQ() { this.status = function(data, type, full, meta) { if (full.cmp_dtestoque) { return '
Recebido'; } if (full.arq_tipo.indexOf('NFe')==0) { if ( (full.arq_conteudo=='') || (!full.arq_conteudo) ) { return '
Ñ baixado'; } if (full.arq_produtosassociados!='S') { return '
Ñ Associado'; } if (full.arq_erro && (full.arq_erro!='')) { return '
Erro'; } return ''; } return '-'; } this.tipoChave = function(data, type, full, meta) { var s = full.arq_tipo; if ( (s.indexOf('-')>0) || (s.indexOf('NF')!=0) ) { s = '' + s + ''; } if (full.arq_chave) { s += ' ' + full.arq_chave; } return s; } } function RenderFRN() { this.descObs30small = function(data, type, full, meta) { var s = full.frn_alias; if (full.cmp_obs) { s += " (" + full.cmp_obs + ")"; } console.error(s,full); if ((s) && (s.length>30)) { s = '' + s + ''; } return s; } } function RenderCMP() { this.frnObs30small = function(data, type, full, meta) { var s = full.frn_alias; if ( !(s)) { s = ''; } if (full.cmp_obs) { if (full.cmp_obs!='') { s += ' (' + full.cmp_obs + ')'; } } if (s.length>30) { s = '' + s + ''; } return s; } }