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.
 
 
 
 
 
 

76 lines
3.2 KiB

<?php
$client = isset($_REQUEST['client_id']) ? $_REQUEST['client_id'] : '';
$nome_cliente = isset($_REQUEST['n']) ? base64_decode($_REQUEST['n']) : '';
$tpLayout = 1;
try {
$cliente = GetAudioCliente($dbcon, $client);
foreach ($cliente as $value) {
$url = "http://{$_SERVER['SERVER_ADDR']}/integracao?method=GetAudio&login=user.api&senha=0000&uniqueid={$value["uniqueid"]}&tipo=mp3&tipoRetorno=JSON/STREAM";
$audio = "<audio controls preload='none' controlsList=\"download\" reconnect src=\"$url\"></audio>";
$data_reg = date('d/m/Y H:i:s', strtotime($value['data_reg']));
$linha .= sprintf("<tr>
<td align='center'>%s</td>
<td align='center'>{$value['src']}</td>
<td align='center'>{$value['dst']}</td>
<td align='center'>%s</td>
<td align='center'>{$value['apelido']}</td>
<td align='center'>{$value['userfield']}</td>
<td align='center'>%s</td>
<td align='center'>{$audio}</td>
</tr>", date('d/m/Y H:i:s', strtotime($value['calldate'])), SecondToStrTime($value['billsec']), tipoEncerramento($value['evento']));
$numReg++;
}
$color = 'green';
} catch (Exception $ex) {
$message = $ex->getMessage();
$color = 'red';
}
$smarty->assign("linhas", $linha ? $linha : "<td colspan='15' align='center'><b>Nenhum registro encontrado!</b></td>");
$smarty->assign("nome_cliente", $nome_cliente);
$smarty->assign("client_id", $cliente['client_id']);
$smarty->assign("contato", ($action == 'edit' ? GetContatoPorId($dbcon, $contato) : ''));
$smarty->assign("color", $color);
$smarty->assign("msgErro", $message);
GetTemplate($smarty, 'cadastros/cliente/clienteAudio.tpl');
/**
* Busca o cliente pelo seu ID.
* @param type $dbcon
* @param type $cliente
* @return type
*/
function GetAudioCliente($dbcon, $cliente) {
$query = "SELECT uniqueid, client_id, calldate, src, dst, apelido, userfield, billsec, evento, data_reg
FROM pbx_bilhetes a
INNER JOIN pbx_cliente_audio b ON a.uniqueid = b.uid
INNER JOIN pbx_eventos_dacs c ON c.uid2 = a.uniqueid
INNER JOIN pbx_usuarios d ON d.matricula = SUBSTRING(c.agente,7,4)
WHERE b.client_id = '{$cliente}'
AND evento IN('COMPLETAAGENT','COMPLETACALLER', 'TRANSFERORIG','BUSYS','NOANSWERS')
ORDER BY calldate;";
$result = pg_query($dbcon, $query);
$rows = pg_fetch_all($result);
return $rows;
}
function tipoEncerramento($evento) {
switch ($evento) {
case 'COMPLETAAGENT':
case 'COMPLETACALLER':
return "ATENDIDA";
case 'TRANSFERORIG':
return "TRANSFERIDA";
case 'BUSYS':
return "OCUPADA";
case 'NOANSWERS':
return "N<EFBFBD>O ATENDIDA";
}
}
?>