|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
$msg = 'Cadastro de destinos!';
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Templae associado ao script.
|
|
|
|
|
*/
|
|
|
|
|
$nomeTpl = "cadastros/backup/bkpDestino.htm";
|
|
|
|
|
$erro = 0;
|
|
|
|
|
$janW = 600;
|
|
|
|
|
$janH = 340;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Informacoes para paginacao.
|
|
|
|
|
*/
|
|
|
|
|
$filtro = isset($_REQUEST["paramPesquisa"]) ? trim($_REQUEST["paramPesquisa"]) : '';
|
|
|
|
|
$recontaPag = (GetFormAcao() == FORM_DELETE) || isset($_POST["pesquisa"]);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Link para inserir novo registro.
|
|
|
|
|
*/
|
|
|
|
|
$imgNovo = "<img src=\"images/novo.gif\" width=\"16\" height=\"16\" border=\"0\" title=\"Inclui novo destino!\">";
|
|
|
|
|
$imgNovo = sprintf("<a href=\"javaScript:NovaJanela('index.php?idProg=220&acaoUser=%s&dst_id=0', 'bkpDestinoCad', '%s', '%s', 'resizable=NO,scrollbars=NO');\">%s %s</a>", FORM_INSERT, $janW, $janH, $imgNovo, 'Novo Destino');
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
/*
|
|
|
|
|
* Apaga o registro selecionado no formulario.
|
|
|
|
|
*/
|
|
|
|
|
if (GetFormAcao() == FORM_DELETE) {
|
|
|
|
|
$dst_id = $_REQUEST['id'];
|
|
|
|
|
/*
|
|
|
|
|
* Verifica dependencias.
|
|
|
|
|
*/
|
|
|
|
|
$query = "select '' from pbx_backup_configuracao where dst_id = '$dst_id'";
|
|
|
|
|
$result = pg_query($dbcon, $query);
|
|
|
|
|
if (!$result) {
|
|
|
|
|
GeraExcept("ERRO;Erro ao verificar depend<EFBFBD>ncias do destino!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (pg_num_rows($result)) {
|
|
|
|
|
GeraExcept("ERRO;N<EFBFBD>o <EFBFBD> poss<EFBFBD>vel apagar o destino informado, pois o mesmo esta associadao a uma ou mais configura<EFBFBD><EFBFBD>es de Backup!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$query = "delete from pbx_backup_destino where dst_id = '$dst_id'";
|
|
|
|
|
$result = pg_query($dbcon, $query);
|
|
|
|
|
if (!$result) {
|
|
|
|
|
GeraExcept("ERRO;Erro ao apagar o destino informado!");
|
|
|
|
|
}
|
|
|
|
|
$msg = "Destino excluido com sucesso!";
|
|
|
|
|
if (IsAjax()) {
|
|
|
|
|
echo "OK;Destino excluido com sucesso!$msg";
|
|
|
|
|
exit();
|
|
|
|
|
} else {
|
|
|
|
|
$jsStartup[] = sprntf("alert('%s');", $msg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Filtra os registro de acordo com a string submetida pelo usuario
|
|
|
|
|
*/
|
|
|
|
|
$compl = '';
|
|
|
|
|
if ($filtro) {
|
|
|
|
|
$compl = PreparaLike($filtro, true);
|
|
|
|
|
$compl = sprintf(" and (a.dst_nome ilike %s or a.dst_host ilike %s)", $compl, $compl);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Prepara a consulta p
|
|
|
|
|
*/
|
|
|
|
|
$query = "select a.dst_id, a.dst_nome, a.dst_host, a.dst_porta, a.dst_diretorio_remoto, b.prt_descricao
|
|
|
|
|
from pbx_backup_destino a, pbx_backup_protocolo b
|
|
|
|
|
where b.prt_id = a.prt_id
|
|
|
|
|
and a.dst_id <> 0 $compl
|
|
|
|
|
order by 2";
|
|
|
|
|
/*
|
|
|
|
|
* Adiciona informacoes para paginacao.
|
|
|
|
|
*/
|
|
|
|
|
$params = "¶mPesquisa=$filtro";
|
|
|
|
|
$links = PaginaDados($idProg, $query, $params, $regPagina, $offSet, $pagMostra, true);
|
|
|
|
|
$query .= " limit $regPagina offset $offSet";
|
|
|
|
|
$result = pg_query($dbcon, $query);
|
|
|
|
|
if (!$result) {
|
|
|
|
|
GeraExcept("Erro ao consultar atualiza<EFBFBD><EFBFBD>es dos clientes!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$linhas = '';
|
|
|
|
|
while ($dadosAtu = pg_fetch_array($result)) {
|
|
|
|
|
$dst_id = $dadosAtu["dst_id"];
|
|
|
|
|
$dst_nome = $dadosAtu["dst_nome"];
|
|
|
|
|
$dst_host = $dadosAtu["dst_host"];
|
|
|
|
|
$dst_porta = $dadosAtu["dst_porta"];
|
|
|
|
|
$dst_diretorio_remoto = $dadosAtu["dst_diretorio_remoto"];
|
|
|
|
|
$prt_descricao = $dadosAtu["prt_descricao"];
|
|
|
|
|
|
|
|
|
|
$imgEdit = "<img src=\"imgSite/editaUser.png\" width=\"16\" height=\"16\" border=\"0\" title=\"Edita o cliente: $cliDescricao\">";
|
|
|
|
|
$imgEdit = sprintf("<a href=\"javaScript:NovaJanela('index.php?idProg=220&acaoUser=%s&dst_id=%s', 'bkpDestinoCad', '%s', '%s', 'resizable=NO,scrollbars=NO');\">%s</a>", FORM_UPDATE, $dst_id, $janW, $janH, $imgEdit);
|
|
|
|
|
|
|
|
|
|
$imgDelete = "<img src=\"imgSite/deletaUser.png\" width=\"16\" height=\"16\" border=\"0\" title=\"Apaga o usu<EFBFBD>rio: $cliDescricao\">";
|
|
|
|
|
$imgDelete = sprintf("<a href=\"javaScript:DeletaRegistro('%s', '%s', '&dst_nome=%s&acaoUser=%s');\">%s</a>", $idProg, $dst_id, $dst_nome, FORM_DELETE, $imgDelete);
|
|
|
|
|
//Id Nome Protocolo Host Port Diret<EFBFBD>rio (idProg, id, param)
|
|
|
|
|
$linhas .= " <tr><td align=\"right\">$dst_id</td>
|
|
|
|
|
<td align=\"left\">$dst_nome</td>
|
|
|
|
|
<td align=\"left\">$prt_descricao</td>
|
|
|
|
|
<td align=\"left\">$dst_host</td>
|
|
|
|
|
<td align=\"center\">$dst_porta</td>
|
|
|
|
|
<td align=\"left\">$dst_diretorio_remoto</td>
|
|
|
|
|
<td align=\"center\" width=16>$imgEdit</td>
|
|
|
|
|
<td align=\"center\" width=16>$imgDelete</td>
|
|
|
|
|
</tr>";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!$linhas) {
|
|
|
|
|
$linhas .= " <tr><td align=\"center\" colspan=\"8\">Nenhum destino cadastrado!</td></tr>";
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception $ex) {
|
|
|
|
|
$erro++;
|
|
|
|
|
$msg = $ex->getMessage();
|
|
|
|
|
/*
|
|
|
|
|
* Registra o erro para analise posterior no diretorio de log.
|
|
|
|
|
*/
|
|
|
|
|
GravaLogApl(array($msg, sprintf("Cmd: %s", $query), sprintf("Sys: %s", GetLasterror())), 'backup', GetLogin());
|
|
|
|
|
if (IsAjax()) {
|
|
|
|
|
echo $msg;
|
|
|
|
|
exit;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$smarty->assign('erro', $erro);
|
|
|
|
|
$smarty->assign('msg', $msg);
|
|
|
|
|
$smarty->assign('linhas', $linhas);
|
|
|
|
|
$smarty->assign("paramPesquisa", $filtro);
|
|
|
|
|
$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, $nomeTpl)
|
|
|
|
|
?>
|