// -*- coding: utf-8 -*- function spaProCriaAjax() { var xmlhttp; try { xmlhttp = new XMLHttpRequest(); } catch (ie1) { try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (ie2) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { xmlhttp = false; } } } return xmlhttp; } function spaProTrataAjax(oObj) { lRet = true; if (oAjax.readyState == 4) { if (oAjax.status == 200) { // Estou usando json oJson = eval("(" + oAjax.responseText + ")"); if (oAjax.responseText.indexOf("status") != -1) { lRet = spaProGeraResult(oObj,oJson); } } } return lRet; } function spaProVerifLogin() { nStatus = 0; oUsuario = document.getElementById("spa-pro-usuario"); oSenha = document.getElementById("spa-pro-senha"); if (oUsuario.value.length == 0 || oSenha.value.length == 0) { nStatus = 1; } if (nStatus == 0) { oAjax = spaProCriaAjax(); if (oAjax) { // **cURL = "principal.php?" + "us=" + oUsuario.value + "&" + "se=" + oSenha.value; cURL = "spa_query.php?tp=8&us=" + oUsuario.value + "&se=" + oSenha.value + "&sr=" + gcSpaSrInqPro; oAjax.open('GET',cURL,false); oAjax.send(null); oResultado = document.getElementById("spa-pro-resultado"); nStatus = spaProTrataAjax(oResultado) ? 0 : 2; } } switch (nStatus) { case 0: gcSpaProUsu = oUsuario.value; gcSpaProSen = oSenha.value; document.getElementById("spa-pro-login").style.display = "none"; document.getElementById("spa-pro-resultado").style.display = "block"; break; case 1: window.alert("Voc\u00EA deve informar o usu\u00E1rio e a senha."); oUsuario.select(); oUsuario.focus(); break; case 2: window.alert("Usu\u00E1rio e/ou senha inv\u00E1lidos."); oUsuario.select(); oUsuario.focus(); break; } } function spaProGeraResult(oObj,oJson) { lRet = true; if (oJson.status == 0) { cConteudo = '

' + '
' + '
   Proprietário: ' + oJson.pro[0].nome + '
Codigo: ' + oJson.pro[0].cod + '   
'; if (oJson.servs == 0) { cConteudo += '
' + '' + '' + '' + '' + '' + '
' + '' + 'Extrato' + '' + '' + '' + 'Informe de rendimentos
' + '

'; } cExibe = (oJson.servs == 1) ? "block" : "none"; cVisivel = (oJson.servs == 1) ? "visible" : "hidden"; cConteudo += '
'; /* * Extratos */ if (oJson.servs == 0 || oJson.servs == 1) { cExtrato = 'Para consultar ou imprimir o extrato clique sobre sua data ou saldo

' + '' + '' + ''; for (i = 0; i < oJson.extratos.length; i++) { cChave = oJson.pro[0].cod + "," + oJson.extratos[i].codverif + "," + oJson.extratos[i].datapg + "," + oJson.extratos[i].datual cExtrato += ''; if (oJson.extratos[i].saldosemfor < 0) { cFontesaldo = ""; } else { cFontesaldo = ""; } cClasseEsq = (i % 2 == 0) ? "spa-pro-tab-itens-det-e-p" : "spa-pro-tab-itens-det-e-i"; cClasseDir = (i % 2 == 0) ? "spa-pro-tab-itens-det-d-p" : "spa-pro-tab-itens-det-d-i"; cExtrato += '' + ''; } if (i > 0) { cExtrato += "
Atualizado emSaldo disponível
' + '' + oJson.extratos[i].datu + '
' + '' + cFontesaldo + oJson.extratos[i].saldo + '
"; cConteudo += cExtrato; } else { cConteudo += "
Não há saldo em aberto.
"; } } /*==================== ALTERAÇÃO FEITA EM 30/03/2012 PARA EXIBIR EXTRATOS PAGOS ======================*/ cExtratopago = '

