<?php
include("../sol/sessao.php");
//Conecta ao banco e abre query
$dados = new dados();
$dados->get_conexao();
VerificaModuloSuporte();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>SolBT - <?=$sitenome?></title>
<link rel="StyleSheet" type="text/css" href="../sol/includes/estilos.css" id="estilo" />
<script language='JavaScript' src='../sol/includes/FuncoesTela.js' type="text/javascript"></script>
<script language='JavaScript' type="text/javascript">
<!--
function Salvar()
{
String.prototype.trim = function() { return this.replace(/^\s+|\s+$/, ''); };
document.getElementById('titulo').value = document.getElementById('titulo').value.trim();
document.getElementById('prazo').value = document.getElementById('prazo').value.trim();
document.getElementById('descricao').value = document.getElementById('descricao').value.trim();
document.getElementById('outra_versao').value = document.getElementById('outra_versao').value.trim();
document.getElementById('banco').value = document.getElementById('banco').value.trim();
if (document.getElementById('titulo').value.length == 0)
{
alert('Informe o tÃtulo.');
document.getElementById('titulo').focus();
return;
}
//Valida data
var er = /^(([0-2]\d|[3][0-1])\/([0]\d|[1][0-2])\/[1-2][0-9]\d{2})$/;
b = document.getElementById('prazo').value;
if (document.getElementById('prazo').value.length > 0)
{
if(!er.test(b))
{
window.alert('Data do prazo inválida!\n\n* Para prazo indeterminado deixe o campo em branco.');
document.getElementById('prazo').value = '';
document.getElementById('prazo').focus();
return;
}
}
if (document.getElementById('prioridade').value == 0)
{
alert('Informe uma prioridade.');
document.getElementById('prioridade').focus();
return;
}
if (document.getElementById('tipo').value == 0)
{
alert('Informe o tipo do chamado.');
document.getElementById('tipo').focus();
return;
}
if (document.getElementById('cliente').value == '')
{
alert('Informe o solicitante/cliente.');
document.getElementById('cliente').focus();
return;
}
if (document.getElementById('sistema').value == 0)
{
alert('Informe o sistema.');
document.getElementById('sistema').focus();
return;
}
if (document.getElementById('andamento').value == 0)
{
alert('Informe pra onde o chamado será encaminhado.');
document.getElementById('andamento').focus();
return;
}
if (document.getElementById('descricao').value.length == 0)
{
alert('Informe a descrição inicial.');
document.getElementById('descricao').focus();
return;
}
//Posta
document.forms.frmChamado.submit();
}
function SelecionaModulo(valor)
{
ajax = InstanciaAJAX();
document.getElementById('modulo').options.length = 1;
document.getElementById('versao').options.length = 1;
OpcaoModulo = document.getElementById('opcaomodulo');
if (valor > 0)
{
ajax.open('POST', 'modulos.xml.php', true);
ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
ajax.onreadystatechange = function()
{
//Enquanto estiver processando emite a mensagem de aguarde
if(ajax.readyState == 1)
{
OpcaoModulo.innerHTML = 'Carregando módulos...';
}
//Após ser processado chama função processXML que vai varrer os dados
if(ajax.readyState == 4 )
{
if(ajax.responseXML)
{
processXML(ajax.responseXML);
}
else
{
//Caso não consiga ler o arquivo XML emite a mensagem e desabilita a lista de cidades
OpcaoModulo.innerHTML = 'Indeterminado';
}
}
}
}
//Passa o codigo do estado escolhido como parametro pro POST e envia
var params = 'id=' + valor;
ajax.send(params);
}
function processXML(obj)
{
//Pega a TAG modulo
var dataArray = obj.getElementsByTagName('modulo');
//Verifica o total de elementos contidos na TAG
if(dataArray.length > 0)
{
//Percorre o arquivo XML para extrair os dados
for(var i = 0 ; i < dataArray.length ; i++)
{
var item = dataArray[i];
//Conteudo dos campos no arquivo XML
var cod = item.getElementsByTagName('codigo')[0].firstChild.nodeValue;
var smodulo = item.getElementsByTagName('nome')[0].firstChild.nodeValue;
OpcaoModulo.innerHTML = 'Indeterminado';
//Cria um novo option dinamicamente
var novo = document.createElement('option');
//Atribui um ID a esse elemento
novo.setAttribute('id', 'opcaomodulo');
//Atribui valor e texto
novo.value = cod;
novo.text = smodulo;
//Adiciona o novo elemento
document.getElementById('modulo').options.add(novo);
}
SelecionaVersao(document.getElementById('sistema').value);
}
else
{
//Caso o XML volte vazio
OpcaoModulo.innerHTML = 'Indeterminado';
}
}
function SelecionaVersao(valor)
{
ajax = InstanciaAJAX();
document.getElementById('versao').options.length = 1;
OpcaoVersao = document.getElementById('opcaoversao');
if (valor > 0)
{
ajax.open('POST', 'versoes.xml.php', true);
ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
ajax.onreadystatechange = function()
{
//Enquanto estiver processando emite a mensagem de aguarde
if(ajax.readyState == 1)
{
OpcaoVersao.innerHTML = 'Carregando versões...';
}
//Após ser processado chama função processXML que vai varrer os dados
if(ajax.readyState == 4 )
{
if(ajax.responseXML)
{
processXMLVer(ajax.responseXML);
}
else
{
//Caso não consiga ler o arquivo XML emite a mensagem e desabilita a lista de cidades
OpcaoVersao.innerHTML = 'Indeterminada';
}
}
}
}
//Passa o código do estado escolhido como parâmetro pro POST e envia
var params = 'id=' + valor;
ajax.send(params);
}
function processXMLVer(obj)
{
//Pega a TAG modulo
var dataArray = obj.getElementsByTagName('versao');
//Verifica o total de elementos contidos na TAG
if(dataArray.length > 0)
{
//Percorre o arquivo XML para extrair os dados
for(var i = 0 ; i < dataArray.length ; i++)
{
var item = dataArray[i];
//Conteudo dos campos no arquivo XML
var cod = item.getElementsByTagName('codigo')[0].firstChild.nodeValue;
var sver = item.getElementsByTagName('ver')[0].firstChild.nodeValue;
OpcaoVersao.innerHTML = 'Indeterminada';
//Cria um novo option dinamicamente
var novo = document.createElement('option');
//Atribui um ID a esse elemento
novo.setAttribute('id', 'opcaoversao');
//Atribui valor e texto
novo.value = cod;
novo.text = sver;
//Adiciona o novo elemento
document.getElementById('versao').options.add(novo);
}
}
else
{
//Caso o XML volte vazio
OpcaoVersao.innerHTML = 'Indeterminada';
}
}
//Pesquisa e valida o cliente
function ValidarCliente(pesquisa)
{
String.prototype.trim = function() { return this.replace(/^\s+|\s+$/, ''); };
b = document.getElementById('cliente').value = b = document.getElementById('cliente').value.trim();
var er = /[0-9]{1,}/;
b = document.getElementById('cliente').value;
if (document.getElementById('cliente').value == '')
{
document.getElementById('clinome').value = '';
if (!pesquisa)
{
window.alert('Campo solicitante/cliente deve ser preenchido!');
document.getElementById('cliente').focus();
return false;
}
}
else
{
if(!er.test(b))
{
window.alert('Campo solicitante/cliente inválido!');
document.getElementById('cliente').value = '';
document.getElementById('cliente').focus();
return false;
}
else
{
ajax = InstanciaAJAX();
document.getElementById('clinome').value = '';
ajax.open('POST', 'clientes.xml.php', true);
ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
ajax.onreadystatechange = function()
{
//Enquanto estiver processando emite a mensagem de aguarde
if(ajax.readyState == 1)
{
document.getElementById('clinome').style.color = '#666666';
document.getElementById('clinome').value = 'Localizando solicitante/cliente...';
}
//Após ser processado chama função processXML que vai varrer os dados
if(ajax.readyState == 4 )
{
if(ajax.responseXML)
{
return processaCliente(ajax.responseXML);
}
else
{
document.getElementById('clinome').value = '';
document.getElementById('cliente').value = '';
alert('Solicitante/cliente não encontrado ou ainda não efetivado!');
document.getElementById('clinome').style.color = '#000000';
document.getElementById('cliente').focus();
return false;
}
}
}
//Passa o código do estado escolhido como parâmetro pro POST e envia
var params = 'id=' + document.getElementById('cliente').value;
ajax.send(params);
return true;
}
}
}
function processaCliente(obj)
{
//Pega a TAG modulo
var dataArray = obj.getElementsByTagName('cliente');
//Verifica o total de elementos contidos na TAG
if(dataArray.length > 0)
{
//Percorre o arquivo XML para extrair os dados
for(var i = 0 ; i < dataArray.length ; i++)
{
var item = dataArray[i];
//Conteudo dos campos no arquivo XML
var cli = item.getElementsByTagName('nome')[0].firstChild.nodeValue;
var codreal = item.getElementsByTagName('codigo')[0].firstChild.nodeValue;
document.getElementById('cliente').value = codreal;
document.getElementById('clinome').value = cli;
document.getElementById('clinome').style.color = '#000000';
return true
}
}
else
{
//Caso o XML volte vazio
document.getElementById('clinome').value = '';
document.getElementById('cliente').value = '';
alert('Solicitante/cliente informado não encontrado ou ainda não efetivado!');
document.getElementById('clinome').style.color = '#000000';
document.getElementById('cliente').focus();
return false;
}
}
function BuscarCliente()
{
document.getElementById('clinome').value = '';
document.getElementById('cliente').value = '';
document.getElementById('pesqcli').style.display = '';
document.getElementById('actSair').style.display = 'none';
document.getElementById('rpVoltar').style.display = 'none';
document.getElementById('actCFG').style.display = 'none';
document.getElementById('edtPesqCli').value = '';
document.getElementById('carregando').style.display = '';
document.getElementById('edtPesqCli').focus();
window.open('pesqcli.php', 'ipesqcli');
}
-->
</script>
</head>
<body onload="document.getElementById('titulo').focus();">
<?php
include("../sol/framepesqcli.php");
include("../sol/includes/menus.php");
?>
<table width="100%">
<?php
include("../sol/includes/top.php");
?>
<!-- CONTEUDO DA PAGINA -->
<tr>
<td id="Conteudo">
<br />
<span class="Titulo">Abrir chamado</span><br /> <br />
<form action="registra_chamado.php" method="post" id="frmChamado">
Título: <input type="text" id="titulo" name="titulo" value="" maxlength="250" size="75" onfocus="if (document.getElementById('pesqcli').style.display == '') document.getElementById('edtPesqCli').focus();" /><br /> <br />
Prazo: <input type="text" id="prazo" name="prazo" value="" maxlength="10" size="10" /> <em style="color:#666666;">(DD/MM/AAAA)</em>
Prioridade:
<select id="prioridade" name="prioridade">
<option value="0" selected>Selecione...</option>
<?php
$sql = "SELECT * FROM prioridades ORDER BY nivel DESC";
$rs = mysql_query($sql);
while ($reg = mysql_fetch_array($rs))
{
echo '<option value="'.$reg["id_prioridade"].'" style="color:#'.getCorPrioridade($reg["nivel"]).';">'.utf8_encode($reg["prioridade"]).'</option>';
}
?>
</select>
Tipo:
<select id="tipo" name="tipo">
<option value="0" selected>Selecione...</option>
<?php
$sql = "SELECT * FROM tipos_de_chamado ORDER BY tipo ASC";
$rs = mysql_query($sql);
while ($reg = mysql_fetch_array($rs))
{
echo '<option value="'.$reg["id_tipos"].'">'.utf8_encode($reg["tipo"]).'</option>';
}
?>
</select>
<br /> <br />
Solicitante/Cliente:
<input type="text" id="cliente" name="cliente" value="" maxlength="7" size="5" onblur="ValidarCliente(true);" />
<input type="button" name="btnCliente" id="btnCliente" value="..." onclick="BuscarCliente();" title="Localizar cliente..." />
<input type="text" id="clinome" name="clinome" value="" size="50" readonly="true" />
<br /> <br />
Sistema:
<select id="sistema" name="sistema" onchange="SelecionaModulo(this.value);">
<option value="0" selected>Selecione...</option>
<?php
$sql = "SELECT * FROM sistemas";
$rs = mysql_query($sql);
while ($reg = mysql_fetch_array($rs))
{
echo '<option value="'.$reg["id_sistema"].'">'.utf8_encode($reg["sistema"]).'</option>';
}
?>
</select>
Módulo: <select id="modulo" name="modulo"><option value="0" id="opcaomodulo" selected>Indeterminado</option></select>
<br /> <br />
Versão: <select id="versao" name="versao" onchange="document.getElementById('outra_versao').value = '';"><option value="0" id="opcaoversao" selected>Indeterminada</option></select>
Outra <font size="1">(certifique-se de que não esteja já cadastrada antes)</font>: <input type="text" id="outra_versao" name="outra_versao" value="" maxlength="15" size="15" onchange="document.getElementById('versao').value = 0;" />
<br /> <br />Encaminhar para (abertura):
<select name="andamento" id="andamento">
<option value="0" selected>Selecione...</option>
<?php
//Lista antamentos de prosseguimento do departamento do usuario
$sql = "SELECT andamento_prosseguimento FROM andamentos WHERE id_departamento = ".$_SESSION["departamento"];
$rs = mysql_query($sql);
$achouandamentos = false;
$in = " OR id_andamento IN (";
while ($reg = mysql_fetch_array($rs))
{
if ($reg["andamento_prosseguimento"] != 0)
{
$achouandamentos = true;
$in .= $reg["andamento_prosseguimento"].", ";
}
}
$in .= ")";
$in = str_replace(", )", ")", $in);
//Lista todos os andamentos acima mais os de abertura
$sql = "SELECT id_andamento, andamento, status FROM andamentos WHERE status = 'A'";
if ($achouandamentos) $sql .= $in;
$sql .= " ORDER BY andamento ASC";
$rs = mysql_query($sql);
while ($reg = mysql_fetch_array($rs))
{
if ($reg['status'] != 'F') echo '<option value="'.$reg["id_andamento"].'">'.utf8_encode($reg["andamento"]).'</option>';
}
?>
</select>
<br /> <br />
Banco de dados <font size="1">(cole a URL do FTP aqui)</font>: <input type="text" id="banco" name="banco" value="" size="50" /> <font size="1"><em>Ex.: ftp://<?=str_replace("http://", "", $_SERVER["HTTP_HOST"])?>/pasta/arquivo.fdb</em></font>
<br /> <br />
Descrição inicial:<br />
<textarea cols="100" rows="7" id="descricao" name="descricao"></textarea>
<br /> <br />
<input type="button" name="btnSalvar" id="btnSalvar" value="Abrir chamado" onclick="Salvar();" onfocus="if (document.getElementById('pesqcli').style.display == '') document.getElementById('edtPesqCli').focus();;" style="font-weight:bold;" />
<input type="button" value="Cancelar" onclick="window.open('chamados.php', '_self');" />
</form>
<br /> <br />
</td>
</tr>
<!-- FIM DE CONTEUDO DA PAGINA -->
<?php
include("../sol/includes/rp.php");
?>
</table>
</body>
</html>
<?php
@mysql_close();
?>