PABX da Simples IP
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

335 lines
16 KiB

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="admin/css/validationEngine.jquery.css" type="text/css" media="screen" title="no title" charset="ISO-8859-1" />
<script type="text/javascript" src="admin/js/jquery-1.4.js"></script>
<script type="text/javascript" src="admin/js/jquery.blockUI.js?v2.29"></script>
<script src="admin/js/jquery.min.js" type="text/javascript"></script>
<script src="admin/js/jquery.validationEngine.js" type="text/javascript"></script>
<script src="admin/js/jquery.validationEngine-en.js" type="text/javascript"></script>
<script src="admin/js/pbxAjax.js" type="text/javascript"></script>
<script>
$(document).ready(function() {
$("#form1").validationEngine({
sucess: function() {
document.form1.submit();
},
failure: function() {}
})
});
function Copia() {
var relacao = document.getElementById("relacao");
j = relacao.length;
for (var i = 0; i < j; i++) {
if (relacao.options[i].value == document.form1.numeros.value) {
var passa = false;
alert('NÚMERO JÁ ESTÁ NA RELAÇÃO!');
return false;
} else {
var passa = true;
}
}
if (j == 0) {
var passa = true;
}
if (passa == true) {
var x = document.getElementById("relacao"); //retorna o objeto select
var options = x.getElementsByTagName("option"); //pega a lista de options do select
var y = document.createElement('option'); //cria um novo elemento option
y.text = document.form1.numeros.value;
y.value = document.form1.numeros.value;
document.form1.numeros.value = '';
try {
x.add(y, null); // adiciona um novo option no fim da lista para navegadores complacentes
} catch (ex) {
x.add(y); // adiciona um novo option no fim da lista para o IE
}
}
}
function _remove() {
var relacao = document.getElementById("relacao");
j = relacao.length;
for (var i = 0; i < j; i++) {
if (relacao.options[i].selected) {
document.form1.numeros.value = relacao.options[i].value;
relacao.options[i] = null;
}
}
}
function marca_todos() {
var relacao = document.getElementById("relacao");
for (var i = 0; i < relacao.length; i++) {
relacao.options[i].selected = true;
}
}
</script>
<link href="admin/css/forms.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style1 {
font-family: Verdana, Arial, Helvetica, sans-serif
}
.style5 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
font-weight: bold;
}
body {
background-color: #EAEAEA;
}
-->
</style>
</head>
<body>
<?php
include_once("admin/opcoes.php");
$acao = $_GET["acao"];
$acao2 = $_GET["acao2"];
$org_id = GetOrganizacao();
/*
* Parametros necessarios para manter a paginação.
*/
$param = sprintf('&numRamal=%s&pgn=%s&bloco=%s&pg=%s', $_REQUEST['numRamal'], $_REQUEST['pgn'], $_REQUEST['bloco'], $_REQUEST['pg']);
if ($acao2 == "salva") {
$id = $_POST["id"];
$numero = trim($_POST["numero"]);
$descricao = RemoveAcentos($_POST["descricao"], true);
$ramalSaida = trim($_POST["ramal_saida"]);
$senha = trim($_POST["senha"]);
$opcao = trim($_POST["opcao"]);
$acaoDest = trim($_POST["acaoDest"]);
$timeout = trim($_POST["timeout"]);
$tempo_timeout = trim($_POST["tempo_timeout"]);
$numeros = trim($_POST["numeros"]);
$ligacao_externa = 0; //isset($_POST["ligacao_externa"]) ? 1 : 0;
if ($acao == "inseri") {
$query = "INSERT INTO pbx_disa(numero,descricao,senha,timeout,tempo_timeout,numeros,opcao, acao, ligacao_externa, ramal_saida, org_id)
VALUES('$numero','$descricao','$senha',$timeout,$tempo_timeout,'$numeros','$opcao','$acaoDest', '$ligacao_externa', '$ramalSaida', $org_id)";
pg_query($dbcon, $query);
$query2 = "select id from pbx_disa order by id desc limit 1";
$result2 = pg_query($dbcon, $query2);
if ($dados2 = pg_fetch_array($result2)) {
$id_ult = $dados2['id'];
}
}
if ($acao == "edita") {
//REALIZA BACKUP BO BANCO
//backup($dbcon,'pbx_disa','U',$id,'update','DISA');
$query = "UPDATE pbx_disa
SET numero='$numero',descricao='$descricao',senha='$senha',timeout=$timeout,tempo_timeout=$tempo_timeout,numeros='$numeros',
opcao='$opcao', acao='$acaoDest', ligacao_externa='$ligacao_externa', ramal_saida = '$ramalSaida'
WHERE id=$id";
pg_query($dbcon, $query);
$query = "delete from pbx_disa_numeros where id_disa=$id";
pg_query($dbcon, $query);
}
if ($acao != "edita")
$id = $id_ult;
$numeros = $_POST["relacao"];
for ($i = 0; $i < count($numeros); $i++) {
$numero = QuotedStr($numeros[$i]);
$query = "insert into pbx_disa_numeros (id_disa,numeros, org_id) values ($id,$numero, $org_id)";
pg_query($dbcon, $query);
} //gera arquivos e executa o reload dos dados no asterisk
gera_arquivos($dbcon, 'DISA');
echo "<script type=\"text/javascript\">
//fecha a janela presa no meio do sistema
fecha_popup(0,'index.php?idProg=10019&pbxRequest=1$param&acao=$acao');
</script>";
}
if ($acao == "edita") {
$id = $_GET["id"] ?? "0";
$query = "SELECT * FROM pbx_disa where id=$id";
$result = pg_query($dbcon, $query);
} else {
$query = "SELECT * FROM pbx_disa where id is null";
}
$result = pg_query($dbcon, $query);
if ($dados = pg_fetch_array($result)) {
$id = $dados["id"];
$numero = $dados["numero"];
$descricao = $dados["descricao"];
$senha = $dados["senha"];
$opcao = $dados["opcao"];
$acaoDest = $dados["acao"];
$timeout = $dados["timeout"];
$tempo_timeout = $dados["tempo_timeout"];
$ligacao_externa = $dados["ligacao_externa"];
$ramalSaida = $dados["ramal_saida"];
}
?>
<link href="admin/css/forms.css" rel="stylesheet" type="text/css">
<form name="form1" method="post" action="index.php?idProg=11019&pbxRequest=1&acao=<?= $acao; ?>&acao2=salva<?= $param ?>" id="form1">
<br />
<br />
<table border="1" align="center" cellpadding="0" cellspacing="0" class="tabela">
<tr bordercolor="#EAEAEA" bgcolor="#EAEAEA" class="cabecalho" background="img/button03.gif">
<td>
<div align="center">CADASTRO DE DISA
<input name="id" type="hidden" id="id" value="<?= $acao == 'edita' ? $id : null; ?>" />
</div>
</td>
</tr>
<tr bordercolor="#EAEAEA" bgcolor="#EAEAEA">
<td bgcolor="#EAEAEA" class="labels">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20%">
<fieldset>
<legend class="labels">N&uacute;mero:</legend>
<input name="numero" type="text" class="validate[required,custom[onlyNumber],length[0,100]] caixas" id="numero2" value="<?= $acao == 'edita' ? $numero : null; ?>" size="10" />
</fieldset>
</td>
<td width="20%">
<fieldset>
<legend class="labels">Senha:</legend>
<input name="senha" type="password" class="validate[optional,custom[onlyNumber],length[0,100]] caixas" id="senha2" value="<?= $acao == 'edita' ? $senha : null; ?>" size="10" />
</fieldset>
</td>
<td width="54%">
<fieldset>
<legend class="labels">Descri&ccedil;&atilde;o:</legend>
<input name="descricao" type="text" class="validate[required,length[0,100]] caixas" id="descricao2" value="<?= $acao == 'edita' ? $descricao : null; ?>" size="40" />
</fieldset>
</td>
</tr>
</table>
</td>
</tr>
<tr bordercolor="#EAEAEA" bgcolor="#EAEAEA">
<td class="labels">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="33%">
<fieldset>
<legend class="labels">Timeout:</legend>
<input name="timeout" type="text" class="validate[required,custom[onlyNumber],length[0,100]] caixas" id="timeout" value="<?= $acao == 'edita' ? $timeout : "10"; ?>" size="10" />
</fieldset>
</td>
<td width="33%">
<fieldset>
<legend class="labels">Timeout Entre Digitos:</legend>
<input name="tempo_timeout" type="text" class="validate[required,custom[onlyNumber],length[0,100]] caixas" id="tempo_timeout2" value="<?= $acao == 'edita' ? $tempo_timeout : "2"; ?>" size="10" />
</fieldset>
</td>
<td>
<fieldset>
<legend class="labels">Ramal Saida:</legend>
<select class="validate[required] caixas" name="ramal_saida" id="ramal_saida">
<option value="" <?= $ramalSaida ? "selected=\"selected\"" : ""; ?>>----------</option>
<?php
$query = "select nome from pbx_ramais where org_id = {$org_id} order by nome;";
$result = pg_query($dbcon, $query);
while ($row = pg_fetch_row($result)) {
$nome = $row[0];
$sel = $ramalSaida == $nome ? "selected=\"selected\"" : "";
echo "<option value=\"$nome\" $sel>$nome</option>\n";
}
?>
</select>
</fieldset>
</td>
</tr>
</table>
</td>
</tr>
<tr bordercolor="#EAEAEA" bgcolor="#EAEAEA">
<td class="labels">
<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0" class="tabela">
<tr>
<td width="37%">
<fieldset>
<legend class="labels">N&uacute;meros:</legend>
<input name="numeros" type="text" class="validate[optional,length[0,100]] caixas" id="numeros" value="" size="20" />
</fieldset>
</td>
<td width="18%" align="center" valign="middle">
<div align="center">
<input name="Submit3" type="button" class="caixas" value="&gt;" onclick="Copia();" />
<br />
<input name="Submit4" type="button" class="caixas" value="&lt;" onclick="_remove();" />
</div>
</td>
<td width="45%">
<div align="center">
<fieldset>
<legend class="labels">N&uacute;meros Cadastrados:</legend>
<div align="center">
<select name="relacao[]" size="10" multiple="multiple" class="validate[required] caixas" id="relacao">
<?php
if ($acao == 'edita') {
$query2 = "select * from pbx_disa_numeros where org_id = {$org_id} and id_disa='$id' order by id desc";
$result2 = pg_query($dbcon, $query2);
$dados2 = pg_fetch_all($result2);
$opt = "";
foreach ($dados2 as $v) {
$opt .= "<option value='{$v['numeros']}'>{$v['numeros']}</option>";
}
echo $opt;
}
?>
</select>
</div>
</fieldset>
</div>
</td>
</tr>
</table>
</td>
</tr>
<tr class="labels" bordercolor="#EAEAEA" bgcolor="#EAEAEA">
<td>
<div align="left">
<fieldset>
<legend class="labels">Destino :</legend>
<select name="opcao" class="caixas" id="opcao" onchange="ajaxComboBox('admin/popula.php?id=<?= $acaoDest; ?>', 'acaoDest', 'opcao', '<?= $acaoDest; ?>');">
<?= _GetOpcoes($dbcon, $opcao); ?>
</select><select name="acaoDest" class="caixas" id="acaoDest">
</select>
<label></label>
</fieldset>
</div>
</td>
</tr>
<tr bordercolor="#EAEAEA" bgcolor="#EAEAEA">
<td>
<div align="center">
<span class="style1"></span>
<span class="style1"></span>
<span class="style1"></span>
<span class="style1">
<input name="Submit2" type="button" class="labels" value="Fechar" id="btfechar" onclick="fecha_popup();">
<input name="Submit" type="submit" class="labels" value="Salvar" onclick="marca_todos();">
</span>
</div>
</td>
</tr>
</table>
<?php if ($acao == 'edita') { ?>
<script>
ajaxComboBox2('admin/popula.php?id=<?php echo $acaoDest; ?>', 'acaoDest', 'opcao', '<?php echo $acaoDest; ?>');
</script>
<?php } ?>
</form>