|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
include_once 'funcoesFormulario.php';
|
|
|
|
|
$param = '';
|
|
|
|
|
$erro = '';
|
|
|
|
|
// echo VerificaAgenteLogadoAstrisk('elvis') ? 'Deslogado' : 'Logado';
|
|
|
|
|
$janW = 500;
|
|
|
|
|
$janH = 285;
|
|
|
|
|
$tpl = 'discador/campanhaContatoStatus.tpl';
|
|
|
|
|
$acao = isset($_REQUEST["acao"]) ? trim($_REQUEST["acao"]) : 'select';
|
|
|
|
|
$paramPesquisa = isset($_REQUEST['paramPesquisa']) ? $_REQUEST['paramPesquisa'] : '';
|
|
|
|
|
$filtro = isset($_REQUEST["paramPesquisa"]) ? trim($_REQUEST["paramPesquisa"]) : '';
|
|
|
|
|
$filtroNovo = !isset($_REQUEST["pgn"]) ? '' : sprintf("¶mPesquisa%s&pgn=%s&bloco=%s&pg=%s", $_REQUEST["paramPesquisa"], $_REQUEST["pgn"], $_REQUEST["bloco"], $_REQUEST["pg"]);
|
|
|
|
|
$recontaPag = ($acao == 'novo') || ($acao == 'apagar') || ($acao == 'ativar') || isset($_POST['pesquisa']);
|
|
|
|
|
|
|
|
|
|
$imgNovo = "<img src=\"images/novo.gif\" width=\"16\" height=\"16\" border=\"0\" title=\"Inclui novo usu<EFBFBD>rio\">";
|
|
|
|
|
$imgNovo = "<a href=\"javaScript:NovaJanela('index.php?idProg=22&idUser=0', 'usuarioCad', '$janW', '$janH', 'resizable=NO,scrollbars=NO');\">$imgNovo</a>";
|
|
|
|
|
|
|
|
|
|
if ($acao) {
|
|
|
|
|
if (($acao == 'apagar') || ($acao == 'ativar')) {
|
|
|
|
|
$id = $_GET["ctst_id"];
|
|
|
|
|
|
|
|
|
|
if ($id) {
|
|
|
|
|
$apaga = false;
|
|
|
|
|
if ($acao == 'apagar') {
|
|
|
|
|
$query = "select case when( exists(select '' from pbx_campanha_contato where cont_status = '$id') or exists(select '' from pbx_campanha_contato_fone where conf_status = '$id'))then 1 else 0 end as existe";
|
|
|
|
|
$result = pg_query($dbcon, $query);
|
|
|
|
|
$dados = @pg_fetch_array($result);
|
|
|
|
|
$apaga = $dados['existe'] == 0;
|
|
|
|
|
}
|
|
|
|
|
$status = ($acao == 'ativar') ? 1 : 0;
|
|
|
|
|
$query = "update pbx_campanha_contato_status set ctst_status = '$status' where ctst_id = $id";
|
|
|
|
|
if ($apaga) {
|
|
|
|
|
$query = "delete from pbx_campanha_contato_status where ctst_id = $id";
|
|
|
|
|
}
|
|
|
|
|
$result = @pg_query($dbcon, $query);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($result) {
|
|
|
|
|
$msg = "Opera<EFBFBD><EFBFBD>o realizada com sucesso!";
|
|
|
|
|
} else {
|
|
|
|
|
$msg = "A opera<EFBFBD><EFBFBD>o n<EFBFBD>o pode ser realizada!";
|
|
|
|
|
}
|
|
|
|
|
$jsStartup[] = sprintf("alert('%s');", $msg);
|
|
|
|
|
} else if ($acao == 'novo') {
|
|
|
|
|
$status = QuotedStr(strtoupper(trim($_GET['status'])));
|
|
|
|
|
$query = "select '' from pbx_campanha_contato_status where upper(ctst_nome) = $status";
|
|
|
|
|
$result = pg_query($dbcon, $query);
|
|
|
|
|
if (pg_num_rows($result)) {
|
|
|
|
|
$msg = "Status j<EFBFBD> cadastrado!";
|
|
|
|
|
} else {
|
|
|
|
|
$query = "select max(ctst_id) from pbx_campanha_contato_status";
|
|
|
|
|
$result = pg_query($dbcon, $query);
|
|
|
|
|
$dados = @pg_fetch_array($result);
|
|
|
|
|
$id = $dados[0] + 1;
|
|
|
|
|
$query = "insert into pbx_campanha_contato_status(ctst_id, ctst_nome, ctst_status) values($id, $status, 1);";
|
|
|
|
|
$result = @pg_query($dbcon, $query);
|
|
|
|
|
|
|
|
|
|
if ($result) {
|
|
|
|
|
$msg = "Opera<EFBFBD><EFBFBD>o realizada com sucesso!";
|
|
|
|
|
} else {
|
|
|
|
|
$msg = "A opera<EFBFBD><EFBFBD>o n<EFBFBD>o pode ser realizada!";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$jsStartup[] = sprintf("alert('%s');", $msg);
|
|
|
|
|
} else if ($acao == 'update') {
|
|
|
|
|
$id = $_GET["ctst_id"];
|
|
|
|
|
$status = QuotedStr(trim($_GET['status']));
|
|
|
|
|
$query = "update pbx_campanha_contato_status set ctst_nome = $status where ctst_id = '$id'";
|
|
|
|
|
$result = @pg_query($dbcon, $query);
|
|
|
|
|
|
|
|
|
|
if ($result) {
|
|
|
|
|
$msg = "Opera<EFBFBD><EFBFBD>o realizada com sucesso!";
|
|
|
|
|
} else {
|
|
|
|
|
$msg = "A opera<EFBFBD><EFBFBD>o n<EFBFBD>o pode ser realizada!";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$jsStartup[] = sprintf("alert('%s');", $msg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$compl = '';
|
|
|
|
|
if (isset($_REQUEST['paramPesquisa']) && $_REQUEST['paramPesquisa']) {
|
|
|
|
|
$compl = PreparaLike($filtro, true);
|
|
|
|
|
$compl = sprintf("and (a.ctst_nome ilike %s)", $compl);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$query = "select ctst_id, ctst_nome, ctst_status from pbx_campanha_contato_status a where ctst_status <> 2 $compl order by 1";
|
|
|
|
|
$params = "¶mPesquisa=$filtro";
|
|
|
|
|
$links = PaginaDados($idProg, $query, $params, $regPagina, $offSet, $pagMostra, true);
|
|
|
|
|
$query .= " limit $regPagina offset $offSet";
|
|
|
|
|
$result = pg_query($dbcon, $query);
|
|
|
|
|
|
|
|
|
|
$linha = "";
|
|
|
|
|
while ($dados = @pg_fetch_array($result)) {
|
|
|
|
|
|
|
|
|
|
$ctst_id = $dados["ctst_id"];
|
|
|
|
|
$ctst_nome = $dados["ctst_nome"];
|
|
|
|
|
$ctst_status = $dados["ctst_status"];
|
|
|
|
|
|
|
|
|
|
$imgEdit = "<img src=\"imgSite/editaUser.png\" width=\"16\" height=\"16\" border=\"0\" title=\"Edita o registro: $ctst_nome\" onclick=\"ContatoStatusAtualiza('$ctst_id', '$ctst_nome', '$params');\">";
|
|
|
|
|
$nomeMostra = "<a href=# style=\"color: #000;\" title=\"Edita o registro: $ctst_nome\" onclick=\"ContatoStatusAtualiza('$ctst_id', '$ctst_nome', '$params');\">$ctst_nome</a>";
|
|
|
|
|
$imgDelete = $ctst_status ? "<img src=\"imgSite/deletaUser.png\" width=\"16\" height=\"16\" border=\"0\" title=\"Apaga o Stastus: $ctst_nome\" onclick=\"DeletaCadastro('274', '&ctst_id=$ctst_id$params', '$ctst_nome');\">" :
|
|
|
|
|
"<img src=\"imgSite/volta16.gif\" width=\"16\" height=\"16\" border=\"0\" title=\"Ativa o Stastus: $ctst_nome\" onclick=\"AtivaCadastro('274', '&ctst_id=$ctst_id$params', '$ctst_nome');\">";
|
|
|
|
|
// $delete = "<a href=\"index.php?idProg=274&idDelete=$ctst_id\">" . $imgDelete . "</a>";
|
|
|
|
|
$imgStatus = sprintf("<img src=\"imgSite/%s\" width=\"12\" height=\"12\ border=\"0\">", ($ctst_status ? 'ok16.gif' : 'fecha16.png'));
|
|
|
|
|
$linha .= " <tr>
|
|
|
|
|
<td width=\"50\" align=\"center\">$ctst_id</td>
|
|
|
|
|
<td align=\"left\" nowrap>$nomeMostra</td>
|
|
|
|
|
<td align=\"center\" width=\"18\">$imgStatus</td>
|
|
|
|
|
<td align=\"center\" width=\"40\">$imgDelete $imgEdit</td>
|
|
|
|
|
</tr>";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$imgNovo = "<img src=\"images/novo.gif\" width=\"16\" height=\"16\" border=\"0\" title=\"Inclui novo usu<EFBFBD>rio\" align=\"absmiddle\">";
|
|
|
|
|
$imgNovo = "<a href=\"#\" onclick=\"ContatoStatusNovo('$filtroNovo');\">$imgNovo Novo Status</a>";
|
|
|
|
|
//<img src="imgSite/novoUser.png" width="16" height="16" border="0" title="Inclui novo Status" onclick="ContatoStatusNovo();" align="absbottom">
|
|
|
|
|
$semResult = "<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>";
|
|
|
|
|
|
|
|
|
|
$smarty->assign('erro', $msg);
|
|
|
|
|
$smarty->assign("linhas", $linha ? $linha : $semResult);
|
|
|
|
|
$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);
|
|
|
|
|
?>
|