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.
 
 
 
 
 
 

322 lines
13 KiB

<link rel="stylesheet" type="text/css" href="utils/m2br.dialog.css" />
<script src="utils/jquery.js" type="text/javascript"></script>
<script src="utils/jquery-ui.js" type="text/javascript"></script>
<script src="utils/m2br.dialog.pack.js" type="text/javascript"></script>
<script type="text/javascript">
var alertaPadrao = function (titulo, msg, tipo, altura, largura) {
$('body').append('<a href="#" id="alerta-padrao"></a>');
$('#alerta-padrao').m2brDialog({
draggable: true,
texto: msg,
tipo: tipo,
titulo: titulo,
altura: altura,
largura: largura,
botoes: {
1: {
label: 'OK',
tipo: 'link',
endereco: 'javascript:history.back();'
}
}
});
$('#alerta-padrao')
.click()
._remove();
};
</script>
<?
$acao = $_GET["acao"];
$acao2 = $_GET["acao2"];
$id_ura = $_GET["id_ura"];
$id = $_GET["id"];
if ($acao2 == "salva") {
$id = trim($_POST["id"]);
$numero = ((int) trim($_POST["numero"]));
$opcao = trim($_POST["opcao"]);
$comando = trim($_POST["comando"]);
$som_ura = trim($_POST["som_ura"]);
$id_ura = trim($_POST["id_ura"]);
if (($numero == '') or ( $opcao == '')) {
?>
<script type="text/javascript">
$(document).ready(function () {
alertaPadrao('Informação:', 'TODOS OS CAMPOS DEVEM SER PREENCHIDOS!', 'info', 110, 250);
});
</script>
<?
exit;
}
if (!is_integer($numero)) {
?>
<script type="text/javascript">
$(document).ready(function () {
alertaPadrao('Informação:', 'A OPÇÃO DEVER SER UM NÚMERO', 'info', 110, 250);
});
</script>
<?
exit;
}
if ($acao == 'inseri') {
$query = "SELECT * FROM pbx_ura_destino where id_ura=$id_ura and numero='$numero'";
$result = pg_query($dbcon, $query);
if (pg_num_rows($result) > 0) {
?>
<script type="text/javascript">
$(document).ready(function () {
alertaPadrao('Informação:', 'JÁ EXISTE UMA OPÇÃO DE NÚMERO: <? echo $numero; ?>', 'info', 110, 250);
});
</script>
<?
exit;
}
}
if ($opcao == 'ramal') {
$comando = trim($_POST['oramal']);
}
if ($opcao == 'fila') {
$comando = trim($_POST['ofila']);
}
if ($opcao == 'grupo') {
$comando = trim($_POST['ogrupo']);
}
if ($opcao == 'voice') {
$comando = trim($_POST['ovoice']);
}
if ($opcao == 'ura') {
$comando = trim($_POST['oura']);
}
if ($acao == "inseri") {
$query = "INSERT INTO pbx_ura_destino(id_ura,numero,tipo,comando,som_ura)
VALUES ('$id_ura','$numero','$opcao','$comando','$som_ura')";
pg_query($dbcon, $query);
}
if ($acao == "edita") {
//REALIZA BACKUP BO BANCO
//($dbcon,'pbx_ura_destino','U',$id,'update','URAS OPÇÕES');
$query = "UPDATE pbx_ura_destino
SET numero='$numero',tipo='$opcao',comando='$comando',som_ura='$som_ura'
WHERE id=$id";
pg_query($dbcon, $query);
}//gera arquivos e executa o reload dos dados no asterisk
gera_arquivos($dbcon, 'URA');
?>
<script>
$(document).ready(function () {
alertaPadrao2();
});
</script>
<?
}
if ($acao == "edita") {
$id = $_GET["id"];
$query = "SELECT * FROM pbx_ura_destino where id=$id";
} else {
$query = "SELECT * FROM pbx_ura_destino where id is null";
}
$result = pg_query($dbcon, $query);
while ($dados = pg_fetch_array($result)) {
$id = $dados['id'];
$numero = $dados['numero'];
$opcao = trim($dados['tipo']);
$comando = trim($dados['comando']);
}
?>
<style type="text/css">
<!--
.style1 {font-size: 12}
.style5 {font-size: 10px}
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
-->
</style>
<form name="form1" method="post" action="index.php?idProg=10005&pbxRequest=1&acao=<? echo $acao; ?>&acao2=salva&id=<? echo $id; ?>">
<table width="457" height="216" border="1" align="left" cellpadding="0" cellspacing="0" bordercolor="#990000" >
<tr class="cabecalho">
<td height="21" colspan="2">
<div align="center">CADASTRO DE op&Ccedil;&Otilde;ES
<input name="id" type="hidden" id="id" value="<?
if ($acao == 'edita') {
echo $_GET['id'];
}
?>">
<input name="id_ura" type="hidden" id="id" value="<? echo $id_ura; ?>">
</div>
</td>
</tr>
<tr bordercolor="#FFFFFF">
<td width="111" height="24" class="labels">
<div align="right">
<span class="style5">OP&Ccedil;&Atilde;O:</span>
</div>
</td>
<td width="340">
<input name="numero" type="text" class="textbox" id="numero" value="<?
if ($acao == 'edita') {
echo $numero;
}
?>" size="10" maxlength="10">
</td>
</tr>
<tr class="cabecalho">
<td height="21" colspan="2">
<div align="center">OP&Ccedil;&Otilde;ES </div>
</td>
</tr>
<tr bordercolor="#FFFFFF">
<td height="122" colspan="2" class="labels"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="25%" class="labels"><div align="right">Ramal
<input name="opcao" type="radio" value="ramal" <?
if ($opcao == 'ramal') {
echo "checked";
}
?>>
</div></td>
<td width="75%"><select name="oramal" class="textbox" id="oramal" onFocus="javascript:document.form1.opcao[0].checked = true;">
<?
$query2 = "SELECT * FROM pbx_sip_ramais order by id asc";
$result2 = pg_query($dbcon, $query2);
while ($dados2 = pg_fetch_array($result2)) {
?>
<option value="<? echo $dados2['nome']; ?>" <?
if ($acao == 'edita') {
if ($comando == $dados2['nome']) {
echo "selected";
}
} else {
echo "selected";
}
?>><? echo $dados2['nome']; ?></option>
<? } ?>
</select></td>
</tr>
<tr>
<td class="labels"><div align="right">Fila
<input name="opcao" type="radio" value="fila" <?
if ($opcao == 'fila') {
echo "checked";
}
?>>
</div></td>
<td><select name="ofila" class="textbox" id="ofila" onFocus="javascript:document.form1.opcao[1].checked = true;">
<?
$query2 = "SELECT * FROM pbx_queues_grupos where status='A' order by id asc";
$result2 = pg_query($dbcon, $query2);
while ($dados2 = pg_fetch_array($result2)) {
?>
<option value="<? echo $dados2['nome']; ?>" <?
if ($acao == 'edita') {
if ($comando == $dados2['nome']) {
echo "selected";
}
}
?>><? echo $dados2['nome']; ?></option>
<? } ?>
</select></td>
</tr>
<tr>
<td class="labels"><div align="right">Ura
<input name="opcao" type="radio" value="ura" <?
if ($opcao == 'ura') {
echo "checked";
}
?>>
</div></td>
<td><select name="oura" class="textbox" id="oura" onFocus="javascript:document.form1.opcao[2].checked = true;">
<?
$query2 = "SELECT * FROM pbx_ura where id not in($id_ura) order by id asc";
$result2 = pg_query($dbcon, $query2);
while ($dados2 = pg_fetch_array($result2)) {
?>
<option value="<? echo $dados2['id'] . '-' . $dados2['nome']; ?>" <?
if ($acao == 'edita') {
if ($comando == $dados2['nome']) {
echo "selected";
}
}
?>><? echo $dados2['nome']; ?></option>
<? } ?>
</select></td>
</tr>
<tr>
<td class="labels"><div align="right">VoiceMail
<input name="opcao" type="radio" value="voice" <?
if ($opcao == 'voicemail') {
echo "checked";
}
?>>
</div></td>
<td><select name="ovoice" class="textbox" id="ovoice" onFocus="javascript:document.form1.opcao[3].checked = true;">
<?
$query2 = "SELECT * FROM pbx_voicemail_usuarios order by caixa_postal asc";
$result2 = pg_query($dbcon, $query2);
while ($dados2 = pg_fetch_array($result2)) {
?>
<option value="<? echo $dados2['caixa_postal']; ?>" <?
if ($acao == 'edita') {
if ($comando == $dados2['caixa_postal']) {
echo "selected";
}
}
?>><? echo $dados2['caixa_postal']; ?></option>
<? } ?>
</select></td>
</tr>
</table></td>
</tr>
<tr bordercolor="#FFFFFF">
<td height="26" colspan="2"><div align="center"><span class="style1"></span><span class="style1"></span><span class="style1"></span><span class="style1">
<input name="Submit2" type="button" class="textbox" onclick=" window.opener.location.reload();window.close();" value="Fechar">
<input name="Submit" type="submit" class="textbox" value="Salvar">
</span></div></td>
</tr>
</table>
</form>
<script>
var alertaPadrao2 = function () {
$('body').append('<a href="#" id="alerta-padrao2"></a>');
$('#alerta-padrao2').m2brDialog({
tipo: 'pergunta',
titulo: 'Confirme',
texto: 'OPÇÃO DE URA CADASTRADA COM SUCESSO! CADASTRAR NOVA OPÇÃO? ',
draggable: true,
botoes: {
1: {
label: 'sim',
tipo: 'link',
endereco: 'cadUraOpcoes.php?acao=inseri&id_ura=<? echo $id_ura; ?>'
},
2: {
label: 'não',
tipo: 'link',
endereco: 'javascript:window.opener.location.reload();javascript:window.close();'
}
}
});
$('#alerta-padrao2')
.click()
._remove();
};
</script>