<?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']);
$filtroNovo = 'index.php?idProg=11007& pbxRequest=1& acao=inseri' . $filtroNovo;
if ($acao == "deleta") {
$query = "delete from pbx_anuncios where id='$id'";
pg_query($dbcon, $query);
Ajusta_tabelas('anuncios', $id, $dbcon);
}
?>
< 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=10007&pbxRequest=1', event);" size = "20" >
< input name = "locaRamal" type = "button" id = "locaRamal" value = "Localizar" onClick = "ConsultaRamal('index.php?idProg=10007&pbxRequest=1&pesquisa=1', 0);" >
< / td >
< td align = "right" nowrap = "nowrap" >
< a href = "#" onclick = "NovaJanela( <? = QuotedStr ( $filtroNovo ); ?> , 'CadAnuncio', '400', '230', 'resizable=YES,scrollbars=YES');" >< img src = "images/novo.gif" width = "20" height = "20" border = "0" align = "absmiddle" > NOVO ANÚ NCIO </ a ></ div >
< / 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 < / th >
< th > Mú sica < / th >
< th align = "center" > < span title = "N<EFBFBD> mero de Depnd<EFBFBD> ncias" > Dep< / span > < / th >
< th align = "center" > A<EFBFBD> <EFBFBD> es< / th >
< / tr >
<?php
$compl = "";
if (isset($_GET['pesquisa']) & & $_GET['pesquisa']) {
$compl = PreparaLike($filtro, true);
$compl = sprintf("and (a.nome ilike %s or a.musica ilike %s) ", $compl, $compl);
}
//seleciona registros do banco
$query = "SELECT id, nome, musica FROM pbx_anuncios a where 1=1 $compl order by id asc";
$params = "& pbxRequest=1& numRamal=$filtro" . (isset($_GET['pesquisa']) ? '& pesquisa=1' : '');
$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)) {
$ext = explode('.', $dados['musica']);
$totaldep = GetTotalDependencias('anuncios', $dados['id']);
$opcao = 'anuncios';
$acao = $dados['id'];
$recursoTipo = 'An<EFBFBD> ncio';
$nomeRecurso = $dados['nome'];
$dep = GetLinkDependenciaRecurso($opcao, $acao, $recursoTipo, $nomeRecurso, $totaldep);
?>
< tr bordercolor = "#000000" class = "headColumn" >
< td width = "50" align = "center" > <?php echo $dados [ 'id' ]; ?> </ td >
< td align = "left" >
< a href = "#" style = "color: #000;" onClick = "abre_janela('400', '230', 'index.php?idProg=11007&pbxRequest=1&acao=edita&id= <?php echo $dados [ 'id' ]; ?><?php echo $params ; ?> ');" > <?php echo $dados [ 'nome' ]; ?> </ a >
< / td >
< td align = "left" > <?php echo $ext [ 0 ]; ?> </ td >
< td width = "30" align = "center" > <?php echo $dep ; ?> </ td >
< td width = "40" >
< table width = "100%" border = "0" cellspacing = "0" cellpadding = "1" >
< tr >
< td style = "border:0" width = "33%" >
< div align = "center" >
< a href = "#" onClick = "abre_janela('400', '230', 'index.php?idProg=11007&pbxRequest=1&acao=edita&id= <?php echo $dados [ 'id' ]; ?><?php echo $params ; ?> ');" >
< img src = "images/edit.gif" alt = "EDITAR O AN<EFBFBD> NCIO: <?php echo $dados [ 'nome' ]; ?> " width = "16" height = "16" border = "0" >
< / a >
< / div >
< / td >
<?php if ( ! $totaldep ) { ?>
< td style = "border:0" width = "33%" >
< div align = "center" >
< a href = "#" onClick = "excluir(' <?php echo $dados [ 'id' ]; ?> ', ' <?php echo $dados [ 'nome' ]; ?> ', 'DESEJA REALMENTE O EXCLUIR AN<EFBFBD> NCIO: <?php echo $dados [ 'nome' ]; ?> ', 'index.php?idProg=10007&pbxRequest=1&acao=deleta&id= <?php echo $dados [ 'id' ]; ?><?php echo $params ; ?> ', 'ANUNCIOS');" >
< img src = "images/delete.gif" alt = "APAGAR A URA: <?php echo $dados [ 'nome' ]; ?> " width = "16" height = "16" border = "0" >
< / a >
< / div >
< / td >
<?php } else { ?>
< td style = "border:0" width = "33%" >
< div align = "center" >
< img src = "images/delete.gif" title = "Este registro possui depend<EFBFBD> ncias e n<EFBFBD> o pode ser exclu<EFBFBD> do!" alt = "Este registro n<EFBFBD> o pode ser exclu<EFBFBD> do!" width = "16" height = "16" border = "0" >
< / div >
< / td >
<?php } ?>
< / tr >
< / table >
< / td >
< / tr >
<?php
$z++;
}
if ($z == 0) {
?>
< tr align = "center" valign = "middle" bordercolor = "#999999" class = "labels" >
< td colspan = "6" >
< 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 >
<?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 >