|
|
|
|
<?php
|
|
|
|
|
/***************************************************************************
|
|
|
|
|
*
|
|
|
|
|
* Recebidas Por DDD
|
|
|
|
|
* Autor
|
|
|
|
|
* Lucas Awade
|
|
|
|
|
*
|
|
|
|
|
* *************************************************************************
|
|
|
|
|
* Defini<EFBFBD><EFBFBD>es do Projeto
|
|
|
|
|
* Nome: RelRecebidasDDD
|
|
|
|
|
* Data in<EFBFBD>cio: 08/08/2018
|
|
|
|
|
* Equipe: Amarildo Pereira
|
|
|
|
|
* Descri<EFBFBD><EFBFBD>o:
|
|
|
|
|
* O objetivo deste relat<EFBFBD>rio <EFBFBD> apresentar informa<EFBFBD><EFBFBD>es das chamdas de
|
|
|
|
|
* Entrada e Sa<EFBFBD>da, com base no DDD de cada chamada, assim foi relacionadas
|
|
|
|
|
* tabelas que possui essas informa<EFBFBD><EFBFBD>es e eventos que filtrara ocorrecias
|
|
|
|
|
* n<EFBFBD>o desejadas.
|
|
|
|
|
*
|
|
|
|
|
* Tabelas utilizadas:
|
|
|
|
|
*
|
|
|
|
|
* -> pbx_bilhetes = Chamadas realizadas;
|
|
|
|
|
* -> pbx_eventos_dacs = Filtrar eventos de chamadas;
|
|
|
|
|
* -> pbx_municipios = Coletar DDD UF e REGIAO;
|
|
|
|
|
* -> pbx_tipo_ligacao = Verificar o tipo da chamada;
|
|
|
|
|
* -> pbx_dacs = Relacionar com a fila;
|
|
|
|
|
*
|
|
|
|
|
* A totaliza<EFBFBD><EFBFBD>o <EFBFBD> feita de modo estruturado onde cont<EFBFBD>m informa<EFBFBD><EFBFBD>es fixas
|
|
|
|
|
* para o tratamento e contagem.Sua estrutura foi adptada para ser utilizado
|
|
|
|
|
* no modulos de impress<EFBFBD>o. Seus relacionamentos <EFBFBD> apenas com os tipo de
|
|
|
|
|
* ligacao.
|
|
|
|
|
*
|
|
|
|
|
* Tipo de liga<EFBFBD><EFBFBD>o em contagem:
|
|
|
|
|
*
|
|
|
|
|
* -> Fixo Interurbano
|
|
|
|
|
* -> Fixo Local
|
|
|
|
|
* -> Movel Local
|
|
|
|
|
* -> Movel Interurbano
|
|
|
|
|
* -> Total = Contagem de todos os demais modos;
|
|
|
|
|
*
|
|
|
|
|
* OBS: Para corrigir ou adicionar informa<EFBFBD><EFBFBD>es no relat<EFBFBD>rio atentar com essa
|
|
|
|
|
* estrutura.
|
|
|
|
|
*
|
|
|
|
|
* *************************************************************************
|
|
|
|
|
* Copyright (c) 2018, Simples IP
|
|
|
|
|
* ************************************************************************/
|
|
|
|
|
|
|
|
|
|
include_once 'util/relatoriosBase.php';
|
|
|
|
|
|
|
|
|
|
class RelRecebidasDDD extends Relatorios {
|
|
|
|
|
|
|
|
|
|
private $___tiposLigacao = null;
|
|
|
|
|
|
|
|
|
|
public function __construct($idProg, $dbcon, $incDac) {
|
|
|
|
|
parent::__construct($idProg, $dbcon, $incDac);
|
|
|
|
|
$this->___dac = isset($_POST['listaDacs']) ? $_POST['listaDacs'] : 0;
|
|
|
|
|
$this->___tiposLigacao = array(
|
|
|
|
|
0 => array('descricao' => 'Fixo Interurbano', 'tempo' => 0, 'quantidade' => 0, 'duracao' => 0),
|
|
|
|
|
1 => array('descricao' => 'Fixo Local', 'tempo' => 0, 'quantidade' => 0, 'duracao' => 0),
|
|
|
|
|
2 => array('descricao' => 'Movel Local', 'tempo' => 0, 'quantidade' => 0, 'duracao' => 0),
|
|
|
|
|
3 => array('descricao' => 'Movel Interurbano', 'tempo' => 0, 'quantidade' => 0, 'duracao' => 0),
|
|
|
|
|
4 => array('descricao' => 'C.I.E.I.V', 'tempo' => 0, 'quantidade' => 0, 'duracao' => 0),
|
|
|
|
|
5 => array('descricao' => 'Total', 'tempo' => 0, 'quantidade' => 0, 'duracao' => 0)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function ___FiltrosRelatorio() {
|
|
|
|
|
if ($this->___media != MEDIA_PRINT_GRID) {
|
|
|
|
|
/*
|
|
|
|
|
* Recupera os filtros da sess<EFBFBD>o do usu<EFBFBD>rio.
|
|
|
|
|
*/
|
|
|
|
|
list($this->___dac, $this->___dataIni, $this->___dataFim, $this->___tipoRelatorio) = $_SESSION["SSstorageFiltros"];
|
|
|
|
|
|
|
|
|
|
if ($this->___media == MEDIA_PRINT_HTML) {
|
|
|
|
|
$fila = $this->GetIncDac() ? 'Fila: ' . GetDacDesc($this->GetDbCon(), $this->GetIdProg() . ' ') : '';
|
|
|
|
|
return sprintf("%sData Inicial: %s Data Final: %s Tipo: %s", $fila, $this->___dataIni, $this->___dataFim, ($this->___tipoRelatorio ? 'Anal<EFBFBD>tico' : 'Sint<EFBFBD>tico'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$fltCsv = array();
|
|
|
|
|
if ($this->GetIncDac()) {
|
|
|
|
|
$fltCsv[] = 'Fila:' . GetDacDesc($this->GetDbCon(), $this->___dac);
|
|
|
|
|
}
|
|
|
|
|
$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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($this->GetIncDac()) {
|
|
|
|
|
$dacs = GetDac($this->GetDbCon(), $this->___dac, "", 0, 1, 0, 0, 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$lkPrint = "";
|
|
|
|
|
if ($this->___dataCount) {
|
|
|
|
|
$prt = '<a href="index.php?idProg=%s&media=%s&tipoRelatorio=%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&tipoRelatorio=%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, $this->___tipoRelatorio, substr(LimpaString(GetDispProgSel($this->GetIdProg())), 0, 20), 'print.gif');
|
|
|
|
|
$lkPrint .= sprintf($prt, $this->GetidProg(), MEDIA_PRINT_EXCEL, $this->___tipoRelatorio, 'prt-xls.png');
|
|
|
|
|
$lkPrint .= sprintf($prt, $this->GetidProg(), MEDIA_PRINT_PDF, $this->___tipoRelatorio, 'prt-pdf.png');
|
|
|
|
|
$lkPrint .= sprintf($prt, $this->GetidProg(), MEDIA_PRINT_CSV, $this->___tipoRelatorio, 'prt-csv.png');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$tipoRel = !$this->___tipoRelatorio ? '' : 'checked="checked"';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Personalise esta fun<EFBFBD><EFBFBD>o se necessitar de outras opera<EFBFBD><EFBFBD>es de filtro.
|
|
|
|
|
*/
|
|
|
|
|
$filtro = '<table border="0" cellspacing="1" cellpadding="1">';
|
|
|
|
|
/*
|
|
|
|
|
* Rotulos.
|
|
|
|
|
*/
|
|
|
|
|
$filtro .= '<tr>';
|
|
|
|
|
$this->GetIncDac() ? $filtro .= '<td>Fila</td>' : '';
|
|
|
|
|
$filtro .= '<td>Data Inicial</td>';
|
|
|
|
|
$filtro .= '<td>Data Final </td>';
|
|
|
|
|
$filtro .= '<td align="center" valign="middle"> </td>';
|
|
|
|
|
$filtro .= '</tr>';
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Valores.
|
|
|
|
|
*/
|
|
|
|
|
$filtro .= '<tr>';
|
|
|
|
|
$this->GetIncDac() ? $filtro .= sprintf('<td>%s</td>', $dacs) : '';
|
|
|
|
|
$filtro .= '<td><input name="dataIni" id="dataIni" type="text" size="15" maxlength="10" value="%s" onkeyup="formataData(this)" title="dd/mm/aaaa"></td>';
|
|
|
|
|
$filtro .= '<td><input name="dataFim" id="dataFim" type="text" size="15" maxlength="10" value="%s" onkeyup="formataData(this)" title="dd/mm/aaaa"></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<EFBFBD>o dos relat<EFBFBD>rios para impress<EFBFBD>o.
|
|
|
|
|
*/
|
|
|
|
|
$_SESSION["SSstorageFiltros"] = array($this->___dac, $this->___dataIni, $this->___dataFim, $this->___tipoRelatorio);
|
|
|
|
|
return sprintf($filtro, $this->___dataIni, $this->___dataFim, $lkPrint);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function ___GetDadosDb() {
|
|
|
|
|
$dataIni = FormatDtMssql($this->___dataIni);
|
|
|
|
|
$dataFim = FormatDtMssql($this->___dataFim);
|
|
|
|
|
$dac = $this->___dac;
|
|
|
|
|
|
|
|
|
|
$query = sprintf("SELECT b.fila,c.codigo_ddd AS ddd, c.uf,
|
|
|
|
|
CASE WHEN(tplg_codigo IN(23,24,33,34))THEN 'M<EFBFBD>VEL' ELSE c.nome_municipio END AS nome_municipio,
|
|
|
|
|
tplg_descricao,count(*) AS qtde, SUM(a.billsec) AS duracao
|
|
|
|
|
FROM pbx_bilhetes a
|
|
|
|
|
INNER JOIN pbx_eventos_dacs b ON a.uniqueid = b.uid2 AND b.evento IN('COMPLETEAGENT','COMPLETECALLER','COMPLETAAGENT','COMPLETECALLERRAMAL','COMPLETEAGENTRAMAL')
|
|
|
|
|
INNER JOIN pbx_municipios c ON a.id_municipio = c.id
|
|
|
|
|
INNER JOIN pbx_tipo_ligacao d ON a.tipo_chamada = d.tplg_codigo
|
|
|
|
|
INNER JOIN pbx_dacs e ON e.nome = b.fila
|
|
|
|
|
WHERE a.data_bilhete >= '%s'
|
|
|
|
|
AND a.data_bilhete <= '%s'
|
|
|
|
|
AND e.id = %s
|
|
|
|
|
AND a.lastapp <> 'Transferred Call'
|
|
|
|
|
GROUP BY 1,2,3,4,5
|
|
|
|
|
ORDER BY c.uf", $dataIni, $dataFim, $dac);
|
|
|
|
|
|
|
|
|
|
$result = $this->___GetQuery($query);
|
|
|
|
|
$row = pg_fetch_all($result);
|
|
|
|
|
|
|
|
|
|
$this->SetData($row ? $row : array());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function ___PreparaCsv() {
|
|
|
|
|
$dataRel = array();
|
|
|
|
|
$filtro = $this->___FiltrosRelatorio();
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Inicia o relat<EFBFBD>rio.
|
|
|
|
|
*/
|
|
|
|
|
$dataRel[] = GenerateCsvFromArray($filtro);
|
|
|
|
|
|
|
|
|
|
$dadosCabecalio = array('DDD', 'UF', 'Regiao', 'Tipo', 'Duracao', 'TMO', 'Quantidade');
|
|
|
|
|
$dadosField = array('ddd', 'uf', 'nome_municipio', 'tplg_descricao', 'duracao', 'tmo', 'qtde');
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Monta a linha de cabecalio.
|
|
|
|
|
*/
|
|
|
|
|
$dataRel[] = GenerateCsvFromArray($dadosCabecalio);
|
|
|
|
|
|
|
|
|
|
$somaTempo = 0;
|
|
|
|
|
$somaQtde = 0;
|
|
|
|
|
$somaReg = 0;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Linhas de dados.
|
|
|
|
|
*/
|
|
|
|
|
foreach ($this->GetData()[0] as $row) {
|
|
|
|
|
$somaQtde ++;
|
|
|
|
|
$somaTempo += $row["duracao"];
|
|
|
|
|
$somaReg += $row['qtde'];
|
|
|
|
|
|
|
|
|
|
$descricao = explode(" ", $row['tplg_descricao']);
|
|
|
|
|
$this->___verificaTipoLigacao($descricao[1] . ' ' . $descricao[2], $row["duracao"]);
|
|
|
|
|
|
|
|
|
|
$row['tmo'] = SecondToStrTime(round($row["duracao"] / $row['qtde']));
|
|
|
|
|
$row["duracao"] = SecondToStrTime($row["duracao"]);
|
|
|
|
|
|
|
|
|
|
// Formata linha de dados.
|
|
|
|
|
$linha = array();
|
|
|
|
|
foreach ($dadosField as $value) {
|
|
|
|
|
$linha[] = $row["$value"];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$dataRel[] = GenerateCsvFromArray($linha);
|
|
|
|
|
}
|
|
|
|
|
$dataRel[] = GenerateCsvFromArray(array('Total: ' . $somaQtde, '', '', '', 'Duracao: ' . SecondToStrTime($somaTempo), 'TMO: ' . SecondToStrTime(round($somaTempo / $somaReg)), $somaQtde));
|
|
|
|
|
$dataRel[] = GenerateCsvFromArray(array('', '', '', ''));
|
|
|
|
|
|
|
|
|
|
$totalCabecalio = array('Tipo', 'Quantidade', 'Tempo');
|
|
|
|
|
$dataRel[] = GenerateCsvFromArray($totalCabecalio);
|
|
|
|
|
foreach ($this->___tiposLigacao as $value) {
|
|
|
|
|
$dataRel[] = GenerateCsvFromArray(array($value['descricao'], $value['quantidade'], $value['duracao']));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->___dataRel[] = $dataRel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function ___PreparaExcel() {
|
|
|
|
|
$dataRel = array();
|
|
|
|
|
$filtro = $this->___FiltrosRelatorio();
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Inicia o relat<EFBFBD>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('DDD', 'UF', 'Regiao', 'Tipo', 'Duracao', 'TMO', 'Quantidade');
|
|
|
|
|
$dadosField = array('ddd', 'uf', 'nome_municipio', 'tplg_descricao', 'duracao', 'tmo', 'qtde');
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Monta a linha de cabecalio.
|
|
|
|
|
*/
|
|
|
|
|
$linha = array('LABEL');
|
|
|
|
|
foreach ($dadosCabecalio as $value) {
|
|
|
|
|
$linha[] = $value;
|
|
|
|
|
}
|
|
|
|
|
$dataRel[] = $linha;
|
|
|
|
|
|
|
|
|
|
$somaTempo = 0;
|
|
|
|
|
$somaQtde = 0;
|
|
|
|
|
$somaReg = 0;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Linhas de dados.
|
|
|
|
|
*/
|
|
|
|
|
foreach ($this->GetData()[0] as $row) {
|
|
|
|
|
$somaQtde ++;
|
|
|
|
|
$somaTempo += $row["duracao"];
|
|
|
|
|
$somaReg += $row['qtde'];
|
|
|
|
|
|
|
|
|
|
$descricao = explode(" ", $row['tplg_descricao']);
|
|
|
|
|
$this->___verificaTipoLigacao($descricao[1] . ' ' . $descricao[2], $row["duracao"]);
|
|
|
|
|
|
|
|
|
|
$row['tmo'] = SecondToStrTime(round($row["duracao"] / $row['qtde']));
|
|
|
|
|
$row["duracao"] = SecondToStrTime($row["duracao"]);
|
|
|
|
|
|
|
|
|
|
// Formata linha de dados.
|
|
|
|
|
$linha = array('DADOS');
|
|
|
|
|
foreach ($dadosField as $key) {
|
|
|
|
|
$linha[] = $row["$key"];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$dataRel[] = $linha;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$dataRel[] = array('LABEL', 'Total: ' . $somaQtde, '', '', '', 'Duracao: ' . SecondToStrTime($somaTempo), 'TMO: ' . SecondToStrTime(round($somaTempo / $somaQtde)), 'Registros: ' . $somaQtde);
|
|
|
|
|
|
|
|
|
|
$dataRel[] = array('LABEL', '', '', '', '', '', '');
|
|
|
|
|
$totalCabecalio = array('Tipo', 'Quantidade', 'Tempo');
|
|
|
|
|
|
|
|
|
|
$linhaTotal = array('LABEL');
|
|
|
|
|
foreach ($totalCabecalio as $value) {
|
|
|
|
|
$linhaTotal[] = $value;
|
|
|
|
|
}
|
|
|
|
|
$dataRel[] = $linhaTotal;
|
|
|
|
|
|
|
|
|
|
$linhaTotal = array('DADOS');
|
|
|
|
|
foreach ($this->___tiposLigacao as $key => $value) {
|
|
|
|
|
$dataRel[] = array('DADOS', $value['descricao'], $value['quantidade'], $value['duracao']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$dataRel[] = $linhaTotal;
|
|
|
|
|
|
|
|
|
|
$this->___dataRel[] = $dataRel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function ___PreparaGrid() {
|
|
|
|
|
$dataRel = array();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$dadosCabecalio = array(
|
|
|
|
|
'DDD' => 'align="center"',
|
|
|
|
|
'UF' => 'align="center"',
|
|
|
|
|
'Regi<EFBFBD>o' => 'align="left"',
|
|
|
|
|
'Tipo' => 'align="left"',
|
|
|
|
|
'Dura<EFBFBD><EFBFBD>o' => 'align="center"',
|
|
|
|
|
'TMO' => 'align="center"',
|
|
|
|
|
'Quantidade' => 'align="center"'
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$dadosField = array(
|
|
|
|
|
'ddd' => 'align="center"',
|
|
|
|
|
'uf' => 'align="center"',
|
|
|
|
|
'nome_municipio' => 'align="left"',
|
|
|
|
|
'tplg_descricao' => 'align="left"',
|
|
|
|
|
'duracao' => 'align="center"',
|
|
|
|
|
'tmo' => 'align="center"',
|
|
|
|
|
'qtde' => 'align="center"'
|
|
|
|
|
);
|
|
|
|
|
/*
|
|
|
|
|
* Inicia o relat<EFBFBD>rio.
|
|
|
|
|
*/
|
|
|
|
|
$dataRel[] = '<table width="70%" 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) - 1, (!IsPostBack() ? 'Informe os parametros e clique em consultar!' : 'Nenhum registro encontado!'));
|
|
|
|
|
$this->___dataRel[] = $dataRel;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$somaTempo = 0;
|
|
|
|
|
$somaReg = 0;
|
|
|
|
|
$somaQtde = 0;
|
|
|
|
|
/*
|
|
|
|
|
* Linhas de dados.
|
|
|
|
|
*/
|
|
|
|
|
foreach ($this->GetData()[0] as $row) {
|
|
|
|
|
$somaTempo += $row["duracao"];
|
|
|
|
|
$somaQtde++;
|
|
|
|
|
$somaReg += $row['qtde'];
|
|
|
|
|
|
|
|
|
|
$descricao = explode(" ", $row['tplg_descricao']);
|
|
|
|
|
$this->___verificaTipoLigacao($descricao[1] . ' ' . $descricao[2], $row["duracao"]);
|
|
|
|
|
|
|
|
|
|
$row["tmo"] = SecondToStrTime(round($row["duracao"] / $row['qtde']));
|
|
|
|
|
$row["duracao"] = SecondToStrTime($row["duracao"]);
|
|
|
|
|
|
|
|
|
|
// 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="center">Dura<EFBFBD><EFBFBD>o: %s</th><th align="center">TMO: %s</th><th align="center">Registros: %s</th></tr>';
|
|
|
|
|
$dataRel[] = sprintf($linha, $somaQtde, SecondToStrTime($somaTempo), SecondToStrTime(round($somaTempo / $somaReg)), $somaReg);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Fecha relatorio.
|
|
|
|
|
*/
|
|
|
|
|
$dataRel[] = '</table>';
|
|
|
|
|
|
|
|
|
|
$linhaTotalizador = "<table width=\"70%\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\" class=\"grid\">";
|
|
|
|
|
$linhaTotalizador .= "<tr><th colspan=\"3\" align=\"center\">Totalização por Tipo</th></tr>";
|
|
|
|
|
$linhaTotalizador .= "<tr><th align=\"center\">Tipo</th><th align=\"center\">Quantidade</th><th align=\"center\">Tempo</th></tr>";
|
|
|
|
|
$linhaTotalizador .= sprintf("<tr><th align=\"left\" width=\"250\">Chamadas Interurbano</th><td align=\"center\">%s</td><td align=\"center\">%s</td></tr>", $this->___tiposLigacao[0]['quantidade'], SecondToStrTime($this->___tiposLigacao[0]['tempo']));
|
|
|
|
|
$linhaTotalizador .= sprintf("<tr><th align=\"left\">Chamadas Interurbano M<EFBFBD>vel</th><td align=\"center\">%s</td><td align=\"center\">%s</td></tr>", $this->___tiposLigacao[3]['quantidade'], SecondToStrTime($this->___tiposLigacao[3]['tempo']));
|
|
|
|
|
$linhaTotalizador .= sprintf("<tr><th align=\"left\">Chamadas Local</th><td align=\"center\">%s</td><td align=\"center\">%s</td></tr>", $this->___tiposLigacao[1]['quantidade'], SecondToStrTime($this->___tiposLigacao[1]['tempo']));
|
|
|
|
|
$linhaTotalizador .= sprintf("<tr><th align=\"left\">Chamadas Local M<EFBFBD>vel</th><td align=\"center\">%s</td><td align=\"center\">%s</td></tr>", $this->___tiposLigacao[2]['quantidade'], SecondToStrTime($this->___tiposLigacao[2]['tempo']));
|
|
|
|
|
$linhaTotalizador .= sprintf("<tr><th align=\"left\">C.I.E.I.V</th><td align=\"center\">%s</td align=\"center\"><td align=\"center\">%s</td></tr>", $this->___tiposLigacao[4]['quantidade'], SecondToStrTime($this->___tiposLigacao[4]['tempo']));
|
|
|
|
|
$linhaTotalizador .= sprintf("<tr><th align=\"left\">Total Chamadas DDD</th><td align=\"center\">%s</td align=\"center\"><td align=\"center\">%s</td></tr>", $this->___tiposLigacao[5]['quantidade'], SecondToStrTime($this->___tiposLigacao[5]['tempo']));
|
|
|
|
|
$linhaTotalizador .= "</table>";
|
|
|
|
|
$dataRel[] = $linhaTotalizador;
|
|
|
|
|
$this->___dataRel[] = $dataRel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function ___PreparaHtml() {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function ___PreparaPdf() {
|
|
|
|
|
list($this->___dac, $this->___dataIni, $this->___dataFim) = $_SESSION["SSstorageFiltros"];
|
|
|
|
|
/**
|
|
|
|
|
* TABELA DADOS PRINCIPAIS
|
|
|
|
|
*/
|
|
|
|
|
$somaQtde = 0;
|
|
|
|
|
$somaTempo = 0;
|
|
|
|
|
$somaReg = 0;
|
|
|
|
|
$dados = array();
|
|
|
|
|
$x = 0;
|
|
|
|
|
|
|
|
|
|
//HEADER DA TABELA DO PDF -> DADOS EM ARRAY
|
|
|
|
|
$header = array(
|
|
|
|
|
'DDD' => 'C',
|
|
|
|
|
'UF' => 'C',
|
|
|
|
|
'Regi<EFBFBD>o' => 'C',
|
|
|
|
|
'Tipo' => 'C',
|
|
|
|
|
'Dura<EFBFBD><EFBFBD>o' => 'C',
|
|
|
|
|
'TMO' => 'C',
|
|
|
|
|
'Quantidade' => 'C'
|
|
|
|
|
);
|
|
|
|
|
$dataHeader = array(
|
|
|
|
|
'ddd' => 'C',
|
|
|
|
|
'uf' => 'C',
|
|
|
|
|
'nome_municipio' => 'C',
|
|
|
|
|
'tplg_descricao' => 'C',
|
|
|
|
|
'duracao' => 'C',
|
|
|
|
|
'tmo' => 'C',
|
|
|
|
|
'qtde' => 'C'
|
|
|
|
|
);
|
|
|
|
|
foreach ($this->GetData()[0] as $row) {
|
|
|
|
|
$somaTempo += $row["duracao"];
|
|
|
|
|
$somaQtde++;
|
|
|
|
|
$somaReg += $row['qtde'];
|
|
|
|
|
|
|
|
|
|
$descricao = explode(" ", $row['tplg_descricao']);
|
|
|
|
|
$this->___verificaTipoLigacao($descricao[1] . ' ' . $descricao[2], $row["duracao"]);
|
|
|
|
|
|
|
|
|
|
$dados[$x]["tmo"] = SecondToStrTime(round($row["duracao"] / $row['qtde']));
|
|
|
|
|
$dados[$x]["duracao"] = SecondToStrTime($row["duracao"]);
|
|
|
|
|
$dados[$x]["ddd"] = $row["ddd"];
|
|
|
|
|
$dados[$x]["uf"] = $row["uf"];
|
|
|
|
|
$dados[$x]["nome_municipio"] = $row["nome_municipio"];
|
|
|
|
|
$dados[$x]["qtde"] = $row["qtde"];
|
|
|
|
|
$dados[$x]["tplg_descricao"] = $row["tplg_descricao"];
|
|
|
|
|
$x++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$widthHeader = array(20, 20, 45, 30, 25, 25);
|
|
|
|
|
//Monta o array para passar para o prepara; Necess<EFBFBD>rio passar 6 parametros
|
|
|
|
|
$table1 = array($header, $dataHeader, $dados, $widthHeader, 0, 0);
|
|
|
|
|
|
|
|
|
|
//Tabela do Totalizador com os Dados
|
|
|
|
|
$headerTotal = array(
|
|
|
|
|
'Tipo' => 'C',
|
|
|
|
|
'Quantidade' => 'C',
|
|
|
|
|
'Tempo' => 'C'
|
|
|
|
|
);
|
|
|
|
|
$dataHdTotal = array(
|
|
|
|
|
'descricao' => 'C',
|
|
|
|
|
'quantidade' => 'C',
|
|
|
|
|
'duracao' => 'C'
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$widthTotal = array(63, 63, 63);
|
|
|
|
|
$table2 = array($headerTotal, $dataHdTotal, $this->___tiposLigacao, $widthTotal, 0, 0);
|
|
|
|
|
|
|
|
|
|
$this->___dataRel = array($table1, $table2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Fun<EFBFBD><EFBFBD>o para n<EFBFBD>o ser reescrita n<EFBFBD>o opera<EFBFBD><EFBFBD>es de impress<EFBFBD>es, al<EFBFBD>m de varer e calcular os tipos de liga<EFBFBD><EFBFBD>es
|
|
|
|
|
* compostas no totalizador!
|
|
|
|
|
*/
|
|
|
|
|
protected function ___verificaTipoLigacao($tipo, $tempo) {
|
|
|
|
|
switch (strtoupper($tipo)) {
|
|
|
|
|
case "FIXO INTERURBANO":
|
|
|
|
|
$this->___tiposLigacao[0]['quantidade'] ++;
|
|
|
|
|
$this->___tiposLigacao[0]['tempo'] += $tempo;
|
|
|
|
|
$this->___tiposLigacao[0]['duracao'] = SecondToStrTime($this->___tiposLigacao[0]['tempo']);
|
|
|
|
|
break;
|
|
|
|
|
case "FIXO LOCAL":
|
|
|
|
|
$this->___tiposLigacao[1]['quantidade'] ++;
|
|
|
|
|
$this->___tiposLigacao[1]['tempo'] += $tempo;
|
|
|
|
|
$this->___tiposLigacao[1]['duracao'] = SecondToStrTime($this->___tiposLigacao[1]['tempo']);
|
|
|
|
|
break;
|
|
|
|
|
case "MOVEL LOCAL":
|
|
|
|
|
$this->___tiposLigacao[2]['quantidade'] ++;
|
|
|
|
|
$this->___tiposLigacao[2]['tempo'] += $tempo;
|
|
|
|
|
$this->___tiposLigacao[2]['duracao'] = SecondToStrTime($this->___tiposLigacao[2]['tempo']);
|
|
|
|
|
break;
|
|
|
|
|
case "MOVEL INTERURBANO":
|
|
|
|
|
$this->___tiposLigacao[3]['quantidade'] ++;
|
|
|
|
|
$this->___tiposLigacao[3]['tempo'] += $tempo;
|
|
|
|
|
$this->___tiposLigacao[3]['duracao'] = SecondToStrTime($this->___tiposLigacao[3]['tempo']);
|
|
|
|
|
break;
|
|
|
|
|
default :
|
|
|
|
|
$this->___tiposLigacao[4]['quantidade'] ++;
|
|
|
|
|
$this->___tiposLigacao[4]['tempo'] += $tempo;
|
|
|
|
|
$this->___tiposLigacao[4]['duracao'] = SecondToStrTime($this->___tiposLigacao[4]['tempo']);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->___tiposLigacao[5]['quantidade'] ++;
|
|
|
|
|
$this->___tiposLigacao[5]['tempo'] += $tempo;
|
|
|
|
|
$this->___tiposLigacao[5]['duracao'] = SecondToStrTime($this->___tiposLigacao[5]['tempo']);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function ExecutaRelatorio() {
|
|
|
|
|
global $jsStartup, $jsJQuery, $smarty;
|
|
|
|
|
try {
|
|
|
|
|
/*
|
|
|
|
|
* Use esta fun<EFBFBD><EFBFBD>o para validar dados do formul<EFBFBD>rio.
|
|
|
|
|
*/
|
|
|
|
|
$this->___ValidaForm();
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Recupera os dados do banco.
|
|
|
|
|
*/
|
|
|
|
|
$this->___ConteudoRelatorio();
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Imprime relat<EFBFBD>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<EFBFBD>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');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$relRcbDDD = new RelRecebidasDDD($idProg, $dbcon, 1);
|
|
|
|
|
$relRcbDDD->ExecutaRelatorio();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
############################################################################
|
|
|
|
|
##################### BACKUP DA QUERY ANTERIOR #####################
|
|
|
|
|
############################################################################
|
|
|
|
|
|
|
|
|
|
$sql = "create temporary table totalizador_ddd as
|
|
|
|
|
select c.id as idDac,
|
|
|
|
|
c.nome as nomeDac,
|
|
|
|
|
case when(b.evento in('COMPLETEAGENT', 'COMPLETECALLER','TRANSFER'))then sonumero(a.src) else sonumero(a.dst) end as fone,
|
|
|
|
|
b.evento,
|
|
|
|
|
a.billsec,
|
|
|
|
|
get_prefixo_fone('$dddDef', case when(b.evento in('COMPLETEAGENT', 'COMPLETECALLER','TRANSFER'))then a.src else a.dst end) as prefixo,
|
|
|
|
|
cast(0 as int) as faixa
|
|
|
|
|
from pbx_bilhetes a, pbx_eventos_dacs b, pbx_dacs c
|
|
|
|
|
where b.uid2 = a.uniqueid
|
|
|
|
|
and c.nome = b.fila
|
|
|
|
|
and a.data_bilhete >= '$dataIin'
|
|
|
|
|
and a.data_bilhete <= '$dataFim'
|
|
|
|
|
and b.evento in('COMPLETEAGENT', 'COMPLETECALLER','TRANSFER', 'COMPLETAAGENT','COMPLETACALLER', 'TRANSFERORIG') -- 'CONNECT'
|
|
|
|
|
and c.id = case when($dac = 0)then c.id else $dac end
|
|
|
|
|
and a.lastapp <> 'Transferred Call'
|
|
|
|
|
and a.id_bilhetes = (select max (l.id_bilhetes) from pbx_bilhetes l where l.uniqueid = a.uniqueid and l.lastapp <> 'Transferred Call' );
|
|
|
|
|
|
|
|
|
|
update totalizador_ddd set faixa = case when(length(fone) >= 8)then strtoint( substring(fone, '....$')) else 0 end;
|
|
|
|
|
|
|
|
|
|
select idDac,
|
|
|
|
|
nomeDac,
|
|
|
|
|
coalesce(b.codigo_ddd, case when(gettipoligacao(fone, $dddDef) in('Local Fixo','Local M<EFBFBD>vel'))then $dddDef else 0 end) as ddd,
|
|
|
|
|
upper( coalesce(b.uf, case when(gettipoligacao(fone, $dddDef) in('Local Fixo','Local M<EFBFBD>vel'))then '$ufPadrao' else 'ni' end)) as uf,
|
|
|
|
|
upper(coalesce(b.nome_municipio, case when(gettipoligacao(fone, $dddDef) in('Local Fixo'))then '$munDef' else gettipoligacao(fone, $dddDef) end)) as nome_municipio,
|
|
|
|
|
sum( case when(a.evento in('COMPLETEAGENT', 'COMPLETECALLER','TRANSFER'))then billsec else 0 end )as tempo_entrante,
|
|
|
|
|
sum( case when(a.evento in('COMPLETEAGENT', 'COMPLETECALLER','TRANSFER'))then 1 else 0 end )as qtde_entrante,
|
|
|
|
|
sum( case when(a.evento in('COMPLETAAGENT','COMPLETACALLER', 'TRANSFERORIG'))then billsec else 0 end)as tempo_sainte,
|
|
|
|
|
sum( case when(a.evento in('COMPLETAAGENT','COMPLETACALLER', 'TRANSFERORIG'))then 1 else 0 end)as qtde_sainte
|
|
|
|
|
from totalizador_ddd a
|
|
|
|
|
left join pbx_consulta_ddd b on b.prefixo = a.prefixo and b.inicial <= a.faixa and b.final >= a.faixa
|
|
|
|
|
where 1=1
|
|
|
|
|
group by 1,2,3,4,5
|
|
|
|
|
order by 4,5 ";
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
?>
|