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.
 
 
 
 
 
 

361 lines
17 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
$acao = $_GET["acao"];
$acao2 = isset($_POST["acao2"]) ? "salva" : "";
$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") {
try {
$id = $_POST["id"];
$tempoDesligamento = $_POST["tempo_desligamento"];
$descricao = RemoveAcentos($_POST["descricao"], true);
$opcaoDest = trim($_POST["opcaoDest"]);
$acaoDest = trim($_POST["acaoDest"]);
$opcao1 = trim($_POST["opcao1"]);
$acao1 = trim($_POST["acao1"]);
$numeros = $_POST["numeros"];
$ramalSaida = $_POST["ramal_saida"];
if ($acao == "inseri") {
if (ExisteRegistro($dbcon, 'pbx_callback', 'descricao', $descricao)) {
RaiseExcept('Esta descrição já esta inserida na base de dados!');
}
$query = "INSERT INTO pbx_callback( descricao, opcao, acao, opcao1, acao1, ramal_saida, tempo_desligamento, org_id)
VALUES ('$descricao', '$opcaoDest', '$acaoDest', '$opcao1', '$acao1', '$ramalSaida', $tempoDesligamento, $org_id)";
pg_query($dbcon, $query);
$query = "select max(id) as id from pbx_callback";
$result = pg_query($dbcon, $query);
$dados = pg_fetch_array($result);
$id_ult = $dados['id'];
} else if ($acao == "edita") {
//REALIZA BACKUP BO BANCO
//@backup($dbcon,'pbx_callback','U',$id,'update','CALLBACK');
$query = "UPDATE pbx_callback
SET descricao = '$descricao',
opcao = '$opcaoDest',
acao = '$acaoDest',
opcao1 = '$opcao1',
acao1 = '$acao1',
ramal_saida = '$ramalSaida',
tempo_desligamento = $tempoDesligamento
WHERE id = '$id' ";
pg_query($dbcon, $query);
$query = "delete from pbx_callback_numeros where id_callback = '$id'";
pg_query($dbcon, $query);
}
$numeros = $_POST["relacao"];
for ($i = 0; $i < count($numeros); $i++) {
if ($acao == "edita") {
$idx = $id;
} else {
$idx = $id_ult;
}
$numero = QuotedStr($numeros[$i]);
$query = "insert into pbx_callback_numeros (id_callback,numero, org_id) values ($idx, $numero, $org_id)";
pg_query($dbcon, $query);
} //gera arquivos e executa o reload dos dados no asterisk
gera_arquivos($dbcon, 'CALLBACK');
PbxFechaPopup('index.php?idProg=10020&pbxRequest=1$param&acao=$acao');
} catch (Exception $ex) {
PbxFechaPopup('index.php?idProg=10020&pbxRequest=1$param&acao=$acao');
}
}
if ($acao == "edita") {
$id = isset($_GET["id"]) ? $_GET["id"] : $_POST["id"];
$query = "SELECT * FROM pbx_callback where id='$id'";
$result = pg_query($dbcon, $query);
$dados = pg_fetch_array($result);
}
if ($dados) {
$id = $dados["id"];
$tempoDesligamento = $dados["tempo_desligamento"];
$descricao = $dados["descricao"];
$opcaoDest = $dados["opcao"];
$acaoDest = $dados["acao"];
$opcao1 = $dados["opcao1"];
$acao1 = $dados["acao1"];
$ramalSaida = $dados["ramal_saida"];
}
?>
<link href="admin/css/forms.css" rel="stylesheet" type="text/css">
<form name="form1" method="post" action="index.php?idProg=11020&pbxRequest=1&acao=<?= $acao . $param; ?>" id="form1">
<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 CALLBACK
<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>
<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>
<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="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<fieldset>
<legend class="labels">Tempo de Desligamento:</legend>
<input name="tempo_desligamento" type="text" class="caixas" id="tempo_desliga" value="<?= ($tempoDesligamento ? $tempoDesligamento : 1); ?>" size="5" />
</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%">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<fieldset>
<legend class="labels">N&uacute;meros:</legend>
<input name="numeros" type="text" class="caixas" id="numeros" value="" size="20" />
</fieldset>
</td>
</tr>
</table>
</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 id, id_callback, numero as numeros from pbx_callback_numeros where org_id = {$org_id} and id_callback='$id' order by id desc";
$result2 = pg_query($dbcon, $query2);
while ($dados2 = pg_fetch_array($result2)) {
?>
<option value="<?= $dados2['numeros'] ?>"><?= $dados2['numeros'] ?></option>
<?php
}
}
?>
</select>
</div>
</fieldset>
</div>
</td>
</tr>
</table>
</td>
</tr>
<tr class="labels" bordercolor="#EAEAEA" bgcolor="#EAEAEA">
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<div align="left">
<fieldset>
<legend class="labels">A&ccedil;&atilde;o Caso Combine :</legend>
<select name="opcaoDest" class="caixas" id="opcaoDest" onchange="ajaxComboBox('admin/popula.php?id=<?php echo $acaoDest; ?>', 'acaoDest', 'opcaoDest', '<?php echo $acaoDest; ?>');">
<?php
$opcao = $opcaoDest;
include_once("admin/opcoes.php");
echo _GetOpcoes($dbcon, $opcao);
?>
</select>
<select name="acaoDest" class="caixas" id="acaoDest">
<?= ($acao == 'edita' && !empty($opcaoDest)) ? GetAcaoAlt($dbcon, $opcaoDest, $acaoDest) : null; ?>
</select>
</fieldset>
</div>
</td>
<td>
<div align="left">
<fieldset>
<legend class="labels">A&ccedil;&atilde;o Caso n&atilde;o Combine :</legend>
<select name="opcao1" class="caixas" id="opcao1" onchange="ajaxComboBox('admin/popula.php?id=<?= $acao1; ?>', 'acao1', 'opcao1', '<?= $acao1; ?>');">
<?php
$opcao = $opcao1;
include_once("admin/opcoes.php");
echo _GetOpcoes($dbcon, $opcao);
?>
</select><select name="acao1" class="caixas" id="acao1">
</select>
</fieldset>
</div>
</td>
</tr>
</table>
</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="acao2" type="submit" class="labels" id="acao2" onclick="marca_todos();" value="Salvar">
</span>
</div>
</td>
</tr>
</table>
<?php if ($acao == 'edita') { ?>
<script>
ajaxComboBox2('admin/popula.php?id=<?= $acao1; ?>', 'acao1', 'opcao1');
</script>
<?php } ?>
</form>