/* * To change this template, choose Tools | Templates * and open the template in the editor. */ var ajax_; var funcName; var dispErro; function GetAjax(tipo, url, assinc, funcName, dispErro) { this.funcName = funcName; this.dispErro = dispErro; if (window.XMLHttpRequest) { /* * Firefox, opera, safari */ ajax_ = new XMLHttpRequest(); } else if (window.ActiveXObject) { /* * Internet Explorer */ ajax_ = new ActiveXObject("Msxml2.XMLHTTP"); if (!ajax_) { ajax_ = new ActiveXObject("Microsoft.XMLHTTP"); } } if (ajax_) { iniciaRequisicao(tipo, url, assinc); } else if (this.dispErro) alert("Seu navegador não possui suporta ao Ajax!"); } function iniciaRequisicao(tipo, url, bool) { /* * Inicializa e passa a funcao para tratar os dados */ ajax_.onreadystatechange = this.funcName; ajax_.open(tipo, url, bool); ajax_.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=iso-8859-1"); ajax_.send(null); } function GetStatusAjax() { return (ajax_.readyState == 4) && (ajax_.status == 200); } /* * Dados retornados pelo servidor */ function GetDadosSupervisor() { if (GetStatusAjax()) { try { //Dados retornados em uma string var listaSuper = ajax_.responseText; if (listaSuper) { var tb = listaSuper.split('#'); if (!(tb[0].substr(0, 5).toUpperCase() == 'CLOSE')) { document.getElementById("tbDac").innerHTML = tb[0]; document.getElementById("tbAgente").innerHTML = tb[1]; if (document.getElementById('msgLogoff')) document.getElementById('msgLogoff').innerHTML = ""; } else { window.location.href = 'index.php?idProg=-1'; } } } catch (e) { ;//ignore exception } } // else if(this.dispErro) // alert("Não foi possível se comunicar com o servidor!") } function GetSupervisor(dac) { if (!dac) dac = !document.getElementById("dacAtivo") ? "0" : document.getElementById("dacAtivo").innerHTML; if (dac) { var url = "index.php?idProg=6&ajax=1&listaDacs=" + dac + GetIdRand(); GetAjax("GET", url, true, GetDadosSupervisor, true); } } function GetAgente() { try { var contrib = !document.formGeral['txtCliente'] ? 0 : document.formGeral['txtCliente'].value; var url = "index.php?idProg=14&idSubProg=3&ajax=1&contrib=" + contrib + GetIdRand(); GetAjax("GET", url, true, GetDadosAgente, true); } catch (e) { ; } } function GetDadosAgente() { if (GetStatusAjax()) { //Dados retornados em uma string var listaSuper = ajax_.responseText; if (document.getElementById("ajabd")) { var tb = listaSuper.split(';'); //for(i = 0; i < tb.length; i++) document.write(tb[i]+ "
"); //$result = $abd 0.";" . 1$tme .";" . 2$tma .";" . 3$atd .";" . 4$fila .";"; //$result .= 5$stAgtAtende .";" . 6$lgd .";" . 7$dura .";" . 8$qtFila .";" . 9$fone; if (tb[0].substr(0, 5).toUpperCase() == 'CLOSE') { window.close(); } else if (tb[0].substr(0, 3) == 999) { window.location.href = 'index.php?idProg=14'; } else if (document.getElementById("ajtme")) { document.getElementById("ajabd").innerHTML = tb[0]; document.getElementById("ajtme").innerHTML = tb[1]; document.getElementById("ajtma").innerHTML = tb[2]; document.getElementById("ajatd").innerHTML = tb[3]; document.getElementById("ajdac").innerHTML = tb[4]; document.getElementById("ajstatus").innerHTML = tb[5]; document.getElementById("ajlgd").innerHTML = tb[6]; document.getElementById("ajdura").innerHTML = tb[7]; document.getElementById("ajfila").innerHTML = tb[8]; document.getElementById("ajfone").innerHTML = tb[9]; document.getElementById("ajramal").innerHTML = tb[10]; document.getElementById("ajlogin").innerHTML = tb[11]; document.getElementById("ajhoraAtu").innerHTML = tb[12]; document.getElementById("ajproto").innerHTML = tb[13]; document.formGeral.txtCliente.value = tb[14]; if ((tb[13].substr(0, 1) == '') || (tb[13].substr(0, 1) == ' ')) { document.formGeral.txtCliente.value = ""; } } } } //else if(this.dispErro) // alert("Não foi possível se comunicar com o servidor!") } function TestaAsterisk() { try { document.getElementById("aguarde").style.display = 'block'; document.getElementById("aguarde").style.visibility = 'visible'; var urlAst = document.formGeral.prm_url_asterisk.value; var url = "index.php?idProg=26&url=" + urlAst + "&idSubProg=3&ajax=1" + GetIdRand(); GetAjax("GET", url, true, GetAsterisk, true); } catch (e) { ; } } function GetAsterisk() { if (GetStatusAjax()) { document.getElementById("aguarde").style.display = 'none'; document.getElementById("aguarde").style.visibility = 'hidden'; var clasItem = ajax_.responseText; clasItem = clasItem.split(';'); if (clasItem[0] == 'OK') alert("Teste realizado com exito!"); else alert("Não foi possível realizar a operação!"); } } function CarregaItem() { try { var indice = document.forms[0].listaClas.selectedIndex; var id = document.forms[0].listaClas.options[indice].value; var url = "index.php?idProg=14&idSubProg=3&idItem=" + id + "&ajax=1" + GetIdRand(); GetAjax("GET", url, true, GetItemClas, true); } catch (e) { ; } } function GetItemClas() { if (GetStatusAjax()) { var clasItem = ajax_.responseText; if (document.getElementById("clasItem")) document.getElementById("clasItem").innerHTML = clasItem; } } function ClassificaRegistra() { try { var indice = document.forms[0].listaClas.selectedIndex; var id = document.forms[0].listaClas.options[indice].value; indice = document.forms[0].listaItem.selectedIndex; var idItem = document.forms[0].listaItem.options[indice].value; var idContrib = document.formGeral.txtCliente.value; var msg = ""; if (id == 0) msg = "Selecione a classificação!"; else if (idItem == 0) msg = "Selecione um item da classificação!" if (msg != "") { document.getElementById('msgSistema').innerHTML = msg; } else { var url = "index.php?idProg=14&idSubProg=3&idItem=" + id + "&idClasItem=" + idItem + "&contrib_id=" + idContrib + "&ajax=1" + GetIdRand(); GetAjax("GET", url, true, GetClasregistra, true); } } catch (e) { ; } } function GetClasregistra() { if (GetStatusAjax()) { var clasItem = ajax_.responseText; if (clasItem) { var tb = clasItem.split('@'); if (document.getElementById("classifica")) document.getElementById("classifica").innerHTML = tb[0]; if (document.getElementById("clasItem")) document.getElementById("clasItem").innerHTML = tb[1]; document.getElementById('msgSistema').innerHTML = tb[2]; } } } function PausaAgente(mat, ramal, dac) { try { var url = "index.php?idProg=6&ajax=1&pausaAgente=" + mat + "&ramal=" + ramal + "&dac=" + dac + GetIdRand(); GetAjax("GET", url, true, GetPausaAgente, true); } catch (e) { ; } } function GetPausaAgente() { if (GetStatusAjax()) { var clasItem = ajax_.responseText; document.getElementById('msgLogoff').innerHTML = clasItem; } } function LogoffAgente(mat, mod, dac) { try { var url = "index.php?idProg=6&ajax=1&logoff=" + mat + "&modu=" + mod + "&dac=" + dac + GetIdRand(); GetAjax("GET", url, true, GetLogoffAgente, true); } catch (e) { ; } } function GetLogoffAgente() { if (GetStatusAjax()) { var clasItem = ajax_.responseText; document.getElementById('msgLogoff').innerHTML = clasItem; } } function GetAgtFromProdAgt() { var indice = document.formGeral.listaDacs.selectedIndex; var dac = document.formGeral.listaDacs.options[indice].value; indice = document.formGeral.listaAgente.selectedIndex; var codAgt = document.formGeral.listaAgente.options[indice].value; var dtIni = document.formGeral.dataIni.value; var dtFim = document.formGeral.dataFim.value; if (validaData(document.formGeral.dataIni) && validaData(document.formGeral.dataFim)) { var url = "index.php?idProg=0&ajax=1&listaDacs=" + dac + "&dataIni=" + dtIni + "&dataFim=" + dtFim + "&codAgt=" + codAgt + GetIdRand(); GetAjax("GET", url, true, GetAgentes, true); } } function GetAgtFromTransfer() { var indice = document.formGeral.listaDacs.selectedIndex; var dac = document.formGeral.listaDacs.options[indice].value; indice = document.formGeral.listaAgente.selectedIndex; var codAgt = document.formGeral.listaAgente.options[indice].value; var dtIni = document.formGeral.dataIni.value.substr(0, 10); var dtFim = document.formGeral.dataFim.value.substr(0, 10); if (validaData(document.formGeral.dataIni) && validaData(document.formGeral.dataFim)) { var url = "index.php?idProg=7&ajax=1&listaDacs=" + dac + "&dataIni=" + dtIni + "&dataFim=" + dtFim + "&codAgt=" + codAgt + GetIdRand(); GetAjax("GET", url, true, GetAgentes, true); } } function GetAgtFromAudio() { var indice = document.formGeral.listaDacs.selectedIndex; var dac = document.formGeral.listaDacs.options[indice].value; indice = document.formGeral.listaAgente.selectedIndex; var codAgt = document.formGeral.listaAgente.options[indice].value; var dtIni = document.formGeral.dataIni.value; var dtFim = document.formGeral.dataFim.value; if (validaData(document.formGeral.dataIni) && validaData(document.formGeral.dataFim)) { var url = "index.php?idProg=23&ajax=1&listaDacs=" + dac + "&dataIni=" + dtIni + "&dataFim=" + dtFim + "&codAgt=" + codAgt + GetIdRand(); GetAjax("GET", url, true, GetAgentes, true); } } function GetAgentes() { if (GetStatusAjax()) { document.getElementById('agentes').innerHTML = ajax_.responseText; } } function GetIdRand() { return "&idRad=" + new Date().getTime(); } function replaceText(el, text) { if (el != null) { clearText(el); var newNode = document.createTextNode(text); el.appendChild(newNode); } } function clearText(el) { if (el != null) { if (el.childNodes) { for (var i = 0; i < el.childNodes.length; i++) { var childNode = el.childNodes[i]; el.removeChild(childNode); } } } } function getText(el) { var text = ""; if (el != null) { if (el.childNodes) { for (var i = 0; i < el.childNodes.length; i++) { var childNode = el.childNodes[i]; if (childNode.nodeValue != null) { text = text + childNode.nodeValue; } } } } return text; } function ListaItensClassifica(codItem, desc) { try { var url = "index.php?idProg=27&ajax=1&codItem=" + codItem + "&desc=" + desc + GetIdRand(); GetAjax("GET", url, true, GetItensClassifica, true); } catch (e) { ; } } function GetItensClassifica() { if (GetStatusAjax()) { var txt = ajax_.responseText; txt = txt.split("#"); document.getElementById('linhaDet').innerHTML = txt[0]; document.getElementById('lbTitle').innerHTML = txt[1]; } } function AddUserGp() { try { var indice = document.formGeral.lstUser.selectedIndex; var codUser = document.formGeral.lstUser.options[indice].value; indice = document.formGeral.lstGrupo.selectedIndex; var codGp = document.formGeral.lstGrupo.options[indice].value; if ((codUser > 0) && (codGp > 0)) { var url = "index.php?idProg=36&ajax=1&codUser=" + codUser + "&codGrup=" + codGp + "&addGrup=1" + GetIdRand(); GetAjax("GET", url, true, GetUserGp, true); } else alert('Selecione usuário e grupo!'); } catch (e) { alert(e); } } function GetUserGp() { if (GetStatusAjax()) { var get = ajax_.responseText; var txt = get.split(";"); if (txt[0] == "OK") { document.getElementById('grupoUser').innerHTML = RetornaPvirgula(txt[1]); document.getElementById('msg').innerHTML = RetornaPvirgula(txt[2]); } else { document.getElementById('msg').innerHTML = RetornaPvirgula(txt[1]); } window.setTimeout("LimpaObj('msg')", "10000"); } } function LimpaObj(name) { document.getElementById(name).innerHTML = ""; } function RemUserGp() { try { var indice = document.formGeral.lstGrupoUser.selectedIndex; var codUser = document.formGeral.lstGrupoUser.options[indice].value; indice = document.formGeral.lstGrupo.selectedIndex; var codGp = document.formGeral.lstGrupo.options[indice].value; if ((codUser > 0) && (codGp > 0)) { var url = "index.php?idProg=36&ajax=1&codUser=" + codUser + "&codGrup=" + codGp + "&remGrup=1" + GetIdRand(); GetAjax("GET", url, true, GetUserGp, true); } else alert('Selecione usuário e grupo!'); } catch (e) { alert(e); } } function AddFuncGp() { try { var indice = document.formGeral.lstFunc.selectedIndex; var codFunc = document.formGeral.lstFunc.options[indice].value; indice = document.formGeral.lstGrupo.selectedIndex; var codGp = document.formGeral.lstGrupo.options[indice].value; if ((codFunc > 0) && (codGp > 0)) { var url = "index.php?idProg=36&ajax=1&codFunc=" + codFunc + "&codGrup=" + codGp + "&addFunc=1" + GetIdRand(); GetAjax("GET", url, true, GetFuncGp, true); } else alert('Selecione função e grupo!'); } catch (e) { alert(e); } } function GetFuncGp() { if (GetStatusAjax()) { var get = ajax_.responseText; var txt = get.split(";"); if (txt[0] == "OK") { document.getElementById('grupoFunc').innerHTML = RetornaPvirgula(txt[1]); document.getElementById('msg').innerHTML = RetornaPvirgula(txt[2]); } else { document.getElementById('msg').innerHTML = RetornaPvirgula(txt[1]); } window.setTimeout("LimpaObj('msg')", "10000"); } } function RemFuncGp() { try { var indice = document.formGeral.lstGrupoFunc.selectedIndex; var codFunc = document.formGeral.lstGrupoFunc.options[indice].value; indice = document.formGeral.lstGrupo.selectedIndex; var codGp = document.formGeral.lstGrupo.options[indice].value; if ((codFunc > 0) && (codGp > 0)) { var url = "index.php?idProg=36&ajax=1&codFunc=" + codFunc + "&codGrup=" + codGp + "&remFunc=1" + GetIdRand(); GetAjax("GET", url, true, GetFuncGp, true); } else alert('Selecione função e grupo!'); } catch (e) { alert(e); } } function RetornaPvirgula(str) { return str.replace(/{#}/g, ";"); } function CarregaGrupo() { try { indice = document.formGeral.lstGrupo.selectedIndex; var codGp = document.formGeral.lstGrupo.options[indice].value; if (codGp > 0) { var url = "index.php?idProg=36&ajax=1&codGrup=" + codGp + "&getGpFunc=1" + GetIdRand(); GetAjax("GET", url, true, GetGpFunc, true); } else alert('Selecione função e grupo!'); } catch (e) { alert(e); } } function GetGpFunc() { if (GetStatusAjax()) { var get = ajax_.responseText; var txt = get.split(";"); document.getElementById('grupoUser').innerHTML = RetornaPvirgula(txt[0]); document.getElementById('grupoFunc').innerHTML = RetornaPvirgula(txt[1]); } } function SetTipoContrib(tp) { var tipo = ""; if (tp == 1) tipo = "CPF"; else if (tp == 2) tipo = "CRC"; else if (tp == 3) tipo = "Insc. Estadual"; else if (tp == 4) tipo = "CNPJ"; document.getElementById("contribTipo").innerHTML = tipo; } function GetDeptos() { try { var indice = document.formGeral.listaEmpresas.selectedIndex; var empresa = document.formGeral.listaEmpresas.options[indice].value; var url = "index.php?idProg=67&listaDeptos=1&ajax=1&empresa=" + empresa + GetIdRand(); GetAjax("GET", url, true, GetDadosDeptos, true); } catch (e) { ; } } function GetDadosDeptos() { if (GetStatusAjax()) { //Dados retornados em uma string var listaSuper = ajax_.responseText; document.getElementById("deptos").innerHTML = listaSuper; } } function SetUserFromConta() { try { var conta = document.formGeral.matricula.value; var url = "index.php?idProg=67&GetUser=1&ajax=1&matricula=" + conta + GetIdRand(); GetAjax("GET", url, true, GetUserFromConta, true); } catch (e) { ; } } function GetUserFromConta() { if (GetStatusAjax()) { //Dados retornados em uma string var listaSuper = ajax_.responseText; document.formGeral.nome.value = listaSuper; } } function SetMonitor() { try { var url = "index.php?idProg=82&ajax=1" + GetIdRand(); GetAjax("GET", url, true, GetMonitor, true); } catch (e) { ; } } function GetMonitor() { if (GetStatusAjax()) { //Dados retornados em uma string var listaSuper = ajax_.responseText; document.getElementById("agentes").innerHTML = listaSuper; } } function SetMonitor() { try { var url = "index.php?idProg=82&ajax=1" + GetIdRand(); GetAjax("GET", url, true, GetMonitor, true); } catch (e) { ; } } function SetCadFuncoesPbx(opcao, valIni) { try { var url = "populaFuncoes.php?opcao=" + opcao + "®Ini=" + valIni + GetIdRand(); GetAjax("GET", url, true, GetCadFuncoesPbx, true); } catch (e) { ; } } function GetCadFuncoesPbx() { if (GetStatusAjax()) { //Dados retornados em uma string var retorno = ajax_.responseText; alert(retorno); document.getElementById("itensFuncoes").innerHTML = retorno; } } function DeletaClassificacao(id) { if (confirm('Esta ação irá excluir a classificação selecionada! Deseja continuar?')) { try { var url = "index.php?idProg=85&formAction=6&ajax=1&tpItem=0&id=" + id + GetIdRand(); GetAjax("GET", url, true, ConfirmaDelecao, true); } catch (e) { ; } } } function DeletaClassificacaoItem(id) { if (confirm('Esta ação irá excluir item selecionado! Deseja continuar?')) { try { var url = "index.php?idProg=85&formAction=6&ajax=1&tpItem=1&id=" + id + GetIdRand(); GetAjax("GET", url, true, ConfirmaDelecao, true); } catch (e) { ; } } } function DeltetaMotivoPausa(id) { if (confirm('Esta ação irá excluir item selecionado! Deseja continuar?')) { try { var url = "index.php?idProg=86&formAction=6&ajax=1&tpItem=1&id=" + id + GetIdRand(); GetAjax("GET", url, true, ConfirmaDelecao, true); } catch (e) { ; } } } function ConfirmaDelecao() { if (GetStatusAjax()) { //Dados retornados em uma string var retorno = ajax_.responseText; var ret = retorno.split(';'); if (ret[0] == 'OK') { alert(ret[1]); ResetForm(); } else { alert(ret[1]); } } } function ResetForm() { document.formGeral.submit(); }