|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
$acao = isset($_GET["acao"]) ? strtoupper(trim($_GET["acao"])) : '';
|
|
|
|
|
$ramal = isset($_GET["ramal"]) ? trim($_GET["ramal"]) : '';
|
|
|
|
|
$numero = isset($_GET["numero"]) ? trim($_GET["numero"]) : '';
|
|
|
|
|
$tpLayout = 1;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
if ($acao == "DISCARDIRETO" && IsAjax()) {
|
|
|
|
|
___GetDiscarDireto($ramal, $numero);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$result = ___GetData($dbcon);
|
|
|
|
|
$linha = ___GetGrid($result, $ramal);
|
|
|
|
|
|
|
|
|
|
} catch (Exception $ex) {
|
|
|
|
|
$mensagem = $ex->getMessage();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$smarty->assign("linhas", $linha);
|
|
|
|
|
$smarty->assign("msg", $mensagem);
|
|
|
|
|
$smarty->display('callcenter/agente/agenteHistorico.tpl');
|
|
|
|
|
|
|
|
|
|
function ___GetGrid($result, $ramal) {
|
|
|
|
|
$numrow = 0;
|
|
|
|
|
$linha = "";
|
|
|
|
|
|
|
|
|
|
while ($row = pg_fetch_array($result)) {
|
|
|
|
|
$fone = FormataFone($row["clid"]);
|
|
|
|
|
$data = date('d/m/Y', strtotime($row["calldate"]));
|
|
|
|
|
$hora = date('H:i:s', strtotime($row["calldate"]));
|
|
|
|
|
$horaAtend = date('H:i:s', strtotime($row["data_atend"]));
|
|
|
|
|
$dura = SecondToStrTime($row["duracao"]);
|
|
|
|
|
$proto = $row["protocolo"];
|
|
|
|
|
$proto = substr($proto, 0, 4) . "-" . substr($proto, 4, (strlen($proto) - 4));
|
|
|
|
|
$img1 = ($row["direcao"] == 'E') ? "direcaoE32.png" : "direcaoS32.png";
|
|
|
|
|
$title1 = ($row["direcao"] == 'E') ? "Chamada Entrante!" : "Chamada Sainte!";
|
|
|
|
|
$direcao = " <img src=\"imgSite/$img1\" width=\"12\" border=\"0\" height=\"12\" title=\"$title1\" alt=\"$title1\" align=\"absmiddle\">";
|
|
|
|
|
|
|
|
|
|
$numFone = soNumero($row["clid"]);
|
|
|
|
|
$acao = "<img src=\"imgSite/ramalOn16.png\" border=\"0\" width=\"20\" height=\"20\" alt=\"Retornar Chamada!\" title=\"Retornar Chamada!\">";
|
|
|
|
|
$linkRamal = "<a href=\"javaScript:DiscarDiretoRet('$numFone','$ramal');\">$acao</a>";
|
|
|
|
|
|
|
|
|
|
$linha .= sprintf("<tr>
|
|
|
|
|
<td align=center>$data</td>
|
|
|
|
|
<td align=center>$hora</td>
|
|
|
|
|
<td align=center>$horaAtend</td>
|
|
|
|
|
<td align=center>%s</td>
|
|
|
|
|
<td align=center>$dura</td>
|
|
|
|
|
<td align=center>$proto</td>
|
|
|
|
|
<td align=center>$direcao</td>
|
|
|
|
|
<td align=center>$linkRamal</td>
|
|
|
|
|
</tr>", ocultarTelefone($fone));
|
|
|
|
|
$numrow++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$linha .= " <trs align=\"center\">
|
|
|
|
|
<th nowrap align=\"left\" colspan=\"8\" >Total</th>
|
|
|
|
|
<th nowrap class=\"headData\">$numrow</th>
|
|
|
|
|
</tr>";
|
|
|
|
|
|
|
|
|
|
return $linha;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function ___GetData($dbcon) {
|
|
|
|
|
$matricula = GetMatricula();
|
|
|
|
|
$dac = $_SESSION[AGT_DAC_CONECT_DESC];
|
|
|
|
|
|
|
|
|
|
$query = "Select bil.calldate, src as clid, dac.param2 as duracao, protocolo, to_timestamp(uid1::float) as data_atend, 'E' as direcao
|
|
|
|
|
from ast_eventos_dacs dac, ast_bilhetes bil, pbx_protocolo_reg reg
|
|
|
|
|
where bil.uniqueid = dac.uid2
|
|
|
|
|
and reg.uniqueid = bil.uniqueid
|
|
|
|
|
and bil.data_bilhete = cast(now() as date)
|
|
|
|
|
and substring(dac.agente, 7,4) = '$matricula'
|
|
|
|
|
and dac.fila = '$dac'
|
|
|
|
|
and dac.evento in('COMPLETEAGENT', 'COMPLETECALLER', 'COMPLETECALLERRAMAL', 'TRANSFER', 'COMPLETECALLERRAMAL')
|
|
|
|
|
and bil.lastapp <> 'Transferred Call'
|
|
|
|
|
union all
|
|
|
|
|
Select bil.calldate, dst as clid, dac.param2 as duracao, protocolo, bil.calldate as data_atend, 'S' as direcao
|
|
|
|
|
from ast_eventos_dacs dac, ast_bilhetes bil, pbx_protocolo_reg reg
|
|
|
|
|
where bil.uniqueid = dac.uid2
|
|
|
|
|
and reg.uniqueid = bil.uniqueid
|
|
|
|
|
and bil.data_bilhete = cast(now() as date)
|
|
|
|
|
and substring(dac.agente, 7,4) = '$matricula'
|
|
|
|
|
and dac.fila = '$dac'
|
|
|
|
|
and dac.evento in('COMPLETAAGENT','COMPLETACALLER','TRANSFERORIG','BUSYS','NOANSWERS')
|
|
|
|
|
and bil.lastapp <> 'Transferred Call' order by 1, 4";
|
|
|
|
|
//if(IsAdmin()) echo $query;
|
|
|
|
|
$result = pg_query($dbcon, $query);
|
|
|
|
|
|
|
|
|
|
if (!$result) {
|
|
|
|
|
throw new Exception('N<EFBFBD>o foi poss<EFBFBD>vel encontrar nenhum registro!');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function ___GetDiscarDireto($ramal, $numero) {
|
|
|
|
|
$servidorApi = "127.0.0.1";
|
|
|
|
|
$userApi = "sinccontasenha";
|
|
|
|
|
$senhaApi = "s3ncC0nt@S2nh@";
|
|
|
|
|
|
|
|
|
|
$url = "http://$servidorApi/integracao?method=DiscarDireto&numeroDiscar=$numero&ramal=$ramal&login=$userApi&senha=$senhaApi&tipoRetorno=XML";
|
|
|
|
|
$xml = simplexml_load_string(GetApi($url));
|
|
|
|
|
$ret = trim(strval($xml->result));
|
|
|
|
|
|
|
|
|
|
if ($ret != "true") {
|
|
|
|
|
throw new Exception("N<EFBFBD>o foi poss<EFBFBD>vel realizar a chamada!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
echo "OK";
|
|
|
|
|
|
|
|
|
|
exit(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
?>
|