forked from SimplesIP/pabx-app
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.
141 lines
7.9 KiB
141 lines
7.9 KiB
<?php |
|
$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ão foi possível acessar a base de dados!'); |
|
$inTran = 1; |
|
|
|
$result = pg_query($dbcon, $query); |
|
if (!$result) |
|
throw new Exception('Não foi possível excluir a conta!'); |
|
|
|
if (SincContaSenha() && IsServerMaster()) { |
|
$result = pg_query($dbcon, $queryRpl); |
|
if (!$result) |
|
throw new Exception('Não foi possível gravar dados da sincronização!'); |
|
} |
|
else if (SincContaSenha()) { |
|
$ret = ExecDb($queryRpl); |
|
$result = $ret['result'] == 'true'; |
|
if (!$result) |
|
throw new Exception('Não foi possível gravar dados da sincronização!'); |
|
} |
|
|
|
$result = pg_query($dbcon, 'commit'); |
|
if (!$result) |
|
throw new Exception('Não foi possível finalizar a transação!'); |
|
} catch (Exception $ex) { |
|
if ($inTran) |
|
pg_query($dbcon, 'rollback'); |
|
$msg = $ex->getMessage(); |
|
$jsStartup[] = "alert('$msg');"; |
|
} |
|
?> |
|
|
|
<?php } ?> |
|
|
|
<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="<?php 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ções</th> |
|
</tr> |
|
<?php |
|
$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"><?php echo $dados['id']; ?></td> |
|
<td><a href="#" style="color: #000;" onclick="abre_janela('700', '520', 'index.php?idProg=11028&pbxRequest=1&acao=edita&id=<?php echo $dados['id']; ?><?php echo $params; ?>');"><?php echo $dados['nome']; ?></a></td> |
|
<td><?php echo $dados['apelido']; ?></td> |
|
<td><?php echo $dados['matricula']; ?></td> |
|
<td><?php echo $dados['empresa']; ?></td> |
|
<td><?php echo $dados['departamento']; ?></td> |
|
<td align="center" width="20"> |
|
<div align="center"> |
|
<?php 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=<?php echo $dados['id']; ?><?php echo $params; ?>');"><img src="images/edit.gif" title="EDITAR O USUÁRIO:<?php echo $dados['nome']; ?>" width="16" height="16" border="0"></a></div></td> |
|
<?php if ($dados['status'] == "A") { ?> |
|
<td style="border:0"><div align="center"><a href="#" onclick="excluir('<?php echo $dados['id']; ?>', '<?php echo $dados['nome']; ?>', 'DESEJA REALMENTE DESABILITAR O USUÁRIO:<?php echo $dados['nome']; ?>', 'index.php?idProg=10028&pbxRequest=1&acao=deleta&id=<?php echo $dados['matricula']; ?><?php echo $params; ?>', 'USUARIOS');"><img src="images/delete.gif" title="DESABILITAR O USUÁRIO:<?php echo $dados['nome']; ?>" width="16" height="16" border="0"></a></div></td> |
|
<?php } ?> |
|
</tr> |
|
</table> |
|
</td> |
|
</tr> |
|
<?php |
|
$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ão foram encontrados registros </div></td> |
|
</tr> |
|
<?php |
|
} |
|
?> |
|
<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>
|
|
|