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.
 
 
 
 
 
 

91 lines
3.4 KiB

<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
$janW = 500;
$janH = 300;
$paramPesquisa = isset($_REQUEST['paramPesquisa']) ? $_REQUEST['paramPesquisa'] : '';
$filtro = isset($_REQUEST["paramPesquisa"]) ? trim($_REQUEST["paramPesquisa"]) : '';
$filtroNovo = !isset($_REQUEST["pgn"]) ? '' : sprintf("&paramPesquisa%s&pgn=%s&bloco=%s&pg=%s", $_REQUEST["paramPesquisa"], $_REQUEST["pgn"], $_REQUEST["bloco"], $_REQUEST["pg"]);
$recontaPag = ($acao == 'inseri') || (GetFormAcao() == FORM_DELETE) || isset($_POST['pesquisa']);
$tpl = 'siteConsulta.tpl';
$imgNovo = GetLinkFormInsert("siteCad", 'images/novo.gif', $filtroNovo, ' Novo Site');
$linha = "";
if (GetFormAcao() == FORM_DELETE) {
$id = $_GET["id"] ?? "0";
$erro = DeletaSite($dbcon, $id);
}
$compl = '';
if (isset($_REQUEST['paramPesquisa']) && $_REQUEST['paramPesquisa']) {
$compl = PreparaLike($filtro, true);
$compl = sprintf("and (a.descricao ilike %s or a.host ilike %s or a.basedados ilike %s)", $compl, $compl, $compl);
}
$query = "select id, host, usuario, senha,
basedados, porta, descricao, status
from pbx_sites a where 1=1 $compl order by descricao";
$params = "&paramPesquisa=$filtro";
$links = PaginaDados($idProg, $query, $params, $regPagina, $offSet, $pagMostra, true);
$query .= " limit $regPagina offset $offSet";
$result = pg_query($dbcon, $query);
while ($row = pg_fetch_array($result)) {
$id = $row["id"];
$host = $row["host"];
$usuario = $row["usuario"];
$basedados = $row["basedados"];
$porta = $row["porta"];
$descricao = $row["descricao"];
$status = $row["status"];
$imgStatus = $status ? "<img src=\"imgSite/ledOn.gif\" width=\"16\" height=\"16\" border=\"0\" title=\"Ativo\">" : "<img src=\"imgSite/ledOff.gif\" width=\"16\" height=\"16\" border=\"0\" title=\"Inativo\">";
$urlEdita = "&id=$id";
//9903-2104
$descricao = GetLinkFormUpdate($urlEdita, "cadSites", "", 0, 1, $descricao);
$imgEdita = GetLinkFormUpdate($urlEdita, "cadSites");
$imgDel = GetLinkFormDelete($id . '|' . $params, "DeletaSite");
$linha .= " <tr class=\"headData\">
<td align=\"right\">$id</td>
<td align=\"left\" nowrap>$descricao</td>
<td align=\"left\">$host</td>
<td align=\"left\">$usuario</td>
<td align=\"left\">$basedados</td>
<td align=\"left\">$porta</td>
<td align=\"center\" width=\"20\" style=\"border-right: 0\">$imgEdita</td>
<td align=\"center\" width=\"20\" style=\"border-left: 0; border-right: 0\">$imgDel</td>
<td align=\"center\" width=\"20\" style=\"border-left: 0\">$imgStatus</td>
</tr>";
}
$smarty->assign('erro', $erro);
$smarty->assign("linhas", $linha);
$smarty->assign("paramPesquisa", $paramPesquisa);
$smarty->assign("imgNovo", $imgNovo);
$smarty->assign("links", $links);
$smarty->assign("pagMostra", $pagMostra);
$smarty->assign("totalReg", $totalReg);
$smarty->assign("pgn", $_REQUEST["pgn"]);
$smarty->assign("bloco", $_REQUEST["bloco"]);
$smarty->assign("pg", $_REQUEST["pg"]);
GetTemplate($smarty, $tpl);
function DeletaSite($db, $id) {
$query = "delete from pbx_sites where id = $id";
$result = pg_query($db, $query);
if ($result)
return "Registro deletado com sucesso!";
else
return "A opera<EFBFBD><EFBFBD>o n<EFBFBD>o pode ser realizada! " . (IsAdmin() ? ("Erro: " . pg_last_error($dbcon)) : "");
}
?>