PABX da Simples IP
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.
 
 
 
 
 
 

152 lines
5.5 KiB

<?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];
$org_id = $_SESSION['SSEmpresaPadrao'];
$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 dac.org_id = $org_id
AND bil.org_id = dac.org_id
AND reg.org_id = dac.org_id
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 dac.org_id = $org_id
AND bil.org_id = dac.org_id
AND reg.org_id = dac.org_id
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);
}
?>