Browse Source

Adicionei a coluna e filtro 'entrada' no Relatorio de Chamadas Entrantes Geral

1.8-dev
Claudio Zimmermann Junior 3 months ago committed by bruno
parent
commit
cb18b0bd63
  1. 2
      include/configBd.php
  2. 116
      include/util/relatoriosBase.php
  3. 479
      include/util/util.php
  4. 63
      relatorios/pbx/chamadasEntrantes/chamadasEntrantesGeral.php

2
include/configBd.php

@ -3,7 +3,7 @@
* configuração para acesso ao banco de dados principal da aplicação.
*/
$dbPort = getenv('DB_PORT') ? getenv('DB_PORT') : '5432';
$dbHost = getenv('DB_HOST') ? getenv('DB_HOST') : '127.0.0.1';
$dbHost = getenv('DB_HOST') ? getenv('DB_HOST') : 'postgres';
$dbName = getenv('DB_BASE') ? getenv('DB_BASE') : 'pbx';
$dbUser = getenv('DB_USER') ? getenv('DB_USER') : 'contacte';
$dbPassword = getenv('DB_PASSWD') ? getenv('DB_PASSWD') : 'ctepgSQL';

116
include/util/relatoriosBase.php

@ -6,7 +6,8 @@ use PhpOffice\PhpSpreadsheet\Writer\Xls;
use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Style\Alignment;
abstract class Relatorios {
abstract class Relatorios
{
/*
* Valores globais para dados de formul?rio.
*/
@ -27,14 +28,16 @@ abstract class Relatorios {
private $idProg;
private $dbcon;
public function __construct($idProg, $dbcon, $incDac) {
public function __construct($idProg, $dbcon, $incDac)
{
$this->idProg = $idProg;
$this->dbcon = $dbcon;
$this->___incDac = $incDac;
$this->___InicializaForm();
}
protected function ___GetQuery($query) {
protected function ___GetQuery($query)
{
$result = pg_query($query);
if (!$result) {
GeraExcept("Não foi possível executar a consulta no banco de dados!");
@ -42,7 +45,8 @@ abstract class Relatorios {
return $result;
}
public function ___ValidaForm() {
public function ___ValidaForm()
{
if (!IsPostBack())
return;
@ -69,7 +73,8 @@ abstract class Relatorios {
}
}
protected function ___InicializaForm() {
protected function ___InicializaForm()
{
/*
* Dados de formul?rio.
*/
@ -113,7 +118,8 @@ abstract class Relatorios {
$this->___pathLog = sprintf("/var/log/asterisk/relatorio_%s.log", $scrpName);
}
protected function ___FiltrosRelatorio() {
protected function ___FiltrosRelatorio()
{
if ($this->___media != MEDIA_PRINT_GRID) {
/*
* Recupera os filtros da sess�o do usu�rio.
@ -184,7 +190,8 @@ abstract class Relatorios {
return sprintf($filtro, $this->___dataIni, $this->___dataFim, $lkPrint);
}
public function ___ConteudoRelatorio() {
public function ___ConteudoRelatorio()
{
if ($this->___media == MEDIA_PRINT_GRID) {
$this->___GetDadosDb();
SaveVarToFile($this->___data, $this->___dataFile);
@ -197,20 +204,26 @@ abstract class Relatorios {
$this->___dataCount = count($this->___data[0] ?? []);
}
public function ___ImprimeRelatorio() {
public function ___ImprimeRelatorio()
{
switch ($this->___media) {
//case MEDIA_PRINT_HTML: return $this->___ImprimeHtml();
case MEDIA_PRINT_HTML: return $this->___ImprimePdf("I");
case MEDIA_PRINT_PDF: return $this->___ImprimePdf("D");
case MEDIA_PRINT_EXCEL: return $this->___ImprimeExcel();
case MEDIA_PRINT_CSV: return $this->___ImprimeCsv();
case MEDIA_PRINT_HTML:
return $this->___ImprimePdf("I");
case MEDIA_PRINT_PDF:
return $this->___ImprimePdf("D");
case MEDIA_PRINT_EXCEL:
return $this->___ImprimeExcel();
case MEDIA_PRINT_CSV:
return $this->___ImprimeCsv();
default:
return $this->___ImprimeGrid();
}
}
protected function ___GravaLog($erro = true) {
protected function ___GravaLog($erro = true)
{
$erroSys = error_get_last();
$erroSys = sprintf("Msg: %s Line: %s", $erroSys['message'], $erroSys['line']);
$erroBd = pg_last_error();
@ -220,7 +233,8 @@ abstract class Relatorios {
fclose($arq);
}
private function ___GetScptName() {
private function ___GetScptName()
{
$query = sprintf("select arquivo from pbx_funcoes_internas where id_prog = '%s'", $this->idProg);
$result = pg_query($query);
$row = pg_fetch_row($result);
@ -228,20 +242,26 @@ abstract class Relatorios {
return $path['filename'];
}
private function ___PreparaData() {
private function ___PreparaData()
{
switch ($this->___media) {
// case MEDIA_PRINT_HTML: $this->___PreparaHtml();
// break;
case MEDIA_PRINT_HTML: $this->___PreparaPdf();
case MEDIA_PRINT_HTML:
$this->___PreparaPdf();
break;
case MEDIA_PRINT_PDF: $this->___PreparaPdf();
case MEDIA_PRINT_PDF:
$this->___PreparaPdf();
break;
case MEDIA_PRINT_EXCEL: $this->___PreparaExcel();
case MEDIA_PRINT_EXCEL:
$this->___PreparaExcel();
break;
case MEDIA_PRINT_CSV: $this->___PreparaCsv();
case MEDIA_PRINT_CSV:
$this->___PreparaCsv();
break;
default:
case MEDIA_PRINT_GRID: $this->___PreparaGrid();
case MEDIA_PRINT_GRID:
$this->___PreparaGrid();
break;
}
}
@ -256,7 +276,8 @@ abstract class Relatorios {
abstract protected function ___PreparaGrid();
private function ___ImprimeGrid() {
private function ___ImprimeGrid()
{
$fh = fopen('php://memory', 'rw');
$numTable = 0;
@ -280,7 +301,8 @@ abstract class Relatorios {
return stream_get_contents($fh);
}
private function ___ImprimeHtml() {
private function ___ImprimeHtml()
{
$fh = fopen('php://memory', 'rw');
$numTable = 0;
@ -313,10 +335,12 @@ abstract class Relatorios {
exit(0);
}
private function ___GetTemplate($filtros, $conteudoRelatorio) {
private function ___GetTemplate($filtros, $conteudoRelatorio)
{
$pathTpl = $_SESSION[PATH_ABSOLUTO] . 'templates/relbasehtml.tpl';
$vars = array('tituloPage' => GetDispProgSel($this->idProg),
$vars = array(
'tituloPage' => GetDispProgSel($this->idProg),
'logoRel' => GetLogoRel(),
'REL_HEAD_NIVEL1' => GetHeadRel(REL_HEAD_NIVEL1),
'tituloRelatorio' => GetDispProgSel($this->idProg),
@ -333,7 +357,8 @@ abstract class Relatorios {
return $content;
}
private function ___ImprimePdf($target) {
private function ___ImprimePdf($target)
{
$pdf = new GerarPDF();
//Informações do Filtro do Relatório
@ -360,7 +385,8 @@ abstract class Relatorios {
$pdf->Output(GetDispProgSel($this->GetIdProg()) . ".pdf", $target);
}
private function ___ImprimeExcel() {
private function ___ImprimeExcel()
{
$fileName = sprintf("%s.xls", substr(LimpaString(GetDispProgSel($this->idProg)), 0, 32));
$objPHPExcel = new Spreadsheet();
$objPHPExcel->setActiveSheetIndex(0);
@ -418,7 +444,8 @@ abstract class Relatorios {
$this->___SendFile($fh, $fileName);
}
private function ___ImprimeExcelOld() {
private function ___ImprimeExcelOld()
{
$fileName = sprintf("%s.xls", substr(LimpaString(GetDispProgSel($this->idProg)), 0, 32));
$fh = fopen('php://memory', 'rw');
@ -475,7 +502,8 @@ abstract class Relatorios {
$this->___SendFile($fh, $fileName);
}
private function ___ImprimeCsv() {
private function ___ImprimeCsv()
{
$fileName = sprintf("%s.csv", substr(LimpaString(GetDispProgSel($this->idProg)), 0, 32));
$fh = fopen('php://memory', 'rw');
@ -489,7 +517,8 @@ abstract class Relatorios {
$this->___SendFile($fh, $fileName);
}
private function ___SendFile($data, $fileName) {
private function ___SendFile($data, $fileName)
{
ob_end_clean();
ob_start();
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
@ -504,39 +533,48 @@ abstract class Relatorios {
exit(0);
}
protected function GetData() {
protected function GetData()
{
return $this->___data;
}
protected function SetData($data) {
protected function SetData($data)
{
$this->___data[] = ($data ?? []);
}
protected function GetIdProg() {
protected function GetIdProg()
{
return $this->idProg;
}
protected function GetDbCon() {
protected function GetDbCon()
{
return $this->dbcon;
}
protected function GetMsg() {
protected function GetMsg()
{
return $this->___msg;
}
protected function GetIncDac() {
protected function GetIncDac()
{
return $this->___incDac;
}
protected function SetMsg($msg) {
protected function SetMsg($msg)
{
$this->___msg = $msg;
}
function getType() {
function getType()
{
return $this->___type;
}
function setType($___type) {
function setType($___type)
{
$this->___type = $___type;
}
@ -544,5 +582,3 @@ abstract class Relatorios {
abstract public function ExecutaRelatorio();
}
?>

479
include/util/util.php

File diff suppressed because it is too large Load Diff

63
relatorios/pbx/chamadasEntrantes/chamadasEntrantesGeral.php

@ -1,24 +1,29 @@
<?php
include_once 'util/relatoriosBase.php';
class ChamadasEntrantesGeral extends Relatorios {
class ChamadasEntrantesGeral extends Relatorios
{
private $___tipoAtendimento;
private $___tempoDuracao;
private $___telefone;
private $___tipoRecepcao;
private $___entrada;
public function __construct($idProg, $dbcon, $incDac) {
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->___entrada = isset($_REQUEST['entrada']) ? $_REQUEST['entrada'] : '';
$this->___dataIni = IsPostBack() ? $_POST['dataIni'] : date('d/m/Y') . " 00:00";
$this->___dataFim = IsPostBack() ? $_POST['dataFim'] : date('d/m/Y') . " 23:59";
}
function ___ValidaForm() {
function ___ValidaForm()
{
parent::___ValidaForm();
if (empty($this->___tipoAtendimento)) {
GeraExcept('Informe um tipo de atendimento!');
@ -39,12 +44,13 @@
}
}
function ___FiltrosRelatorio() {
function ___FiltrosRelatorio()
{
if ($this->___media != MEDIA_PRINT_GRID) {
/*
* Recupera os filtros da sess�o do usu�rio.
*/
list($this->___dac, $this->___dataIni, $this->___dataFim, $this->___telefone) = $_SESSION["SSstorageFiltros"];
list($this->___dac, $this->___dataIni, $this->___dataFim, $this->___telefone, $this->___entrada) = $_SESSION["SSstorageFiltros"];
if ($this->___media == MEDIA_PRINT_HTML) {
return sprintf("Data Inicial: %s Data Final: %s ", $this->___dataIni, $this->___dataFim);
@ -90,6 +96,7 @@
. '<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 style="padding-left: 10px;">Entrada<td>';
$filtro .= '<td align="center" valign="middle">&nbsp;</td>';
$filtro .= '</tr>';
@ -112,6 +119,7 @@
. '<input name="tipoAtendimento" class="clean" type="radio" id="tipoAtendimento" value="3" %s>Nã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" value="%s" /></td>';
$filtro .= '<td><input name="entrada" type="text" id="entrada" value="%s" /></td>';
$filtro .= '<td><input type="submit" name="btConsulta" id="btConsulta" value="Consultar"></td>';
$filtro .= '<td>%s</td>';
$filtro .= '</tr>';
@ -120,22 +128,24 @@
/*
* Guarda os filtros passados para recuperar na emiss�o dos relat?ios para impress�o.
*/
$_SESSION["SSstorageFiltros"] = array($this->___dataIni, $this->___dataFim, $this->___telefone);
$_SESSION["SSstorageFiltros"] = array($this->___dataIni, $this->___dataFim, $this->___telefone, $this->___entrada);
return sprintf($filtro, $this->___dataIni, $this->___dataFim, $this->___telefone, $lkPrint);
return sprintf($filtro, $this->___dataIni, $this->___dataFim, $this->___telefone, $this->___entrada, $lkPrint);
}
protected function ___GetDadosDb() {
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;
$entrada = $this->___entrada;
$duracao = $this->___tempoDuracao;
$tipoAtendimento = $this->___tipoAtendimento;
$fonePesquisa = $this->___tipoRecepcao;
$query = sprintf("SELECT a.uniqueid, a.calldate, a.src, a.dst,
$query = sprintf("SELECT a.uniqueid, a.calldate, a.src, a.dst, a.clid AS entrada,
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(23,24))THEN 'MÓVEL' ELSE c.nome_municipio END AS nome_municipio, c.uf, b.tplg_descricao,
CASE WHEN((d.evento IN('COMPLETEAGENT','COMPLETECALLER') AND (strtoint(d.param2) > 3) ) OR ((d.evento is null) AND (billsec > 3)))THEN 'ATENDIDA' ELSE 'N ATENDIDA' END AS status
@ -159,6 +169,10 @@
else if (!empty($telefone) && ($fonePesquisa == 3))
$query .= sprintf(" AND (a.dst LIKE '%s' OR src LIKE '%s') ", PreparaLike($telefone), PreparaLike($telefone));
if (!empty($entrada)) {
$query .= "AND UPPER(a.clid) LIKE UPPER('%$entrada%')";
}
if ($duracao == 2) {
$query .= " AND a.billsec > 0 ";
}
@ -174,13 +188,16 @@
}
$query .= " ORDER BY a.calldate";
$this->SetMsg("Query: $query");
$this->___GravaLog(false);
$result = $this->___GetQuery($query);
$row = pg_fetch_all($result);
$this->SetData($row ? $row : array());
}
protected function ___PreparaCsv() {
protected function ___PreparaCsv()
{
$nomeDac = "";
$dataRel = array();
$dataAgrup = array();
@ -223,7 +240,8 @@
$this->___dataRel[] = $dataRel;
}
protected function ___PreparaExcel() {
protected function ___PreparaExcel()
{
//list($this->___dataIni, $this->___dataFim) = $_SESSION["SSstorageFiltros"];
$dataRel = array();
@ -295,7 +313,8 @@
$this->___dataRel[] = $dataRel;
}
protected function ___PreparaGrid() {
protected function ___PreparaGrid()
{
$dadosCabecalio = array(
'Data/Hora' => 'align="center"',
'Origem' => 'align="left"',
@ -305,6 +324,7 @@
'Atendida' => 'align="center"',
'Fila' => 'align="left"',
'Agente' => 'align="left"',
'Entrada' => 'align="left"',
'Município' => 'align="left"',
'UF' => 'align="center"'
);
@ -317,11 +337,12 @@
'status' => 'align="center"',
'fila' => 'align="left"',
'agente' => 'align="left"',
'entrada' => 'align="left"',
'nome_municipio' => 'align="left"',
'uf' => 'align="center"'
);
/*
* Inicia o relat<EFBFBD>rio.
* Inicia o relatorio.
*/
$dataRel[] = '<table width="90%" cellpadding="2" class="grid">';
@ -350,6 +371,7 @@
* Linhas de dados.
*/
foreach ($this->GetData()[0] as $row) {
$row['entrada'] = explode('"', $row['entrada'])[1];
$row['src'] = ocultarTelefone($row['src']);
$row["calldate"] = date('d/m/Y H:i', strtotime($row["calldate"]));
$row["tplg_descricao"] = str_replace("Fixo Entrada", "", $row["tplg_descricao"]);
@ -383,10 +405,11 @@
$this->___dataRel[] = $dataRel;
}
protected function ___PreparaHtml() {
protected function ___PreparaHtml()
{
}
protected function ___PreparaPdf() {
protected function ___PreparaPdf()
{
list($this->___dataIni, $this->___dataFim) = $_SESSION["SSstorageFiltros"];
$dados = array();
@ -420,7 +443,8 @@
'Fila' => 'L',
'Agente' => 'L',
'Município' => 'L',
'UF' => 'C');
'UF' => 'C'
);
$dataHeader = array(
'calldate' => 'C',
'src' => 'L',
@ -442,7 +466,8 @@
$this->___dataRel = array($table1);
}
public function ExecutaRelatorio() {
public function ExecutaRelatorio()
{
global $jsStartup, $jsJQuery, $smarty;
try {
/*
@ -476,9 +501,7 @@
$smarty->assign('msg', $this->GetMsg());
GetTemplate($smarty, 'relatoriosGrid.tpl');
}
}
$relChmEntG = new ChamadasEntrantesGeral($idProg, $dbcon, 0);
$relChmEntG->ExecutaRelatorio();
?>

Loading…
Cancel
Save