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.
217 lines
11 KiB
217 lines
11 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 (isset($_GET["audioIndisp"]) && $_GET["audioIndisp"]) { |
|
$fileExist = 0; |
|
$fileDisp = $_GET["audioIndisp"]; |
|
$filepath = ($path_som) . GetDirArqSom($dbcon) . $_GET["audioIndisp"]; |
|
$fileExist = @file_exists($filepath); |
|
|
|
if (!$fileExist) { |
|
$jsStartup[] = "alert('Arquivo não encontrado!');"; |
|
} else { |
|
ob_clean(); |
|
header("Pragma: public"); |
|
header('Cache-Control: no-cache, must-revalidate'); |
|
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
|
//header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime( $filepath )) . ' GMT'); |
|
header('Accept-Ranges: bytes'); |
|
header('Content-Type: ' . GetMimeContentType($fileDisp)); |
|
header('Content-Disposition: attachment; filename="' . $fileDisp . '";'); |
|
header('Content-Transfer-Encoding: binary'); |
|
header('Content-Length: ' . filesize($filepath)); |
|
header('Connection: close'); |
|
readfile($filepath); |
|
exit; |
|
} |
|
} |
|
if ($acao == 'deleta') { |
|
try { |
|
$inTran = 0; |
|
/* |
|
* Consulta o caminho dos arquivos. |
|
*/ |
|
$query = "select arq_path_origem, arq_path_destino from pbx_arquivo_som where arq_id = '$id'"; |
|
$result = pg_query($dbcon, $query); |
|
if (!$result) { |
|
GeraExcept("Erro ao consultar arquivo!"); |
|
} |
|
if (!pg_num_rows($result)) { |
|
GeraExcept("Arquivo não encontrado!"); |
|
} |
|
$dados = pg_fetch_array($result); |
|
$origem = $dados['arq_path_origem']; |
|
$destino = $dados['arq_path_destino']; |
|
|
|
/* |
|
* Verifica as dependencias do arquivo. |
|
*/ |
|
$nome = basename($destino); |
|
$query = "select tipo from pbx_lista_arquivo_som where arq_som = '$nome'"; |
|
$result = pg_query($dbcon, $query); |
|
if (!$result) { |
|
GeraExcept("Erro ao verificar as dependência do arquivo!"); |
|
} |
|
if (pg_num_rows($result)) { |
|
GeraExcept("Arquivo não pode ser excluido porque esta sendo utilizado!"); |
|
} |
|
|
|
/* |
|
* Apaga os arquivos. |
|
*/ |
|
$result = pg_query($dbcon, 'begin'); |
|
if (!$result) { |
|
GeraExcept("Erro ao iniciar a operação!"); |
|
} |
|
$inTran++; |
|
|
|
$result = pg_query($dbcon, "delete from pbx_arquivo_som where arq_id = '$id'"); |
|
if (!$result) { |
|
GeraExcept("Erro ao excluir o arquivo no banco de dados!"); |
|
} |
|
|
|
vai_comando("/bin/rm -Rf {$origem}", $dbcon); |
|
unlink($destino); |
|
if (file_exists($destino) && file_exists($origem)) { |
|
GeraExcept("Erro ao excluir o arquivo!"); |
|
} |
|
|
|
$result = pg_query($dbcon, 'commit'); |
|
if (!$result) { |
|
GeraExcept("Erro ao finalizar a operação!"); |
|
} |
|
|
|
Alert("Arquivo excluido com sucesso!"); |
|
} catch (Exception $ex) { |
|
if ($inTran) |
|
@pg_query('rollback'); |
|
Alert($ex->getMessage()); |
|
} |
|
} |
|
?> |
|
<table width="99%" align="center" border="0" cellpadding="2" cellspacing="0" class="filtro"> |
|
<tr> |
|
<td colspan="2">Ramal/Bina</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=10043&pbxRequest=1', event);" size="20"> |
|
<input name="locaRamal" type="button" id="locaRamal" value="Localizar" onClick="ConsultaRamal('index.php?idProg=10043&pbxRequest=1&pesquisa=1', 0);"> |
|
</td> |
|
<td align="right" nowrap="nowrap" > |
|
<a href="#" onClick="abre_janela('475', '232', 'index.php?idProg=11043&pbxRequest=1<?php echo $filtroNovo; ?>');"><img src="images/novo.gif" width="20" height="20" border="0" align="absmiddle">NOVO ARQUIVO </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 align="center" width="50">Data</th> |
|
<th align="center" width="200">Nome</th> |
|
<th align="center" width="200">Sistema </th> |
|
<th align="center">Descrição</th> |
|
<th align="right" width="50">Tamanho</th> |
|
<th align="center">Ações</th> |
|
</tr> |
|
<?php |
|
$compl = ''; |
|
if (isset($_GET['pesquisa']) && $_GET['pesquisa']) { |
|
$compl = PreparaLike($filtro, true); |
|
$compl = sprintf("and (a.arq_nome ilike %s or a.arq_descricao ilike %s)", $compl, $compl); |
|
} |
|
|
|
$query = "select arq_id, arq_data, arq_nome, arq_nome_sistema, arq_descricao, arq_orig_tamanho, arq_dest_tamanho " |
|
. " from pbx_arquivo_som a" |
|
. " where 1=1 $compl order by arq_id"; |
|
//echo $query; |
|
$params = "&pbxRequest=1&numRamal=$filtro"; |
|
$links = PaginaDados($idProg, $query, $params, $regPagina, $offSet, $pagMostra, true); |
|
$query .= " limit $regPagina offset $offSet"; |
|
$result = pg_query($dbcon, $query); |
|
while ($dados = pg_fetch_array($result)) { |
|
$id = $dados['arq_id']; |
|
$data = FormataDBDataHora($dados['arq_data']); |
|
$nome = basename($dados['arq_nome'], ".mp3"); |
|
$nomeSis = $dados['arq_nome_sistema']; |
|
$descricao = $dados['arq_descricao']; |
|
$tamOrig = ConvertSize($dados['arq_orig_tamanho']); |
|
$tamDest = ConvertSize($dados['arq_dest_tamanho']); |
|
?> |
|
<tr> |
|
<td align="center"><?php echo $id; ?></td> |
|
<td align="center"><?php echo $data; ?></td> |
|
<td align="left"><?php echo $nome; ?></td> |
|
<td align="left"><?php echo $nomeSis; ?></td> |
|
<td align="left"><?php echo $descricao; ?></td> |
|
<td align="right"><?php echo $tamDest; ?></td> |
|
<td width="40"> |
|
<table width="100%" border="0" cellpadding="3" cellspacing="0" bordercolor="#EAEAEA"> |
|
<tr> |
|
<td style="border:0"><div align="center"><a href="#" onclick="excluir('', '<?php echo $file; ?>', 'DESEJA REALMENTE EXLUIR O ARQUIVO:<?php echo $file; ?>', 'index.php?idProg=10043&pbxRequest=1&acao=deleta&id=<?php echo $id; ?><?php echo $params; ?>', 'ANUNCIOS');"><img src="images/delete.gif" alt="EDITAR O RAMAL:<?php echo $dados['nome']; ?>" width="16" height="16" border="0" /></a></div> <div align="center"></div></td> |
|
<td style="border:0"><a href="index.php?idProg=10043&pbxRequest=1&audioIndisp=<?php echo $nomeSis . ".mp3"; ?>"><img src="imgSite/sound22.png" alt="Arquivo de Som!" width="16" height="16" border="0" align="absmiddle" /></a></td> |
|
</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> |
|
|
|
|
|
<div id="mensagem" style="display:none;width:300;height:auto"> |
|
|
|
<table width="100%" border="0" cellpadding="0" cellspacing="0"> |
|
<tr bordercolor="#FFFFFF" bgcolor="#FFFFFF" style="border-color:#FFFFFF;background-image:'utils/m2brbgtitulo.jpg'" > |
|
<td width="5%" align="center" style="border: none;font-family: Arial, Helvetica, sans-serif;font-size: 16px;color: #990000;background-color: #FFFFFF;"> |
|
</td> |
|
<td width="95%" align="center" bgcolor="#FFFFFF" style="border: none;font-family: Arial, Helvetica, sans-serif;font-size: 16px;color: #990000;background-color: #FFFFFF;"><div align="center"> |
|
<input name="mens" type="button" value="mens" style="border: none;font-family: Arial, Helvetica, sans-serif;font-size: 14px;color: #990000;background-color: #FFFFFF;" id="mens"> |
|
</div></td> |
|
</tr> |
|
<tr bordercolor="#FFFFFF" bgcolor="#FFFFFF" style="border-color:#FFFFFF"> |
|
<td colspan="2" align="center" bordercolor="#FFFFFF" bgcolor="#FFFFFF" style="border-color:#FFFFFF"><span style="color: #FFFFFF"> _ |
|
</span></td> |
|
</tr> |
|
<tr bordercolor="#FFFFFF" bgcolor="#FFFFFF" style="border-color:#FFFFFF"> |
|
<td colspan="2" bordercolor="#FFFFFF" bgcolor="#FFFFFF" style="border-color:#FFFFFF"> |
|
<table width="100%" border="0" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF" style="border-color:#FFFFFF"> |
|
<tr> |
|
<td width="50%" align="center" bordercolor="#FFFFFF" bgcolor="#FFFFFF" style="border-color:#FFFFFF"> |
|
<div align="center"> |
|
<button id="todos" class="botoes">Sim</button> |
|
</div> |
|
</td> |
|
<td width="50%" align="center" bordercolor="#FFFFFF" bgcolor="#FFFFFF" style="border-color:#FFFFFF"> |
|
<div align="center"> <button id="cancela" class="botoes">Não</button> |
|
</div> |
|
</td> |
|
</tr> |
|
</table></td> |
|
</tr> |
|
</table></div> |
|
</div> |
|
</div> |
|
</body> |
|
</html>
|
|
|