Histórico de Extratos Pagos
' + '
' + '' + ''; for (i = 0; i < oJson.extratos_pagos.length; i++) { cChavepago = oJson.pro[0].cod + "," + oJson.extratos_pagos[i].codverif + "," + oJson.extratos_pagos[i].datapg + "," + oJson.extratos_pagos[i].datual cExtratopago += ''; cClasseEsq = (i % 2 == 0) ? "spa-pro-tab-itens-det-e-p" : "spa-pro-tab-itens-det-e-i"; cClasseDir = (i % 2 == 0) ? "spa-pro-tab-itens-det-d-p" : "spa-pro-tab-itens-det-d-i"; cExtratopago += '' + ''; } if (i > 0) { cExtratopago += "
Pago emValor Pago
' + oJson.extratos_pagos[i].data_pagt + '
' + oJson.extratos_pagos[i].saldo + '
"; cConteudo += cExtratopago; } else { cConteudo += "
Não há histórico de extratos pagos.
"; } /*==================== FIM DA ALTERAÇÃO FEITA EM 30/03/2012 ======================*/ cExibe = (oJson.servs == 2) ? "block" : "none"; cVisivel = (oJson.servs == 2) ? "visible" : "hidden"; cConteudo += '
' + '
'; /* * Informes de rendimentos */ if (oJson.servs == 0 || oJson.servs == 2) { cInforme = 'Para consultar ou imprimir um informe de rendimentos clique sobre o ano desejado

