"; $data_reg = date('d/m/Y H:i:s', strtotime($value['data_reg'])); $linha .= sprintf(" %s {$value['src']} {$value['dst']} %s {$value['apelido']} {$value['userfield']} %s {$audio} ", 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 : "Nenhum registro encontrado!"); $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ÃO ATENDIDA"; } } ?>