|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
include_once 'util/relatoriosBase.php';
|
|
|
|
|
|
|
|
|
|
class SaintesGeral extends Relatorios {
|
|
|
|
|
|
|
|
|
|
private $___tipoAtendimento;
|
|
|
|
|
private $___tempoDuracao;
|
|
|
|
|
private $___telefone;
|
|
|
|
|
private $___tipoRecepcao;
|
|
|
|
|
|
|
|
|
|
public function __construct($idProg, $dbcon, $incDac) {
|
|
|
|
|
parent::__construct($idProg, $dbcon, $incDac);
|
|
|
|
|
$this->___tipoAtendimento = isset($_REQUEST['tipoAtendimento']) ? $_REQUEST['tipoAtendimento'] : 1;
|
|
|
|
|
$this->___tempoDuracao = isset($_REQUEST['tempoDuracao']) ? $_REQUEST['tempoDuracao'] : 1;
|
|
|
|
|
$this->___tipoRecepcao = isset($_REQUEST['tipoRecepcao']) ? $_REQUEST['tipoRecepcao'] : 1;
|
|
|
|
|
$this->___telefone = isset($_REQUEST['telefone']) ? $_REQUEST['telefone'] : '';
|
|
|
|
|
$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();
|
|
|
|
|
if (empty($this->___tipoAtendimento)) {
|
|
|
|
|
GeraExcept('Informe um tipo de atendimento!');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (empty($this->___tempoDuracao)) {
|
|
|
|
|
GeraExcept('Informe um tempo de dura<EFBFBD><EFBFBD>o!');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (empty($this->___tipoRecepcao)) {
|
|
|
|
|
GeraExcept('Informe um tipo de recep<EFBFBD><EFBFBD>o!');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($this->___telefone) {
|
|
|
|
|
if (!soNumero($this->___telefone)) {
|
|
|
|
|
GeraExcept('Informe apenas n<EFBFBD>meros no campo de Telefone!');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function ___FiltrosRelatorio() {
|
|
|
|
|
if ($this->___media != MEDIA_PRINT_GRID) {
|
|
|
|
|
/*
|
|
|
|
|
* Recupera os filtros da sess<EFBFBD>o do usu<EFBFBD>rio.
|
|
|
|
|
*/
|
|
|
|
|
list($this->___dataIni, $this->___dataFim) = $_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[] = $this->___telefone ? "Telefone: " . $this->___telefone : '';
|
|
|
|
|
$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<EFBFBD><EFBFBD>o se necessitar de outras op<EFBFBD><EFBFBD>es de filtro.
|
|
|
|
|
*/
|
|
|
|
|
$filtro = '<table class="filtro" border="0" cellspacing="1" cellpadding="1">';
|
|
|
|
|
/*
|
|
|
|
|
* Rotulos.
|
|
|
|
|
*/
|
|
|
|
|
$filtro .= '<tr>';
|
|
|
|
|
$filtro .= '<td> </td>';
|
|
|
|
|
$filtro .= '<td>Data Inicial </td>';
|
|
|
|
|
$filtro .= '<td>Data Final </td>';
|
|
|
|
|
$filtro .= '<td>Dura<EFBFBD><EFBFBD>o</td>';
|
|
|
|
|
$filtro .= '<td>Tipo Atendimento</td>';
|
|
|
|
|
$filtro .= '<td>';
|
|
|
|
|
$filtro .= sprintf('<input name="tipoRecepcao" class="clean" type="radio" value="1" %s>Origem'
|
|
|
|
|
. '<input type="radio" class="clean" name="tipoRecepcao" value="2" %s>Destino'
|
|
|
|
|
. '<input type="radio" class="clean" name="tipoRecepcao" value="3" %s>Ambos'
|
|
|
|
|
. '</td>', $this->___tipoRecepcao == 1 ? 'checked' : '', $this->___tipoRecepcao == 2 ? 'checked' : '', $this->___tipoRecepcao == 3 ? 'checked' : '');
|
|
|
|
|
$filtro .= '<td align="center" valign="middle"> </td>';
|
|
|
|
|
$filtro .= '</tr>';
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Valores.
|
|
|
|
|
*/
|
|
|
|
|
$filtro .= '<tr>'
|
|
|
|
|
. '<td> </td>';
|
|
|
|
|
$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><div class="geral"> ';
|
|
|
|
|
$filtro .= sprintf('<input name="tempoDuracao" class="clean" type="radio" id="tempoDuracao" value="1" %s>Todos'
|
|
|
|
|
. '<input name="tempoDuracao" class="clean" type="radio" id="tempoDuracao" value="2" %s>maior que(>0)'
|
|
|
|
|
. '<input name="tempoDuracao" class="clean" type="radio" id="tempoDuracao" value="3" %s>Igual a 0 (= 0)', $this->___tempoDuracao == 1 ? 'checked' : '', $this->___tempoDuracao == 2 ? 'checked' : '', $this->___tempoDuracao == 3 ? 'checked' : '');
|
|
|
|
|
$filtro .= '</div></td>';
|
|
|
|
|
$filtro .= sprintf('<td><div class="geral"> '
|
|
|
|
|
. '<input name="tipoAtendimento" class="clean" type="radio" id="tipoAtendimento" value="1" %s>Ambos'
|
|
|
|
|
. '<input name="tipoAtendimento" class="clean" type="radio" id="tipoAtendimento" value="2" %s>Atendida'
|
|
|
|
|
. '<input name="tipoAtendimento" class="clean" type="radio" id="tipoAtendimento" value="3" %s>N<EFBFBD>o Atendida'
|
|
|
|
|
. '</div></td>', $this->___tipoAtendimento == 1 ? 'checked' : '', $this->___tipoAtendimento == 2 ? 'checked' : '', $this->___tipoAtendimento == 3 ? 'checked' : '');
|
|
|
|
|
$filtro .= '<td><input name="telefone" type="text" id="telefone"/></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?ios para impress<EFBFBD>o.
|
|
|
|
|
*/
|
|
|
|
|
$_SESSION["SSstorageFiltros"] = array($this->___dataIni, $this->___dataFim, $this->___telefone);
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
$telefone = $this->___telefone;
|
|
|
|
|
$duracao = $this->___tempoDuracao;
|
|
|
|
|
$tipoAtendimento = $this->___tipoAtendimento;
|
|
|
|
|
$fonePesquisa = $this->___tipoRecepcao;
|
|
|
|
|
|
|
|
|
|
$query = sprintf("select a.uniqueid, a.calldate, a.src, a.dst, case when(d.evento = 'ABANDON')then strtoint(d.param3) else a.billsec end as tempo_atendimento, coalesce(d.fila, '-') as fila, coalesce(e.apelido, '-') as agente,
|
|
|
|
|
d.evento, case when(tplg_codigo in(33,34))then 'M<EFBFBD>VEL' else c.nome_municipio end as nome_municipio, c.uf, b.tplg_descricao,
|
|
|
|
|
case when((d.evento in('COMPLETEAGENT','COMPLETECALLER') and (billsec > 3) ) or ((d.evento is null) and (billsec > 3)))then 'ATENDIDA' else 'N ATENDIDA' end as status
|
|
|
|
|
from pbx_bilhetes a
|
|
|
|
|
inner join pbx_tipo_ligacao b on b.tplg_codigo = a.tipo_chamada
|
|
|
|
|
inner join pbx_municipios c on c.id = a.id_municipio
|
|
|
|
|
left join pbx_eventos_dacs d on d.uid2 = a.uniqueid and d.evento in('COMPLETEAGENT','COMPLETECALLER','ABANDON')
|
|
|
|
|
left join pbx_usuarios e on e.matricula = substring(d.agente,7,4)
|
|
|
|
|
where b.tplg_tipo = 3
|
|
|
|
|
AND a.calldate = (SELECT MAX(calldate) FROM pbx_bilhetes WHERE uniqueid = a.uniqueid)
|
|
|
|
|
and a.calldate::timestamp >= '%s'
|
|
|
|
|
and a.calldate::timestamp <= '%s'
|
|
|
|
|
and a.lastapp <> 'Transferred Call'", $dataIni, $dataFim);
|
|
|
|
|
|
|
|
|
|
if (!empty($telefone) && ($fonePesquisa == 1))
|
|
|
|
|
$query .= sprintf(" AND a.src LIKE '%s' ", PreparaLike($telefone));
|
|
|
|
|
else if (!empty($telefone) && ($fonePesquisa == 2))
|
|
|
|
|
$query .= sprintf(" AND a.dst LIKE '%s' ", PreparaLike($telefone));
|
|
|
|
|
else if (!empty($telefone) && ($fonePesquisa == 3))
|
|
|
|
|
$query .= sprintf(" AND (a.dst LIKE '%s' OR src LIKE '%s') ", PreparaLike($telefone), PreparaLike($telefone));
|
|
|
|
|
|
|
|
|
|
if ($duracao == 2) {
|
|
|
|
|
$query .= " AND a.billsec > 0 ";
|
|
|
|
|
}
|
|
|
|
|
if ($duracao == 3) {
|
|
|
|
|
$query .= " AND a.billsec = 0 ";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($tipoAtendimento == 2) {
|
|
|
|
|
$query .= "AND ((d.evento IN('COMPLETEAGENT','COMPLETECALLER') AND (billsec > 3) ) OR ((d.evento is null) AND (billsec > 3)))";
|
|
|
|
|
}
|
|
|
|
|
if ($tipoAtendimento == 3) {
|
|
|
|
|
$query .= "AND ((d.evento NOT IN('COMPLETEAGENT','COMPLETECALLER')) OR (billsec <= 3))";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$query .= " ORDER BY a.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' => 'align="center"',
|
|
|
|
|
'Origem' => 'align="left"',
|
|
|
|
|
'Destino' => 'align="left"',
|
|
|
|
|
'Tipo' => 'align="left"',
|
|
|
|
|
'Duracao' => 'align="center"',
|
|
|
|
|
'Atendida' => 'align="center"',
|
|
|
|
|
'Fila' => 'align="left"',
|
|
|
|
|
'Agente' => 'align="left"',
|
|
|
|
|
'Municipio' => 'align="left"',
|
|
|
|
|
'UF' => 'align="center"'
|
|
|
|
|
);
|
|
|
|
|
$dadosField = array(
|
|
|
|
|
'calldate' => 'align="center"',
|
|
|
|
|
'src' => 'align="left"',
|
|
|
|
|
'dst' => 'align="left"',
|
|
|
|
|
'tplg_descricao' => 'align="left"',
|
|
|
|
|
'tempo_atendimento' => 'align="center"',
|
|
|
|
|
'status' => 'align="center"',
|
|
|
|
|
'fila' => 'align="left"',
|
|
|
|
|
'agente' => 'align="left"',
|
|
|
|
|
'nome_municipio' => 'align="left"',
|
|
|
|
|
'uf' => 'align="center"'
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$dataRel[] = GenerateCsvFromArray(array_keys($dadosCabecalio));
|
|
|
|
|
|
|
|
|
|
$somaTempo = 0;
|
|
|
|
|
$somaQuantidade = 0;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Inicia o relat<EFBFBD>rio.
|
|
|
|
|
*/
|
|
|
|
|
foreach ($this->GetData()[0] as $row) {
|
|
|
|
|
|
|
|
|
|
$row["calldate"] = date('d/m/Y H:i', strtotime($row["calldate"]));
|
|
|
|
|
$row["tplg_descricao"] = str_replace("Entrada", "", $row["tplg_descricao"]);
|
|
|
|
|
$row["status"] = $row["status"] == 'ATENDIDA' ? 'S' : 'N';
|
|
|
|
|
$somaTempo += $row["tempo_atendimento"];
|
|
|
|
|
$row["tempo_atendimento"] = SecondToStrTime($row["tempo_atendimento"]);
|
|
|
|
|
$row["nome_municipio"] = $row['nome_municipio'] == "CHAMADAS NAO IDENTIFICADAS" ? 'NI' : RemoveAcentos($row['nome_municipio']);
|
|
|
|
|
$somaQuantidade ++;
|
|
|
|
|
|
|
|
|
|
$linha = array();
|
|
|
|
|
foreach ($dadosField as $key => $value) {
|
|
|
|
|
$linha[] = $row["$key"];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$dataRel[] = GenerateCsvFromArray($linha);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$dataRel[] = $linha;
|
|
|
|
|
|
|
|
|
|
$linha1 = array('Total', '', '', 'Registros: '.$somaQuantidade, 'Duracao: '.SecondToStrTime($somaTempo));
|
|
|
|
|
$dataRel[] = GenerateCsvFromArray($linha1);
|
|
|
|
|
$dataRel[] = $linha1;
|
|
|
|
|
|
|
|
|
|
$this->___dataRel[] = $dataRel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function ___PreparaExcel() {
|
|
|
|
|
$dataRel = array();
|
|
|
|
|
$dataAgrup = 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('Data/Hora', 'Origem', 'Destino', 'Tipo', 'Duracao', 'Atendida', 'Fila', 'Agente', 'Municipio', 'UF');
|
|
|
|
|
$dadosField = array('calldate', 'src', 'dst', 'tplg_descricao', 'tempo_atendimento', 'status', 'fila', 'agente', 'nome_municipio', 'uf');
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Monta a linha de cabecalio.
|
|
|
|
|
*/
|
|
|
|
|
$linha = array('LABEL');
|
|
|
|
|
foreach ($dadosCabecalio as $value) {
|
|
|
|
|
$linha[] = $value;
|
|
|
|
|
}
|
|
|
|
|
$dataRel[] = $linha;
|
|
|
|
|
|
|
|
|
|
$somaTempo = 0;
|
|
|
|
|
$somaQuantidade = 0;
|
|
|
|
|
/*
|
|
|
|
|
* Linhas de dados.
|
|
|
|
|
*/
|
|
|
|
|
foreach ($this->GetData()[0] as $row) {
|
|
|
|
|
|
|
|
|
|
$row["calldate"] = date('d/m/Y H:i', strtotime($row["calldate"]));
|
|
|
|
|
$row["tplg_descricao"] = str_replace("Entrada", "", $row["tplg_descricao"]);
|
|
|
|
|
$row["status"] = $row["status"] == 'ATENDIDA' ? 'S' : 'N';
|
|
|
|
|
$somaTempo += $row["tempo_atendimento"];
|
|
|
|
|
$row["tempo_atendimento"] = SecondToStrTime($row["tempo_atendimento"]);
|
|
|
|
|
$row["nome_municipio"] = $row['nome_municipio'] == "CHAMADAS NAO IDENTIFICADAS" ? 'NI' : RemoveAcentos($row['nome_municipio']);
|
|
|
|
|
$somaQuantidade ++;
|
|
|
|
|
|
|
|
|
|
// Formata linha de dados.
|
|
|
|
|
$linha = array('DADOS');
|
|
|
|
|
foreach ($dadosField as $key) {
|
|
|
|
|
$linha[] = $row["$key"];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$dataRel[] = $linha;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$linha = array('LABEL', 'Total', '', '', 'Registros: '.$somaQuantidade, 'Duracao: '.SecondToStrTime($somaTempo));
|
|
|
|
|
|
|
|
|
|
$dataRel[] = $linha;
|
|
|
|
|
|
|
|
|
|
$this->___dataRel[] = $dataRel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function ___PreparaGrid() {
|
|
|
|
|
$dadosCabecalio = array(
|
|
|
|
|
'Data/Hora' => 'align="center"',
|
|
|
|
|
'Origem' => 'align="left"',
|
|
|
|
|
'Destino' => 'align="left"',
|
|
|
|
|
'Tipo' => 'align="left"',
|
|
|
|
|
'Dura<EFBFBD><EFBFBD>o' => 'align="center"',
|
|
|
|
|
'Atendida' => 'align="center"',
|
|
|
|
|
'Fila' => 'align="left"',
|
|
|
|
|
'Agente' => 'align="left"',
|
|
|
|
|
'Munic<EFBFBD>pio' => 'align="left"',
|
|
|
|
|
'UF' => 'align="center"'
|
|
|
|
|
);
|
|
|
|
|
$dadosField = array(
|
|
|
|
|
'calldate' => 'align="center"',
|
|
|
|
|
'src' => 'align="left"',
|
|
|
|
|
'dst' => 'align="left"',
|
|
|
|
|
'tplg_descricao' => 'align="left"',
|
|
|
|
|
'tempo_atendimento' => 'align="center"',
|
|
|
|
|
'status' => 'align="center"',
|
|
|
|
|
'fila' => 'align="left"',
|
|
|
|
|
'agente' => 'align="left"',
|
|
|
|
|
'nome_municipio' => 'align="left"',
|
|
|
|
|
'uf' => 'align="center"'
|
|
|
|
|
);
|
|
|
|
|
/*
|
|
|
|
|
* Inicia o relat<EFBFBD>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) - 1, (!IsPostBack() ? 'Informe os parametros e clique em consultar!' : 'Nenhum registro encontado!'));
|
|
|
|
|
$this->___dataRel[] = $dataRel;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$somaTempo = 0;
|
|
|
|
|
$somaQuantidade = 0;
|
|
|
|
|
/*
|
|
|
|
|
* Linhas de dados.
|
|
|
|
|
*/
|
|
|
|
|
foreach ($this->GetData()[0] as $row) {
|
|
|
|
|
$row['dst'] = ocultarTelefone($row['dst']);
|
|
|
|
|
$row["calldate"] = date('d/m/Y H:i', strtotime($row["calldate"]));
|
|
|
|
|
$row["tplg_descricao"] = str_replace("Fixo Entrada", "", $row["tplg_descricao"]);
|
|
|
|
|
$row["status"] = $row["status"] == 'ATENDIDA' ? 'S' : 'N';
|
|
|
|
|
$somaTempo += $row["tempo_atendimento"];
|
|
|
|
|
$row["tempo_atendimento"] = SecondToStrTime($row["tempo_atendimento"]);
|
|
|
|
|
$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="2" align="left">Total</th><th align="left" colspan="2">Registros: %s</th><th align="left" colspan="6">Dura<EFBFBD><EFBFBD>o: %s</th></tr>';
|
|
|
|
|
$dataRel[] = sprintf($linha, $somaQuantidade, SecondToStrTime($somaTempo));
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Fecha relatorio.
|
|
|
|
|
*/
|
|
|
|
|
$dataRel[] = '</table>';
|
|
|
|
|
$this->___dataRel[] = $dataRel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function ___PreparaHtml() {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function ___PreparaPdf() {
|
|
|
|
|
list($this->___dataIni, $this->___dataFim) = $_SESSION["SSstorageFiltros"];
|
|
|
|
|
|
|
|
|
|
$dados = array();
|
|
|
|
|
$x = 0;
|
|
|
|
|
$somaQtd = 0;
|
|
|
|
|
foreach ($this->GetData()[0] as $row) {
|
|
|
|
|
$dados[$x]["calldate"] = date('d/m/Y H', strtotime($row["calldate"]));
|
|
|
|
|
$dados[$x]["src"] = $row["src"];
|
|
|
|
|
$dados[$x]["dst"] = $row["dst"];
|
|
|
|
|
$dados[$x]["tplg_descricao"] = str_replace('Entrada', '', $row["tplg_descricao"]);
|
|
|
|
|
$somaTempo += $row["tempo_atendimento"];
|
|
|
|
|
$dados[$x]["tempo_atendimento"] = SecondToStrTime($row["tempo_atendimento"]);
|
|
|
|
|
$dados[$x]["status"] = $row["status"] == 'ATENDIDA' ? 'S' : 'N';
|
|
|
|
|
$dados[$x]["fila"] = $row["fila"];
|
|
|
|
|
$dados[$x]["agente"] = $row["agente"];
|
|
|
|
|
$dados[$x]["nome_municipio"] = $row['nome_municipio'] == "CHAMADAS NAO IDENTIFICADAS" ? 'NI' : $row['nome_municipio'];
|
|
|
|
|
$dados[$x]["uf"] = $row['uf'];
|
|
|
|
|
$somaQtd ++;
|
|
|
|
|
$x++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//HEADER DA TABELA DO PDF -> DADOS EM ARRAY
|
|
|
|
|
$header = array(
|
|
|
|
|
'Data/Hora' => 'C',
|
|
|
|
|
'Origem' => 'L',
|
|
|
|
|
'Destino' => 'L',
|
|
|
|
|
'Tipo' => 'L',
|
|
|
|
|
'Dura<EFBFBD><EFBFBD>o' => 'C',
|
|
|
|
|
'Atend.' => 'C',
|
|
|
|
|
'Fila' => 'L',
|
|
|
|
|
'Agente' => 'L',
|
|
|
|
|
'Munic<EFBFBD>pio' => 'L',
|
|
|
|
|
'UF' => 'C');
|
|
|
|
|
$dataHeader = array(
|
|
|
|
|
'calldate' => 'C',
|
|
|
|
|
'src' => 'L',
|
|
|
|
|
'dst' => 'L',
|
|
|
|
|
'tplg_descricao' => 'L',
|
|
|
|
|
'tempo_atendimento' => 'C',
|
|
|
|
|
'status' => 'C',
|
|
|
|
|
'fila' => 'L',
|
|
|
|
|
'agente' => 'L',
|
|
|
|
|
'nome_municipio' => 'L',
|
|
|
|
|
'uf' => 'C'
|
|
|
|
|
);
|
|
|
|
|
$widthHeader = array(20, 25, 15, 25, 15, 10, 20, 20, 30, 10);
|
|
|
|
|
$totaliza = array('Total', "Registros: ", $somaQtd, 'Dura<EFBFBD><EFBFBD>o:', SecondToStrTime($somaTempo), '', '', '', '', '');
|
|
|
|
|
|
|
|
|
|
//Monta o array para passar para o prepara; Necess<EFBFBD>rio passar 6 parametros
|
|
|
|
|
$table1 = array($header, $dataHeader, $dados, $widthHeader, $totaliza, 0);
|
|
|
|
|
|
|
|
|
|
$this->___dataRel = array($table1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$relSaintes = new SaintesGeral($idProg, $dbcon, null);
|
|
|
|
|
$relSaintes->ExecutaRelatorio();
|
|
|
|
|
|