|
|
|
|
<?php
|
|
|
|
|
// *************************************************************************
|
|
|
|
|
// *
|
|
|
|
|
// * PBX Chamadas Ramal
|
|
|
|
|
// * Autor
|
|
|
|
|
// * Lucas Awade
|
|
|
|
|
// *
|
|
|
|
|
// *************************************************************************
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
|
|
Defini<EFBFBD><EFBFBD>es do Projeto
|
|
|
|
|
Nome: RelChamadasRamal
|
|
|
|
|
Data in<EFBFBD>cio: 14/09/2018
|
|
|
|
|
Equipe: Amarildo Pereira
|
|
|
|
|
Descri<EFBFBD><EFBFBD>o:
|
|
|
|
|
O relat<EFBFBD>rio tem a finalidade de apresentar todas as chamadas na fila com
|
|
|
|
|
o ramal estatico. De acordo com o ramal cadastrado na fila.
|
|
|
|
|
|
|
|
|
|
OBS: Caso o ramal passe para outra fila como estatico ambas as filas iram
|
|
|
|
|
apresentar as informa<EFBFBD><EFBFBD>es com o mesmo ramal.
|
|
|
|
|
|
|
|
|
|
// *************************************************************************
|
|
|
|
|
// * Copyright (c) 2018, Simples IP
|
|
|
|
|
// *************************************************************************/
|
|
|
|
|
include_once 'util/relatoriosBase.php';
|
|
|
|
|
|
|
|
|
|
class RelChamadasRamal extends Relatorios {
|
|
|
|
|
|
|
|
|
|
private $___ramal;
|
|
|
|
|
|
|
|
|
|
public function __construct($idProg, $dbcon, $incDac) {
|
|
|
|
|
parent::__construct($idProg, $dbcon, $incDac);
|
|
|
|
|
$this->___ramal = isset($_POST["numeroRamal"]) ? $_POST["numeroRamal"] : '';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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 op<EFBFBD><EFBFBD>es de filtro.
|
|
|
|
|
*/
|
|
|
|
|
$filtro = '<table border="0" cellspacing="1" cellpadding="1">';
|
|
|
|
|
/*
|
|
|
|
|
* Rotulos.
|
|
|
|
|
*/
|
|
|
|
|
$filtro .= '<tr>';
|
|
|
|
|
if ($this->GetIncDac())
|
|
|
|
|
$filtro .= '<td>Fila</td>';
|
|
|
|
|
$filtro .= '<td>Data Inicial</td>';
|
|
|
|
|
$filtro .= '<td>Data Final </td>';
|
|
|
|
|
$filtro .= '<td>Ramal</td>';
|
|
|
|
|
$filtro .= '<td align="center" valign="middle"> </td>';
|
|
|
|
|
$filtro .= '</tr>';
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Valores.
|
|
|
|
|
*/
|
|
|
|
|
$filtro .= '<tr>';
|
|
|
|
|
if ($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 .= sprintf('<td><input name="numeroRamal" id="ramal" type="text" size="15" value="%s" /></td>', $this->___ramal);
|
|
|
|
|
$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>ios para impress<EFBFBD>o.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
$_SESSION["SSstorageFiltros"] = array($this->___dac, $this->___dataIni, $this->___dataFim, $this->___tipoRelatorio, $this->___agente);
|
|
|
|
|
|
|
|
|
|
return sprintf($filtro, $this->___dataIni, $this->___dataFim, $lkPrint);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function ___GetDadosDb() {
|
|
|
|
|
|
|
|
|
|
$dataIni = FormatDtMssql($this->___dataIni);
|
|
|
|
|
$dataFim = FormatDtMssql($this->___dataFim);
|
|
|
|
|
$ramal = $this->___ramal;
|
|
|
|
|
$dac = $this->___dac;
|
|
|
|
|
|
|
|
|
|
$query = "drop TABLE IF EXISTS chamadas_ramal;
|
|
|
|
|
create temporary table chamadas_ramal(ramal varchar(25), transbordando int not null default 0,qt_entra int not null default 0, dura_entra int not null default 0, qt_sai int not null default 0, dura_sai int not null default 0);
|
|
|
|
|
create unique index \"chamadasRamalRamal\" on chamadas_ramal(ramal);
|
|
|
|
|
|
|
|
|
|
drop TABLE IF EXISTS chamadas_ramal_saite;
|
|
|
|
|
create temporary table chamadas_ramal_saite(ramal varchar(25), qt_sai int not null default 0, dura_sai int not null default 0);
|
|
|
|
|
create unique index \"chamadasRamalRamalSainte\" on chamadas_ramal_saite(ramal);
|
|
|
|
|
|
|
|
|
|
insert into chamadas_ramal(ramal, qt_entra, dura_entra,transbordando)
|
|
|
|
|
select (case when b.evento in('COMPLETECALLER', 'COMPLETEAGENT', 'TRANSFER')then substring(b.agente,5)
|
|
|
|
|
else
|
|
|
|
|
(CASE WHEN (b.evento IN('TRANSBORDANDO'))then a.src else a.dst end) end) as ramal,
|
|
|
|
|
count(a.*), sum(a.billsec),
|
|
|
|
|
SUM (CASE WHEN EVENTO IN ('TRANSBORDANDO') THEN 1 ELSE 0 END) AS TRANSBORDANDO
|
|
|
|
|
from pbx_bilhetes a
|
|
|
|
|
left join pbx_eventos_dacs b on b.uid2 = a.uniqueid and b.evento IN('COMPLETECALLER', 'COMPLETEAGENT', 'TRANSFER','TRANSBORDANDO')
|
|
|
|
|
left join pbx_dacs c on c.nome = b.fila
|
|
|
|
|
inner join pbx_ramais d on (case when b.evento IN('COMPLETECALLER', 'COMPLETEAGENT', 'TRANSFER') then d.nome = substring(b.agente,5) else d.nome = a.src end)
|
|
|
|
|
where a.billsec > 3
|
|
|
|
|
and a.id_bilhetes = (select max (l.id_bilhetes) from pbx_bilhetes l where l.uniqueid = a.uniqueid and l.lastapp <> 'Transferred Call')
|
|
|
|
|
and a.data_bilhete >= '$dataIni'
|
|
|
|
|
and a.data_bilhete <= '$dataFim' ";
|
|
|
|
|
$dac ? $query .= "and c.id = '$dac' " : '';
|
|
|
|
|
$ramal ? $query .= "and substring(b.agente,5) = '$ramal' " : '';
|
|
|
|
|
|
|
|
|
|
$query .= "group by ramal; \n";
|
|
|
|
|
|
|
|
|
|
$query .= "insert into chamadas_ramal_saite(ramal, qt_sai, dura_sai )
|
|
|
|
|
select a.src as ramal, count(*), sum(a.billsec)
|
|
|
|
|
from pbx_bilhetes a, pbx_bilhetes_complemento c
|
|
|
|
|
where c.uniqueid2 = a.uniqueid
|
|
|
|
|
and c.direcao in ('saida-pstn','interna')
|
|
|
|
|
and coalesce(trim(c.dac), '') = ''
|
|
|
|
|
and not exists(select '' from pbx_eventos_dacs where uid2 = a.uniqueid)
|
|
|
|
|
and exists(select '' from pbx_ramais where nome = a.src)
|
|
|
|
|
and a.lastapp <> 'Transferred Call'
|
|
|
|
|
and a.billsec > 3
|
|
|
|
|
and a.data_bilhete >= '$dataIni'
|
|
|
|
|
and a.data_bilhete <= '$dataFim' ";
|
|
|
|
|
$ramal ? $query .= "and a.src = '$ramal' " : '';
|
|
|
|
|
|
|
|
|
|
$query .= "group by ramal; \n";
|
|
|
|
|
|
|
|
|
|
$query .= "update chamadas_ramal
|
|
|
|
|
set qt_sai = b.qt_sai,dura_sai = b.dura_sai
|
|
|
|
|
from chamadas_ramal_saite b
|
|
|
|
|
where b.ramal = chamadas_ramal.ramal;
|
|
|
|
|
|
|
|
|
|
insert into chamadas_ramal(ramal, qt_sai, dura_sai)
|
|
|
|
|
select ramal, qt_sai, dura_sai
|
|
|
|
|
from chamadas_ramal_saite a
|
|
|
|
|
where not exists(select '' from chamadas_ramal where ramal = a.ramal);
|
|
|
|
|
|
|
|
|
|
select ramal,transbordando, qt_entra, dura_entra, qt_sai, dura_sai, qt_entra + qt_sai as qt_total, dura_entra + dura_sai as dura_total from chamadas_ramal order by 1;";
|
|
|
|
|
$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('Ramal','Transbordo','E. Quantidade','E. Duracao','S. Quantidade','S. Duracao','T. Quantidade','T. Duracao');
|
|
|
|
|
$dadosField = array('ramal','transbordando','qt_entra','dura_entra','qt_sai','dura_sai','qt_total','dura_total');
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Monta a linha de cabecalio.
|
|
|
|
|
*/
|
|
|
|
|
$dataRel[] = GenerateCsvFromArray($dadosCabecalio);
|
|
|
|
|
|
|
|
|
|
$somaEQtde = 0;
|
|
|
|
|
$somaEDura = 0;
|
|
|
|
|
$somaSQtde = 0;
|
|
|
|
|
$somaSDura = 0;
|
|
|
|
|
$somaTQtde = 0;
|
|
|
|
|
$somaTDura = 0;
|
|
|
|
|
$somaTrans = 0;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Linhas de dados.
|
|
|
|
|
*/
|
|
|
|
|
foreach ($this->GetData()[0] as $row) {
|
|
|
|
|
$somaTrans += $row['transbordando'];
|
|
|
|
|
$somaEQtde += $row['qt_entra'];
|
|
|
|
|
$somaEDura += $row['dura_entra'];
|
|
|
|
|
$somaSQtde += $row['qt_sai'];
|
|
|
|
|
$somaSDura += $row['dura_sai'];
|
|
|
|
|
$somaTQtde += $row['qt_total'];
|
|
|
|
|
$somaTDura += $row['dura_total'];
|
|
|
|
|
|
|
|
|
|
$row['dura_entra'] = SecondToStrTime($row['dura_entra']);
|
|
|
|
|
$row['dura_sai'] = SecondToStrTime($row['dura_sai']);
|
|
|
|
|
$row['dura_total'] = SecondToStrTime($row['dura_total']);
|
|
|
|
|
|
|
|
|
|
// Formata linha de dados.
|
|
|
|
|
$linha = array();
|
|
|
|
|
foreach ($dadosField as $value) {
|
|
|
|
|
$linha[] = $row["$value"];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$dataRel[] = GenerateCsvFromArray($linha);
|
|
|
|
|
}
|
|
|
|
|
$dataRel[] = GenerateCsvFromArray(array('Total',$somaTrans, $somaEQtde , SecondToStrTime($somaEDura) ,$somaSQtde , SecondToStrTime($somaSDura) ,$somaTQtde , SecondToStrTime($somaTDura)));
|
|
|
|
|
|
|
|
|
|
$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('Ramal','Transbordo','E. Quantidade','E. Duracao','S. Quantidade','S. Duracao','T. Quantidade','T. Duracao');
|
|
|
|
|
$dadosField = array('ramal','transbordando','qt_entra','dura_entra','qt_sai','dura_sai','qt_total','dura_total');
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Monta a linha de cabecalio.
|
|
|
|
|
*/
|
|
|
|
|
$linha = array('LABEL');
|
|
|
|
|
foreach ($dadosCabecalio as $value) {
|
|
|
|
|
$linha[] = $value;
|
|
|
|
|
}
|
|
|
|
|
$dataRel[] = $linha;
|
|
|
|
|
|
|
|
|
|
$somaEQtde = 0;
|
|
|
|
|
$somaEDura = 0;
|
|
|
|
|
$somaSQtde = 0;
|
|
|
|
|
$somaSDura = 0;
|
|
|
|
|
$somaTQtde = 0;
|
|
|
|
|
$somaTDura = 0;
|
|
|
|
|
$somaTrans = 0;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Linhas de dados.
|
|
|
|
|
*/
|
|
|
|
|
foreach ($this->GetData()[0] as $row) {
|
|
|
|
|
$somaTrans += $row['transbordando'];
|
|
|
|
|
$somaEQtde += $row['qt_entra'];
|
|
|
|
|
$somaEDura += $row['dura_entra'];
|
|
|
|
|
$somaSQtde += $row['qt_sai'];
|
|
|
|
|
$somaSDura += $row['dura_sai'];
|
|
|
|
|
$somaTQtde += $row['qt_total'];
|
|
|
|
|
$somaTDura += $row['dura_total'];
|
|
|
|
|
|
|
|
|
|
$row['dura_entra'] = SecondToStrTime($row['dura_entra']);
|
|
|
|
|
$row['dura_sai'] = SecondToStrTime($row['dura_sai']);
|
|
|
|
|
$row['dura_total'] = SecondToStrTime($row['dura_total']);
|
|
|
|
|
|
|
|
|
|
// Formata linha de dados.
|
|
|
|
|
$linha = array('DADOS');
|
|
|
|
|
foreach ($dadosField as $key) {
|
|
|
|
|
$linha[] = $row["$key"];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$dataRel[] = $linha;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$dataRel[] = array('LABEL', 'Total',$somaTrans ,$somaEQtde , SecondToStrTime($somaEDura) ,$somaSQtde , SecondToStrTime($somaSDura) ,$somaTQtde , SecondToStrTime($somaTDura));
|
|
|
|
|
|
|
|
|
|
$this->___dataRel[] = $dataRel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function ___PreparaGrid() {
|
|
|
|
|
$dataRel = array();
|
|
|
|
|
|
|
|
|
|
$dadosCabecalio = array(
|
|
|
|
|
'Ramal' => 'align="center"',
|
|
|
|
|
'Transbordo' => 'align="center"',
|
|
|
|
|
'E. Quantidade' => 'align="center"',
|
|
|
|
|
'E. Dura<EFBFBD><EFBFBD>o' => 'align="center"',
|
|
|
|
|
'S. Quantidade' => 'align="center"',
|
|
|
|
|
'S. Dura<EFBFBD><EFBFBD>o' => 'align="center"',
|
|
|
|
|
'T. Quantidade' => 'align="center"',
|
|
|
|
|
'T. Dura<EFBFBD><EFBFBD>o' => 'align="center"',
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$dadosField = array(
|
|
|
|
|
'ramal' => 'align="center"',
|
|
|
|
|
'transbordando' => 'align="center"',
|
|
|
|
|
'qt_entra' => 'align="center"',
|
|
|
|
|
'dura_entra' => 'align="center"',
|
|
|
|
|
'qt_sai' => 'align="center"',
|
|
|
|
|
'dura_sai' => 'align="center"',
|
|
|
|
|
'qt_total' => 'align="center"',
|
|
|
|
|
'dura_total' => 'align="center"'
|
|
|
|
|
);
|
|
|
|
|
/*
|
|
|
|
|
* Inicia o relat<EFBFBD>rio.
|
|
|
|
|
*/
|
|
|
|
|
$dataRel[] = '<table width="70%" cellpadding="2" class="grid">';
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Monta a linha de cabecalio.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
$dataRel[] = "<tr><th></th><th colspan='3'>Entrada</th><th colspan='2'>Sa<EFBFBD>da</th><th colspan='2'>Total</th></tr>";
|
|
|
|
|
|
|
|
|
|
$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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$somaEQtde = 0;
|
|
|
|
|
$somaEDura = 0;
|
|
|
|
|
$somaSQtde = 0;
|
|
|
|
|
$somaSDura = 0;
|
|
|
|
|
$somaTQtde = 0;
|
|
|
|
|
$somaTDura = 0;
|
|
|
|
|
$somaTrans = 0;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Linhas de dados.
|
|
|
|
|
*/
|
|
|
|
|
foreach ($this->GetData()[0] as $row) {
|
|
|
|
|
$somaTrans += $row['transbordando'];
|
|
|
|
|
$somaEQtde += $row['qt_entra'];
|
|
|
|
|
$somaEDura += $row['dura_entra'];
|
|
|
|
|
$somaSQtde += $row['qt_sai'];
|
|
|
|
|
$somaSDura += $row['dura_sai'];
|
|
|
|
|
$somaTQtde += $row['qt_total'];
|
|
|
|
|
$somaTDura += $row['dura_total'];
|
|
|
|
|
|
|
|
|
|
$row['dura_entra'] = SecondToStrTime($row['dura_entra']);
|
|
|
|
|
$row['dura_sai'] = SecondToStrTime($row['dura_sai']);
|
|
|
|
|
$row['dura_total'] = SecondToStrTime($row['dura_total']);
|
|
|
|
|
// 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 align="left">Total</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th></tr>';
|
|
|
|
|
$dataRel[] = sprintf($linha, $somaTrans,$somaEQtde , SecondToStrTime($somaEDura) ,$somaSQtde , SecondToStrTime($somaSDura) ,$somaTQtde , SecondToStrTime($somaTDura));
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Fecha relatorio.
|
|
|
|
|
*/
|
|
|
|
|
$dataRel[] = '</table>';
|
|
|
|
|
$this->___dataRel[] = $dataRel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function ___PreparaHtml() {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function ___PreparaPdf() {
|
|
|
|
|
list($this->___dac, $this->___dataIni, $this->___dataFim) = $_SESSION["SSstorageFiltros"];
|
|
|
|
|
/**
|
|
|
|
|
* TABELA DADOS PRINCIPAIS
|
|
|
|
|
*/
|
|
|
|
|
//HEADER DA TABELA DO PDF -> DADOS EM ARRAY
|
|
|
|
|
$dadosCabecalio = array(
|
|
|
|
|
'Ramal' => 'C',
|
|
|
|
|
'Transbordo' => 'C',
|
|
|
|
|
'E. Quantidade' => 'C',
|
|
|
|
|
'E. Dura<EFBFBD><EFBFBD>o' => 'C',
|
|
|
|
|
'S. Quantidade' => 'C',
|
|
|
|
|
'S. Dura<EFBFBD><EFBFBD>o' => 'C',
|
|
|
|
|
'T. Quantidade' => 'C',
|
|
|
|
|
'T. Dura<EFBFBD><EFBFBD>o' => 'C',
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$dadosField = array(
|
|
|
|
|
'ramal' => 'C',
|
|
|
|
|
'transbordando' => 'C',
|
|
|
|
|
'qt_entra' => 'C',
|
|
|
|
|
'dura_entra' => 'C',
|
|
|
|
|
'qt_sai' => 'C',
|
|
|
|
|
'dura_sai' => 'C',
|
|
|
|
|
'qt_total' => 'C',
|
|
|
|
|
'dura_total' => 'C'
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$somaEQtde = 0;
|
|
|
|
|
$somaEDura = 0;
|
|
|
|
|
$somaSQtde = 0;
|
|
|
|
|
$somaSDura = 0;
|
|
|
|
|
$somaTQtde = 0;
|
|
|
|
|
$somaTDura = 0;
|
|
|
|
|
$somaTrans = 0;
|
|
|
|
|
$dados = $this->GetData()[0];
|
|
|
|
|
$x = 0;
|
|
|
|
|
|
|
|
|
|
foreach ($dados as $row) {
|
|
|
|
|
$somaTrans += $row['transbordando'];
|
|
|
|
|
$somaEQtde += $row['qt_entra'];
|
|
|
|
|
$somaEDura += $row['dura_entra'];
|
|
|
|
|
$somaSQtde += $row['qt_sai'];
|
|
|
|
|
$somaSDura += $row['dura_sai'];
|
|
|
|
|
$somaTQtde += $row['qt_total'];
|
|
|
|
|
$somaTDura += $row['dura_total'];
|
|
|
|
|
|
|
|
|
|
$dados[$x]['dura_entra'] = SecondToStrTime($row['dura_entra']);
|
|
|
|
|
$dados[$x]['dura_sai'] = SecondToStrTime($row['dura_sai']);
|
|
|
|
|
$dados[$x]['dura_total'] = SecondToStrTime($row['dura_total']);
|
|
|
|
|
$x++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$widthHeader = array(23,23, 23, 23, 23,23,23,23);
|
|
|
|
|
$totalizador = array('Total' , $somaTrans ,$somaEQtde , SecondToStrTime($somaEDura) ,$somaSQtde , SecondToStrTime($somaSDura) ,$somaTQtde , SecondToStrTime($somaTDura));
|
|
|
|
|
//Monta o array para passar para o prepara; Necess<EFBFBD>rio passar 6 parametros
|
|
|
|
|
$table1 = array($dadosCabecalio, $dadosField, $dados, $widthHeader, $totalizador, 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');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$relChamadasRamal = new RelChamadasRamal($idProg, $dbcon, 1);
|
|
|
|
|
$relChamadasRamal->ExecutaRelatorio();
|
|
|
|
|
?>
|