' + '' + ''; // + //''; for (i = 0; i < oJson.informes.length; i++) { cChave = oJson.pro[0].cod + "," + oJson.informes[i].ano; cInforme += ''; cClasseEsq = (i % 2 == 0) ? "spa-pro-tab-itens-det-e-p" : "spa-pro-tab-itens-det-e-i"; cClasseDir = (i % 2 == 0) ? "spa-pro-tab-itens-det-d-p" : "spa-pro-tab-itens-det-d-i"; cInforme += ''; } if (i > 0) { cInforme += "
Ano
Saldo disponível
' + oJson.informes[i].ano + '
"; cConteudo += cInforme; } else { cConteudo += '
Nenhum informe de rendimentos disponível.
'; } } cConteudo += '
'; oObj.innerHTML = cConteudo + '
' + '
' + '
'; } else { lRet = false; } return lRet; } function spaProExibeConteudo(oObj) { oExtrato = document.getElementById("spa-pro-extrato"); oInforme = document.getElementById("spa-pro-informe"); if (oObj.value == "E") { oInforme.style.visibility = "hidden"; oInforme.style.display = "none"; oExtrato.style.visibility = "visible"; oExtrato.style.display = "block"; } else if (oObj.value == "I") { oExtrato.style.visibility = "hidden"; oExtrato.style.display = "none"; oInforme.style.visibility = "visible"; oInforme.style.display = "block"; } } function spaProFechaPesquisa() { document.getElementById("spa-pro-extrato").style.visibility = "hidden"; document.getElementById("spa-pro-informe").style.visibility = "hidden"; document.getElementById("spa-pro-resultado").style.display = "none"; document.getElementById("spa-pro-login").style.display = "block"; document.getElementById("spa-pro-usuario").value = ""; document.getElementById("spa-pro-senha").value = ""; document.getElementById("spa-pro-usuario").focus(); } function spaProLinkOver(oObj) { //oObj.style.color = "#0000CC"; oObj.style.cursor = "hand"; /* * Um "hack" maluco necessário para o Firefox. Seria um bug ou uma feature? * Curioso é que no IE, com ou sem esta linha, tudo funciona perfeitamente. */ oObj.style.cursor = "pointer"; } function spaProLinkOut(oObj) { //oObj.style.color = "#000000"; oObj.style.cursor = "pointer"; } function spaProExibeExtrato(oObj) { /* * O Firefox só obedece width e height. A janela traz barra de endereço, statusbar e permite redimensionamento. * Só é possível mudar este comportamento em about:config. */ cID = oObj.id; cItem = cID.substring(cID.indexOf("_") + 1); cURL = "spa_query.php?tp=9&id=" + document.getElementById("spa-pro-chave-e_" + cItem).value + "&sr=" + gcSpaSrInqPro + "&us=" + gcSpaProUsu + "&se=" + gcSpaProSen; window.open(cURL,"_blank","width=850,height=" + window.clientHeight + ",resizable=1,scrollbars=1,menubar=1,toolbar=1"); } function spaProExibeExtratopago(oObj) { /* * O Firefox só obedece width e height. A janela traz barra de endereço, statusbar e permite redimensionamento. * Só é possível mudar este comportamento em about:config. */ cID = oObj.id; cItem = cID.substring(cID.indexOf("_") + 1); cURL = "spa_query.php?tp=9&id=" + document.getElementById("spa-pro-chave-epg_" + cItem).value + "&sr=" + gcSpaSrInqPro + "&us=" + gcSpaProUsu + "&se=" + gcSpaProSen; window.open(cURL,"_blank","width=850,height=" + window.clientHeight + ",resizable=1,scrollbars=1,menubar=1,toolbar=1"); } function spaProExibeInforme(oObj) { cID = oObj.id; cItem = cID.substring(cID.indexOf("_") + 1); /** cURL = "informe.php?id=" + document.getElementById("chave-i_" + cItem).value; window.open(cURL,"_blank","width=850,height=" + window.clientHeight + ",resizable=1,scrollbars=1,menubar=1,toolbar=1"); **/ cURL = "spa_query.php?tp=10&id=" + document.getElementById("spa-pro-chave-i_" + cItem).value + "&sr=" + gcSpaSrInqPro + "&us=" + gcSpaProUsu + "&se=" + gcSpaProSen; window.open(cURL,"_blank","width=850,height=" + window.clientHeight + ",resizable=1,scrollbars=1,menubar=1,toolbar=1"); } function spaProFrmSen() { oAjax = spaProCriaAjax(); if (oAjax) { cURL = "spa_query.php?tp=19&sr=" + gcSpaSrInqPro; oAjax.open('GET',cURL,false); oAjax.send(null); if (oAjax.readyState == 4) { if (oAjax.status == 200) { oDiv = document.getElementById(gcSpaIDCtn); oDiv.innerHTML = oAjax.responseText; document.getElementById("spa-pro-usuario").focus(); cNav = navigator.userAgent; lMSIE = (cNav.indexOf("MSIE") != -1); if (lMSIE) { document.getElementById("spa-pro-usuario").focus(); } } } } } function spaProAltSen() { nStatus = 0; oUsuario = document.getElementById("spa-pro-usuario"); oSenha = document.getElementById("spa-pro-senha"); oNovSen = document.getElementById("spa-pro-nov-sen"); oConfSen = document.getElementById("spa-pro-conf-sen"); if (oUsuario.value.length == 0 || oSenha.value.length == 0) { nStatus = 1; } else if (oNovSen.value.length == 0 || oConfSen.value.length == 0) { nStatus = 2; } else if (oNovSen.value != oConfSen.value) { nStatus = 3; } if (nStatus == 0) { oAjax = spaProCriaAjax(); if (oAjax) { cURL = "spa_query.php?tp=20&us=" + oUsuario.value + "&se=" + oSenha.value + "&sr=" + gcSpaSrInqPro + "&nse=" + oNovSen.value; oAjax.open('GET',cURL,false); oAjax.send(null); if (oAjax.readyState == 4) { if (oAjax.status == 200) { if (oAjax.responseText.indexOf("*NE*") != -1) { nStatus = 4; } else if (oAjax.responseText.indexOf("*ER*") != -1) { nStatus = 5; } else { oDiv = document.getElementById(gcSpaIDCtn); oDiv.innerHTML = oAjax.responseText; } } } } } switch (nStatus) { /* case 0: gcSpaProUsu = oUsuario.value; gcSpaProSen = oSenha.value; document.getElementById("spa-pro-login").style.display = "none"; document.getElementById("spa-pro-resultado").style.display = "block"; break; */ case 1: window.alert("Voc\u00EA deve informar o usu\u00E1rio e a senha atual."); oUsuario.select(); oUsuario.focus(); break; case 2: window.alert("Voc\u00EA deve digitar a nova senha 2 vezes para confirm\u00E1-la."); oNovSen.select(); oNovSen.focus(); break; case 3: window.alert("A nova senha digitada n\u00E3o confere com a confirma\u00E7\u00E3o."); oNovSen.select(); oNovSen.focus(); break; case 4: window.alert("Usu\u00E1rio e/ou senha inv\u00E1lidos."); oUsuario.select(); oUsuario.focus(); break; case 5: window.alert("Erro desconhecido. A senha n\u00E3o p\u00F4de ser alterada!"); oUsuario.select(); oUsuario.focus(); break; } } function spaProVoltSen() { oAjax = spaProCriaAjax(); if (oAjax) { cURL = "spa_query.php?tp=7&sr=" + gcSpaSrInqPro; oAjax.open('GET',cURL,false); oAjax.send(null); if (oAjax.readyState == 4) { if (oAjax.status == 200) { oDiv = document.getElementById(gcSpaIDCtn); oDiv.innerHTML = oAjax.responseText; document.getElementById("spa-pro-usuario").focus(); cNav = navigator.userAgent; lMSIE = (cNav.indexOf("MSIE") != -1); if (lMSIE) { document.getElementById("spa-pro-usuario").focus(); } } } } } function spaProEsqSen() { oAjax = spaProCriaAjax(); if (oAjax) { cURL = "spa_query.php?tp=21&sr=" + gcSpaSrInqPro; oAjax.open('GET',cURL,false); oAjax.send(null); if (oAjax.readyState == 4) { if (oAjax.status == 200) { oDiv = document.getElementById(gcSpaIDCtn); oDiv.innerHTML = oAjax.responseText; } } } }