|
|
<?php |
|
|
$acao = $_GET['acao']; |
|
|
$acao2 = $_GET['acao2']; |
|
|
$id = $_GET['id']; |
|
|
$id_ura = $_GET['id_ura']; |
|
|
$nome_ura = $_GET['nome_ura']; |
|
|
?> |
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
|
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cs" lang="cs"> |
|
|
|
|
|
<head> |
|
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> |
|
|
<link href="admin/css/forms.css" rel="stylesheet" type="text/css"> |
|
|
<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.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 MM_openBrWindow(theURL, winName, features) { |
|
|
window.open(theURL, winName, features); |
|
|
} |
|
|
|
|
|
function GetCommand() { |
|
|
var combo = document.getElementById('acao'); |
|
|
var opt = combo.options[combo.selectedIndex]; |
|
|
document.getElementById('display_comando').value = opt.text; |
|
|
} |
|
|
</script> |
|
|
</head> |
|
|
|
|
|
<body> |
|
|
<?php |
|
|
|
|
|
include_once("admin/opcoes.php"); |
|
|
|
|
|
$org_id = GetOrganizacao(); |
|
|
|
|
|
if ($acao == "deleta") { |
|
|
$id = $_GET["id"] ?? "0"; |
|
|
$query = "delete from pbx_ura_destino where id='$id'"; |
|
|
pg_query($dbcon, $query); |
|
|
} |
|
|
|
|
|
if ($_GET["salva"] == "sim") { |
|
|
$acao2 = $_GET["acao2"]; |
|
|
$id = trim($_POST["id"]); |
|
|
$numero = trim($_POST["numero"]); |
|
|
$opcao = trim($_POST["opcao"]); |
|
|
$param = explode(";", $_POST["acao"]); |
|
|
$comando = $param[0]; |
|
|
$nome_comando = $param[1]; |
|
|
$som_ura = trim($_POST["som_ura"]); |
|
|
$id_ura = trim($_POST["id_ura"]); |
|
|
$sequencia = 0; |
|
|
|
|
|
if (ctype_digit($numero)) { |
|
|
$sequencia = $numero; |
|
|
} |
|
|
|
|
|
if ($acao2 == 'inseri') { |
|
|
$query = "SELECT * FROM pbx_ura_destino where id_ura = $id_ura and numero='$numero' and visible = 'S'"; |
|
|
$result = pg_query($dbcon, $query); |
|
|
if (pg_num_rows($result) > 0) { |
|
|
echo "<script>alerta_existe('A OP<EFBFBD><EFBFBD>O DE URA J<EFBFBD> EXISTE!');</script>"; |
|
|
$link = "uraOpcoes.php?id_ura=$id_ura&nome_ura=$nome_ura"; |
|
|
@header("Location: $link"); |
|
|
exit; |
|
|
} else { |
|
|
$query = "INSERT INTO pbx_ura_destino(id_ura, numero, tipo, comando, som_ura, sequencia, nome_comando, org_id) |
|
|
VALUES ('$id_ura','$numero','$opcao','$comando','$som_ura', '$sequencia', '$nome_comando', $org_id)"; |
|
|
$result = pg_query($dbcon, $query); |
|
|
if ($result) { |
|
|
$opcao = null; |
|
|
$comando = null; |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
if ($acao2 == "edita") { |
|
|
$query = "UPDATE pbx_ura_destino |
|
|
SET numero='$numero', tipo='$opcao', comando='$comando', som_ura='$som_ura', nome_comando = '$nome_comando' |
|
|
WHERE id=$id"; |
|
|
pg_query($dbcon, $query); |
|
|
} |
|
|
echo "<script>javascript:history.back();</script>"; |
|
|
gera_arquivos($dbcon, 'URA'); |
|
|
} |
|
|
?> |
|
|
<table width="90%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#EAEAEA" id="view"> |
|
|
<tr class="cabecalho"> |
|
|
<td colspan="4"> |
|
|
<div align="center">CADASTRO DE OPÇÕES DE URA : <?= $nome_ura; ?></div> |
|
|
</td> |
|
|
</tr> |
|
|
<tr> |
|
|
<td colspan="4"> |
|
|
<table width="100%" border="0" cellspacing="0" cellpadding="0"> |
|
|
<tr> |
|
|
<td width="25%" background="img/button03.gif"> |
|
|
<div align="center"> |
|
|
<a href="index.php?idProg=11131&pbxRequest=1&id_ura=<?= $id_ura; ?>&nome_ura=<?= $nome_ura; ?>&acao2=inseri" class="dados"> |
|
|
<img src="images/novo.gif" width="20" height="20" border="0" align="absmiddle">NOVA OPÇÃO |
|
|
</a> |
|
|
</div> |
|
|
</td> |
|
|
</tr> |
|
|
</table> |
|
|
</td> |
|
|
</tr> |
|
|
<?php |
|
|
if (trim($acao2) != '') { |
|
|
if ($acao2 == 'edita') { |
|
|
$query3 = "SELECT * FROM pbx_ura_destino WHERE id = $id AND visible = 'S'"; |
|
|
$result3 = pg_query($dbcon, $query3); |
|
|
while ($dados3 = pg_fetch_array($result3)) { |
|
|
$id = $dados3['id']; |
|
|
$acao = trim($dados3['comando']); |
|
|
$tipo = trim($dados3['tipo']); |
|
|
$opcao = trim($dados3['tipo']); |
|
|
$opcao_2 = trim($dados3['opcao2']); |
|
|
$acao_2 = trim($dados3['acao2']); |
|
|
$numero = $dados3['numero']; |
|
|
} |
|
|
} |
|
|
|
|
|
$query3 = "SELECT max(sequencia::int) AS numero FROM pbx_ura_destino WHERE id_ura = $id_ura AND visible <> 'N'"; |
|
|
$result3 = pg_query($dbcon, $query3); |
|
|
while ($dados3 = pg_fetch_array($result3)) { |
|
|
$proximo_numero = $dados3['numero'] + 1; |
|
|
} |
|
|
|
|
|
if ($proximo_numero < 1) { |
|
|
$proximo_numero = 1; |
|
|
} |
|
|
?> |
|
|
<tr> |
|
|
<td colspan="4"> |
|
|
<form action="index.php?idProg=11131&pbxRequest=1&acao2=<?= $acao2; ?>&salva=sim&id_ura=<?= $id_ura; ?>&nome_ura=<?= $nome_ura; ?>" method="post" name="form1" target="_self" id="form1"> |
|
|
<table width="100%" border="0" cellspacing="0" cellpadding="0"> |
|
|
<tr class="labels"> |
|
|
<td width="12%" class="dados"> |
|
|
<div align="center">Opçao:</div> |
|
|
</td> |
|
|
<td width="10%" class="dados">Tipo:</td> |
|
|
<td class="dados">Ação: |
|
|
<input name="id_ura" type="hidden" id="id_ura" value="<?= $id_ura; ?>" /> |
|
|
<input name="id" type="hidden" id="acao4" value="<?= $id; ?>" /> |
|
|
</td> |
|
|
</tr> |
|
|
<tr> |
|
|
<td> |
|
|
<div align="center"> |
|
|
<input name="numero" type="text" class="validate[required] caixas" id="opcao2" size="10" maxlength="10" value="<?= ($acao2 == 'edita') ? $numero : $proximo_numero; ?>" /> |
|
|
</div> |
|
|
</td> |
|
|
<td> |
|
|
<select name="opcao" class="validate[required] caixas" id="opcao" onchange="ajaxComboBox('admin/populaUra.php?id_ura=' + document.form1.id_ura.value, 'acao', 'opcao', <?= $acao; ?>);"> |
|
|
<?= _GetOpcoes($dbcon, $opcao, 1); ?> |
|
|
</select> |
|
|
</td> |
|
|
<td> |
|
|
<select name="acao" class="validate[required] caixas" id="acao" onfocus="ajaxComboBox('admin/populaUra.php?id_ura=' + document.form1.id_ura.value, 'acao', 'opcao', '<?= $acao; ?>');"> |
|
|
</select> |
|
|
<input name="display_comando" type="hidden" value="" /> |
|
|
</td> |
|
|
</tr> |
|
|
<tr> |
|
|
<td colspan="3"> |
|
|
<div align="center"> |
|
|
<span class="style1"> |
|
|
<input name="Submit" type="submit" class="labels" value="Salvar" /> |
|
|
</span> |
|
|
</div> |
|
|
</td> |
|
|
</tr> |
|
|
</table> |
|
|
</form> |
|
|
</td> |
|
|
</tr> |
|
|
<?php } ?> |
|
|
<tr bordercolor="#EAEAEA" class="cabecalho" background="img/button03.gif"> |
|
|
<td class="dados"> |
|
|
<div align="center">Id</div> |
|
|
</td> |
|
|
<td class="dados"> opção</td> |
|
|
<td class="dados"> Destino:</td> |
|
|
<td background="img/button03.gif"> |
|
|
<div align="center" class="dados"> |
|
|
<span class="style11">Ação</span> |
|
|
</div> |
|
|
</td> |
|
|
</tr> |
|
|
|
|
|
<?php |
|
|
$janW = '500'; |
|
|
$janH = '400'; |
|
|
|
|
|
$query = "SELECT * FROM pbx_ura_destino where id_ura = $id_ura AND visible = 'S' order by numero asc"; |
|
|
$result = pg_query($dbcon, $query); |
|
|
$z == 0; |
|
|
while ($dados = pg_fetch_array($result)) { |
|
|
?> |
|
|
<tr bordercolor="#EAEAEA" class="dadosResult"> |
|
|
<td> |
|
|
<div align="center" class="style5 style6"><?= $dados['id']; ?></div> |
|
|
</td> |
|
|
<td><span class="style7"><?= $dados['numero']; ?></span></td> |
|
|
<td><span class="style7"><?= $dados['tipo'] . ' > ' . $dados['nome_comando']; ?></span></td> |
|
|
<td> |
|
|
<table width="100%" border="0" cellspacing="0" cellpadding="0"> |
|
|
<tr> |
|
|
<td width="33%" class="style7"> |
|
|
<div align="center"> |
|
|
<a href="index.php?idProg=11131&pbxRequest=1&acao2=edita&id=<?= $dados['id']; ?>&id_ura=<?= $id_ura; ?>&nome_ura=<?= $nome_ura; ?>"> |
|
|
<img src="images/edit.gif" alt="EDITAR A URA:<?= $dados['nome']; ?>" width="22" height="22" border="0"> |
|
|
</a> |
|
|
</div> |
|
|
</td> |
|
|
<td width="33%" class="style7"> |
|
|
<div align="center"> |
|
|
<a href="#" onclick="excluir('<?= $dados['id']; ?>', '<?= $dados['numero']; ?>', 'DESEJA EXLUIR A OP<EFBFBD><EFBFBD>O DE URA:<?= $dados['numero']; ?>', 'index.php?idProg=11131&pbxRequest=1&acao=deleta&id=<?= $dados['id']; ?>&id_ura=<?= $id_ura; ?>', 'URA');"> |
|
|
<img src="images/delete.gif" alt="APAGAR A OP<EFBFBD><EFBFBD>O DE URA:<?= $dados['numero']; ?>" name="delete" width="22" height="22" border="0"> |
|
|
</a> |
|
|
</div> |
|
|
</td> |
|
|
</tr> |
|
|
</table> |
|
|
</td> |
|
|
</tr> |
|
|
<?php $z++; ?> |
|
|
<?php } ?> |
|
|
<?php if ($z == 0) { ?> |
|
|
<tr align="center" valign="middle" bordercolor="#EAEAEA" bgcolor="#FFFFFF" class="labels"> |
|
|
<td colspan="4"> |
|
|
<div align="center"> |
|
|
Não foram cadastrados as op<EFBFBD><EFBFBD>es |
|
|
</div> |
|
|
</td> |
|
|
</tr> |
|
|
<?php } ?> |
|
|
</table> |
|
|
<script> |
|
|
function excluir2(codigo, nome, mensagem, endereco, tipo) { |
|
|
$.blockUI({ |
|
|
message: $('#mensagem'), |
|
|
css: { |
|
|
width: '275px', |
|
|
left: '20%', |
|
|
top: '20%' |
|
|
} |
|
|
}); |
|
|
window.mens.value = mensagem; |
|
|
$('#todos').click(function() { |
|
|
// update the block message |
|
|
$.blockUI({ |
|
|
message: "<h1>Exluindo o " + tipo + " : " + nome + "</h1>", |
|
|
css: { |
|
|
width: '275px', |
|
|
left: '20%', |
|
|
top: '20%' |
|
|
} |
|
|
}); |
|
|
|
|
|
$.ajax({ |
|
|
url: endereco, |
|
|
cache: false, |
|
|
complete: function() { |
|
|
window.self.location.href = 'index.php?idProg=11131&pbxRequest=1&id_ura=<?= $id_ura; ?>'; |
|
|
$.unblockUI(); |
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
$('#cancela').click(function() { |
|
|
$.unblockUI(); |
|
|
window.self.location.reload(); |
|
|
return false; |
|
|
}); |
|
|
} |
|
|
</script> |
|
|
</body> |
|
|
|
|
|
</html> |
|
|
<?php if ($acao2 == 'edita') { ?> |
|
|
<script> |
|
|
ajaxComboBox('admin/popula.php?id=<?= $acao; ?>', 'acao', 'opcao', '<?= $acao; ?>'); |
|
|
</script> |
|
|
<?php } ?>
|