|
|
|
|
<?
|
|
|
|
|
$acao = isset($_GET['acao']) ? trim($_GET['acao']) : 'select';
|
|
|
|
|
$id = isset($_GET['id']) ? trim($_GET['id']) : 0;
|
|
|
|
|
$filtro = isset($_GET["numRamal"]) ? trim($_GET["numRamal"]) : '';
|
|
|
|
|
$filtroNovo = !isset($_GET["pgn"]) ? '' : sprintf("&numRamal%s&pgn=%s&bloco=%s&pg=%s", $_GET["numRamal"], $_GET["pgn"], $_GET["bloco"], $_GET["pg"]);
|
|
|
|
|
$recontaPag = ($acao == 'inseri') || ($acao == "deleta") || isset($_GET['pesquisa']);
|
|
|
|
|
|
|
|
|
|
if ($acao == "deleta") {
|
|
|
|
|
$query = "update pbx_cs_usuarios set status = 'D' where matricula='$id'";
|
|
|
|
|
$queryRpl = 'insert into pbx_replica(rpl_command, rpl_user, rpl_origem) values(%s, %s, %s)';
|
|
|
|
|
$queryRpl = sprintf($queryRpl, QuotedStr($query), QuotedStr(GetLogin()), QuotedStr(GetServerName()));
|
|
|
|
|
$inTran = 0;
|
|
|
|
|
|
|
|
|
|
$result = pg_query($dbcon, 'begin');
|
|
|
|
|
try {
|
|
|
|
|
if (!$result)
|
|
|
|
|
throw new Exception('N<EFBFBD>o foi poss<EFBFBD>vel acessar a base de dados!');
|
|
|
|
|
$inTran = 1;
|
|
|
|
|
|
|
|
|
|
$result = pg_query($dbcon, $query);
|
|
|
|
|
if (!$result)
|
|
|
|
|
throw new Exception('N<EFBFBD>o foi poss<EFBFBD>vel excluir a conta!');
|
|
|
|
|
|
|
|
|
|
if (SincContaSenha() && IsServerMaster()) {
|
|
|
|
|
$result = pg_query($dbcon, $queryRpl);
|
|
|
|
|
if (!$result)
|
|
|
|
|
throw new Exception('N<EFBFBD>o foi poss<EFBFBD>vel gravar dados da sincroniza<EFBFBD><EFBFBD>o!');
|
|
|
|
|
}
|
|
|
|
|
else if (SincContaSenha()) {
|
|
|
|
|
$ret = ExecDb($queryRpl);
|
|
|
|
|
$result = $ret['result'] == 'true';
|
|
|
|
|
if (!$result)
|
|
|
|
|
throw new Exception('N<EFBFBD>o foi poss<EFBFBD>vel gravar dados da sincroniza<EFBFBD><EFBFBD>o!');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$result = pg_query($dbcon, 'commit');
|
|
|
|
|
if (!$result)
|
|
|
|
|
throw new Exception('N<EFBFBD>o foi poss<EFBFBD>vel finalizar a transa<EFBFBD><EFBFBD>o!');
|
|
|
|
|
} catch (Exception $ex) {
|
|
|
|
|
if ($inTran)
|
|
|
|
|
@pg_query($dbcon, 'rollback');
|
|
|
|
|
$msg = $ex->getMessage();
|
|
|
|
|
$jsStartup[] = "alert('$msg');";
|
|
|
|
|
}
|
|
|
|
|
?>
|
|
|
|
|
|
|
|
|
|
<? } ?>
|
|
|
|
|
|
|
|
|
|
<table width="99%" align="center" border="0" cellpadding="2" cellspacing="0" class="filtro">
|
|
|
|
|
<tr>
|
|
|
|
|
<td colspan="2">Palavra Chave</td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
|
|
|
|
<td align="left" nowrap="nowrap" >
|
|
|
|
|
<input name="numRamal" type="text" id="numRamal" value="<? echo $_GET["numRamal"]; ?>" onkeyup="ConsultaRamal('index.php?idProg=10028&pbxRequest=1', event);" size="20">
|
|
|
|
|
<input name="locaRamal" type="button" id="locaRamal" value="Localizar" onClick="ConsultaRamal('index.php?idProg=10028&pbxRequest=1&pesquisa=1', 0);">
|
|
|
|
|
</td>
|
|
|
|
|
<td align="right" nowrap="nowrap">
|
|
|
|
|
<a href="#" onclick="abre_janela('700', '520', 'index.php?idProg=11028&pbxRequest=1&acao=inseri&acao2=novo<?php echo $filtroNovo; ?>');"><img src="admin/images/novo.gif" width="20" height="20" border="0" align="absmiddle">NOVA CONTA </a>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
|
|
|
|
<td colspan="2">
|
|
|
|
|
<table width="100%" class="grid" border="0" cellspacing="0" cellpadding="2">
|
|
|
|
|
<tr>
|
|
|
|
|
<th align="center">Id</th>
|
|
|
|
|
<th>Nome</div></th>
|
|
|
|
|
<th>Apelido </th>
|
|
|
|
|
<th>Matricula</th>
|
|
|
|
|
<th>Empresa</th>
|
|
|
|
|
<th>Departamento</th>
|
|
|
|
|
<th>Status</th>
|
|
|
|
|
<th align="center">A<EFBFBD><EFBFBD>es</th>
|
|
|
|
|
</tr>
|
|
|
|
|
<?
|
|
|
|
|
$janW = '500';
|
|
|
|
|
$janH = '400';
|
|
|
|
|
|
|
|
|
|
$compl = '';
|
|
|
|
|
if (isset($_GET['pesquisa']) && $_GET['pesquisa']) {
|
|
|
|
|
$compl = PreparaLike($filtro, true);
|
|
|
|
|
$compl = sprintf("and (a.nome ilike %s or a.apelido ilike %s or a.matricula::text ilike %s)", $compl, $compl, $compl);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$query = "select a.id, a.nome, a.apelido, a.matricula, b.nome as empresa, c.nome_depto as departamento, a.status
|
|
|
|
|
from pbx_cs_usuarios a, pbx_empresa b, pbx_departamentos c
|
|
|
|
|
where b.id = a.empresa
|
|
|
|
|
and c.id = a.departamento
|
|
|
|
|
-- and a.status = 'A'
|
|
|
|
|
$compl order by a.nome asc";
|
|
|
|
|
|
|
|
|
|
$params = "&pbxRequest=1&numRamal=$filtro";
|
|
|
|
|
$links = PaginaDados($idProg, $query, $params, $regPagina, $offSet, $pagMostra, true);
|
|
|
|
|
$query .= " limit $regPagina offset $offSet";
|
|
|
|
|
$result = pg_query($dbcon, $query);
|
|
|
|
|
$z = 0;
|
|
|
|
|
while ($dados = pg_fetch_array($result)) {
|
|
|
|
|
?>
|
|
|
|
|
<tr>
|
|
|
|
|
<td width="50" align="center"><? echo $dados['id']; ?></td>
|
|
|
|
|
<td><a href="#" style="color: #000;" onclick="abre_janela('700', '520', 'index.php?idProg=11028&pbxRequest=1&acao=edita&id=<? echo $dados['id']; ?><? echo $params; ?>');"><? echo $dados['nome']; ?></a></td>
|
|
|
|
|
<td><? echo $dados['apelido']; ?></td>
|
|
|
|
|
<td><? echo $dados['matricula']; ?></td>
|
|
|
|
|
<td><? echo $dados['empresa']; ?></td>
|
|
|
|
|
<td><? echo $dados['departamento']; ?></td>
|
|
|
|
|
<td align="center" width="20">
|
|
|
|
|
<div align="center">
|
|
|
|
|
<? echo GetStatusModulo($dados['status']); ?>
|
|
|
|
|
</div>
|
|
|
|
|
</td>
|
|
|
|
|
<td width="40">
|
|
|
|
|
<table width="100%" border="0" cellspacing="0" cellpadding="1">
|
|
|
|
|
<tr>
|
|
|
|
|
|
|
|
|
|
<td style="border:0"><div align="center"><a href="#" onclick="abre_janela('700', '520', 'index.php?idProg=11028&pbxRequest=1&acao=edita&id=<? echo $dados['id']; ?><? echo $params; ?>');"><img src="images/edit.gif" title="EDITAR O USU<EFBFBD>RIO:<? echo $dados['nome']; ?>" width="16" height="16" border="0"></a></div></td>
|
|
|
|
|
<? if ($dados['status'] == "A") { ?>
|
|
|
|
|
<td style="border:0"><div align="center"><a href="#" onclick="excluir('<? echo $dados['id']; ?>', '<? echo $dados['nome']; ?>', 'DESEJA REALMENTE DESABILITAR O USU<EFBFBD>RIO:<? echo $dados['nome']; ?>', 'index.php?idProg=10028&pbxRequest=1&acao=deleta&id=<? echo $dados['matricula']; ?><? echo $params; ?>', 'USUARIOS');"><img src="images/delete.gif" title="DESABILITAR O USU<EFBFBD>RIO:<? echo $dados['nome']; ?>" width="16" height="16" border="0"></a></div></td>
|
|
|
|
|
<? } ?>
|
|
|
|
|
</tr>
|
|
|
|
|
</table>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
<?
|
|
|
|
|
$z++;
|
|
|
|
|
} if ($z == 0) {
|
|
|
|
|
?>
|
|
|
|
|
<tr align="center" valign="middle" bordercolor="#999999" class="labels">
|
|
|
|
|
<td colspan="8"><div align="center" class="info"><img src="images/shutdown.gif" width="24" height="24" border="0" align="absmiddle" /> N<EFBFBD>o foram encontrados registros </div></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<?
|
|
|
|
|
}
|
|
|
|
|
?>
|
|
|
|
|
<tr>
|
|
|
|
|
<th align="center" colspan="8"><table width="100%" class="grid" border="0" cellspacing="0" cellpadding="2"><tr><th align="center" style="width: 90%; border:0;"><?php echo $links; ?></th><th align="right" style="width: 10%; border:0;"><?php echo sprintf("%s/%s", $pagMostra, $totalReg); ?></th></tr></table></th>
|
|
|
|
|
</tr>
|
|
|
|
|
</table>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
</table>
|
|
|
|
|
</body>
|
|
|
|
|
</html>
|