forked from SimplesIP/pabx-app
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.
641 lines
27 KiB
641 lines
27 KiB
<?php |
|
/*************************************************************************** |
|
* |
|
* PBX Detalhamento Chamada |
|
* Autor |
|
* Lucas Awade |
|
* |
|
* ************************************************************************* |
|
Definições do Projeto |
|
Nome: RelPbxResumoFone |
|
Data início: 14/09/2018 |
|
Equipe: Amarildo Pereira |
|
Descrição: |
|
O relatório tem a finalidade de apresentar todas as chamadas com relacio- |
|
namento com as tabelas de bilhetes e eventos_dacs assim apresentar seus res- |
|
pectivos status, tempo de espera, tempo de atendimento, tempo de abandono e |
|
a fila correspondente. |
|
|
|
Tabela(s): |
|
-> pbx_bilhetes |
|
-> pbx_eventos_dacs |
|
-> pbx_tipo_ligacao |
|
|
|
Tipo de Evento: |
|
-> ENTERQUEUE |
|
param1 = url (não é utilizado hoje) |
|
param2 = callerid (numero do cliente) |
|
|
|
-> CONNECT |
|
param1 = tempo de espera |
|
param2 = bridgedchanneluniqueid (gerado pelo asterisk, não utilizamos) |
|
|
|
-> COMPLETEAGENTRAMAL |
|
param1 = tempo de espera [variante]; |
|
param2 = tempo da ligação; |
|
|
|
-> COMPLETECALLERRAMAL |
|
param1 = tempo de espera [variante]; |
|
param2 = tempo da ligação; |
|
|
|
-> COMPLETEAGENT |
|
param1 = tempo de espera |
|
param2 = tempo da ligação (do dialogo entre atendente e cliente) |
|
param3 = indica se a ligação é gravada ou não (não utilizamos) |
|
|
|
-> COMPLETECALLER |
|
param1 = tempo de espera |
|
param2 = tempo da ligação (do dialogo entre atendente e cliente) |
|
param3 = indica se a ligação é gravada ou não (não utilizamos) |
|
|
|
-> ABANDON |
|
param1 = posição na fila no momento do abandono |
|
param2 = posição na fila no momento em que chegou |
|
param3 = tempo aguardando antes de desligar (segundos) |
|
|
|
-> TRANSFER |
|
param1 = numero discado (ramal de destino da transferencia) |
|
param2 = contexto no asterisk |
|
param3 = tempo de espera antes do ramal transferido atendenter |
|
param4 = tempo da ligação |
|
|
|
-> NOANSWERS |
|
|
|
-> BUSY |
|
|
|
Calculos(Tempo Espera): |
|
Foi realizada um calculo para saber quanto tempo o cliente ficou em espera |
|
para isso é subtraido o duration[Tempo total da chamada] e billsec[Tempo to |
|
tal de conversação] retornando o tempo em segundo; |
|
Tempo Espera = duration - billsec |
|
|
|
Metricas(Abandono e Não atendida): |
|
Quando a chamada possui evento de abandono e não atendida o billsec vem |
|
composto pelo tempo de espera do cliente na fila. Sendo assim, o billsec não |
|
conta como tempo de atendimento, com isso, seu tempo foi zerado nas impressões; |
|
|
|
|
|
* ************************************************************************* |
|
* Copyright (c) 2018, Simples IP |
|
* *************************************************************************/ |
|
|
|
include_once 'util/relatoriosBase.php'; |
|
|
|
class RelPbxResumoFone extends Relatorios { |
|
|
|
private $___origem; |
|
private $___status; |
|
|
|
public function __construct($idProg, $dbcon, $incDac) { |
|
parent::__construct($idProg, $dbcon, $incDac); |
|
$this->___origem = isset($_POST["origem"]) ? $_POST["origem"] : ''; |
|
$this->___status = isset($_POST["status"]) ? $_POST["status"] : 0; |
|
$this->___dataIni = IsPostBack() ? $_POST['dataIni'] : date('d/m/Y') . " 00:00"; |
|
$this->___dataFim = IsPostBack() ? $_POST['dataFim'] : date('d/m/Y') . " 23:59"; |
|
} |
|
|
|
function ___ValidaForm() { |
|
parent::___ValidaForm(); |
|
} |
|
|
|
function ___FiltrosRelatorio() { |
|
$status = $this->___GetStatus(); |
|
if ($this->___media != MEDIA_PRINT_GRID) { |
|
/* |
|
* Recupera os filtros da sess�o do usu�rio. |
|
*/ |
|
list($this->___dataIni, $this->___dataFim, $this->___matricula, $this->___usuario, $this->___tempoDuracao) = $_SESSION["SSstorageFiltros"]; |
|
|
|
if ($this->___media == MEDIA_PRINT_HTML) { |
|
return sprintf("Data Inicial: %s Data Final: %s ", $this->___dataIni, $this->___dataFim); |
|
} |
|
|
|
$fltCsv = array(); |
|
$fltCsv[] = "Data Inicial: " . $this->___dataIni; |
|
$fltCsv[] = "Data Final: " . $this->___dataFim; |
|
$fltCsv[] = "Data Emissao: " . date('d/m/Y H:i:s'); |
|
$fltCsv[] = "Emitido Por: " . GetLogin(); |
|
return $fltCsv; |
|
} |
|
|
|
$lkPrint = ""; |
|
if ($this->___dataCount) { |
|
$prt = '<a href="index.php?idProg=%s&media=%s"><img src="imgSite/%s" alt="Clique aqui para imprimir!" width="24" height="24" border="0"></a>'; |
|
$prtHtml = "<a href=\"javaScript:NovaJanela('index.php?idProg=%s&media=%s', '%s', '720', '700', 'scrollbars=YES');\"><img src=\"imgSite/%s\" alt=\"Clique aqui para imprimir!\" width=\"24\" height=\"24\" border=\"0\"></a>"; |
|
$lkPrint .= sprintf($prtHtml, $this->GetidProg(), MEDIA_PRINT_HTML, substr(LimpaString(GetDispProgSel($this->GetIdProg())), 0, 20), 'print.gif'); |
|
$lkPrint .= sprintf($prt, $this->GetidProg(), MEDIA_PRINT_EXCEL, 'prt-xls.png'); |
|
$lkPrint .= sprintf($prt, $this->GetidProg(), MEDIA_PRINT_PDF, 'prt-pdf.png'); |
|
$lkPrint .= sprintf($prt, $this->GetidProg(), MEDIA_PRINT_CSV, 'prt-csv.png'); |
|
} |
|
|
|
/* |
|
* Personalise esta função se necessitar de outras opções de filtro. |
|
*/ |
|
$filtro = '<table class="filtro" border="0" cellspacing="1" cellpadding="1">'; |
|
/* |
|
* Rotulos. |
|
*/ |
|
$filtro .= '<tr>'; |
|
$filtro .= '<td>Telefone Origem </td>'; |
|
$filtro .= '<td>Data Inicial </td>'; |
|
$filtro .= '<td>Data Final </td>'; |
|
$filtro .= '<td>Status </td>'; |
|
$filtro .= '<td> </td>'; |
|
$filtro .= '<td align="center" valign="middle"> </td>'; |
|
$filtro .= '</tr>'; |
|
|
|
/* |
|
* Valores. |
|
*/ |
|
$filtro .= '<tr>'; |
|
$filtro .= sprintf('<td><input name="origem" id="origem" type="text" size="15" maxlength="15" value="%s" title="Número de telefone"></td></span></td>', $this->___origem); |
|
$filtro .= '<td><input name="dataIni" id="dataIni" type="text" size="15" maxlength="16" value="%s" onkeyup="formataDataHora(this)" title="dd/mm/aaaa HH:mm"></td>'; |
|
$filtro .= '<td><input name="dataFim" id="dataFim" type="text" size="15" maxlength="16" value="%s" onkeyup="formataDataHora(this)" title="dd/mm/aaaa HH:mm"></td>'; |
|
$filtro .= "<td>$status</td>"; |
|
$filtro .= '<td><input type="submit" name="btConsulta" id="btConsulta" value="Consultar"></td>'; |
|
$filtro .= '<td>%s</td>'; |
|
$filtro .= '</tr>'; |
|
$filtro .= '</table>'; |
|
|
|
/* |
|
* Guarda os filtros passados para recuperar na emiss�o dos relat?ios para impress�o. |
|
*/ |
|
$_SESSION["SSstorageFiltros"] = array($this->___dataIni, $this->___dataFim); |
|
|
|
return sprintf($filtro, $this->___dataIni, $this->___dataFim, $lkPrint); |
|
} |
|
|
|
protected function ___GetDadosDb() { |
|
$dataIni = strlen($this->___dataIni) == 10 ? FormatDtMssql($this->___dataIni) . " 00:00": FormatDtMssql(substr($this->___dataIni, 0, 10)). substr($this->___dataIni, 10, 16); |
|
$dataFim = strlen($this->___dataFim) == 10 ? FormatDtMssql($this->___dataFim) . " 23:59": FormatDtMssql(substr($this->___dataFim, 0, 10)). substr($this->___dataFim, 10, 16); |
|
$origem = $this->___origem; |
|
$status = $this->___status; |
|
|
|
|
|
$query = "SELECT uniqueid,calldate,dst,src,SUM(duration - billsec) as espera, billsec, |
|
CASE WHEN(param3 <> '' AND evento = 'ABANDON') THEN param3 ELSE '' END AS tempo_abandon, |
|
apelido AS agente, |
|
fila,evento,tplg_descricao |
|
FROM pbx_bilhetes a |
|
INNER JOIN pbx_eventos_dacs b ON a.uniqueid = uid2 |
|
INNER JOIN pbx_tipo_ligacao c ON a.tipo_chamada = c.tplg_codigo |
|
LEFT JOIN pbx_usuarios d ON d.matricula = CASE WHEN (SUBSTRING(b.agente,1,5) = 'Agent') THEN SUBSTRING(b.agente,7,4) END |
|
WHERE calldate::timestamp >= '$dataIni' AND calldate::timestamp <= '$dataFim'"; |
|
switch ($status) { |
|
case 1: |
|
$evento = "COMPLETEAGENT','COMPLETEAGENTRAMAL','COMPLETECALLER','COMPLETECALLERRAMAL', 'COMPLETAAGENT','COMPLETACALLER"; |
|
break; |
|
case 2: |
|
$evento = "NOANSWERS"; |
|
break; |
|
case 3: |
|
$evento = "TRANSFER"; |
|
break; |
|
case 4: |
|
$evento = "ABANDON"; |
|
break; |
|
case 5: |
|
$evento = "BUSY"; |
|
break; |
|
default: |
|
$evento = "COMPLETEAGENT','COMPLETEAGENTRAMAL','COMPLETECALLER','COMPLETECALLERRAMAL', 'COMPLETAAGENT','COMPLETACALLER','ABANDON','TRANSFER','NOANSWERS','BUSY"; |
|
} |
|
$query .= " AND b.evento IN('$evento') |
|
AND a.lastapp <> 'Transferred Call'"; |
|
|
|
$origem ? $query .= " AND (src like '%$origem%' or dst like '%$origem%')" : ''; |
|
|
|
$query .= " GROUP BY 1,2,3,4,6,7,8,9,10,11 |
|
ORDER BY calldate"; |
|
|
|
$result = $this->___GetQuery($query); |
|
$row = pg_fetch_all($result); |
|
$this->SetData($row ? $row : array()); |
|
} |
|
|
|
protected function ___PreparaCsv() { |
|
$nomeDac = ""; |
|
$dataRel = array(); |
|
$dataAgrup = array(); |
|
$filtro = $this->___FiltrosRelatorio(); |
|
|
|
$dataRel[] = GenerateCsvFromArray($filtro); |
|
|
|
$dadosCabecalio = array('Data/Hora', 'Origem', 'Destino', 'Status', 'Tempo Espera', 'Tempo Atendimento', 'Tempo Abandono', 'Agente/Ramal', 'Fila', 'Tipo'); |
|
$dadosField = array('calldate', 'src', 'dst', 'evento', 'espera', 'billsec', 'tempo_abandon', 'agente', 'fila', 'tplg_descricao'); |
|
|
|
$dataRel[] = GenerateCsvFromArray($dadosCabecalio); |
|
|
|
$somaTE = 0; |
|
$somaTA = 0; |
|
$somaTABAN = 0; |
|
$somaQuantidade = 0; |
|
|
|
/* |
|
* Inicia o relat�rio. |
|
*/ |
|
foreach ($this->GetData()[0] as $row) { |
|
$somaTE += (int) $row['espera']; |
|
$somaTABAN += (int) $row['tempo_abandon']; |
|
$row['src'] = ocultarTelefone($row['src']); |
|
$row['dst'] = ocultarTelefone($row['dst']); |
|
$row["calldate"] = date('d/m/Y H:i', strtotime($row["calldate"])); |
|
$row["tplg_descricao"] = explode(" ", $row["tplg_descricao"])[0]; |
|
$row["espera"] = SecondToStrTime($row["espera"]); |
|
$row["tempo_abandon"] ? $row["tempo_abandon"] = SecondToStrTime($row["tempo_abandon"]) : $row["tempo_abandon"] = '00:00:00'; |
|
$row["tempo_atendimento"] = SecondToStrTime($row["tempo_atendimento"]); |
|
$row['agente'] = !$row['agente'] ? ' --- ' : $row['agente']; |
|
$row['tplg_descricao'] = RemoveAcentos($row['tplg_descricao']); |
|
|
|
if ($row["evento"] == 'ABANDON' || $row["evento"] == 'NOANSWERS') { |
|
$row["billsec"] = SecondToStrTime(0); |
|
} else { |
|
$somaTA += $row['billsec']; |
|
$row["billsec"] = SecondToStrTime($row["billsec"]); |
|
} |
|
|
|
switch ($row["evento"]) { |
|
case 'TRANSFER': |
|
$row["evento"] = 'TRANSFERENCIA'; |
|
break; |
|
case 'NOANSWERS': |
|
$row["evento"] = 'NAO ATENDIDA'; |
|
break; |
|
case 'BUSY': |
|
$row["evento"] = 'OCUPADO'; |
|
break; |
|
case 'ABANDON': |
|
$row["evento"] = 'ABANDONADA'; |
|
break; |
|
default: |
|
$row["evento"] = 'ATENDIDA'; |
|
} |
|
|
|
$somaQuantidade ++; |
|
|
|
$linha = array(); |
|
foreach ($dadosField as $key) { |
|
$linha[] = $row["$key"]; |
|
} |
|
|
|
$dataRel[] = GenerateCsvFromArray($linha); |
|
} |
|
|
|
$linha = array('Total: ' . $somaQuantidade, '', '', '', 'Total E.:' . SecondToStrTime($somaTE), 'Total A.:' . SecondToStrTime($somaTA), 'Total ABAN.:' . SecondToStrTime($somaTABAN)); |
|
$dataRel[] = GenerateCsvFromArray($linha); |
|
|
|
$this->___dataRel[] = $dataRel; |
|
} |
|
|
|
protected function ___PreparaExcel() { |
|
$dataRel = array(); |
|
$filtro = $this->___FiltrosRelatorio(); |
|
|
|
/* |
|
* Inicia o relatório. |
|
*/ |
|
|
|
/* |
|
* Cria os filtros |
|
*/ |
|
$linha = array('LABEL'); |
|
foreach ($filtro as $values) { |
|
list($label, $value) = explode(":", $values); |
|
$linha[] = $label; |
|
} |
|
$dataRel[] = $linha; |
|
|
|
$linha = array('DADOS'); |
|
foreach ($filtro as $values) { |
|
list($label, $value) = explode(":", $values); |
|
$linha[] = $value; |
|
} |
|
|
|
$dataRel[] = $linha; |
|
|
|
$dadosCabecalio = array('Data/Hora', 'Origem', 'Destino', 'Status', 'Tempo Espera', 'Tempo Atendimento', 'Tempo Abandono', 'Agente/Ramal', 'Fila', 'Tipo'); |
|
$dadosField = array('calldate', 'src', 'dst', 'evento', 'espera', 'billsec', 'tempo_abandon', 'agente', 'fila', 'tplg_descricao'); |
|
|
|
/* |
|
* Monta a linha de cabecalio. |
|
*/ |
|
$linha = array('LABEL'); |
|
foreach ($dadosCabecalio as $value) { |
|
$linha[] = $value; |
|
} |
|
$dataRel[] = $linha; |
|
|
|
$somaTE = 0; |
|
$somaTA = 0; |
|
$somaTABAN = 0; |
|
$somaQuantidade = 0; |
|
/* |
|
* Linhas de dados. |
|
*/ |
|
foreach ($this->GetData()[0] as $row) { |
|
$somaTE += (int) $row['espera']; |
|
$somaTABAN += (int) $row['tempo_abandon']; |
|
$row['src'] = ocultarTelefone($row['src']); |
|
$row['dst'] = ocultarTelefone($row['dst']); |
|
$row["calldate"] = date('d/m/Y H:i', strtotime($row["calldate"])); |
|
$row["tplg_descricao"] = explode(" ", $row["tplg_descricao"])[0]; |
|
$row["espera"] = SecondToStrTime($row["espera"]); |
|
$row["tempo_abandon"] ? $row["tempo_abandon"] = SecondToStrTime($row["tempo_abandon"]) : $row["tempo_abandon"] = '00:00:00'; |
|
$row["tempo_atendimento"] = SecondToStrTime($row["tempo_atendimento"]); |
|
$row['agente'] = !$row['agente'] ? ' --- ' : $row['agente']; |
|
$row['tplg_descricao'] = RemoveAcentos($row['tplg_descricao']); |
|
|
|
if ($row["evento"] == 'ABANDON' || $row["evento"] == 'NOANSWERS') { |
|
$row["billsec"] = SecondToStrTime(0); |
|
} else { |
|
$somaTA += $row['billsec']; |
|
$row["billsec"] = SecondToStrTime($row["billsec"]); |
|
} |
|
|
|
switch ($row["evento"]) { |
|
case 'TRANSFER': |
|
$row["evento"] = 'TRANSFERENCIA'; |
|
break; |
|
case 'NOANSWERS': |
|
$row["evento"] = 'NAO ATENDIDA'; |
|
break; |
|
case 'BUSY': |
|
$row["evento"] = 'OCUPADO'; |
|
break; |
|
case 'ABANDON': |
|
$row["evento"] = 'ABANDONADA'; |
|
break; |
|
default: |
|
$row["evento"] = 'ATENDIDA'; |
|
} |
|
|
|
$somaQuantidade ++; |
|
|
|
// Formata linha de dados. |
|
$linha = array('DADOS'); |
|
foreach ($dadosField as $key) { |
|
$linha[] = $row["$key"]; |
|
} |
|
|
|
$dataRel[] = $linha; |
|
} |
|
|
|
$linha = array('LABEL', 'Total: ' . $somaQuantidade, '', '', '', 'ESP.:' . SecondToStrTime($somaTE), 'ATEN.:' . SecondToStrTime($somaTA), 'ABAN.:' . SecondToStrTime($somaTABAN)); |
|
|
|
$dataRel[] = $linha; |
|
|
|
$this->___dataRel[] = $dataRel; |
|
} |
|
|
|
protected function ___PreparaGrid() { |
|
$dadosCabecalio = array( |
|
'Data/Hora' => 'align="center"', |
|
'Origem' => 'align="left"', |
|
'Destino' => 'align="left"', |
|
'Status' => 'align="left"', |
|
'Tempo Espera' => 'align="center"', |
|
'Tempo Atendimento' => 'align="center"', |
|
'Tempo Abandono' => 'align="center"', |
|
'Agente/Ramal' => 'align="left"', |
|
'Fila' => 'align="left"', |
|
'Tipo' => 'align="center"' |
|
); |
|
$dadosField = array( |
|
'calldate' => 'align="center"', |
|
'src' => 'align="left"', |
|
'dst' => 'align="left"', |
|
'evento' => 'align="left"', |
|
'espera' => 'align="center"', |
|
'billsec' => 'align="center"', |
|
'tempo_abandon' => 'align="center"', |
|
'agente' => 'align="left"', |
|
'fila' => 'align="left"', |
|
'tplg_descricao' => 'align="center"' |
|
); |
|
/* |
|
* Inicia o relat�rio. |
|
*/ |
|
$dataRel[] = '<table width="90%" cellpadding="2" class="grid">'; |
|
|
|
/* |
|
* Monta a linha de cabecalio. |
|
*/ |
|
$linha = '<tr>'; |
|
foreach ($dadosCabecalio as $key => $value) { |
|
$linha .= sprintf("<th %s>%s</th>", $value, $key); |
|
} |
|
$linha .= "</tr>"; |
|
$dataRel[] = $linha; |
|
|
|
/* |
|
* Verifica se retornou dados |
|
*/ |
|
if (!IsPostBack() || !count($this->GetData()[0])) { |
|
$dataRel[] = sprintf("<tr><td align=\"center\" colspan=\"%s\">%s</td></tr></table>", count($dadosCabecalio), (!IsPostBack() ? 'Informe os parametros e clique em consultar!' : 'Nenhum registro encontado!')); |
|
$this->___dataRel[] = $dataRel; |
|
return; |
|
} |
|
|
|
$somaTE = 0; |
|
$somaTA = 0; |
|
$somaTABAN = 0; |
|
$somaQuantidade = 0; |
|
/* |
|
* Linhas de dados. |
|
*/ |
|
foreach ($this->GetData()[0] as $row) { |
|
$somaTE += (int) $row['espera']; |
|
$somaTABAN += (int) $row['tempo_abandon']; |
|
$row['src'] = ocultarTelefone($row['src']); |
|
$row['dst'] = ocultarTelefone($row['dst']); |
|
$row["calldate"] = date('d/m/Y H:i', strtotime($row["calldate"])); |
|
$row["tplg_descricao"] = explode(" ", $row["tplg_descricao"])[0]; |
|
$row["espera"] = SecondToStrTime($row["espera"]); |
|
$row["tempo_abandon"] ? $row["tempo_abandon"] = SecondToStrTime($row["tempo_abandon"]) : $row["tempo_abandon"] = '00:00:00'; |
|
$row['agente'] = !$row['agente'] ? ' --- ' : $row['agente']; |
|
|
|
if ($row["evento"] == 'ABANDON' || $row["evento"] == 'NOANSWERS') { |
|
$row["billsec"] = SecondToStrTime(0); |
|
} else { |
|
$somaTA += $row['billsec']; |
|
$row["billsec"] = SecondToStrTime($row["billsec"]); |
|
} |
|
|
|
switch ($row["evento"]) { |
|
case 'TRANSFER': |
|
$row["evento"] = 'TRANSFERENCIA'; |
|
break; |
|
case 'NOANSWERS': |
|
$row["evento"] = 'NÃO ATENDIDA'; |
|
break; |
|
case 'BUSY': |
|
$row["evento"] = 'OCUPADO'; |
|
break; |
|
case 'ABANDON': |
|
$row["evento"] = 'ABANDONADA'; |
|
break; |
|
default: |
|
$row["evento"] = 'ATENDIDA'; |
|
} |
|
|
|
$somaQuantidade ++; |
|
|
|
// Formata linha de dados. |
|
$linha = "<tr>"; |
|
foreach ($dadosField as $key => $value) { |
|
$linha .= sprintf("<td %s>%s</td>", $value, $row["$key"]); |
|
} |
|
$linha .= "</tr>"; |
|
$dataRel[] = $linha; |
|
} |
|
/* |
|
* Linha de totalizacao. |
|
*/ |
|
$linha = '<tr><th colspan="4" align="left">Total: %s</th><th align="left">Total E.: %s</th><th align="left">Total A.: %s</th><th align="left">Total ABAN.: %s</th><th align="left" colspan="3"></th></tr>'; |
|
$dataRel[] = sprintf($linha, $somaQuantidade, SecondToStrTime($somaTE), SecondToStrTime($somaTA), SecondToStrTime($somaTABAN)); |
|
|
|
/* |
|
* Fecha relatorio. |
|
*/ |
|
$dataRel[] = '</table>'; |
|
$this->___dataRel[] = $dataRel; |
|
} |
|
|
|
protected function ___PreparaHtml() { |
|
|
|
} |
|
|
|
protected function ___PreparaPdf() { |
|
list($this->___dataIni, $this->___dataFim) = $_SESSION["SSstorageFiltros"]; |
|
|
|
$dadosCabecalio = array( |
|
'Data/Hora' => 'C', |
|
'Origem' => 'C', |
|
'Destino' => 'C', |
|
'Status' => 'C', |
|
'Tempo Espera' => 'C', |
|
'Tempo Atendimento' => 'C', |
|
'Tempo Abandono' => 'C', |
|
'Agente/Ramal' => 'C', |
|
'Fila' => 'C', |
|
'Tipo' => 'C' |
|
); |
|
$dadosField = array( |
|
'calldate' => 'C', |
|
'src' => 'C', |
|
'dst' => 'C', |
|
'evento' => 'C', |
|
'espera' => 'C', |
|
'billsec' => 'C', |
|
'tempo_abandon' => 'C', |
|
'agente' => 'C', |
|
'fila' => 'C', |
|
'tplg_descricao' => 'C' |
|
); |
|
|
|
$dados = $this->GetData()[0]; |
|
$x = 0; |
|
$somaTE = 0; |
|
$somaTA = 0; |
|
$somaTABAN = 0; |
|
|
|
foreach ($dados as $row) { |
|
$somaTE += (int) $row['espera']; |
|
$somaTABAN += (int) $row['tempo_abandon']; |
|
$dados[$x]['src'] = ocultarTelefone($row['src']); |
|
$dados[$x]['dst'] = ocultarTelefone($row['dst']); |
|
$dados[$x]["calldate"] = date('d/m/Y H:i', strtotime($row["calldate"])); |
|
$dados[$x]["tplg_descricao"] = explode(" ", $row["tplg_descricao"])[0]; |
|
$dados[$x]["espera"] = SecondToStrTime($row["espera"]); |
|
$dados[$x]["tempo_abandon"] = $row["tempo_abandon"] ? SecondToStrTime($row["tempo_abandon"]) : '00:00:00'; |
|
$dados[$x]["tempo_atendimento"] = SecondToStrTime($row["tempo_atendimento"]); |
|
$dados[$x]['agente'] = !$row['agente'] ? ' --- ' : $row['agente']; |
|
|
|
if ($row["evento"] == 'ABANDON' || $row["evento"] == 'NOANSWERS') { |
|
$dados[$x]["billsec"] = SecondToStrTime(0); |
|
} else { |
|
$somaTA += $row['billsec']; |
|
$dados[$x]["billsec"] = SecondToStrTime($row["billsec"]); |
|
} |
|
|
|
switch ($row["evento"]) { |
|
case 'TRANSFER': |
|
$dados[$x]["evento"] = 'TRANSFERENCIA'; |
|
break; |
|
case 'NOANSWERS': |
|
$dados[$x]["evento"] = 'NÃO ATENDIDA'; |
|
break; |
|
case 'BUSY': |
|
$dados[$x]["evento"] = 'OCUPADO'; |
|
break; |
|
case 'ABANDON': |
|
$dados[$x]["evento"] = 'ABANDONADA'; |
|
break; |
|
default: |
|
$dados[$x]["evento"] = 'ATENDIDA'; |
|
} |
|
$x++; |
|
} |
|
|
|
$widthHeader = array(20, 15, 20, 20, 18, 23, 23, 15, 30, 10); |
|
$totaliza = array('Total: ' . $x, '', '', '', 'ESP:' . SecondToStrTime($somaTE), 'ATEN:' . SecondToStrTime($somaTA), 'ABAN:' . SecondToStrTime($somaTABAN), '', '', ''); |
|
|
|
//Monta o array para passar para o prepara; Necessário passar 6 parametros |
|
$table1 = array($dadosCabecalio, $dadosField, $dados, $widthHeader, $totaliza, 0); |
|
|
|
$this->___dataRel = array($table1); |
|
} |
|
|
|
protected function ___GetStatus() { |
|
$status = array(1 => 'ATENDIDA', 2 => 'NÃO ATENDIDA', 3 => 'TRANSFERENCIA', 4 => 'ABANDONADA', 5 => 'OCUPADO'); |
|
$row = "<select name=\"status\">"; |
|
!$this->___status ? $row .= "<option value=\"0\"> ----- </option>" : $row .= "<option value=\"0\">Todos</option>"; |
|
|
|
foreach ($status as $key => $sts) { |
|
$sel = $this->___status == $key ? "selected" : ''; |
|
$row .= sprintf("<option value=\"%s\" $sel>%s</option>", $key, $sts); |
|
} |
|
$row .= "</select>"; |
|
|
|
return $row; |
|
} |
|
|
|
public function ExecutaRelatorio() { |
|
global $jsStartup, $jsJQuery, $smarty; |
|
try { |
|
/* |
|
* Use esta fun��o para validar dados do formul�rio. |
|
*/ |
|
$this->___ValidaForm(); |
|
|
|
/* |
|
* Recupera os dados do banco. |
|
*/ |
|
$this->___ConteudoRelatorio(); |
|
|
|
/* |
|
* Imprime relat�rio de acordo com a media passada. |
|
*/ |
|
$conteudoRelatorio = $this->___ImprimeRelatorio(); |
|
} catch (Exception $exc) { |
|
$this->SetMsg($exc->getMessage()); |
|
$jsStartup[] = sprintf("alert('%s');", $this->GetMsg()); |
|
$this->___GravaLog(); |
|
} |
|
|
|
/* |
|
* Inclua os scripts necess�rios aqui. |
|
*/ |
|
$jsJQuery[] = "\$('#dataIni').keypress(function(){formataDataHora(this);}) "; |
|
$jsJQuery[] = "\$('#dataFim').keypress(function(){formataDataHora(this);}) "; |
|
|
|
$smarty->assign('filtros', $this->___FiltrosRelatorio()); |
|
$smarty->assign('conteudo', $conteudoRelatorio); |
|
$smarty->assign('msg', $this->GetMsg()); |
|
GetTemplate($smarty, 'relatoriosGrid.tpl'); |
|
} |
|
|
|
} |
|
|
|
$relResumoFone = new RelPbxResumoFone($idProg, $dbcon, 0); |
|
$relResumoFone->ExecutaRelatorio();
|
|
|