|
|
|
|
<!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 () {}
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
</script>
|
|
|
|
|
<link href="admin/css/forms.css" rel="stylesheet" type="text/css">
|
|
|
|
|
<style type="text/css">
|
|
|
|
|
<!--
|
|
|
|
|
body {
|
|
|
|
|
background-color: #EAEAEA;
|
|
|
|
|
}
|
|
|
|
|
-->
|
|
|
|
|
</style></head>
|
|
|
|
|
<body>
|
|
|
|
|
|
|
|
|
|
<?php
|
|
|
|
|
//INCLUDE DAS FUN<EFBFBD><EFBFBD>ES PADR<EFBFBD>ES DO SISTEMA
|
|
|
|
|
|
|
|
|
|
$acao = $_GET["acao"];
|
|
|
|
|
$acao2 = $_GET["acao2"];
|
|
|
|
|
|
|
|
|
|
if ($acao2 == "salva") {
|
|
|
|
|
$id = $_POST["id"];
|
|
|
|
|
$nome = trim($_POST["nome"]);
|
|
|
|
|
$telefone = trim($_POST["telefone"]);
|
|
|
|
|
$tipo = trim($_POST["tipo"]);
|
|
|
|
|
$posicao = trim($_POST["posicao"]);
|
|
|
|
|
$ramal = trim($_POST["ramal"]);
|
|
|
|
|
|
|
|
|
|
if ($acao == 'inseri') {
|
|
|
|
|
//VALIDACAO PARA EXISTENCIA DE POSIC<EFBFBD>ES CADASTRADAS NO SISTEMA
|
|
|
|
|
if ($tipo == 'P') {
|
|
|
|
|
//SE TIPO = PUBLICA
|
|
|
|
|
$query = "SELECT * FROM pbx_agenda where posicao='$posicao' and tipo='$tipo'";
|
|
|
|
|
} else {
|
|
|
|
|
//SE TIPO = RAMAL
|
|
|
|
|
$query = "SELECT * FROM pbx_agenda where posicao='$posicao' and tipo='$tipo' and ramal='$ramal'";
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
//SE TIPO = ATUALIZA<EFBFBD><EFBFBD>O
|
|
|
|
|
$query = "SELECT * FROM pbx_agenda where posicao='$posicao' and id <> $id and tipo='$tipo'";
|
|
|
|
|
}
|
|
|
|
|
$result = pg_query($dbcon, $query);
|
|
|
|
|
|
|
|
|
|
while ($dados = pg_fetch_array($result)) {
|
|
|
|
|
$existe = trim($dados['telefone']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($existe != '') {
|
|
|
|
|
?>
|
|
|
|
|
<script>
|
|
|
|
|
alert('POSI<EFBFBD><EFBFBD>O J<EFBFBD> CADASTRADA PARA O TELEFONE <?php echo $existe; ?>');
|
|
|
|
|
history.back();
|
|
|
|
|
</script>
|
|
|
|
|
<?php
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($acao == "inseri") {
|
|
|
|
|
$query = "INSERT INTO pbx_agenda(nome,telefone,tipo,posicao,ramal)
|
|
|
|
|
VALUES ('$nome','$telefone','$tipo','$posicao','$ramal')";
|
|
|
|
|
|
|
|
|
|
//ACAO DE INSERT NO BANCO
|
|
|
|
|
pg_query($dbcon, $query);
|
|
|
|
|
|
|
|
|
|
if ($tipo == 'R') {
|
|
|
|
|
//CADASTRA AGENDA DO RAMAL NO ASTERISK//executa inser<EFBFBD><EFBFBD>o na base interna do asterisk
|
|
|
|
|
CommandAsterisk2($dbcon, 'AGENDA_RAMAL', $ramal . '/' . $posicao, $telefone);
|
|
|
|
|
} else {
|
|
|
|
|
//CADASTRA AGENDA PUBLICA NO ASTERISK//executa inser<EFBFBD><EFBFBD>o na base interna do asterisk
|
|
|
|
|
CommandAsterisk2($dbcon, 'AGENDA_RAMAL', $posicao, $telefone);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($acao == "edita") {
|
|
|
|
|
|
|
|
|
|
//REALIZA BACKUP BO BANCO
|
|
|
|
|
//backup($dbcon,'pbx_agenda','U',$id,'update','AGENDA');
|
|
|
|
|
|
|
|
|
|
$query = "UPDATE pbx_agenda
|
|
|
|
|
SET nome='$nome', telefone='$telefone',tipo='$tipo',posicao='$posicao',ramal='$ramal'
|
|
|
|
|
WHERE id=$id";
|
|
|
|
|
pg_query($dbcon, $query);
|
|
|
|
|
|
|
|
|
|
$tipo2 = $_POST['tipo2'];
|
|
|
|
|
$ramal2 = $_POST['ramal2'];
|
|
|
|
|
$posicao2 = $_POST['posicao2'];
|
|
|
|
|
|
|
|
|
|
if ($tipo2 == 'R') {
|
|
|
|
|
//SE TIPO DE AGENDA = RAMAL , APAGA O REGISTRO DO BANCO ASTERISK//executa inser<EFBFBD><EFBFBD>o na base interna do asterisk
|
|
|
|
|
CommandAsterisk2($dbcon, 'DEL AGENDA', $ramal2 . '/' . $posicao2, '');
|
|
|
|
|
} else {
|
|
|
|
|
//SE TIPO DE AGENDA = PUBLICA , APAGA O REGISTRO DO BANCO ASTERISK//executa inser<EFBFBD><EFBFBD>o na base interna do asterisk
|
|
|
|
|
CommandAsterisk2($dbcon, 'DEL AGENDA', $posicao2, '');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($tipo == 'R') {
|
|
|
|
|
//SE TIPO DE AGENDA = RAMAL , REGISTRA DO BANCO ASTERISK//executa inser<EFBFBD><EFBFBD>o na base interna do asterisk
|
|
|
|
|
CommandAsterisk2($dbcon, 'AGENDA_RAMAL', $ramal . '/' . $posicao, $telefone);
|
|
|
|
|
} else {
|
|
|
|
|
//SE TIPO DE AGENDA = PUBLICA , REGISTRA DO BANCO ASTERISK//executa inser<EFBFBD><EFBFBD>o na base interna do asterisk
|
|
|
|
|
CommandAsterisk2($dbcon, 'AGENDA_RAMAL', $posicao, $telefone);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
?>
|
|
|
|
|
<script>
|
|
|
|
|
//FECHA POPUP
|
|
|
|
|
//fecha a janela presa no meio do sistema
|
|
|
|
|
fecha_popup();
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<?php
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($acao == "edita") {
|
|
|
|
|
$id = $_GET["id"] ?? "0";
|
|
|
|
|
$query = "SELECT * FROM pbx_agenda where id=$id";
|
|
|
|
|
$result = pg_query($dbcon, $query);
|
|
|
|
|
} else {
|
|
|
|
|
$query = "SELECT * FROM pbx_agenda where id is null";
|
|
|
|
|
}
|
|
|
|
|
$result = pg_query($dbcon, $query);
|
|
|
|
|
//SELECIONA REGISTROS PARA APRESENTACAO NA TELA DE CADASTRO
|
|
|
|
|
while ($dados = pg_fetch_array($result)) {
|
|
|
|
|
$id = $dados["id"];
|
|
|
|
|
$nome = $dados["nome"];
|
|
|
|
|
$telefone = $dados["telefone"];
|
|
|
|
|
$tipo = $dados["tipo"];
|
|
|
|
|
$ramal = $dados["ramal"];
|
|
|
|
|
$posicao = $dados["posicao"];
|
|
|
|
|
}
|
|
|
|
|
?>
|
|
|
|
|
|
|
|
|
|
<form name="form1" method="post" action="index.php?idProg=11004&pbxRequest=1&acao=<?php echo $acao; ?>&acao2=salva" id="form1">
|
|
|
|
|
<table border="1" align="center" cellpadding="0" cellspacing="0" class="tabela">
|
|
|
|
|
<tr bordercolor="#EAEAEA" class="cabecalho">
|
|
|
|
|
<td colspan="4"><div align="center">CADASTRO DE CONTATOS
|
|
|
|
|
<input name="id" type="hidden" id="id" value="<?php
|
|
|
|
|
if ($acao == 'edita') {
|
|
|
|
|
echo $id;
|
|
|
|
|
}
|
|
|
|
|
?>" />
|
|
|
|
|
<input name="tipo2" type="hidden" id="tipo2" value="<?php
|
|
|
|
|
if ($acao == 'edita') {
|
|
|
|
|
echo $tipo;
|
|
|
|
|
}
|
|
|
|
|
?>" />
|
|
|
|
|
<input name="posicao2" type="hidden" id="posicao2" value="<?php
|
|
|
|
|
if ($acao == 'edita') {
|
|
|
|
|
echo $posicao;
|
|
|
|
|
}
|
|
|
|
|
?>" />
|
|
|
|
|
<input name="ramal2" type="hidden" id="ramal2" value="<?php
|
|
|
|
|
if ($acao == 'edita') {
|
|
|
|
|
echo $ramal;
|
|
|
|
|
}
|
|
|
|
|
?>" />
|
|
|
|
|
</div></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr bordercolor="#EAEAEA" bgcolor="#EAEAEA">
|
|
|
|
|
<td colspan="4" class="labels"><table width="100%" border="0" cellspacing="0" cellpadding="0">
|
|
|
|
|
<tr>
|
|
|
|
|
<td><fieldset>
|
|
|
|
|
<legend class="labels"><span class="style5">Nome:</span></legend>
|
|
|
|
|
<input name="nome" type="text" class="validate[required,length[0,100]] caixas" id="nome2" value="<?php
|
|
|
|
|
if ($acao == 'edita') {
|
|
|
|
|
echo $nome;
|
|
|
|
|
}
|
|
|
|
|
?>" size="70\" maxlength="50" />
|
|
|
|
|
</fieldset></td>
|
|
|
|
|
</tr>
|
|
|
|
|
</table></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr bordercolor="#EAEAEA" bgcolor="#EAEAEA">
|
|
|
|
|
<td colspan="4" class="labels"><table width="100%" border="0" cellspacing="0" cellpadding="0">
|
|
|
|
|
<tr>
|
|
|
|
|
<td width="59%"><fieldset>
|
|
|
|
|
<legend class="labels"><span class="style5">Telefone:</span></legend>
|
|
|
|
|
<input name="telefone" type="text" class="validate[required,custom[onlyNumber],length[0,100]] caixas" id="razao_social2" value="<?php
|
|
|
|
|
if ($acao == 'edita') {
|
|
|
|
|
echo $telefone;
|
|
|
|
|
} else {
|
|
|
|
|
echo "";
|
|
|
|
|
}
|
|
|
|
|
?>" size="40" maxlength="100" />
|
|
|
|
|
</fieldset></td>
|
|
|
|
|
<td width="41%"><fieldset>
|
|
|
|
|
<legend class="labels">Tipo:</legend>
|
|
|
|
|
<span class="style5">
|
|
|
|
|
<input name="tipo" type="radio" value="P" <?php
|
|
|
|
|
if ($acao == 'edita') {
|
|
|
|
|
if ($tipo == 'P') {
|
|
|
|
|
echo "checked";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
?> onchange="javascript:document.form1.ramal.disabled = true;document.form1.ramal.className = 'validate[optional] caixas';"/>
|
|
|
|
|
Pública
|
|
|
|
|
<input name="tipo" type="radio" value="R" <?php
|
|
|
|
|
if ($acao == 'edita') {
|
|
|
|
|
if ($tipo == 'R') {
|
|
|
|
|
echo "checked";
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
echo "checked";
|
|
|
|
|
}
|
|
|
|
|
?> onchange="javascript:document.form1.ramal.disabled = false;
|
|
|
|
|
document.form1.ramal.className = 'validate[required] caixas';"/>
|
|
|
|
|
Ramal
|
|
|
|
|
</span>
|
|
|
|
|
</fieldset></td>
|
|
|
|
|
</tr>
|
|
|
|
|
</table></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr bordercolor="#EAEAEA" bgcolor="#EAEAEA">
|
|
|
|
|
<td colspan="4"><table width="100%" border="0" cellspacing="0" cellpadding="0">
|
|
|
|
|
<tr>
|
|
|
|
|
<td width="50%"><fieldset>
|
|
|
|
|
<legend class="labels"><span class="style5">Posição:</span></legend>
|
|
|
|
|
<input name="posicao" type="text" class="validate[required,custom[onlyNumber],length[0,100]] caixas" id="telefone3" value="<?php
|
|
|
|
|
if ($acao == 'edita') {
|
|
|
|
|
echo $posicao;
|
|
|
|
|
} else {
|
|
|
|
|
echo "";
|
|
|
|
|
}
|
|
|
|
|
?>" size="10" maxlength="10" />
|
|
|
|
|
</fieldset></td>
|
|
|
|
|
<td width="50%"><fieldset>
|
|
|
|
|
<legend class="labels"><span class="style5">Ramal:</span></legend>
|
|
|
|
|
<select name="ramal" class="caixas" id="ramal" >
|
|
|
|
|
<option value="">-----------</option>
|
|
|
|
|
<?php
|
|
|
|
|
$query2 = "select id,nome from pbx_ramais ";
|
|
|
|
|
$result2 = pg_query($dbcon, $query2);
|
|
|
|
|
while ($dados2 = pg_fetch_array($result2)) {
|
|
|
|
|
?>
|
|
|
|
|
<option value="<?php echo $dados2['nome'] ?>" <?php
|
|
|
|
|
if ($ramal == $dados2['nome']) {
|
|
|
|
|
echo "selected";
|
|
|
|
|
}
|
|
|
|
|
?>><?php echo $dados2['nome']; ?></option>
|
|
|
|
|
<?php } ?>
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
</fieldset></td>
|
|
|
|
|
</tr>
|
|
|
|
|
</table></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr bordercolor="#EAEAEA" bgcolor="#EAEAEA">
|
|
|
|
|
<td colspan="4"><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" onclick="fecha_popup();" value="Fechar">
|
|
|
|
|
<input name="Submit" type="submit" class="labels" value="Salvar">
|
|
|
|
|
</span></div></td>
|
|
|
|
|
</tr>
|
|
|
|
|
</table>
|
|
|
|
|
</form>
|
|
|
|
|
<?php if ($tipo == 'P') { ?>
|
|
|
|
|
<script>document.form1.ramal.disabled = true;</script>
|
|
|
|
|
<?php
|
|
|
|
|
}?>
|