|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* To change this template, choose Tools | Templates
|
|
|
|
|
* and open the template in the editor.
|
|
|
|
|
*/
|
|
|
|
|
$tpLayout = 1;
|
|
|
|
|
$matricula = GetMatricula();
|
|
|
|
|
$consultar = isset($_POST["btPesquisa"]);
|
|
|
|
|
$valida = isset($_POST["btAnota"]) && (trim($_POST["AnotaTexto"]) != "");
|
|
|
|
|
$agtAnota = isset($_POST["AnotaTexto"]) ? $_POST["AnotaTexto"] : "";
|
|
|
|
|
$agtFone = isset($_POST["AnotaFone"]) ? soNumero($_POST["AnotaFone"]) : (isset($_SESSION[RAMAL_DESTINO]) ? soNumero($_SESSION[RAMAL_DESTINO]) : '');
|
|
|
|
|
$btAnota = isset($_POST["btAnota"]) ? $_POST["btAnota"] : "";
|
|
|
|
|
$listaAgente = isset($_POST["listaAgente"]) ? $_POST["listaAgente"] : GetMatricula();
|
|
|
|
|
$dataIni = !isset($_POST["dataIni"]) ? date('d/m/Y') : $_POST["dataIni"];
|
|
|
|
|
$dataFim = !isset($_POST["dataFim"]) ? date('d/m/Y') : $_POST["dataFim"];
|
|
|
|
|
|
|
|
|
|
$msg = "";
|
|
|
|
|
$pesquisa = "";
|
|
|
|
|
|
|
|
|
|
if (isset($_GET["formAction"])) {
|
|
|
|
|
$idDel = $_GET["id"];
|
|
|
|
|
$query = "delete from pbx_anotacoes where id_text = '$idDel'";
|
|
|
|
|
@pg_query($dbcon, $query);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!is_date($dataIni)) {
|
|
|
|
|
$jsStartup[] = "alert('Data inicial inv<EFBFBD>lida!');";
|
|
|
|
|
$msg = "Data inicial inv<EFBFBD>lida!";
|
|
|
|
|
$isValid = 0;
|
|
|
|
|
} else if (!is_date($dataFim)) {
|
|
|
|
|
$jsStartup[] = "alert('Data final inv<EFBFBD>lida!');";
|
|
|
|
|
$msg = "Data final inv<EFBFBD>lida!";
|
|
|
|
|
$isValid = 0;
|
|
|
|
|
} else if (!$consultar && $valida && empty($agtFone)) {
|
|
|
|
|
$msg = GetAnotacoesKey() ? "Informe o n<EFBFBD>mero do telefone!" : "Informe o n<EFBFBD>mero do protocolo!";
|
|
|
|
|
} else if ($valida && empty($agtAnota)) {
|
|
|
|
|
$msg = "Insira uma anota<EFBFBD><EFBFBD>o!";
|
|
|
|
|
} else if (!$consultar && $valida) {
|
|
|
|
|
$query = "insert into pbx_anotacoes(conteudo, matricula_agente, fone_cliente)
|
|
|
|
|
values('$agtAnota', '$matricula', '$agtFone')";
|
|
|
|
|
$result = pg_query($dbcon, $query);
|
|
|
|
|
if ($result) {
|
|
|
|
|
$agtAnota = "";
|
|
|
|
|
$msg = "Opera<EFBFBD><EFBFBD>o realizada com sucesso!";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$pesquisa = PesquisaFone($dbcon, $agtFone);
|
|
|
|
|
if (empty($pesquisa))
|
|
|
|
|
$pesquisa = "<tr><td colspan=4>Nenhum registro encontrado!</td></tr>";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$cor = !$msg || stripos($msg, 'sucesso') ? '#0000FF' : '#FF0000';
|
|
|
|
|
$smarty->assign("AnotaFone", $agtFone);
|
|
|
|
|
$smarty->assign("AnotaTexto", $agtAnota);
|
|
|
|
|
$smarty->assign("corErro", $cor);
|
|
|
|
|
$smarty->assign("msg", $msg);
|
|
|
|
|
$smarty->assign("linhas", $pesquisa);
|
|
|
|
|
$smarty->assign("isFone", GetAnotacoesKey());
|
|
|
|
|
$smarty->assign("isSuper", IsSuper());
|
|
|
|
|
$smarty->assign("dataIni", $dataIni);
|
|
|
|
|
$smarty->assign("dataFim", $dataFim);
|
|
|
|
|
$smarty->assign("prm_label_protoco_pesquisa", $_SESSION['prm_label_protoco_pesquisa']);
|
|
|
|
|
$smarty->assign("prm_label_protoco_texto", $_SESSION['prm_label_protoco_texto']);
|
|
|
|
|
$smarty->assign("prm_label_protoco_grid", $_SESSION['prm_label_protoco_grid']);
|
|
|
|
|
if (IsSuper()) {
|
|
|
|
|
$agentes = GetAgentesAnotacoes($listaAgente);
|
|
|
|
|
$smarty->assign("listaAgente", $agentes);
|
|
|
|
|
}
|
|
|
|
|
DispLogin($smarty);
|
|
|
|
|
|
|
|
|
|
function PesquisaFone($db, $num) {
|
|
|
|
|
global $listaAgente, $dataIni, $dataFim;
|
|
|
|
|
$mat = IsSuper() ? $listaAgente : GetMatricula();
|
|
|
|
|
$query = "select a.id_text, a.conteudo, a.matricula_agente, a.fone_cliente, a.data, b.apelido from pbx_anotacoes a, pbx_usuarios b where b.matricula = a.matricula_agente::text ";
|
|
|
|
|
$query .= $mat ? " and a.matricula_agente::text = '$mat' " : "";
|
|
|
|
|
$query .= sprintf(" and data::date >= %s and data::date <= %s ", FormatDtMssql($dataIni, true), FormatDtMssql($dataFim, true));
|
|
|
|
|
$query .= " and fone_cliente like '%" . $num . "%'";
|
|
|
|
|
$query .= " order by b.apelido, a.data desc";
|
|
|
|
|
|
|
|
|
|
$result = @pg_query($db, $query);
|
|
|
|
|
//if(IsAdmin()) echo $query;
|
|
|
|
|
while (($result) && ($row = pg_fetch_array($result))) {
|
|
|
|
|
$fone = GetAnotacoesKey() ? FormataFone($row["fone_cliente"]) : $row["fone_cliente"];
|
|
|
|
|
$content = $row["conteudo"];
|
|
|
|
|
$matAgt = $row["matricula_agente"] . '-' . $row["apelido"];
|
|
|
|
|
$data = date('d/m/Y', strtotime($row["data"]));
|
|
|
|
|
$imgDel = GetLinkFormDelete($row["id_text"], 'DeletaAnotacao');
|
|
|
|
|
$linha .= "<tr>
|
|
|
|
|
<td align=left>$data</td>";
|
|
|
|
|
if (IsSuper()) {
|
|
|
|
|
$linha .= " <td align=left>$matAgt</td>";
|
|
|
|
|
}
|
|
|
|
|
$linha .= " <td align=left>$fone</td>
|
|
|
|
|
<td align=left>$content</td>
|
|
|
|
|
<td align=center>$imgDel</td>
|
|
|
|
|
</tr>";
|
|
|
|
|
}
|
|
|
|
|
$colspan = IsSuper() ? 4 : 3;
|
|
|
|
|
if (empty($linha))
|
|
|
|
|
$linha = "<tr><td colspan=\"$colspan\">Nenhum registro encontrado!</td></tr>";
|
|
|
|
|
|
|
|
|
|
return $linha;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function DispLogin($smarty) {
|
|
|
|
|
$smarty->display('callcenter/agente/agenteAnota.tpl');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function GetAgentesAnotacoes($matricula) {
|
|
|
|
|
$query = "select id, apelido, nome, matricula from pbx_usuarios where delete_ = 0 and apelido not in('sinccontasenha' )"; //'admin',
|
|
|
|
|
$result = pg_query($query);
|
|
|
|
|
$sel = $matricula == "0" ? ' Selected="selected" ' : '';
|
|
|
|
|
$item = "<option value=\"0\"$sel>Todos</option>\n";
|
|
|
|
|
while ($dados = pg_fetch_array($result, null, PGSQL_ASSOC)) {
|
|
|
|
|
$mat = $dados['matricula'];
|
|
|
|
|
$apelido = $dados['apelido'];
|
|
|
|
|
$sel = $mat == $matricula ? ' Selected="selected" ' : '';
|
|
|
|
|
$item .= "<option value=\"$mat\"$sel>$apelido-[$mat]</option>\n";
|
|
|
|
|
}
|
|
|
|
|
return $item;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
?>
|