From 2e13679894283f0e8c1f1901765e123908a227ae Mon Sep 17 00:00:00 2001 From: "amarildo.pereira" Date: Fri, 11 Nov 2022 08:28:53 -0400 Subject: [PATCH] =?UTF-8?q?Inclus=C3=A3o=20dos=20servi=C3=A7os=20em=20rela?= =?UTF-8?q?t=C3=B3rios=20de=20call=20center,=20corre=C3=A7=C3=A3o=20na=20i?= =?UTF-8?q?mporta=20bilhetes=20na=20limpeza=20de=20dados=20duplicados=20[s?= =?UTF-8?q?ervicos]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../scripts/manutencaoDB/importaBilhetes.php | 2 +- .../scripts/vendas/configVendasAlgar.php | 4 +- .../scripts/vendas/consolidaVendas.php | 2 +- checaSessao.php | 1 + compara/atual.php | 34 + configGeral.php | 11 +- imgSite/LOGO_SIMPLESIP.PNG | Bin 0 -> 48299 bytes include/FPDF/GerarPDF.php | 334 +-- include/util/constantes.php | 10 +- include/util/funcoesApl.php | 49 +- include/util/funcoesInternas.php | 38 +- include/util/util.php | 23 +- login.php | 5 +- master.css | 22 +- nbproject/private/private.properties | 1 + nbproject/private/private.xml | 10 +- nbproject/project.properties | 2 +- projeto/base/sql/versao-1.7.11.5.sql | 19 + .../callcenter/geral/abandonadasFila.php | 1501 ++++++----- .../geral/abandonadasFilaDetalhes.php | 949 +++---- .../callcenter/geral/recebidasAgente.php | 964 ++++--- relatorios/callcenter/geral/rechamadas.php | 623 +++-- .../callcenter/geral/relClassificacao.php | 763 +++--- .../geral/relClassificacaoDetalhes.php | 1029 +++---- .../geral/relClassificacaoMensal.php | 755 +++--- .../callcenter/metas/metricasDiaria.php | 1748 ++++++------ .../callcenter/metas/metricasMensal.php | 2362 +++++++++-------- templates/confSistema.tpl | 9 + templates/relatoriosGrid.tpl | 11 +- 29 files changed, 6200 insertions(+), 5081 deletions(-) create mode 100644 imgSite/LOGO_SIMPLESIP.PNG diff --git a/asterisk/var_lib_asterisk/scripts/manutencaoDB/importaBilhetes.php b/asterisk/var_lib_asterisk/scripts/manutencaoDB/importaBilhetes.php index 7bf05353..cd0f00e3 100644 --- a/asterisk/var_lib_asterisk/scripts/manutencaoDB/importaBilhetes.php +++ b/asterisk/var_lib_asterisk/scripts/manutencaoDB/importaBilhetes.php @@ -36,7 +36,7 @@ try { if (pg_connection_status($dbcon) === PGSQL_CONNECTION_BAD) { ibRaiseExcept("Nao foi possivel conecta com o banco de dados!"); } - @AtualizaPreVenda($dbcon); + //@AtualizaPreVenda($dbcon); //desativado, não estamos usando o sistema. @CorrigeNumeroDestino($dbcon); @ApagaBilheteDuplTransfer($dbcon); @CorrigeAbandonTransbordo($dbcon); diff --git a/asterisk/var_lib_asterisk/scripts/vendas/configVendasAlgar.php b/asterisk/var_lib_asterisk/scripts/vendas/configVendasAlgar.php index 9797f92f..34ab6cf6 100644 --- a/asterisk/var_lib_asterisk/scripts/vendas/configVendasAlgar.php +++ b/asterisk/var_lib_asterisk/scripts/vendas/configVendasAlgar.php @@ -1,6 +1,6 @@ '192.168.115.240', + 'dbServer' => 'algar.simplesip.com.br', 'dbBase' => '', 'dbPorta' => '', 'userDb' => '', diff --git a/asterisk/var_lib_asterisk/scripts/vendas/consolidaVendas.php b/asterisk/var_lib_asterisk/scripts/vendas/consolidaVendas.php index 2375ef75..db5d84c7 100644 --- a/asterisk/var_lib_asterisk/scripts/vendas/consolidaVendas.php +++ b/asterisk/var_lib_asterisk/scripts/vendas/consolidaVendas.php @@ -1183,7 +1183,7 @@ function __VerificaDefault() { global $paramRemoteConn, $paramLocalConn; if (!isset($paramRemoteConn)) { - array('dbServer' => 'algar.simplesip.com.br', 'dbBase' => '', 'dbPorta' => '', 'userDb' => '', 'dbPass' => ''); + $paramRemoteConn = array('dbServer' => 'algar.simplesip.com.br', 'dbBase' => '', 'dbPorta' => '', 'userDb' => '', 'dbPass' => ''); } if (!isset($paramLocalConn)) { diff --git a/checaSessao.php b/checaSessao.php index 087d3fb5..d933f206 100644 --- a/checaSessao.php +++ b/checaSessao.php @@ -21,6 +21,7 @@ if (!isset($_SESSION["SSinSession"]) || ($_SESSION["SSinSession"] != "ok")) { $_SESSION["primAcesso"] = 0; $_SESSION[HOSTS_INFO] = null; //pbx_sites $_SESSION["SSagentePenalidade"] = null; + $_SESSION["SSUsoServico"] = 0; GetParametrosLicensa(); } diff --git a/compara/atual.php b/compara/atual.php index 5b5af6ac..29418f23 100644 --- a/compara/atual.php +++ b/compara/atual.php @@ -1,3 +1,37 @@ + +function ApagaBilheteDuplTransfer($dbcon) { + /* + * Esta funcao apaga bilhetes que estao duplicatos na transferencia. + */ + $path = '/var/log/asterisk/apaga_bilhetes_transfer.log'; + + $query = "delete from ast_bilhetes a where rtrim(disposition) in('NO ANSWER', 'BUSY', 'FAILED') and exists(select '' from ast_bilhetes where uniqueid = a.uniqueid and rtrim(disposition) = 'ANSWERED');"; + + if (!pg_query($dbcon, $query)) { + $log = sprintf("Data: %s Cmd: Erro: %s\n", date('Y-m-d H:i:s'), $query, GetLasterror()); + WriteLog($log, $path); + } + + $query = "drop table if exists bilhetes_dupl +create table bilhetes_dupl as +select uniqueid, min(sequence) as sequence from ast_bilhetes where calldate::date = now()::date group by uniqueid having count(*) > 1; +delete from ast_bilhetes a using bilhetes_dupl b where b.uniqueid = a.uniqueid and a.sequence not in(select sequence from bilhetes_dupl);"; + + if (!pg_query($dbcon, $query)) { + $log = sprintf("Data: %s Cmd: Erro: %s\n", date('Y-m-d H:i:s'), $query, GetLasterror()); + WriteLog($log, $path); + } +} + + + +delete from ast_bilhetes a where rtrim(disposition) in('NO ANSWER', 'BUSY', 'FAILED') and exists(select '' from ast_bilhetes where uniqueid = a.uniqueid and rtrim(disposition) = 'ANSWERED'); +drop table if exists bilhetes_dupl; +create table bilhetes_dupl as +select uniqueid, min(sequence) as sequence from ast_bilhetes where calldate::date = now()::date group by uniqueid having count(*) > 1; +delete from ast_bilhetes a using bilhetes_dupl b where b.uniqueid = a.uniqueid and a.sequence not in(select sequence from bilhetes_dupl);"; + + http://192.168.115.233:3000/amarildo.pereira/pabx-app.git diff --git a/configGeral.php b/configGeral.php index a77c8db4..c6a1e05a 100644 --- a/configGeral.php +++ b/configGeral.php @@ -102,7 +102,8 @@ if ($idSubProg == CONFIG_BASE_DADOS) { 'prm_contasenha_master', 'prm_portabilidade', 'prm_tarifacao', 'prm_prepago', 'prm_use_discador', 'prm_ativa_complemento_campanha', "prm_tempo_sessao", "prm_registro_pagina", "prm_use_vendas", "prm_nome_vendas", "prm_exige_proto_vendas", "prm_bloqueio", "prm_bloqueio_data", "prm_abandonada_semretorno", "prm_max_licenca", "prm_max_ramal", - "prm_normaliza_agenda", 'prm_max_dias_relatorio', 'prm_ocultar_telefone', 'prm_ocultar_email', 'prm_ocultar_documento', 'prm_max_licenca_fixo'); + "prm_normaliza_agenda", 'prm_max_dias_relatorio', 'prm_ocultar_telefone', 'prm_ocultar_email', 'prm_ocultar_documento', 'prm_max_licenca_fixo', + "prm_relatorio_servico"); $default = array("prm_atende_auto" => 0, "prm_atende_manual" => 0, "prm_tempo_sessao" => 20, "prm_normaliza_agenda" => 0, "prm_max_dias_relatorio" => 0, 'prm_ocultar_telefone' => 0); $values = array(); @@ -112,8 +113,8 @@ if ($idSubProg == CONFIG_BASE_DADOS) { if (!ExisteRegistro($dbcon, 'pbx_parametros', 'id', '1')) { $query = "insert into pbx_parametros - (id, prm_slogan, prm_path_audio, prm_path_arq_agente, prm_logo_relatorio, prm_relatorio_head, prm_relatorio_linha1, prm_relatorio_linha2, prm_msg_senha_def, prm_msg_senha_exp, prm_url_asterisk, prm_ddd_padrao, prm_mun_padrao, prm_uf_padrao, prm_cadastro_atendido, prm_digitos_conta, prm_digitos_senhas, prm_gera_conta, prm_pausa_grupo, prm_atende_auto, prm_atende_manual, prm_atende_preferencial, prm_prefixo_sennha_ramal, prm_modulo_pesquisa, prm_contasenha_sinc, prm_contasenha_master, prm_portabilidade, prm_tarifacao, prm_prepago, prm_use_discador, prm_tempo_sessao, prm_registro_pagina, prm_use_vendas, prm_nome_vendas, prm_exige_proto_vendas, prm_bloqueio, prm_bloqueio_data, prm_abandonada_semretorno, prm_max_licenca, prm_max_ramal, prm_normaliza_agenda, prm_max_dias_relatorio, prm_ocultar_telefone, prm_ocultar_email, prm_ocultar_documento, prm_max_licenca_fixo) - values(1, {prm_slogan},{prm_path_audio},{prm_path_arq_agente}, {prm_logo_relatorio},{prm_relatorio_head},{prm_relatorio_linha1},{prm_relatorio_linha2},{prm_msg_senha_def},{prm_msg_senha_exp},{prm_url_asterisk},{prm_ddd_padrao},{prm_mun_padrao},{prm_uf_padrao},{prm_cadastro_atendidos},{prm_digitos_conta},{prm_digitos_senha},{prm_gera_conta},{prm_pausa_grupo},{prm_atende_auto},{prm_atende_manual},{prm_atende_preferencial},{prm_prefixo_sennha_ramal},{prm_modulo_pesquisa},{prm_contasenha_sinc},{prm_contasenha_master},{prm_portabilidade},{prm_tarifacao},{prm_prepago},{prm_use_discador},{prm_tempo_sessao},{prm_registro_pagina},{prm_use_vendas},{prm_nome_vendas}, {prm_exige_proto_vendas}, {prm_bloqueio}, {prm_bloqueio_data}, {prm_abandonada_semretorno}, {prm_max_licenca}, {prm_max_ramal}, {prm_normaliza_agenda},{prm_max_dias_relatorio}, {prm_ocultar_telefone}, {prm_ocultar_email}, {prm_ocultar_documento}, {prm_max_licenca_fixo})"; + (id, prm_slogan, prm_path_audio, prm_path_arq_agente, prm_logo_relatorio, prm_relatorio_head, prm_relatorio_linha1, prm_relatorio_linha2, prm_msg_senha_def, prm_msg_senha_exp, prm_url_asterisk, prm_ddd_padrao, prm_mun_padrao, prm_uf_padrao, prm_cadastro_atendido, prm_digitos_conta, prm_digitos_senhas, prm_gera_conta, prm_pausa_grupo, prm_atende_auto, prm_atende_manual, prm_atende_preferencial, prm_prefixo_sennha_ramal, prm_modulo_pesquisa, prm_contasenha_sinc, prm_contasenha_master, prm_portabilidade, prm_tarifacao, prm_prepago, prm_use_discador, prm_tempo_sessao, prm_registro_pagina, prm_use_vendas, prm_nome_vendas, prm_exige_proto_vendas, prm_bloqueio, prm_bloqueio_data, prm_abandonada_semretorno, prm_max_licenca, prm_max_ramal, prm_normaliza_agenda, prm_max_dias_relatorio, prm_ocultar_telefone, prm_ocultar_email, prm_ocultar_documento, prm_max_licenca_fixo, prm_relatorio_servico) + values(1, {prm_slogan},{prm_path_audio},{prm_path_arq_agente}, {prm_logo_relatorio},{prm_relatorio_head},{prm_relatorio_linha1},{prm_relatorio_linha2},{prm_msg_senha_def},{prm_msg_senha_exp},{prm_url_asterisk},{prm_ddd_padrao},{prm_mun_padrao},{prm_uf_padrao},{prm_cadastro_atendidos},{prm_digitos_conta},{prm_digitos_senha},{prm_gera_conta},{prm_pausa_grupo},{prm_atende_auto},{prm_atende_manual},{prm_atende_preferencial},{prm_prefixo_sennha_ramal},{prm_modulo_pesquisa},{prm_contasenha_sinc},{prm_contasenha_master},{prm_portabilidade},{prm_tarifacao},{prm_prepago},{prm_use_discador},{prm_tempo_sessao},{prm_registro_pagina},{prm_use_vendas},{prm_nome_vendas}, {prm_exige_proto_vendas}, {prm_bloqueio}, {prm_bloqueio_data}, {prm_abandonada_semretorno}, {prm_max_licenca}, {prm_max_ramal}, {prm_normaliza_agenda},{prm_max_dias_relatorio}, {prm_ocultar_telefone}, {prm_ocultar_email}, {prm_ocultar_documento}, {prm_max_licenca_fixo}, {prm_relatorio_servico})"; } else { $query = "update pbx_parametros set prm_slogan = {prm_slogan}, prm_path_audio = {prm_path_audio}, prm_path_arq_agente = {prm_path_arq_agente}, @@ -132,7 +133,7 @@ if ($idSubProg == CONFIG_BASE_DADOS) { prm_exige_proto_vendas = {prm_exige_proto_vendas}, prm_bloqueio = {prm_bloqueio}, prm_bloqueio_data = {prm_bloqueio_data}, prm_abandonada_semretorno = {prm_abandonada_semretorno}, prm_max_licenca = {prm_max_licenca}, prm_max_ramal = {prm_max_ramal}, prm_normaliza_agenda = {prm_normaliza_agenda}, prm_max_dias_relatorio = {prm_max_dias_relatorio}, prm_ocultar_telefone = {prm_ocultar_telefone}, - prm_ocultar_email = {prm_ocultar_email}, prm_ocultar_documento = {prm_ocultar_documento}, prm_max_licenca_fixo = {prm_max_licenca_fixo} + prm_ocultar_email = {prm_ocultar_email}, prm_ocultar_documento = {prm_ocultar_documento}, prm_max_licenca_fixo = {prm_max_licenca_fixo}, prm_relatorio_servico = {prm_relatorio_servico} where id = 1"; } @@ -230,7 +231,7 @@ if ($idSubProg == CONFIG_BASE_DADOS) { prm_ativa_complemento_campanha, prm_tempo_sessao, prm_registro_pagina, prm_use_vendas, prm_nome_vendas, prm_exige_proto_vendas, prm_bloqueio, prm_bloqueio_data, prm_abandonada_semretorno, prm_max_licenca, prm_max_ramal,prm_normaliza_agenda, prm_max_dias_relatorio, prm_ocultar_telefone, prm_ocultar_email, - prm_ocultar_documento,prm_max_licenca_fixo + prm_ocultar_documento,prm_max_licenca_fixo, prm_relatorio_servico from pbx_parametros where id = 1"; $result = @pg_query($dbcon, $query); $dados = @pg_fetch_array($result); diff --git a/imgSite/LOGO_SIMPLESIP.PNG b/imgSite/LOGO_SIMPLESIP.PNG new file mode 100644 index 0000000000000000000000000000000000000000..444b5f10e38867ca2df89fef0da5fcdda734fc76 GIT binary patch literal 48299 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'Arial', '', 6); Parametros ('FONTE', '(B | I | '')','TAMANHO') - * $pdf->AddPage(); Adiciona a primeira página - * $pdf->Ln(5); Pula linhas - * - * Para gerar a tabela no PDF é necessário a população de dados é feita apartir de um array - * que engloba 4 arrays multidimensionais um Array comun e uma variavel boolean. - * - * Exemplo de geração: - * $pdf->Table(Array 1, Array 2, Array 3, Array 4, Array 5, boolean); - * - * Array 1 = Array para o cabeçalho(Header) [MULTIDIMENSIONAL]; - * Array 2 = Array para os dados do cabeçalho [MULTIDIMENSIONAL]; - * Array 3 = Array de dados para o preencimento das linhas [MULTIDIMENSIONAL] - * Array 4 = Array para o tamanho dos cabeçalhos [COMUM] - * boolean = 0 sem grid | 1 com grid - * - * Por fim para gerar o PDF em arquivo para download ou via browser adicione a linha Output - * com uma target de arquivo. - * - * Exemplo: - * $pdf->Output(NOMEPDF .".pdf", 'target'); - * - * Targets = 'D' para Download | 'I' via browser | 'F' Salva local | 'S' Retorna String - * - * Para saber e adicionar mais recursos na classe e importante verificar a classe FPDF. - * - * ************************************************************************************** - * Copyright (c) 2018, Simples IP - * ************************************************************************************* */ - - require('fpdf.php'); - - class GerarPDF extends FPDF { - - private $nomeRel; - private $dataRel; - private $userRel; - private $logoRel; - private $filtroRelIni; - private $filtroRelFim; - private $filtroRelDac; - private $type; - - function getLogoRel() { - return $this->logoRel; - } +/* * *************************************************************************************** + * + * GERA PDF + * Autor + * Lucas Awade + * + * *************************************************************************************** + * Definições do Projeto + * Nome: GerarPDF + * Data início: 02/08/2018 + * Equipe: Amarildo Pereira + * Descrição: + * O objetivo desta Classe é processar e retornar arquivos em PDF, para isso é necessário + * instanciar o Objeto da classe com os seus atributos. Após o preenchimendo dos atributos + * é importante formatar a fonte e criar uma página inicial para o preenchimento dos dados. + * + * Exemplo formatação: + * $pdf->SetFont('Arial', '', 6); Parametros ('FONTE', '(B | I | '')','TAMANHO') + * $pdf->AddPage(); Adiciona a primeira página + * $pdf->Ln(5); Pula linhas + * + * Para gerar a tabela no PDF é necessário a população de dados é feita apartir de um array + * que engloba 4 arrays multidimensionais um Array comun e uma variavel boolean. + * + * Exemplo de geração: + * $pdf->Table(Array 1, Array 2, Array 3, Array 4, Array 5, boolean); + * + * Array 1 = Array para o cabeçalho(Header) [MULTIDIMENSIONAL]; + * Array 2 = Array para os dados do cabeçalho [MULTIDIMENSIONAL]; + * Array 3 = Array de dados para o preencimento das linhas [MULTIDIMENSIONAL] + * Array 4 = Array para o tamanho dos cabeçalhos [COMUM] + * boolean = 0 sem grid | 1 com grid + * + * Por fim para gerar o PDF em arquivo para download ou via browser adicione a linha Output + * com uma target de arquivo. + * + * Exemplo: + * $pdf->Output(NOMEPDF .".pdf", 'target'); + * + * Targets = 'D' para Download | 'I' via browser | 'F' Salva local | 'S' Retorna String + * + * Para saber e adicionar mais recursos na classe e importante verificar a classe FPDF. + * + * ************************************************************************************** + * Copyright (c) 2018, Simples IP + * ************************************************************************************* */ + +require('fpdf.php'); + +class GerarPDF extends FPDF { + + private $nomeRel; + private $dataRel; + private $userRel; + private $logoRel; + private $filtroRelIni; + private $filtroRelFim; + private $filtroRelDac; + private $type; + + function getLogoRel() { + return $this->logoRel; + } - function setLogoRel($logoRel) { - $this->logoRel = $logoRel; - } - - function getNomeRel() { - return $this->nomeRel; - } + function setLogoRel($logoRel) { + $this->logoRel = $logoRel; + } - function setNomeRel($nomeRel) { - $this->nomeRel = $nomeRel; - } + function getNomeRel() { + return $this->nomeRel; + } - function getDataRel() { - return $this->dataRel; - } - - function getUserRel() { - return $this->userRel; - } + function setNomeRel($nomeRel) { + $this->nomeRel = $nomeRel; + } - function setDataRel($dataRel) { - $this->dataRel = $dataRel; - } + function getDataRel() { + return $this->dataRel; + } - function setUserRel($userRel) { - $this->userRel = $userRel; - } + function getUserRel() { + return $this->userRel; + } - function getFiltroRelIni() { - return $this->filtroRelIni; - } + function setDataRel($dataRel) { + $this->dataRel = $dataRel; + } - function getFiltroRelFim() { - return $this->filtroRelFim; - } + function setUserRel($userRel) { + $this->userRel = $userRel; + } - function setFiltroRelIni($filtroRelIni) { - $this->filtroRelIni = $filtroRelIni; - } + function getFiltroRelIni() { + return $this->filtroRelIni; + } - function setFiltroRelFim($filtroRelFim) { - $this->filtroRelFim = $filtroRelFim; - } + function getFiltroRelFim() { + return $this->filtroRelFim; + } - function getFiltroRelDac() { - return $this->filtroRelDac; - } + function setFiltroRelIni($filtroRelIni) { + $this->filtroRelIni = $filtroRelIni; + } - function setFiltroRelDac($filtroRelDac) { - $this->filtroRelDac = $filtroRelDac; - } - function getType() { - return $this->type; - } + function setFiltroRelFim($filtroRelFim) { + $this->filtroRelFim = $filtroRelFim; + } - function setType($type) { - $this->type = $type; - } + function getFiltroRelDac() { + return $this->filtroRelDac; + } - function Header() { - // Logo - - $this->Image(file_exists($this->getLogoRel()) ? $this->getLogoRel() : LOGO_HEADER_RELATORIO, 10, 13, 30); - $this->SetFont('Arial', 'B', 13); - $this->Cell(80); - // Titulo - $this->Cell($this->type == "L" ? 120 : 30, 5, $this->getNomeRel(), 0, 0, 'C'); - $this->Ln(1); - $this->SetFont('Arial', 'B', 9); - $this->Cell(0, 18, sprintf("Datas Filtradas: %s até %s", $this->getFiltroRelIni(), $this->getFiltroRelFim()), 0, 0, 'C'); - $this->Ln(5); - $this->getFiltroRelDac() ? $this->Cell(0, 18, sprintf("Fila: %s", $this->getFiltroRelDac()), 0, 0, 'C') : ''; - $this->Ln(15); - } + function setFiltroRelDac($filtroRelDac) { + $this->filtroRelDac = $filtroRelDac; + } + + function getType() { + return $this->type; + } + + function setType($type) { + $this->type = $type; + } + + function Header() { + // Logo + + $this->Image(file_exists($this->getLogoRel()) ? $this->getLogoRel() : LOGO_HEADER_RELATORIO, 10, 13, 30); + $this->SetFont('Arial', 'B', 13); + $this->Cell(80); + // Titulo + $this->Cell($this->type == "L" ? 120 : 30, 5, $this->getNomeRel(), 0, 0, 'C'); + $this->Ln(1); + $this->SetFont('Arial', 'B', 9); + $this->Cell(0, 18, sprintf("Datas Filtradas: %s até %s", $this->getFiltroRelIni(), $this->getFiltroRelFim()), 0, 0, 'C'); + $this->Ln(5); + $this->getFiltroRelDac() ? $this->Cell(0, 18, sprintf("Fila: %s", $this->getFiltroRelDac()), 0, 0, 'C') : ''; + $this->Ln(15); + } + + function Table($header, $dataRow, $dataDB, $headerW, $totaliza, $gridRow = 0) { + $this->SetFillColor(200); + $this->SetLineWidth(.1); + $this->SetFont('Arial', 'B'); + $this->Ln(2); + $i = 0; + foreach ($header as $keyH => $dataH) { + $this->Cell($headerW[$i], 7, $keyH, $gridRow, 0, $dataH, true); + $i++; + } + $this->Ln(); + // Cor das linhas da tabela + $this->SetFillColor(255); + + $this->SetFont(''); + $fill = false; + foreach ($dataDB as $keyD => $data) { + $x = 0; - function Table($header, $dataRow, $dataDB, $headerW, $totaliza, $gridRow = 0) { - $this->SetFillColor(235); - $this->SetLineWidth(.1); - $this->SetFont('Arial', 'B'); - $this->Ln(2); - $i = 0; - foreach ($header as $keyH => $dataH) { - $this->Cell($headerW[$i], 7, $keyH, $gridRow, 0, $dataH, true); - $i++; - } - $this->Ln(); // Cor das linhas da tabela $this->SetFillColor(255); - $this->SetFont(''); - $fill = false; - foreach ($dataDB as $keyD => $data) { - $x = 0; - foreach ($dataRow as $keyR => $row) { - $this->Cell($headerW[$x], 7, $data[$keyR] ? $data[$keyR] : "0", $gridRow, 0, $row, $fill); - $x++; - } - $this->Ln(); - $fill = !$fill; + $setFill = 0; + if (array_key_exists('cor_linha_dados', $data)) { + $this->SetFillColor((int) $data['cor_linha_dados']); + $setFill = 1; } - $this->Ln(3); - if ($totaliza) { - $this->SetFont('Arial', 'B'); - $this->SetFillColor(235); - for ($t = 0; $t < count($totaliza); $t++) { - $this->Cell($headerW[$t], 7, $totaliza[$t], 0, 0, 'C', true); - } + + foreach ($dataRow as $keyR => $row) { + $this->Cell($headerW[$x], 7, $data[$keyR] ? $data[$keyR] : "0", $gridRow, 0, $row, ($setFill ? $setFill : $fill)); + $x++; } - $this->Ln(6); - $this->Cell(array_sum($headerW), 0, '', ''); + + $this->Ln(); + $fill = !$fill; } - - function Footer() { - $this->SetY(-15); - $this->SetFont('Arial', '', 8); - $this->Cell(0, 15, 'Emitido em: ' . $this->dataRel . " | Gerado por: " . $this->userRel, 0, 0, 'L'); - $this->Cell(0, 15, 'Página ' . $this->PageNo(), 0, 0, 'R'); + $this->Ln(3); + if ($totaliza) { + $this->SetFont('Arial', 'B'); + $this->SetFillColor(235); + for ($t = 0; $t < count($totaliza); $t++) { + $this->Cell($headerW[$t], 7, $totaliza[$t], 0, 0, 'C', true); + } } + $this->Ln(6); + $this->Cell(array_sum($headerW), 0, '', ''); + } + function Footer() { + $this->SetY(-15); + $this->SetFont('Arial', '', 8); + $this->Cell(0, 15, 'Emitido em: ' . $this->dataRel . " | Gerado por: " . $this->userRel, 0, 0, 'L'); + $this->Cell(0, 15, 'Página ' . $this->PageNo(), 0, 0, 'R'); } +} + ?> diff --git a/include/util/constantes.php b/include/util/constantes.php index cc716135..786687bd 100644 --- a/include/util/constantes.php +++ b/include/util/constantes.php @@ -450,4 +450,12 @@ define('IP_CENTRAL_ATUALIZACAO', '192.168.115.12'); * Mascara a ser mostrada nos campos de senha. */ define('MASCARA_PASSWORD', '*******'); -?> + + +/* + * Define o comportamento dos relatorios de servico. + */ + +define("RELATORIO_SERVICOS_DESABILITA", 0); +define("RELATORIO_SERVICOS_HABILITA", 1); +define("RELATORIO_SERVICOS_FILTROS", 2); \ No newline at end of file diff --git a/include/util/funcoesApl.php b/include/util/funcoesApl.php index c999274e..c60e68d5 100644 --- a/include/util/funcoesApl.php +++ b/include/util/funcoesApl.php @@ -105,7 +105,7 @@ function VerificaCadastroMenu($conn) { $menuUsuario[] = array('29', 'mnMetaMensal', '1', 'Meta Mensal', 'index.php?idProg=32', '', '28', '1', '0', '', '32'); //$menuUsuario[] = array('30','mnMetaMensaAneel','1','Meta Mensal Analítico','index.php?idProg=1','','28','1','0','','1'); $menuUsuario[] = array('31', 'mnMetaDiaria', '1', 'Meta Diária', 'index.php?idProg=33', '', '28', '1', '0', '', '33'); - $menuUsuario[] = array('32', 'mnMetaDiariaAneel', '1', 'Meta Diária Aneel', 'index.php?idProg=2', '', '28', '1', '0', '', '2'); + //$menuUsuario[] = array('32', 'mnMetaDiariaAneel', '1', 'Meta Diária Aneel', 'index.php?idProg=2', '', '28', '1', '0', '', '2'); $menuUsuario[] = array('33', 'mnRelOriginadasAgente', '1', 'Originadas/Agente', 'index.php?idProg=89', '', '18', '1', '0', '', '89'); $menuUsuario[] = array('34', 'mnRelProdAgente', '1', 'Produção/Agente', 'index.php?idProg=0', '', '18', '1', '0', '', '0'); // $menuUsuario[] = array('35','mnRamlRamal','1','Ramal/Ramal','index.php?idProg=47','','18','0','0'); @@ -315,15 +315,15 @@ function VerificaCadastroMenu($conn) { $menuUsuario[] = array('176', 'mnGrupoVendas', '1', 'Regionais', 'index.php?idProg=285', '', '173', '1', '0', '', '285'); } - $menuUsuario[] = array('177', 'mnAnalysis', '1', 'Gráficos', 'index.php?idProg=58&idMenu=177&menuNome=Analysis', '', '17', '1', '0', '', '58'); - $menuUsuario[] = array('178', 'mnResumoOperacao', '1', 'Resumo Chamadas/DAC', 'index.php?idProg=289', '', '177', '1', '0', '', '289'); - $menuUsuario[] = array('179', 'mnResumoOperacaoServico', '1', 'Resumo Chamadas/Serviços', 'index.php?idProg=290', '', '177', '1', '0', '', '290'); - $menuUsuario[] = array('180', 'mnIndicesDac', '1', 'Índices/DAC', 'index.php?idProg=291', '', '177', '1', '0', '', '291'); - $menuUsuario[] = array('181', 'mnIndicesServ', '1', 'Índices/Serviços', 'index.php?idProg=292', '', '177', '1', '0', '', '292'); - $menuUsuario[] = array('182', 'mnMetaMensalServ', '1', 'Meta Mensal/Serviço', 'index.php?idProg=293', '', '28', '1', '0', '', '293'); - $menuUsuario[] = array('183', 'mnMetaDiariaServ', '1', 'Meta Diária/Serviço', 'index.php?idProg=294', '', '28', '1', '0', '', '294'); - $menuUsuario[] = array('184', 'mnDesempenhoDac', '1', 'Desempenho por DAC', 'index.php?idProg=300', '', '177', '1', '0', '', '300'); - $menuUsuario[] = array('185', 'mnDesempenhoServ', '1', 'Desempenho por Serviço', 'index.php?idProg=301', '', '177', '1', '0', '', '301'); +// $menuUsuario[] = array('177', 'mnAnalysis', '1', 'Gráficos', 'index.php?idProg=58&idMenu=177&menuNome=Analysis', '', '17', '1', '0', '', '58'); +// $menuUsuario[] = array('178', 'mnResumoOperacao', '1', 'Resumo Chamadas/DAC', 'index.php?idProg=289', '', '177', '1', '0', '', '289'); +// $menuUsuario[] = array('179', 'mnResumoOperacaoServico', '1', 'Resumo Chamadas/Serviços', 'index.php?idProg=290', '', '177', '1', '0', '', '290'); +// $menuUsuario[] = array('180', 'mnIndicesDac', '1', 'Índices/DAC', 'index.php?idProg=291', '', '177', '1', '0', '', '291'); +// $menuUsuario[] = array('181', 'mnIndicesServ', '1', 'Índices/Serviços', 'index.php?idProg=292', '', '177', '1', '0', '', '292'); +// $menuUsuario[] = array('182', 'mnMetaMensalServ', '1', 'Meta Mensal/Serviço', 'index.php?idProg=293', '', '28', '1', '0', '', '293'); +// $menuUsuario[] = array('183', 'mnMetaDiariaServ', '1', 'Meta Diária/Serviço', 'index.php?idProg=294', '', '28', '1', '0', '', '294'); +// $menuUsuario[] = array('184', 'mnDesempenhoDac', '1', 'Desempenho por DAC', 'index.php?idProg=300', '', '177', '1', '0', '', '300'); +// $menuUsuario[] = array('185', 'mnDesempenhoServ', '1', 'Desempenho por Serviço', 'index.php?idProg=301', '', '177', '1', '0', '', '301'); $menuUsuario[] = array('186', 'mnUra', '1', 'URA', 'index.php?idProg=58&idMenu=186&menuNome=URA', '', '17', '1', '0', '', '58'); @@ -1121,6 +1121,7 @@ function GetDispProgSel($idProg) { $dispProgSel[356] = 'SimplesChat'; $dispProgSel[358] = 'Dashboard'; + $dispProgSel[365] = 'Recebidas Agente/Serviços'; $dispProgSel[10001] = "Cadastro de Agentes PBX"; $dispProgSel[10002] = "Cadastro de Filas"; @@ -1632,7 +1633,8 @@ function GetParametros($db) { 'prm_classifica_municipio', 'prm_max_agente_pausa', 'prm_disponivel_fila', 'prm_boloco_notas_key', 'caminho_producao', 'prm_exige_classificacao', 'prm_obs_pausaprod', 'prm_modulo_pesquisa', 'prm_portabilidade', 'prm_tarifacao', 'prm_prepago', 'prm_use_discador', 'prm_tempo_sessao', 'prm_agente_nova_janela', 'prm_label_protoco_pesquisa', 'prm_label_protoco_texto', 'prm_label_protoco_grid', 'prm_registro_pagina', 'prm_use_vendas', 'prm_nome_vendas', 'prm_exige_proto_vendas', 'prm_alerta_classificacao', 'prm_ativa_integracao', 'prm_select_integracao', 'prm_aviso_desconnect', 'prm_link_audio', - 'prm_ocultar_telefone', 'prm_ocultar_email', 'prm_ocultar_documento', 'prm_sk_host_chat', 'prm_chat_api', 'prm_chat_url_client', 'prm_sk_api_centrais', 'prm_max_licenca', 'prm_max_ramal', 'prm_max_licenca_fixo', 'prm_media_simultaneo', 'prm_ativa_complemento_campanha'); + 'prm_ocultar_telefone', 'prm_ocultar_email', 'prm_ocultar_documento', 'prm_sk_host_chat', 'prm_chat_api', 'prm_chat_url_client', 'prm_sk_api_centrais', 'prm_max_licenca', 'prm_max_ramal', 'prm_max_licenca_fixo', 'prm_media_simultaneo', + 'prm_ativa_complemento_campanha', 'prm_relatorio_servico'); $query = "select prm_slogan, prm_path_audio, prm_path_arq_agente, prm_logo_relatorio, prm_relatorio_head, prm_relatorio_linha1, prm_relatorio_linha2, @@ -1647,7 +1649,8 @@ function GetParametros($db) { prm_exige_classificacao, prm_obs_pausaprod, prm_modulo_pesquisa, prm_portabilidade, prm_tarifacao, prm_prepago, prm_use_discador, prm_tempo_sessao, prm_agente_nova_janela, prm_label_protoco_pesquisa, prm_label_protoco_texto, prm_label_protoco_grid, prm_registro_pagina, prm_use_vendas, prm_nome_vendas, prm_exige_proto_vendas, prm_alerta_classificacao, prm_ativa_integracao, prm_select_integracao, prm_aviso_desconnect, - prm_link_audio, prm_ocultar_telefone, prm_ocultar_email, prm_ocultar_documento, prm_sk_host_chat, prm_chat_api, prm_chat_url_client, prm_sk_api_centrais, prm_max_licenca, prm_max_ramal, prm_max_licenca_fixo, prm_media_simultaneo, prm_ativa_complemento_campanha + prm_link_audio, prm_ocultar_telefone, prm_ocultar_email, prm_ocultar_documento, prm_sk_host_chat, prm_chat_api, prm_chat_url_client, prm_sk_api_centrais, prm_max_licenca, + prm_max_ramal, prm_max_licenca_fixo, prm_media_simultaneo, prm_ativa_complemento_campanha, prm_relatorio_servico from pbx_parametros where id = 1"; $result = pg_query($db, $query); @@ -3613,16 +3616,17 @@ function ConfigRamalMonitorar() { } } -function GetIdentRota($dbcon, $codServ = 0) { +function GetIdentRota($dbcon, $codServ = 0, $wdt = 160) { $codSel = $codServ; - $serv = ""; $sel = $codSel == '0' ? "selected" : ""; $serv .= ""; $cont = 0; $i = 0; $query = "select serv_id as identificador from pbx_servicos where serv_status = 1 order by 1"; - $result = @pg_query($dbcon, $query); + $result = !$dbcon ? @pg_query($query) : @pg_query($dbcon, $query); while ($dados = pg_fetch_row($result)) { if ($codSel === $dados[0]) { $sel = "selected"; @@ -4722,3 +4726,18 @@ values(%s, %s, %s, 'GET', %s, (select substring(arquivo, function ComplementoCampanhaAtivo() { return $_SESSION['prm_ativa_complemento_campanha']; } + +function VerificaUsoServicos() { + + if (!isset($_SESSION["SSUsoServico"])) { + $query = "select case when( exists( select '' from pbx_servicos a, pbx_servicos_registra b where b.serv_id = a.serv_id))then 1 else 0 end as existe_servico"; + $result = pg_query($query); + $row = pg_fetch_row($result); + $_SESSION["SSUsoServico"] = $row[0] ? true : false; + } + return $_SESSION["SSUsoServico"]; +} + +function GetUsoServico() { + return $_SESSION["prm_relatorio_servico"]; +} diff --git a/include/util/funcoesInternas.php b/include/util/funcoesInternas.php index cb8edd41..e6874da6 100644 --- a/include/util/funcoesInternas.php +++ b/include/util/funcoesInternas.php @@ -6,10 +6,10 @@ */ $funcosInternas[] = "insert into pbx_funcoes_internas(id_prog, arquivo, id_prog_pai, status, exit)values(0,'relatorios/callcenter/geral/relAgenteProducao.php',0,0,0)"; //$funcosInternas[] = "insert into pbx_funcoes_internas(id_prog, arquivo, id_prog_pai, status, exit)values(1,'relatorios/callcenter/metas/metricasMensalAneel.php',1,0,0)"; -$funcosInternas[] = "insert into pbx_funcoes_internas(id_prog, arquivo, id_prog_pai, status, exit)values(2,'relatorios/callcenter/metas/metricasDiariaAneel.php',2,0,0)"; -$funcosInternas[] = "insert into pbx_funcoes_internas(id_prog, arquivo, id_prog_pai, status, exit)values(3,'relatorios/callcenter/geral/relAgenteProducaoImp.php',0,0,1)"; +//$funcosInternas[] = "insert into pbx_funcoes_internas(id_prog, arquivo, id_prog_pai, status, exit)values(2,'relatorios/callcenter/metas/metricasDiariaAneel.php',2,0,0)"; +//$funcosInternas[] = "insert into pbx_funcoes_internas(id_prog, arquivo, id_prog_pai, status, exit)values(3,'relatorios/callcenter/geral/relAgenteProducaoImp.php',0,0,1)"; //$funcosInternas[] = "insert into pbx_funcoes_internas(id_prog, arquivo, id_prog_pai, status, exit)values(4,'relatorios/callcenter/metas/metricasMensalAneelImp.php',1,0,1)"; -$funcosInternas[] = "insert into pbx_funcoes_internas(id_prog, arquivo, id_prog_pai, status, exit)values(5,'relatorios/callcenter/metas/metricasDiariaAneelImp.php',2,0,1)"; +//$funcosInternas[] = "insert into pbx_funcoes_internas(id_prog, arquivo, id_prog_pai, status, exit)values(5,'relatorios/callcenter/metas/metricasDiariaAneelImp.php',2,0,1)"; $funcosInternas[] = "insert into pbx_funcoes_internas(id_prog, arquivo, id_prog_pai, status, exit)values(6,'supervisor.php',6,0,0)"; $funcosInternas[] = "insert into pbx_funcoes_internas(id_prog, arquivo, id_prog_pai, status, exit)values(7,'relatorios/callcenter/geral/relTransfer.php',7,0,0)"; //$funcosInternas[] = "insert into pbx_funcoes_internas(id_prog, arquivo, id_prog_pai, status, exit)values(8,'relatorios/callcenter/geral/relResumoFone.php',8,0,0)"; @@ -39,7 +39,7 @@ $funcosInternas[] = "insert into pbx_funcoes_internas(id_prog, arquivo, id_prog_ $funcosInternas[] = "insert into pbx_funcoes_internas(id_prog, arquivo, id_prog_pai, status, exit)values(31,'cadastros/classificaAtendimento/classificaDetUpd.php',27,0,0)"; $funcosInternas[] = "insert into pbx_funcoes_internas(id_prog, arquivo, id_prog_pai, status, exit)values(32,'relatorios/callcenter/metas/metricasMensal.php',32,0,0)"; $funcosInternas[] = "insert into pbx_funcoes_internas(id_prog, arquivo, id_prog_pai, status, exit)values(33,'relatorios/callcenter/metas/metricasDiaria.php',33,0,0)"; -$funcosInternas[] = "insert into pbx_funcoes_internas(id_prog, arquivo, id_prog_pai, status, exit)values(34,'relatorios/callcenter/metas/metricasMensalImp.php',32,0,1)"; +//$funcosInternas[] = "insert into pbx_funcoes_internas(id_prog, arquivo, id_prog_pai, status, exit)values(34,'relatorios/callcenter/metas/metricasMensalImp.php',32,0,1)"; $funcosInternas[] = "insert into pbx_funcoes_internas(id_prog, arquivo, id_prog_pai, status, exit)values(35,'relatorios/callcenter/metas/metricasDiariaImp.php',33,0,1)"; $funcosInternas[] = "insert into pbx_funcoes_internas(id_prog, arquivo, id_prog_pai, status, exit)values(36,'seguranca/perfil/perfilGrupo.php',36,0,0)"; $funcosInternas[] = "insert into pbx_funcoes_internas(id_prog, arquivo, id_prog_pai, status, exit)values(37,'relatorios/pbx/chamadasSaintes/saintesRamal.php',37,0,0)"; @@ -237,7 +237,7 @@ $funcosInternas[] = "insert into pbx_funcoes_internas(id_prog, arquivo, id_prog_ $funcosInternas[] = "insert into pbx_funcoes_internas(id_prog, arquivo, id_prog_pai, status, exit)values(265,'supervisao/RelSupRecebidas.php',6,0,0)"; $funcosInternas[] = "insert into pbx_funcoes_internas(id_prog, arquivo, id_prog_pai, status, exit)values(266,'relatorios/callcenter/metas/metricasDiaSemana.php',266,0,0)"; $funcosInternas[] = "insert into pbx_funcoes_internas(id_prog, arquivo, id_prog_pai, status, exit)values(267,'relatorios/callcenter/metas/MetaDiaSemanaExcel.php',266,0,1)"; -$funcosInternas[] = "insert into pbx_funcoes_internas(id_prog, arquivo, id_prog_pai, status, exit)values(268,'relatorios/callcenter/metas/metricasDiaSemanaImp.php',266,0,1)"; +//$funcosInternas[] = "insert into pbx_funcoes_internas(id_prog, arquivo, id_prog_pai, status, exit)values(268,'relatorios/callcenter/metas/metricasDiaSemanaImp.php',266,0,1)"; $funcosInternas[] = "insert into pbx_funcoes_internas(id_prog, arquivo, id_prog_pai, status, exit)values(269,'cadastros/tarifacao/tarifacaoOperadorasRel.php',199,0,0)"; $funcosInternas[] = "insert into pbx_funcoes_internas(id_prog, arquivo, id_prog_pai, status, exit)values(270,'cadastros/tarifacao/tarifaRefatura.php',270,0,0)"; $funcosInternas[] = "insert into pbx_funcoes_internas(id_prog, arquivo, id_prog_pai, status, exit)values(271,'downloadAudio.php',271,0,0)"; @@ -262,13 +262,13 @@ $funcosInternas[] = "insert into pbx_funcoes_internas(id_prog, arquivo, id_prog_ $funcosInternas[] = "insert into pbx_funcoes_internas(id_prog, arquivo, id_prog_pai, status, exit)values(290,'relatorios/analise/resumoOperacaoServico.php',290,0,0)"; $funcosInternas[] = "insert into pbx_funcoes_internas(id_prog, arquivo, id_prog_pai, status, exit)values(291,'relatorios/analise/indicesDac.php',291,0,0)"; $funcosInternas[] = "insert into pbx_funcoes_internas(id_prog, arquivo, id_prog_pai, status, exit)values(292,'relatorios/analise/indicesServicos.php',292,0,0)"; -$funcosInternas[] = "insert into pbx_funcoes_internas(id_prog, arquivo, id_prog_pai, status, exit)values(293,'relatorios/callcenter/metas/metricasMensalServ.php',293,0,0)"; -$funcosInternas[] = "insert into pbx_funcoes_internas(id_prog, arquivo, id_prog_pai, status, exit)values(294,'relatorios/callcenter/metas/metricasDiariaServ.php',294,0,0)"; -$funcosInternas[] = "insert into pbx_funcoes_internas(id_prog, arquivo, id_prog_pai, status, exit)values(295,'relatorios/callcenter/metas/metricasMensalServImp.php',32,0,1)"; -$funcosInternas[] = "insert into pbx_funcoes_internas(id_prog, arquivo, id_prog_pai, status, exit)values(296,'relatorios/callcenter/metas/MetaMensalServExcel.php',32,0,1)"; -$funcosInternas[] = "insert into pbx_funcoes_internas(id_prog, arquivo, id_prog_pai, status, exit)values(297,'relatorios/callcenter/metas/metricasDiariaServImp.php',33,0,1)"; -$funcosInternas[] = "insert into pbx_funcoes_internas(id_prog, arquivo, id_prog_pai, status, exit)values(298,'relatorios/callcenter/metas/metricasDiariaServExcel.php',33,0,1)"; -$funcosInternas[] = "insert into pbx_funcoes_internas(id_prog, arquivo, id_prog_pai, status, exit)values(299,'relatorios/callcenter/metas/MetaDiariaServExcel.php',33,0,1)"; +//$funcosInternas[] = "insert into pbx_funcoes_internas(id_prog, arquivo, id_prog_pai, status, exit)values(293,'relatorios/callcenter/metas/metricasMensalServ.php',293,0,0)"; +//$funcosInternas[] = "insert into pbx_funcoes_internas(id_prog, arquivo, id_prog_pai, status, exit)values(294,'relatorios/callcenter/metas/metricasDiariaServ.php',294,0,0)"; +//$funcosInternas[] = "insert into pbx_funcoes_internas(id_prog, arquivo, id_prog_pai, status, exit)values(295,'relatorios/callcenter/metas/metricasMensalServImp.php',32,0,1)"; +//$funcosInternas[] = "insert into pbx_funcoes_internas(id_prog, arquivo, id_prog_pai, status, exit)values(296,'relatorios/callcenter/metas/MetaMensalServExcel.php',32,0,1)"; +//$funcosInternas[] = "insert into pbx_funcoes_internas(id_prog, arquivo, id_prog_pai, status, exit)values(297,'relatorios/callcenter/metas/metricasDiariaServImp.php',33,0,1)"; +//$funcosInternas[] = "insert into pbx_funcoes_internas(id_prog, arquivo, id_prog_pai, status, exit)values(298,'relatorios/callcenter/metas/metricasDiariaServExcel.php',33,0,1)"; +//$funcosInternas[] = "insert into pbx_funcoes_internas(id_prog, arquivo, id_prog_pai, status, exit)values(299,'relatorios/callcenter/metas/MetaDiariaServExcel.php',33,0,1)"; $funcosInternas[] = "insert into pbx_funcoes_internas(id_prog, arquivo, id_prog_pai, status, exit)values(300,'relatorios/analise/desempenhoDac.php',300,0,0)"; $funcosInternas[] = "insert into pbx_funcoes_internas(id_prog, arquivo, id_prog_pai, status, exit)values(301,'relatorios/analise/desempenhoServico.php',301,0,0)"; $funcosInternas[] = "insert into pbx_funcoes_internas(id_prog, arquivo, id_prog_pai, status, exit)values(302,'relatorios/ura/uraGeral.php',302,0,0)"; @@ -336,6 +336,20 @@ $funcosInternas[] = "insert into pbx_funcoes_internas(id_prog, arquivo, id_prog_ $funcosInternas[] = "insert into pbx_funcoes_internas(id_prog, arquivo, id_prog_pai, status, exit)values(364,'admLgpd.php',364,0,0)"; + + + + + + + + + + + + + + $funcosInternas[] = "insert into pbx_funcoes_internas(id_prog, arquivo, id_prog_pai, status, exit)values(10001,'admin/agents.php',10001,0,0)"; $funcosInternas[] = "insert into pbx_funcoes_internas(id_prog, arquivo, id_prog_pai, status, exit)values(10002,'admin/queues.php',10002,0,0)"; $funcosInternas[] = "insert into pbx_funcoes_internas(id_prog, arquivo, id_prog_pai, status, exit)values(10004,'admin/agenda.php',10004,0,0)"; diff --git a/include/util/util.php b/include/util/util.php index 64cacd49..92f5e3d7 100644 --- a/include/util/util.php +++ b/include/util/util.php @@ -193,10 +193,10 @@ function RemoveAcentos($str, $upper = False) { function TextToHtml($str) { $text = array('á', 'é', 'í', 'ó', 'ú', 'â', 'ê', 'ô', 'ã', 'õ', 'à', 'ç', 'Á', 'É', 'Í', 'Ó', 'Ú', 'Â', 'Ê', 'Ô', 'Ã', 'Õ', 'À', 'Ç', '&'); $subs = array('á', 'é', 'í', 'ó', 'ú', 'â', 'ê', 'ô', 'ã', 'õ', 'à', 'ç', 'Á', 'É', 'Í', 'Ó', 'Ú', 'Â', 'Ê', 'Ô', 'Ã', 'Õ', 'À', 'Ç', '&'); - + for ($i = 0; $i < strlen($str); $i++) { $j = array_search($str[$i], $text); - if ($j !== false){ + if ($j !== false) { $str[$i] = $subs[$j]; } } @@ -372,14 +372,14 @@ function LimpaString($str, $toUpeer = true, $removeSpace = true) { if (!isset($str) || !$str) { return ''; } else - if (!is_string($str)) { + if (!is_string($str)) { return $str; } $string = trim($str); $array1 = array('À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ð', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'Þ', 'ß', 'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ð', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', 'ø', 'ù', 'ú', 'û', 'ü', 'ý'); $array2 = array('A', 'A', 'A', 'A', 'A', 'A', 'A', 'C', 'E', 'E', 'E', 'E', 'I', 'I', 'I', 'I', 'D', 'N', 'O', 'O', 'O', 'O', 'O', 'O', 'U', 'U', 'U', 'U', 'U', 'P', 'B', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'c', 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i', 'o', 'n', 'o', 'o', 'o', 'o', 'o', 'o', 'u', 'u', 'u', 'u', 'y'); $string = str_replace($array1, $array2, $string); - $newstring = preg_replace(($removeSpace ? "/[^a-zA-Z0-9_.]/" : "/[^a-zA-Z0-9\s_.]/"), "", $string); + $newstring = preg_replace(($removeSpace ? "/[^a-zA-Z0-9_.]/" : "/[^a-zA-Z0-9\s_.]/"), "", $string); return $toUpeer ? strtoupper($newstring) : $newstring; } @@ -524,7 +524,7 @@ function GetDefStrDb() { } function GetSckConnect() { - + $path = "bd"; $arq = @fopen($path, 'r', true); if (!$arq) { @@ -1451,14 +1451,20 @@ function ApagaBilheteDuplTransfer($dbcon) { */ $path = '/var/log/asterisk/apaga_bilhetes_transfer.log'; - $query = "delete from ast_bilhetes a where rtrim(disposition) in('NO ANSWER', 'BUSY', 'FAILED') and exists(select '' from ast_bilhetes where uniqueid = a.uniqueid and rtrim(disposition) = 'ANSWERED'); -drop table if exists bilhetes_dupl; + $query = "delete from ast_bilhetes a where rtrim(disposition) in('NO ANSWER', 'BUSY', 'FAILED') and exists(select '' from ast_bilhetes where uniqueid = a.uniqueid and rtrim(disposition) = 'ANSWERED');"; + + if (!pg_query($dbcon, $query)) { + $log = sprintf("Data: %s Cmd: Erro: %s\n", date('Y-m-d H:i:s'), $query, GetLasterror()); + WriteLog($log, $path); + } + + $query = "drop table if exists bilhetes_dupl; create table bilhetes_dupl as select uniqueid, min(sequence) as sequence from ast_bilhetes where calldate::date = now()::date group by uniqueid having count(*) > 1; delete from ast_bilhetes a using bilhetes_dupl b where b.uniqueid = a.uniqueid and a.sequence not in(select sequence from bilhetes_dupl);"; if (!pg_query($dbcon, $query)) { - $log = GetLasterror(); + $log = sprintf("Data: %s Cmd: Erro: %s\n", date('Y-m-d H:i:s'), $query, GetLasterror()); WriteLog($log, $path); } } @@ -1542,7 +1548,6 @@ function GetParamLgpd($param) { return false; } - function GetDiasAbandonada($conn = null) { $query = "select prm_abandonada_semretorno from pbx_parametros"; $result = $conn ? pg_query($conn, $query) : pg_query($query); diff --git a/login.php b/login.php index 11864455..81e24aba 100644 --- a/login.php +++ b/login.php @@ -86,6 +86,7 @@ if (!isset($_POST["loginUser"])) { // $siteError->SetLogin($row['apelido']); //parametros do sistema GetParametros($dbcon); + //armazenha informacoes para relatórios de pabx em base diversa SetDefaultSite($dbcon); if (true) { @@ -94,10 +95,10 @@ if (!isset($_POST["loginUser"])) { // SetSupervisorAcesso($dbcon); Desativaro era usado para identificar se o superfivor tem acesso nas filas ativas e receptiva. SetAgente($dbcon); - //Modo de atendimento default + // Modo de atendimento default SetModuAtendimentoDefault(); - //caminhos para gravar arquivos + // caminhos para gravar arquivos GetCofigPadrao($dbcon); } diff --git a/master.css b/master.css index 19a51fba..d8455ea2 100644 --- a/master.css +++ b/master.css @@ -156,7 +156,7 @@ a:active background: #f09f47; height: 30px; color: #FFFFFF; - + } #nav_login @@ -982,12 +982,22 @@ table.gridClean td { } .textPrivate { - background-color: lightblue; - width: 110px; - height: 110px; - overflow: scroll; + background-color: lightblue; + width: 110px; + height: 110px; + overflow: scroll; } .textPrivate p { - text-align: justify; + text-align: justify; } + +#agrupamentoTable th !important { + + font-weight: bold; + padding: 0; + margin: 0; + padding-left: 6px; + padding-right: 6px; + background-color: #4F71C0; +} \ No newline at end of file diff --git a/nbproject/private/private.properties b/nbproject/private/private.properties index 61857fd2..9fc15f70 100644 --- a/nbproject/private/private.properties +++ b/nbproject/private/private.properties @@ -2,6 +2,7 @@ browser.id=SL[/Browsers/FirefoxBrowser copy.src.files=false copy.src.on.open=false copy.src.target=/var/www/aplicativo +include.path.private= index.file=index.php run.as=LOCAL url=http://localhost/ diff --git a/nbproject/private/private.xml b/nbproject/private/private.xml index 8fe73eef..d7e43d1c 100644 --- a/nbproject/private/private.xml +++ b/nbproject/private/private.xml @@ -3,8 +3,16 @@ - file:/var/www/html/aplicativo/asterisk/var_lib_asterisk/scripts/integracao/abdAgi.php + file:/var/www/html/aplicativo/relatorios/relBase.php + file:/var/www/html/aplicativo/include/FPDF/fpdf.php + file:/var/www/html/aplicativo/include/util/relatoriosBase.php file:/var/www/html/aplicativo/index.php + file:/var/www/html/aplicativo/include/util/funcoesInternas.php + file:/var/www/html/aplicativo/relatorios/callcenter/geral/relAgenteProducao.php + file:/var/www/html/aplicativo/relatorios/callcenter/servicos/recebidasAgenteSrv.php + file:/var/www/html/aplicativo/relatorios/callcenter/geral/rechamadas.php + file:/var/www/html/aplicativo/contacteFunc.php + file:/var/www/html/aplicativo/include/FPDF/GerarPDF.php file:/var/www/html/aplicativo/include/util/funcoesApl.php diff --git a/nbproject/project.properties b/nbproject/project.properties index 0e58865d..88cadcda 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -1,4 +1,4 @@ -include.path=${php.global.include.path} +include.path= php.version=PHP_56 source.encoding=ISO-8859-1 src.dir=. diff --git a/projeto/base/sql/versao-1.7.11.5.sql b/projeto/base/sql/versao-1.7.11.5.sql index 8b22c5ba..118eeff8 100644 --- a/projeto/base/sql/versao-1.7.11.5.sql +++ b/projeto/base/sql/versao-1.7.11.5.sql @@ -3,3 +3,22 @@ */ insert into pbx_grupo_usuario(user_id, gp_id) select (select id from pbx_usuarios where apelido = 'administrador') as user_id, gp_id from pbx_grupo a where user_id = 0 and not exists(select '' from pbx_grupo_usuario where gp_id = a.gp_id and user_id = (select id from pbx_usuarios where apelido = 'administrador')) + + +/* + * Habilita os servicos nos relatorios de: + * - Recbidas Agente + * - Rechamadas + * - Classificação Atendimento + * - Classificação Mensal + * - Classificação Agente + * - Abandonadas Fila + * - Meta Mensal + * - Meta Diaria + * + * Os valores para o parametro "prm_relatorio_servico" sao os seguintes: + * 0 -> Desabilitado + * 1 -> Habilitado + * 2 -> Habilita apenas os Filtros. + */ +alter table pbx_parametros add prm_relatorio_servico int not null default 0; \ No newline at end of file diff --git a/relatorios/callcenter/geral/abandonadasFila.php b/relatorios/callcenter/geral/abandonadasFila.php index f3e9da3d..e3ed320d 100644 --- a/relatorios/callcenter/geral/abandonadasFila.php +++ b/relatorios/callcenter/geral/abandonadasFila.php @@ -1,770 +1,874 @@ ___tipoRelatorio = isset($_REQUEST['tipoRelatorio']) ? $_REQUEST['tipoRelatorio'] : 0; + public function __construct($idProg, $dbcon, $incDac) { + parent::__construct($idProg, $dbcon, $incDac); + $this->___tipoRelatorio = isset($_REQUEST['tipoRelatorio']) ? $_REQUEST['tipoRelatorio'] : 0; + $this->___servico = isset($_POST["listaServico"]) ? $_POST["listaServico"] : 0; + } + + function ___ValidaForm() { + parent::___ValidaForm(); + if (!IsPostBack()) { + return; + } + if ($this->GetIncDac() && !StrToIntDef($this->___dac)) { + GeraExcept('Informe uma Fila!'); } + } - function ___ValidaForm() { - parent::___ValidaForm(); - if (!IsPostBack()) { - return; + 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->___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ítico' : 'Sintético')); } - if ($this->GetIncDac() && !StrToIntDef($this->___dac)) { - GeraExcept('Informe uma Fila!'); + + $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; } - 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->___tipoRelatorio) = $_SESSION["SSstorageFiltros"]; + if ($this->GetIncDac()) { + $dacs = GetDac($this->GetDbCon(), $this->___dac, "", 0, 1, 0, 0, 1); + } - 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ítico' : 'Sintético')); - } + $lkPrint = ""; + if ($this->___dataCount) { + $prt = 'Clique aqui para imprimir!'; + $prtHtml = "\"Clique"; + $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'); + } - $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; - } + $tipoRel = !$this->___tipoRelatorio ? '' : 'checked="checked"'; + /* + * Personalise esta fun��o se necessitar de outras op��es de filtro. + */ + $filtro = ''; + /* + * Rotulos. + */ + $filtro .= ''; + $filtro .= $this->GetIncDac() ? '' : ''; + $filtro .= GetUsoServico() ? '' : ''; + $filtro .= ''; + $filtro .= ''; + $filtro .= ''; + $filtro .= ''; + $filtro .= ''; + + /* + * Valores. + */ + $filtro .= ''; + $filtro .= $this->GetIncDac() ? sprintf('', $dacs) : ''; + + if (GetUsoServico()) { + $filtro .= sprintf('', GetIdentRota(false, $this->___servico)); + } + $filtro .= ''; + $filtro .= ''; + $filtro .= ''; + $filtro .= ''; + $filtro .= ''; + $filtro .= '
FilaServiçoData InicialData Final Analítico 
%s%s%s
'; + + /* + * Guarda os filtros passados para recuperar na emiss�o dos relat?ios para impress�o. + */ + $_SESSION["SSstorageFiltros"] = array($this->___dac, $this->___dataIni, $this->___dataFim, $this->___tipoRelatorio); + + return sprintf($filtro, $tipoRel, $this->___dataIni, $this->___dataFim, $lkPrint); + } - if ($this->GetIncDac()) { - $dacs = GetDac($this->GetDbCon(), $this->___dac, "", 0, 1, 0, 0, 1); - } + function ___PreparaExcel() { + + $nomeDac = ""; + $dataRel = array(); + $dataAgrup = array(); + $filtro = $this->___FiltrosRelatorio(); + $mostraColunaServicos = GetUsoServico() == RELATORIO_SERVICOS_HABILITA; + /* + * 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; + + if (!$this->___tipoRelatorio) { - $lkPrint = ""; - if ($this->___dataCount) { - $prt = 'Clique aqui para imprimir!'; - $prtHtml = "\"Clique"; - $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'); + $dadosCabecalio = array('Data', 'Hora', 'Origem', 'Quantidade', 'Tempo', 'TMAB'); + $dadosField = array('data', 'hora', 'origem', 'qtde', 'tempo', 'tmab'); + + if ($mostraColunaServicos) { + $dadosCabecalio = array_merge(['Servico'], $dadosCabecalio); + $dadosField = array_merge(['serv_id'], $dadosField); } - $tipoRel = !$this->___tipoRelatorio ? '' : 'checked="checked"'; - /* - * Personalise esta fun��o se necessitar de outras op��es de filtro. - */ - $filtro = ''; /* - * Rotulos. + * Monta a linha de cabecalio. */ - $filtro .= ''; - if ($this->GetIncDac()) - $filtro .= ''; - $filtro .= ''; - $filtro .= ''; - $filtro .= ''; - $filtro .= ''; - $filtro .= ''; + $linha = array('LABEL'); + foreach ($dadosCabecalio as $value) { + $linha[] = $value; + } + $dataRel[] = $linha; + $somaTempo = 0; + $somaQuantidade = 0; /* - * Valores. + * Linhas de dados. */ - $filtro .= ''; - if ($this->GetIncDac()) - $filtro .= sprintf('', $dacs); - $filtro .= ''; - $filtro .= ''; - $filtro .= ''; - $filtro .= ''; - $filtro .= ''; - $filtro .= '
FilaData InicialData Final Analítico 
%s%s
'; + foreach ($this->GetData()[0] as $row) { + $row["data"] = substr(FormataDBDataHora($row["data"]), 0, 10); + $row["hora"] = str_pad($row["hora"], 2, "0", STR_PAD_LEFT); + $row["tmab"] = SecondToStrTime(round(($row["tempo"] / $row["qtde"]), 0)); + + $somaTempo += $row["tempo"]; + $somaQuantidade += $row["qtde"]; + $row["tempo"] = SecondToStrTime(round($row["tempo"], 0)); + + // Formata linha de dados. + $linha = array('DADOS'); + foreach ($dadosField as $key) { + $linha[] = $row["$key"]; + } + $dataRel[] = $linha; + } + + if ($mostraColunaServicos) { + $linha = array('LABEL', 'Total', '', '', '', $somaQuantidade, SecondToStrTime($somaTempo), SecondToStrTime(round(($somaTempo / $somaQuantidade), 0))); + } else { + $linha = array('LABEL', 'Total', '', '', $somaQuantidade, SecondToStrTime($somaTempo), SecondToStrTime(round(($somaTempo / $somaQuantidade), 0))); + } + // $linha = 'Total%s%s%s'; + $dataRel[] = $linha; + + $this->___dataRel[] = $dataRel; + $dataRel = array(); /* - * Guarda os filtros passados para recuperar na emiss�o dos relat?ios para impress�o. + * Agrupamento */ - $_SESSION["SSstorageFiltros"] = array($this->___dac, $this->___dataIni, $this->___dataFim, $this->___tipoRelatorio); - - return sprintf($filtro, $tipoRel, $this->___dataIni, $this->___dataFim, $lkPrint); - } + foreach ($this->GetData()[1] as $row) { + $total = 0; + $linha = array("LABEL", "Tempo Espera"); + $linha1 = array("DADOS", "Chamadas Abandonadas"); + foreach ($row as $key => $value) { + $linha[] = $key; + $linha1[] = StrToIntDef($value); + $total += StrToIntDef($value); + } + $linha[] = "Total"; + $linha1[] = $total; + $dataRel[] = $linha; + $dataRel[] = $linha1; + } + $this->___dataRel[] = $dataRel; + } else { - function ___PreparaExcel() { + $dadosCabecalio = array('Data', 'Hora', 'Origem', 'Logado', 'Pausa', 'Ocupado', 'Indisponivel', 'Nao Classificado', 'Retorno', 'Pos. Chegada', 'Pos. Abandono', 'Tempo', 'TMAB'); + $dadosField = array('data', 'hora', 'origem', 'qtd_logado', 'qtd_pausa', 'qtd_ocupado', 'qtd_indisponivel', 'qtd_naoclassificado', 'retornado', 'posicao_chegada', 'posicao_abandono', 'tempo', 'tmab'); - $nomeDac = ""; - $dataRel = array(); - $dataAgrup = array(); - $filtro = $this->___FiltrosRelatorio(); + if ($mostraColunaServicos) { + $dadosCabecalio = array_merge(['Servico'], $dadosCabecalio); + $dadosField = array_merge(['serv_id'], $dadosField); + } /* - * Inicia o relatório. + * Inicia o relatorio. */ /* - * Cria os filtros + * Monta a linha de cabecalio. */ $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); + foreach ($dadosCabecalio as $value) { $linha[] = $value; } - $dataRel[] = $linha; - if (!$this->___tipoRelatorio) { - $dadosCabecalio = array('Data', 'Hora', 'Origem', 'Quantidade', 'Tempo', 'TMAB'); - $dadosField = array('data', 'hora', 'origem', 'qtde', 'tempo', 'tmab'); + $somaTempo = 0; + $somaQuantidade = 0; + $arUseSoma = array('qtd_logado', 'qtd_pausa', 'qtd_ocupado', 'qtd_indisponivel', 'qtd_naoclassificado', 'tempo'); + $arSoma = array('qtd_logado' => 0, 'qtd_pausa' => 0, 'qtd_ocupado' => 0, 'qtd_indisponivel' => 0, 'qtd_naoclassificado' => 0, 'retornado' => '-', 'posicao_chegada' => '-', 'posicao_abandono' => '-', 'tempo' => 0, 'tmab' => 0); + + foreach ($this->GetData()[0] as $row) { + //$somaTMAB += $row["tmab"]; + $somaTempo += $row["tempo"]; /* - * Monta a linha de cabecalio. + * Soma as colunas. */ - $linha = array('LABEL'); - foreach ($dadosCabecalio as $value) { - $linha[] = $value; + foreach ($arUseSoma as $value) { + $arSoma["$value"] += StrToIntDef($row["$value"]); } - $dataRel[] = $linha; - $somaTempo = 0; - $somaQuantidade = 0; /* * Linhas de dados. */ - foreach ($this->GetData()[0] as $row) { - $row["data"] = substr(FormataDBDataHora($row["data"]), 0, 10); - $row["hora"] = str_pad($row["hora"], 2, "0", STR_PAD_LEFT); - $row["tmab"] = SecondToStrTime(round(($row["tempo"] / $row["qtde"]), 0)); - - $somaTempo += $row["tempo"]; - $somaQuantidade += $row["qtde"]; - $row["tempo"] = SecondToStrTime(round($row["tempo"], 0)); - - // Formata linha de dados. - $linha = array('DADOS'); - foreach ($dadosField as $key) { - $linha[] = $row["$key"]; - } - $dataRel[] = $linha; + $row["data"] = substr(FormataDBDataHora($row["data"]), 0, 10); + $row["hora"] = str_pad($row["hora"], 2, "0", STR_PAD_LEFT); + $row['retornado'] = $row['retornado'] ? $row['retornado'] : "-"; + $row["tmab"] = SecondToStrTime($row["tempo"]); + $row["tempo"] = SecondToStrTime($row["tempo"]); + + // Formata linha de dados. + $linha = array('DADOS'); + foreach ($dadosField as $key) { + $linha[] = $row["$key"]; } - $linha = array('LABEL', 'Total', '', '', $somaQuantidade, SecondToStrTime($somaTempo), SecondToStrTime(round(($somaTempo / $somaQuantidade), 0))); - // $linha = 'Total%s%s%s'; $dataRel[] = $linha; + } - $this->___dataRel[] = $dataRel; - $dataRel = array(); - - /* - * Agrupamento - */ - foreach ($this->GetData()[1] as $row) { - $total = 0; - $linha = array("LABEL", "Tempo Espera"); - $linha1 = array("DADOS", "Chamadas Abandonadas"); - foreach ($row as $key => $value) { - $linha[] = $key; - $linha1[] = StrToIntDef($value); - $total += StrToIntDef($value); - } - $linha[] = "Total"; - $linha1[] = $total; - $dataRel[] = $linha; - $dataRel[] = $linha1; - } - $this->___dataRel[] = $dataRel; + /* + * Linha de totalizacao. + */ + $arSoma['tempo'] = SecondToStrTime($somaTempo); + $arSoma['tmab'] = SecondToStrTime(round($somaTempo / count($this->GetData()[0]))); + if ($mostraColunaServicos) { + $linha = array('LABEL', 'Total', '', ''); } else { + $linha = array('LABEL', 'Total', '', ''); + } + foreach ($arSoma as $soma) { + $linha[] = $soma; + } - $dadosCabecalio = array('Data', 'Hora', 'Origem', 'Logado', 'Pausa', 'Ocupado', 'Indisponivel', 'Nao Classificado', 'Retorno', 'Pos. Chegada', 'Pos. Abandono', 'Tempo', 'TMAB'); - $dadosField = array('data', 'hora', 'origem', 'qtd_logado', 'qtd_pausa', 'qtd_ocupado', 'qtd_indisponivel', 'qtd_naoclassificado', 'retornado', 'posicao_chegada', 'posicao_abandono', 'tempo', 'tmab'); + $dataRel[] = $linha; + $this->___dataRel[] = $dataRel; + } + } - /* - * Inicia o relatorio. - */ + function ___PreparaCsv() { + $nomeDac = ""; + $dataRel = array(); + $dataAgrup = array(); + $filtro = $this->___FiltrosRelatorio(); + $mostraColunaServicos = GetUsoServico() == RELATORIO_SERVICOS_HABILITA; + + /* + * Inicia o relat�rio. + */ + $dataRel[] = GenerateCsvFromArray($filtro); + + if (!$this->___tipoRelatorio) { + $dadosCabecalio = array('Data' => 'align="center"', 'Hora' => 'align="center"', 'Origem' => 'align="left"', 'Quantidade' => 'align="right"', 'Tempo' => 'align="center"', 'TMAB' => 'align="center"'); + $dadosField = array('data' => 'align="center"', 'hora' => 'align="center"', 'origem' => 'align="left"', 'qtde' => 'align="right"', 'tempo' => 'align="center"', 'tmab' => 'align="center"'); + + if ($mostraColunaServicos) { + $dadosCabecalio = array_merge(['Servico'], $dadosCabecalio); + $dadosField = array_merge(['serv_id'], $dadosField); + } - /* - * Monta a linha de cabecalio. - */ - $linha = array('LABEL'); - foreach ($dadosCabecalio as $value) { - $linha[] = $value; + /* + * Monta a linha de cabecalio. + */ + $dataRel[] = GenerateCsvFromArray(array_keys($dadosCabecalio)); + + $somaTempo = 0; + $somaQuantidade = 0; + /* + * Linhas de dados. + */ + foreach ($this->GetData()[0] as $row) { + $row["data"] = substr(FormataDBDataHora($row["data"]), 0, 10); + $row["hora"] = str_pad($row["hora"], 2, "0", STR_PAD_LEFT); + $row["tmab"] = SecondToStrTime(round(($row["tempo"] / $row["qtde"]), 0)); + + $somaTempo += $row["tempo"]; + $somaQuantidade += $row["qtde"]; + $row["tempo"] = SecondToStrTime(round($row["tempo"], 0)); + + // Formata linha de dados. + $linha = array(); + foreach ($dadosField as $key => $value) { + $linha[] = $row["$key"]; } - $dataRel[] = $linha; + $dataRel[] = GenerateCsvFromArray($linha); + } - $somaTempo = 0; - $somaQuantidade = 0; - $arUseSoma = array('qtd_logado', 'qtd_pausa', 'qtd_ocupado', 'qtd_indisponivel', 'qtd_naoclassificado', 'tempo'); - $arSoma = array('qtd_logado' => 0, 'qtd_pausa' => 0, 'qtd_ocupado' => 0, 'qtd_indisponivel' => 0, 'qtd_naoclassificado' => 0, 'retornado' => '-', 'posicao_chegada' => '-', 'posicao_abandono' => '-', 'tempo' => 0, 'tmab' => 0); - - foreach ($this->GetData()[0] as $row) { - //$somaTMAB += $row["tmab"]; - $somaTempo += $row["tempo"]; - /* - * Soma as colunas. - */ - foreach ($arUseSoma as $value) { - $arSoma["$value"] += StrToIntDef($row["$value"]); - } - - /* - * Linhas de dados. - */ - $row["data"] = substr(FormataDBDataHora($row["data"]), 0, 10); - $row["hora"] = str_pad($row["hora"], 2, "0", STR_PAD_LEFT); - $row['retornado'] = $row['retornado'] ? $row['retornado'] : "-"; - $row["tmab"] = SecondToStrTime($row["tempo"]); - $row["tempo"] = SecondToStrTime($row["tempo"]); - - // Formata linha de dados. - $linha = array('DADOS'); - foreach ($dadosField as $key) { - $linha[] = $row["$key"]; - } - - $dataRel[] = $linha; - } + $this->___dataRel[] = $dataRel; + $dataRel = array(); - /* - * Linha de totalizacao. - */ - $arSoma['tempo'] = SecondToStrTime($somaTempo); - $arSoma['tmab'] = SecondToStrTime(round($somaTempo/count($this->GetData()[0]))); - $linha = array('LABEL', 'Total', '', ''); - foreach ($arSoma as $soma) { - $linha[] = $soma; + /* + * Agrupamento + */ + foreach ($this->GetData()[1] as $row) { + $total = 0; + $linha = array("Tempo Espera"); + $linha1 = array("Chamadas Abandonadas"); + foreach ($row as $key => $value) { + $linha[] = $key; + $linha1[] = StrToIntDef($value); + $total += StrToIntDef($value); } - - $dataRel[] = $linha; - $this->___dataRel[] = $dataRel; + $linha[] = "Total"; + $linha1[] = $total; + $dataRel[] = GenerateCsvFromArray($linha); + $dataRel[] = GenerateCsvFromArray($linha1); + } + $this->___dataRel[] = $dataRel; + } else { + + $dadosCabecalio = array('Data' => 'align="center"', 'Hora' => 'align="center"', 'Origem' => 'align="left"' + , 'Logado' => 'align="right"', 'Pausa' => 'align="right"', 'Ocupado' => 'align="right"', 'Indisponível' => 'align="right"' + , 'Não Classificado' => 'align="right"', 'Retorno' => 'align="center"', 'Pos. Chegada' => 'align="right"', 'Pos. Abandono' => 'align="right"' + , 'Tempo' => 'align="center"', 'TMAB' => 'align="center"' + ); + + $dadosField = array('data' => 'align="center"', 'hora' => 'align="center"', 'origem' => 'align="left"' + , 'qtd_logado' => 'align="right"', 'qtd_pausa' => 'align="right"', 'qtd_ocupado' => 'align="right"', 'qtd_indisponivel' => 'align="right"' + , 'qtd_naoclassificado' => 'align="right"', 'retornado' => 'align="center"', 'posicao_chegada' => 'align="right"', 'posicao_abandono' => 'align="right"' + , 'tempo' => 'align="center"', 'tmab' => 'align="center"' + ); + + if ($mostraColunaServicos) { + $dadosCabecalio = array_merge(['Servico'], $dadosCabecalio); + $dadosField = array_merge(['serv_id'], $dadosField); } - } - function ___PreparaCsv() { - $nomeDac = ""; - $dataRel = array(); - $dataAgrup = array(); - $filtro = $this->___FiltrosRelatorio(); /* * Inicia o relat�rio. */ - $dataRel[] = GenerateCsvFromArray($filtro); + /* + * Monta a linha de cabecalio. + */ + $dataRel[] = GenerateCsvFromArray(array_keys($dadosCabecalio)); - if (!$this->___tipoRelatorio) { - $dadosCabecalio = array('Data' => 'align="center"', 'Hora' => 'align="center"', 'Origem' => 'align="left"', 'Quantidade' => 'align="right"', 'Tempo' => 'align="center"', 'TMAB' => 'align="center"'); - $dadosField = array('data' => 'align="center"', 'hora' => 'align="center"', 'origem' => 'align="left"', 'qtde' => 'align="right"', 'tempo' => 'align="center"', 'tmab' => 'align="center"'); - /* - * Monta a linha de cabecalio. - */ - $dataRel[] = GenerateCsvFromArray(array_keys($dadosCabecalio)); + $somaTempo = 0; + $somaTMAB = 0; + $arUseSoma = array('qtd_logado', 'qtd_pausa', 'qtd_ocupado', 'qtd_indisponivel', 'qtd_naoclassificado', 'tempo'); + $arSoma = array('qtd_logado' => 0, 'qtd_pausa' => 0, 'qtd_ocupado' => 0, 'qtd_indisponivel' => 0, 'qtd_naoclassificado' => 0, 'retornado' => '-', 'posicao_chegada' => '-', 'posicao_abandono' => '-', 'tempo' => 0, 'tmab' => 0, 'lkRel' => '-'); + + foreach ($this->GetData()[0] as $row) { + $somaTempo += $row["tempo"]; + $row["data"] = FormataDBDataHora($row["data"]); + $row["hora"] = substr(FormataDBDataHora($row["hora"]), 11, 2); + $row['retornado'] = $row['retornado'] ? $row['retornado'] : "-"; + $row["tmab"] = SecondToStrTime($row["tempo"]); + $row['tempo'] = SecondToStrTime($row["tempo"]); - $somaTempo = 0; - $somaQuantidade = 0; /* - * Linhas de dados. + * Soma as colunas. */ - foreach ($this->GetData()[0] as $row) { - $row["data"] = substr(FormataDBDataHora($row["data"]), 0, 10); - $row["hora"] = str_pad($row["hora"], 2, "0", STR_PAD_LEFT); - $row["tmab"] = SecondToStrTime(round(($row["tempo"] / $row["qtde"]), 0)); - - $somaTempo += $row["tempo"]; - $somaQuantidade += $row["qtde"]; - $row["tempo"] = SecondToStrTime(round($row["tempo"], 0)); - - // Formata linha de dados. - $linha = array(); - foreach ($dadosField as $key => $value) { - $linha[] = $row["$key"]; - } - - $dataRel[] = GenerateCsvFromArray($linha); + foreach ($arUseSoma as $value) { + $arSoma["$value"] += StrToIntDef($row["$value"]); } - $this->___dataRel[] = $dataRel; - $dataRel = array(); - /* - * Agrupamento - */ - foreach ($this->GetData()[1] as $row) { - $total = 0; - $linha = array("Tempo Espera"); - $linha1 = array("Chamadas Abandonadas"); - foreach ($row as $key => $value) { - $linha[] = $key; - $linha1[] = StrToIntDef($value); - $total += StrToIntDef($value); - } - $linha[] = "Total"; - $linha1[] = $total; - $dataRel[] = GenerateCsvFromArray($linha); - $dataRel[] = GenerateCsvFromArray($linha1); + // Formata linha de dados. + $linha = array(); + foreach ($dadosField as $key => $value) { + $linha[] = $row["$key"]; } - $this->___dataRel[] = $dataRel; - } else { - $dadosCabecalio = array('Data' => 'align="center"', 'Hora' => 'align="center"', 'Origem' => 'align="left"' - , 'Logado' => 'align="right"', 'Pausa' => 'align="right"', 'Ocupado' => 'align="right"', 'Indisponível' => 'align="right"' - , 'Não Classificado' => 'align="right"', 'Retorno' => 'align="center"', 'Pos. Chegada' => 'align="right"', 'Pos. Abandono' => 'align="right"' - , 'Tempo' => 'align="center"', 'TMAB' => 'align="center"' - ); + $dataRel[] = GenerateCsvFromArray($linha); + } - $dadosField = array('data' => 'align="center"', 'hora' => 'align="center"', 'origem' => 'align="left"' - , 'qtd_logado' => 'align="right"', 'qtd_pausa' => 'align="right"', 'qtd_ocupado' => 'align="right"', 'qtd_indisponivel' => 'align="right"' - , 'qtd_naoclassificado' => 'align="right"', 'retornado' => 'align="center"', 'posicao_chegada' => 'align="right"', 'posicao_abandono' => 'align="right"' - , 'tempo' => 'align="center"', 'tmab' => 'align="center"' - ); + /* + * Linha de totalizacao. + */ + $arSoma['tempo'] = SecondToStrTime($somaTempo); + $arSoma['tmab'] = SecondToStrTime(round($somaTempo / count($this->GetData()[0]))); + + if ($mostraColunaServicos) { + $linha = array('Total', '', ''); + } else { + $linha = array('Total', '', ''); + } + + foreach ($arSoma as $soma) { + $linha[] = $soma; + } - /* - * Inicia o relat�rio. - */ - /* - * Monta a linha de cabecalio. - */ - $dataRel[] = GenerateCsvFromArray(array_keys($dadosCabecalio)); - - - $somaTempo = 0; - $somaTMAB = 0; - $arUseSoma = array('qtd_logado', 'qtd_pausa', 'qtd_ocupado', 'qtd_indisponivel', 'qtd_naoclassificado', 'tempo'); - $arSoma = array('qtd_logado' => 0, 'qtd_pausa' => 0, 'qtd_ocupado' => 0, 'qtd_indisponivel' => 0, 'qtd_naoclassificado' => 0, 'retornado' => '-', 'posicao_chegada' => '-', 'posicao_abandono' => '-', 'tempo' => 0, 'tmab' => 0, 'lkRel' => '-'); - - foreach ($this->GetData()[0] as $row) { - $somaTempo += $row["tempo"]; - $row["data"] = FormataDBDataHora($row["data"]); - $row["hora"] = substr(FormataDBDataHora($row["hora"]), 11, 2); - $row['retornado'] = $row['retornado'] ? $row['retornado'] : "-"; - $row["tmab"] = SecondToStrTime($row["tempo"]); - $row['tempo'] = SecondToStrTime($row["tempo"]); - - /* - * Soma as colunas. - */ - foreach ($arUseSoma as $value) { - $arSoma["$value"] += StrToIntDef($row["$value"]); - } - - - // Formata linha de dados. - $linha = array(); - foreach ($dadosField as $key => $value) { - $linha[] = $row["$key"]; - } - - $dataRel[] = GenerateCsvFromArray($linha); - } + $dataRel[] = GenerateCsvFromArray($linha); + $this->___dataRel[] = $dataRel; + } + } - /* - * Linha de totalizacao. - */ - $arSoma['tempo'] = SecondToStrTime($somaTempo); - $arSoma['tmab'] = SecondToStrTime(round($somaTempo/count($this->GetData()[0]))); - $linha = array('Total', '', ''); - foreach ($arSoma as $soma) { - $linha[] = $soma; - } + function ___PreparaGrid() { + $nomeDac = ""; + $dataRel = array(); + $dataAgrup = array(); + $mostraColunaServicos = GetUsoServico() == RELATORIO_SERVICOS_HABILITA; + + if (!$this->___tipoRelatorio) { + $dadosCabecalio = array( + 'Data' => 'align="center"', + 'Hora' => 'align="center"', + 'Origem' => 'align="left"', + 'Quantidade' => 'align="right"', + 'Tempo' => 'align="center"', + 'TMAB' => 'align="center"' + ); + $dadosField = array( + 'data' => 'align="center"', + 'hora' => 'align="center"', + 'origem' => 'align="left"', + 'qtde' => 'align="right"', + 'tempo' => 'align="center"', + 'tmab' => 'align="center"' + ); + + + if ($mostraColunaServicos) { + $dadosCabecalio = array_merge(['Serviço' => 'align="center"'], $dadosCabecalio); + $dadosField = array_merge(['serv_id' => 'align="left"'], $dadosField); + } + /* + * Inicia o relat�rio. + */ + $dataRel[] = ''; - $dataRel[] = GenerateCsvFromArray($linha); - $this->___dataRel[] = $dataRel; + /* + * Monta a linha de cabecalio. + */ + $linha = ''; + foreach ($dadosCabecalio as $key => $value) { + $linha .= sprintf("", $value, $key); } - } + $linha .= ""; + $dataRel[] = $linha; - function ___PreparaGrid() { - $nomeDac = ""; - $dataRel = array(); - $dataAgrup = array(); - - if (!$this->___tipoRelatorio) { - $dadosCabecalio = array( - 'Data' => 'align="center"', - 'Hora' => 'align="center"', - 'Origem' => 'align="left"', - 'Quantidade' => 'align="right"', - 'Tempo' => 'align="center"', - 'TMAB' => 'align="center"' - ); - $dadosField = array( - 'data' => 'align="center"', - 'hora' => 'align="center"', - 'origem' => 'align="left"', - 'qtde' => 'align="right"', - 'tempo' => 'align="center"', - 'tmab' => 'align="center"' - ); - /* - * Inicia o relat�rio. - */ - $dataRel[] = '
%s
'; + /* + * Verifica se retornou dados + */ + if (!IsPostBack() || !count($this->GetData()[0])) { + $dataRel[] = sprintf("
%s
", count($dadosCabecalio) - 1, (!IsPostBack() ? 'Informe os parametros e clique em consultar!' : 'Nenhum registro encontado!')); + $this->___dataRel[] = $dataRel; + return; + } - /* - * Monta a linha de cabecalio. - */ - $linha = ''; - foreach ($dadosCabecalio as $key => $value) { - $linha .= sprintf("%s", $value, $key); + $somaTempo = 0; + $somaQuantidade = 0; + $somaReg = 0; + /* + * Linhas de dados. + */ + foreach ($this->GetData()[0] as $row) { + $somaReg ++; + $row['origem'] = ocultarTelefone($row['origem']); + $row["data"] = substr(FormataDBDataHora($row["data"]), 0, 10); + $row["hora"] = str_pad($row["hora"], 2, "0", STR_PAD_LEFT); + $row["tmab"] = SecondToStrTime(round(($row["tempo"] / $row["qtde"]), 0)); + + $somaTempo += $row["tempo"]; + $somaQuantidade += $row["qtde"]; + $row["tempo"] = SecondToStrTime(round($row["tempo"], 0)); + + // Formata linha de dados. + $linha = ""; + foreach ($dadosField as $key => $value) { + $linha .= sprintf("%s", $value, $row["$key"]); } $linha .= ""; $dataRel[] = $linha; + } + /* + * Linha de totalizacao. + */ + $colspan = $mostraColunaServicos ? 3 : 2; + $linha = 'Total%s%s%s%s'; + $dataRel[] = sprintf($linha, $somaReg, $somaQuantidade, SecondToStrTime($somaTempo), SecondToStrTime(round(($somaTempo / $somaQuantidade), 0))); - /* - * Verifica se retornou dados - */ - if (!IsPostBack() || !count($this->GetData()[0])) { - $dataRel[] = sprintf("%s", count($dadosCabecalio) - 1, (!IsPostBack() ? 'Informe os parametros e clique em consultar!' : 'Nenhum registro encontado!')); - $this->___dataRel[] = $dataRel; - return; - } + /* + * Fecha relatorio. + */ + $dataRel[] = ''; + $this->___dataRel[] = $dataRel; + $dataRel = array(); - $somaTempo = 0; - $somaQuantidade = 0; - $somaReg = 0; - /* - * Linhas de dados. - */ - foreach ($this->GetData()[0] as $row) { - $somaReg ++; - $row['origem'] = ocultarTelefone($row['origem']); - $row["data"] = substr(FormataDBDataHora($row["data"]), 0, 10); - $row["hora"] = str_pad($row["hora"], 2, "0", STR_PAD_LEFT); - $row["tmab"] = SecondToStrTime(round(($row["tempo"] / $row["qtde"]), 0)); - - $somaTempo += $row["tempo"]; - $somaQuantidade += $row["qtde"]; - $row["tempo"] = SecondToStrTime(round($row["tempo"], 0)); - - // Formata linha de dados. - $linha = ""; - foreach ($dadosField as $key => $value) { - $linha .= sprintf("%s", $value, $row["$key"]); - } - $linha .= ""; - $dataRel[] = $linha; + /* + * Agrupamento + */ + foreach ($this->GetData()[1] as $row) { + $total = 0; + $linha = '' . ""; + $linha1 = ""; + foreach ($row as $key => $value) { + $linha .= sprintf("", $key); + $linha1 .= sprintf("", StrToIntDef($value)); + $total += $value; } - /* - * Linha de totalizacao. - */ - $linha = ''; - $dataRel[] = sprintf($linha, $somaReg, $somaQuantidade, SecondToStrTime($somaTempo), SecondToStrTime(round(($somaTempo / $somaQuantidade), 0))); + $linha .= ""; + $linha1 .= "
Tempo Espera
Chamadas Abandonadas%s%s
Total%s%s%s%s
Total
$total
"; + $dataRel[] = $linha . $linha1; + } + $this->___dataRel[] = $dataRel; + } else { + + $dadosCabecalio = array( + 'Data' => 'align="center"', + 'Hora' => 'align="center"', + 'Origem' => 'align="left"', + 'Logado' => 'align="right"', + 'Pausa' => 'align="right"', + 'Ocupado' => 'align="right"', + 'Indisponivel' => 'align="right"', + 'Nao Classificado' => 'align="right"', + 'Retorno' => 'align="center"', + 'Pos. Chegada' => 'align="right"', + 'Pos. Abandono' => 'align="right"', + 'Tempo' => 'align="center"', + 'TMAB' => 'align="center"', + '-' => 'align="center"' + ); + + $dadosField = array( + 'data' => 'align="center"', + 'hora' => 'align="center"', + 'origem' => 'align="left"', + 'qtd_logado' => 'align="right"', + 'qtd_pausa' => 'align="right"', + 'qtd_ocupado' => 'align="right"', + 'qtd_indisponivel' => 'align="right"', + 'qtd_naoclassificado' => 'align="right"', + 'retornado' => 'align="center"', + 'posicao_chegada' => 'align="right"', + 'posicao_abandono' => 'align="right"', + 'tempo' => 'align="center"', + 'tmab' => 'align="center"', + 'linkRel' => 'align="center"' + ); + + $getUsoServico = false; + if ($mostraColunaServicos) { + $dadosCabecalio = array_merge(['Serviço' => 'align="center"'], $dadosCabecalio); + $dadosField = array_merge(['serv_id' => 'align="left"'], $dadosField); + $getUsoServico = true; + } - /* - * Fecha relatorio. - */ - $dataRel[] = ''; - $this->___dataRel[] = $dataRel; - $dataRel = array(); + /* + * Inicia o relat�rio. + */ + $dataRel[] = ''; - /* - * Agrupamento - */ - foreach ($this->GetData()[1] as $row) { - $total = 0; - $linha = '
' . ""; - $linha1 = ""; - foreach ($row as $key => $value) { - $linha .= sprintf("", $key); - $linha1 .= sprintf("", StrToIntDef($value)); - $total += $value; - } - $linha .= ""; - $linha1 .= "
Tempo Espera
Chamadas Abandonadas%s%sTotal
$total
"; - $dataRel[] = $linha . $linha1; - } + /* + * Monta a linha de cabecalio. + */ + $linha = ''; + foreach ($dadosCabecalio as $key => $value) { + $linha .= sprintf("%s", $value, $key); + } + $linha .= ""; + $dataRel[] = $linha; + + /* + * Verifica se retornou dados + */ + if (!IsPostBack() || !count($this->GetData()[0])) { + $dataRel[] = sprintf("%s", count($dadosCabecalio) - 1, (!IsPostBack() ? 'Informe os parametros e clique em consultar!' : 'Nenhum registro encontado!')); $this->___dataRel[] = $dataRel; - } else { + return; + } - $dadosCabecalio = array( - 'Data' => 'align="center"', - 'Hora' => 'align="center"', - 'Origem' => 'align="left"', - 'Logado' => 'align="right"', - 'Pausa' => 'align="right"', - 'Ocupado' => 'align="right"', - 'Indisponivel' => 'align="right"', - 'Nao Classificado' => 'align="right"', - 'Retorno' => 'align="center"', - 'Pos. Chegada' => 'align="right"', - 'Pos. Abandono' => 'align="right"', - 'Tempo' => 'align="center"', - 'TMAB' => 'align="center"', - '-' => 'align="center"' - ); - - $dadosField = array( - 'data' => 'align="center"', - 'hora' => 'align="center"', - 'origem' => 'align="left"', - 'qtd_logado' => 'align="right"', - 'qtd_pausa' => 'align="right"', - 'qtd_ocupado' => 'align="right"', - 'qtd_indisponivel' => 'align="right"', - 'qtd_naoclassificado' => 'align="right"', - 'retornado' => 'align="center"', - 'posicao_chegada' => 'align="right"', - 'posicao_abandono' => 'align="right"', - 'tempo' => 'align="center"', - 'tmab' => 'align="center"', - 'linkRel' => 'align="center"' - ); + $somaTempo = 0; + $arUseSoma = array('qtd_logado', 'qtd_pausa', 'qtd_ocupado', 'qtd_indisponivel', 'qtd_naoclassificado', 'tempo'); + $arSoma = array('qtd_logado' => 0, 'qtd_pausa' => 0, 'qtd_ocupado' => 0, 'qtd_indisponivel' => 0, 'qtd_naoclassificado' => 0, 'retornado' => '-', 'posicao_chegada' => '-', 'posicao_abandono' => '-', 'tempo' => 0, 'tmab' => 0, 'lkRel' => '-'); + $somaReg = 0; + foreach ($this->GetData()[0] as $row) { + $somaReg++; + $srv = $getUsoServico ? $row['serv_id'] : ''; /* - * Inicia o relat�rio. + * Links para detalhamento. */ - $dataRel[] = ''; + $imgrel = "\"Detalhes"; + $linkRel = "$imgrel"; + $row["linkRel"] = sprintf($linkRel, $row["hora"], $row["hora_fim"], $row["fila"], base64_encode($row["uniqueid"]), $row["qtd_logado"], $row["qtd_pausa"], $row["qtd_ocupado"], $row["qtd_indisponivel"], $row["qtd_naoclassificado"], $row["posicao_chegada"], $row["posicao_abandono"], $row['agente_retorno'] ? $row['agente_retorno'] : " - ", $row['retornado'] ? $row['retornado'] : "", ($srv ? "&serv_id=$srv" : "")); + + $somaTempo += $row["tempo"]; + $row['origem'] = ocultarTelefone($row['origem']); + $row["data"] = FormataDBDataHora($row["data"]); + $row['hora'] = substr(FormataDBDataHora($row["hora"]), 11, 2); + $row["retornado"] = $row["retornado"] ? "SIM" : "NÃO"; + $row["tmab"] = SecondToStrTime($row["tempo"]); + $row['tempo'] = SecondToStrTime($row['tempo']); /* - * Monta a linha de cabecalio. + * Soma as colunas. */ - $linha = ''; - foreach ($dadosCabecalio as $key => $value) { - $linha .= sprintf("", $value, $key); + foreach ($arUseSoma as $value) { + $arSoma["$value"] += $row["$value"]; } - $linha .= ""; - $dataRel[] = $linha; /* - * Verifica se retornou dados + * Linhas de dados. */ - if (!IsPostBack() || !count($this->GetData()[0])) { - $dataRel[] = sprintf("
%s
%s
", count($dadosCabecalio) - 1, (!IsPostBack() ? 'Informe os parametros e clique em consultar!' : 'Nenhum registro encontado!')); - $this->___dataRel[] = $dataRel; - return; - } - $somaTempo = 0; - $arUseSoma = array('qtd_logado', 'qtd_pausa', 'qtd_ocupado', 'qtd_indisponivel', 'qtd_naoclassificado', 'tempo'); - $arSoma = array('qtd_logado' => 0, 'qtd_pausa' => 0, 'qtd_ocupado' => 0, 'qtd_indisponivel' => 0, 'qtd_naoclassificado' => 0, 'retornado' => '-', 'posicao_chegada' => '-', 'posicao_abandono' => '-', 'tempo' => 0, 'tmab' => 0, 'lkRel' => '-'); - $somaReg = 0; - foreach ($this->GetData()[0] as $row) { - $somaReg++; - /* - * Links para detalhamento. - */ - $imgrel = "\"Detalhes"; - $linkRel = "$imgrel"; - $row["linkRel"] = sprintf($linkRel, $row["hora"], $row["hora_fim"], $row["fila"] ,base64_encode($row["uniqueid"]), $row["qtd_logado"], $row["qtd_pausa"], $row["qtd_ocupado"], $row["qtd_indisponivel"], $row["qtd_naoclassificado"], $row["posicao_chegada"], $row["posicao_abandono"], $row['agente_retorno'] ? $row['agente_retorno'] : " - ", $row['retornado'] ? $row['retornado'] : ""); - - $somaTempo += $row["tempo"]; - $row['origem'] = ocultarTelefone($row['origem']); - $row["data"] = FormataDBDataHora($row["data"]); - $row['hora'] = substr(FormataDBDataHora($row["hora"]), 11, 2); - $row["retornado"] = $row["retornado"] ? "SIM" : "NÃO"; - $row["tmab"] = SecondToStrTime($row["tempo"]); - $row['tempo'] = SecondToStrTime($row['tempo']); - - /* - * Soma as colunas. - */ - foreach ($arUseSoma as $value) { - $arSoma["$value"] += $row["$value"]; - } - - /* - * Linhas de dados. - */ - - $row["hora"] = str_pad($row["hora"], 2, "0", STR_PAD_LEFT); - - // Formata linha de dados. - $linha = ""; - foreach ($dadosField as $key => $value) { - $linha .= sprintf("%s", $value, $row["$key"]); - } - $linha .= ""; - $dataRel[] = $linha; - } + $row["hora"] = str_pad($row["hora"], 2, "0", STR_PAD_LEFT); - /* - * Linha de totalizacao. - */ - $arSoma['tempo'] = SecondToStrTime($somaTempo); - $arSoma['tmab'] = SecondToStrTime(round($somaTempo/count($this->GetData()[0]))); - $linha = 'Total'; - $linha .= "Registros: {$somaReg}"; - foreach ($arSoma as $soma) { - $linha .= sprintf("%s", (is_numeric($soma) ? 'right' : 'center'), $soma); + // Formata linha de dados. + $linha = ""; + foreach ($dadosField as $key => $value) { + $linha .= sprintf("%s", $value, $row["$key"]); } - $linha .= ''; + $linha .= ""; $dataRel[] = $linha; - $this->___dataRel[] = $dataRel; } - } - function ___PreparaHtml() { - ; + /* + * Linha de totalizacao. + */ + $arSoma['tempo'] = SecondToStrTime($somaTempo); + $arSoma['tmab'] = SecondToStrTime(round($somaTempo / count($this->GetData()[0]))); + $colspan = $mostraColunaServicos ? 3 : 2; + $linha = 'Total'; + $linha .= "Registros: {$somaReg}"; + foreach ($arSoma as $soma) { + $linha .= sprintf("%s", (is_numeric($soma) ? 'right' : 'center'), $soma); + } + $linha .= ''; + $dataRel[] = $linha; + $this->___dataRel[] = $dataRel; } + } - function ___PreparaPdf() { - $nomeDac = ""; - list($this->___dac, $this->___dataIni, $this->___dataFim, $this->___tipoRelatorio) = $_SESSION["SSstorageFiltros"]; - /** - * TABELA DADOS PRINCIPAIS - */ - $somaTMAB = 0; - $somaTempo = 0; - $dados = array(); - $x = 0; - if (!$this->___tipoRelatorio) { - foreach ($this->GetData()[0] as $row) { - $dados[$x]["data"] = substr(FormataDBDataHora($row["data"]), 0, 10); - $dados[$x]["origem"] = $row["origem"]; - $dados[$x]["hora"] = str_pad($row["hora"], 2, "0", STR_PAD_LEFT); - $dados[$x]["tmab"] = SecondToStrTime(round($row["tempo"]/$row["qtde"])); - $dados[$x]["tempo"] = SecondToStrTime(round($row["tempo"], 0)); - $dados[$x]["qtde"] = $row["qtde"]; - $somaQtd += $row["qtde"]; - $somaTempo += $row["tempo"]; - $x++; - } + function ___PreparaHtml() { + ; + } + + function ___PreparaPdf() { + + $nomeDac = ""; + list($this->___dac, $this->___dataIni, $this->___dataFim, $this->___tipoRelatorio) = $_SESSION["SSstorageFiltros"]; + + /** + * TABELA DADOS PRINCIPAIS + */ + $somaTMAB = 0; + $somaTempo = 0; + $dados = array(); + $mostraColunaServicos = GetUsoServico() == RELATORIO_SERVICOS_HABILITA; + + if (!$this->___tipoRelatorio) { + foreach ($this->GetData()[0] as $row) { + + $somaQtd += $row["qtde"]; + $somaTempo += $row["tempo"]; + $row["data"] = substr(FormataDBDataHora($row["data"]), 0, 10); + $row["hora"] = str_pad($row["hora"], 2, "0", STR_PAD_LEFT); + $row["tmab"] = SecondToStrTime(round($row["tempo"] / $row["qtde"])); + $row["tempo"] = SecondToStrTime(round($row["tempo"], 0)); + $dados[] = $row; + } + + //HEADER DA TABELA DO PDF -> DADOS EM ARRAY + $header = array( + 'Data' => 'C', + 'Hora' => 'C', + 'Origem' => 'L', + 'Quantidade' => 'R', + 'Tempo' => 'C', + 'TMAB' => 'C' + ); + + $dataHeader = array( + 'data' => 'C', + 'hora' => 'C', + 'origem' => 'L', + 'qtde' => 'R', + 'tempo' => 'C', + 'tmab' => 'C' + ); + + if ($mostraColunaServicos) { + $header = array_merge(['Serviço' => 'C'], $header); + $dataHeader = array_merge(['serv_id' => 'C'], $dataHeader); + $widthHeader = array(35, 30, 20, 35, 20, 25, 25); + $totaliza = array( + 'Total', '', '', '', $somaQtd, SecondToStrTime($somaTempo), SecondToStrTime(round($somaTempo / $somaQtd))); + } else { - //HEADER DA TABELA DO PDF -> DADOS EM ARRAY - $header = array( - 'Data' => 'C', - 'Hora' => 'C', - 'Origem' => 'L', - 'Quantidade' => 'R', - 'Tempo' => 'C', - 'TMAB' => 'C' - ); - $dataHeader = array( - 'data' => 'C', - 'hora' => 'C', - 'origem' => 'L', - 'qtde' => 'R', - 'tempo' => 'C', - 'tmab' => 'C' - ); $widthHeader = array(35, 20, 45, 20, 35, 35); $totaliza = array( 'Total', '', '', $somaQtd, SecondToStrTime($somaTempo), SecondToStrTime(round($somaTempo / $somaQtd))); + } - //Monta o array para passar para o prepara; Necessário passar 6 parametros - $table1 = array($header, $dataHeader, $dados, $widthHeader, $totaliza, 0); + //Monta o array para passar para o prepara; Necessário passar 6 parametros + $table1 = array($header, $dataHeader, $dados, $widthHeader, $totaliza, 0); - /** - * TABELA DE TOTALIZAÇÃO - */ - $headerTotal = array( - 'TE <= 10' => 'C', - '10 < TE <= 20' => 'C', - '20 < TE <= 30' => 'C', - '30 < TE <= 60' => 'C', - '60 < TE <= 120' => 'C', - '120 < TE <= 180' => 'C', - '180 < TE <= 300' => 'C', - '300 < TE' => 'C' - ); - $widthHeaderTotal = array(22, 22, 22, 22, 25, 25, 25, 20, 20); - $table2 = array($headerTotal, $headerTotal, $this->GetData()[1], $widthHeaderTotal, '', 1); - - $this->___dataRel = array($table1, $table2); - } else { - $header = array( - 'Data' => 'C', - 'Hora' => 'C', - 'Origem' => 'L', - 'Logado' => 'R', - 'Pausa' => 'R', - 'Ocupado' => 'R', - 'Indisponivel' => 'R', - 'N Class.' => 'R', - 'Retorno' => 'C', - 'Pos. Chegada' => 'R', - 'Pos. Aban.' => 'R', - 'Tempo' => 'C', - 'TMAB' => 'C' - ); - - $dataHeader = array( - 'data' => 'C', - 'hora' => 'C', - 'origem' => 'L', - 'qtd_logado' => 'R', - 'qtd_pausa' => 'R', - 'qtd_ocupado' => 'R', - 'qtd_indisponivel' => 'R', - 'qtd_naoclassificado' => 'R', - 'retornado' => 'C', - 'posicao_chegada' => 'R', - 'posicao_abandono' => 'R', - 'tempo' => 'C', - 'tmab' => 'C' - ); - - $arUseSoma = array('qtd_logado', 'qtd_pausa', 'qtd_ocupado', 'qtd_indisponivel', 'qtd_naoclassificado', 'tempo'); - $arSoma = array('qtd_logado' => 0, 'qtd_pausa' => 0, 'qtd_ocupado' => 0, 'qtd_indisponivel' => 0, 'qtd_naoclassificado' => 0, 'retornado' => '-', 'posicao_chegada' => '-', 'posicao_abandono' => '-', 'tempo' => 0, 'tmab' => 0); - //$somaReg = 0; - foreach ($this->GetData()[0] as $row) { - $somaTempo += $row["tempo"]; - $dados[$x]["data"] = date('d/m/Y', strtotime($row["data"])); - $dados[$x]["hora"] = substr(FormataDBDataHora($row["hora"]), 11, 2); - $dados[$x]["origem"] = $row["origem"]; - $dados[$x]["qtd_logado"] = $row["qtd_logado"]; - $dados[$x]["qtd_pausa"] = $row["qtd_pausa"]; - $dados[$x]["qtd_ocupado"] = $row["qtd_ocupado"]; - $dados[$x]["qtd_indisponivel"] = $row["qtd_indisponivel"]; - $dados[$x]["qtd_naoclassificado"] = $row["qtd_naoclassificado"]; - $dados[$x]['tempo_disp'] = SecondToStrTime($row["tempo"]); - $dados[$x]['posicao_chegada'] = $row['posicao_chegada']; - $dados[$x]['posicao_abandono'] = $row['posicao_abandono']; - $dados[$x]['retornado'] = $row['retornado'] ? $row['retornado'] : "-"; - $dados[$x]['tmab'] = SecondToStrTime($row["tempo"]); - $dados[$x]['tempo'] = SecondToStrTime($row["tempo"]); - $x++; - foreach ($arUseSoma as $value) { - $arSoma["$value"] += $row["$value"]; - } + /** + * TABELA DE TOTALIZAÇÃO + */ + $headerTotal = array( + 'TE <= 10' => 'C', + '10 < TE <= 20' => 'C', + '20 < TE <= 30' => 'C', + '30 < TE <= 60' => 'C', + '60 < TE <= 120' => 'C', + '120 < TE <= 180' => 'C', + '180 < TE <= 300' => 'C', + '300 < TE' => 'C' + ); + $widthHeaderTotal = array(22, 22, 22, 22, 25, 25, 25, 20, 20); + $table2 = array($headerTotal, $headerTotal, $this->GetData()[1], $widthHeaderTotal, '', 1); + + $this->___dataRel = array($table1, $table2); + } else { + $header = array( + 'Data' => 'C', + 'Hora' => 'C', + 'Origem' => 'L', + 'Logado' => 'R', + 'Pausa' => 'R', + 'Ocupado' => 'R', + 'Indisponivel' => 'R', + 'N Class.' => 'R', + 'Retorno' => 'C', + 'Pos. Chegada' => 'R', + 'Pos. Aban.' => 'R', + 'Tempo' => 'C', + 'TMAB' => 'C' + ); + + $dataHeader = array( + 'data' => 'C', + 'hora' => 'C', + 'origem' => 'L', + 'qtd_logado' => 'R', + 'qtd_pausa' => 'R', + 'qtd_ocupado' => 'R', + 'qtd_indisponivel' => 'R', + 'qtd_naoclassificado' => 'R', + 'retornado' => 'C', + 'posicao_chegada' => 'R', + 'posicao_abandono' => 'R', + 'tempo' => 'C', + 'tmab' => 'C' + ); + + if ($mostraColunaServicos) { + $header = array_merge(['Serviço' => 'C'], $header); + $dataHeader = array_merge(['serv_id' => 'L'], $dataHeader); + } + + $arUseSoma = array('qtd_logado', 'qtd_pausa', 'qtd_ocupado', 'qtd_indisponivel', 'qtd_naoclassificado', 'tempo'); + $arSoma = array('qtd_logado' => 0, 'qtd_pausa' => 0, 'qtd_ocupado' => 0, 'qtd_indisponivel' => 0, 'qtd_naoclassificado' => 0, 'retornado' => '-', 'posicao_chegada' => '-', 'posicao_abandono' => '-', 'tempo' => 0, 'tmab' => 0); + //$somaReg = 0; + foreach ($this->GetData()[0] as $row) { + $somaTempo += $row["tempo"]; + $dados[$x]["data"] = date('d/m/Y', strtotime($row["data"])); + $dados[$x]["hora"] = substr(FormataDBDataHora($row["hora"]), 11, 2); + $dados[$x]["origem"] = $row["origem"]; + $dados[$x]["qtd_logado"] = $row["qtd_logado"]; + $dados[$x]["qtd_pausa"] = $row["qtd_pausa"]; + $dados[$x]["qtd_ocupado"] = $row["qtd_ocupado"]; + $dados[$x]["qtd_indisponivel"] = $row["qtd_indisponivel"]; + $dados[$x]["qtd_naoclassificado"] = $row["qtd_naoclassificado"]; + $dados[$x]['tempo_disp'] = SecondToStrTime($row["tempo"]); + $dados[$x]['posicao_chegada'] = $row['posicao_chegada']; + $dados[$x]['posicao_abandono'] = $row['posicao_abandono']; + $dados[$x]['retornado'] = $row['retornado'] ? $row['retornado'] : "-"; + $dados[$x]['tmab'] = SecondToStrTime($row["tempo"]); + $dados[$x]['tempo'] = SecondToStrTime($row["tempo"]); + $dados[$x]["serv_id"] = substr($row["serv_id"], 0, 36); + $x++; + foreach ($arUseSoma as $value) { + $arSoma["$value"] += $row["$value"]; } + } + + if ($mostraColunaServicos) { + $widthHeader = array(36, 15, 5, 15, 7, 7, 15, 15, 15, 10, 15, 15, 15, 15); + $totaliza = array('Total', '', '', '', $arSoma['qtd_logado'], + $arSoma['qtd_pausa'], $arSoma['qtd_ocupado'], $arSoma['qtd_indisponivel'], + $arSoma['qtd_naoclassificado'], $arSoma['retornado'], + $arSoma['posicao_chegada'], $arSoma['posicao_abandono'], + SecondToStrTime($somaTempo), SecondToStrTime(round($somaTempo / count($this->GetData()[0])))); + } else { $widthHeader = array(20, 5, 20, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15); $totaliza = array('Total', '', '', $arSoma['qtd_logado'], $arSoma['qtd_pausa'], $arSoma['qtd_ocupado'], $arSoma['qtd_indisponivel'], $arSoma['qtd_naoclassificado'], $arSoma['retornado'], $arSoma['posicao_chegada'], $arSoma['posicao_abandono'], - SecondToStrTime($somaTempo), SecondToStrTime(round($somaTempo/count($this->GetData()[0])))); - $table1 = array($header, $dataHeader, $dados, $widthHeader, $totaliza, 0); - $this->___dataRel = array($table1); + SecondToStrTime($somaTempo), SecondToStrTime(round($somaTempo / count($this->GetData()[0])))); } + + $table1 = array($header, $dataHeader, $dados, $widthHeader, $totaliza, 0); + $this->___dataRel = array($table1); } + } - function ___GetDadosDb() { + function ___GetDadosDb() { - $query = ''; - $dataIni = FormatDtMssql($this->___dataIni); - $dataFim = FormatDtMssql($this->___dataFim); - $dac = GetDacDesc($this->GetDbCon(), $this->___dac); - $analitico = $this->___tipoRelatorio; + $query = ''; + $dataIni = FormatDtMssql($this->___dataIni); + $dataFim = FormatDtMssql($this->___dataFim); + $dac = GetDacDesc($this->GetDbCon(), $this->___dac); + $analitico = $this->___tipoRelatorio; + $srv = $this->___servico; + $mostraColunaServicos = GetUsoServico() == RELATORIO_SERVICOS_HABILITA; - if ($analitico) { - $query = sprintf("SELECT a.uniqueid,b.fila, a.data_bilhete AS data, MIN(calldate::timestamp) AS hora, MIN(a.calldate::timestamp) + (b.param3::bigint * interval '1 second') as hora_fim, + if ($analitico) { + $query = "SELECT a.uniqueid,b.fila, a.data_bilhete AS data, MIN(calldate::timestamp) AS hora, MIN(a.calldate::timestamp) + (b.param3::bigint * interval '1 second') as hora_fim, src AS origem,strtoint(b.param2) AS posicao_chegada, abdsr_data_retorno AS retornado,abdsr_agente AS agente_retorno, strtoint(b.param1) AS posicao_abandono,abdsr_agt_logado AS qtd_logado, abdsr_agt_pausa AS qtd_pausa,abdsr_agt_ocupado AS qtd_ocupado, abdsr_agt_indisponivel AS qtd_indisponivel, abdsr_agt_nao_classificado AS qtd_naoclassificado, - STRTOINT(param3) AS tempo + STRTOINT(param3) AS tempo " . ($mostraColunaServicos ? ",s.serv_id" : "") . " FROM pbx_bilhetes a - LEFT JOIN pbx_eventos_dacs b ON a.uniqueid = b.uid2 - LEFT JOIN pbx_abandonadas_semretorno c ON c.abdsr_uniqueid = a.uniqueid - WHERE data_bilhete >= '%s' AND data_bilhete <= '%s' + inner JOIN pbx_eventos_dacs b ON a.uniqueid = b.uid2 + inner JOIN pbx_abandonadas_semretorno c ON c.abdsr_uniqueid = a.uniqueid "; + + if (GetUsoServico()) { + $query .= "\nleft join pbx_servicos_registra s on s.uniqueid = a.uniqueid "; + } + + $query .= "\nWHERE data_bilhete >= '%s' AND data_bilhete <= '%s' AND b.evento = 'ABANDON' AND a.lastapp <> 'Transferred Call' - AND b.fila = '%s' - GROUP BY 1,2,3,6,7,8,9,10,11,12,13,14,15,param3 - ORDER BY 2,3", $dataIni, $dataFim, $dac); + AND b.fila = '%s'"; + + if (GetUsoServico() && $srv) { + $query .= "\nand s.serv_id = '{$srv}'"; + } + + $query .= " GROUP BY 1,2,3,6,7,8,9,10,11,12,13,14,15,param3 " . ($mostraColunaServicos ? ", s.serv_id" : "") . " ORDER BY " . ($mostraColunaServicos ? " s.serv_id," : "") . " 2,3"; + + $query = sprintf($query, $dataIni, $dataFim, $dac); + // if ($tipo == 1) { // $query = sprintf("SELECT b.calldate, b.src ,b.dst, c.fila, d.apelido @@ -778,27 +882,39 @@ // AND b.lastapp <> 'Transferred Call' // ORDER BY 1",$dac,$dataIni); // } - } else { - $query = sprintf("SELECT b.fila, a.data_bilhete as data, date_part('hour', calldate) as hora, + } else { + $query = "SELECT " . ($mostraColunaServicos ? "s.serv_id," : "") . " b.fila, a.data_bilhete as data, date_part('hour', calldate) as hora, a.src as origem, count(*) as qtde, sum(strtoint(param3)) as tempo FROM pbx_bilhetes a INNER JOIN pbx_eventos_dacs b ON a.uniqueid = b.uid2 - INNER JOIN pbx_abandonadas_semretorno c ON c.abdsr_uniqueid = a.uniqueid - WHERE data_bilhete >= '%s' AND data_bilhete <= '%s' + INNER JOIN pbx_abandonadas_semretorno c ON c.abdsr_uniqueid = a.uniqueid"; + + if (GetUsoServico()) { + $query .= "\nleft join pbx_servicos_registra s on s.uniqueid = a.uniqueid "; + } + + $query .= "\nWHERE data_bilhete >= '%s' AND data_bilhete <= '%s' AND b.evento = 'ABANDON' AND a.lastapp <> 'Transferred Call' - AND b.fila = '%s' - GROUP BY b.fila, a.data_bilhete,date_part('hour', a.calldate), a.src - ORDER BY 2,3", $dataIni, $dataFim, $dac); - } - //if(IsAdmin()){echo $query ; exit;} - $result = $this->___GetQuery($query); - while ($row = pg_fetch_array($result, null, PGSQL_ASSOC)) { - $dataRel[] = $row; + AND b.fila = '%s'"; + + if (GetUsoServico() && $srv) { + $query .= "\nand s.serv_id = '{$srv}'"; } - $this->SetData($dataRel); - $query = sprintf("SELECT SUM(CASE WHEN(STRTOINT(param3) <= 10)THEN 1 END) AS \"TE <= 10\", + $query .= "\nGROUP BY " . ($mostraColunaServicos ? "s.serv_id," : "") . " b.fila, a.data_bilhete,date_part('hour', a.calldate), a.src + ORDER BY " . ($mostraColunaServicos ? "1," : "") . "2,3"; + + $query = sprintf($query, $dataIni, $dataFim, $dac); + } + //if(IsAdmin()){echo $query ; exit;} + $result = $this->___GetQuery($query); + while ($row = pg_fetch_array($result, null, PGSQL_ASSOC)) { + $dataRel[] = $row; + } + $this->SetData($dataRel); + + $query = "SELECT SUM(CASE WHEN(STRTOINT(param3) <= 10)THEN 1 END) AS \"TE <= 10\", SUM(CASE WHEN((STRTOINT(param3) > 10) AND (STRTOINT(param3) <= 20))THEN 1 END) AS \"10 < TE <= 20\", SUM(CASE WHEN((STRTOINT(param3) > 20) AND (STRTOINT(param3) <= 30))THEN 1 END) AS \"20 < TE <= 30\", SUM(CASE WHEN((STRTOINT(param3) > 30) AND (STRTOINT(param3) <= 60))THEN 1 END) AS \"30 < TE <= 60\", @@ -808,60 +924,73 @@ SUM(CASE WHEN(STRTOINT(param3) > 300)THEN 1 END) AS \"300 < TE\" FROM pbx_bilhetes a INNER JOIN pbx_eventos_dacs b ON b.uid2 = a.uniqueid - INNER JOIN pbx_abandonadas_semretorno c ON c.abdsr_uniqueid = a.uniqueid - INNER JOIN pbx_abandonadas_status d ON d.uniqueid = a.uniqueid - WHERE a.data_bilhete >= '%s' AND a.data_bilhete <= '%s' + INNER JOIN pbx_abandonadas_semretorno c ON c.abdsr_uniqueid = a.uniqueid"; + + if (GetUsoServico()) { + $query .= "\nleft join pbx_servicos_registra s on s.uniqueid = a.uniqueid "; + } + + $query .= "\nWHERE a.data_bilhete >= '%s' AND a.data_bilhete <= '%s' AND b.evento = 'ABANDON' AND a.lastapp <> 'Transferred Call' AND 1 = CASE WHEN(b.evento = 'ABANDON')THEN (CASE WHEN(NOT EXISTS(SELECT '' FROM ast_eventos_dacs WHERE uid2 = b.uid2 AND evento = 'TRANSBORDANDO' AND fila = b.fila)) THEN 1 ELSE 0 END) ELSE 1 END - AND b.fila = '%s' - ORDER BY 1,2", $dataIni, $dataFim, $dac); + AND b.fila = '%s'"; - $dataRel = array(); - $result = $this->___GetQuery($query); - while ($row = pg_fetch_array($result, null, PGSQL_ASSOC)) { - $dataRel[] = $row; - } - $this->SetData($dataRel); + if (GetUsoServico() && $srv) { + $query .= "\nand s.serv_id = '{$srv}'"; } - public function ExecutaRelatorio() { - global $jsStartup, $jsJQuery, $smarty; - try { - /* - * Use esta fun��o para validar dados do formul�rio. - */ - $this->___ValidaForm(); + $query .= "\nORDER BY 1,2"; + + $query = sprintf($query, $dataIni, $dataFim, $dac); - /* - * 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(); - } + + $dataRel = array(); + $result = $this->___GetQuery($query); + while ($row = pg_fetch_array($result, null, PGSQL_ASSOC)) { + $dataRel[] = $row; + } + $this->SetData($dataRel); + } + + public function ExecutaRelatorio() { + global $jsStartup, $jsJQuery, $smarty; + try { + /* + * Use esta fun��o para validar dados do formul�rio. + */ + $this->___ValidaForm(); /* - * Inclua os scripts necess�rios aqui. + * Recupera os dados do banco. */ - $jsJQuery[] = "\$('#dataIni').keypress(function(){formataDataHora(this);}) "; - $jsJQuery[] = "\$('#dataFim').keypress(function(){formataDataHora(this);}) "; + $this->___ConteudoRelatorio(); - $smarty->assign('filtros', $this->___FiltrosRelatorio()); - $smarty->assign('conteudo', $conteudoRelatorio); - $smarty->assign('msg', $this->GetMsg()); - GetTemplate($smarty, 'relatoriosGrid.tpl'); + /* + * 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'); } - $relAbd = new RelAbandonadasFila($idProg, $dbcon, 1); - $relAbd->ExecutaRelatorio(); +} + +$relAbd = new RelAbandonadasFila($idProg, $dbcon, 1); +$relAbd->ExecutaRelatorio(); ?> diff --git a/relatorios/callcenter/geral/abandonadasFilaDetalhes.php b/relatorios/callcenter/geral/abandonadasFilaDetalhes.php index 433c05ab..334959e6 100644 --- a/relatorios/callcenter/geral/abandonadasFilaDetalhes.php +++ b/relatorios/callcenter/geral/abandonadasFilaDetalhes.php @@ -1,104 +1,116 @@ ___dac = isset($_GET['dacDesc']) ? $_GET['dacDesc'] : ''; - $this->___uid = isset($_GET['uid']) ? base64_decode($_GET['uid']) : ''; - $this->___dataIni = isset($_GET['dataIni']) ? $_GET['dataIni'] : date('d/m/Y'); - $this->___dataFim = isset($_GET['dataFim']) ? $_GET['dataFim'] : date('d/m/Y'); - } + public function __construct($idProg, $dbcon, $incDac) { + parent::__construct($idProg, $dbcon, $incDac); + $this->___dac = isset($_GET['dacDesc']) ? $_GET['dacDesc'] : ''; + $this->___uid = isset($_GET['uid']) ? base64_decode($_GET['uid']) : ''; + $this->___dataIni = isset($_GET['dataIni']) ? $_GET['dataIni'] : date('d/m/Y'); + $this->___dataFim = isset($_GET['dataFim']) ? $_GET['dataFim'] : date('d/m/Y'); + $this->___servico = isset($_GET['serv_id']) ? $_GET['serv_id'] : '0'; + } - function ___ValidaForm() { - parent::___ValidaForm(); - if (!IsPostBack()) { - return; - } - if ($this->GetIncDac() && !StrToIntDef($this->___dac)) { - GeraExcept('Informe uma Fila!'); - } + function ___ValidaForm() { + parent::___ValidaForm(); + if (!IsPostBack()) { + return; } + if ($this->GetIncDac() && !StrToIntDef($this->___dac)) { + GeraExcept('Informe uma Fila!'); + } + } - function ___FiltrosRelatorio() { - if ($this->___media != MEDIA_PRINT_GRID) { - /* - * Recupera os filtros da sess�o do usu�rio. - */ - list($this->___dac, $this->___dataIni, $this->___dataFim) = $_SESSION["SSstorageFiltros"]; + function ___FiltrosRelatorio() { + if ($this->___media != MEDIA_PRINT_GRID) { + /* + * Recupera os filtros da sess�o do usu�rio. + */ + list($this->___dac, $this->___dataIni, $this->___dataFim) = $_SESSION["SSstorageFiltros"]; // if ($this->___media == MEDIA_PRINT_HTML) { // $fila = $this->GetIncDac() ? 'Fila: ' . GetDacDesc($this->GetDbCon(), $this->GetIdProg() . ' ') : ''; // return sprintf("%s Data Inicial: %s Data Final: %s ", $fila, $this->___dataIni, $this->___dataFim); // } - $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; - } - - $lkPrint = ""; - if ($this->___dataCount) { - $prt = 'Clique aqui para imprimir!'; - $prtHtml = "\"Clique"; - $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'); + $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; + } - /* - * Personalise esta função se necessitar de outras opções de filtro. - */ - $filtro = ''; - /* - * Rotulos. - */ - $filtro .= ''; - $filtro .= ''; - $filtro .= ''; - $filtro .= ''; - $filtro .= ''; - $filtro .= ''; + $lkPrint = ""; + if ($this->___dataCount) { + $prt = 'Clique aqui para imprimir!'; + $prtHtml = "\"Clique"; + $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'); + } - /* - * Valores. - */ - $filtro .= ''; + /* + * Personalise esta função se necessitar de outras opções de filtro. + */ + $filtro = '
DacData Inicial Data Final  
'; + /* + * Rotulos. + */ + $filtro .= ''; + $filtro .= ''; + if ($this->___servico) { + $filtro .= ''; + } + $filtro .= ''; + $filtro .= ''; + $filtro .= ''; + $filtro .= ''; + + /* + * Valores. + */ + $filtro .= ''; + $filtro .= ''; - $filtro .= ''; - $filtro .= ''; - $filtro .= ''; - $filtro .= '
DacServiçoData Inicial Data Final  

%s

'; + if ($this->___servico) { $filtro .= '

%s

'; - $filtro .= '

%s

%s

%s
'; - - /* - * Guarda os filtros passados para recuperar na emiss�o dos relat?ios para impress�o. - */ - //$_SESSION["SSstorageFiltros"] = array($this->___dataIni, $this->___dataFim,$this->___tipoRel); - - return sprintf($filtro, $this->___dac, date('d/m/Y H:i:s', strtotime($this->___dataIni)), date('d/m/Y H:i:s', strtotime($this->___dataFim)), $lkPrint); } + $filtro .= '

%s

'; + $filtro .= '

%s

'; + $filtro .= '%s'; + $filtro .= ''; + $filtro .= ''; + + /* + * Guarda os filtros passados para recuperar na emiss�o dos relat?ios para impress�o. + */ + //$_SESSION["SSstorageFiltros"] = array($this->___dataIni, $this->___dataFim,$this->___tipoRel); + if ($this->___servico) { + return sprintf($filtro, $this->___dac, $this->___servico, date('d/m/Y H:i:s', strtotime($this->___dataIni)), date('d/m/Y H:i:s', strtotime($this->___dataFim)), $lkPrint); + } else { + return sprintf($filtro, $this->___dac, date('d/m/Y H:i:s', strtotime($this->___dataIni)), date('d/m/Y H:i:s', strtotime($this->___dataFim)), $lkPrint); + } + } - protected function ___GetDadosDb() { + protected function ___GetDadosDb() { - $dataIni = $this->___dataIni; - $dataFim = $this->___dataFim; - $uid = $this->___uid; + $dataIni = $this->___dataIni; + $dataFim = $this->___dataFim; + $uid = $this->___uid; + $srv = $this->___servico; - if ($uid) { - $query = "SELECT data_bilhete AS data, a.matricula, apelido AS agente, a.status,d.nome AS fila, + if ($uid) { + $query = "SELECT data_bilhete AS data, a.matricula, apelido AS agente, a.status,d.nome AS fila, CASE WHEN (disponivel = 1)THEN 'DISPONIVEL' ELSE 'INDISPONIVEL' END AS disponivel, CASE WHEN (classificado = -1) THEN 'NAO OBRIGATORIO' WHEN (classificado = 0) THEN 'NAO CLASSIFICADO' @@ -106,441 +118,462 @@ motivo_pausa AS motivo, login AS hora_login, logoff AS hora_logoff FROM pbx_abandonadas_status a INNER JOIN pbx_bilhetes e ON e.uniqueid = a.uniqueid - INNER JOIN pbx_eventos_agentes b ON b.matricula = a.matricula - INNER JOIN pbx_usuarios c ON c.matricula = a.matricula + INNER JOIN pbx_eventos_agentes b ON b.matricula = a.matricula"; + + if (GetUsoServico()) { + $query .= "\nleft join pbx_servicos_registra s on s.uniqueid = a.uniqueid "; + } + + $query .= "\nINNER JOIN pbx_usuarios c ON c.matricula = a.matricula INNER JOIN pbx_dacs d ON d.id = b.id_dac WHERE login <= '$dataIni' AND logoff >= '$dataFim' AND a.uniqueid = '{$uid}' AND d.nome = '$this->___dac'"; - $query .= " GROUP BY data_bilhete,a.matricula,apelido,a.status,d.nome,disponivel,classificado,motivo_pausa, login, logoff ORDER BY login"; - } else { - $query = "SELECT '{$this->___dataIni}' AS data, a.matricula, apelido AS agente, d.nome AS fila, + + if (GetUsoServico() && $srv) { + $query .= "\nand s.serv_id = '{$srv}'"; + } + + $query .= " GROUP BY data_bilhete,a.matricula,apelido,a.status,d.nome,disponivel,classificado,motivo_pausa, login, logoff ORDER BY login"; + } else { + $query = "SELECT '{$this->___dataIni}' AS data, a.matricula, apelido AS agente, d.nome AS fila, login AS hora_login, logoff AS hora_logoff FROM pbx_abandonadas_status a INNER JOIN pbx_bilhetes e ON e.uniqueid = a.uniqueid - INNER JOIN pbx_eventos_agentes b ON b.matricula = a.matricula - INNER JOIN pbx_usuarios c ON c.matricula = a.matricula - INNER JOIN pbx_dacs d ON d.id = b.id_dac - WHERE login <= '$dataIni' AND logoff >= '$dataFim' AND d.id = '$this->___dac' - GROUP BY a.matricula,apelido,d.nome, login, logoff - ORDER BY login"; + INNER JOIN pbx_eventos_agentes b ON b.matricula = a.matricula"; + + if (GetUsoServico()) { + $query .= "\nleft join pbx_servicos_registra s on s.uniqueid = a.uniqueid "; } + $query .= "\nINNER JOIN pbx_usuarios c ON c.matricula = a.matricula + INNER JOIN pbx_dacs d ON d.id = b.id_dac + WHERE login <= '$dataIni' AND logoff >= '$dataFim' AND d.id = '$this->___dac'"; - $result = $this->___GetQuery($query); - $row = pg_fetch_all($result); - - $this->SetData($row ? $row : array()); - $this->SetData(array( - array( - 'logado' => $_GET['logado'], - 'pausa' => $_GET['pausa'], - 'ocupado' => $_GET['ocupado'], - 'indisponivel' => $_GET['indisponivel'], - 'classificacao' => $_GET['classificacao'], - 'pos_chegada' => $_GET['pos_chegada'], - 'pos_abandono' => $_GET['pos_saida'], - 'agtRet' => $_GET['agtRet'], - 'dtRet' => $_GET['dtRet'] - ))); - } - protected function ___PreparaCsv() { - $dataRel = array(); - $filtro = $this->___FiltrosRelatorio(); + if (GetUsoServico() && $srv) { + $query .= "\nand s.serv_id = '{$srv}'"; + } - /* - * Inicia o relat�rio. - */ - $dataRel[] = GenerateCsvFromArray($filtro); - - $dadosCabecalio = array( - 'Data', - 'Agente', - 'Matricula', - 'Login', - 'Logoff', - 'Status', - 'Disponivel Fila', - 'Classificacao', - 'Motivo Pausa'); - $dadosField = array( - 'data', - 'agente', - 'matricula', - 'hora_login', - 'hora_logoff', - 'status', - 'disponivel', - 'classificado', - 'motivo'); + $query .= " GROUP BY a.matricula,apelido,d.nome, login, logoff + ORDER BY login"; + } - /* - * Monta a linha de cabecalio. - */ - $dataRel[] = GenerateCsvFromArray($dadosCabecalio); - /* - * Linhas de dados. - */ - foreach ($this->GetData()[0] as $row) { - $row["data"] = date('d/m/Y', strtotime($row["data"])); - $row["hora_login"] = date('H:m:i', strtotime($row["hora_login"])); - $row["hora_logoff"] = date('H:m:i', strtotime($row["hora_logoff"])); - - // Formata linha de dados. - $linha = array(); - foreach ($dadosField as $key => $value) { - $linha[] = $row["$value"]; - } + $result = $this->___GetQuery($query); + $row = pg_fetch_all($result); + + $this->SetData($row ? $row : array()); + $this->SetData(array( + array( + 'logado' => $_GET['logado'], + 'pausa' => $_GET['pausa'], + 'ocupado' => $_GET['ocupado'], + 'indisponivel' => $_GET['indisponivel'], + 'classificacao' => $_GET['classificacao'], + 'pos_chegada' => $_GET['pos_chegada'], + 'pos_abandono' => $_GET['pos_saida'], + 'agtRet' => $_GET['agtRet'], + 'dtRet' => $_GET['dtRet'] + ))); + } - $dataRel[] = GenerateCsvFromArray($linha); + protected function ___PreparaCsv() { + $dataRel = array(); + $filtro = $this->___FiltrosRelatorio(); + + /* + * Inicia o relat�rio. + */ + $dataRel[] = GenerateCsvFromArray($filtro); + + $dadosCabecalio = array( + 'Data', + 'Agente', + 'Matricula', + 'Login', + 'Logoff', + 'Status', + 'Disponivel Fila', + 'Classificacao', + 'Motivo Pausa'); + $dadosField = array( + 'data', + 'agente', + 'matricula', + 'hora_login', + 'hora_logoff', + 'status', + 'disponivel', + 'classificado', + 'motivo'); + + /* + * Monta a linha de cabecalio. + */ + $dataRel[] = GenerateCsvFromArray($dadosCabecalio); + + /* + * Linhas de dados. + */ + foreach ($this->GetData()[0] as $row) { + $row["data"] = date('d/m/Y', strtotime($row["data"])); + $row["hora_login"] = date('H:m:i', strtotime($row["hora_login"])); + $row["hora_logoff"] = date('H:m:i', strtotime($row["hora_logoff"])); + + // Formata linha de dados. + $linha = array(); + foreach ($dadosField as $key => $value) { + $linha[] = $row["$value"]; } - $dadosCabecalio1 = array('Logado', 'Pausa', 'Ocupado', 'Indisponivel', 'Nao Classificado', 'Pos. Chegada', 'Pos. Abandono', 'Agente Retorno', 'Data Retorno'); - $dadosField1 = array('logado', 'pausa', 'ocupado', 'indisponivel', 'classificacao', 'pos_chegada', 'pos_abandono', 'agtRet', 'dtRet'); - $dataRel[] = GenerateCsvFromArray($dadosCabecalio1); + $dataRel[] = GenerateCsvFromArray($linha); + } + + $dadosCabecalio1 = array('Logado', 'Pausa', 'Ocupado', 'Indisponivel', 'Nao Classificado', 'Pos. Chegada', 'Pos. Abandono', 'Agente Retorno', 'Data Retorno'); + $dadosField1 = array('logado', 'pausa', 'ocupado', 'indisponivel', 'classificacao', 'pos_chegada', 'pos_abandono', 'agtRet', 'dtRet'); + $dataRel[] = GenerateCsvFromArray($dadosCabecalio1); - foreach ($this->GetData()[1] as $row) { + foreach ($this->GetData()[1] as $row) { - // Formata linha de dados. - $linha = array(); - foreach ($dadosField1 as $key => $value) { - if ($key == 'dtRet') { - $row['dtRet'] = $row['dtRet'] ? date('d/m/Y', strtotime($row['dtRet'])) : '-'; - } - $linha[] = $row["$value"]; + // Formata linha de dados. + $linha = array(); + foreach ($dadosField1 as $key => $value) { + if ($key == 'dtRet') { + $row['dtRet'] = $row['dtRet'] ? date('d/m/Y', strtotime($row['dtRet'])) : '-'; } - - $dataRel[] = GenerateCsvFromArray($linha); + $linha[] = $row["$value"]; } - $this->___dataRel[] = $dataRel; + $dataRel[] = GenerateCsvFromArray($linha); } - protected function ___PreparaExcel() { - $dataRel = array(); - $filtro = $this->___FiltrosRelatorio(); - - /* - * Inicia o relatório. - */ + $this->___dataRel[] = $dataRel; + } - /* - * Cria os filtros - */ - $linha = array('LABEL'); - foreach ($filtro as $values) { - list($label, $value) = explode(":", $values); - $linha[] = $label; - } - $dataRel[] = $linha; + 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; - } + $linha = array('DADOS'); + foreach ($filtro as $values) { + list($label, $value) = explode(":", $values); + $linha[] = $value; + } - $dataRel[] = $linha; + $dataRel[] = $linha; + + $dadosCabecalio = array( + 'Data', + 'Agente', + 'Matricula', + 'Login', + 'Logoff', + 'Status', + 'Disponivel Fila', + 'Classificacao', + 'Motivo Pausa'); + $dadosField = array( + 'data', + 'agente', + 'matricula', + 'hora_login', + 'hora_logoff', + 'status', + 'disponivel', + 'classificado', + 'motivo'); + + /* + * Monta a linha de cabecalio. + */ + $linha = array('LABEL'); + foreach ($dadosCabecalio as $value) { + $linha[] = $value; + } + $dataRel[] = $linha; - $dadosCabecalio = array( - 'Data', - 'Agente', - 'Matricula', - 'Login', - 'Logoff', - 'Status', - 'Disponivel Fila', - 'Classificacao', - 'Motivo Pausa'); - $dadosField = array( - 'data', - 'agente', - 'matricula', - 'hora_login', - 'hora_logoff', - 'status', - 'disponivel', - 'classificado', - 'motivo'); + /* + * Linhas de dados. + */ + foreach ($this->GetData()[0] as $row) { + $row["data"] = date('d/m/Y', strtotime($row["data"])); + $row["hora_login"] = date('H:m:i', strtotime($row["hora_login"])); + $row["hora_logoff"] = date('H:m:i', strtotime($row["hora_logoff"])); - /* - * Monta a linha de cabecalio. - */ - $linha = array('LABEL'); - foreach ($dadosCabecalio as $value) { - $linha[] = $value; + // Formata linha de dados. + $linha = array('DADOS'); + foreach ($dadosField as $key) { + $linha[] = $row["$key"]; } $dataRel[] = $linha; + } - /* - * Linhas de dados. - */ - foreach ($this->GetData()[0] as $row) { - $row["data"] = date('d/m/Y', strtotime($row["data"])); - $row["hora_login"] = date('H:m:i', strtotime($row["hora_login"])); - $row["hora_logoff"] = date('H:m:i', strtotime($row["hora_logoff"])); - - // Formata linha de dados. - $linha = array('DADOS'); - foreach ($dadosField as $key) { - $linha[] = $row["$key"]; - } - $dataRel[] = $linha; - } + $this->___dataRel[] = $dataRel; - $this->___dataRel[] = $dataRel; + /* + * Agrupamento + */ + $dadosCabecalio1 = array( + 'Logado', 'Pausa', 'Ocupado', 'Indisponivel', 'Nao Classificado', + 'Pos. Chegada', 'Pos. Abandono', 'Agente Retorno', 'Data Retorno' + ); - /* - * Agrupamento - */ - $dadosCabecalio1 = array( - 'Logado', 'Pausa', 'Ocupado', 'Indisponivel', 'Nao Classificado', - 'Pos. Chegada', 'Pos. Abandono', 'Agente Retorno', 'Data Retorno' - ); - - $dadosField1 = array( - 'logado', 'pausa', 'ocupado', 'indisponivel', 'classificacao', - 'pos_chegada', 'pos_abandono', 'agtRet', 'dtRet' - ); - - $linha = array('LABEL'); - foreach ($dadosCabecalio1 as $value) { - $linha[] = $value; - } - $dataRel1[] = $linha; + $dadosField1 = array( + 'logado', 'pausa', 'ocupado', 'indisponivel', 'classificacao', + 'pos_chegada', 'pos_abandono', 'agtRet', 'dtRet' + ); + + $linha = array('LABEL'); + foreach ($dadosCabecalio1 as $value) { + $linha[] = $value; + } + $dataRel1[] = $linha; - foreach ($this->GetData()[1] as $row) { + foreach ($this->GetData()[1] as $row) { - // Formata linha de dados. - $linha = array('DADOS'); - foreach ($dadosField1 as $key) { - if ($key == 'dtRet') { - $row['dtRet'] = $row['dtRet'] ? date('d/m/Y', strtotime($row['dtRet'])) : '-'; - } - $linha[] = $row["$key"]; + // Formata linha de dados. + $linha = array('DADOS'); + foreach ($dadosField1 as $key) { + if ($key == 'dtRet') { + $row['dtRet'] = $row['dtRet'] ? date('d/m/Y', strtotime($row['dtRet'])) : '-'; } - $dataRel1[] = $linha; + $linha[] = $row["$key"]; } - $this->___dataRel[] = $dataRel1; + $dataRel1[] = $linha; } + $this->___dataRel[] = $dataRel1; + } - protected function ___PreparaGrid() { - $dadosCabecalio = array( - 'Data' => 'align="center"', - 'Agente' => 'align="left"', - 'Matricula' => 'align="left"', - 'Login' => 'align="center"', - 'Logoff' => 'align="center"', - 'Status' => 'align="left"', - 'Disponível Fila' => 'align="center"', - 'Classificação' => 'align="center"', - 'Motivo Pausa' => 'align="left"' - ); - $dadosField = array( - 'data' => 'align="center"', - 'agente' => 'align="left"', - 'matricula' => 'align="left"', - 'hora_login' => 'align="center"', - 'hora_logoff' => 'align="center"', - 'status' => 'align="left"', - 'disponivel' => 'align="center"', - 'classificado' => 'align="center"', - 'motivo' => 'align="left"'); - /* - * Inicia o relat�rio. - */ - $dataRel[] = ''; - - /* - * Monta a linha de cabecalio. - */ - $linhaH = ''; - foreach ($dadosCabecalio as $key => $value) { - $linhaH .= sprintf("", $value, $key); + protected function ___PreparaGrid() { + $dadosCabecalio = array( + 'Data' => 'align="center"', + 'Agente' => 'align="left"', + 'Matricula' => 'align="left"', + 'Login' => 'align="center"', + 'Logoff' => 'align="center"', + 'Status' => 'align="left"', + 'Disponível Fila' => 'align="center"', + 'Classificação' => 'align="center"', + 'Motivo Pausa' => 'align="left"' + ); + $dadosField = array( + 'data' => 'align="center"', + 'agente' => 'align="left"', + 'matricula' => 'align="left"', + 'hora_login' => 'align="center"', + 'hora_logoff' => 'align="center"', + 'status' => 'align="left"', + 'disponivel' => 'align="center"', + 'classificado' => 'align="center"', + 'motivo' => 'align="left"'); + /* + * Inicia o relat�rio. + */ + $dataRel[] = '
%s
'; + + /* + * Monta a linha de cabecalio. + */ + $linhaH = ''; + foreach ($dadosCabecalio as $key => $value) { + $linhaH .= sprintf("", $value, $key); + } + $linhaH .= ""; + $dataRel[] = $linhaH; + + /* + * Linhas de dados. + */ + foreach ($this->GetData()[0] as $row) { + $row["data"] = date('d/m/Y', strtotime($row["data"])); + $row["hora_login"] = date('H:i:s', strtotime($row["hora_login"])); + $row["hora_logoff"] = date('H:i:s', strtotime($row["hora_logoff"])); + $row["disponivel"] = $row["disponivel"] ? $row["disponivel"] : '-'; + $row["classificado"] = $row["classificado"] ? $row["classificado"] : '-'; + $row["motivo"] = $row["motivo"] ? $row["motivo"] : '-'; + + // Formata linha de dados. + $linha = ""; + foreach ($dadosField as $key => $value) { + $linha .= sprintf("", $value, $row["$key"]); } - $linhaH .= ""; - $dataRel[] = $linhaH; + $linha .= ""; + $dataRel[] = $linha; + } - /* - * Linhas de dados. - */ - foreach ($this->GetData()[0] as $row) { - $row["data"] = date('d/m/Y', strtotime($row["data"])); - $row["hora_login"] = date('H:i:s', strtotime($row["hora_login"])); - $row["hora_logoff"] = date('H:i:s', strtotime($row["hora_logoff"])); - $row["disponivel"] = $row["disponivel"] ? $row["disponivel"] : '-'; - $row["classificado"] = $row["classificado"] ? $row["classificado"] : '-'; - $row["motivo"] = $row["motivo"] ? $row["motivo"] : '-'; - - // Formata linha de dados. - $linha = ""; - foreach ($dadosField as $key => $value) { - $linha .= sprintf("", $value, $row["$key"]); - } - $linha .= ""; - $dataRel[] = $linha; + $dataRel[] = '
%s
%s
%s
'; + $this->___dataRel[] = $dataRel; + /* + * Linha de totalizacao. + */ + $dadosCabecalio1 = array( + 'Logado' => 'align="right"', + 'Pausa' => 'align="right"', + 'Ocupado' => 'align="right"', + 'Indisponivel' => 'align="right"', + 'Não Classificado' => 'align="right"', + 'Pos. Chegada' => 'align="right"', + 'Pos. Abandono' => 'align="right"', + 'Agente Retorno' => 'align="center"', + 'Data Retorno' => 'align="center"' + ); + + if ($this->___uid) { + $dataRel1[] = ''; + $linhaH1 = ''; + foreach ($dadosCabecalio1 as $key => $value) { + $linhaH1 .= sprintf("", $value, $key); } + $linhaH1 .= ""; + $dataRel1[] = $linhaH1; + + $linhaH2 = sprintf('' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '', $_GET['logado'], $_GET['pausa'], $_GET['ocupado'], $_GET['indisponivel'], $_GET['classificacao'], $_GET['pos_chegada'], $_GET['pos_saida'], $_GET['agtRet'], $_GET['dtRet'] ? date('d/m/Y', strtotime($_GET['dtRet'])) : '-'); + $dataRel1[] = $linhaH2; - $dataRel[] = '
%s
%s%s%s%s%s%s%s%s%s
'; - $this->___dataRel[] = $dataRel; /* - * Linha de totalizacao. + * Fecha relatorio. */ - $dadosCabecalio1 = array( - 'Logado' => 'align="right"', - 'Pausa' => 'align="right"', - 'Ocupado' => 'align="right"', - 'Indisponivel' => 'align="right"', - 'Não Classificado' => 'align="right"', - 'Pos. Chegada' => 'align="right"', - 'Pos. Abandono' => 'align="right"', - 'Agente Retorno' => 'align="center"', - 'Data Retorno' => 'align="center"' - ); - - if ($this->___uid) { - $dataRel1[] = ''; - $linhaH1 = ''; - foreach ($dadosCabecalio1 as $key => $value) { - $linhaH1 .= sprintf("", $value, $key); - } - $linhaH1 .= ""; - $dataRel1[] = $linhaH1; - - $linhaH2 = sprintf('' - . '' - . '' - . '' - . '' - . '' - . '' - . '' - . '' - . '' - . '', $_GET['logado'], $_GET['pausa'], $_GET['ocupado'], $_GET['indisponivel'], $_GET['classificacao'], $_GET['pos_chegada'], $_GET['pos_saida'], $_GET['agtRet'], $_GET['dtRet'] ? date('d/m/Y', strtotime($_GET['dtRet'])) : '-'); - $dataRel1[] = $linhaH2; - - /* - * Fecha relatorio. - */ - $dataRel1[] = '
%s
%s%s%s%s%s%s%s%s%s
'; - } - $this->___dataRel[] = $dataRel1; - } - - protected function ___PreparaHtml() { - + $dataRel1[] = ''; } + $this->___dataRel[] = $dataRel1; + } - protected function ___PreparaPdf() { + protected function ___PreparaHtml() { + + } - list($this->___dac, $this->___dataIni, $this->___dataFim) = $_SESSION["SSstorageFiltros"]; - $dados = $this->GetData()[0]; - $x = 0; - $y = 0; - foreach ($dados as $row) { - $dados[$x]["data"] = date('d/m/Y', strtotime($row["data"])); - $dados[$x]["hora_login"] = date('H:m:i', strtotime($row["hora_login"])); - $dados[$x]["hora_logoff"] = date('H:m:i', strtotime($row["hora_logoff"])); - $x++; - } - $header = array( - 'Data' => 'C', - 'Agente' => 'C', - 'Matricula' => 'C', - 'Login' => 'C', - 'Logoff' => 'C', - 'Status' => 'C', - 'Disponível Fila' => 'C', - 'Classificação' => 'C', - 'Motivo Pausa' => 'C' - ); - $dataHeader = array( - 'data' => 'C', - 'agente' => 'C', - 'matricula' => 'C', - 'hora_login' => 'C', - 'hora_logoff' => 'C', - 'status' => 'C', - 'disponivel' => 'C', - 'classificado' => 'C', - 'motivo' => 'C' - ); - $widthHeader = array(20, 20, 20, 20, 20, 20, 25, 25, 25); - $table1 = array($header, $dataHeader, $dados, $widthHeader, '', 0); - - $headerTotal = array( - 'Logado' => 'C', - 'Pausa' => 'C', - 'Ocupado' => 'C', - 'Indisponível' => 'C', - 'Não Classificado' => 'C', - 'Pos. Chegada' => 'C', - 'Pos Abandono' => 'C', - 'Agente Retorno' => 'C', - 'Data Retorno' => 'C' - ); - $dataTotal = array( - 'logado' => 'C', - 'pausa' => 'C', - 'ocupado' => 'C', - 'indisponivel' => 'C', - 'classificacao' => 'C', - 'pos_chegada' => 'C', - 'pos_abandono' => 'C', - 'agtRet' => 'C', - 'dtRet' => 'C' - ); - - $dadosAgt = $this->GetData()[1]; - foreach ($dadosAgt as $rowAgt) { - $dadosAgt[$y]['dtRet'] = $rowAgt['dtRet'] ? date('d/m/Y', strtotime($rowAgt['dtRet'])) : '-'; - $y++; - } + protected function ___PreparaPdf() { + + list($this->___dac, $this->___dataIni, $this->___dataFim) = $_SESSION["SSstorageFiltros"]; + $dados = $this->GetData()[0]; + $x = 0; + $y = 0; + foreach ($dados as $row) { + $dados[$x]["data"] = date('d/m/Y', strtotime($row["data"])); + $dados[$x]["hora_login"] = date('H:m:i', strtotime($row["hora_login"])); + $dados[$x]["hora_logoff"] = date('H:m:i', strtotime($row["hora_logoff"])); + $x++; + } + $header = array( + 'Data' => 'C', + 'Agente' => 'C', + 'Matricula' => 'C', + 'Login' => 'C', + 'Logoff' => 'C', + 'Status' => 'C', + 'Disponível Fila' => 'C', + 'Classificação' => 'C', + 'Motivo Pausa' => 'C' + ); + $dataHeader = array( + 'data' => 'C', + 'agente' => 'C', + 'matricula' => 'C', + 'hora_login' => 'C', + 'hora_logoff' => 'C', + 'status' => 'C', + 'disponivel' => 'C', + 'classificado' => 'C', + 'motivo' => 'C' + ); + $widthHeader = array(20, 20, 20, 20, 20, 20, 25, 25, 25); + $table1 = array($header, $dataHeader, $dados, $widthHeader, '', 0); + + $headerTotal = array( + 'Logado' => 'C', + 'Pausa' => 'C', + 'Ocupado' => 'C', + 'Indisponível' => 'C', + 'Não Classificado' => 'C', + 'Pos. Chegada' => 'C', + 'Pos Abandono' => 'C', + 'Agente Retorno' => 'C', + 'Data Retorno' => 'C' + ); + $dataTotal = array( + 'logado' => 'C', + 'pausa' => 'C', + 'ocupado' => 'C', + 'indisponivel' => 'C', + 'classificacao' => 'C', + 'pos_chegada' => 'C', + 'pos_abandono' => 'C', + 'agtRet' => 'C', + 'dtRet' => 'C' + ); + + $dadosAgt = $this->GetData()[1]; + foreach ($dadosAgt as $rowAgt) { + $dadosAgt[$y]['dtRet'] = $rowAgt['dtRet'] ? date('d/m/Y', strtotime($rowAgt['dtRet'])) : '-'; + $y++; + } - $widthHeaderTotal = array(20, 20, 20, 20, 25, 25, 25, 20, 20); - $table2 = array($headerTotal, $dataTotal, $dadosAgt, $widthHeaderTotal, '', 1); + $widthHeaderTotal = array(20, 20, 20, 20, 25, 25, 25, 20, 20); + $table2 = array($headerTotal, $dataTotal, $dadosAgt, $widthHeaderTotal, '', 1); - $this->___dataRel = array($table1, $table2); - } + $this->___dataRel = array($table1, $table2); + } - 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(); - } + public function ExecutaRelatorio() { + global $jsStartup, $jsJQuery, $smarty; + try { + /* + * Use esta fun��o para validar dados do formul�rio. + */ + $this->___ValidaForm(); /* - * Inclua os scripts necess�rios aqui. + * Recupera os dados do banco. */ - $jsJQuery[] = "\$('#dataIni').keypress(function(){formataDataHora(this);}) "; - $jsJQuery[] = "\$('#dataFim').keypress(function(){formataDataHora(this);}) "; + $this->___ConteudoRelatorio(); - $smarty->assign('filtros', $this->___FiltrosRelatorio()); - $smarty->assign('conteudo', $conteudoRelatorio); - $smarty->assign('msg', $this->GetMsg()); - GetTemplate($smarty, 'relatoriosGrid.tpl'); + /* + * 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'); } - $relChmEntG = new AbandonadasFilaDetalhes($idProg, $dbcon, 1); - $relChmEntG->ExecutaRelatorio(); +} + +$relChmEntG = new AbandonadasFilaDetalhes($idProg, $dbcon, 1); +$relChmEntG->ExecutaRelatorio(); ?> diff --git a/relatorios/callcenter/geral/recebidasAgente.php b/relatorios/callcenter/geral/recebidasAgente.php index 2892ea21..11d05e4c 100644 --- a/relatorios/callcenter/geral/recebidasAgente.php +++ b/relatorios/callcenter/geral/recebidasAgente.php @@ -1,492 +1,624 @@ ___dac = isset($_POST['listaDacs']) ? $_POST['listaDacs'] : 0; - $this->___tempoAtendimento = isset($_POST['tempoAtendimento']) ? $_POST['tempoAtendimento'] : ''; - $this->___agente = isset($_POST["listaAgente"]) ? $_POST["listaAgente"] : 0; + private $___agente; + private $___tempoAtendimento; + private $___servico; + + public function __construct($idProg, $dbcon, $incDac) { + parent::__construct($idProg, $dbcon, $incDac); + $this->___dac = isset($_POST['listaDacs']) ? $_POST['listaDacs'] : 0; + $this->___tempoAtendimento = isset($_POST['tempoAtendimento']) ? $_POST['tempoAtendimento'] : ''; + $this->___agente = isset($_POST["listaAgente"]) ? $_POST["listaAgente"] : 0; + $this->___servico = isset($_POST["listaServico"]) ? $_POST["listaServico"] : 0; + } + + public function ___ValidaForm() { + parent::___ValidaForm(); + if (!IsPostBack()) { + return; + } + if ($this->___agente < 0) { + GeraExcept('Informe um agente!'); } - public function ___ValidaForm() { - parent::___ValidaForm(); - if (!IsPostBack()) { - return; - } - if ($this->___agente < 0) { - GeraExcept('Informe um agente!'); - } - - if ($this->___tempoAtendimento && $this->___tempoAtendimento < 10) { - GeraExcept('Por favor, informe a duração maior que 10 segundos!'); - } + if ($this->___tempoAtendimento && $this->___tempoAtendimento < 10) { + GeraExcept('Por favor, informe a duração maior que 10 segundos!'); } + } + + function ___FiltrosRelatorio() { + + $agente = $this->___GetAgente(); + + if ($this->___media != MEDIA_PRINT_GRID) { + /* + * Recupera os filtros da sessão do usuário. + */ + list($this->___dac, $this->___dataIni, $this->___dataFim, $this->___tipoRelatorio) = $_SESSION["SSstorageFiltros"]; - function ___FiltrosRelatorio() { - $agente = $this->___GetAgente(); - - if ($this->___media != MEDIA_PRINT_GRID) { - /* - * Recupera os filtros da sessão do usuá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ítico' : 'Sinté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->___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ítico' : 'Sintético')); } + $fltCsv = array(); if ($this->GetIncDac()) { - $dacs = GetDac($this->GetDbCon(), $this->___dac, "", 0, 1, 0, 0, 1); + $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; + } - $lkPrint = ""; - if ($this->___dataCount) { - $prt = 'Clique aqui para imprimir!'; - $prtHtml = "\"Clique"; - $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'); - } + if ($this->GetIncDac()) { + $dacs = GetDac($this->GetDbCon(), $this->___dac, "", 0, 1, 0, 0, 1); + } - $tipoRel = !$this->___tipoRelatorio ? '' : 'checked="checked"'; - /* - * Personalise esta função se necessitar de outras op��es de filtro. - */ - $filtro = ''; - /* - * Rotulos. - */ - $filtro .= ''; - if ($this->GetIncDac()) - $filtro .= ''; - $filtro .= ''; - $filtro .= ''; - $filtro .= ''; - $filtro .= ''; - $filtro .= ''; - $filtro .= ''; + $lkPrint = ""; + if ($this->___dataCount) { + $prt = 'Clique aqui para imprimir!'; + $prtHtml = "\"Clique"; + $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'); + } - /* - * Valores. - */ - $filtro .= ''; - if ($this->GetIncDac()) - $filtro .= sprintf('', $dacs); - $filtro .= ''; - $filtro .= ''; - $filtro .= sprintf('', $agente); - $filtro .= ""; - $filtro .= ''; - $filtro .= ''; - $filtro .= ''; - $filtro .= '
FilaData InicialData Final AgenteDuração (Segundos) 
%s%s%s
'; + $tipoRel = !$this->___tipoRelatorio ? '' : 'checked="checked"'; + /* + * Personalise esta função se necessitar de outras op��es de filtro. + */ + $filtro = ''; + /* + * Rotulos. + */ + $filtro .= ''; + if ($this->GetIncDac()) + $filtro .= ''; + $filtro .= ''; + $filtro .= ''; + if (GetUsoServico()) { + $filtro .= ''; + } + $filtro .= ''; + $filtro .= ''; + $filtro .= ''; + $filtro .= ''; + + /* + * Valores. + */ + $filtro .= ''; + if ($this->GetIncDac()) + $filtro .= sprintf('', $dacs); + $filtro .= ''; + $filtro .= ''; + if (GetUsoServico()) { + $filtro .= sprintf('', GetIdentRota(false, $this->___servico)); + } + $filtro .= sprintf('', $agente); + $filtro .= ""; + $filtro .= ''; + $filtro .= ''; + $filtro .= ''; + $filtro .= '
FilaData InicialData Final Serviço AgenteDuração (Segundos) 
%s%s%s%s
'; - /* - * Guarda os filtros passados para recuperar na emissão dos relatóios para impressão. - */ + /* + * Guarda os filtros passados para recuperar na emissão dos relatóios para impressão. + */ - $_SESSION["SSstorageFiltros"] = array($this->___dac, $this->___dataIni, $this->___dataFim, $this->___tipoRelatorio, $this->___agente); + $_SESSION["SSstorageFiltros"] = array($this->___dac, $this->___dataIni, $this->___dataFim, $this->___tipoRelatorio, $this->___agente); - return sprintf($filtro, $this->___dataIni, $this->___dataFim, $lkPrint); - } + return sprintf($filtro, $this->___dataIni, $this->___dataFim, $lkPrint); + } - protected function ___GetDadosDb() { - $dataIni = FormatDtMssql($this->___dataIni); - $dataFim = FormatDtHoraBD($this->___dataFim); - $agente = $this->___agente; - $dac = $this->___dac; + protected function ___GetDadosDb() { + $dataIni = FormatDtMssql($this->___dataIni); + $dataFim = FormatDtHoraBD($this->___dataFim); + $srv = $this->___servico; + $agente = $this->___agente; + $dac = $this->___dac; + $mostraColunaServicos = GetUsoServico() == RELATORIO_SERVICOS_HABILITA; - $query1 = "SELECT a.calldate AS data, a.src AS origem, + $query1 = "SELECT a.calldate AS data, a.src AS origem, CASE WHEN(b.evento IN('COMPLETECALLER', 'COMPLETEAGENT', 'COMPLETEAGENTRAMAL', 'COMPLETECALLERRAMAL'))THEN strtoint(b.param2) ELSE CASE WHEN(b.evento = 'TRANSFER')THEN strtoint(b.param4) ELSE 0 END END AS tmo, - c.apelido AS agente, CASE WHEN(b.evento IN('BUSY','NOANSWER'))THEN 0 ELSE 1 END AS status,'' AS desligado, b.fila"; - - $query2 = "SELECT DISTINCT c.matricula, c.apelido"; - - $query = " FROM pbx_bilhetes a, pbx_eventos_dacs b, pbx_usuarios c - WHERE b.uid2 = a.uniqueid - AND c.matricula = SUBSTRING(b.agente,7 ,4) - AND a.data_bilhete >= '$dataIni' - AND a.data_bilhete <= '$dataFim' - AND a.lastapp <> 'Transferred Call' - AND b.evento IN('COMPLETEAGENT','COMPLETECALLER', 'TRANSFER','COMPLETEAGENTRAMAL','COMPLETECALLERRAMAL','BUSY','NOANSWER') - AND b.fila = (SELECT nome FROM pbx_dacs WHERE id = '$dac') "; - if ($agente) { - $query .= "AND c.matricula = '$agente'"; - } - - $sqlTempo = $this->___tempoAtendimento && $this->___tempoAtendimento > 10 ? " AND strtoint(b.param2) >= ".$this->___tempoAtendimento : ''; + c.apelido AS agente, CASE WHEN(b.evento IN('BUSY','NOANSWER'))THEN 0 ELSE 1 END AS status,'' AS desligado, b.fila" . ($mostraColunaServicos ? ", s.serv_id" : ""); - $result = $this->___GetQuery($query1 . $query . $sqlTempo ." ORDER BY 1 "); - $row = pg_fetch_all($result); - $this->SetData($row ? $row : array()); + $query2 = "SELECT DISTINCT c.matricula, c.apelido"; - $result2 = $this->___GetQuery($query2 . $query . " ORDER BY 2 "); - $row2 = pg_fetch_all($result2); - $this->SetData($row2 ? $row2 : array()); + $query = " FROM pbx_bilhetes a + inner join pbx_eventos_dacs b on b.uid2 = a.uniqueid + inner join pbx_usuarios c on c.matricula = SUBSTRING(b.agente,7 ,4)"; + if (GetUsoServico()) { + $query .= " left join pbx_servicos_registra s on s.uniqueid = a.uniqueid"; + } + $query .= " WHERE a.data_bilhete >= '$dataIni' + AND a.data_bilhete <= '$dataFim' + AND a.lastapp <> 'Transferred Call' + AND b.evento IN('COMPLETEAGENT','COMPLETECALLER', 'TRANSFER','COMPLETEAGENTRAMAL','COMPLETECALLERRAMAL','BUSY','NOANSWER') + AND b.fila = (SELECT nome FROM pbx_dacs WHERE id = '$dac') "; + if ($agente) { + $addAgente = "\nAND c.matricula = '$agente'"; } - protected function ___PreparaCsv() { - $dataRel = array(); - $filtro = $this->___FiltrosRelatorio(); - $dataRel[] = GenerateCsvFromArray($filtro); - - $dadosCabecalio = array( - 'Data', 'Hora', 'Origem', 'TMA', 'Agente', 'Status' - ); - $dadosField = array( - 'data', 'hora', 'origem', 'tmo', 'agente', 'status' - ); - - $dataRel[] = GenerateCsvFromArray($dadosCabecalio); - - $somaReg = 0; - $somaDuracao = 0; - $somaAtendida = 0; - $somaNAtendida = 0; - - foreach ($this->GetData()[0] as $row) { - $somaReg ++; - $somaDuracao += $row['tmo']; - $row['status'] == 1 ? $somaAtendida++ : $somaNAtendida++; - - $row['hora'] = date('H:i:s', strtotime($row['data'])); - $row['data'] = date('d/m/Y', strtotime($row['data'])); - $row['tmo'] = SecondToStrTime($row['tmo']); - $row['status'] = $row['status'] == 1 ? "Atendida" : "Não Atendida"; - - $linha = array(); - foreach ($dadosField as $key) { - $linha[] = $row["$key"]; - } - $dataRel[] = GenerateCsvFromArray($linha); - } - $dataRel[] = GenerateCsvFromArray(array('TMO', SecondToStrTime($somaDuracao) , '')); - - $dataRel[] = GenerateCsvFromArray(array('')); - $dataRel[] = GenerateCsvFromArray(array('Atendida', 'Nao Atendida', 'Geral')); - $dataRel[] = GenerateCsvFromArray(array($somaAtendida, $somaNAtendida, $somaReg)); - - $this->___dataRel[] = $dataRel; - + if (GetUsoServico() && $srv) { + $query .= "\nAND s.serv_id = '{$srv}'"; } - protected function ___PreparaExcel() { - $dataRel = array(); - $filtro = $this->___FiltrosRelatorio(); + $sqlTempo = $this->___tempoAtendimento && $this->___tempoAtendimento > 10 ? "\nAND strtoint(b.param2) >= " . $this->___tempoAtendimento : ''; - /* - * Inicia o relatório. - */ + $query1 = ($query1 . $query . $addAgente . $sqlTempo . sprintf("\nORDER BY %s ", $mostraColunaServicos ? 's.serv_id, a.calldate' : 'a.calldate')); - /* - * Cria os filtros - */ - $linha = array('LABEL'); - foreach ($filtro as $values) { - list($label, $value) = explode(":", $values); - $linha[] = $label; + $result = $this->___GetQuery($query1); + $row = pg_fetch_all($result); + $this->SetData($row ? $row : array()); + + $result2 = $this->___GetQuery($query2 . $query . " ORDER BY 2 "); + $row2 = pg_fetch_all($result2); + $this->SetData($row2 ? $row2 : array()); + } + + protected function ___PreparaCsv() { + $dataRel = array(); + $filtro = $this->___FiltrosRelatorio(); + $dataRel[] = GenerateCsvFromArray($filtro); + $mostraColunaServicos = GetUsoServico() == RELATORIO_SERVICOS_HABILITA; + + $dadosCabecalio = array( + 'Data', 'Hora', 'Origem', 'Tempo', 'Agente', 'Status' + ); + $dadosField = array( + 'data', 'hora', 'origem', 'tmo', 'agente', 'status' + ); + + if ($mostraColunaServicos) { + $dadosCabecalio = array_merge(['Servico'], $dadosCabecalio); + $dadosField = array_merge(['serv_id'], $dadosField); + } + + $dataRel[] = GenerateCsvFromArray($dadosCabecalio); + + $somaReg = 0; + $somaDuracao = 0; + $somaAtendida = 0; + $somaNAtendida = 0; + + foreach ($this->GetData()[0] as $row) { + $somaReg ++; + $somaDuracao += $row['tmo']; + $row['status'] == 1 ? $somaAtendida++ : $somaNAtendida++; + + $row['hora'] = date('H:i:s', strtotime($row['data'])); + $row['data'] = date('d/m/Y', strtotime($row['data'])); + $row['tmo'] = SecondToStrTime($row['tmo']); + $row['status'] = $row['status'] == 1 ? "Atendida" : "Não Atendida"; + + $linha = array(); + foreach ($dadosField as $key) { + $linha[] = $row["$key"]; } - $dataRel[] = $linha; + $dataRel[] = GenerateCsvFromArray($linha); + } + $dataRel[] = GenerateCsvFromArray(array('DURAÇÃO', SecondToStrTime($somaDuracao), '')); + + $dataRel[] = GenerateCsvFromArray(array('')); + $dataRel[] = GenerateCsvFromArray(array('Atendida', 'Nao Atendida', 'Geral')); + $dataRel[] = GenerateCsvFromArray(array($somaAtendida, $somaNAtendida, $somaReg)); + + $this->___dataRel[] = $dataRel; + } + + protected function ___PreparaExcel() { + $dataRel = array(); + $filtro = $this->___FiltrosRelatorio(); + $mostraColunaServicos = GetUsoServico() == RELATORIO_SERVICOS_HABILITA; + /* + * 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', 'Tempo', 'Agente', 'Status' + ); + + $dadosField = array( + 'data', 'hora', 'origem', 'tmo', 'agente', 'status' + ); + + if ($mostraColunaServicos) { + $dadosCabecalio = array_merge(['Servico'], $dadosCabecalio); + $dadosField = array_merge(['serv_id'], $dadosField); + } + + $linha = array('LABEL'); + foreach ($dadosCabecalio as $value) { + $linha[] = $value; + } + $dataRel[] = $linha; + + $somaReg = 0; + $somaDuracao = 0; + $somaAtendida = 0; + $somaNAtendida = 0; + + /* + * Linhas de dados. + */ + foreach ($this->GetData()[0] as $row) { + $somaReg ++; + $somaDuracao += $row['tmo']; + $row['status'] == 1 ? $somaAtendida++ : $somaNAtendida++; + + $row['hora'] = date('H:i:s', strtotime($row['data'])); + $row['data'] = date('d/m/Y', strtotime($row['data'])); + $row['tmo'] = SecondToStrTime($row['tmo']); + $row['status'] = $row['status'] == 1 ? "Atendida" : "Não Atendida"; $linha = array('DADOS'); - foreach ($filtro as $values) { - list($label, $value) = explode(":", $values); - $linha[] = $value; + foreach ($dadosField as $key) { + $linha[] = $row["$key"]; } $dataRel[] = $linha; + } + $dataRel[] = array('LABEL', 'DURAÇÃO', SecondToStrTime($somaDuracao), ''); + $dataRel[] = array('DADOS', ''); + $dataRel[] = array('LABEL', 'Atendida', 'Nao Atendida', 'Geral'); + $dataRel[] = array('DADOS', $somaAtendida, $somaNAtendida, $somaReg); - $dadosCabecalio = array( - 'Data', 'Hora', 'Origem', 'TMA', 'Agente', 'Status' - ); - $dadosField = array( - 'data', 'hora', 'origem', 'tmo', 'agente', 'status' - ); - $linha = array('LABEL'); - foreach ($dadosCabecalio as $value) { - $linha[] = $value; - } - $dataRel[] = $linha; + $this->___dataRel[] = $dataRel; + } - $somaReg = 0; - $somaDuracao = 0; - $somaAtendida = 0; - $somaNAtendida = 0; + protected function ___PreparaGrid() { + + $dataRel = array(); + $mostraColunaServicos = GetUsoServico() == RELATORIO_SERVICOS_HABILITA; + + $dadosCabecalio = array( + 'Data' => 'align="center"', + 'Hora' => 'align="center"', + 'Origem' => 'align="center"', + 'DURAÇÃO' => 'align="center"', + 'Agente' => 'align="center"', + 'Status' => 'align="center"' + ); + + + $dadosField = array( + 'data' => 'align="center"', + 'hora' => 'align="center"', + 'origem' => 'align="center"', + 'tmo' => 'align="center"', + 'agente' => 'align="center"', + 'status' => 'align="center"' + ); + + if ($mostraColunaServicos) { + $dadosCabecalio = array_merge(['Serviço' => 'align="center"'], $dadosCabecalio); + $dadosField = array_merge(['serv_id' => 'align="left"'], $dadosField); + } - /* - * Linhas de dados. - */ - foreach ($this->GetData()[0] as $row) { - $somaReg ++; - $somaDuracao += $row['tmo']; - $row['status'] == 1 ? $somaAtendida++ : $somaNAtendida++; - - $row['hora'] = date('H:i:s', strtotime($row['data'])); - $row['data'] = date('d/m/Y', strtotime($row['data'])); - $row['tmo'] = SecondToStrTime($row['tmo']); - $row['status'] = $row['status'] == 1 ? "Atendida" : "Não Atendida"; - - $linha = array('DADOS'); - foreach ($dadosField as $key) { - $linha[] = $row["$key"]; - } - $dataRel[] = $linha; - } - $dataRel[] = array('LABEL', 'TMO', SecondToStrTime($somaDuracao) , ''); - - $dataRel[] = array('DADOS', ''); - $dataRel[] = array('LABEL', 'Atendida', 'Nao Atendida', 'Geral'); - $dataRel[] = array('DADOS', $somaAtendida, $somaNAtendida, $somaReg); - + /* + * Inicia o relatório. + */ + $dataRel[] = ''; + + /* + * Monta a linha de cabecalio. + */ + + $linha = ''; + $linha .= sprintf("", ($mostraColunaServicos ? '7' : '6')); + $linha .= ""; + $dataRel[] = $linha; + + /* + * Verifica se retornou dados + */ + if (!IsPostBack() || !count($this->GetData()[0])) { + $dataRel[] = sprintf("
Chamadas Recebidas por Agente
%s
", count(1) - 1, (!IsPostBack() ? 'Informe os parametros e clique em consultar!' : 'Nenhum registro encontado!')); $this->___dataRel[] = $dataRel; + return; } - protected function ___PreparaGrid() { - $dataRel = array(); - - $dadosCabecalio = array( - 'Data' => 'align="center"', - 'Hora' => 'align="center"', - 'Origem' => 'align="center"', - 'TMA' => 'align="center"', - 'Agente' => 'align="center"', - 'Status' => 'align="center"' - ); - $dadosField = array( - 'data' => 'align="center"', - 'hora' => 'align="center"', - 'origem' => 'align="center"', - 'tmo' => 'align="center"', - 'agente' => 'align="center"', - 'status' => 'align="center"' - ); + $linhaC = ""; + foreach ($dadosCabecalio as $key => $value) { + $linhaC .= sprintf("%s", $value, $key); + } + $linhaC .= ""; + $dataRel[] = $linhaC; + + $somaReg = 0; + $somaDuracao = 0; + $somaAtendida = 0; + $somaAtendidaServico = 0; + $somaNAtendida = 0; + $somaNAtendidaServico = 0; + $somaDuracaoServico = 0; + $srv = ""; + $oldSrv = ""; + $tmo = 0; + + $agrupaServico = function($row) use(&$somaDuracaoServico, &$somaAtendidaServico, &$somaNAtendidaServico, &$dataRel, &$srv, &$oldSrv) { + + $style = 'style="font-weight: bold; padding: 0; margin: 0; padding-left: 6px; padding-right: 6px; background-color: #4F71C0 !important"'; + $srv = $row["serv_id"]; + if (!$oldSrv) { + $oldSrv = $srv; + } + if ((($srv != $oldSrv)) || !$row) { - /* - * Inicia o relatório. - */ - $dataRel[] = ''; + $dataRel[] = sprintf("", $oldSrv, SecondToStrTime($somaDuracaoServico), $somaAtendidaServico, $somaNAtendidaServico); + $oldSrv = $srv; + $somaDuracaoServico = 0; + $somaAtendidaServico = 0; + $somaNAtendidaServico = 0; + } - /* - * Monta a linha de cabecalio. - */ + $somaDuracaoServico += $row['tmo']; + $row['status'] == 1 ? $somaAtendidaServico++ : $somaNAtendidaServico++; + }; - $linha = ''; - $linha .= ""; - $linha .= ""; - $dataRel[] = $linha; + /* + * Linhas de dados. + */ + foreach ($this->GetData()[0] as $row) { - /* - * Verifica se retornou dados - */ - if (!IsPostBack() || !count($this->GetData()[0])) { - $dataRel[] = sprintf("
Total [%s] DURAÇÃO%sATENDIDAS / NA%s / %s
Chamadas Recebidas por Agente
%s
", count(1) - 1, (!IsPostBack() ? 'Informe os parametros e clique em consultar!' : 'Nenhum registro encontado!')); - $this->___dataRel[] = $dataRel; - return; + if ($mostraColunaServicos) { + $agrupaServico($row); } - - $linhaC = ""; - foreach ($dadosCabecalio as $key => $value) { - $linhaC .= sprintf("%s", $value, $key); + $somaReg ++; + $somaDuracao += $row['tmo']; + $row['status'] == 1 ? $somaAtendida++ : $somaNAtendida++; + $row['origem'] = ocultarTelefone($row['origem']); + $row['hora'] = date('H:i:s', strtotime($row['data'])); + $row['data'] = date('d/m/Y', strtotime($row['data'])); + $row['tmo'] = SecondToStrTime($row['tmo']); + $row['status'] = $row['status'] == 1 ? "Atendida" : "Não Atendida"; + + $linha = ""; + foreach ($dadosField as $key => $value) { + $linha .= sprintf("%s", $value, $row["$key"]); } - $linhaC .= ""; - $dataRel[] = $linhaC; - $somaReg = 0; - $somaDuracao = 0; - $somaAtendida = 0; - $somaNAtendida = 0; - /* - * Linhas de dados. - */ - foreach ($this->GetData()[0] as $row) { - - $somaReg ++; - $somaDuracao += $row['tmo']; - $row['status'] == 1 ? $somaAtendida++ : $somaNAtendida++; - $row['origem'] = ocultarTelefone($row['origem']); - $row['hora'] = date('H:i:s', strtotime($row['data'])); - $row['data'] = date('d/m/Y', strtotime($row['data'])); - $row['tmo'] = SecondToStrTime($row['tmo']); - $row['status'] = $row['status'] == 1 ? "Atendida" : "Não Atendida"; - - $linha = ""; - foreach ($dadosField as $key => $value) { - $linha .= sprintf("%s", $value, $row["$key"]); - } - $linha .= ""; - $dataRel[] = $linha; - } - $linhaGeral = 'TMO: %s'; - $dataRel[] = sprintf($linhaGeral, SecondToStrTime($somaDuracao)); - /* - * Fecha relatorio. - */ - $dataRel[] = ''; - - $linha = '
'; - $linha .= ""; - $linha .= "" - . "" - . "" - . "" - . "" - . "" - . "" - . ""; - $linha .= '
Totalizador
Atendida: $somaAtendida
Não Atendida:$somaNAtendida
Geral:$somaReg
'; + $linha .= ""; $dataRel[] = $linha; - - $this->___dataRel[] = $dataRel; } + if ($mostraColunaServicos) { + $agrupaServico(false); + } + + $linhaGeral = 'TOTAL GERALDURAÇÃO%sATENDIDAS / NA%s / %s'; + $dataRel[] = sprintf($linhaGeral, ($mostraColunaServicos ? '3' : '2'), SecondToStrTime($somaDuracao), $somaAtendida, $somaNAtendida); + /* + * Fecha relatorio. + */ + $dataRel[] = ''; + + $linha = '
'; + $linha .= ""; + $linha .= "" + . "" + . "" + . "" + . "" + . "" + . "" + . ""; + $linha .= '
Totalizador
Atendida: $somaAtendida
Não Atendida:$somaNAtendida
Geral:$somaReg
'; + $dataRel[] = $linha; + + $this->___dataRel[] = $dataRel; + } + + protected function ___PreparaHtml() { + + } - protected function ___PreparaHtml() { - + protected function ___PreparaPdf() { + + list($this->___dac, $this->___dataIni, $this->___dataFim, $this->___tipoRelatorio) = $_SESSION["SSstorageFiltros"]; + $mostraColunaServicos = GetUsoServico() == RELATORIO_SERVICOS_HABILITA; + + $dadosCabecalio = array( + 'Data' => 'C', + 'Hora' => 'C', + 'Origem' => 'C', + 'Tempo' => 'C', + 'Agente' => 'C', + 'Status' => 'C' + ); + $dadosField = array( + 'data' => 'C', + 'hora' => 'C', + 'origem' => 'C', + 'tmo' => 'C', + 'agente' => 'C', + 'status' => 'C' + ); + + if ($mostraColunaServicos) { + $dadosCabecalio = array_merge(['Serviço' => 'C'], $dadosCabecalio); + $dadosField = array_merge(['serv_id' => 'C'], $dadosField); } - protected function ___PreparaPdf() { - list($this->___dac, $this->___dataIni, $this->___dataFim, $this->___tipoRelatorio) = $_SESSION["SSstorageFiltros"]; + $dados = $this->GetData()[0]; + $somaReg = 0; + $somaDuracao = 0; + $somaAtendida = 0; + $somaNAtendida = 0; + $x = 0; + + $somaAtendidaServico = 0; + $somaNAtendidaServico = 0; + $somaDuracaoServico = 0; + $srv = ""; + $oldSrv = ""; + $dadosTable = []; + + $agrupaServico = function($row) use(&$somaDuracaoServico, &$somaAtendidaServico, &$somaNAtendidaServico, &$dadosTable, &$srv, &$oldSrv) { + + $srv = $row["serv_id"]; + if (!$oldSrv) { + $oldSrv = $srv; + } + if ((($srv != $oldSrv)) || !$row) { + $data = []; + + $data['serv_id'] = ' '; + $data['data'] = 'TOTAL'; + $data['hora'] = ' '; + $data['origem'] = 'Duração'; + $data['tmo'] = SecondToStrTime($somaDuracaoServico); + $data['agente'] = 'ATENDIDAS / NA'; + $data['status'] = "$somaAtendidaServico / $somaNAtendidaServico"; + $data['cor_linha_dados'] = "225"; + + $oldSrv = $srv; + $somaDuracaoServico = 0; + $somaAtendidaServico = 0; + $somaNAtendidaServico = 0; + $dadosTable[] = $data; + } - $dadosCabecalio = array( - 'Data' => 'C', - 'Hora' => 'C', - 'Origem' => 'C', - 'TMA' => 'C', - 'Agente' => 'C', - 'Status' => 'C' - ); - $dadosField = array( - 'data' => 'C', - 'hora' => 'C', - 'origem' => 'C', - 'tmo' => 'C', - 'agente' => 'C', - 'status' => 'C' - ); - - $dados = $this->GetData()[0]; - $somaReg = 0; - $somaDuracao = 0; - $somaAtendida = 0; - $somaNAtendida = 0; - $x = 0; + $somaDuracaoServico += $row['tmo']; + $row['status'] == 1 ? $somaAtendidaServico++ : $somaNAtendidaServico++; + }; - /* - * Linhas de dados. - */ - foreach ($dados as $row) { - $somaReg ++; - $somaDuracao += $row['tmo']; - $dados[$x]['status'] == 1 ? $somaAtendida++ : $somaNAtendida++; - - $dados[$x]['hora'] = date('H:i:s', strtotime($row['data'])); - $dados[$x]['data'] = date('d/m/Y', strtotime($row['data'])); - $dados[$x]['tmo'] = SecondToStrTime($row['tmo']); - $dados[$x]['status'] = $row['status'] == 1 ? "Atendida" : "Não Atendida"; - $x++; + + /* + * Linhas de dados. + */ + foreach ($dados as $row) { + + if ($mostraColunaServicos) { + $agrupaServico($row); } - $widthHeader = array(32, 32, 32, 32, 32, 32); - $totaliza = array('TMO', SecondToStrTime($somaDuracao), '', '', '', ''); - $table = array($dadosCabecalio, $dadosField, $dados, $widthHeader, $totaliza, 0); - - $legendaCabecalio = array( - "Atendida" => 'C', - "Não Atendida" => 'C', - 'Geral' => 'C' - ); - - $legendaField = array( - 1 => 'C', - 2 => 'C', - 3 => 'C' - ); - - $legDadosField = array(array( - 1 => $somaAtendida, - 2 => $somaNAtendida, - 3 => $somaReg - ) - ); - - $legendaHeader = array(31, 31, 31); - $table2 = array($legendaCabecalio, $legendaField, $legDadosField, $legendaHeader, 0, 1); - $this->___dataRel = array($table, $table2); + $somaReg ++; + $somaDuracao += $row['tmo']; + + $row['hora'] = date('H:i:s', strtotime($row['data'])); + $row['data'] = date('d/m/Y', strtotime($row['data'])); + $row['tmo'] = SecondToStrTime($row['tmo']); + $row['status'] = $row['status'] == 1 ? "Atendida" : "Não Atendida"; + $row['status'] == 1 ? $somaAtendida++ : $somaNAtendida++; + $dadosTable[] = $row; } - protected function ___GetAgente() { + if ($mostraColunaServicos) { + $agrupaServico(false); + $widthHeader = array(26, 26, 26, 26, 26, 26, 26); + } else { + $widthHeader = array(26, 26, 26, 26, 26, 26); + } + $totaliza = $mostraColunaServicos ? array('DURAÇÃO', SecondToStrTime($somaDuracao), '', '', '', '', '') : array('DURAÇÃO', SecondToStrTime($somaDuracao), '', '', '', ''); + $table = array($dadosCabecalio, $dadosField, $dadosTable, $widthHeader, $totaliza, 0); + + $legendaCabecalio = array( + "Atendida" => 'C', + "Não Atendida" => 'C', + 'Geral' => 'C' + ); + + $legendaField = array( + 1 => 'C', + 2 => 'C', + 3 => 'C' + ); + + $legDadosField = array(array( + 1 => $somaAtendida, + 2 => $somaNAtendida, + 3 => $somaReg + ) + ); + + $legendaHeader = array(31, 31, 31); + $table2 = array($legendaCabecalio, $legendaField, $legDadosField, $legendaHeader, 0, 1); + $this->___dataRel = array($table, $table2); + } - $result = $this->GetData()[1]; + protected function ___GetAgente() { - $row = ""; - return $row; + $result = $this->GetData()[1]; + + $row = ""; + 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(); - } + public function ExecutaRelatorio() { + global $jsStartup, $jsJQuery, $smarty; + try { + /* + * Use esta função para validar dados do formulário. + */ + $this->___ValidaForm(); /* - * Inclua os scripts necessários aqui. + * Recupera os dados do banco. */ - $jsJQuery[] = "\$('#dataIni').keypress(function(){formataDataHora(this);}) "; - $jsJQuery[] = "\$('#dataFim').keypress(function(){formataDataHora(this);}) "; + $this->___ConteudoRelatorio(); - $smarty->assign('filtros', $this->___FiltrosRelatorio()); - $smarty->assign('conteudo', $conteudoRelatorio); - $smarty->assign('msg', $this->GetMsg()); - GetTemplate($smarty, 'relatoriosGrid.tpl'); + /* + * 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(); } + $legendas = '* C.I.E.I.V: CHAMADAS INTERNAS/EMERGENCIA/INTERNACIONAL/VOIP.'; + + /* + * 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('legendas', $legendas); + $smarty->assign('msg', $this->GetMsg()); + GetTemplate($smarty, 'relatoriosGrid.tpl'); } - $relRecebidasAgente = new RelRecebidasAgente($idProg, $dbcon, 1); - $relRecebidasAgente->ExecutaRelatorio(); +} + +$relRecebidasAgente = new RelRecebidasAgenteSrv($idProg, $dbcon, 1); +$relRecebidasAgente->ExecutaRelatorio(); ?> diff --git a/relatorios/callcenter/geral/rechamadas.php b/relatorios/callcenter/geral/rechamadas.php index 31e59152..3f986d09 100644 --- a/relatorios/callcenter/geral/rechamadas.php +++ b/relatorios/callcenter/geral/rechamadas.php @@ -1,334 +1,399 @@ ___dac = isset($_POST['listaDacs']) ? $_POST['listaDacs'] : 0; - $this->___origem = isset($_POST["origem"]) ? $_POST["origem"] : ''; - } + private $___origem; + private $___servico; + public function __construct($idProg, $dbcon, $incDac) { + parent::__construct($idProg, $dbcon, $incDac); + $this->___dac = isset($_POST['listaDacs']) ? $_POST['listaDacs'] : 0; + $this->___origem = isset($_POST["origem"]) ? $_POST["origem"] : ''; + $this->___servico = isset($_POST["listaServico"]) ? $_POST["listaServico"] : 0; + } - 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->___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ítico' : 'Sinté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; - } + function ___FiltrosRelatorio() { - if ($this->GetIncDac()) { - $dacs = GetDac($this->GetDbCon(), $this->___dac, "", 0, 1, 0, 0, 1); + if ($this->___media != MEDIA_PRINT_GRID) { + /* + * Recupera os filtros da sessão do usuá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ítico' : 'Sintético')); } - $lkPrint = ""; - if ($this->___dataCount) { - $prt = 'Clique aqui para imprimir!'; - $prtHtml = "\"Clique"; - $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'); + $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; + } - $tipoRel = !$this->___tipoRelatorio ? '' : 'checked="checked"'; - /* - * Personalise esta função se necessitar de outras op��es de filtro. - */ - $filtro = ''; - /* - * Rotulos. - */ - $filtro .= ''; - if ($this->GetIncDac()) - $filtro .= ''; - $filtro .= ''; - $filtro .= ''; - $filtro .= ''; - $filtro .= ''; - $filtro .= ''; + if ($this->GetIncDac()) { + $dacs = GetDac($this->GetDbCon(), $this->___dac, "", 0, 1, 0, 0, 1); + } - /* - * Valores. - */ - $filtro .= ''; - if ($this->GetIncDac()) - $filtro .= sprintf('', $dacs); - $filtro .= ''; - $filtro .= ''; - $filtro .= sprintf('', $this->___origem); - $filtro .= ''; - $filtro .= ''; - $filtro .= ''; - $filtro .= '
FilaData InicialData Final Origem 
%s%s
'; + $lkPrint = ""; + if ($this->___dataCount) { + $prt = 'Clique aqui para imprimir!'; + $prtHtml = "\"Clique"; + $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'); + } - /* - * Guarda os filtros passados para recuperar na emissão dos relatóios para impressão. - */ + $tipoRel = !$this->___tipoRelatorio ? '' : 'checked="checked"'; + /* + * Personalise esta função se necessitar de outras op��es de filtro. + */ + $filtro = ''; + /* + * Rotulos. + */ + $filtro .= ''; + if ($this->GetIncDac()) { + $filtro .= ''; + } + if (GetUsoServico()) { + $filtro .= ''; + } + $filtro .= ''; + $filtro .= ''; + $filtro .= ''; + $filtro .= ''; + $filtro .= ''; + + /* + * Valores. + */ + $filtro .= ''; + if ($this->GetIncDac()) { + $filtro .= sprintf('', $dacs); + } - $_SESSION["SSstorageFiltros"] = array($this->___dac, $this->___dataIni, $this->___dataFim, $this->___tipoRelatorio, $this->___agente); + if (GetUsoServico()) { + $filtro .= sprintf('', GetIdentRota(false, $this->___servico)); + } + $filtro .= ''; + $filtro .= ''; + $filtro .= sprintf('', $this->___origem); + $filtro .= ''; + $filtro .= ''; + $filtro .= ''; + $filtro .= '
FilaServiçoData InicialData Final Origem 
%s%s%s
'; + + /* + * Guarda os filtros passados para recuperar na emissão dos relatóios para impressão. + */ + $_SESSION["SSstorageFiltros"] = array($this->___dac, $this->___dataIni, $this->___dataFim, $this->___tipoRelatorio, $this->___agente); + + return sprintf($filtro, $this->___dataIni, $this->___dataFim, $lkPrint); + } - return sprintf($filtro, $this->___dataIni, $this->___dataFim, $lkPrint); + protected function ___GetDadosDb() { + $dataIni = FormatDtMssql($this->___dataIni); + $dataFim = FormatDtHoraBD($this->___dataFim); + $dac = $this->___dac; + $srv = $this->___servico; + $origem = soNumero($this->___origem); + $mostraColunaServicos = GetUsoServico() == RELATORIO_SERVICOS_HABILITA; + + $query = "SELECT fila, origem ,COUNT(qtde) AS qtde ,SUM (tempo_atende) AS tempo_atende ,SUM (tempo_transf) AS tempo_transf"; + if ($mostraColunaServicos) { + $query .= "\n ,serv_id"; + } + $query .= "\nFROM ( + select b.fila, case when(coalesce(a.src, '') = '')then 'NI*' else a.src end as origem, a.uniqueid as qtde, + (case when(b.evento in('COMPLETEAGENT','COMPLETECALLER', 'COMPLETAAGENT','COMPLETACALLER'))then strtoint(param2) else 0 end) as tempo_atende, + (case when(exists(select * from pbx_bilhetes where data_bilhete = a.data_bilhete and accountcode = a.uniqueid ))then a.billsec else 0 end) as tempo_transf"; + if ($mostraColunaServicos) { + $query .= "\n ,coalesce(serv_id, 'SERV. NÃO ASSOCIADO') as serv_id"; } + $query .= "\n from pbx_bilhetes a + inner join pbx_eventos_dacs b on b.uid2 = a.uniqueid "; + if (GetUsoServico()) { + $query .= "\nleft join pbx_servicos_registra c on c.uniqueid = a.uniqueid"; + } + $query .= "\nwhere a.id_bilhetes = (select max (l.id_bilhetes) from pbx_bilhetes l where l.uniqueid = a.uniqueid and l.lastapp <> 'Transferred Call' ) + and b.evento in('COMPLETEAGENT','COMPLETECALLER', 'COMPLETAAGENT','COMPLETACALLER', 'TRANSFER', 'TRANSFERORIG')\n"; - protected function ___GetDadosDb() { - $dataIni = FormatDtMssql($this->___dataIni); - $dataFim = FormatDtHoraBD($this->___dataFim); - $dac = $this->___dac; - $origem = soNumero($this->___origem); - - $query = "SELECT FILA, ORIGEM ,COUNT(QTDE) AS QTDE ,SUM (TEMPO_ATENDE) AS TEMPO_ATENDE ,SUM (TEMPO_TRANSF) AS TEMPO_TRANSF - FROM (select b.fila, case when(coalesce(a.src, '') = '')then 'NI*' else a.src end as origem, a.uniqueid as qtde, - (case when(b.evento in('COMPLETEAGENT','COMPLETECALLER', 'COMPLETAAGENT','COMPLETACALLER'))then strtoint(param2) else 0 end) as tempo_atende, - (case when(exists(select * from pbx_bilhetes where data_bilhete = a.data_bilhete and accountcode = a.uniqueid ))then a.billsec else 0 end) as tempo_transf - from pbx_bilhetes a, pbx_eventos_dacs b - where b.uid2 = a.uniqueid - and a.id_bilhetes = (select max (l.id_bilhetes) from pbx_bilhetes l where l.uniqueid = a.uniqueid and l.lastapp <> 'Transferred Call' ) - and b.evento in('COMPLETEAGENT','COMPLETECALLER', 'COMPLETAAGENT','COMPLETACALLER', 'TRANSFER', 'TRANSFERORIG') - and a.lastapp <> 'Transferred Call' + if (GetUsoServico() && $srv) { + $query .= "\nand c.serv_id = '{$srv}'"; + } + $query .= "\nand a.lastapp <> 'Transferred Call' and a.data_bilhete >= '$dataIni' and a.data_bilhete <= '$dataFim' - and b.fila = (select nome from pbx_dacs where id = '$dac')"; - if ($origem) { - $query .= " and a.src like '%$origem%' \n"; - } + and b.fila = (select nome from pbx_dacs where id = '$dac')\n"; + if ($origem) { + $query .= "\nand a.src like '%$origem%' \n"; + } - $query .= " ) AS RECHAMADAS GROUP BY FILA, ORIGEM having count(*) > 1 ORDER BY 3 desc"; - - $result = $this->___GetQuery($query); - $row = pg_fetch_all($result); - $this->SetData($row ? $row : array()); + if ($mostraColunaServicos) { + $query .= " ) AS RECHAMADAS GROUP BY fila, serv_id, origem having count(*) > 1 ORDER BY serv_id, qtde desc"; + } else { + $query .= " ) AS RECHAMADAS GROUP BY fila, origem having count(*) > 1 ORDER BY qtde desc"; } - protected function ___PreparaCsv() { - $dataRel = array(); - $filtro = $this->___FiltrosRelatorio(); - $dataRel[] = GenerateCsvFromArray($filtro); - - $dadosCabecalio = array('Origem', 'Quantidade', 'TMA', 'Tempo'); - $dadosField = array('origem', 'qtde', 'tma', 'tempo_atende'); - - $dataRel[] = GenerateCsvFromArray($dadosCabecalio); - - foreach ($this->GetData()[0] as $row) { - $row['tma'] = SecondToStrTime(round($row['tempo_atende']/$row['qtde'])); - $row['tempo_atende'] = SecondToStrTime($row['tempo_atende']); - - $linha = array(); - foreach ($dadosField as $key) { - $linha[] = $row["$key"]; - } - $dataRel[] = GenerateCsvFromArray($linha); - } - - $this->___dataRel[] = $dataRel; + + $result = $this->___GetQuery($query); + $row = pg_fetch_all($result); + $this->SetData($row ? $row : array()); + } + + protected function ___PreparaCsv() { + + $dataRel = array(); + $filtro = $this->___FiltrosRelatorio(); + $dataRel[] = GenerateCsvFromArray($filtro); + $mostraColunaServicos = GetUsoServico() == RELATORIO_SERVICOS_HABILITA; + + $dadosCabecalio = array('Origem', 'Quantidade', 'TMA', 'Tempo'); + $dadosField = array('origem', 'qtde', 'tma', 'tempo_atende'); + + + if ($mostraColunaServicos) { + $dadosCabecalio = array_merge(['Servico'], $dadosCabecalio); + $dadosField = array_merge(['serv_id'], $dadosField); } - protected function ___PreparaExcel() { - $dataRel = array(); - $filtro = $this->___FiltrosRelatorio(); + $dataRel[] = GenerateCsvFromArray($dadosCabecalio); - /* - * Inicia o relatório. - */ + foreach ($this->GetData()[0] as $row) { + $row['tma'] = SecondToStrTime(round($row['tempo_atende'] / $row['qtde'])); + $row['tempo_atende'] = SecondToStrTime($row['tempo_atende']); - /* - * Cria os filtros - */ - $linha = array('LABEL'); - foreach ($filtro as $values) { - list($label, $value) = explode(":", $values); - $linha[] = $label; + $linha = array(); + foreach ($dadosField as $key) { + $linha[] = $row["$key"]; } - $dataRel[] = $linha; + $dataRel[] = GenerateCsvFromArray($linha); + } - $linha = array('DADOS'); - foreach ($filtro as $values) { - list($label, $value) = explode(":", $values); - $linha[] = $value; - } - $dataRel[] = $linha; + $this->___dataRel[] = $dataRel; + } - $dadosCabecalio = array('Origem', 'Quantidade', 'TMA', 'Tempo'); - $dadosField = array('origem', 'qtde', 'tma', 'tempo_atende'); - - $linha = array('LABEL'); - foreach ($dadosCabecalio as $value) { - $linha[] = $value; - } - $dataRel[] = $linha; - - foreach ($this->GetData()[0] as $row) { - $row['tma'] = SecondToStrTime(round($row['tempo_atende']/$row['qtde'])); - $row['tempo_atende'] = SecondToStrTime($row['tempo_atende']); - - $linha = array('DADOS'); - foreach ($dadosField as $key) { - $linha[] = $row["$key"]; - } - $dataRel[] = $linha; - } - - $this->___dataRel[] = $dataRel; + protected function ___PreparaExcel() { + $dataRel = array(); + $filtro = $this->___FiltrosRelatorio(); + $mostraColunaServicos = GetUsoServico() == RELATORIO_SERVICOS_HABILITA; + /* + * Inicia o relatório. + */ + + /* + * Cria os filtros + */ + $linha = array('LABEL'); + foreach ($filtro as $values) { + list($label, $value) = explode(":", $values); + $linha[] = $label; } + $dataRel[] = $linha; - protected function ___PreparaGrid() { - $dataRel = array(); - - $dadosCabecalio = array( - 'Origem' => 'align="center"', - 'Quantidade' => 'align="center"', - 'TMA' => 'align="center"', - 'Tempo' => 'align="center"' - ); - $dadosField = array( - 'origem' => 'align="center"', - 'qtde' => 'align="center"', - 'tma' => 'align="center"', - 'tempo_atende' => 'align="center"' - ); + $linha = array('DADOS'); + foreach ($filtro as $values) { + list($label, $value) = explode(":", $values); + $linha[] = $value; + } + $dataRel[] = $linha; - /* - * Inicia o relatório. - */ - $dataRel[] = ''; + $dadosCabecalio = array('Origem', 'Quantidade', 'TMA', 'Tempo'); + $dadosField = array('origem', 'qtde', 'tma', 'tempo_atende'); - /* - * Monta a linha de cabecalio. - */ + if ($mostraColunaServicos) { + $dadosCabecalio = array_merge(['Servico'], $dadosCabecalio); + $dadosField = array_merge(['serv_id'], $dadosField); + } - $linha = ''; - $linha .= ""; - $linha .= ""; - $dataRel[] = $linha; + $linha = array('LABEL'); + foreach ($dadosCabecalio as $value) { + $linha[] = $value; + } + $dataRel[] = $linha; - /* - * Verifica se retornou dados - */ - if (!IsPostBack() || !count($this->GetData()[0])) { - $dataRel[] = sprintf("
Rechamadas
%s
", count(1) - 1, (!IsPostBack() ? 'Informe os parametros e clique em consultar!' : 'Nenhum registro encontado!')); - $this->___dataRel[] = $dataRel; - return; - } + foreach ($this->GetData()[0] as $row) { + $row['tma'] = SecondToStrTime(round($row['tempo_atende'] / $row['qtde'])); + $row['tempo_atende'] = SecondToStrTime($row['tempo_atende']); - $linhaC = ""; - foreach ($dadosCabecalio as $key => $value) { - $linhaC .= sprintf("%s", $value, $key); + $linha = array('DADOS'); + foreach ($dadosField as $key) { + $linha[] = $row["$key"]; } - $linhaC .= ""; - $dataRel[] = $linhaC; + $dataRel[] = $linha; + } - /* - * Linhas de dados. - */ - foreach ($this->GetData()[0] as $row) { - $row['origem'] = ocultarTelefone($row['origem']); - $row['tma'] = SecondToStrTime(round($row['tempo_atende']/$row['qtde'])); - $row['tempo_atende'] = SecondToStrTime($row['tempo_atende']); - - $linha = ""; - foreach ($dadosField as $key => $value) { - $linha .= sprintf("%s", $value, $row["$key"]); - } - $linha .= ""; - $dataRel[] = $linha; - } + $this->___dataRel[] = $dataRel; + } + + protected function ___PreparaGrid() { + $dataRel = array(); + $mostraColunaServicos = GetUsoServico() == RELATORIO_SERVICOS_HABILITA; + $dadosCabecalio = array( + 'Origem' => 'align="center"', + 'Quantidade' => 'align="center"', + 'TMA' => 'align="center"', + 'Tempo' => 'align="center"' + ); + + + $dadosField = array( + 'origem' => 'align="center"', + 'qtde' => 'align="center"', + 'tma' => 'align="center"', + 'tempo_atende' => 'align="center"' + ); + + if ($mostraColunaServicos) { + $dadosCabecalio = array_merge(['Serviço' => 'align="center"'], $dadosCabecalio); + $dadosField = array_merge(['serv_id' => 'align="left"'], $dadosField); + } + + /* + * Inicia o relatório. + */ + $dataRel[] = ''; + + /* + * Monta a linha de cabecalio. + */ + + $linha = ''; + $linha .= ""; + $linha .= ""; + $dataRel[] = $linha; + + /* + * Verifica se retornou dados + */ + if (!IsPostBack() || !count($this->GetData()[0])) { + $dataRel[] = sprintf("
Rechamadas
%s
", count(1) - 1, (!IsPostBack() ? 'Informe os parametros e clique em consultar!' : 'Nenhum registro encontado!')); $this->___dataRel[] = $dataRel; + return; } - protected function ___PreparaHtml() { - + $linhaC = ""; + foreach ($dadosCabecalio as $key => $value) { + $linhaC .= sprintf("%s", $value, $key); + } + $linhaC .= ""; + $dataRel[] = $linhaC; + + $somaRechamada = 0; + + /* + * Linhas de dados. + */ + foreach ($this->GetData()[0] as $row) { + $row['origem'] = ocultarTelefone($row['origem']); + $row['tma'] = SecondToStrTime(round($row['tempo_atende'] / $row['qtde'])); + $row['tempo_atende'] = SecondToStrTime($row['tempo_atende']); + + $linha = ""; + foreach ($dadosField as $key => $value) { + $linha .= sprintf("%s", $value, $row["$key"]); + } + $linha .= ""; + $dataRel[] = $linha; } - protected function ___PreparaPdf() { - list($this->___dac, $this->___dataIni, $this->___dataFim, $this->___tipoRelatorio) = $_SESSION["SSstorageFiltros"]; + $this->___dataRel[] = $dataRel; + } - $dadosCabecalio = array( - 'Origem' => 'C', - 'Quantidade' => 'C', - 'TMA' => 'C', - 'Tempo' => 'C' - ); - $dadosField = array( - 'origem' => 'C', - 'qtde' => 'C', - 'tma' => 'C', - 'tempo_atende' => 'C' - ); - - $x = 0; - $dados = $this->GetData()[0]; - /* - * Linhas de dados. - */ - foreach ($dados as $row) { - $dados[$x]['tma'] = SecondToStrTime(round($row['tempo_atende']/$row['qtde'])); - $dados[$x]['tempo_atende'] = SecondToStrTime($row['tempo_atende']); - $x++; - } - $widthHeader = array(45, 45, 45, 45); - $table = array($dadosCabecalio, $dadosField, $dados, $widthHeader, 0, 0); - $this->___dataRel = array($table); + protected function ___PreparaHtml() { + + } + + protected function ___PreparaPdf() { + + list($this->___dac, $this->___dataIni, $this->___dataFim, $this->___tipoRelatorio) = $_SESSION["SSstorageFiltros"]; + $mostraColunaServicos = GetUsoServico() == RELATORIO_SERVICOS_HABILITA; + + $dadosCabecalio = array( + 'Origem' => 'C', + 'Quantidade' => 'C', + 'TMA' => 'C', + 'Tempo' => 'C' + ); + $dadosField = array( + 'origem' => 'C', + 'qtde' => 'C', + 'tma' => 'C', + 'tempo_atende' => 'C' + ); + + if ($mostraColunaServicos) { + $dadosCabecalio = array_merge(['Serviço' => 'C'], $dadosCabecalio); + $dadosField = array_merge(['serv_id' => 'C'], $dadosField); } - 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(); - } + $x = 0; + $dados = $this->GetData()[0]; + /* + * Linhas de dados. + */ + foreach ($dados as $row) { + $dados[$x]['tma'] = SecondToStrTime(round($row['tempo_atende'] / $row['qtde'])); + $dados[$x]['tempo_atende'] = SecondToStrTime($row['tempo_atende']); + $x++; + } + + if ($mostraColunaServicos) { + $widthHeader = array(40, 45, 25, 35, 35); + } else { + $widthHeader = array(45, 45, 45, 45); + } + $table = array($dadosCabecalio, $dadosField, $dados, $widthHeader, 0, 0); + $this->___dataRel = array($table); + } + public function ExecutaRelatorio() { + global $jsStartup, $jsJQuery, $smarty; + try { /* - * Inclua os scripts necessários aqui. + * Use esta função para validar dados do formulário. */ - $jsJQuery[] = "\$('#dataIni').keypress(function(){formataDataHora(this);}) "; - $jsJQuery[] = "\$('#dataFim').keypress(function(){formataDataHora(this);}) "; + $this->___ValidaForm(); - $smarty->assign('filtros', $this->___FiltrosRelatorio()); - $smarty->assign('conteudo', $conteudoRelatorio); - $smarty->assign('msg', $this->GetMsg()); - GetTemplate($smarty, 'relatoriosGrid.tpl'); + /* + * 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'); } - - $relRechamadas = new RelRechamadas($idProg, $dbcon, 1); - $relRechamadas->ExecutaRelatorio(); + +} + +$relRechamadas = new RelRechamadas($idProg, $dbcon, 1); +$relRechamadas->ExecutaRelatorio(); ?> diff --git a/relatorios/callcenter/geral/relClassificacao.php b/relatorios/callcenter/geral/relClassificacao.php index 374a5f15..2db75ace 100644 --- a/relatorios/callcenter/geral/relClassificacao.php +++ b/relatorios/callcenter/geral/relClassificacao.php @@ -1,408 +1,525 @@ ___dac = isset($_POST['listaDacs']) ? $_POST['listaDacs'] : 0; - } + private $___servico; + + public function __construct($idProg, $dbcon, $incDac) { + parent::__construct($idProg, $dbcon, $incDac); + $this->___dac = isset($_POST['listaDacs']) ? $_POST['listaDacs'] : 0; + $this->___servico = isset($_POST["listaServico"]) ? $_POST["listaServico"] : 0; + } + + 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->___tipoRelatorio) = $_SESSION["SSstorageFiltros"]; - 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->___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ítico' : 'Sinté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->___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ítico' : 'Sintético')); } + $fltCsv = array(); if ($this->GetIncDac()) { - $dacs = GetDac($this->GetDbCon(), $this->___dac, "", 0, 1, 0, 0, 1); + $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; + } - $lkPrint = ""; - if ($this->___dataCount) { - $prt = 'Clique aqui para imprimir!'; - $prtHtml = "\"Clique"; - $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'); - } + if ($this->GetIncDac()) { + $dacs = GetDac($this->GetDbCon(), $this->___dac, "", 0, 1, 0, 0, 1); + } - $tipoRel = !$this->___tipoRelatorio ? '' : 'checked="checked"'; + $lkPrint = ""; + if ($this->___dataCount) { + $prt = 'Clique aqui para imprimir!'; + $prtHtml = "\"Clique"; + $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ção se necessitar de outras operações de filtro. - */ - $filtro = ''; - /* - * Rotulos. - */ - $filtro .= ''; - $this->GetIncDac() ? $filtro .= '' : ''; - $filtro .= ''; - $filtro .= ''; - $filtro .= ''; - $filtro .= ''; - /* - * Valores. - */ - $filtro .= ''; - $this->GetIncDac() ? $filtro .= sprintf('', $dacs) : ''; - $filtro .= ''; - $filtro .= ''; - $filtro .= ''; - $filtro .= ''; - $filtro .= ''; - $filtro .= '
FilaData InicialData Final  
%s%s
'; + /* + * Personalise esta função se necessitar de outras operações de filtro. + */ + $filtro = ''; + /* + * Rotulos. + */ + $filtro .= ''; + $this->GetIncDac() ? $filtro .= '' : ''; - /* - * Guarda os filtros passados para recuperar na emissão dos relatórios para impressão. - */ - $_SESSION["SSstorageFiltros"] = array($this->___dac, $this->___dataIni, $this->___dataFim, $this->___tipoRelatorio); - return sprintf($filtro, $this->___dataIni, $this->___dataFim, $lkPrint); + if (GetUsoServico()) { + $filtro .= ''; + } + $filtro .= ''; + $filtro .= ''; + $filtro .= ''; + $filtro .= ''; + + /* + * Valores. + */ + $filtro .= ''; + $this->GetIncDac() ? $filtro .= sprintf('', $dacs) : ''; + if (GetUsoServico()) { + $filtro .= sprintf('', GetIdentRota(false, $this->___servico)); } + $filtro .= ''; + $filtro .= ''; + $filtro .= ''; + $filtro .= ''; + $filtro .= ''; + $filtro .= '
FilaServiço Data InicialData Final  
%s%s%s
'; + + /* + * Guarda os filtros passados para recuperar na emissão dos relatórios para impressã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 clas_descricao, clit_descricao, count(*) as qtde, count(distinct e.uid2) as chmd - FROM pbx_classifica_reg a - INNER JOIN pbx_classifica_atendimento b ON b.clas_id = a.clas_id - INNER JOIN pbx_classifica_item c ON c.clit_id = a.clit_id - INNER JOIN pbx_bilhetes d ON d.uniqueid = a.id_bilhetes - INNER JOIN pbx_eventos_dacs e ON e.uid2 = d.uniqueid - INNER JOIN pbx_usuarios f ON f.matricula = substring(e.agente, 7, 4) - WHERE d.data_bilhete >= '%s' AND d.data_bilhete <= '%s' - AND d.lastapp <> 'Transferred Call' - AND e.evento in('COMPLETEAGENT','COMPLETECALLER', 'TRANSFER','COMPLETEAGENTRAMAL','COMPLETECALLERRAMAL','BUSY','NOANSWER', 'COMPLETAAGENT','COMPLETACALLER', 'TRANSFERORIG','BUSYS','NOANSWERS') - AND a.id_dac = %s - GROUP BY clas_descricao, clit_descricao", $dataIni, $dataFim, $dac); - - $subQuery = sprintf("SELECT count(1) as chmd - FROM pbx_bilhetes d - INNER JOIN pbx_eventos_dacs e ON e.uid2 = d.uniqueid - INNER JOIN pbx_usuarios f ON f.matricula = substring(e.agente, 7, 4) - INNER JOIN pbx_dacs a ON a.nome = e.fila - WHERE d.data_bilhete >= '%s' AND d.data_bilhete <= '%s' - AND e.evento IN('COMPLETEAGENT','COMPLETECALLER', 'TRANSFER','COMPLETEAGENTRAMAL','COMPLETECALLERRAMAL','BUSY','NOANSWER', 'COMPLETAAGENT','COMPLETACALLER', 'TRANSFERORIG','BUSYS','NOANSWERS') - AND a.id = %s - AND d.lastapp <> 'Transferred Call'", $dataIni, $dataFim, $dac); - - $result = $this->___GetQuery($query); - $row = pg_fetch_all($result); - $this->SetData($row ? $row : array()); - - $subResult = $this->___GetQuery($subQuery); - $subRow = pg_fetch_assoc($subResult ? $subResult : array()); - $this->SetData($subRow); + protected function ___GetDadosDb() { + $dataIni = FormatDtMssql($this->___dataIni); + $dataFim = FormatDtMssql($this->___dataFim); + $dac = $this->___dac; + $srv = $this->___servico; + $mostraColunaServicos = GetUsoServico() == RELATORIO_SERVICOS_HABILITA; + + $queryCabecalio = "SELECT" . ($mostraColunaServicos ? " coalesce(s.serv_id, 'Não Informado') as serv_id," : "") . " clas_descricao, clit_descricao, count(*) as qtde, count(distinct e.uid2) as chmd"; + $query = "\nFROM pbx_classifica_reg a + INNER JOIN pbx_classifica_atendimento b ON b.clas_id = a.clas_id + INNER JOIN pbx_classifica_item c ON c.clit_id = a.clit_id + INNER JOIN pbx_bilhetes d ON d.uniqueid = a.id_bilhetes + INNER JOIN pbx_eventos_dacs e ON e.uid2 = d.uniqueid + INNER JOIN pbx_usuarios f ON f.matricula = substring(e.agente, 7, 4)"; + if (GetUsoServico()) { + $query .= "\nleft join pbx_servicos_registra s on s.uniqueid = d.uniqueid"; } - protected function ___PreparaCsv() { - $dataRel = array(); - $filtro = $this->___FiltrosRelatorio(); + $query .= "\nWHERE d.data_bilhete >= '%s' AND d.data_bilhete <= '%s' + AND d.lastapp <> 'Transferred Call' + AND e.evento in('COMPLETEAGENT','COMPLETECALLER', 'TRANSFER','COMPLETEAGENTRAMAL','COMPLETECALLERRAMAL','BUSY','NOANSWER', 'COMPLETAAGENT','COMPLETACALLER', 'TRANSFERORIG','BUSYS','NOANSWERS') + AND a.id_dac = %s"; - /* - * Inicia o relatório. - */ - $dataRel[] = GenerateCsvFromArray($filtro); + if (GetUsoServico() && $srv) { + $query .= "\nand s.serv_id = '{$srv}'"; + } - $dadosCabecalio = array('Classificacao', 'Servico', 'Porcentagem %', 'Quantidade'); - $dadosField = array('clas_descricao', 'clit_descricao', 'chmd', 'qtde'); - /* - * Monta a linha de cabecalio. - */ - $dataRel[] = GenerateCsvFromArray($dadosCabecalio); + $queryGroup .= $mostraColunaServicos ? "\nGROUP BY clas_descricao, clit_descricao, s.serv_id" : "\nGROUP BY clas_descricao, clit_descricao\n"; + $queryOrder .= $mostraColunaServicos ? "\norder by s.serv_id, clas_descricao, clit_descricao" : "\norder by clas_descricao, clit_descricao\n"; - $somaChmTotal = 0; + $query = sprintf($query, $dataIni, $dataFim, $dac); + $queryDados = ($queryCabecalio . $query . $queryGroup . $queryOrder); - foreach ($this->GetData()[0] as $row) { - $somaChmTotal += $row['chmd']; - } + $queryCabecalio = "\nSELECT count(distinct d.uniqueid) as chmd "; - $somaReg = 0; - - /* - * Linhas de dados. - */ - foreach ($this->GetData()[0] as $row) { - $somaReg += $row['qtde']; + $result = $this->___GetQuery($queryDados); + $row = pg_fetch_all($result); + $this->SetData($row ? $row : array()); - $row['clit_descricao'] = RemoveAcentos($row['clit_descricao']); - $row['chmd'] = round(!$somaChmTotal ? 0 : ($row['qtde'] * 100) / $somaChmTotal) . '%'; + $subResult = $this->___GetQuery($queryCabecalio . $query); + $subRow = pg_fetch_assoc($subResult ? $subResult : array()); + $this->SetData($subRow); + } - // Formata linha de dados. - $linha = array(); - foreach ($dadosField as $value) { - $linha[] = $row["$value"]; - } + protected function ___PreparaCsv() { + $dataRel = array(); + $filtro = $this->___FiltrosRelatorio(); + $mostraColunaServicos = GetUsoServico() == RELATORIO_SERVICOS_HABILITA; - $dataRel[] = GenerateCsvFromArray($linha); - } - $dataRel[] = GenerateCsvFromArray(array('Total Chamadas: ' . $this->GetData()[1]['chmd'], '', '', 'Registros: ' . $somaReg)); + /* + * Inicia o relatório. + */ + $dataRel[] = GenerateCsvFromArray($filtro); - $this->___dataRel[] = $dataRel; + $dadosCabecalio = array('Classificacao', 'Item', 'Porcentagem %', 'Quantidade'); + $dadosField = array('clas_descricao', 'clit_descricao', 'chmd', 'qtde'); + + if ($mostraColunaServicos) { + $dadosCabecalio = array_merge(['Servico'], $dadosCabecalio); + $dadosField = array_merge(['serv_id'], $dadosField); } - protected function ___PreparaExcel() { - $dataRel = array(); - $filtro = $this->___FiltrosRelatorio(); + /* + * Monta a linha de cabecalio. + */ + $dataRel[] = GenerateCsvFromArray($dadosCabecalio); - /* - * Inicia o relatório. - */ + $somaChmTotal = 0; - /* - * Cria os filtros - */ - $linha = array('LABEL'); - foreach ($filtro as $values) { - list($label, $value) = explode(":", $values); - $linha[] = $label; - } - $dataRel[] = $linha; + foreach ($this->GetData()[0] as $row) { + $somaChmTotal += $row['chmd']; + } - $linha = array('DADOS'); - foreach ($filtro as $values) { - list($label, $value) = explode(":", $values); - $linha[] = $value; - } + $somaReg = 0; - $dataRel[] = $linha; + /* + * Linhas de dados. + */ + foreach ($this->GetData()[0] as $row) { + $somaReg += $row['qtde']; - $dadosCabecalio = array('Classificacao', 'Servico', 'Porcentagem %', 'Quantidade'); - $dadosField = array('clas_descricao', 'clit_descricao', 'chmd', 'qtde'); + $row['clit_descricao'] = RemoveAcentos($row['clit_descricao']); + $row['chmd'] = round(!$somaChmTotal ? 0 : ($row['qtde'] * 100) / $somaChmTotal) . '%'; - /* - * Monta a linha de cabecalio. - */ - $linha = array('LABEL'); - foreach ($dadosCabecalio as $value) { - $linha[] = $value; + // Formata linha de dados. + $linha = array(); + foreach ($dadosField as $value) { + $linha[] = $row["$value"]; } - $dataRel[] = $linha; - $somaChmTotal = 0; + $dataRel[] = GenerateCsvFromArray($linha); + } + $dataRel[] = GenerateCsvFromArray(array('Total Chamadas: ' . $this->GetData()[1]['chmd'], '', '', 'Registros: ' . $somaReg)); - foreach ($this->GetData()[0] as $row) { - $somaChmTotal += $row['chmd']; - } + $this->___dataRel[] = $dataRel; + } - $somaReg = 0; + protected function ___PreparaExcel() { + $dataRel = array(); + $filtro = $this->___FiltrosRelatorio(); + $mostraColunaServicos = GetUsoServico() == RELATORIO_SERVICOS_HABILITA; + /* + * Inicia o relatório. + */ + + /* + * Cria os filtros + */ + $linha = array('LABEL'); + foreach ($filtro as $values) { + list($label, $value) = explode(":", $values); + $linha[] = $label; + } + $dataRel[] = $linha; - /* - * Linhas de dados. - */ - foreach ($this->GetData()[0] as $row) { - $somaReg += $row['qtde']; + $linha = array('DADOS'); + foreach ($filtro as $values) { + list($label, $value) = explode(":", $values); + $linha[] = $value; + } - $row['clit_descricao'] = RemoveAcentos($row['clit_descricao']); - $row['chmd'] = round(!$somaChmTotal ? 0 : ($row['qtde'] * 100) / $somaChmTotal) . '%'; + $dataRel[] = $linha; - // Formata linha de dados. - $linha = array('DADOS'); - foreach ($dadosField as $key) { - $linha[] = $row["$key"]; - } + $dadosCabecalio = array('Classificacao', 'Item', 'Porcentagem %', 'Quantidade'); + $dadosField = array('clas_descricao', 'clit_descricao', 'chmd', 'qtde'); - $dataRel[] = $linha; - } + if ($mostraColunaServicos) { + $dadosCabecalio = array_merge(['Servico'], $dadosCabecalio); + $dadosField = array_merge(['serv_id'], $dadosField); + } + + /* + * Monta a linha de cabecalio. + */ + $linha = array('LABEL'); + foreach ($dadosCabecalio as $value) { + $linha[] = $value; + } + $dataRel[] = $linha; - $dataRel[] = array('LABEL', 'Total Chamadas: ' . $this->GetData()[1]['chmd'], '', '', 'Registros: ' . $somaReg); + $somaChmTotal = 0; - $this->___dataRel[] = $dataRel; + foreach ($this->GetData()[0] as $row) { + $somaChmTotal += $row['chmd']; } - protected function ___PreparaGrid() { - $dataRel = array(); - - $dadosCabecalio = array( - 'Classificação' => 'align="left"', - 'Serviço' => 'align="left"', - 'Porcentagem %' => 'align="right"', - 'Quantidade' => 'align="right"' - ); - - $dadosField = array( - 'clas_descricao' => 'align="left"', - 'clit_descricao' => 'align="left"', - 'chmd' => 'align="right"', - 'qtde' => 'align="right"' - ); - /* - * Inicia o relatório. - */ - $dataRel[] = ''; + $somaReg = 0; - /* - * Monta a linha de cabecalio. - */ - $linha = ''; - foreach ($dadosCabecalio as $key => $value) { - $linha .= sprintf("", $value, $key); + /* + * Linhas de dados. + */ + foreach ($this->GetData()[0] as $row) { + $somaReg += $row['qtde']; + + $row['clit_descricao'] = RemoveAcentos($row['clit_descricao']); + $row['chmd'] = round(!$somaChmTotal ? 0 : ($row['qtde'] * 100) / $somaChmTotal) . '%'; + + // Formata linha de dados. + $linha = array('DADOS'); + foreach ($dadosField as $key) { + $linha[] = $row["$key"]; } - $linha .= ""; + $dataRel[] = $linha; + } - /* - * Verifica se retornou dados - */ - if (!IsPostBack() || !count($this->GetData()[0])) { - $dataRel[] = sprintf("
%s
%s
", count($dadosCabecalio) - 1, (!IsPostBack() ? 'Informe os parametros e clique em consultar!' : 'Nenhum registro encontado!')); - $this->___dataRel[] = $dataRel; - return; + $dataRel[] = array('LABEL', 'Total Chamadas: ' . $this->GetData()[1]['chmd'], '', '', 'Registros: ' . $somaReg); + + $this->___dataRel[] = $dataRel; + } + + protected function ___PreparaGrid() { + + $dataRel = array(); + $mostraColunaServicos = GetUsoServico() == RELATORIO_SERVICOS_HABILITA; + + + + $dadosCabecalio = array( + 'Classificação' => 'align="left"', + 'Item' => 'align="left"', + 'Porcentagem %' => 'align="right"', + 'Quantidade' => 'align="right"' + ); + + $dadosField = array( + 'clas_descricao' => 'align="left"', + 'clit_descricao' => 'align="left"', + 'chmd' => 'align="right"', + 'qtde' => 'align="right"' + ); + + + if ($mostraColunaServicos) { + $dadosCabecalio = array_merge(['Serviço' => 'align="center"'], $dadosCabecalio); + $dadosField = array_merge(['serv_id' => 'align="left"'], $dadosField); + } + + /* + * Inicia o relatório. + */ + $dataRel[] = ''; + + /* + * Monta a linha de cabecalio. + */ + $linha = ''; + foreach ($dadosCabecalio as $key => $value) { + $linha .= sprintf("", $value, $key); + } + $linha .= ""; + $dataRel[] = $linha; + + /* + * Verifica se retornou dados + */ + if (!IsPostBack() || !count($this->GetData()[0])) { + $dataRel[] = sprintf("
%s
%s
", count($dadosCabecalio) - 1, (!IsPostBack() ? 'Informe os parametros e clique em consultar!' : 'Nenhum registro encontado!')); + $this->___dataRel[] = $dataRel; + return; + } + + $somaChmTotal = 0; + + foreach ($this->GetData()[0] as $row) { + $somaChmTotal += $row['chmd']; + } + + $somaReg = 0; + $somaServico = 0; + $srv = ''; + $oldSrv = ''; + + $agrupaServico = function($row, $somaChmTotal) use(&$somaServico, &$dataRel, &$srv, &$oldSrv) { + + $style = 'style="font-weight: bold; padding: 0; margin: 0; padding-left: 6px; padding-right: 6px; background-color: #4F71C0 !important"'; + $srv = $row["serv_id"]; + if (!$oldSrv) { + $oldSrv = $srv; } + if ((($srv != $oldSrv)) || !$row) { + $perc = !$somaChmTotal ? 0 : round(($somaServico / $somaChmTotal) * 100.0); + $dataRel[] = sprintf("Total [%s] %s%s", $oldSrv, $perc . "%", $somaServico); + $oldSrv = $srv; + $somaServico = 0; + } + + $somaServico += $row['qtde']; + }; - $somaChmTotal = 0; + /* + * Linhas de dados. + */ + foreach ($this->GetData()[0] as $row) { - foreach ($this->GetData()[0] as $row) { - $somaChmTotal += $row['chmd']; + if ($mostraColunaServicos) { + $agrupaServico($row, $somaChmTotal); } + $somaReg += $row['qtde']; + $row['chmd'] = round(!$somaChmTotal ? 0 : ($row['qtde'] * 100) / $somaChmTotal) . '%'; - $somaReg = 0; - /* - * Linhas de dados. - */ - foreach ($this->GetData()[0] as $row) { - $somaReg += $row['qtde']; - - $row['chmd'] = round(!$somaChmTotal ? 0 : ($row['qtde'] * 100) / $somaChmTotal) . '%'; - - // Formata linha de dados. - $linha = ""; - foreach ($dadosField as $key => $value) { - $linha .= sprintf("%s", $value, $row["$key"]); - } - $linha .= ""; - $dataRel[] = $linha; + // Formata linha de dados. + $linha = ""; + foreach ($dadosField as $key => $value) { + $linha .= sprintf("%s", $value, $row["$key"]); } - /* - * Linha de totalizacao. - */ - $linha = 'Total Chamadas: %sRegistros: %s'; - $dataRel[] = sprintf($linha, $this->GetData()[1]['chmd'], $somaReg); + $linha .= ""; + $dataRel[] = $linha; + } - /* - * Fecha relatorio. - */ - $dataRel[] = ''; - $this->___dataRel[] = $dataRel; + $colspan = 3; + if ($mostraColunaServicos) { + $agrupaServico(false, $somaChmTotal); + $colspan = 4; } - protected function ___PreparaHtml() { - + /* + * Linha de totalizacao. + */ + $linha = 'Total Chamadas: %sRegistros: %s'; + $dataRel[] = sprintf($linha, $this->GetData()[1]['chmd'], $somaReg); + + /* + * Fecha relatorio. + */ + $dataRel[] = ''; + $this->___dataRel[] = $dataRel; + } + + protected function ___PreparaHtml() { + + } + + protected function ___PreparaPdf() { + + list($this->___dac, $this->___dataIni, $this->___dataFim) = $_SESSION["SSstorageFiltros"]; + $mostraColunaServicos = GetUsoServico() == RELATORIO_SERVICOS_HABILITA; + + + /** + * TABELA DADOS PRINCIPAIS + */ + //HEADER DA TABELA DO PDF -> DADOS EM ARRAY + $dadosCabecalio = array( + 'Classificação' => 'C', + 'Item' => 'C', + 'Porcentagem %' => 'C', + 'Quantidade' => 'C' + ); + + $dadosField = array( + 'clas_descricao' => 'C', + 'clit_descricao' => 'C', + 'chmd' => 'C', + 'qtde' => 'C' + ); + + if ($mostraColunaServicos) { + $dadosCabecalio = array_merge(['Serviço' => 'C'], $dadosCabecalio); + $dadosField = array_merge(['serv_id' => 'C'], $dadosField); } - protected function ___PreparaPdf() { - list($this->___dac, $this->___dataIni, $this->___dataFim) = $_SESSION["SSstorageFiltros"]; - /** - * TABELA DADOS PRINCIPAIS - */ - //HEADER DA TABELA DO PDF -> DADOS EM ARRAY - $header = array( - 'Classificação' => 'C', - 'Serviço' => 'C', - 'Porcentagem %' => 'C', - 'Quantidade' => 'C' - ); - $dataHeader = array( - 'clas_descricao' => 'C', - 'clit_descricao' => 'C', - 'chmd' => 'C', - 'qtde' => 'C' - ); - - $somaChmTotal = 0; - - foreach ($this->GetData()[0] as $row) { - $somaChmTotal += $row['chmd']; + $somaChmTotal = 0; + + foreach ($this->GetData()[0] as $row) { + $somaChmTotal += $row['chmd']; + } + + $somaReg = 0; + $dados = array(); + $somaServico = 0; + $srv = ''; + $oldSrv = ''; + $dadosTable = []; + + $agrupaServico = function($row, $somaChmTotal) use(&$somaServico, &$dadosTable, &$srv, &$oldSrv) { + + $style = 'style="font-weight: bold; padding: 0; margin: 0; padding-left: 6px; padding-right: 6px; background-color: #4F71C0 !important"'; + $srv = $row["serv_id"]; + if (!$oldSrv) { + $oldSrv = $srv; + } + if ((($srv != $oldSrv)) || !$row) { + $perc = !$somaChmTotal ? 0 : (($somaServico / $somaChmTotal) * 100.0); + $data = []; + $data['serv_id'] = "TOTAL[$oldSrv]"; + $data['clas_descricao'] = ' '; + $data['clit_descricao'] = ' '; + $data['chmd'] = round($perc); + $data['qtde'] = $somaServico; + $data['cor_linha_dados'] = 225; + $dadosTable[] = $data; + $oldSrv = $srv; + $somaDuracaoServico = 0; + $oldSrv = $srv; + $somaServico = 0; } - $somaReg = 0; - $dados = array(); - $x = 0; + $somaServico += $row['qtde']; + }; - foreach ($this->GetData()[0] as $row) { - $somaReg += $row['qtde']; + foreach ($this->GetData()[0] as $row) { - $dados[$x]["clas_descricao"] = $row["clas_descricao"]; - $dados[$x]["clit_descricao"] = $row["clit_descricao"]; - $dados[$x]["chmd"] = round(!$somaChmTotal ? 0 : ($row['qtde'] * 100) / $somaChmTotal) . '%'; - $dados[$x]["qtde"] = $row['qtde']; - $x++; + if ($mostraColunaServicos) { + $agrupaServico($row, $somaChmTotal); } + $somaReg += $row['qtde']; + $row["chmd"] = round(!$somaChmTotal ? 0 : ($row['qtde'] * 100) / $somaChmTotal) . '%'; + $dadosTable[] = $row; + } + if ($mostraColunaServicos) { + $agrupaServico(false, $somaChmTotal); + $widthHeader = array(42, 43, 43, 30, 30); + $totalizador = array('Total Chamadas: ' . $this->GetData()[1]['chmd'], '','', '', 'Registros: ' . $somaReg); + } else { $widthHeader = array(47, 47, 47, 47); $totalizador = array('Total Chamadas: ' . $this->GetData()[1]['chmd'], '', '', 'Registros: ' . $somaReg); - //Monta o array para passar para o prepara; Necessário passar 6 parametros - $table1 = array($header, $dataHeader, $dados, $widthHeader, $totalizador, 0); - - $this->___dataRel = array($table1); } + + //Monta o array para passar para o prepara; Necessário passar 6 parametros + $table1 = array($dadosCabecalio, $dadosField, $dadosTable, $widthHeader, $totalizador, 0); - 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(); - } + $this->___dataRel = array($table1); + } + + public function ExecutaRelatorio() { + global $jsStartup, $jsJQuery, $smarty; + try { + /* + * Use esta função para validar dados do formulário. + */ + $this->___ValidaForm(); /* - * Inclua os scripts necessários aqui. + * Recupera os dados do banco. */ - $jsJQuery[] = "\$('#dataIni').keypress(function(){formataDataHora(this);}) "; - $jsJQuery[] = "\$('#dataFim').keypress(function(){formataDataHora(this);}) "; + $this->___ConteudoRelatorio(); - $smarty->assign('filtros', $this->___FiltrosRelatorio()); - $smarty->assign('conteudo', $conteudoRelatorio); - $smarty->assign('msg', $this->GetMsg()); - GetTemplate($smarty, 'relatoriosGrid.tpl'); + /* + * 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'); } - $relClassficacao = new RelClassificacao($idProg, $dbcon, 1); - $relClassficacao->ExecutaRelatorio(); - - /* +} + +$relClassficacao = new RelClassificacao($idProg, $dbcon, 1); +$relClassficacao->ExecutaRelatorio(); + +/* * ************************************************************************* * BACKUP DA QUERY ANTERIOR diff --git a/relatorios/callcenter/geral/relClassificacaoDetalhes.php b/relatorios/callcenter/geral/relClassificacaoDetalhes.php index b675a1cb..98fbc94f 100644 --- a/relatorios/callcenter/geral/relClassificacaoDetalhes.php +++ b/relatorios/callcenter/geral/relClassificacaoDetalhes.php @@ -1,113 +1,123 @@ ___dac = isset($_POST['listaDacs']) ? $_POST['listaDacs'] : 0; + $this->___classificacao = isset($_POST['listaClas']) ? $_POST['listaClas'] : 0; + $this->___classItem = isset($_POST['listaItem']) ? $_POST['listaItem'] : 0; + $this->___agente = isset($_POST["listaAgente"]) ? $_POST["listaAgente"] : null; + $this->___servico = isset($_POST["listaServico"]) ? $_POST["listaServico"] : 0; + } - public function __construct($idProg, $dbcon, $incDac) { - parent::__construct($idProg, $dbcon, $incDac); - $this->___dac = isset($_POST['listaDacs']) ? $_POST['listaDacs'] : 0; - $this->___classificacao = isset($_POST['listaClas']) ? $_POST['listaClas'] : 0; - $this->___classItem = isset($_POST['listaItem']) ? $_POST['listaItem'] : 0; - $this->___agente = isset($_POST["listaAgente"]) ? $_POST["listaAgente"] : null; - } + 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->___tipoRelatorio) = $_SESSION["SSstorageFiltros"]; - 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->___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ítico' : 'Sinté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->___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ítico' : 'Sintético')); } + $fltCsv = array(); if ($this->GetIncDac()) { - $dacs = GetDac($this->GetDbCon(), $this->___dac, "", 0, 1, 0, 0, 1); + $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; + } - $lkPrint = ""; - if ($this->___dataCount) { - $prt = 'Clique aqui para imprimir!'; - $prtHtml = "\"Clique"; - $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'); - } + if ($this->GetIncDac()) { + $dacs = GetDac($this->GetDbCon(), $this->___dac, "", 0, 1, 0, 0, 1); + } - $tipoRel = !$this->___tipoRelatorio ? '' : 'checked="checked"'; - - if ($this->___dataIni && $this->___dataFim) { - $agentes = $this->retornaAgente(); - } + $lkPrint = ""; + if ($this->___dataCount) { + $prt = 'Clique aqui para imprimir!'; + $prtHtml = "\"Clique"; + $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'); + } - /* - * Personalise esta função se necessitar de outras operações de filtro. - */ - $filtro = ''; - /* - * Rotulos. - */ - $filtro .= ''; - $this->GetIncDac() ? $filtro .= '' : ''; - $filtro .= ''; - $filtro .= ''; - $filtro .= ''; - $filtro .= ''; - $filtro .= ''; - $filtro .= ''; - $filtro .= ''; + $tipoRel = !$this->___tipoRelatorio ? '' : 'checked="checked"'; - /* - * Valores. - */ - global $dbcon; - $filtro .= ''; - $this->GetIncDac() ? $filtro .= sprintf('', $dacs) : ''; - $filtro .= ''; - $filtro .= ''; - $filtro .= ""; - $filtro .= sprintf('', GetClassificacao($dbcon, $this->___classificacao, $this->___dac)); - $filtro .= sprintf('', GetItem($dbcon, $this->___classificacao, $this->___classItem)); - $filtro .= ''; - $filtro .= ''; - $filtro .= ''; - $filtro .= '
FilaData InicialData Final Agente Classificação Classificação Item  
%s$agentes%s%s%s
'; + if ($this->___dataIni && $this->___dataFim) { + $agentes = $this->retornaAgente(); + } - /* - * Guarda os filtros passados para recuperar na emissão dos relatórios para impressão. - */ - $_SESSION["SSstorageFiltros"] = array($this->___dac, $this->___dataIni, $this->___dataFim, $this->___tipoRelatorio); - return sprintf($filtro, $this->___dataIni, $this->___dataFim, $lkPrint); + /* + * Personalise esta função se necessitar de outras operações de filtro. + */ + $filtro = ''; + /* + * Rotulos. + */ + $filtro .= ''; + $filtro .= $this->GetIncDac() ? '' : ''; + $filtro .= GetUsoServico() ? '' : ''; + $filtro .= ''; + $filtro .= ''; + $filtro .= ''; + $filtro .= ''; + $filtro .= ''; + $filtro .= ''; + $filtro .= ''; + + /* + * Valores. + */ + global $dbcon; + $filtro .= ''; + $filtro .= $this->GetIncDac() ? sprintf('', $dacs) : ''; + + if (GetUsoServico()) { + $filtro .= sprintf('', GetIdentRota(false, $this->___servico)); } - protected function ___GetDadosDb() { - $dataIni = FormatDtMssql($this->___dataIni); - $dataFim = FormatDtMssql($this->___dataFim); - $dac = $this->___dac; - $classificacao = $this->___classificacao; - $classificaItem = $this->___classItem; - $agente = $this->___agente ? $this->___agente : 0; + $filtro .= ''; + $filtro .= ''; + $filtro .= ""; + $filtro .= sprintf('', GetClassificacao($dbcon, $this->___classificacao, $this->___dac)); + $filtro .= sprintf('', GetItem($dbcon, $this->___classificacao, $this->___classItem)); + $filtro .= ''; + $filtro .= ''; + $filtro .= ''; + $filtro .= '
FilaServiçoData InicialData Final Agente Classificação Classificação Item  
%s%s$agentes%s%s%s
'; + + /* + * Guarda os filtros passados para recuperar na emissão dos relatórios para impressão. + */ + $_SESSION["SSstorageFiltros"] = array($this->___dac, $this->___dataIni, $this->___dataFim, $this->___tipoRelatorio); + return sprintf($filtro, $this->___dataIni, $this->___dataFim, $lkPrint); + } - $query = "SELECT calldate, apelido, src AS origem, dst AS destino, f.nome, clas_descricao, clit_descricao,tplg_descricao, + protected function ___GetDadosDb() { + $dataIni = FormatDtMssql($this->___dataIni); + $dataFim = FormatDtMssql($this->___dataFim); + $dac = $this->___dac; + $classificacao = $this->___classificacao; + $classificaItem = $this->___classItem; + $agente = $this->___agente ? $this->___agente : 0; + $srv = $this->___servico; + $mostraColunaServicos = GetUsoServico() == RELATORIO_SERVICOS_HABILITA; + + $query = "SELECT " . ( $mostraColunaServicos ? "coalesce(s.serv_id, 'Não Informado') as serv_id," : "" ) . " calldate, apelido, src AS origem, dst AS destino, f.nome, clas_descricao, clit_descricao,tplg_descricao, CASE WHEN (g.conf_uid <> '' AND g.conf_discado = 1) THEN 'S' ELSE 'N' END AS discador FROM pbx_bilhetes a INNER JOIN pbx_tipo_ligacao h ON h.tplg_codigo = a.tipo_chamada @@ -115,324 +125,445 @@ INNER JOIN pbx_classifica_atendimento c ON c.clas_id = b.clas_id INNER JOIN pbx_classifica_item d ON d.clit_id = b.clit_id INNER JOIN pbx_usuarios e ON e.matricula = b.matricula - INNER JOIN pbx_dacs f ON f.id = b.id_dac - LEFT JOIN pbx_campanha_contato_fone g ON a.uniqueid = g.conf_uid + INNER JOIN pbx_dacs f ON f.id = b.id_dac "; + + if (GetUsoServico()) { + $query .= "\nleft join pbx_servicos_registra s on s.uniqueid = a.uniqueid "; + } + + $query .= "\n LEFT JOIN pbx_campanha_contato_fone g ON a.uniqueid = g.conf_uid WHERE data_bilhete >= '%s' AND data_bilhete <= '%s' AND a.lastapp <> 'Transferred Call' AND b.id_dac = %s"; - if($classificacao){ - $query .= "AND b.clas_id = $classificacao"; - } - if($classificaItem){ - $query .= "AND b.clit_id = $classificaItem"; - } - if($agente){ - $query .= "AND apelido = '$agente'"; - } - $query .= "ORDER BY calldate"; - $query = sprintf($query,$dataIni, $dataFim, $dac); - - - $subQuery = sprintf("SELECT count(1) as chmd FROM pbx_bilhetes a + if ($classificacao) { + $query .= "AND b.clas_id = $classificacao"; + } + + if ($classificaItem) { + $query .= "AND b.clit_id = $classificaItem"; + } + + if ($agente) { + $query .= "AND apelido = '$agente'"; + } + + if (GetUsoServico() && $srv) { + $query .= "\nand s.serv_id = '{$srv}'"; + } + + $query .= $mostraColunaServicos ? "ORDER BY s.serv_id, calldate" : "ORDER BY calldate"; + $query = sprintf($query, $dataIni, $dataFim, $dac); + + + $subQuery = "SELECT count(1) as chmd FROM pbx_bilhetes a INNER JOIN pbx_eventos_dacs b ON b.uid2 = a.uniqueid AND b.evento in('COMPLETEAGENT','COMPLETECALLER', 'TRANSFER','COMPLETEAGENTRAMAL','COMPLETECALLERRAMAL','BUSY','NOANSWER', 'COMPLETAAGENT','COMPLETACALLER', 'TRANSFERORIG','BUSYS','NOANSWERS') INNER JOIN pbx_usuarios c ON c.matricula = substring(b.agente, 7, 4) - INNER JOIN pbx_dacs d ON d.nome = b.fila - WHERE data_bilhete >= '%s' AND data_bilhete <= '%s' + INNER JOIN pbx_dacs d ON d.nome = b.fila"; + + if (GetUsoServico()) { + $subQuery .= "\nleft join pbx_servicos_registra s on s.uniqueid = a.uniqueid "; + } + + $subQuery .= "\nWHERE data_bilhete >= '%s' AND data_bilhete <= '%s' AND d.id = %s - AND a.lastapp <> 'Transferred Call'",$dataIni, $dataFim, $dac); - - $result = $this->___GetQuery($query); - $row = pg_fetch_all($result); - $this->SetData($row ? $row : array()); - - $subResult = $this->___GetQuery($subQuery); - $subRow = pg_fetch_assoc($subResult); - $this->SetData($subRow ? $subRow : array()); - - $this->SetData($this->___agente ? $this->___agente : 0); + AND a.lastapp <> 'Transferred Call'"; + + if (GetUsoServico() && $srv) { + $subQuery .= "\nand s.serv_id = '{$srv}'"; } - protected function ___PreparaCsv() { - $dataRel = array(); - $filtro = $this->___FiltrosRelatorio(); + $subQuery = sprintf($subQuery, $dataIni, $dataFim, $dac); - /* - * Inicia o relatório. - */ - $dataRel[] = GenerateCsvFromArray($filtro); - - $dadosCabecalio = array( - 'Data/Hora', - 'Origem', - 'Agente', - 'Classificacao', - 'Item', - 'Tipo', - 'Discador', - ); - $dadosField = array( - 'calldate', - 'origem', - 'apelido', - 'clas_descricao', - 'clit_descricao', - 'tplg_descricao', - 'discador', - ); + $result = $this->___GetQuery($query); + $row = pg_fetch_all($result); + $this->SetData($row ? $row : array()); - /* - * Monta a linha de cabecalio. - */ - $dataRel[] = GenerateCsvFromArray($dadosCabecalio); + $subResult = $this->___GetQuery($subQuery); + $subRow = pg_fetch_assoc($subResult); + $this->SetData($subRow ? $subRow : array()); - $somaReg = 0; - - /* - * Linhas de dados. - */ - foreach ($this->GetData()[0] as $row) { - $somaReg ++; - - $row['clit_descricao'] = RemoveAcentos($row['clit_descricao']); - $row['clas_descricao'] = RemoveAcentos($row['clas_descricao']); - $row['tplg_descricao'] = explode(' ', $row['tplg_descricao'])[0]; - $row['calldate'] = date('d/m/Y H:i:s', strtotime($row['calldate'])); - // Formata linha de dados. - $linha = array(); - foreach ($dadosField as $value) { - $linha[] = $row["$value"]; - } - - $dataRel[] = GenerateCsvFromArray($linha); - } - $dataRel[] = GenerateCsvFromArray(array('Total Chamadas: ' . $this->GetData()[1]['chmd'], '', '','', 'Registros: ' . $somaReg)); + $this->SetData($this->___agente ? $this->___agente : 0); + } - $this->___dataRel[] = $dataRel; + protected function ___PreparaCsv() { + $dataRel = array(); + $filtro = $this->___FiltrosRelatorio(); + + /* + * Inicia o relatório. + */ + $dataRel[] = GenerateCsvFromArray($filtro); + + $dadosCabecalio = array( + 'Data/Hora', + 'Origem', + 'Agente', + 'Classificacao', + 'Item', + 'Tipo', + 'Discador', + ); + + $dadosField = array( + 'calldate', + 'origem', + 'apelido', + 'clas_descricao', + 'clit_descricao', + 'tplg_descricao', + 'discador', + ); + + if (GetUsoServico() == RELATORIO_SERVICOS_HABILITA) { + $dadosCabecalio = array_merge(['Servico'], $dadosCabecalio); + $dadosField = array_merge(['serv_id'], $dadosField); } - protected function ___PreparaExcel() { - $dataRel = array(); - $filtro = $this->___FiltrosRelatorio(); - /* - * Inicia o relatório. - */ + /* + * Monta a linha de cabecalio. + */ + $dataRel[] = GenerateCsvFromArray($dadosCabecalio); - /* - * Cria os filtros - */ - $linha = array('LABEL'); - foreach ($filtro as $values) { - list($label, $value) = explode(":", $values); - $linha[] = $label; - } - $dataRel[] = $linha; + $somaReg = 0; - $linha = array('DADOS'); - foreach ($filtro as $values) { - list($label, $value) = explode(":", $values); - $linha[] = $value; + /* + * Linhas de dados. + */ + foreach ($this->GetData()[0] as $row) { + $somaReg ++; + + $row['clit_descricao'] = RemoveAcentos($row['clit_descricao']); + $row['clas_descricao'] = RemoveAcentos($row['clas_descricao']); + $row['tplg_descricao'] = explode(' ', $row['tplg_descricao'])[0]; + $row['calldate'] = date('d/m/Y H:i:s', strtotime($row['calldate'])); + // Formata linha de dados. + $linha = array(); + foreach ($dadosField as $value) { + $linha[] = $row["$value"]; } - $dataRel[] = $linha; + $dataRel[] = GenerateCsvFromArray($linha); + } + $dataRel[] = GenerateCsvFromArray(array('Total Chamadas: ' . $this->GetData()[1]['chmd'], '', '', '', 'Registros: ' . $somaReg)); - $dadosCabecalio = array( - 'Data/Hora', - 'Origem', - 'Agente', - 'Classificacao', - 'Item', - 'Tipo', - 'Discador' - ); - $dadosField = array( - 'calldate', - 'origem', - 'apelido', - 'clas_descricao', - 'clit_descricao', - 'tplg_descricao', - 'discador' - ); + $this->___dataRel[] = $dataRel; + } - /* - * Monta a linha de cabecalio. - */ - $linha = array('LABEL'); - foreach ($dadosCabecalio as $value) { - $linha[] = $value; - } - $dataRel[] = $linha; + 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; - $somaChmTotal = 0; + $linha = array('DADOS'); + foreach ($filtro as $values) { + list($label, $value) = explode(":", $values); + $linha[] = $value; + } - foreach ($this->GetData()[0] as $row) { - $somaChmTotal += $row['chmd']; - } + $dataRel[] = $linha; + + $dadosCabecalio = array( + 'Data/Hora', + 'Origem', + 'Agente', + 'Classificacao', + 'Item', + 'Tipo', + 'Discador' + ); + + $dadosField = array( + 'calldate', + 'origem', + 'apelido', + 'clas_descricao', + 'clit_descricao', + 'tplg_descricao', + 'discador' + ); + + if (GetUsoServico() == RELATORIO_SERVICOS_HABILITA) { + $dadosCabecalio = array_merge(['Servico'], $dadosCabecalio); + $dadosField = array_merge(['serv_id'], $dadosField); + } - $somaReg = 0; + /* + * Monta a linha de cabecalio. + */ + $linha = array('LABEL'); + foreach ($dadosCabecalio as $value) { + $linha[] = $value; + } + $dataRel[] = $linha; - /* - * Linhas de dados. - */ - foreach ($this->GetData()[0] as $row) { - $somaReg ++; + $somaChmTotal = 0; + + foreach ($this->GetData()[0] as $row) { + $somaChmTotal += $row['chmd']; + } - $row['clit_descricao'] = RemoveAcentos($row['clit_descricao']); - $row['clas_descricao'] = RemoveAcentos($row['clas_descricao']); - $row['tplg_descricao'] = explode(' ', $row['tplg_descricao'])[0]; - $row['calldate'] = date('d/m/Y H:i:s',strtotime($row['calldate'])); + $somaReg = 0; - // Formata linha de dados. - $linha = array('DADOS'); - foreach ($dadosField as $key) { - $linha[] = $row["$key"]; - } + /* + * Linhas de dados. + */ + foreach ($this->GetData()[0] as $row) { + $somaReg ++; - $dataRel[] = $linha; + $row['clit_descricao'] = RemoveAcentos($row['clit_descricao']); + $row['clas_descricao'] = RemoveAcentos($row['clas_descricao']); + $row['tplg_descricao'] = explode(' ', $row['tplg_descricao'])[0]; + $row['calldate'] = date('d/m/Y H:i:s', strtotime($row['calldate'])); + + // Formata linha de dados. + $linha = array('DADOS'); + foreach ($dadosField as $key) { + $linha[] = $row["$key"]; } - $dataRel[] = array('LABEL', 'Total Chamadas: ' . $this->GetData()[1]['chmd'], '', '','', 'Registros: ' . $somaReg); + $dataRel[] = $linha; + } + + $dataRel[] = array('LABEL', 'Total Chamadas: ' . $this->GetData()[1]['chmd'], '', '', '', 'Registros: ' . $somaReg); + + $this->___dataRel[] = $dataRel; + } + protected function ___PreparaGrid() { + + $dataRel = array(); + $mostraColunaServicos = GetUsoServico() == RELATORIO_SERVICOS_HABILITA; + + $dadosCabecalio = array( + 'Data/Hora' => 'align="center"', + 'Origem' => 'align="left"', + 'Agente' => 'align="left"', + 'Classificação' => 'align="left"', + 'Item' => 'align="center"', + 'Tipo' => 'align="center"', + 'Discador' => 'align="Center"', + ); + + $dadosField = array( + 'calldate' => 'align="center"', + 'origem' => 'align="left"', + 'apelido' => 'align="left"', + 'clas_descricao' => 'align="left"', + 'clit_descricao' => 'align="center"', + 'tplg_descricao' => 'align="center"', + 'discador' => 'align="Center"' + ); + + if ($mostraColunaServicos) { + $dadosCabecalio = array_merge(['Serviço' => 'align="center"'], $dadosCabecalio); + $dadosField = array_merge(['serv_id' => 'align="left"'], $dadosField); + } + /* + * Inicia o relat�rio. + */ + $dataRel[] = ''; + + /* + * Monta a linha de cabecalio. + */ + $linha = ''; + foreach ($dadosCabecalio as $key => $value) { + $linha .= sprintf("", $value, $key); + } + $linha .= ""; + $dataRel[] = $linha; + + /* + * Verifica se retornou dados + */ + if (!IsPostBack() || !count($this->GetData()[0])) { + $dataRel[] = sprintf("
%s
%s
", count($dadosCabecalio) - 1, (!IsPostBack() ? 'Informe os parametros e clique em consultar!' : 'Nenhum registro encontado!')); $this->___dataRel[] = $dataRel; + return; } - protected function ___PreparaGrid() { - $dataRel = array(); - $dadosCabecalio = array( - 'Data/Hora' => 'align="center"', - 'Origem' => 'align="left"', - 'Agente' => 'align="left"', - 'Classificação' => 'align="left"', - 'Item' => 'align="center"', - 'Tipo' => 'align="center"', - 'Discador' => 'align="Center"', - ); - $dadosField = array( - 'calldate' => 'align="center"', - 'origem' => 'align="left"', - 'apelido' => 'align="left"', - 'clas_descricao' => 'align="left"', - 'clit_descricao' => 'align="center"', - 'tplg_descricao' => 'align="center"', - 'discador' => 'align="Center"' - ); - /* - * Inicia o relat�rio. - */ - $dataRel[] = ''; + $somaReg = 0; + $somaServico = 0; + $srv = ''; + $oldSrv = ''; - /* - * Monta a linha de cabecalio. - */ - $linha = ''; - foreach ($dadosCabecalio as $key => $value) { - $linha .= sprintf("", $value, $key); - } - $linha .= ""; - $dataRel[] = $linha; + $agrupaServico = function($row) use(&$somaServico, &$dataRel, &$srv, &$oldSrv) { - /* - * Verifica se retornou dados - */ - if (!IsPostBack() || !count($this->GetData()[0])) { - $dataRel[] = sprintf("
%s
%s
", count($dadosCabecalio) - 1, (!IsPostBack() ? 'Informe os parametros e clique em consultar!' : 'Nenhum registro encontado!')); - $this->___dataRel[] = $dataRel; - return; + $style = 'style="font-weight: bold; padding: 0; margin: 0; padding-left: 6px; padding-right: 6px; background-color: #4F71C0 !important"'; + $srv = $row["serv_id"]; + if (!$oldSrv) { + $oldSrv = $srv; + } + if ((($srv != $oldSrv)) || !$row) { + $dataRel[] = sprintf("Total [%s] %s", $oldSrv, $somaServico); + $oldSrv = $srv; + $somaServico = 0; } - $somaReg = 0; - /* - * Linhas de dados. - */ - foreach ($this->GetData()[0] as $row) { - $somaReg ++; - $row["calldate"] = date('d/m/Y H:i:s', strtotime($row["calldate"])); - $row['tplg_descricao'] = explode(' ', $row['tplg_descricao'])[0]; - $row['origem'] = ocultarTelefone($row['origem']); - // Formata linha de dados. - $linha = ""; - foreach ($dadosField as $key => $value) { - $linha .= sprintf("%s", $value, $row["$key"]); - } - $linha .= ""; - $dataRel[] = $linha; + $somaServico++; + }; + + + /* + * Linhas de dados. + */ + foreach ($this->GetData()[0] as $row) { + + if ($mostraColunaServicos) { + $agrupaServico($row); } - /* - * Linha de totalizacao. - */ - $linha = 'Total [ Chamadas Periodo ]: %sRegistros: %s'; - $dataRel[] = sprintf($linha, $this->GetData()[1]['chmd'], $somaReg); - /* - * Fecha relatorio. - */ - $dataRel[] = ''; - $this->___dataRel[] = $dataRel; + $somaReg ++; + $row["calldate"] = date('d/m/Y H:i:s', strtotime($row["calldate"])); + $row['tplg_descricao'] = explode(' ', $row['tplg_descricao'])[0]; + $row['origem'] = ocultarTelefone($row['origem']); + // Formata linha de dados. + $linha = ""; + foreach ($dadosField as $key => $value) { + $linha .= sprintf("%s", $value, $row["$key"]); + } + $linha .= ""; + $dataRel[] = $linha; + } + /* + * Linha de totalizacao. + */ + $colspan = 5; + if ($mostraColunaServicos) { + $agrupaServico(false); + $colspan = 6; } - protected function ___PreparaHtml() { - + $linha = 'Total [ Chamadas Periodo ]: %sRegistros: %s'; + $dataRel[] = sprintf($linha, $this->GetData()[1]['chmd'], $somaReg); + + /* + * Fecha relatorio. + */ + $dataRel[] = ''; + $this->___dataRel[] = $dataRel; + } + + protected function ___PreparaHtml() { + + } + + protected function ___PreparaPdf() { + + list($this->___dac, $this->___dataIni, $this->___dataFim) = $_SESSION["SSstorageFiltros"]; + $mostraColunaServicos = GetUsoServico() == RELATORIO_SERVICOS_HABILITA; + + /** + * TABELA DADOS PRINCIPAIS + */ + //HEADER DA TABELA DO PDF -> DADOS EM ARRAY + $dadosCabecalio = array( + 'Data/Hora' => 'C', + 'Origem' => 'C', + 'Agente' => 'C', + 'Classificação' => 'C', + 'Item' => 'C', + 'Tipo' => 'C', + 'Discador' => 'C', + ); + $dadosField = array( + 'calldate' => 'C', + 'origem' => 'C', + 'apelido' => 'C', + 'clas_descricao' => 'C', + 'clit_descricao' => 'C', + 'tplg_descricao' => 'C', + 'discador' => 'C', + ); + + if ($mostraColunaServicos) { + $dadosCabecalio = array_merge(['Serviço' => 'C'], $dadosCabecalio); + $dadosField = array_merge(['serv_id' => 'C'], $dadosField); } - protected function ___PreparaPdf() { - list($this->___dac, $this->___dataIni, $this->___dataFim) = $_SESSION["SSstorageFiltros"]; - /** - * TABELA DADOS PRINCIPAIS - */ - //HEADER DA TABELA DO PDF -> DADOS EM ARRAY - $header = array( - 'Data/Hora' => 'C', - 'Origem' => 'C', - 'Agente' => 'C', - 'Classificação' => 'C', - 'Item' => 'C', - 'Tipo' => 'C', - 'Discador' => 'C', - ); - $dataHeader = array( - 'calldate' => 'C', - 'origem' => 'C', - 'apelido' => 'C', - 'clas_descricao' => 'C', - 'clit_descricao' => 'C', - 'tplg_descricao' => 'C', - 'discador' => 'C', - ); - - $somaReg = 0; - $dados = array(); - $x = 0; - - foreach ($this->GetData()[0] as $row) { - $somaReg ++; - - $dados[$x]["clas_descricao"] = $row["clas_descricao"]; - $dados[$x]["clit_descricao"] = $row["clit_descricao"]; - $dados[$x]["origem"] = $row['origem']; - $dados[$x]["apelido"] = $row['apelido']; - $dados[$x]["discador"] = $row["discador"]; - $dados[$x]["calldate"] = date('d/m/Y H:i:s',strtotime($row['calldate'])); - $dados[$x]['tplg_descricao'] = explode(' ', $row['tplg_descricao'])[0]; - $x++; + $somaReg = 0; + $somaServico = 0; + $srv = ''; + $oldSrv = ''; + $dadosTable = []; + + $agrupaServico = function($row) use(&$somaServico, &$dadosTable, &$srv, &$oldSrv) { + + $style = 'style="font-weight: bold; padding: 0; margin: 0; padding-left: 6px; padding-right: 6px; background-color: #4F71C0 !important"'; + $srv = $row["serv_id"]; + if (!$oldSrv) { + $oldSrv = $srv; + } + if ((($srv != $oldSrv)) || !$row) { + $perc = !$somaChmTotal ? 0 : (($somaServico / $somaChmTotal) * 100.0); + $data = []; + $data['serv_id'] = "TOTAL[$oldSrv]"; + $data['calldate'] = ' '; + $data['origem'] = ' '; + $data['apelido'] = ' '; + $data['clas_descricao'] = ' '; + $data['clit_descricao'] = ' '; + $data['tplg_descricao'] = ' '; + $data['discador'] = $somaServico; + $data['cor_linha_dados'] = 225; + $dadosTable[] = $data; + $oldSrv = $srv; + $oldSrv = $srv; + $somaServico = 0; } - $widthHeader = array(30, 15, 30, 40, 40, 20,15); - $totalizador = array('Total Chamadas: ' . $this->GetData()[1]['chmd'], '', '','', 'Registros: ' . $somaReg,'','',); - //Monta o array para passar para o prepara; Necessário passar 6 parametros - $table = array($header, $dataHeader, $dados, $widthHeader, $totalizador, 0); + $somaServico ++; + }; - $this->___dataRel = array($table); + + foreach ($this->GetData()[0] as $row) { + + if ($mostraColunaServicos) { + $agrupaServico($row); + } + + $somaReg ++; + $row['calldate'] = date('d/m/Y H:i:s', strtotime($row['calldate'])); + $row['tplg_descricao'] = explode(' ', $row['tplg_descricao'])[0]; + $dadosTable[] = $row; } - - protected function retornaAgente() { - global $dbcon; - $codSel = $this->GetData()[2] ? $this->GetData()[2] : ''; - $agentes = ""; + $agentes .= ""; + + $query = sprintf("SELECT apelido AS nome FROM pbx_usuarios u WHERE EXISTS(SELECT '' FROM pbx_eventos_agentes WHERE id_dac = %s AND matricula = u.matricula @@ -440,104 +571,104 @@ AND CAST(login as date) <= '%s') ", $this->___dac, FormatDtMssql($this->___dataIni), FormatDtMssql($this->___dataFim)); - $result = @pg_query($dbcon, $query); + $result = @pg_query($dbcon, $query); - while ($dados = pg_fetch_row($result)) { - if ($codSel == $dados[0]) { - $sel = "selected"; - $i = 1; - } else { - $sel = ""; - } - $agentes .= ""; + while ($dados = pg_fetch_row($result)) { + if ($codSel == $dados[0]) { + $sel = "selected"; + $i = 1; + } else { + $sel = ""; } - $agentes .= ""; - return $agentes; + $agentes .= ""; } + $agentes .= ""; + return $agentes; + } - 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(); - } + public function ExecutaRelatorio() { + global $jsStartup, $jsJQuery, $smarty; + try { + /* + * Use esta função para validar dados do formulário. + */ + $this->___ValidaForm(); /* - * Inclua os scripts necessários aqui. + * Recupera os dados do banco. */ - $jsJQuery[] = "\$('#dataIni').keypress(function(){formataDataHora(this);}) "; - $jsJQuery[] = "\$('#dataFim').keypress(function(){formataDataHora(this);}) "; + $this->___ConteudoRelatorio(); - $smarty->assign('filtros', $this->___FiltrosRelatorio()); - $smarty->assign('conteudo', $conteudoRelatorio); - $smarty->assign('msg', $this->GetMsg()); - GetTemplate($smarty, 'relatoriosGrid.tpl'); + /* + * 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'); } - $relClassDetalhes = new RelClassificacaoDetalhes($idProg, $dbcon, 1); - $relClassDetalhes->ExecutaRelatorio(); - - /* - - * ************************************************************************* - * BACKUP DAS QUERYS ANTIGAS - * ************************************************************************* - - $query = "select distinct c.matricula, c.apelido as nome - from pbx_classifica_reg a, pbx_bilhetes b, pbx_usuarios c - where b.uniqueid = a.id_bilhetes - and c.matricula = a.matricula - and b.lastapp <> 'Transferred Call' - and a.id_dac = $idDac - and b.data_bilhete >= '$dataInicial' - and b.data_bilhete <= '$dataFinal' - order by 2 - "; - - if ($total) { - $query = "select count(1) as chmd - from pbx_bilhetes d, pbx_eventos_dacs e, pbx_usuarios f, pbx_dacs a - where e.uid2 = d.uniqueid - and e.evento in('COMPLETEAGENT','COMPLETECALLER', 'TRANSFER','COMPLETEAGENTRAMAL','COMPLETECALLERRAMAL','BUSY','NOANSWER', 'COMPLETAAGENT','COMPLETACALLER', 'TRANSFERORIG','BUSYS','NOANSWERS') - and a.nome = e.fila - and f.matricula = substring(e.agente, 7, 4) - and d.lastapp <> 'Transferred Call' - and coalesce(a.id, 0) = case when($dac > 0)then $dac else coalesce(a.id, 0) end - and b.data_bilhete >= '$dataInicial' - and b.data_bilhete <= '$dataFinal' - "; - } else { - $query .= "from pbx_classifica_reg a, pbx_classifica_atendimento b, pbx_classifica_item c, - pbx_bilhetes d, pbx_usuarios e, pbx_dacs f - where b.clas_id = a.clas_id - and c.clit_id = a.clit_id - and d.uniqueid = a.id_bilhetes - and e.matricula = a.matricula - and f.id = a.id_dac - and d.lastapp <> 'Transferred Call' - and coalesce(a.id_dac, 0) = case when($dac > 0)then $dac else coalesce(a.id_dac, 0) end - and b.data_bilhete >= '$dataInicial' - and b.data_bilhete <= '$dataFinal'"; - } - - */ +} + +$relClassDetalhes = new RelClassificacaoDetalhes($idProg, $dbcon, 1); +$relClassDetalhes->ExecutaRelatorio(); + +/* + + * ************************************************************************* + * BACKUP DAS QUERYS ANTIGAS + * ************************************************************************* + + $query = "select distinct c.matricula, c.apelido as nome + from pbx_classifica_reg a, pbx_bilhetes b, pbx_usuarios c + where b.uniqueid = a.id_bilhetes + and c.matricula = a.matricula + and b.lastapp <> 'Transferred Call' + and a.id_dac = $idDac + and b.data_bilhete >= '$dataInicial' + and b.data_bilhete <= '$dataFinal' + order by 2 + "; + + if ($total) { + $query = "select count(1) as chmd + from pbx_bilhetes d, pbx_eventos_dacs e, pbx_usuarios f, pbx_dacs a + where e.uid2 = d.uniqueid + and e.evento in('COMPLETEAGENT','COMPLETECALLER', 'TRANSFER','COMPLETEAGENTRAMAL','COMPLETECALLERRAMAL','BUSY','NOANSWER', 'COMPLETAAGENT','COMPLETACALLER', 'TRANSFERORIG','BUSYS','NOANSWERS') + and a.nome = e.fila + and f.matricula = substring(e.agente, 7, 4) + and d.lastapp <> 'Transferred Call' + and coalesce(a.id, 0) = case when($dac > 0)then $dac else coalesce(a.id, 0) end + and b.data_bilhete >= '$dataInicial' + and b.data_bilhete <= '$dataFinal' + "; + } else { + $query .= "from pbx_classifica_reg a, pbx_classifica_atendimento b, pbx_classifica_item c, + pbx_bilhetes d, pbx_usuarios e, pbx_dacs f + where b.clas_id = a.clas_id + and c.clit_id = a.clit_id + and d.uniqueid = a.id_bilhetes + and e.matricula = a.matricula + and f.id = a.id_dac + and d.lastapp <> 'Transferred Call' + and coalesce(a.id_dac, 0) = case when($dac > 0)then $dac else coalesce(a.id_dac, 0) end + and b.data_bilhete >= '$dataInicial' + and b.data_bilhete <= '$dataFinal'"; + } + + */ ?> diff --git a/relatorios/callcenter/geral/relClassificacaoMensal.php b/relatorios/callcenter/geral/relClassificacaoMensal.php index f25d17d6..06d72a4f 100644 --- a/relatorios/callcenter/geral/relClassificacaoMensal.php +++ b/relatorios/callcenter/geral/relClassificacaoMensal.php @@ -1,441 +1,474 @@ ___dac = isset($_POST['listaDacs']) ? $_POST['listaDacs'] : 0; - $this->___mes = isset($_POST['listaMes']) ? $_POST['listaMes'] : date('m'); - $this->___ano = isset($_POST['listaAno']) ? $_POST['listaAno'] : 0; - } +/* * ************************************************************************ + * + * RELATÓRIO CLASSIFICAÇÃO MENSAL + * Autor + * Lucas Awade + * + * ************************************************************************* + * Definições do Projeto + * Nome: RelClassificacaoMensal + * Data início: 10/08/2018 + * Equipe: Amarildo Pereira + * Descrição: Gera relatório de classificação realizadas no mês e cadastrada + * no banco de dados. As impressões é feito de acordo com o retorno com a + * query do banco de dados que possui na pesquisa o mês e ano e a fila(DAC); + * + * Pré-requisito: As querys de banco de dados tem que retornar com ordenação + * de acordo com os classificações; + * + * OBS: Atenção ao realizar manutenção nos itens de impressão pois os dados + * apresentados são estruturados. + * + * ************************************************************************* + * Copyright (c) 2018, Simples IP + * ************************************************************************ */ + +include_once 'util/relatoriosBase.php'; + +class RelClassificacaoMensal extends Relatorios { + + private $___ano; + private $___mes; + private $___servico; + + public function __construct($idProg, $dbcon, $incDac) { + parent::__construct($idProg, $dbcon, $incDac); + $this->___dac = isset($_POST['listaDacs']) ? $_POST['listaDacs'] : 0; + $this->___mes = isset($_POST['listaMes']) ? $_POST['listaMes'] : date('m'); + $this->___ano = isset($_POST['listaAno']) ? $_POST['listaAno'] : 0; + $this->___servico = isset($_POST["listaServico"]) ? $_POST["listaServico"] : 0; + } - public function ___ValidaForm() { - if (!IsPostBack()) - return; + public function ___ValidaForm() { + if (!IsPostBack()) + return; - if ($this->GetIncDac() && !StrToIntDef($this->___dac)) { - GeraExcept('Informe uma Fila!'); - } + if ($this->GetIncDac() && !StrToIntDef($this->___dac)) { + GeraExcept('Informe uma Fila!'); } + } - function ___FiltrosRelatorio() { - if ($this->___media != MEDIA_PRINT_GRID) { - /* - * Recupera os filtros da sessão do usuário. - */ - list($this->___dac, $this->___ano, $this->___mes, $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ítico' : 'Sintético')); - } + function ___FiltrosRelatorio() { + if ($this->___media != MEDIA_PRINT_GRID) { + /* + * Recupera os filtros da sessão do usuário. + */ + list($this->___dac, $this->___ano, $this->___mes, $this->___tipoRelatorio) = $_SESSION["SSstorageFiltros"]; - $fltCsv = array(); - if ($this->GetIncDac()) { - $fltCsv[] = 'Fila:' . GetDacDesc($this->GetDbCon(), $this->___dac); - } - $fltCsv[] = "Ano:" . $this->___ano; - $fltCsv[] = "Mes:" . $this->___mes; - $fltCsv[] = "Data Emissao:" . date('d/m/Y H:i:s'); - $fltCsv[] = "Emitido Por:" . GetLogin(); - return $fltCsv; + 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ítico' : 'Sintético')); } + $fltCsv = array(); if ($this->GetIncDac()) { - $dacs = GetDac($this->GetDbCon(), $this->___dac, "", 0, 1, 0, 0, 1); + $fltCsv[] = 'Fila:' . GetDacDesc($this->GetDbCon(), $this->___dac); } + $fltCsv[] = "Ano:" . $this->___ano; + $fltCsv[] = "Mes:" . $this->___mes; + $fltCsv[] = "Data Emissao:" . date('d/m/Y H:i:s'); + $fltCsv[] = "Emitido Por:" . GetLogin(); + return $fltCsv; + } - $lkPrint = ""; - if ($this->___dataCount) { - $prt = 'Clique aqui para imprimir!'; - $prtHtml = "\"Clique"; - $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'); - } + if ($this->GetIncDac()) { + $dacs = GetDac($this->GetDbCon(), $this->___dac, "", 0, 1, 0, 0, 1); + } - $tipoRel = !$this->___tipoRelatorio ? '' : 'checked="checked"'; + $lkPrint = ""; + if ($this->___dataCount) { + $prt = 'Clique aqui para imprimir!'; + $prtHtml = "\"Clique"; + $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ção se necessitar de outras operações de filtro. + */ + $filtro = ''; + /* + * Rotulos. + */ + $filtro .= ''; + $filtro .= $this->GetIncDac() ? '' : ''; + $filtro .= GetUsoServico() ? '' : ''; + $filtro .= ''; + $filtro .= ''; + $filtro .= ''; + $filtro .= ''; + + /* + * Valores. + */ + $filtro .= ''; + $filtro .= $this->GetIncDac() ? sprintf('', $dacs) : ''; + + if (GetUsoServico()) { + $filtro .= sprintf('', GetIdentRota(false, $this->___servico)); + } + $filtro .= sprintf("", GetMes($this->___mes, '', 1)); + $filtro .= sprintf('', GetAno($this->___ano, 1)); + $filtro .= ''; + $filtro .= ''; + $filtro .= ''; + $filtro .= '
FilaServiçoMêsAno 
%s%s%s%s%s
'; + + /* + * Guarda os filtros passados para recuperar na emissão dos relatórios para impressão. + */ + $_SESSION["SSstorageFiltros"] = array($this->___dac, $this->___ano, $this->___mes, $this->___tipoRelatorio); + return sprintf($filtro, $lkPrint); + } - /* - * Personalise esta função se necessitar de outras operações de filtro. - */ - $filtro = ''; - /* - * Rotulos. - */ - $filtro .= ''; - $this->GetIncDac() ? $filtro .= '' : ''; - $filtro .= ''; - $filtro .= ''; - $filtro .= ''; - $filtro .= ''; + protected function ___GetDadosDb() { - /* - * Valores. - */ - $filtro .= ''; - $this->GetIncDac() ? $filtro .= sprintf('', $dacs) : ''; - $filtro .= sprintf("", GetMes($this->___mes, '', 1)); - $filtro .= sprintf('', GetAno($this->___ano, 1)); - $filtro .= ''; - $filtro .= ''; - $filtro .= ''; - $filtro .= '
FilaMêsAno 
%s%s%s%s
'; + $ano = $this->___ano; + $mes = $this->___mes; + $dac = $this->___dac; + $srv = $this->___servico; + $mostraColunaServicos = GetUsoServico() == RELATORIO_SERVICOS_HABILITA; + + $query = $mostraColunaServicos ? "select clas_descricao, clit_descricao," : "select clas_descricao, clit_descricao,"; + $query .= " (select count(*) from pbx_classifica_reg d + inner join pbx_bilhetes e on e.uniqueid = d.id_bilhetes + inner join pbx_eventos_dacs f on f.uid2 = e.uniqueid "; + if (GetUsoServico()) { + $query .= "\nleft join pbx_servicos_registra s on s.uniqueid = e.uniqueid"; + } + $query .= "\n where e.lastapp <> 'Transferred Call' + and date_part('year',e.data_bilhete) = '$ano' + and date_part('month',e.data_bilhete) = '$mes' + and f.evento in('COMPLETEAGENT','COMPLETECALLER', 'TRANSFER','COMPLETEAGENTRAMAL','COMPLETECALLERRAMAL','BUSY','NOANSWER', 'COMPLETAAGENT','COMPLETACALLER', 'TRANSFERORIG','BUSYS','NOANSWERS') + and d.clas_id = c.clas_id + and d.clit_id = c.clit_id + and d.id_dac = dac.id_dac"; + + if (GetUsoServico() && $srv) { + $query .= "\nand s.serv_id = '{$srv}'"; + } - /* - * Guarda os filtros passados para recuperar na emissão dos relatórios para impressão. - */ - $_SESSION["SSstorageFiltros"] = array($this->___dac, $this->___ano, $this->___mes, $this->___tipoRelatorio); - return sprintf($filtro, $lkPrint); + $query .= " ) as qtde, + + (select count(distinct d.id_bilhetes) from pbx_classifica_reg d + inner join pbx_bilhetes e on e.uniqueid = d.id_bilhetes + inner join pbx_eventos_dacs f on f.uid2 = e.uniqueid "; + + if (GetUsoServico()) { + $query .= "\nleft join pbx_servicos_registra s on s.uniqueid = e.uniqueid"; + } + $query .= "\nwhere e.lastapp <> 'Transferred Call' + and date_part('year', e.data_bilhete) = '$ano' + and date_part('month', e.data_bilhete) = '$mes' + and f.evento in('COMPLETEAGENT','COMPLETECALLER', 'TRANSFER','COMPLETEAGENTRAMAL','COMPLETECALLERRAMAL','BUSY','NOANSWER', 'COMPLETAAGENT','COMPLETACALLER', 'TRANSFERORIG','BUSYS','NOANSWERS') + and d.clas_id = c.clas_id + and d.clit_id = c.clit_id + and d.id_dac = dac.id_dac"; + + if (GetUsoServico() && $srv) { + $query .= "\nand s.serv_id = '{$srv}'"; } - protected function ___GetDadosDb() { + $query .= ") as chmd + from pbx_classifica_atendimento a + inner join pbx_classifica_item c on c.clas_id = a.clas_id + inner join pbx_classifica_dacs dac on dac.clas_id = a.clas_id + where dac.id_dac = '$dac' + order by clas_descricao, clit_descricao"; - $ano = $this->___ano; - $mes = $this->___mes; - $dac = $this->___dac; + $result = $this->___GetQuery($query); + $row = pg_fetch_all($result); + $this->SetData($row ? $row : array()); + } - $query = "select clas_descricao, clit_descricao, - (select count(*) from pbx_classifica_reg d - inner join pbx_bilhetes e on e.uniqueid = d.id_bilhetes - and e.lastapp <> 'Transferred Call' - and date_part('year',e.data_bilhete) = '$ano' - and date_part('month',e.data_bilhete) = '$mes' - where d.clas_id = c.clas_id - and d.clit_id = c.clit_id - and d.id_dac = '$dac') as qtde, + protected function ___PreparaCsv() { + $dataRel = array(); + $filtro = $this->___FiltrosRelatorio(); - (select count(distinct d.id_bilhetes) from pbx_classifica_reg d - inner join pbx_bilhetes e on e.uniqueid = d.id_bilhetes - and e.lastapp <> 'Transferred Call' - and date_part('year',e.data_bilhete) = '$ano' - and date_part('month',e.data_bilhete) = '$mes' - where d.clas_id = c.clas_id - and d.clit_id = c.clit_id - and d.id_dac = '$dac') as chmd - from pbx_classifica_atendimento a - inner join pbx_classifica_item c on c.clas_id = a.clas_id - inner join pbx_classifica_dacs d on d.clas_id = a.clas_id - where d.id_dac = '$dac' - order by clas_descricao, clit_descricao"; - $result = $this->___GetQuery($query); - $row = pg_fetch_all($result); - $this->SetData($row ? $row : array()); - } + /* + * Inicia o relatório. + */ + $dataRel[] = GenerateCsvFromArray($filtro); - protected function ___PreparaCsv() { - $dataRel = array(); - $filtro = $this->___FiltrosRelatorio(); + $ultClass = ''; + $somaReg = 0; + + foreach ($this->GetData()[0] as $row) { + $count++; + $row['clas_descricao'] = RemoveAcentos($row['clas_descricao']); + + if ($count != 1) { + if ($ultClass != $row['clas_descricao']) { + $dataRel[] = GenerateCsvFromArray(array("Total [$ultClass]", $somaReg)); + $dataRel[] = GenerateCsvFromArray(array('', '')); + unset($somaReg); - /* - * Inicia o relatório. - */ - $dataRel[] = GenerateCsvFromArray($filtro); - - $ultClass = ''; - $somaReg = 0; - - foreach ($this->GetData()[0] as $row) { - $count++; - $row['clas_descricao'] = RemoveAcentos($row['clas_descricao']); - - if ($count != 1) { - if ($ultClass != $row['clas_descricao']) { - $dataRel[] = GenerateCsvFromArray(array("Total [ $ultClass ]", $somaReg)); - $dataRel[] = GenerateCsvFromArray(array('', '')); - unset($somaReg); - - $dataRel[] = GenerateCsvFromArray(array($row['clas_descricao'], 'Classificacoes')); - } - } else { $dataRel[] = GenerateCsvFromArray(array($row['clas_descricao'], 'Classificacoes')); } + } else { + $dataRel[] = GenerateCsvFromArray(array($row['clas_descricao'], 'Classificacoes')); + } - $somaReg += $row["qtde"]; - $row['clit_descricao'] = RemoveAcentos($row['clit_descricao']); + $somaReg += $row["qtde"]; + $row['clit_descricao'] = RemoveAcentos($row['clit_descricao']); - // Formata linha de dados. - - $dataRel[] = GenerateCsvFromArray(array($row['clit_descricao'],$row['qtde'])); - $ultClass = $row['clas_descricao']; + // Formata linha de dados. - if (count($this->GetData()[0]) == $count) { - $dataRel[] = GenerateCsvFromArray(array("Total [ $ultClass ]", $somaReg)); - } + $dataRel[] = GenerateCsvFromArray(array($row['clit_descricao'], $row['qtde'])); + $ultClass = $row['clas_descricao']; + + if (count($this->GetData()[0]) == $count) { + $dataRel[] = GenerateCsvFromArray(array("Total [$ultClass]", $somaReg)); } - $this->___dataRel[] = $dataRel; } + $this->___dataRel[] = $dataRel; + } - protected function ___PreparaExcel() { - $dataRel = array(); - $filtro = $this->___FiltrosRelatorio(); - - /* - * Inicia o relatório. - */ + 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; - /* - * 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; - $linha = array('DADOS'); - foreach ($filtro as $values) { - list($label, $value) = explode(":", $values); - $linha[] = $value; - } - $dataRel[] = $linha; - - $dadosCabecalio = array('Descricao', 'Quantidade'); - $dadosField = array('clit_descricao', 'qtde'); - $linha = array('LABEL'); - foreach ($dadosCabecalio as $value) { - $linha[] = $value; - } - $dataRel[] = $linha; + $dadosCabecalio = array('Descricao', 'Quantidade'); + $dadosField = array('clit_descricao', 'qtde'); + $linha = array('LABEL'); + foreach ($dadosCabecalio as $value) { + $linha[] = $value; + } + $dataRel[] = $linha; - $ultClass = ''; + $ultClass = ''; - $somaReg = 0; + $somaReg = 0; - /* - * Linhas de dados. - */ - foreach ($this->GetData()[0] as $row) { - $count++; - $row['clas_descricao'] = RemoveAcentos($row['clas_descricao']); - if ($count != 1) { - if ($ultClass != $row['clas_descricao']) { - $dataRel[] = array('LABEL', "Total [ $ultClass ]", $somaReg); - $dataRel[] = array('LABEL', '', ''); - unset($somaReg); - $dataRel[] = array('LABEL', $row['clas_descricao'], 'Classificacoes'); - } - } else { + /* + * Linhas de dados. + */ + foreach ($this->GetData()[0] as $row) { + $count++; + $row['clas_descricao'] = RemoveAcentos($row['clas_descricao']); + if ($count != 1) { + if ($ultClass != $row['clas_descricao']) { + $dataRel[] = array('LABEL', "Total [$ultClass]", $somaReg); + $dataRel[] = array('LABEL', '', ''); + unset($somaReg); $dataRel[] = array('LABEL', $row['clas_descricao'], 'Classificacoes'); } - $somaReg += $row["qtde"]; - - $row['clit_descricao'] = RemoveAcentos($row['clit_descricao']); + } else { + $dataRel[] = array('LABEL', $row['clas_descricao'], 'Classificacoes'); + } + $somaReg += $row["qtde"]; - $linha = array('DADOS'); - foreach ($dadosField as $key) { - $linha[] = $row["$key"]; - } - $dataRel[] = $linha; - $ultClass = $row['clas_descricao']; + $row['clit_descricao'] = RemoveAcentos($row['clit_descricao']); - if (count($this->GetData()[0]) == $count) { - $dataRel[] = array('LABEL', "Total [ $ultClass ]", $somaReg); - } + $linha = array('DADOS'); + foreach ($dadosField as $key) { + $linha[] = $row["$key"]; } + $dataRel[] = $linha; + $ultClass = $row['clas_descricao']; - $this->___dataRel[] = $dataRel; + if (count($this->GetData()[0]) == $count) { + $dataRel[] = array('LABEL', "Total [$ultClass]", $somaReg); + } } - protected function ___PreparaGrid() { - $dataRel = array(); + $this->___dataRel[] = $dataRel; + } - /* - * Inicia o relatório. - */ - $dataRel[] = ''; + protected function ___PreparaGrid() { + $dataRel = array(); - /* - * Monta a linha de cabecalio. - */ + /* + * Inicia o relatório. + */ + $dataRel[] = '
'; - $linha = ''; - $linha .= sprintf("", 'align="center"', 'Relatório Classificação Mensal'); - $linha .= ""; - $dataRel[] = $linha; + /* + * Monta a linha de cabecalio. + */ - /* - * Verifica se retornou dados - */ - if (!IsPostBack() || !count($this->GetData()[0])) { - $dataRel[] = sprintf("
%s
%s
", count(1) - 1, (!IsPostBack() ? 'Informe os parametros e clique em consultar!' : 'Nenhum registro encontado!')); - $this->___dataRel[] = $dataRel; - return; - } - - $somaReg = 0; - $ultClass = ""; - $pass = 0; - /* - * Linhas de dados. - */ - foreach ($this->GetData()[0] as $row) { - $count ++; + $linha = ''; + $linha .= sprintf("%s", 'align="center"', 'Relatório Classificação Mensal'); + $linha .= ""; + $dataRel[] = $linha; - if ($ultClass != $row['clas_descricao']) { - if ($pass) { - $linha = 'Total [ %s ]%s'; - $dataRel[] = sprintf($linha, $ultClass, $somaReg); - $dataRel[] = ' '; - unset($somaReg); - } - - $linha = ''; - $linha .= sprintf("%s", 'align="left"', $row['clas_descricao']); - $linha .= sprintf("%s", 'align="right"', 'Classificações'); - $linha .= ""; - $dataRel[] = $linha; - } - - $ultClass = $row['clas_descricao']; - $somaReg += $row['qtde']; + /* + * Verifica se retornou dados + */ + if (!IsPostBack() || !count($this->GetData()[0])) { + $dataRel[] = sprintf("%s", count(1) - 1, (!IsPostBack() ? 'Informe os parametros e clique em consultar!' : 'Nenhum registro encontado!')); + $this->___dataRel[] = $dataRel; + return; + } - // Formata linha de dados. - $linha = ""; - $linha .= sprintf("%s", $row['clit_descricao']); - $linha .= sprintf("%s", $row['qtde']); - $linha .= ""; - $dataRel[] = $linha; - $pass = 1; - if (count($this->GetData()[0]) == $count) { + $somaReg = 0; + $ultClass = ""; + $pass = 0; + /* + * Linhas de dados. + */ + foreach ($this->GetData()[0] as $row) { + $count ++; + + if ($ultClass != $row['clas_descricao']) { + if ($pass) { $linha = 'Total [ %s ]%s'; $dataRel[] = sprintf($linha, $ultClass, $somaReg); + $dataRel[] = ' '; unset($somaReg); } + + $linha = ''; + $linha .= sprintf("%s", 'align="left"', $row['clas_descricao']); + $linha .= sprintf("%s", 'align="right"', 'Classificações'); + $linha .= ""; + $dataRel[] = $linha; } - /* - * Fecha relatorio. - */ - $dataRel[] = ''; - $this->___dataRel[] = $dataRel; - } - protected function ___PreparaHtml() { - + $ultClass = $row['clas_descricao']; + $somaReg += $row['qtde']; + + // Formata linha de dados. + $linha = ""; + $linha .= sprintf("%s", $row['clit_descricao']); + $linha .= sprintf("%s", $row['qtde']); + $linha .= ""; + $dataRel[] = $linha; + $pass = 1; + if (count($this->GetData()[0]) == $count) { + $linha = 'Total [ %s ]%s'; + $dataRel[] = sprintf($linha, $ultClass, $somaReg); + unset($somaReg); + } } + /* + * Fecha relatorio. + */ + $dataRel[] = ''; + $this->___dataRel[] = $dataRel; + } - protected function ___PreparaPdf() { - list($this->___dac, $this->___dataIni, $this->___dataFim, $this->___tipoRelatorio) = $_SESSION["SSstorageFiltros"]; - - $dados = array(); - $tables = array(); - $header = null; - - $x = 0; - $t = 0; - - $ultClass = ""; - $somaReg = 0; - - $dataHeader = array('clit_descricao' => 'C', 'qtde' => 'C'); - $widthHeader = array(130, 60); - - foreach ($this->GetData()[0] as $row) { - $count ++; - if ($x) { - if ($ultClass != $row['clas_descricao']) { - $totalizador = array("Total [ $ultClass ] ", $somaReg); - ${'table' . $t} = array($header, $dataHeader, $dados, $widthHeader, $totalizador, 0); - array_push($tables, ${"table" . $t}); - $t++; - unset($somaReg); - unset($dados); - $x = 0; - $header = array($row['clas_descricao'] => 'C', "Classificações" => 'C'); - } - } else { - $header = array($row['clas_descricao'] => 'C', "Classificações" => 'C'); - } + protected function ___PreparaHtml() { + + } + + protected function ___PreparaPdf() { + list($this->___dac, $this->___dataIni, $this->___dataFim, $this->___tipoRelatorio) = $_SESSION["SSstorageFiltros"]; + + $dados = array(); + $tables = array(); + $header = null; + + $x = 0; + $t = 0; - $somaReg += $row['qtde']; - $ultClass = $row['clas_descricao']; + $ultClass = ""; + $somaReg = 0; - $dados[$x]["clit_descricao"] = $row["clit_descricao"]; - $dados[$x]["qtde"] = $row['qtde']; - $x++; - $z++; + $dataHeader = array('clit_descricao' => 'C', 'qtde' => 'C'); + $widthHeader = array(130, 60); - if (count($this->GetData()[0]) == $count) { + foreach ($this->GetData()[0] as $row) { + $count ++; + if ($x) { + if ($ultClass != $row['clas_descricao']) { $totalizador = array("Total [ $ultClass ] ", $somaReg); ${'table' . $t} = array($header, $dataHeader, $dados, $widthHeader, $totalizador, 0); array_push($tables, ${"table" . $t}); + $t++; + unset($somaReg); + unset($dados); + $x = 0; + $header = array($row['clas_descricao'] => 'C', "Classificações" => 'C'); } + } else { + $header = array($row['clas_descricao'] => 'C', "Classificações" => 'C'); } - $this->___dataRel = $tables; - } + $somaReg += $row['qtde']; + $ultClass = $row['clas_descricao']; - 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(); + $dados[$x]["clit_descricao"] = $row["clit_descricao"]; + $dados[$x]["qtde"] = $row['qtde']; + $x++; + $z++; + + if (count($this->GetData()[0]) == $count) { + $totalizador = array("Total [ $ultClass ] ", $somaReg); + ${'table' . $t} = array($header, $dataHeader, $dados, $widthHeader, $totalizador, 0); + array_push($tables, ${"table" . $t}); } + } + + $this->___dataRel = $tables; + } + public function ExecutaRelatorio() { + global $jsStartup, $jsJQuery, $smarty; + try { /* - * Inclua os scripts necessários aqui. + * Use esta função para validar dados do formulário. */ - $jsJQuery[] = "\$('#dataIni').keypress(function(){formataDataHora(this);}) "; - $jsJQuery[] = "\$('#dataFim').keypress(function(){formataDataHora(this);}) "; + $this->___ValidaForm(); - $smarty->assign('filtros', $this->___FiltrosRelatorio()); - $smarty->assign('conteudo', $conteudoRelatorio); - $smarty->assign('msg', $this->GetMsg()); - GetTemplate($smarty, 'relatoriosGrid.tpl'); + /* + * 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'); } - $relClassMensal = new RelClassificacaoMensal($idProg, $dbcon, 1); - $relClassMensal->ExecutaRelatorio(); +} + +$relClassMensal = new RelClassificacaoMensal($idProg, $dbcon, 1); +$relClassMensal->ExecutaRelatorio(); ?> diff --git a/relatorios/callcenter/metas/metricasDiaria.php b/relatorios/callcenter/metas/metricasDiaria.php index 55ec222d..73dc2c25 100644 --- a/relatorios/callcenter/metas/metricasDiaria.php +++ b/relatorios/callcenter/metas/metricasDiaria.php @@ -1,159 +1,164 @@ Índice Nível de serviço [INS]: - É calculado pela relação entre chamadas atendidas até 30s pela soma - total das chamadas atendidas no pa + o total de abandonadas. - atendidas_30 / (atendidas-pa + abandonadas) * 100.0; - - $atendida30Total = $atendidas30; - $atdPaAbd = $atendidas + $abandonadas; - $ins = $atdPaAbd > 0 ? ($atendida30Total / $atdPaAbd) * 100.0 : 0; - $ins = round($ins, 2); //NS - - - -> Indice de abandono [IAB]: - É o simples percentual de chamadas abandonadas em relacao as ofereciadas. - - $iab = $oferTotal > 0 ? ($abdTotal / $oferTotal) * 100.0 : 0; - $iab = round($iab, 2); - - - -> Indice de Atendimento [IA]: - É o percentual de chamadas que foram atendidas ser ficar em espera em - realação ao total de chamdas oferecidas na fila. - - $abdEspera = $abdTotal + $espera; - $ia = !$oferTotal ? 0 : (($oferTotal - $abdEspera) * 100.0) / $oferTotal; - $ia = round($ia, 2); - - * ************************************************************************* - * Copyright (c) 2018, Simples IP - * *************************************************************************/ - - include_once 'util/relatoriosBase.php'; - - class RelMetricasDiaria extends Relatorios { - - private $___servico; - private $___tmpGrid; - private $___tmpSla; - - public function __construct($idProg, $dbcon, $incDac) { - parent::__construct($idProg, $dbcon, $incDac); - $this->___dac = isset($_POST['listaDacs']) ? $_POST['listaDacs'] : 0; - $this->___servico = isset($_POST["listaServico"]) ? $_POST["listaServico"] : 0; - $this->___tmpGrid = isset($_POST["tmpGrid"]) ? $_POST["tmpGrid"] : 30; - $this->___tmpSla = isset($_POST["tmpSla"]) ? $_POST["tmpSla"] : 30; - } - - function ___FiltrosRelatorio() { - global $dbcon; - if ($this->___media != MEDIA_PRINT_GRID) { - /* - * Recupera os filtros da sess�o do usu�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ítico' : 'Sinté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 = 'Clique aqui para imprimir!'; - $prtHtml = "\"Clique"; - $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'); - } +/* * ************************************************************************* + * + * Metricas Diaria + * Autor + * Lucas Awade + * + * ************************************************************************* + Definições do Projeto + Nome: RelMetricasDiaria + Data início: 23/08/2018 + Equipe: Amarildo Pereira + Descrição: + Este relatório tem a finalidade de agregar valores e gerar resultados + em outros afins, com isso são utilizadas formulas para a construção dos + mesmos. + + Formulas: + -> Índice Nível de serviço [INS]: + É calculado pela relação entre chamadas atendidas até 30s pela soma + total das chamadas atendidas no pa + o total de abandonadas. + atendidas_30 / (atendidas-pa + abandonadas) * 100.0; + + $atendida30Total = $atendidas30; + $atdPaAbd = $atendidas + $abandonadas; + $ins = $atdPaAbd > 0 ? ($atendida30Total / $atdPaAbd) * 100.0 : 0; + $ins = round($ins, 2); //NS + + + -> Indice de abandono [IAB]: + É o simples percentual de chamadas abandonadas em relacao as ofereciadas. + + $iab = $oferTotal > 0 ? ($abdTotal / $oferTotal) * 100.0 : 0; + $iab = round($iab, 2); + + + -> Indice de Atendimento [IA]: + É o percentual de chamadas que foram atendidas ser ficar em espera em + realação ao total de chamdas oferecidas na fila. + + $abdEspera = $abdTotal + $espera; + $ia = !$oferTotal ? 0 : (($oferTotal - $abdEspera) * 100.0) / $oferTotal; + $ia = round($ia, 2); + + * ************************************************************************* + * Copyright (c) 2018, Simples IP + * ************************************************************************ */ + +include_once 'util/relatoriosBase.php'; + +class RelMetricasDiaria extends Relatorios { + + private $___servico; + private $___tmpGrid; + private $___tmpSla; + + public function __construct($idProg, $dbcon, $incDac) { + parent::__construct($idProg, $dbcon, $incDac); + $this->___dac = isset($_POST['listaDacs']) ? $_POST['listaDacs'] : 0; + $this->___servico = isset($_POST["listaServico"]) ? $_POST["listaServico"] : 0; + $this->___tmpGrid = isset($_POST["tmpGrid"]) ? $_POST["tmpGrid"] : 30; + $this->___tmpSla = isset($_POST["tmpSla"]) ? $_POST["tmpSla"] : 30; + } - $tipoRel = !$this->___tipoRelatorio ? '' : 'checked="checked"'; - /* - * Personalise esta fun��o se necessitar de outras op��es de filtro. - */ - $filtro = ''; + function ___FiltrosRelatorio() { + global $dbcon; + if ($this->___media != MEDIA_PRINT_GRID) { /* - * Rotulos. + * Recupera os filtros da sess�o do usu�rio. */ - $filtro .= ''; - if ($this->GetIncDac()) - $filtro .= ''; - $filtro .= ''; - $filtro .= ''; - $filtro .= ''; - $filtro .= ''; - $filtro .= ''; - $filtro .= ''; - $filtro .= ''; + list($this->___dac, $this->___dataIni, $this->___dataFim, $this->___tipoRelatorio) = $_SESSION["SSstorageFiltros"]; - /* - * Valores. - */ - $filtro .= ''; - if ($this->GetIncDac()) - $filtro .= sprintf('', $dacs); - $filtro .= ''; - $filtro .= ''; - $filtro .= sprintf('', GetIdentRota($dbcon, $this->___servico)); - $filtro .= sprintf('', GetTempo($dbcon, "tmpGrid", "Minutos", $this->___tmpGrid)); - $filtro .= sprintf('', GetTempo($dbcon, "tmpSla", "Segundos", $this->___tmpSla)); - $filtro .= ''; - $filtro .= ''; - $filtro .= ''; - $filtro .= '
FilaData InicialData Final ServiçoTempo GridTempo Sla 
%s%s%s%s%s
'; + 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ítico' : 'Sintético')); + } - /* - * Guarda os filtros passados para recuperar na emiss�o dos relat?ios para impress�o. - */ - $_SESSION["SSstorageFiltros"] = array($this->___dac, $this->___dataIni, $this->___dataFim, $this->___tipoRelatorio); + $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; + } - return sprintf($filtro, $this->___dataIni, $this->___dataFim, $lkPrint); + if ($this->GetIncDac()) { + $dacs = GetDac($this->GetDbCon(), $this->___dac, "", 0, 1, 0, 0, 1); } - protected function ___GetDadosDb() { - $sla = $this->___tmpSla; - $tmp = $this->___tmpGrid; - $dataIni = FormatDtMssql($this->___dataIni); - $dataFim = FormatDtMssql($this->___dataFim); - //$dataCorte = GetDataRelatorio(); - $dac = $this->___dac; - $servico = $this->___servico; + $lkPrint = ""; + if ($this->___dataCount) { + $prt = 'Clique aqui para imprimir!'; + $prtHtml = "\"Clique"; + $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��o se necessitar de outras op��es de filtro. + */ + $filtro = ''; + /* + * Rotulos. + */ + $filtro .= ''; + if ($this->GetIncDac()) + $filtro .= ''; + $filtro .= ''; + $filtro .= ''; + if (GetUsoServico()) { + $filtro .= ''; + } + $filtro .= ''; + $filtro .= ''; + $filtro .= ''; + $filtro .= ''; + + /* + * Valores. + */ + $filtro .= ''; + if ($this->GetIncDac()) + $filtro .= sprintf('', $dacs); + $filtro .= ''; + $filtro .= ''; + if (GetUsoServico()) { + $filtro .= sprintf('', GetIdentRota($dbcon, $this->___servico)); + } + $filtro .= sprintf('', GetTempo($dbcon, "tmpGrid", "Minutos", $this->___tmpGrid)); + $filtro .= sprintf('', GetTempo($dbcon, "tmpSla", "Segundos", $this->___tmpSla)); + $filtro .= ''; + $filtro .= ''; + $filtro .= ''; + $filtro .= '
FilaData InicialData Final ServiçoTempo GridTempo Sla 
%s%s%s%s%s
'; + + /* + * Guarda os filtros passados para recuperar na emiss�o dos relat?ios para impress�o. + */ + $_SESSION["SSstorageFiltros"] = array($this->___dac, $this->___dataIni, $this->___dataFim, $this->___tipoRelatorio); + + return sprintf($filtro, $this->___dataIni, $this->___dataFim, $lkPrint); + } - $query = "SELECT HORA_INI + protected function ___GetDadosDb() { + $sla = $this->___tmpSla; + $tmp = $this->___tmpGrid; + $dataIni = FormatDtMssql($this->___dataIni); + $dataFim = FormatDtMssql($this->___dataFim); + //$dataCorte = GetDataRelatorio(); + $dac = $this->___dac; + $srv = $this->___servico; + $mostraColunaServicos = GetUsoServico() == RELATORIO_SERVICOS_HABILITA; + + $query = "SELECT " . ($mostraColunaServicos ? "serv_id," : "") . " HORA_INI ,case when(HORA_FIM = '23:59:59.999')then '00:00:00' else HORA_FIM end as HORA_FIM ,OFERECIDAS,ATENDIDAS_URA,TRANSBORDADA,TRANSBORDANDO,ABANDONADAS,ATENDIDAS_RAMAL ,ATENDIDAS_PA,ATENDIDAS_30,TRANSFERIDAS,ESPERA @@ -171,7 +176,7 @@ ,TEMPO_ATENDIMENTO ,TEMPO_ABANDONO FROM ( - SELECT hora_ini + select " . ($mostraColunaServicos ? "coalesce(serv_id, 'NAO INFORMADO') as serv_id," : "") . " hora_ini ,hora_fim ,SUM (CASE WHEN EVENTO in('ABANDON', 'COMPLETEAGENT','COMPLETECALLER','TRANSFER','TRANSBORDANDO') THEN 1 ELSE 0 END) AS OFERECIDAS ,SUM (CASE WHEN (EVENTO = 'ENTERQUEUE') AND (URA > 0) THEN 1 ELSE 0 END) AS ATENDIDAS_URA @@ -187,32 +192,32 @@ ,SUM (CASE WHEN EVENTO IN ('TRANSBORDANDO') THEN 1 ELSE 0 END) AS TRANSBORDANDO ,SUM (case when EVENTO = 'TRANSBORDADO' THEN 1 else 0 end) AS TRANSBORDADA FROM ( - SELECT c.hora_ini + select " . ($mostraColunaServicos ? "coalesce(s.serv_id, 'NAO INFORMADO') as serv_id," : "") . " c.hora_ini ,c.hora_fim,a.calldate,b.fila,b.agente,b.evento,b.param1,b.param2,b.param3,b.param4,0 as ura FROM (select hora_ini, hora_fim from pbx_hora_meta where tempo = $tmp ) c INNER JOIN pbx_bilhetes a on cast(a.calldate as time) >= c.hora_ini and cast(a.calldate as time) < c.hora_fim INNER JOIN pbx_eventos_dacs b on b.uid2 = a.uniqueid - INNER JOIN pbx_dacs d on d.nome = b.fila - WHERE b.evento in ('ABANDON','COMPLETEAGENT','COMPLETECALLER', 'CONNECT','ENTERQUEUE','TRANSFER', 'TRANSBORDANDO', 'TRANSBORDADO') + INNER JOIN pbx_dacs d on d.nome = b.fila "; + if (GetUsoServico()) { + $query .= "\nleft join pbx_servicos_registra s on s.uniqueid = a.uniqueid"; + } + $query .= "\nwhere b.evento in ('ABANDON','COMPLETEAGENT','COMPLETECALLER', 'CONNECT','ENTERQUEUE','TRANSFER', 'TRANSBORDANDO', 'TRANSBORDADO') and a.lastapp <> 'Transferred Call' and a.data_bilhete >= '$dataIni' and a.data_bilhete <= '$dataFim' and d.id = '$dac'"; - if ($servico) { - $query .= " AND uniqueid IN (SELECT uniqueid FROM pbx_servicos_registra WHERE serv_id = '$servico') "; - } - $query .= " ) as dados - group by hora_ini, hora_fim - ) as dados - order by 1,2"; - - /******************************************************************* - * - * QUERY DE TOTALIZAÇÃO - * - *******************************************************************/ - - $totalQuery = "SELECT 'Chamadas Abandonadas' as tipo + if (GetUsoServico() && $srv) { + $query .= sprintf("\nand s.serv_id = %s", QuotedStr($srv)); + } + $query .= " ) as dados group by " . ($mostraColunaServicos ? " serv_id, hora_ini, hora_fim" : " hora_ini, hora_fim") . ") as dados order by " . ($mostraColunaServicos ? " 1,2,3" : "1,2"); + + /* * ***************************************************************** + * + * QUERY DE TOTALIZAÇÃO + * + * ***************************************************************** */ + + $totalQuery = "SELECT 'Chamadas Abandonadas' as tipo ,SUM (CASE WHEN( (strtoint(param3) <= 10)) THEN 1 ELSE 0 END) as ATE_10 ,SUM (CASE WHEN( (strtoint(param3) > 10) AND (strtoint(param3) <= 20) ) THEN 1 ELSE 0 END) as ATE_20 ,SUM (CASE WHEN( (strtoint(param3) > 20) AND (strtoint(param3) <= 30) ) THEN 1 ELSE 0 END) as ATE_30 @@ -232,10 +237,10 @@ AND a.data_bilhete >= '$dataIni' AND a.data_bilhete <= '$dataFim' AND d.id = '$dac'"; - if ($servico) { - $totalQuery .= " AND uniqueid IN (SELECT uniqueid FROM pbx_servicos_registra WHERE serv_id = '$servico') "; - } - $totalQuery .= " ) AS DADOS + if (GetUsoServico() && $srv) { + $totalQuery .= sprintf(" AND exists(select '' from pbx_servicos_registra where uniqueid = a.uniqueid and serv_id = %s)", QuotedStr($srv)); + } + $totalQuery .= " ) AS DADOS UNION ALL SELECT 'Chamadas Atendidas' as tipo @@ -257,10 +262,10 @@ AND a.data_bilhete >= '$dataIni' AND a.data_bilhete <= '$dataFim' AND d.id = '$dac'"; - if ($servico) { - $totalQuery .= " AND uniqueid IN (SELECT uniqueid FROM pbx_servicos_registra WHERE serv_id = '$servico') "; - } - $totalQuery .= " ) AS DADOS + if (GetUsoServico() && $srv) { + $totalQuery .= sprintf(" AND exists(select '' from pbx_servicos_registra where uniqueid = a.uniqueid and serv_id = %s)", QuotedStr($srv)); + } + $totalQuery .= " ) AS DADOS UNION ALL SELECT 'Chamadas em Espera' as tipo @@ -283,694 +288,851 @@ AND a.data_bilhete >= '$dataIni' AND a.data_bilhete <= '$dataFim' AND d.id = '$dac'"; - if ($servico) { - $totalQuery .= " AND substring(clid,2,3) = '$servico'"; - } - $totalQuery .= " ) AS DADOS ORDER BY 1"; + if (GetUsoServico() && $srv) { + $totalQuery .= sprintf(" AND exists(select '' from pbx_servicos_registra where uniqueid = a.uniqueid and serv_id = %s)", QuotedStr($srv)); + } + $totalQuery .= " ) AS DADOS ORDER BY 1"; - // Query de dados - $dataRel = array(); - $result = $this->___GetQuery($query); - while ($row = pg_fetch_array($result, null, PGSQL_ASSOC)) { - $dataRel[] = $row; - } - $this->SetData($dataRel); - - // Query de Totalização - $totalResult = $this->___GetQuery($totalQuery); - $totalRow = pg_fetch_all($totalResult); - $this->SetData($totalRow ? $totalRow : array()); - } - - protected function ___PreparaCsv() { - $dataRel = array(); - $filtro = $this->___FiltrosRelatorio(); - $dataRel[] = GenerateCsvFromArray($filtro); - - $dadosCabecalio = array( - "$this->___dataIni" . ' - ' . "$this->___dataFim", - 'Fila', 'Transbordo Entrada', 'Transbordo Saida', 'Abandonadas', 'Ramal Estático', 'Atendidas PA', - 'Atendidas Ate 30', 'Transferidas', 'Espera', 'TME', 'PA', 'Abandono', 'NS', 'IAB', 'IA' - ); - - $dadosField = array( - 'data', 'oferecidas', 'transbordada', 'transbordando', 'abandonadas', 'atendidas_ramal', - 'atendidas_pa', 'atendidas_30', 'transferidas', 'espera', 'tme', 'tma', 'tmab', 'inb', 'iab', 'ia' - ); - - $dataRel[] = GenerateCsvFromArray($dadosCabecalio); - - $somaReg = 0; - $somaFila = 0; - $somaTransbordada = 0; - $somaTransbordando = 0; - $somaAbandonadas = 0; - $somaAtendRamal = 0; - $somaAtendPA = 0; - $somaAtend30 = 0; - $somaTransferidas = 0; - $somaEspera = 0; - $somaOriginadasPA = 0; - - - foreach ($this->GetData()[0] as $row) { - - $somaReg ++; - $somaFila += $row['oferecidas']; - $somaTransbordada += $row['transbordada']; - $somaTransbordando += $row['transbordando']; - $somaAbandonadas += $row['abandonadas']; - $somaAtendRamal += $row['atendidas_ramal']; - $somaAtendPA += $row['atendidas_pa']; - $somaAtend30 += $row['atendidas_30']; - $somaTransferidas += $row['transferidas']; - $somaEspera += $row['espera']; - $somaOriginadasPA += $row['originadas_pa']; - - $somaTempoEspera += $row['tempo_espera']; - $somaTempoAtendimento += $row['tempo_atendimento']; - $somaTempoAbandono += $row['tempo_abandono']; - - // Formata linha de dados. - $linha = array(); - foreach ($dadosField as $value) { - if ($value == 'data') { - $linha[] = $row['hora_ini'] . ' as ' . $row['hora_fim']; - } else { - $linha[] = $row["$value"]; - } - } + // Query de dados + $dataRel = array(); + $result = $this->___GetQuery($query); + while ($row = pg_fetch_array($result, null, PGSQL_ASSOC)) { + $dataRel[] = $row; + } + $this->SetData($dataRel); - $dataRel[] = GenerateCsvFromArray($linha); - } + // Query de Totalização + $totalResult = $this->___GetQuery($totalQuery); + $totalRow = pg_fetch_all($totalResult); + $this->SetData($totalRow ? $totalRow : array()); + } - $somaTME = SecondToStrTime($somaEspera ? round($somaTempoEspera / $somaEspera,0) : 0); - $somaPA = SecondToStrTime($somaTempoAtendimento ? round($somaTempoAtendimento / $somaAtendPA,0) : 0); - $somaAbandono = SecondToStrTime($somaTempoAbandono ? round($somaTempoAbandono / $somaAbandonadas,0) : 0); - $mediaNS = $somaFila > 0 ? ($somaAtend30 / $somaFila) * 100.0 : 0; - $mediaIAB = $somaFila > 0 ? ($somaAbandonadas / $somaFila) * 100.0 : 0; - $mediaIA = $somaFila > 0 ? (($somaFila - ($somaAbandonadas + $somaEspera)) / $somaFila) * 100.0 : 0; - - $dataRel[] = GenerateCsvFromArray(array('Media', round($somaFila / $somaReg), round($somaTransbordada / $somaReg), round($somaTransbordando / $somaReg), round($somaAbandonadas / $somaReg), round($somaAtendRamal / $somaReg), round($somaAtendPA / $somaReg), round($somaAtend30 / $somaReg), round($somaTransferidas / $somaReg), round($somaEspera / $somaReg), $somaTME, $somaPA, $somaAbandono, round($mediaNS,2), round($mediaIAB,2), round($mediaIA,2))); - $dataRel[] = GenerateCsvFromArray(array('Total', $somaFila, $somaTransbordada, $somaTransbordando, $somaAbandonadas, $somaAtendRamal, $somaAtendPA, $somaAtend30, $somaTransferidas, $somaEspera, ' - ', ' - ', ' - ', ' - ', ' - ', ' - ')); - $dataRel[] = GenerateCsvFromArray(array('')); - - $totalCabecalio = array( - "Tempo de Espera", - "TE <= 10", - '10 < TE <= 20', - '20 < TE <= 30', - '30 < TE <= 60', - '60 < TE <= 120', - '120 < TE <= 180', - '180 < TE <= 300', - '300 < TE', - 'Total' - ); - $totalField = array( - 'tipo', - 'ate_10', - 'ate_20', - 'ate_30', - 'ate_60', - 'ate_120', - 'ate_180', - 'ate_300', - 'ate_maior', - 'total' - ); - - $dataRel[] = GenerateCsvFromArray($totalCabecalio); - - foreach ($this->GetData()[1] as $row) { - $row['total'] = $row['ate_10'] + $row['ate_20'] + $row['ate_30'] + $row['ate_60'] + $row['ate_120'] + $row['ate_180'] + $row['ate_300'] + $row['ate_maior']; - // Formata linha de dados. - $linha = array(); - foreach ($totalField as $value) { + protected function ___PreparaCsv() { + $dataRel = array(); + $filtro = $this->___FiltrosRelatorio(); + $dataRel[] = GenerateCsvFromArray($filtro); + $mostraColunaServicos = GetUsoServico() == RELATORIO_SERVICOS_HABILITA; + + $dadosCabecalio = array( + "$this->___dataIni" . ' - ' . "$this->___dataFim", + 'Fila', 'Transbordo Entrada', 'Transbordo Saida', 'Abandonadas', 'Ramal Estático', 'Atendidas PA', + 'Atendidas Ate 30', 'Transferidas', 'Espera', 'TME', 'PA', 'Abandono', 'NS', 'IAB', 'IA' + ); + + $dadosField = array( + 'data', 'oferecidas', 'transbordada', 'transbordando', 'abandonadas', 'atendidas_ramal', + 'atendidas_pa', 'atendidas_30', 'transferidas', 'espera', 'tme', 'tma', 'tmab', 'inb', 'iab', 'ia' + ); + + if ($mostraColunaServicos) { + $dadosCabecalio = array_merge(['Servico'], $dadosCabecalio); + $dadosField = array_merge(['serv_id'], $dadosField); + } + + + $dataRel[] = GenerateCsvFromArray($dadosCabecalio); + + $totalDias = 0; + $somaFila = 0; + $somaTransbordada = 0; + $somaTransbordando = 0; + $somaAbandonadas = 0; + $somaAtendRamal = 0; + $somaAtendPA = 0; + $somaAtend30 = 0; + $somaTransferidas = 0; + $somaEspera = 0; + $somaOriginadasPA = 0; + + + foreach ($this->GetData()[0] as $row) { + + $totalDias ++; + $somaFila += $row['oferecidas']; + $somaTransbordada += $row['transbordada']; + $somaTransbordando += $row['transbordando']; + $somaAbandonadas += $row['abandonadas']; + $somaAtendRamal += $row['atendidas_ramal']; + $somaAtendPA += $row['atendidas_pa']; + $somaAtend30 += $row['atendidas_30']; + $somaTransferidas += $row['transferidas']; + $somaEspera += $row['espera']; + $somaOriginadasPA += $row['originadas_pa']; + + $somaTempoEspera += $row['tempo_espera']; + $somaTempoAtendimento += $row['tempo_atendimento']; + $somaTempoAbandono += $row['tempo_abandono']; + + // Formata linha de dados. + $linha = array(); + foreach ($dadosField as $value) { + if ($value == 'data') { + $linha[] = $row['hora_ini'] . ' as ' . $row['hora_fim']; + } else { $linha[] = $row["$value"]; } + } + + $dataRel[] = GenerateCsvFromArray($linha); + } - $dataRel[] = GenerateCsvFromArray($linha); + $somaTME = SecondToStrTime($somaEspera ? round($somaTempoEspera / $somaEspera, 0) : 0); + $somaPA = SecondToStrTime($somaTempoAtendimento ? round($somaTempoAtendimento / $somaAtendPA, 0) : 0); + $somaAbandono = SecondToStrTime($somaTempoAbandono ? round($somaTempoAbandono / $somaAbandonadas, 0) : 0); + $mediaNS = $somaFila > 0 ? ($somaAtend30 / $somaFila) * 100.0 : 0; + $mediaIAB = $somaFila > 0 ? ($somaAbandonadas / $somaFila) * 100.0 : 0; + $mediaIA = $somaFila > 0 ? (($somaFila - ($somaAbandonadas + $somaEspera)) / $somaFila) * 100.0 : 0; + + if ($mostraColunaServicos) { + $dataRel[] = GenerateCsvFromArray(array('Media', '-', round($somaFila / $totalDias), round($somaTransbordada / $totalDias), round($somaTransbordando / $totalDias), round($somaAbandonadas / $totalDias), round($somaAtendRamal / $totalDias), round($somaAtendPA / $totalDias), round($somaAtend30 / $totalDias), round($somaTransferidas / $totalDias), round($somaEspera / $totalDias), $somaTME, $somaPA, $somaAbandono, round($mediaNS, 2), round($mediaIAB, 2), round($mediaIA, 2))); + $dataRel[] = GenerateCsvFromArray(array('Total', '-', $somaFila, $somaTransbordada, $somaTransbordando, $somaAbandonadas, $somaAtendRamal, $somaAtendPA, $somaAtend30, $somaTransferidas, $somaEspera, ' - ', ' - ', ' - ', ' - ', ' - ', ' - ')); + } else { + $dataRel[] = GenerateCsvFromArray(array('Media', round($somaFila / $totalDias), round($somaTransbordada / $totalDias), round($somaTransbordando / $totalDias), round($somaAbandonadas / $totalDias), round($somaAtendRamal / $totalDias), round($somaAtendPA / $totalDias), round($somaAtend30 / $totalDias), round($somaTransferidas / $totalDias), round($somaEspera / $totalDias), $somaTME, $somaPA, $somaAbandono, round($mediaNS, 2), round($mediaIAB, 2), round($mediaIA, 2))); + $dataRel[] = GenerateCsvFromArray(array('Total', $somaFila, $somaTransbordada, $somaTransbordando, $somaAbandonadas, $somaAtendRamal, $somaAtendPA, $somaAtend30, $somaTransferidas, $somaEspera, ' - ', ' - ', ' - ', ' - ', ' - ', ' - ')); + } + $dataRel[] = GenerateCsvFromArray(array('')); + + $totalCabecalio = array( + "Tempo de Espera", + "TE <= 10", + '10 < TE <= 20', + '20 < TE <= 30', + '30 < TE <= 60', + '60 < TE <= 120', + '120 < TE <= 180', + '180 < TE <= 300', + '300 < TE', + 'Total' + ); + $totalField = array( + 'tipo', + 'ate_10', + 'ate_20', + 'ate_30', + 'ate_60', + 'ate_120', + 'ate_180', + 'ate_300', + 'ate_maior', + 'total' + ); + + $dataRel[] = GenerateCsvFromArray($totalCabecalio); + + foreach ($this->GetData()[1] as $row) { + $row['total'] = $row['ate_10'] + $row['ate_20'] + $row['ate_30'] + $row['ate_60'] + $row['ate_120'] + $row['ate_180'] + $row['ate_300'] + $row['ate_maior']; + // Formata linha de dados. + $linha = array(); + foreach ($totalField as $value) { + $linha[] = $row["$value"]; } - $dataRel[] = GenerateCsvFromArray(array('')); - $dataRel[] = GenerateCsvFromArray(array('NS', 'IAB', 'IA')); - $dataRel[] = GenerateCsvFromArray(array('Nivel de Servico','Indice de Abandono', 'Indice de Atendimento')); - $this->___dataRel[] = $dataRel; - + $dataRel[] = GenerateCsvFromArray($linha); } - protected function ___PreparaExcel() { - $nomeDac = ""; - $dataRel = array(); - $dataAgrup = array(); - $filtro = $this->___FiltrosRelatorio(); + $dataRel[] = GenerateCsvFromArray(array('')); + $dataRel[] = GenerateCsvFromArray(array('NS', 'IAB', 'IA')); + $dataRel[] = GenerateCsvFromArray(array('Nivel de Servico', 'Indice de Abandono', 'Indice de Atendimento')); + $this->___dataRel[] = $dataRel; + } - /* - * Inicia o relatório. - */ + protected function ___PreparaExcel() { + $nomeDac = ""; + $dataRel = array(); + $dataAgrup = array(); + $filtro = $this->___FiltrosRelatorio(); + $mostraColunaServicos = GetUsoServico() == RELATORIO_SERVICOS_HABILITA; + /* + * Inicia o relatório. + */ + + /* + * Cria os filtros + */ + $linha = array('LABEL'); + foreach ($filtro as $values) { + list($label, $value) = explode(":", $values); + $linha[] = $label; + } + $dataRel[] = $linha; - /* - * Cria os filtros - */ - $linha = array('LABEL'); - foreach ($filtro as $values) { - list($label, $value) = explode(":", $values); - $linha[] = $label; + $linha = array('DADOS'); + foreach ($filtro as $values) { + list($label, $value) = explode(":", $values); + $linha[] = $value; + } + + $dataRel[] = $linha; + + $dadosCabecalio = array( + "$this->___dataIni" . ' - ' . "$this->___dataFim", + 'Fila', 'Transbordo Entrada', 'Transbordo Saida', 'Abandonadas', 'Ramal Estático', 'Atendidas PA', + 'Atendidas Ate 30', 'Transferidas', 'Espera', 'TME', 'PA', 'Abandono', 'NS', 'IAB', 'IA' + ); + $dadosField = array( + 'data', 'oferecidas', 'transbordada', 'transbordando', 'abandonadas', 'atendidas_ramal', + 'atendidas_pa', 'atendidas_30', 'transferidas', 'espera', 'tme', 'tma', 'tmab', 'inb', 'iab', 'ia' + ); + + if ($mostraColunaServicos) { + $dadosCabecalio = array_merge(['Servico'], $dadosCabecalio); + $dadosField = array_merge(['serv_id'], $dadosField); + } + + $linha = array('LABEL'); + foreach ($dadosCabecalio as $value) { + $linha[] = $value; + } + $dataRel[] = $linha; + + $totalDias = 0; + $somaFila = 0; + $somaTransbordada = 0; + $somaTransbordando = 0; + $somaAbandonadas = 0; + $somaAtendRamal = 0; + $somaAtendPA = 0; + $somaAtend30 = 0; + $somaTransferidas = 0; + $somaEspera = 0; + $somaOriginadasPA = 0; + + + foreach ($this->GetData()[0] as $row) { + $totalDias ++; + $somaFila += $row['oferecidas']; + $somaTransbordada += $row['transbordada']; + $somaTransbordando += $row['transbordando']; + $somaAbandonadas += $row['abandonadas']; + $somaAtendRamal += $row['atendidas_ramal']; + $somaAtendPA += $row['atendidas_pa']; + $somaAtend30 += $row['atendidas_30']; + $somaTransferidas += $row['transferidas']; + $somaEspera += $row['espera']; + $somaOriginadasPA += $row['originadas_pa']; + + $somaTempoEspera += $row['tempo_espera']; + $somaTempoAtendimento += $row['tempo_atendimento']; + $somaTempoAbandono += $row['tempo_abandono']; + + $linha = array('DADOS'); + foreach ($dadosField as $key) { + if ($key == 'data') { + $linha[] = $row['hora_ini'] . ' as ' . $row['hora_fim']; + } else { + $linha[] = $row["$key"]; + } } $dataRel[] = $linha; + } + $somaTME = SecondToStrTime($somaEspera ? round($somaTempoEspera / $somaEspera, 0) : 0); + $somaPA = SecondToStrTime($somaTempoAtendimento ? round($somaTempoAtendimento / $somaAtendPA, 0) : 0); + $somaAbandono = SecondToStrTime($somaTempoAbandono ? round($somaTempoAbandono / $somaAbandonadas, 0) : 0); + $mediaNS = $somaFila > 0 ? ($somaAtend30 / $somaFila) * 100.0 : 0; + $mediaIAB = $somaFila > 0 ? ($somaAbandonadas / $somaFila) * 100.0 : 0; + $mediaIA = $somaFila > 0 ? (($somaFila - ($somaAbandonadas + $somaEspera)) / $somaFila) * 100.0 : 0; + + if ($mostraColunaServicos) { + $dataRel[] = array('LABEL', 'Media', ' ', round($somaFila / $totalDias), round($somaTransbordada / $totalDias), round($somaTransbordando / $totalDias), round($somaAbandonadas / $totalDias), round($somaAtendRamal / $totalDias), round($somaAtendPA / $totalDias), round($somaAtend30 / $totalDias), round($somaTransferidas / $totalDias), round($somaEspera / $totalDias), $somaTME, $somaPA, $somaAbandono, round($mediaNS, 2), round($mediaIAB, 2), round($mediaIA, 2)); + $dataRel[] = array('LABEL', 'Total', ' ', $somaFila, $somaTransbordada, $somaTransbordando, $somaAbandonadas, $somaAtendRamal, $somaAtendPA, $somaAtend30, $somaTransferidas, $somaEspera, '-', ' - ', ' - ', ' - ', ' - ', ' - '); + } else { + $dataRel[] = array('LABEL', 'Media', round($somaFila / $totalDias), round($somaTransbordada / $totalDias), round($somaTransbordando / $totalDias), round($somaAbandonadas / $totalDias), round($somaAtendRamal / $totalDias), round($somaAtendPA / $totalDias), round($somaAtend30 / $totalDias), round($somaTransferidas / $totalDias), round($somaEspera / $totalDias), $somaTME, $somaPA, $somaAbandono, round($mediaNS, 2), round($mediaIAB, 2), round($mediaIA, 2)); + $dataRel[] = array('LABEL', 'Total', $somaFila, $somaTransbordada, $somaTransbordando, $somaAbandonadas, $somaAtendRamal, $somaAtendPA, $somaAtend30, $somaTransferidas, $somaEspera, '-', ' - ', ' - ', ' - ', ' - ', ' - '); + } + + $dataRel[] = array('DADOS', ''); + + $totalCabecalio = array( + "Tempo de Espera", + "TE <= 10", + '10 < TE <= 20', + '20 < TE <= 30', + '30 < TE <= 60', + '60 < TE <= 120', + '120 < TE <= 180', + '180 < TE <= 300', + '300 < TE', + 'Total' + ); + $totalField = array( + 'tipo', + 'ate_10', + 'ate_20', + 'ate_30', + 'ate_60', + 'ate_120', + 'ate_180', + 'ate_300', + 'ate_maior', + 'total' + ); + $linha = array('LABEL'); + foreach ($totalCabecalio as $value) { + $linha[] = $value; + } + $dataRel[] = $linha; + + foreach ($this->GetData()[1] as $row) { + $row['total'] = $row['ate_10'] + $row['ate_20'] + $row['ate_30'] + $row['ate_60'] + $row['ate_120'] + $row['ate_180'] + $row['ate_300'] + $row['ate_maior']; $linha = array('DADOS'); - foreach ($filtro as $values) { - list($label, $value) = explode(":", $values); - $linha[] = $value; + foreach ($totalField as $key) { + $linha[] = $row["$key"]; } - $dataRel[] = $linha; + } - $dadosCabecalio = array( - "$this->___dataIni" . ' - ' . "$this->___dataFim", - 'Fila', 'Transbordo Entrada', 'Transbordo Saida', 'Abandonadas', 'Ramal Estático', 'Atendidas PA', - 'Atendidas Ate 30', 'Transferidas', 'Espera', 'TME', 'PA', 'Abandono', 'NS', 'IAB', 'IA' - ); - $dadosField = array( - 'data', 'oferecidas', 'transbordada', 'transbordando', 'abandonadas', 'atendidas_ramal', - 'atendidas_pa', 'atendidas_30', 'transferidas', 'espera', 'tme', 'tma', 'tmab', 'inb', 'iab', 'ia' - ); - - $linha = array('LABEL'); - foreach ($dadosCabecalio as $value) { - $linha[] = $value; + $dataRel[] = array('DADOS', ''); + $dataRel[] = array('LABEL', 'NS', 'IAB', 'IA'); + $dataRel[] = array('DADOS', 'Nivel de Servico', 'Indice Abandonadas', 'Indice Atendimento'); + + $this->___dataRel[] = $dataRel; + } + + protected function ___PreparaGrid() { + $dataRel = array(); + $mostraColunaServicos = GetUsoServico() == RELATORIO_SERVICOS_HABILITA; + + $dadosCabecalio = array( + "$this->___dataIni" . ' - ' . "$this->___dataFim" => 'align="center"', + 'Fila' => 'align="center"', + 'Transbordo Entrada' => 'align="center"', + 'Transbordo Saída' => 'align="center"', + 'Abandonadas' => 'align="center"', + 'Ramal Estático' => 'align="center"', + 'Atendidas PA' => 'align="center"', + 'Atendidas Até 30' => 'align="center"', + 'Transferidas' => 'align="center"', + 'Espera' => 'align="center"', + 'TME' => 'align="center"', + 'PA' => 'align="center"', + 'Abandono' => 'align="center"', + 'NS' => 'align="center"', + 'IAB' => 'align="center"', + 'IA' => 'align="center"' + ); + + $dadosField = array( + 'data' => 'align="center"', + 'oferecidas' => 'align="center"', + 'transbordada' => 'align="center"', + 'transbordando' => 'align="center"', + 'abandonadas' => 'align="center"', + 'atendidas_ramal' => 'align="center"', + 'atendidas_pa' => 'align="center"', + 'atendidas_30' => 'align="center"', + 'transferidas' => 'align="center"', + 'espera' => 'align="center"', + 'tme' => 'align="center"', + 'tma' => 'align="center"', + 'tmab' => 'align="center"', + 'inb' => 'align="center"', + 'iab' => 'align="center"', + 'ia' => 'align="center"' + ); + + $colspan = ""; + if ($mostraColunaServicos) { + $dadosCabecalio = array_merge(['Serviço' => 'align="center"'], $dadosCabecalio); + $dadosField = array_merge(['serv_id' => 'align="left"'], $dadosField); + $colspan = "colspan=\"2\""; + } + + /* + * Inicia o relatório. + */ + $dataRel[] = ''; + + /* + * Monta a linha de cabecalio. + */ + + $linha = ''; + $linha .= sprintf( + "" + . "" + . "" + . "", ucfirst(strftime('%B', strtotime(FormatDtMssql($this->___dataIni))))); + $linha .= ""; + $dataRel[] = $linha; + + /* + * Verifica se retornou dados + */ + if (!IsPostBack() || !count($this->GetData()[0])) { + $dataRel[] = sprintf("
%sTotal ChamadasTempo Médio (Segundos)
%s
", count($dadosCabecalio) - 1, (!IsPostBack() ? 'Informe os parametros e clique em consultar!' : 'Nenhum registro encontado!')); + $this->___dataRel[] = $dataRel; + return; + } + + $linhaC = ""; + foreach ($dadosCabecalio as $key => $value) { + $linhaC .= sprintf("%s", $value, $key); + } + $linhaC .= ""; + $dataRel[] = $linhaC; + $numDiasRelatorio = []; + $totalDias = 0; + $somaFila = 0; + $somaTransbordada = 0; + $somaTransbordando = 0; + $somaAbandonadas = 0; + $somaAtendRamal = 0; + $somaAtendPA = 0; + $somaAtend30 = 0; + $somaTransferidas = 0; + $somaEspera = 0; + $somaOriginadasPA = 0; + + $somaTempoEspera = 0; + $somaTempoAtendimento = 0; + $somaTempoAbandono = 0; + + $srv = ''; + $oldSrv = ''; + + $somaFieldServ = ['oferecidas', 'transbordada', 'transbordando', 'abandonadas', 'atendidas_fila', 'atendidas_pa', 'atendidas_30', 'transferidas', 'espera']; + $somaServ = []; + + foreach ($somaFieldServ as $value) { + $somaServ[$value] = 0; + } + + + $agrupaServico = function($row, $somaFieldServ) use(&$somaServ, &$dataRel, &$srv, &$oldSrv) { + + $style = 'style="font-weight: bold; padding: 0; margin: 0; padding-left: 6px; padding-right: 6px; background-color: #4F71C0 !important"'; + $srv = $row["serv_id"]; + if (!$oldSrv) { + $oldSrv = $srv; } - $dataRel[] = $linha; + if ((($srv != $oldSrv)) || !$row) { + $linhaTotal = sprintf('TOTAL[%s]', $style, $oldSrv); + + foreach ($somaFieldServ as $value) { + $linhaTotal .= sprintf('%s', $style, $somaServ[$value]); + } + + $dataRel[] = sprintf('%s ', $linhaTotal, $style); + $oldSrv = $srv; + $somaServico = 0; - $somaReg = 0; - $somaFila = 0; - $somaTransbordada = 0; - $somaTransbordando = 0; - $somaAbandonadas = 0; - $somaAtendRamal = 0; - $somaAtendPA = 0; - $somaAtend30 = 0; - $somaTransferidas = 0; - $somaEspera = 0; - $somaOriginadasPA = 0; - - - foreach ($this->GetData()[0] as $row) { - $somaReg ++; - $somaFila += $row['oferecidas']; - $somaTransbordada += $row['transbordada']; - $somaTransbordando += $row['transbordando']; - $somaAbandonadas += $row['abandonadas']; - $somaAtendRamal += $row['atendidas_ramal']; - $somaAtendPA += $row['atendidas_pa']; - $somaAtend30 += $row['atendidas_30']; - $somaTransferidas += $row['transferidas']; - $somaEspera += $row['espera']; - $somaOriginadasPA += $row['originadas_pa']; - - $somaTempoEspera += $row['tempo_espera']; - $somaTempoAtendimento += $row['tempo_atendimento']; - $somaTempoAbandono += $row['tempo_abandono']; - - $linha = array('DADOS'); - foreach ($dadosField as $key) { - if ($key == 'data') { - $linha[] = $row['hora_ini'] . ' as ' . $row['hora_fim']; - } else { - $linha[] = $row["$key"]; - } + foreach ($somaFieldServ as $value) { + $somaServ[$value] = 0; } - $dataRel[] = $linha; } - $somaTME = SecondToStrTime($somaEspera ? round($somaTempoEspera / $somaEspera,0) : 0); - $somaPA = SecondToStrTime($somaTempoAtendimento ? round($somaTempoAtendimento / $somaAtendPA,0) : 0); - $somaAbandono = SecondToStrTime($somaTempoAbandono ? round($somaTempoAbandono / $somaAbandonadas,0) : 0); - $mediaNS = $somaFila > 0 ? ($somaAtend30 / $somaFila) * 100.0 : 0; - $mediaIAB = $somaFila > 0 ? ($somaAbandonadas / $somaFila) * 100.0 : 0; - $mediaIA = $somaFila > 0 ? (($somaFila - ($somaAbandonadas + $somaEspera)) / $somaFila) * 100.0 : 0; - - $dataRel[] = array('LABEL', 'Media', round($somaFila / $somaReg), round($somaTransbordada / $somaReg), round($somaTransbordando / $somaReg), round($somaAbandonadas / $somaReg), round($somaAtendRamal / $somaReg), round($somaAtendPA / $somaReg), round($somaAtend30 / $somaReg), round($somaTransferidas / $somaReg), round($somaEspera / $somaReg), $somaTME, $somaPA, $somaAbandono, round($mediaNS,2), round($mediaIAB,2), round($mediaIA,2)); - $dataRel[] = array('LABEL', 'Total', $somaFila, $somaTransbordada, $somaTransbordando, $somaAbandonadas, $somaAtendRamal, $somaAtendPA, $somaAtend30, $somaTransferidas, $somaEspera, '-', ' - ', ' - ', ' - ', ' - ', ' - '); - $dataRel[] = array('DADOS', ''); - - $totalCabecalio = array( - "Tempo de Espera", - "TE <= 10", - '10 < TE <= 20', - '20 < TE <= 30', - '30 < TE <= 60', - '60 < TE <= 120', - '120 < TE <= 180', - '180 < TE <= 300', - '300 < TE', - 'Total' - ); - $totalField = array( - 'tipo', - 'ate_10', - 'ate_20', - 'ate_30', - 'ate_60', - 'ate_120', - 'ate_180', - 'ate_300', - 'ate_maior', - 'total' - ); - $linha = array('LABEL'); - foreach ($totalCabecalio as $value) { - $linha[] = $value; + + foreach ($somaFieldServ as $value) { + $somaServ[$value] += $row[$value]; } - $dataRel[] = $linha; + }; - foreach ($this->GetData()[1] as $row) { - $row['total'] = $row['ate_10'] + $row['ate_20'] + $row['ate_30'] + $row['ate_60'] + $row['ate_120'] + $row['ate_180'] + $row['ate_300'] + $row['ate_maior']; + /* + * Linhas de dados. + */ + foreach ($this->GetData()[0] as $row) { - $linha = array('DADOS'); - foreach ($totalField as $key) { - $linha[] = $row["$key"]; + if ($mostraColunaServicos) { + $agrupaServico($row, $somaFieldServ); + } + $numDiasRelatorio[($row['hora_ini'] . ' ' . substr($row['hora_fim'], 0, 8))] = 1; + + $somaFila += $row['oferecidas']; + $somaTransbordada += $row['transbordada']; + $somaTransbordando += $row['transbordando']; + $somaAbandonadas += $row['abandonadas']; + $somaAtendRamal += $row['atendidas_ramal']; + $somaAtendPA += $row['atendidas_pa']; + $somaAtend30 += $row['atendidas_30']; + $somaTransferidas += $row['transferidas']; + $somaEspera += $row['espera']; + $somaOriginadasPA += $row['originadas_pa']; + + $somaTempoEspera += $row['tempo_espera']; + $somaTempoAtendimento += $row['tempo_atendimento']; + $somaTempoAbandono += $row['tempo_abandono']; + + $dataRelIni = FormatDtMssql($this->___dataIni); + $dataRelFim = FormatDtMssql($this->___dataFim); + $link = "javaScript:NovaJanela('index.php?idProg=229&dataIni={$dataRelIni}+{$row['hora_ini']}&dataFim={$dataRelFim}+{$row['hora_fim']}&dacDesc={$this->___dac}')"; + $row['oferecidas'] = "{$row['oferecidas']}"; + + $linha = ""; + foreach ($dadosField as $key => $value) { + if ($key == 'data') { + $linha .= sprintf("%s", $value, $row['hora_ini'] . ' às ' . substr($row['hora_fim'], 0, 8)); + } else { + $linha .= sprintf("%s", $value, $row["$key"]); } - $dataRel[] = $linha; } - - $dataRel[] = array('DADOS', ''); - $dataRel[] = array('LABEL', 'NS', 'IAB', 'IA'); - $dataRel[] = array('DADOS', 'Nivel de Servico', 'Indice Abandonadas', 'Indice Atendimento'); + $linha .= ""; + $dataRel[] = $linha; + } - $this->___dataRel[] = $dataRel; + if ($mostraColunaServicos) { + $agrupaServico(false, $somaFieldServ); } - protected function ___PreparaGrid() { - $dataRel = array(); - - $dadosCabecalio = array( - "$this->___dataIni" . ' - ' . "$this->___dataFim" => 'align="center"', - 'Fila' => 'align="center"', - 'Transbordo Entrada' => 'align="center"', - 'Transbordo Saída' => 'align="center"', - 'Abandonadas' => 'align="center"', - 'Ramal Estático' => 'align="center"', - 'Atendidas PA' => 'align="center"', - 'Atendidas Até 30' => 'align="center"', - 'Transferidas' => 'align="center"', - 'Espera' => 'align="center"', - 'TME' => 'align="center"', - 'PA' => 'align="center"', - 'Abandono' => 'align="center"', - 'NS' => 'align="center"', - 'IAB' => 'align="center"', - 'IA' => 'align="center"' - ); - $dadosField = array( - 'data' => 'align="center"', - 'oferecidas' => 'align="center"', - 'transbordada' => 'align="center"', - 'transbordando' => 'align="center"', - 'abandonadas' => 'align="center"', - 'atendidas_ramal' => 'align="center"', - 'atendidas_pa' => 'align="center"', - 'atendidas_30' => 'align="center"', - 'transferidas' => 'align="center"', - 'espera' => 'align="center"', - 'tme' => 'align="center"', - 'tma' => 'align="center"', - 'tmab' => 'align="center"', - 'inb' => 'align="center"', - 'iab' => 'align="center"', - 'ia' => 'align="center"' - ); + $totalDias = count($numDiasRelatorio); - /* - * Inicia o relatório. - */ - $dataRel[] = ''; + $somaTME = SecondToStrTime($somaEspera ? round($somaTempoEspera / $somaEspera, 0) : 0); + $somaPA = SecondToStrTime($somaTempoAtendimento ? round($somaTempoAtendimento / $somaAtendPA, 0) : 0); + $somaAbandono = SecondToStrTime($somaTempoAbandono ? round($somaTempoAbandono / $somaAbandonadas, 0) : 0); + $mediaNS = $somaFila > 0 ? ($somaAtend30 / $somaFila) * 100.0 : 0; + $mediaIAB = $somaFila > 0 ? ($somaAbandonadas / $somaFila) * 100.0 : 0; + $mediaIA = $somaFila > 0 ? (($somaFila - ($somaAbandonadas + $somaEspera)) / $somaFila) * 100.0 : 0; - /* - * Monta a linha de cabecalio. - */ + $colspan = 1; + if ($mostraColunaServicos) { + $colspan = 2; + } - $linha = ''; - $linha .= sprintf( - "" - . "" - . "" - . "", ucfirst(strftime('%B', strtotime(FormatDtMssql($this->___dataIni))))); + $linhaTotal = ''; + $dataRel[] = sprintf($linhaTotal, round($somaFila / $totalDias), round($somaTransbordada / $totalDias), round($somaTransbordando / $totalDias), round($somaAbandonadas / $totalDias), round($somaAtendRamal / $totalDias), round($somaAtendPA / $totalDias), round($somaAtend30 / $totalDias), round($somaTransferidas / $totalDias), round($somaEspera / $totalDias), $somaTME, $somaPA, $somaAbandono, round($mediaNS, 2), round($mediaIAB, 2), round($mediaIA, 2)); + + $linhaGeral = ''; + $dataRel[] = sprintf($linhaGeral, $somaFila, $somaTransbordada, $somaTransbordando, $somaAbandonadas, $somaAtendRamal, $somaAtendPA, $somaAtend30, $somaTransferidas, $somaEspera, $somaOriginadasPA); + /* + * Fecha relatorio. + */ + $dataRel[] = '
%sTotal ChamadasTempo Médio (Segundos)
Média%s%s%s%s%s%s%s%s%s%s%s%s %s %s %s
Total%s%s%s%s%s%s%s%s%s - - - - - -
'; + + $dataRel[] = '
'; + + + $totalCabecalio = array( + "Tempo de Espera" => 'align="center"', + "TE <= 10" => 'align="center"', + '10 < TE <= 20' => 'align="center"', + '20 < TE <= 30' => 'align="center"', + '30 < TE <= 60' => 'align="center"', + '60 < TE <= 120' => 'align="center"', + '120 < TE <= 180' => 'align="center"', + '180 < TE <= 300' => 'align="center"', + '300 < TE' => 'align="center"', + 'Total' => 'align="center"' + ); + $totalField = array( + 'tipo' => 'align="center"', + 'ate_10' => 'align="center"', + 'ate_20' => 'align="center"', + 'ate_30' => 'align="center"', + 'ate_60' => 'align="center"', + 'ate_120' => 'align="center"', + 'ate_180' => 'align="center"', + 'ate_300' => 'align="center"', + 'ate_maior' => 'align="center"', + 'total' => 'align="center"' + ); + + $linhaT = ""; + foreach ($totalCabecalio as $key => $value) { + $linhaT .= sprintf("", $value, $key); + } + $linhaT .= ""; + $dataRel[] = $linhaT; + + foreach ($this->GetData()[1] as $row) { + + $row['total'] = $row['ate_10'] + $row['ate_20'] + $row['ate_30'] + $row['ate_60'] + $row['ate_120'] + $row['ate_180'] + $row['ate_300'] + $row['ate_maior']; + + $linha = ""; + foreach ($totalField as $key => $value) { + if ($key == 'tipo') { + $linha .= sprintf("", $value, $row['tipo']); + } else { + $linha .= sprintf("", $value, $row["$key"]); + } + } $linha .= ""; $dataRel[] = $linha; + } - /* - * Verifica se retornou dados - */ - if (!IsPostBack() || !count($this->GetData()[0])) { - $dataRel[] = sprintf("
%s
%s%s
%s
", count($dadosCabecalio) - 1 , (!IsPostBack() ? 'Informe os parametros e clique em consultar!' : 'Nenhum registro encontado!')); - $this->___dataRel[] = $dataRel; - return; - } + $dataRel[] = ''; + + $linha = '
'; + $linha .= ""; + $linha .= "" + . "" + . "" + . "" + . "" + . "" + . ""; + $linha .= '
Legenda
NSNível de Serviço
IABÍndice de Abandono
IAÍndice de Atendimento
'; + $dataRel[] = $linha; + + $this->___dataRel[] = $dataRel; + } + + protected function ___PreparaHtml() { + + } + + protected function ___PreparaPdf() { + list($this->___dac, $this->___dataIni, $this->___dataFim, $this->___tipoRelatorio) = $_SESSION["SSstorageFiltros"]; + $mostraColunaServicos = GetUsoServico() == RELATORIO_SERVICOS_HABILITA; + + $dadosCabecalio = array( + "$this->___dataIni" . ' - ' . "$this->___dataFim" => 'C', + 'Fila' => 'C', + 'Trans. E.' => 'C', + 'Trans. S.' => 'C', + 'ABD.' => 'C', + 'R. E.' => 'C', + 'Atd PA' => 'C', + 'Atd 30' => 'C', + 'Transf.' => 'C', + 'Espera' => 'C', + 'TME' => 'C', + 'PA' => 'C', + 'ABD' => 'C', + 'NS' => 'C', + 'IAB' => 'C', + 'IA' => 'C' + ); + + $dadosField = array( + 'hora_ini' => 'C', + 'oferecidas' => 'C', + 'transbordada' => 'C', + 'transbordando' => 'C', + 'abandonadas' => 'C', + 'atendidas_ramal' => 'C', + 'atendidas_pa' => 'C', + 'atendidas_30' => 'C', + 'transferidas' => 'C', + 'espera' => 'C', + 'tme' => 'C', + 'tma' => 'C', + 'tmab' => 'C', + 'inb' => 'C', + 'iab' => 'C', + 'ia' => 'C' + ); + + if ($mostraColunaServicos) { + $dadosCabecalio = array_merge(['Serviço' => 'C'], $dadosCabecalio); + $dadosField = array_merge(['serv_id' => 'C'], $dadosField); + } - $linhaC = ""; - foreach ($dadosCabecalio as $key => $value) { - $linhaC .= sprintf("%s", $value, $key); + $numDiasRelatorio = []; + $totalDias = 0; + $somaFila = 0; + $somaTransbordada = 0; + $somaTransbordando = 0; + $somaAbandonadas = 0; + $somaAtendRamal = 0; + $somaAtendPA = 0; + $somaAtend30 = 0; + $somaTransferidas = 0; + $somaEspera = 0; + $somaOriginadasPA = 0; + $srv = ''; + $oldSrv = ''; + $somaFieldServ = ['oferecidas', 'transbordada', 'transbordando', 'abandonadas', 'atendidas_fila', 'atendidas_pa', 'atendidas_30', 'transferidas', 'espera']; + $somaServ = []; + $linhaTotal = []; + $dadosTable = []; + + foreach ($somaFieldServ as $value) { + $somaServ[$value] = 0; + } + + + $agrupaServico = function($row, $somaFieldServ) use(&$somaServ, &$dadosTable, &$srv, &$oldSrv) { + + $srv = $row["serv_id"]; + if (!$oldSrv) { + $oldSrv = $srv; } - $linhaC .= ""; - $dataRel[] = $linhaC; - - $somaReg = 0; - $somaFila = 0; - $somaTransbordada = 0; - $somaTransbordando = 0; - $somaAbandonadas = 0; - $somaAtendRamal = 0; - $somaAtendPA = 0; - $somaAtend30 = 0; - $somaTransferidas = 0; - $somaEspera = 0; - $somaOriginadasPA = 0; - - $somaTempoEspera = 0; - $somaTempoAtendimento = 0; - $somaTempoAbandono = 0; + if ((($srv != $oldSrv)) || !$row) { + $linhaTotal['serv_id'] = sprintf('TOTAL[%s]', $oldSrv); + $linhaTotal['hora_ini'] = '-'; - /* - * Linhas de dados. - */ - foreach ($this->GetData()[0] as $row) { - $somaReg ++; - $somaFila += $row['oferecidas']; - $somaTransbordada += $row['transbordada']; - $somaTransbordando += $row['transbordando']; - $somaAbandonadas += $row['abandonadas']; - $somaAtendRamal += $row['atendidas_ramal']; - $somaAtendPA += $row['atendidas_pa']; - $somaAtend30 += $row['atendidas_30']; - $somaTransferidas += $row['transferidas']; - $somaEspera += $row['espera']; - $somaOriginadasPA += $row['originadas_pa']; - - $somaTempoEspera += $row['tempo_espera']; - $somaTempoAtendimento += $row['tempo_atendimento']; - $somaTempoAbandono += $row['tempo_abandono']; - - $dataRelIni = FormatDtMssql($this->___dataIni); - $dataRelFim = FormatDtMssql($this->___dataFim); - $link = "javaScript:NovaJanela('index.php?idProg=229&dataIni={$dataRelIni}+{$row['hora_ini']}&dataFim={$dataRelFim}+{$row['hora_fim']}&dacDesc={$this->___dac}')"; - $row['oferecidas'] = "{$row['oferecidas']}"; - - $linha = ""; - foreach ($dadosField as $key => $value) { - if ($key == 'data') { - $linha .= sprintf("%s", $value, $row['hora_ini'] . ' às ' . $row['hora_fim']); - } else { - $linha .= sprintf("%s", $value, $row["$key"]); - } + foreach ($somaFieldServ as $value) { + $linhaTotal[$value] = $somaServ[$value]; } - $linha .= ""; - $dataRel[] = $linha; - - } - - $somaTME = SecondToStrTime($somaEspera ? round($somaTempoEspera / $somaEspera,0) : 0); - $somaPA = SecondToStrTime($somaTempoAtendimento ? round($somaTempoAtendimento / $somaAtendPA,0) : 0); - $somaAbandono = SecondToStrTime($somaTempoAbandono ? round($somaTempoAbandono / $somaAbandonadas,0) : 0); - $mediaNS = $somaFila > 0 ? ($somaAtend30 / $somaFila) * 100.0 : 0; - $mediaIAB = $somaFila > 0 ? ($somaAbandonadas / $somaFila) * 100.0 : 0; - $mediaIA = $somaFila > 0 ? (($somaFila - ($somaAbandonadas + $somaEspera)) / $somaFila) * 100.0 : 0; - - $linhaTotal = 'Média%s%s%s%s%s%s%s%s%s%s%s%s %s %s %s '; - $dataRel[] = sprintf($linhaTotal, round($somaFila / $somaReg), round($somaTransbordada / $somaReg), round($somaTransbordando / $somaReg), round($somaAbandonadas / $somaReg), round($somaAtendRamal / $somaReg), round($somaAtendPA / $somaReg), round($somaAtend30 / $somaReg), round($somaTransferidas / $somaReg), round($somaEspera / $somaReg), $somaTME, $somaPA, $somaAbandono,round($mediaNS,2),round($mediaIAB,2), round($mediaIA,2)); - - $linhaGeral = 'Total%s%s%s%s%s%s%s%s%s - - - - - - '; - $dataRel[] = sprintf($linhaGeral, $somaFila, $somaTransbordada, $somaTransbordando, $somaAbandonadas, $somaAtendRamal, $somaAtendPA, $somaAtend30, $somaTransferidas, $somaEspera, $somaOriginadasPA); - /* - * Fecha relatorio. - */ - $dataRel[] = ''; - - $dataRel[] = '
'; - - - $totalCabecalio = array( - "Tempo de Espera" => 'align="center"', - "TE <= 10" => 'align="center"', - '10 < TE <= 20' => 'align="center"', - '20 < TE <= 30' => 'align="center"', - '30 < TE <= 60' => 'align="center"', - '60 < TE <= 120' => 'align="center"', - '120 < TE <= 180' => 'align="center"', - '180 < TE <= 300' => 'align="center"', - '300 < TE' => 'align="center"', - 'Total' => 'align="center"' - ); - $totalField = array( - 'tipo' => 'align="center"', - 'ate_10' => 'align="center"', - 'ate_20' => 'align="center"', - 'ate_30' => 'align="center"', - 'ate_60' => 'align="center"', - 'ate_120' => 'align="center"', - 'ate_180' => 'align="center"', - 'ate_300' => 'align="center"', - 'ate_maior' => 'align="center"', - 'total' => 'align="center"' - ); - - $linhaT = ""; - foreach ($totalCabecalio as $key => $value) { - $linhaT .= sprintf("", $value, $key); - } - $linhaT .= ""; - $dataRel[] = $linhaT; - foreach ($this->GetData()[1] as $row) { + $linhaTotal['tme'] = ' '; + $linhaTotal['tma'] = ' '; + $linhaTotal['tmab'] = ' '; + $linhaTotal['inb'] = ' '; + $linhaTotal['iab'] = ' '; + $linhaTotal['ia'] = ' '; + $linhaTotal['cor_linha_dados'] = "225"; - $row['total'] = $row['ate_10'] + $row['ate_20'] + $row['ate_30'] + $row['ate_60'] + $row['ate_120'] + $row['ate_180'] + $row['ate_300'] + $row['ate_maior']; + $dadosTable[] = $linhaTotal; + $oldSrv = $srv; + $somaServico = 0; - $linha = ""; - foreach ($totalField as $key => $value) { - if ($key == 'tipo') { - $linha .= sprintf("", $value, $row['tipo']); - } else { - $linha .= sprintf("", $value, $row["$key"]); - } + foreach ($somaFieldServ as $value) { + $somaServ[$value] = 0; } - $linha .= ""; - $dataRel[] = $linha; } - $dataRel[] = '
%s
%s%s
'; - - $linha = '
'; - $linha .= ""; - $linha .= "" - . "" - . "" - . "" - . "" - . "" - . ""; - $linha .= '
Legenda
NSNível de Serviço
IABÍndice de Abandono
IAÍndice de Atendimento
'; - $dataRel[] = $linha; + foreach ($somaFieldServ as $value) { + $somaServ[$value] += $row[$value]; + } + }; - $this->___dataRel[] = $dataRel; + + $dados = $this->GetData()[0]; + $x = 0; + foreach ($dados as $row) { + + if ($mostraColunaServicos) { + $agrupaServico($row, $somaFieldServ); + } + $numDiasRelatorio[$row['hora_ini']] = 1; + $somaFila += $row['oferecidas']; + $somaTransbordada += $row['transbordada']; + $somaTransbordando += $row['transbordando']; + $somaAbandonadas += $row['abandonadas']; + $somaAtendRamal += $row['atendidas_ramal']; + $somaAtendPA += $row['atendidas_pa']; + $somaAtend30 += $row['atendidas_30']; + $somaTransferidas += $row['transferidas']; + $somaEspera += $row['espera']; + $somaOriginadasPA += $row['originadas_pa']; + + $somaTempoEspera += $row['tempo_espera']; + $somaTempoAtendimento += $row['tempo_atendimento']; + $somaTempoAbandono += $row['tempo_abandono']; + + $row["serv_id"] = substr($row["serv_id"], 0, 20); + $row['hora_ini'] = $row['hora_ini'] . ' às ' . $row['hora_fim']; + $dadosTable[] = $row; } - protected function ___PreparaHtml() { - + if ($mostraColunaServicos) { + $agrupaServico(false, $somaFieldServ); } - protected function ___PreparaPdf() { - list($this->___dac, $this->___dataIni, $this->___dataFim, $this->___tipoRelatorio) = $_SESSION["SSstorageFiltros"]; + $totalDias = count($numDiasRelatorio); - $dadosCabecalio = array( - "$this->___dataIni" . ' - ' . "$this->___dataFim" => 'C', - 'Fila' => 'C', - 'Trans. E.' => 'C', - 'Trans. S.' => 'C', - 'Aband.' => 'C', - 'Ramal Estático' => 'C', - 'Atend. PA' => 'C', - 'Atend. 30' => 'C', - 'Transf.' => 'C', - 'Espera' => 'C', - 'TME' => 'C', - 'PA' => 'C', - 'Abandono' => 'C', - 'NS' => 'C', - 'IAB' => 'C', - 'IA' => 'C' - ); - $dadosField = array( - 'hora_ini' => 'C', - 'oferecidas' => 'C', - 'transbordada' => 'C', - 'transbordando' => 'C', - 'abandonadas' => 'C', - 'atendidas_ramal' => 'C', - 'atendidas_pa' => 'C', - 'atendidas_30' => 'C', - 'transferidas' => 'C', - 'espera' => 'C', - 'tme' => 'C', - 'tma' => 'C', - 'tmab' => 'C', - 'inb' => 'C', - 'iab' => 'C', - 'ia' => 'C' - ); - - $somaReg = 0; - $somaFila = 0; - $somaTransbordada = 0; - $somaTransbordando = 0; - $somaAbandonadas = 0; - $somaAtendRamal = 0; - $somaAtendPA = 0; - $somaAtend30 = 0; - $somaTransferidas = 0; - $somaEspera = 0; - $somaOriginadasPA = 0; - - $dados = $this->GetData()[0]; - $x = 0; - foreach ($dados as $row) { - - $somaReg ++; - $somaFila += $row['oferecidas']; - $somaTransbordada += $row['transbordada']; - $somaTransbordando += $row['transbordando']; - $somaAbandonadas += $row['abandonadas']; - $somaAtendRamal += $row['atendidas_ramal']; - $somaAtendPA += $row['atendidas_pa']; - $somaAtend30 += $row['atendidas_30']; - $somaTransferidas += $row['transferidas']; - $somaEspera += $row['espera']; - $somaOriginadasPA += $row['originadas_pa']; - - $somaTempoEspera += $row['tempo_espera']; - $somaTempoAtendimento += $row['tempo_atendimento']; - $somaTempoAbandono += $row['tempo_abandono']; - - if ($row['hora_ini']) { - $dados[$x]['hora_ini'] = $row['hora_ini'] . ' às ' . $row['hora_fim']; - } - $x++; - } - $somaTME = SecondToStrTime($somaEspera ? round($somaTempoEspera / $somaEspera,0) : 0); - $somaPA = SecondToStrTime($somaTempoAtendimento ? round($somaTempoAtendimento / $somaAtendPA,0) : 0); - $somaAbandono = SecondToStrTime($somaTempoAbandono ? round($somaTempoAbandono / $somaAbandonadas,0) : 0); - $mediaNS = $somaFila > 0 ? ($somaAtend30 / $somaFila) * 100.0 : 0; - $mediaIAB = $somaFila > 0 ? ($somaAbandonadas / $somaFila) * 100.0 : 0; - $mediaIA = $somaFila > 0 ? (($somaFila - ($somaAbandonadas + $somaEspera)) / $somaFila) * 100.0 : 0; - + $somaTME = SecondToStrTime($somaEspera ? round($somaTempoEspera / $somaEspera, 0) : 0); + $somaPA = SecondToStrTime($somaTempoAtendimento ? round($somaTempoAtendimento / $somaAtendPA, 0) : 0); + $somaAbandono = SecondToStrTime($somaTempoAbandono ? round($somaTempoAbandono / $somaAbandonadas, 0) : 0); + $mediaNS = $somaFila > 0 ? ($somaAtend30 / $somaFila) * 100.0 : 0; + $mediaIAB = $somaFila > 0 ? ($somaAbandonadas / $somaFila) * 100.0 : 0; + $mediaIA = $somaFila > 0 ? (($somaFila - ($somaAbandonadas + $somaEspera)) / $somaFila) * 100.0 : 0; + + if ($mostraColunaServicos) { + $widthHeader = array(25, 25, 8, 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 8, 8, 8); + $totaliza = array('Media', '-', round($somaFila / $totalDias), round($somaTransbordada / $totalDias), round($somaTransbordando / $totalDias), round($somaAbandonadas / $totalDias), round($somaAtendRamal / $totalDias), round($somaAtendPA / $totalDias), round($somaAtend30 / $totalDias), round($somaTransferidas / $totalDias), round($somaEspera / $totalDias), $somaTME, $somaPA, $somaAbandono, round($mediaNS, 2), round($mediaIAB, 2), round($mediaIA, 2)); + $table = array($dadosCabecalio, $dadosField, $dadosTable, $widthHeader, $totaliza, 0); + + $totalizaGeral = array('Total', '-', $somaFila, $somaTransbordada, $somaTransbordando, $somaAbandonadas, $somaAtendRamal, $somaAtendPA, $somaAtend30, $somaTransferidas, $somaEspera, '-', '-', '-', ' - ', ' - ', ' - '); + $table1 = array('', '', '', $widthHeader, $totalizaGeral, 0); + } else { $widthHeader = array(25, 8, 12, 12, 10, 15, 12, 12, 12, 12, 13, 13, 13, 8, 8, 8); - $totaliza = array('Media', round($somaFila / $somaReg), round($somaTransbordada / $somaReg), round($somaTransbordando / $somaReg), round($somaAbandonadas / $somaReg), round($somaAtendRamal / $somaReg), round($somaAtendPA / $somaReg), round($somaAtend30 / $somaReg), round($somaTransferidas / $somaReg), round($somaEspera / $somaReg), $somaTME , $somaPA , $somaAbandono , round($mediaNS,2), round($mediaIAB,2), round($mediaIA,2)); - $table = array($dadosCabecalio, $dadosField, $dados, $widthHeader, $totaliza, 0); + $totaliza = array('Media', round($somaFila / $totalDias), round($somaTransbordada / $totalDias), round($somaTransbordando / $totalDias), round($somaAbandonadas / $totalDias), round($somaAtendRamal / $totalDias), round($somaAtendPA / $totalDias), round($somaAtend30 / $totalDias), round($somaTransferidas / $totalDias), round($somaEspera / $totalDias), $somaTME, $somaPA, $somaAbandono, round($mediaNS, 2), round($mediaIAB, 2), round($mediaIA, 2)); + $table = array($dadosCabecalio, $dadosField, $dadosTable, $widthHeader, $totaliza, 0); $totalizaGeral = array('Total', $somaFila, $somaTransbordada, $somaTransbordando, $somaAbandonadas, $somaAtendRamal, $somaAtendPA, $somaAtend30, $somaTransferidas, $somaEspera, '-', '-', '-', ' - ', ' - ', ' - '); $table1 = array('', '', '', $widthHeader, $totalizaGeral, 0); + } + $totalCabecalio = array( + "Tempo de Espera" => 'C', + "TE <= 10" => 'C', + '10 < TE <= 20' => 'C', + '20 < TE <= 30' => 'C', + '30 < TE <= 60' => 'C', + '60 < TE <= 120' => 'C', + '120 < TE <= 180' => 'C', + '180 < TE <= 300' => 'C', + '300 < TE' => 'C', + 'Total' => 'C' + ); + + $totalField = array( + 'tipo' => 'C', + 'ate_10' => 'C', + 'ate_20' => 'C', + 'ate_30' => 'C', + 'ate_60' => 'C', + 'ate_120' => 'C', + 'ate_180' => 'C', + 'ate_300' => 'C', + 'ate_maior' => 'C', + 'total' => 'C' + ); + $x = 0; + $dadosTotal = $this->GetData()[1]; + foreach ($dadosTotal as $row) { + $dadosTotal[$x]['total'] = $row['ate_10'] + $row['ate_20'] + $row['ate_30'] + $row['ate_60'] + $row['ate_120'] + $row['ate_180'] + $row['ate_300'] + $row['ate_maior']; + $x++; + } + $totalHeader = array(30, 17, 17, 18, 17, 20, 20, 20, 17, 17); + $table2 = array($totalCabecalio, $totalField, $dadosTotal, $totalHeader, 0, 1); + + $legendaCabecalio = array( + "NS" => 'C', + "IAB" => 'C', + 'IA' => 'C' + ); + + $legendaField = array( + 1 => 'C', + 2 => 'C', + 3 => 'C' + ); + + $legDadosField = array(array( + 1 => 'Nível de Serviço', + 2 => 'Índice de Abandono', + 3 => 'Índice de Atendimento') + ); + + $legendaHeader = array(64, 64, 65); + $table3 = array($legendaCabecalio, $legendaField, $legDadosField, $legendaHeader, 0, 1); + + $this->___dataRel = array($table, $table1, $table2, $table3); + } - $totalCabecalio = array( - "Tempo de Espera" => 'C', - "TE <= 10" => 'C', - '10 < TE <= 20' => 'C', - '20 < TE <= 30' => 'C', - '30 < TE <= 60' => 'C', - '60 < TE <= 120' => 'C', - '120 < TE <= 180' => 'C', - '180 < TE <= 300' => 'C', - '300 < TE' => 'C', - 'Total' => 'C' - ); - - $totalField = array( - 'tipo' => 'C', - 'ate_10' => 'C', - 'ate_20' => 'C', - 'ate_30' => 'C', - 'ate_60' => 'C', - 'ate_120' => 'C', - 'ate_180' => 'C', - 'ate_300' => 'C', - 'ate_maior' => 'C', - 'total' => 'C' - ); - $x = 0; - $dadosTotal = $this->GetData()[1]; - foreach ($dadosTotal as $row) { - $dadosTotal[$x]['total'] = $row['ate_10'] + $row['ate_20'] + $row['ate_30'] + $row['ate_60'] + $row['ate_120'] + $row['ate_180'] + $row['ate_300'] + $row['ate_maior']; - $x++; - } - $totalHeader = array(30, 17, 17, 18, 17, 20, 20, 20, 17, 17); - $table2 = array($totalCabecalio, $totalField, $dadosTotal, $totalHeader, 0, 1); - - $legendaCabecalio = array( - "NS" => 'C', - "IAB" => 'C', - 'IA' => 'C' - ); - - $legendaField = array( - 1 => 'C', - 2 => 'C', - 3 => 'C' - ); - - $legDadosField = array(array( - 1 => 'Nível de Serviço', - 2 => 'Índice de Abandono', - 3 => 'Índice de Atendimento') - ); - - $legendaHeader = array(64,64,65); - $table3 = array($legendaCabecalio, $legendaField, $legDadosField, $legendaHeader, 0, 1); - - $this->___dataRel = array($table, $table1, $table2, $table3); - } - - public function ExecutaRelatorio() { - global $jsStartup, $jsJQuery, $smarty; - try { - /* - * Formata as linha da função date - */ - setlocale(LC_ALL, "pt_BR", "pt_BR.iso-8859-1", "pt_BR.utf-8", "portuguese"); - /* - * 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(); - } + public function ExecutaRelatorio() { + global $jsStartup, $jsJQuery, $smarty; + try { + /* + * Formata as linha da função date + */ + setlocale(LC_ALL, "pt_BR", "pt_BR.iso-8859-1", "pt_BR.utf-8", "portuguese"); + /* + * Use esta função para validar dados do formulário. + */ + $this->___ValidaForm(); /* - * Inclua os scripts necessários aqui. + * Recupera os dados do banco. */ - $jsJQuery[] = "\$('#dataIni').keypress(function(){formataDataHora(this);}) "; - $jsJQuery[] = "\$('#dataFim').keypress(function(){formataDataHora(this);}) "; + $this->___ConteudoRelatorio(); - $smarty->assign('filtros', $this->___FiltrosRelatorio()); - $smarty->assign('conteudo', $conteudoRelatorio); - $smarty->assign('msg', $this->GetMsg()); - GetTemplate($smarty, 'relatoriosGrid.tpl'); + /* + * 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'); } - $relMetricasDiaria = new RelMetricasDiaria($idProg, $dbcon, 1); - $relMetricasDiaria->ExecutaRelatorio(); +} +$relMetricasDiaria = new RelMetricasDiaria($idProg, $dbcon, 1); +$relMetricasDiaria->ExecutaRelatorio(); ?> diff --git a/relatorios/callcenter/metas/metricasMensal.php b/relatorios/callcenter/metas/metricasMensal.php index e4981e57..227ba6be 100644 --- a/relatorios/callcenter/metas/metricasMensal.php +++ b/relatorios/callcenter/metas/metricasMensal.php @@ -1,160 +1,165 @@ Índice Nível de serviço [INS]: - É calculado pela relação entre chamadas atendidas até 30s pela soma - total das chamadas atendidas no pa + o total de abandonadas. - atendidas_30 / (atendidas-pa + abandonadas) * 100.0; - - $atendida30Total = $atendidas30; - $atdPaAbd = $atendidas + $abandonadas; - $ins = $atdPaAbd > 0 ? ($atendida30Total / $atdPaAbd) * 100.0 : 0; - $ins = round($ins, 2); //NS - - - -> Indice de abandono [IAB]: - É o simples percentual de chamadas abandonadas em relacao as ofereciadas. - - $iab = $oferTotal > 0 ? ($abdTotal / $oferTotal) * 100.0 : 0; - $iab = round($iab, 2); - - - -> Indice de Atendimento [IA]: - É o percentual de chamadas que foram atendidas ser ficar em espera em - realação ao total de chamdas oferecidas na fila. - - $abdEspera = $abdTotal + $espera; - $ia = !$oferTotal ? 0 : (($oferTotal - $abdEspera) * 100.0) / $oferTotal; - $ia = round($ia, 2); - - * ************************************************************************* - * Copyright (c) 2018, Simples IP - * *************************************************************************/ - - include_once 'util/relatoriosBase.php'; - - class RelMetricasMensal extends Relatorios { - - private $___servico; - private $___ano; - private $___mes; - - public function __construct($idProg, $dbcon, $incDac) { - parent::__construct($idProg, $dbcon, $incDac); - $this->___dac = isset($_POST['listaDacs']) ? $_POST['listaDacs'] : 0; - $this->___servico = isset($_POST["listaServico"]) ? $_POST["listaServico"] : 0; - $this->___mes = isset($_POST['listaMes']) ? $_POST['listaMes'] : date('m'); - $this->___ano = isset($_POST['listaAno']) ? $_POST['listaAno'] : date('Y'); - } - public function ___ValidaForm() { - if (!IsPostBack()) - return; +/* * ************************************************************************* + * + * Metricas Mensal + * Autor + * Lucas Awade + * + * ************************************************************************* + Definições do Projeto + Nome: RelMetricasMensal + Data início: 23/08/2018 + Equipe: Amarildo Pereira + Descrição: + Este relatório tem a finalidade de agregar valores e gerar resultados + em outros afins, com isso são utilizadas formulas para a construção dos + mesmos. + + Formulas: + -> Índice Nível de serviço [INS]: + É calculado pela relação entre chamadas atendidas até 30s pela soma + total das chamadas atendidas no pa + o total de abandonadas. + atendidas_30 / (atendidas-pa + abandonadas) * 100.0; + + $atendida30Total = $atendidas30; + $atdPaAbd = $atendidas + $abandonadas; + $ins = $atdPaAbd > 0 ? ($atendida30Total / $atdPaAbd) * 100.0 : 0; + $ins = round($ins, 2); //NS + + + -> Indice de abandono [IAB]: + É o simples percentual de chamadas abandonadas em relacao as ofereciadas. + + $iab = $oferTotal > 0 ? ($abdTotal / $oferTotal) * 100.0 : 0; + $iab = round($iab, 2); + + + -> Indice de Atendimento [IA]: + É o percentual de chamadas que foram atendidas ser ficar em espera em + realação ao total de chamdas oferecidas na fila. + + $abdEspera = $abdTotal + $espera; + $ia = !$oferTotal ? 0 : (($oferTotal - $abdEspera) * 100.0) / $oferTotal; + $ia = round($ia, 2); + + * ************************************************************************* + * Copyright (c) 2018, Simples IP + * ************************************************************************ */ + +include_once 'util/relatoriosBase.php'; + +class RelMetricasMensal extends Relatorios { + + private $___servico; + private $___ano; + private $___mes; + + public function __construct($idProg, $dbcon, $incDac) { + parent::__construct($idProg, $dbcon, $incDac); + $this->___dac = isset($_POST['listaDacs']) ? $_POST['listaDacs'] : 0; + $this->___servico = isset($_POST["listaServico"]) ? $_POST["listaServico"] : 0; + $this->___mes = isset($_POST['listaMes']) ? $_POST['listaMes'] : date('m'); + $this->___ano = isset($_POST['listaAno']) ? $_POST['listaAno'] : date('Y'); + } - if ($this->GetIncDac() && !StrToIntDef($this->___dac)) { - GeraExcept('Informe uma Fila!'); - } + public function ___ValidaForm() { + if (!IsPostBack()) + return; + + if ($this->GetIncDac() && !StrToIntDef($this->___dac)) { + GeraExcept('Informe uma Fila!'); } + } - function ___FiltrosRelatorio() { - global $dbcon; - if ($this->___media != MEDIA_PRINT_GRID) { - /* - * Recupera os filtros da sessão do usuário. - */ - list($this->___dac, $this->___ano, $this->___mes, $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->___ano, $this->___mes, ($this->___tipoRelatorio ? 'Analítico' : 'Sintético')); - } + function ___FiltrosRelatorio() { + global $dbcon; + if ($this->___media != MEDIA_PRINT_GRID) { + /* + * Recupera os filtros da sessão do usuário. + */ + list($this->___dac, $this->___ano, $this->___mes, $this->___tipoRelatorio) = $_SESSION["SSstorageFiltros"]; - $fltCsv = array(); - if ($this->GetIncDac()) { - $fltCsv[] = 'Fila:' . GetDacDesc($this->GetDbCon(), $this->___dac); - } - // $fltCsv[] = "Ano:" . $this->___ano; - //$fltCsv[] = "Mês:" . $this->___mes; - $fltCsv[] = "Data Emissao:" . date('d/m/Y H:i:s'); - $fltCsv[] = "Emitido Por:" . GetLogin(); - return $fltCsv; + 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->___ano, $this->___mes, ($this->___tipoRelatorio ? 'Analítico' : 'Sintético')); } + $fltCsv = array(); if ($this->GetIncDac()) { - $dacs = GetDac($this->GetDbCon(), $this->___dac, "", 0, 1, 0, 0, 1); + $fltCsv[] = 'Fila:' . GetDacDesc($this->GetDbCon(), $this->___dac); } +// $fltCsv[] = "Ano:" . $this->___ano; +//$fltCsv[] = "Mês:" . $this->___mes; + $fltCsv[] = "Data Emissao:" . date('d/m/Y H:i:s'); + $fltCsv[] = "Emitido Por:" . GetLogin(); + return $fltCsv; + } - $lkPrint = ""; - if ($this->___dataCount) { - $prt = 'Clique aqui para imprimir!'; - $prtHtml = "\"Clique"; - $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'); - } + if ($this->GetIncDac()) { + $dacs = GetDac($this->GetDbCon(), $this->___dac, "", 0, 1, 0, 0, 1); + } - $tipoRel = !$this->___tipoRelatorio ? '' : 'checked="checked"'; + $lkPrint = ""; + if ($this->___dataCount) { + $prt = 'Clique aqui para imprimir!'; + $prtHtml = "\"Clique"; + $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ção se necessitar de outras operações de filtro. - */ - $filtro = ''; - /* - * Rotulos. - */ - $filtro .= ''; - $this->GetIncDac() ? $filtro .= '' : ''; - $filtro .= ''; - $filtro .= ''; - $filtro .= ''; - $filtro .= ''; - $filtro .= ''; - /* - * Valores. - */ - $filtro .= ''; - $this->GetIncDac() ? $filtro .= sprintf('', $dacs) : ''; + /* + * Personalise esta função se necessitar de outras operações de filtro. + */ + $filtro = '
FilaServiçoMêsAno 
%s
'; + /* + * Rotulos. + */ + $filtro .= ''; + $this->GetIncDac() ? $filtro .= '' : ''; + if (GetUsoServico()) { + $filtro .= ''; + } + $filtro .= ''; + $filtro .= ''; + $filtro .= ''; + $filtro .= ''; + + /* + * Valores. + */ + $filtro .= ''; + $this->GetIncDac() ? $filtro .= sprintf('', $dacs) : ''; + if (GetUsoServico()) { $filtro .= sprintf('', GetIdentRota($dbcon, $this->___servico)); - $filtro .= sprintf('', GetMes($this->___mes, '', 1)); - $filtro .= sprintf('', GetAno($this->___ano, 1)); - $filtro .= ''; - $filtro .= ''; - $filtro .= ''; - $filtro .= '
FilaServiçoMêsAno 
%s%s%s%s%s
'; - - /* - * Guarda os filtros passados para recuperar na emissão dos relatórios para impressão. - */ - $_SESSION["SSstorageFiltros"] = array($this->___dac, $this->___ano, $this->___mes, $this->___tipoRelatorio); - return sprintf($filtro, $lkPrint); } + $filtro .= sprintf('%s', GetMes($this->___mes, '', 1)); + $filtro .= sprintf('%s', GetAno($this->___ano, 1)); + $filtro .= ''; + $filtro .= '%s'; + $filtro .= ''; + $filtro .= ''; + + /* + * Guarda os filtros passados para recuperar na emissão dos relatórios para impressão. + */ + $_SESSION["SSstorageFiltros"] = array($this->___dac, $this->___ano, $this->___mes, $this->___tipoRelatorio); + return sprintf($filtro, $lkPrint); + } - protected function ___GetDadosDb() { - $iniMes = $this->___ano . '-' . $this->___mes . '-01'; - $fimMes = $this->___ano . '-' . $this->___mes . '-'.GetLastDayofMonth($this->___ano, $this->___mes); - $dac = GetDacDesc($this->GetDbCon(),$this->___dac); - $servico = $this->___servico; + protected function ___GetDadosDb() { + $iniMes = $this->___ano . '-' . $this->___mes . '-01'; + $fimMes = $this->___ano . '-' . $this->___mes . '-' . GetLastDayofMonth($this->___ano, $this->___mes); + $dac = GetDacDesc($this->GetDbCon(), $this->___dac); + $srv = $this->___servico; + $mostraColunaServicos = GetUsoServico() == RELATORIO_SERVICOS_HABILITA; - $query = "SELECT - DIA,OFERECIDAS,ATENDIDAS_URA,TRANSBORDADA,TRANSBORDANDO,ABANDONADAS + $query = "SELECT " . ($mostraColunaServicos ? "serv_id," : "") . " DIA,OFERECIDAS,ATENDIDAS_URA,TRANSBORDADA,TRANSBORDANDO,ABANDONADAS ,ATENDIDAS_FILA,ATENDIDAS_PA,ATENDIDAS_30,TRANSFERIDAS,ESPERA ,round( CASE WHEN(ESPERA = 0)THEN 0 ELSE (TEMPO_ESPERA / ESPERA) END ) * INTERVAL '1 SECOND' AS TME ,round( CASE WHEN(ATENDIDAS_PA = 0)THEN 0 ELSE (TEMPO_ATENDIMENTO / ATENDIDAS_PA)END) * INTERVAL '1 SECOND' AS TMA @@ -166,7 +171,7 @@ ,0 AS ICO,TEMPO_ESPERA,TEMPO_ATENDIMENTO,TEMPO_ABANDONO FROM ( - select extract(day from a.data_bilhete) as dia + select " . ($mostraColunaServicos ? "coalesce(s.serv_id, 'NAO INFORMADO') as serv_id," : "") . " extract(day from a.data_bilhete) as dia ,SUM (CASE WHEN EVENTO in('ABANDON', 'COMPLETEAGENT','COMPLETECALLER','TRANSFER','TRANSBORDANDO') THEN 1 ELSE 0 END) AS OFERECIDAS ,0 AS ATENDIDAS_URA ,SUM (CASE WHEN EVENTO = 'ABANDON' THEN 1 ELSE 0 END) AS ABANDONADAS @@ -180,25 +185,28 @@ ,SUM (CASE WHEN EVENTO = 'ABANDON' THEN strtoint(param3) ELSE 0 END) AS TEMPO_ABANDONO ,SUM (CASE WHEN EVENTO IN ('TRANSBORDANDO') THEN 1 ELSE 0 END) AS TRANSBORDANDO ,SUM (case when EVENTO = 'TRANSBORDADO' THEN 1 else 0 end) AS TRANSBORDADA - from pbx_bilhetes a, pbx_eventos_dacs b - where b.uid2 = a.uniqueid - AND b.evento in ('ABANDON','COMPLETEAGENT','COMPLETECALLER', 'CONNECT','ENTERQUEUE','TRANSFER', 'TRANSBORDANDO', 'TRANSBORDADO') + from pbx_bilhetes a + inner join pbx_eventos_dacs b on b.uid2 = a.uniqueid "; + if (GetUsoServico()) { + $query .= "\nleft join pbx_servicos_registra s on s.uniqueid = a.uniqueid"; + } + $query .= "\nwhere b.evento in ('ABANDON','COMPLETEAGENT','COMPLETECALLER', 'CONNECT','ENTERQUEUE','TRANSFER', 'TRANSBORDANDO', 'TRANSBORDADO') AND a.data_bilhete >= '$iniMes' AND a.data_bilhete <= '$fimMes' AND a.lastapp <> 'Transferred Call' AND b.fila = '$dac'\n"; - if ($servico) { - $query .= sprintf(" AND exists(select '' from pbx_servicos_registra where uniqueid = a.uniqueid and serv_id = %s)", QuotedStr($servico)); - } + if (GetUsoServico() && $srv) { + $query .= sprintf("\nand s.serv_id = %s", QuotedStr($srv)); + } - $query .= " group by a.data_bilhete order by a.data_bilhete) as dados"; + $query .= $mostraColunaServicos ? "\ngroup by s.serv_id, a.data_bilhete order by s.serv_id, a.data_bilhete) as dados" : "\ngroup by a.data_bilhete order by a.data_bilhete) as dados"; - /******************************************************************* - * - * QUERY DE TOTALIZAÇÃO - * - *******************************************************************/ - $totalQuery = "SELECT 'Chamadas Abandonadas' as tipo + /* * ***************************************************************** + * + * QUERY DE TOTALIZAÇÃO + * + * ***************************************************************** */ + $totalQuery = "SELECT 'Chamadas Abandonadas' as tipo ,SUM (CASE WHEN( (strtoint(param3) <= 10)) THEN 1 ELSE 0 END) as ATE_10 ,SUM (CASE WHEN( (strtoint(param3) > 10) AND (strtoint(param3) <= 20) ) THEN 1 ELSE 0 END) as ATE_20 ,SUM (CASE WHEN( (strtoint(param3) > 20) AND (strtoint(param3) <= 30) ) THEN 1 ELSE 0 END) as ATE_30 @@ -223,11 +231,10 @@ and a.data_bilhete >= '$iniMes' and a.data_bilhete <= '$fimMes' and b.fila = '$dac'\n"; - if ($servico) { - $totalQuery .= " AND substring(clid,2,3) = '$servico'"; - $totalQuery .= sprintf(" AND exists(select '' from pbx_servicos_registra where uniqueid = a.uniqueid and serv_id = %s)", QuotedStr($servico)); - } - $totalQuery .= " ) AS DADOS + if (GetUsoServico() && $srv) { + $totalQuery .= sprintf(" AND exists(select '' from pbx_servicos_registra where uniqueid = a.uniqueid and serv_id = %s)", QuotedStr($srv)); + } + $totalQuery .= " ) AS DADOS UNION ALL SELECT 'Chamadas Atendidas' as tipo @@ -248,11 +255,11 @@ AND a.data_bilhete >= '$iniMes' AND a.data_bilhete <= '$fimMes' AND b.fila = '$dac'\n"; - if ($servico) { - $totalQuery .= sprintf(" AND exists(select '' from pbx_servicos_registra where uniqueid = a.uniqueid and serv_id = %s)", QuotedStr($servico)); - } + if (GetUsoServico() && $srv) { + $totalQuery .= sprintf(" AND exists(select '' from pbx_servicos_registra where uniqueid = a.uniqueid and serv_id = %s)", QuotedStr($srv)); + } - $totalQuery .= " ) AS DADOS + $totalQuery .= " ) AS DADOS UNION ALL SELECT 'Chamadas em Espera' as tipo ,SUM (CASE WHEN( (strtoint(param1) <= 10)) THEN 1 ELSE 0 END) as ATE_10 @@ -275,1007 +282,1170 @@ AND a.data_bilhete >= '$iniMes' AND a.data_bilhete <= '$fimMes' AND b.fila = '$dac'\n"; - if ($servico) { - $totalQuery .= sprintf(" AND exists(select '' from pbx_servicos_registra where uniqueid = a.uniqueid and serv_id = %s)", QuotedStr($servico)); - } - $totalQuery .= " ) AS DADOS ORDER BY 1 "; - - $result = $this->___GetQuery($query); - $row = pg_fetch_all($result); - $this->SetData($row ? $row : array()); - - $totalResult = $this->___GetQuery($totalQuery); - $totalRow = pg_fetch_all($totalResult); - $this->SetData($totalRow ? $totalRow : array()); + if (GetUsoServico() && $srv) { + $totalQuery .= sprintf(" AND exists(select '' from pbx_servicos_registra where uniqueid = a.uniqueid and serv_id = %s)", QuotedStr($srv)); } + $totalQuery .= " ) AS DADOS ORDER BY 1 "; + + $result = $this->___GetQuery($query); + $row = pg_fetch_all($result); + $this->SetData($row ? $row : array()); + + $totalResult = $this->___GetQuery($totalQuery); + $totalRow = pg_fetch_all($totalResult); + $this->SetData($totalRow ? $totalRow : array()); + } - protected function ___PreparaCsv() { - $dataRel = array(); - $filtro = $this->___FiltrosRelatorio(); - $dataRel[] = GenerateCsvFromArray($filtro); - - $dadosCabecalio = array( - "Mes", - 'Fila', 'Transbordo Entrada', 'Transbordo Saida', 'Abandonadas', 'Ramal Estático', 'Atendidas PA', - 'Atendidas Ate 30', 'Transferidas', 'Espera', 'TME', 'PA', 'Abandono', 'NS', 'IAB', 'IA' - ); - - $dadosField = array( - 'dia', 'oferecidas', 'transbordada', 'transbordando', 'abandonadas', 'atendidas_fila', - 'atendidas_pa', 'atendidas_30', 'transferidas', 'espera', 'tme', 'tma', 'tmab', 'inb', 'iab', 'ie' - ); - - $dataRel[] = GenerateCsvFromArray($dadosCabecalio); - - $somaReg = 0; - $somaFila = 0; - $somaTransbordada = 0; - $somaTransbordando = 0; - $somaAbandonadas = 0; - $somaAtendRamal = 0; - $somaAtendPA = 0; - $somaAtend30 = 0; - $somaTransferidas = 0; - $somaEspera = 0; - $somaOriginadasPA = 0; - - - foreach ($this->GetData()[0] as $row) { - - $somaReg ++; - $somaFila += $row['oferecidas']; - $somaTransbordada += $row['transbordada']; - $somaTransbordando += $row['transbordando']; - $somaAbandonadas += $row['abandonadas']; - $somaAtendRamal += $row['atendidas_fila']; - $somaAtendPA += $row['atendidas_pa']; - $somaAtend30 += $row['atendidas_30']; - $somaTransferidas += $row['transferidas']; - $somaEspera += $row['espera']; - $somaOriginadasPA += $row['originadas_pa']; - - $somaTempoEspera += $row['tempo_espera']; - $somaTempoAtendimento += $row['tempo_atendimento']; - $somaTempoAbandono += $row['tempo_abandono']; - - // Formata linha de dados. - $linha = array(); - foreach ($dadosField as $value) { - if ($value == 'data') { - $linha[] = $row['hora_ini'] . ' as ' . $row['hora_fim']; - } else { - $linha[] = $row["$value"]; - } - } + protected function ___PreparaCsv() { + $dataRel = array(); + $filtro = $this->___FiltrosRelatorio(); + $dataRel[] = GenerateCsvFromArray($filtro); + $mostraColunaServicos = GetUsoServico() == RELATORIO_SERVICOS_HABILITA; + + $dadosCabecalio = array( + "Mes", + 'Fila', 'Transbordo Entrada', 'Transbordo Saida', 'Abandonadas', 'Ramal Estático', 'Atendidas PA', + 'Atendidas Ate 30', 'Transferidas', 'Espera', 'TME', 'PA', 'Abandono', 'NS', 'IAB', 'IA' + ); + + $dadosField = array( + 'dia', 'oferecidas', 'transbordada', 'transbordando', 'abandonadas', 'atendidas_fila', + 'atendidas_pa', 'atendidas_30', 'transferidas', 'espera', 'tme', 'tma', 'tmab', 'inb', 'iab', 'ie' + ); + + if ($mostraColunaServicos) { + $dadosCabecalio = array_merge(['Servico'], $dadosCabecalio); + $dadosField = array_merge(['serv_id'], $dadosField); + } - $dataRel[] = GenerateCsvFromArray($linha); - } - $somaTME = SecondToStrTime($somaEspera ? round($somaTempoEspera / $somaEspera,0) : 0); - $somaPA = SecondToStrTime($somaTempoAtendimento ? round($somaTempoAtendimento / $somaAtendPA,0) : 0); - $somaAbandono = SecondToStrTime($somaTempoAbandono ? round($somaTempoAbandono / $somaAbandonadas,0) : 0); - $mediaNS = $somaFila > 0 ? ($somaAtend30 / $somaFila) * 100.0 : 0; - $mediaIAB = $somaFila > 0 ? ($somaAbandonadas / $somaFila) * 100.0 : 0; - $mediaIA = $somaFila > 0 ? (($somaFila - ($somaAbandonadas + $somaEspera)) / $somaFila) * 100.0 : 0; - - $dataRel[] = GenerateCsvFromArray(array('Media', round($somaFila / $somaReg), round($somaTransbordada / $somaReg), round($somaTransbordando / $somaReg), round($somaAbandonadas / $somaReg), round($somaAtendRamal / $somaReg), round($somaAtendPA / $somaReg), round($somaAtend30 / $somaReg), round($somaTransferidas / $somaReg), round($somaEspera / $somaReg), $somaTME, $somaPA, $somaAbandono, round($mediaNS,2), round($mediaIAB,2), round($mediaIA,2))); - $dataRel[] = GenerateCsvFromArray(array('Total', $somaFila, $somaTransbordada, $somaTransbordando, $somaAbandonadas, $somaAtendRamal, $somaAtendPA, $somaAtend30, $somaTransferidas, $somaEspera, ' - ', ' - ', ' - ', ' - ', ' - ', ' - ')); - $dataRel[] = GenerateCsvFromArray(array('')); - - $totalCabecalio = array( - "Tempo de Espera", - "TE <= 10", - '10 < TE <= 20', - '20 < TE <= 30', - '30 < TE <= 60', - '60 < TE <= 120', - '120 < TE <= 180', - '180 < TE <= 300', - '300 < TE', - 'Total' - ); - $totalField = array( - 'tipo', - 'ate_10', - 'ate_20', - 'ate_30', - 'ate_60', - 'ate_120', - 'ate_180', - 'ate_300', - 'ate_maior', - 'total' - ); - - $dataRel[] = GenerateCsvFromArray($totalCabecalio); - - foreach ($this->GetData()[1] as $row) { - $row['total'] = $row['ate_10'] + $row['ate_20'] + $row['ate_30'] + $row['ate_60'] + $row['ate_120'] + $row['ate_180'] + $row['ate_300'] + $row['ate_maior']; - // Formata linha de dados. - $linha = array(); - foreach ($totalField as $value) { + $dataRel[] = GenerateCsvFromArray($dadosCabecalio); + + $somaReg = 0; + $somaFila = 0; + $somaTransbordada = 0; + $somaTransbordando = 0; + $somaAbandonadas = 0; + $somaAtendRamal = 0; + $somaAtendPA = 0; + $somaAtend30 = 0; + $somaTransferidas = 0; + $somaEspera = 0; + $somaOriginadasPA = 0; + + + foreach ($this->GetData()[0] as $row) { + + $somaReg ++; + $somaFila += $row['oferecidas']; + $somaTransbordada += $row['transbordada']; + $somaTransbordando += $row['transbordando']; + $somaAbandonadas += $row['abandonadas']; + $somaAtendRamal += $row['atendidas_fila']; + $somaAtendPA += $row['atendidas_pa']; + $somaAtend30 += $row['atendidas_30']; + $somaTransferidas += $row['transferidas']; + $somaEspera += $row['espera']; + $somaOriginadasPA += $row['originadas_pa']; + + $somaTempoEspera += $row['tempo_espera']; + $somaTempoAtendimento += $row['tempo_atendimento']; + $somaTempoAbandono += $row['tempo_abandono']; + +// Formata linha de dados. + $linha = array(); + foreach ($dadosField as $value) { + if ($value == 'data') { + $linha[] = $row['hora_ini'] . ' as ' . $row['hora_fim']; + } else { $linha[] = $row["$value"]; } + } + + $dataRel[] = GenerateCsvFromArray($linha); + } + + $somaTME = SecondToStrTime($somaEspera ? round($somaTempoEspera / $somaEspera, 0) : 0); + $somaPA = SecondToStrTime($somaTempoAtendimento ? round($somaTempoAtendimento / $somaAtendPA, 0) : 0); + $somaAbandono = SecondToStrTime($somaTempoAbandono ? round($somaTempoAbandono / $somaAbandonadas, 0) : 0); + $mediaNS = $somaFila > 0 ? ($somaAtend30 / $somaFila) * 100.0 : 0; + $mediaIAB = $somaFila > 0 ? ($somaAbandonadas / $somaFila) * 100.0 : 0; + $mediaIA = $somaFila > 0 ? (($somaFila - ($somaAbandonadas + $somaEspera)) / $somaFila) * 100.0 : 0; + + if ($mostraColunaServicos) { + $dataRel[] = GenerateCsvFromArray(array('Media', ' ', round($somaFila / $somaReg), round($somaTransbordada / $somaReg), round($somaTransbordando / $somaReg), round($somaAbandonadas / $somaReg), round($somaAtendRamal / $somaReg), round($somaAtendPA / $somaReg), round($somaAtend30 / $somaReg), round($somaTransferidas / $somaReg), round($somaEspera / $somaReg), $somaTME, $somaPA, $somaAbandono, round($mediaNS, 2), round($mediaIAB, 2), round($mediaIA, 2))); + $dataRel[] = GenerateCsvFromArray(array('Total', ' ', $somaFila, $somaTransbordada, $somaTransbordando, $somaAbandonadas, $somaAtendRamal, $somaAtendPA, $somaAtend30, $somaTransferidas, $somaEspera, ' - ', ' - ', ' - ', ' - ', ' - ', ' - ')); + } else { + $dataRel[] = GenerateCsvFromArray(array('Media', round($somaFila / $somaReg), round($somaTransbordada / $somaReg), round($somaTransbordando / $somaReg), round($somaAbandonadas / $somaReg), round($somaAtendRamal / $somaReg), round($somaAtendPA / $somaReg), round($somaAtend30 / $somaReg), round($somaTransferidas / $somaReg), round($somaEspera / $somaReg), $somaTME, $somaPA, $somaAbandono, round($mediaNS, 2), round($mediaIAB, 2), round($mediaIA, 2))); + $dataRel[] = GenerateCsvFromArray(array('Total', $somaFila, $somaTransbordada, $somaTransbordando, $somaAbandonadas, $somaAtendRamal, $somaAtendPA, $somaAtend30, $somaTransferidas, $somaEspera, ' - ', ' - ', ' - ', ' - ', ' - ', ' - ')); + } - $dataRel[] = GenerateCsvFromArray($linha); + $dataRel[] = GenerateCsvFromArray(array('')); + + $totalCabecalio = array( + "Tempo de Espera", + "TE <= 10", + '10 < TE <= 20', + '20 < TE <= 30', + '30 < TE <= 60', + '60 < TE <= 120', + '120 < TE <= 180', + '180 < TE <= 300', + '300 < TE', + 'Total' + ); + $totalField = array( + 'tipo', + 'ate_10', + 'ate_20', + 'ate_30', + 'ate_60', + 'ate_120', + 'ate_180', + 'ate_300', + 'ate_maior', + 'total' + ); + + $dataRel[] = GenerateCsvFromArray($totalCabecalio); + + foreach ($this->GetData()[1] as $row) { + $row['total'] = $row['ate_10'] + $row['ate_20'] + $row['ate_30'] + $row['ate_60'] + $row['ate_120'] + $row['ate_180'] + $row['ate_300'] + $row['ate_maior']; +// Formata linha de dados. + $linha = array(); + foreach ($totalField as $value) { + $linha[] = $row["$value"]; } - $dataRel[] = GenerateCsvFromArray(array('')); - $dataRel[] = GenerateCsvFromArray(array('NS', 'IAB', 'IA')); - $dataRel[] = GenerateCsvFromArray(array('Nivel de Servico','Indice de Abandono', 'Indice de Atendimento')); - $this->___dataRel[] = $dataRel; + $dataRel[] = GenerateCsvFromArray($linha); } - protected function ___PreparaExcel() { - $dataRel = array(); - $filtro = $this->___FiltrosRelatorio(); + $dataRel[] = GenerateCsvFromArray(array('')); + $dataRel[] = GenerateCsvFromArray(array('NS', 'IAB', 'IA')); + $dataRel[] = GenerateCsvFromArray(array('Nivel de Servico', 'Indice de Abandono', 'Indice de Atendimento')); + $this->___dataRel[] = $dataRel; + } - /* - * Inicia o relatório. - */ + protected function ___PreparaExcel() { + $dataRel = array(); + $filtro = $this->___FiltrosRelatorio(); + $mostraColunaServicos = GetUsoServico() == RELATORIO_SERVICOS_HABILITA; - /* - * Cria os filtros - */ - $linha = array('LABEL'); - foreach ($filtro as $values) { - list($label, $value) = explode(":", $values); - $linha[] = $label; + + /* + * 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( + "Mes", + 'Fila', 'Transbordo Entrada', 'Transbordo Saida', 'Abandonadas', 'Ramal Estatico', 'Atendidas PA', + 'Atendidas Ate 30', 'Transferidas', 'Espera', 'TME', 'PA', 'Abandono', 'NS', 'IAB', 'IA' + ); + $dadosField = array( + 'dia', 'oferecidas', 'transbordada', 'transbordando', 'abandonadas', 'atendidas_fila', + 'atendidas_pa', 'atendidas_30', 'transferidas', 'espera', 'tme', 'tma', 'tmab', 'inb', 'iab', 'ie' + ); + + if ($mostraColunaServicos) { + $dadosCabecalio = array_merge(['Servico'], $dadosCabecalio); + $dadosField = array_merge(['serv_id'], $dadosField); + } + + $linha = array('LABEL'); + foreach ($dadosCabecalio as $value) { + $linha[] = $value; + } + $dataRel[] = $linha; + + $somaReg = 0; + $somaFila = 0; + $somaTransbordada = 0; + $somaTransbordando = 0; + $somaAbandonadas = 0; + $somaAtendRamal = 0; + $somaAtendPA = 0; + $somaAtend30 = 0; + $somaTransferidas = 0; + $somaEspera = 0; + $somaOriginadasPA = 0; + + + foreach ($this->GetData()[0] as $row) { + $somaReg ++; + $somaFila += $row['oferecidas']; + $somaTransbordada += $row['transbordada']; + $somaTransbordando += $row['transbordando']; + $somaAbandonadas += $row['abandonadas']; + $somaAtendRamal += $row['atendidas_fila']; + $somaAtendPA += $row['atendidas_pa']; + $somaAtend30 += $row['atendidas_30']; + $somaTransferidas += $row['transferidas']; + $somaEspera += $row['espera']; + $somaOriginadasPA += $row['originadas_pa']; + + $somaTempoEspera += $row['tempo_espera']; + $somaTempoAtendimento += $row['tempo_atendimento']; + $somaTempoAbandono += $row['tempo_abandono']; + + $linha = array('DADOS'); + foreach ($dadosField as $key) { + if ($key == 'data') { + $linha[] = $row['hora_ini'] . ' as ' . $row['hora_fim']; + } else { + $linha[] = $row["$key"]; + } } $dataRel[] = $linha; + } + $somaTME = SecondToStrTime($somaEspera ? round($somaTempoEspera / $somaEspera, 0) : 0); + $somaPA = SecondToStrTime($somaTempoAtendimento ? round($somaTempoAtendimento / $somaAtendPA, 0) : 0); + $somaAbandono = SecondToStrTime($somaTempoAbandono ? round($somaTempoAbandono / $somaAbandonadas, 0) : 0); + $mediaNS = $somaFila > 0 ? ($somaAtend30 / $somaFila) * 100.0 : 0; + $mediaIAB = $somaFila > 0 ? ($somaAbandonadas / $somaFila) * 100.0 : 0; + $mediaIA = $somaFila > 0 ? (($somaFila - ($somaAbandonadas + $somaEspera)) / $somaFila) * 100.0 : 0; + + if ($mostraColunaServicos) { + $dataRel[] = array('LABEL', 'Media', ' ', round($somaFila / $somaReg), round($somaTransbordada / $somaReg), round($somaTransbordando / $somaReg), round($somaAbandonadas / $somaReg), round($somaAtendRamal / $somaReg), round($somaAtendPA / $somaReg), round($somaAtend30 / $somaReg), round($somaTransferidas / $somaReg), round($somaEspera / $somaReg), $somaTME, $somaPA, $somaAbandono, round($mediaNS, 2), round($mediaIAB, 2), round($mediaIA, 2)); + $dataRel[] = array('LABEL', 'Total', ' ', $somaFila, $somaTransbordada, $somaTransbordando, $somaAbandonadas, $somaAtendRamal, $somaAtendPA, $somaAtend30, $somaTransferidas, $somaEspera, '-', ' - ', ' - ', ' - ', ' - ', ' - '); + } else { + $dataRel[] = array('LABEL', 'Media', round($somaFila / $somaReg), round($somaTransbordada / $somaReg), round($somaTransbordando / $somaReg), round($somaAbandonadas / $somaReg), round($somaAtendRamal / $somaReg), round($somaAtendPA / $somaReg), round($somaAtend30 / $somaReg), round($somaTransferidas / $somaReg), round($somaEspera / $somaReg), $somaTME, $somaPA, $somaAbandono, round($mediaNS, 2), round($mediaIAB, 2), round($mediaIA, 2)); + $dataRel[] = array('LABEL', 'Total', $somaFila, $somaTransbordada, $somaTransbordando, $somaAbandonadas, $somaAtendRamal, $somaAtendPA, $somaAtend30, $somaTransferidas, $somaEspera, '-', ' - ', ' - ', ' - ', ' - ', ' - '); + } + + $dataRel[] = array('DADOS', ''); + + $totalCabecalio = array( + "Tempo de Espera", + "TE <= 10", + '10 < TE <= 20', + '20 < TE <= 30', + '30 < TE <= 60', + '60 < TE <= 120', + '120 < TE <= 180', + '180 < TE <= 300', + '300 < TE', + 'Total' + ); + $totalField = array( + 'tipo', + 'ate_10', + 'ate_20', + 'ate_30', + 'ate_60', + 'ate_120', + 'ate_180', + 'ate_300', + 'ate_maior', + 'total' + ); + $linha = array('LABEL'); + foreach ($totalCabecalio as $value) { + $linha[] = $value; + } + $dataRel[] = $linha; + + foreach ($this->GetData()[1] as $row) { + $row['total'] = $row['ate_10'] + $row['ate_20'] + $row['ate_30'] + $row['ate_60'] + $row['ate_120'] + $row['ate_180'] + $row['ate_300'] + $row['ate_maior']; $linha = array('DADOS'); - foreach ($filtro as $values) { - list($label, $value) = explode(":", $values); - $linha[] = $value; + foreach ($totalField as $key) { + $linha[] = $row["$key"]; } - $dataRel[] = $linha; + } + + $dataRel[] = array('DADOS', ''); + $dataRel[] = array('LABEL', 'NS', 'IAB', 'IA'); + $dataRel[] = array('DADOS', 'Nivel de Servico', 'Indice Abandonadas', 'Indice Atendimento'); + + $this->___dataRel[] = $dataRel; + } + + protected function ___PreparaGrid() { + + $dataRel = array(); + $mostraColunaServicos = GetUsoServico() == RELATORIO_SERVICOS_HABILITA; + + $dadosCabecalio = array( + "Dia" => 'align="center"', + 'Fila' => 'align="center"', + 'Transbordo Entrada' => 'align="center"', + 'Transbordo Saída' => 'align="center"', + 'Abandonadas' => 'align="center"', + 'Ramal Estático' => 'align="center"', + 'Atendidas PA' => 'align="center"', + 'Atendidas Até 30' => 'align="center"', + 'Transferidas' => 'align="center"', + 'Espera' => 'align="center"', + 'TME' => 'align="center"', + 'PA' => 'align="center"', + 'Abandono' => 'align="center"', + 'NS' => 'align="center"', + 'IAB' => 'align="center"', + 'IA' => 'align="center"' + ); + + $dadosField = array( + 'dia' => 'align="center"', + 'oferecidas' => 'align="center"', + 'transbordada' => 'align="center"', + 'transbordando' => 'align="center"', + 'abandonadas' => 'align="center"', + 'atendidas_fila' => 'align="center"', + 'atendidas_pa' => 'align="center"', + 'atendidas_30' => 'align="center"', + 'transferidas' => 'align="center"', + 'espera' => 'align="center"', + 'tme' => 'align="center"', + 'tma' => 'align="center"', + 'tmab' => 'align="center"', + 'inb' => 'align="center"', + 'iab' => 'align="center"', + 'ie' => 'align="center"' + ); + + $colspan = ""; + if ($mostraColunaServicos) { + $dadosCabecalio = array_merge(['Serviço' => 'align="center"'], $dadosCabecalio); + $dadosField = array_merge(['serv_id' => 'align="left"'], $dadosField); + $colspan = "colspan=\"2\""; + } + /* + * Inicia o relatório. + */ + $dataRel[] = ''; + + /* + * Monta a linha de cabecalio. + */ + + $linha = ''; + $linha .= "" + . "" + . "" + . ""; + $linha .= ""; + $dataRel[] = $linha; + + /* + * Verifica se retornou dados + */ + if (!IsPostBack() || !count($this->GetData()[0])) { + $dataRel[] = sprintf("
MêsTotal ChamadasTempo Médio (Segundos)
%s
", count($dadosCabecalio) - 1, (!IsPostBack() ? 'Informe os parametros e clique em consultar!' : 'Nenhum registro encontado!')); + $this->___dataRel[] = $dataRel; + return; + } + + $linhaC = ""; + foreach ($dadosCabecalio as $key => $value) { + $linhaC .= sprintf("%s", $value, $key); + } + $linhaC .= ""; + $dataRel[] = $linhaC; + + $numDiasRelatorio = []; + $totalDias = 0; + $somaFila = 0; + $somaTransbordada = 0; + $somaTransbordando = 0; + $somaAbandonadas = 0; + $somaAtendRamal = 0; + $somaAtendPA = 0; + $somaAtend30 = 0; + $somaTransferidas = 0; + $somaEspera = 0; + $somaOriginadasPA = 0; + + $somaTempoEspera = 0; + $somaTempoAtendimento = 0; + $somaTempoAbandono = 0; + + $srv = ''; + $oldSrv = ''; + + $somaFieldServ = ['oferecidas', 'transbordada', 'transbordando', 'abandonadas', 'atendidas_fila', 'atendidas_pa', 'atendidas_30', 'transferidas', 'espera']; + $somaServ = []; + + foreach ($somaFieldServ as $value) { + $somaServ[$value] = 0; + } + - $dadosCabecalio = array( - "Mes", - 'Fila', 'Transbordo Entrada', 'Transbordo Saida', 'Abandonadas', 'Ramal Estático', 'Atendidas PA', - 'Atendidas Ate 30', 'Transferidas', 'Espera', 'TME', 'PA', 'Abandono', 'NS', 'IAB', 'IA' - ); - $dadosField = array( - 'dia', 'oferecidas', 'transbordada', 'transbordando', 'abandonadas', 'atendidas_fila', - 'atendidas_pa', 'atendidas_30', 'transferidas', 'espera', 'tme', 'tma', 'tmab', 'inb', 'iab', 'ie' - ); - - $linha = array('LABEL'); - foreach ($dadosCabecalio as $value) { - $linha[] = $value; + $agrupaServico = function($row, $somaFieldServ) use(&$somaServ, &$dataRel, &$srv, &$oldSrv) { + + $style = 'style="font-weight: bold; padding: 0; margin: 0; padding-left: 6px; padding-right: 6px; background-color: #4F71C0 !important"'; + $srv = $row["serv_id"]; + if (!$oldSrv) { + $oldSrv = $srv; } - $dataRel[] = $linha; + if ((($srv != $oldSrv)) || !$row) { + $linhaTotal = sprintf('TOTAL[%s]', $style, $oldSrv); + + foreach ($somaFieldServ as $value) { + $linhaTotal .= sprintf('%s', $style, $somaServ[$value]); + } + + $dataRel[] = sprintf('%s ', $linhaTotal, $style); + $oldSrv = $srv; + $somaServico = 0; - $somaReg = 0; - $somaFila = 0; - $somaTransbordada = 0; - $somaTransbordando = 0; - $somaAbandonadas = 0; - $somaAtendRamal = 0; - $somaAtendPA = 0; - $somaAtend30 = 0; - $somaTransferidas = 0; - $somaEspera = 0; - $somaOriginadasPA = 0; - - - foreach ($this->GetData()[0] as $row) { - $somaReg ++; - $somaFila += $row['oferecidas']; - $somaTransbordada += $row['transbordada']; - $somaTransbordando += $row['transbordando']; - $somaAbandonadas += $row['abandonadas']; - $somaAtendRamal += $row['atendidas_fila']; - $somaAtendPA += $row['atendidas_pa']; - $somaAtend30 += $row['atendidas_30']; - $somaTransferidas += $row['transferidas']; - $somaEspera += $row['espera']; - $somaOriginadasPA += $row['originadas_pa']; - - $somaTempoEspera += $row['tempo_espera']; - $somaTempoAtendimento += $row['tempo_atendimento']; - $somaTempoAbandono += $row['tempo_abandono']; - - $linha = array('DADOS'); - foreach ($dadosField as $key) { - if ($key == 'data') { - $linha[] = $row['hora_ini'] . ' as ' . $row['hora_fim']; - } else { - $linha[] = $row["$key"]; - } + foreach ($somaFieldServ as $value) { + $somaServ[$value] = 0; } - $dataRel[] = $linha; } - $somaTME = SecondToStrTime($somaEspera ? round($somaTempoEspera / $somaEspera,0) : 0); - $somaPA = SecondToStrTime($somaTempoAtendimento ? round($somaTempoAtendimento / $somaAtendPA,0) : 0); - $somaAbandono = SecondToStrTime($somaTempoAbandono ? round($somaTempoAbandono / $somaAbandonadas,0) : 0); - $mediaNS = $somaFila > 0 ? ($somaAtend30 / $somaFila) * 100.0 : 0; - $mediaIAB = $somaFila > 0 ? ($somaAbandonadas / $somaFila) * 100.0 : 0; - $mediaIA = $somaFila > 0 ? (($somaFila - ($somaAbandonadas + $somaEspera)) / $somaFila) * 100.0 : 0; - - $dataRel[] = array('LABEL', 'Media', round($somaFila / $somaReg), round($somaTransbordada / $somaReg), round($somaTransbordando / $somaReg), round($somaAbandonadas / $somaReg), round($somaAtendRamal / $somaReg), round($somaAtendPA / $somaReg), round($somaAtend30 / $somaReg), round($somaTransferidas / $somaReg), round($somaEspera / $somaReg), $somaTME, $somaPA, $somaAbandono, round($mediaNS,2), round($mediaIAB,2), round($mediaIA,2)); - $dataRel[] = array('LABEL', 'Total', $somaFila, $somaTransbordada, $somaTransbordando, $somaAbandonadas, $somaAtendRamal, $somaAtendPA, $somaAtend30, $somaTransferidas, $somaEspera, '-', ' - ', ' - ', ' - ', ' - ', ' - '); - $dataRel[] = array('DADOS', ''); - - $totalCabecalio = array( - "Tempo de Espera", - "TE <= 10", - '10 < TE <= 20', - '20 < TE <= 30', - '30 < TE <= 60', - '60 < TE <= 120', - '120 < TE <= 180', - '180 < TE <= 300', - '300 < TE', - 'Total' - ); - $totalField = array( - 'tipo', - 'ate_10', - 'ate_20', - 'ate_30', - 'ate_60', - 'ate_120', - 'ate_180', - 'ate_300', - 'ate_maior', - 'total' - ); - $linha = array('LABEL'); - foreach ($totalCabecalio as $value) { - $linha[] = $value; + + foreach ($somaFieldServ as $value) { + $somaServ[$value] += $row[$value]; } - $dataRel[] = $linha; + }; - foreach ($this->GetData()[1] as $row) { - $row['total'] = $row['ate_10'] + $row['ate_20'] + $row['ate_30'] + $row['ate_60'] + $row['ate_120'] + $row['ate_180'] + $row['ate_300'] + $row['ate_maior']; - $linha = array('DADOS'); - foreach ($totalField as $key) { - $linha[] = $row["$key"]; - } - $dataRel[] = $linha; + + /* + * Linhas de dados. + */ + foreach ($this->GetData()[0] as $row) { + + if ($mostraColunaServicos) { + $agrupaServico($row, $somaFieldServ); + } + $numDiasRelatorio[$row["dia"]] = 1; + $somaFila += $row['oferecidas']; + $somaTransbordada += $row['transbordada']; + $somaTransbordando += $row['transbordando']; + $somaAbandonadas += $row['abandonadas']; + $somaAtendRamal += $row['atendidas_fila']; + $somaAtendPA += $row['atendidas_pa']; + $somaAtend30 += $row['atendidas_30']; + $somaTransferidas += $row['transferidas']; + $somaEspera += $row['espera']; + $somaOriginadasPA += $row['originadas_pa']; + + $somaTempoEspera += $row['tempo_espera']; + $somaTempoAtendimento += $row['tempo_atendimento']; + $somaTempoAbandono += $row['tempo_abandono']; + + + $linha = ""; + foreach ($dadosField as $key => $value) { + $linha .= sprintf("%s", $value, $row["$key"]); } - - $dataRel[] = array('DADOS', ''); - $dataRel[] = array('LABEL', 'NS', 'IAB', 'IA'); - $dataRel[] = array('DADOS', 'Nivel de Servico', 'Indice Abandonadas', 'Indice Atendimento'); + $linha .= ""; + $dataRel[] = $linha; + } - $this->___dataRel[] = $dataRel; + $totalDias = count($numDiasRelatorio); + + if ($mostraColunaServicos) { + $agrupaServico(false, $somaFieldServ); } - protected function ___PreparaGrid() { - $dataRel = array(); - - $dadosCabecalio = array( - "Dia" => 'align="center"', - 'Fila' => 'align="center"', - 'Transbordo Entrada' => 'align="center"', - 'Transbordo Saída' => 'align="center"', - 'Abandonadas' => 'align="center"', - 'Ramal Estático' => 'align="center"', - 'Atendidas PA' => 'align="center"', - 'Atendidas Até 30' => 'align="center"', - 'Transferidas' => 'align="center"', - 'Espera' => 'align="center"', - 'TME' => 'align="center"', - 'PA' => 'align="center"', - 'Abandono' => 'align="center"', - 'NS' => 'align="center"', - 'IAB' => 'align="center"', - 'IA' => 'align="center"' - ); - $dadosField = array( - 'dia' => 'align="center"', - 'oferecidas' => 'align="center"', - 'transbordada' => 'align="center"', - 'transbordando' => 'align="center"', - 'abandonadas' => 'align="center"', - 'atendidas_fila' => 'align="center"', - 'atendidas_pa' => 'align="center"', - 'atendidas_30' => 'align="center"', - 'transferidas' => 'align="center"', - 'espera' => 'align="center"', - 'tme' => 'align="center"', - 'tma' => 'align="center"', - 'tmab' => 'align="center"', - 'inb' => 'align="center"', - 'iab' => 'align="center"', - 'ie' => 'align="center"' - ); + $somaTME = SecondToStrTime($somaEspera ? round($somaTempoEspera / $somaEspera, 0) : 0); + $somaPA = SecondToStrTime($somaTempoAtendimento ? round($somaTempoAtendimento / $somaAtendPA, 0) : 0); + $somaAbandono = SecondToStrTime($somaTempoAbandono ? round($somaTempoAbandono / $somaAbandonadas, 0) : 0); + $mediaNS = $somaFila > 0 ? ($somaAtend30 / $somaFila) * 100.0 : 0; + $mediaIAB = $somaFila > 0 ? ($somaAbandonadas / $somaFila) * 100.0 : 0; + $mediaIA = $somaFila > 0 ? (($somaFila - ($somaAbandonadas + $somaEspera)) / $somaFila) * 100.0 : 0; - /* - * Inicia o relatório. - */ - $dataRel[] = ''; + $colspan = 1; - /* - * Monta a linha de cabecalio. - */ + if ($mostraColunaServicos) { + $colspan = 2; + } + $linhaTotal = ''; + $dataRel[] = sprintf($linhaTotal, round($somaFila / $totalDias), round($somaTransbordada / $totalDias), round($somaTransbordando / $totalDias), round($somaAbandonadas / $totalDias), round($somaAtendRamal / $totalDias), round($somaAtendPA / $totalDias), round($somaAtend30 / $totalDias), round($somaTransferidas / $totalDias), round($somaEspera / $totalDias), $somaTME, $somaPA, $somaAbandono, round($mediaNS, 2), round($mediaIAB, 2), round($mediaIA, 2)); + + $linhaGeral = ''; + $dataRel[] = sprintf($linhaGeral, $somaFila, $somaTransbordada, $somaTransbordando, $somaAbandonadas, $somaAtendRamal, $somaAtendPA, $somaAtend30, $somaTransferidas, $somaEspera, $somaOriginadasPA); + /* + * Fecha relatorio. + */ + $dataRel[] = '
Média%s%s%s%s%s%s%s%s%s%s%s%s %s %s %s
Total%s%s%s%s%s%s%s%s%s - - - - - -
'; + + $dataRel[] = '
'; + + + $totalCabecalio = array( + "Tempo de Espera" => 'align = "center"', + "TE <= 10" => 'align = "center"', + '10 < TE <= 20' => 'align = "center"', + '20 < TE <= 30' => 'align = "center"', + '30 < TE <= 60' => 'align = "center"', + '60 < TE <= 120' => 'align = "center"', + '120 < TE <= 180' => 'align = "center"', + '180 < TE <= 300' => 'align = "center"', + '300 < TE' => 'align = "center"', + 'Total' => 'align = "center"' + ); + $totalField = array( + 'tipo' => 'align = "center"', + 'ate_10' => 'align = "center"', + 'ate_20' => 'align = "center"', + 'ate_30' => 'align = "center"', + 'ate_60' => 'align = "center"', + 'ate_120' => 'align = "center"', + 'ate_180' => 'align = "center"', + 'ate_300' => 'align = "center"', + 'ate_maior' => 'align = "center"', + 'total' => 'align = "center"' + ); + + $linhaT = ""; + foreach ($totalCabecalio as $key => $value) { + $linhaT .= sprintf("", $value, $key); + } + $linhaT .= ""; + $dataRel[] = $linhaT; + + foreach ($this->GetData()[1] as $row) { - $linha = ''; - $linha .= "" - . "" - . "" - . ""; + $row['total'] = $row['ate_10'] + $row['ate_20'] + $row['ate_30'] + $row['ate_60'] + $row['ate_120'] + $row['ate_180'] + $row['ate_300'] + $row['ate_maior']; + + $linha = ""; + foreach ($totalField as $key => $value) { + if ($key == 'tipo') { + $linha .= sprintf("", $value, $row['tipo']); + } else { + $linha .= sprintf("", $value, $row["$key"]); + } + } $linha .= ""; $dataRel[] = $linha; + } - /* - * Verifica se retornou dados - */ - if (!IsPostBack() || !count($this->GetData()[0])) { - $dataRel[] = sprintf("
%s
MêsTotal ChamadasTempo Médio (Segundos)
%s%s
%s
", count($dadosCabecalio) - 1 , (!IsPostBack() ? 'Informe os parametros e clique em consultar!' : 'Nenhum registro encontado!')); - $this->___dataRel[] = $dataRel; - return; - } + $dataRel[] = ''; + + $linha = '
'; + $linha .= ""; + $linha .= "" + . "" + . "" + . "" + . "" + . "" + . ""; + $linha .= '
Legenda
NSNível de Serviço
IABÍndice de Abandono
IAÍndice de Atendimento
'; + $dataRel[] = $linha; + + $this->___dataRel[] = $dataRel; + } + + protected function ___PreparaHtml() { + + } - $linhaC = ""; - foreach ($dadosCabecalio as $key => $value) { - $linhaC .= sprintf("%s", $value, $key); + protected function ___PreparaPdf() { + + list($this->___dac, $this->___ano, $this->___mes, $this->___tipoRelatorio) = $_SESSION["SSstorageFiltros"]; + $this->___dataIni = $this->___mes; + $this->___dataFim = $this->___ano; + $mostraColunaServicos = GetUsoServico() == RELATORIO_SERVICOS_HABILITA; + + $dadosCabecalio = array( + "Mês" => 'C', + 'Fila' => 'C', + 'Tbd Etd' => 'C', + 'Tbd Sda' => 'C', + 'Abd' => 'C', + 'R Est.' => 'C', + 'Atd PA' => 'C', + 'Atd 30' => 'C', + 'Transf.' => 'C', + 'Espera' => 'C', + 'TME' => 'C', + 'PA' => 'C', + 'Abandono' => 'C', + 'NS' => 'C', + 'IAB' => 'C', + 'IA' => 'C' + ); + + $dadosField = array( + 'dia' => 'C', + 'oferecidas' => 'C', + 'transbordada' => 'C', + 'transbordando' => 'C', + 'abandonadas' => 'C', + 'atendidas_fila' => 'C', + 'atendidas_pa' => 'C', + 'atendidas_30' => 'C', + 'transferidas' => 'C', + 'espera' => 'C', + 'tme' => 'C', + 'tma' => 'C', + 'tmab' => 'C', + 'inb' => 'C', + 'iab' => 'C', + 'ie' => 'C' + ); + + if ($mostraColunaServicos) { + $dadosCabecalio = array_merge(['Serviço' => 'C'], $dadosCabecalio); + $dadosField = array_merge(['serv_id' => 'C'], $dadosField); + } + + + $numDiasRelatorio = []; + $totalDias = 0; + $somaFila = 0; + $somaTransbordada = 0; + $somaTransbordando = 0; + $somaAbandonadas = 0; + $somaAtendRamal = 0; + $somaAtendPA = 0; + $somaAtend30 = 0; + $somaTransferidas = 0; + $somaEspera = 0; + $somaOriginadasPA = 0; + $srv = ''; + $oldSrv = ''; + $somaFieldServ = ['oferecidas', 'transbordada', 'transbordando', 'abandonadas', 'atendidas_fila', 'atendidas_pa', 'atendidas_30', 'transferidas', 'espera']; + $somaServ = []; + $linhaTotal = []; + $dadosTable = []; + + foreach ($somaFieldServ as $value) { + $somaServ[$value] = 0; + } + + + $agrupaServico = function($row, $somaFieldServ) use(&$somaServ, &$dadosTable, &$srv, &$oldSrv) { + + $srv = $row["serv_id"]; + if (!$oldSrv) { + $oldSrv = $srv; } - $linhaC .= ""; - $dataRel[] = $linhaC; - - $somaReg = 0; - $somaFila = 0; - $somaTransbordada = 0; - $somaTransbordando = 0; - $somaAbandonadas = 0; - $somaAtendRamal = 0; - $somaAtendPA = 0; - $somaAtend30 = 0; - $somaTransferidas = 0; - $somaEspera = 0; - $somaOriginadasPA = 0; - - $somaTempoEspera = 0; - $somaTempoAtendimento = 0; - $somaTempoAbandono = 0; + if ((($srv != $oldSrv)) || !$row) { + $linhaTotal['serv_id'] = sprintf('TOTAL[%s]', $oldSrv); - /* - * Linhas de dados. - */ - foreach ($this->GetData()[0] as $row) { - $somaReg ++; - $somaFila += $row['oferecidas']; - $somaTransbordada += $row['transbordada']; - $somaTransbordando += $row['transbordando']; - $somaAbandonadas += $row['abandonadas']; - $somaAtendRamal += $row['atendidas_fila']; - $somaAtendPA += $row['atendidas_pa']; - $somaAtend30 += $row['atendidas_30']; - $somaTransferidas += $row['transferidas']; - $somaEspera += $row['espera']; - $somaOriginadasPA += $row['originadas_pa']; - - $somaTempoEspera += $row['tempo_espera']; - $somaTempoAtendimento += $row['tempo_atendimento']; - $somaTempoAbandono += $row['tempo_abandono']; - - - $linha = ""; - foreach ($dadosField as $key => $value) { - if ($key == 'data') { - $linha .= sprintf("%s", $value, $row['hora_ini'] . ' às ' . $row['hora_fim']); - } else { - $linha .= sprintf("%s", $value, $row["$key"]); - } + foreach ($somaFieldServ as $value) { + $linhaTotal[$value] = $somaServ[$value]; + } + + $linhaTotal['tme'] = ' '; + $linhaTotal['tma'] = ' '; + $linhaTotal['tmab'] = ' '; + $linhaTotal['inb'] = ' '; + $linhaTotal['iab'] = ' '; + $linhaTotal['ie'] = ' '; + $linhaTotal['cor_linha_dados'] = "225"; + + $dadosTable[] = $linhaTotal; + $oldSrv = $srv; + $somaServico = 0; + + foreach ($somaFieldServ as $value) { + $somaServ[$value] = 0; } - $linha .= ""; - $dataRel[] = $linha; - } - - $somaTME = SecondToStrTime($somaEspera ? round($somaTempoEspera / $somaEspera,0) : 0); - $somaPA = SecondToStrTime($somaTempoAtendimento ? round($somaTempoAtendimento / $somaAtendPA,0) : 0); - $somaAbandono = SecondToStrTime($somaTempoAbandono ? round($somaTempoAbandono / $somaAbandonadas,0) : 0); - $mediaNS = $somaFila > 0 ? ($somaAtend30 / $somaFila) * 100.0 : 0; - $mediaIAB = $somaFila > 0 ? ($somaAbandonadas / $somaFila) * 100.0 : 0; - $mediaIA = $somaFila > 0 ? (($somaFila - ($somaAbandonadas + $somaEspera)) / $somaFila) * 100.0 : 0; - - $linhaTotal = 'Média%s%s%s%s%s%s%s%s%s%s%s%s %s %s %s '; - $dataRel[] = sprintf($linhaTotal, round($somaFila / $somaReg), round($somaTransbordada / $somaReg), round($somaTransbordando / $somaReg), round($somaAbandonadas / $somaReg), round($somaAtendRamal / $somaReg), round($somaAtendPA / $somaReg), round($somaAtend30 / $somaReg), round($somaTransferidas / $somaReg), round($somaEspera / $somaReg), $somaTME, $somaPA, $somaAbandono,round($mediaNS,2),round($mediaIAB,2), round($mediaIA,2)); - - $linhaGeral = 'Total%s%s%s%s%s%s%s%s%s - - - - - - '; - $dataRel[] = sprintf($linhaGeral, $somaFila, $somaTransbordada, $somaTransbordando, $somaAbandonadas, $somaAtendRamal, $somaAtendPA, $somaAtend30, $somaTransferidas, $somaEspera, $somaOriginadasPA); - /* - * Fecha relatorio. - */ - $dataRel[] = ''; - - $dataRel[] = '
'; - - - $totalCabecalio = array( - "Tempo de Espera" => 'align="center"', - "TE <= 10" => 'align="center"', - '10 < TE <= 20' => 'align="center"', - '20 < TE <= 30' => 'align="center"', - '30 < TE <= 60' => 'align="center"', - '60 < TE <= 120' => 'align="center"', - '120 < TE <= 180' => 'align="center"', - '180 < TE <= 300' => 'align="center"', - '300 < TE' => 'align="center"', - 'Total' => 'align="center"' - ); - $totalField = array( - 'tipo' => 'align="center"', - 'ate_10' => 'align="center"', - 'ate_20' => 'align="center"', - 'ate_30' => 'align="center"', - 'ate_60' => 'align="center"', - 'ate_120' => 'align="center"', - 'ate_180' => 'align="center"', - 'ate_300' => 'align="center"', - 'ate_maior' => 'align="center"', - 'total' => 'align="center"' - ); - - $linhaT = ""; - foreach ($totalCabecalio as $key => $value) { - $linhaT .= sprintf("", $value, $key); + + foreach ($somaFieldServ as $value) { + $somaServ[$value] += $row[$value]; } - $linhaT .= ""; - $dataRel[] = $linhaT; + }; - foreach ($this->GetData()[1] as $row) { - $row['total'] = $row['ate_10'] + $row['ate_20'] + $row['ate_30'] + $row['ate_60'] + $row['ate_120'] + $row['ate_180'] + $row['ate_300'] + $row['ate_maior']; + $dados = $this->GetData()[0]; - $linha = ""; - foreach ($totalField as $key => $value) { - if ($key == 'tipo') { - $linha .= sprintf("", $value, $row['tipo']); - } else { - $linha .= sprintf("", $value, $row["$key"]); - } - } - $linha .= ""; - $dataRel[] = $linha; + foreach ($dados as $row) { + + if ($mostraColunaServicos) { + $agrupaServico($row, $somaFieldServ); } - $dataRel[] = '
%s
%s%s
'; - - $linha = '
'; - $linha .= ""; - $linha .= "" - . "" - . "" - . "" - . "" - . "" - . ""; - $linha .= '
Legenda
NSNível de Serviço
IABÍndice de Abandono
IAÍndice de Atendimento
'; - $dataRel[] = $linha; + $numDiasRelatorio[$row["dia"]] = 1; - $this->___dataRel[] = $dataRel; + $somaFila += $row['oferecidas']; + $somaTransbordada += $row['transbordada']; + $somaTransbordando += $row['transbordando']; + $somaAbandonadas += $row['abandonadas']; + $somaAtendRamal += $row['atendidas_fila']; + $somaAtendPA += $row['atendidas_pa']; + $somaAtend30 += $row['atendidas_30']; + $somaTransferidas += $row['transferidas']; + $somaEspera += $row['espera']; + $somaOriginadasPA += $row['originadas_pa']; + + $somaTempoEspera += $row['tempo_espera']; + $somaTempoAtendimento += $row['tempo_atendimento']; + $somaTempoAbandono += $row['tempo_abandono']; + + $dadosTable[] = $row; } - protected function ___PreparaHtml() { - + if ($mostraColunaServicos) { + $agrupaServico(false, $somaFieldServ); } - protected function ___PreparaPdf() { - list($this->___dac, $this->___ano,$this->___mes, $this->___tipoRelatorio) = $_SESSION["SSstorageFiltros"]; - $this->___dataIni = $this->___mes; - $this->___dataFim = $this->___ano; - $dadosCabecalio = array( - "Mês" => 'C', - 'Fila' => 'C', - 'Trans. Entrada' => 'C', - 'Trans. Saída' => 'C', - 'Abandonadas' => 'C', - 'Ramal Estático' => 'C', - 'Atend. PA' => 'C', - 'Atend. 30' => 'C', - 'Transf.' => 'C', - 'Espera' => 'C', - 'TME' => 'C', - 'PA' => 'C', - 'Abandono' => 'C', - 'NS' => 'C', - 'IAB' => 'C', - 'IA' => 'C' - ); - $dadosField = array( - 'dia' => 'C', - 'oferecidas' => 'C', - 'transbordada' => 'C', - 'transbordando' => 'C', - 'abandonadas' => 'C', - 'atendidas_fila' => 'C', - 'atendidas_pa' => 'C', - 'atendidas_30' => 'C', - 'transferidas' => 'C', - 'espera' => 'C', - 'tme' => 'C', - 'tma' => 'C', - 'tmab' => 'C', - 'inb' => 'C', - 'iab' => 'C', - 'ie' => 'C' - ); - - $somaReg = 0; - $somaFila = 0; - $somaTransbordada = 0; - $somaTransbordando = 0; - $somaAbandonadas = 0; - $somaAtendRamal = 0; - $somaAtendPA = 0; - $somaAtend30 = 0; - $somaTransferidas = 0; - $somaEspera = 0; - $somaOriginadasPA = 0; - - $dados = $this->GetData()[0]; - $x = 0; - foreach ($dados as $row) { - - $somaReg ++; - $somaFila += $row['oferecidas']; - $somaTransbordada += $row['transbordada']; - $somaTransbordando += $row['transbordando']; - $somaAbandonadas += $row['abandonadas']; - $somaAtendRamal += $row['atendidas_fila']; - $somaAtendPA += $row['atendidas_pa']; - $somaAtend30 += $row['atendidas_30']; - $somaTransferidas += $row['transferidas']; - $somaEspera += $row['espera']; - $somaOriginadasPA += $row['originadas_pa']; - - $somaTempoEspera += $row['tempo_espera']; - $somaTempoAtendimento += $row['tempo_atendimento']; - $somaTempoAbandono += $row['tempo_abandono']; - - if ($row['hora_ini']) { - $dados[$x]['hora_ini'] = $row['hora_ini'] . ' às ' . $row['hora_fim']; - } - $x++; - } - $somaTME = SecondToStrTime($somaEspera ? round($somaTempoEspera / $somaEspera,0) : 0); - $somaPA = SecondToStrTime($somaTempoAtendimento ? round($somaTempoAtendimento / $somaAtendPA,0) : 0); - $somaAbandono = SecondToStrTime($somaTempoAbandono ? round($somaTempoAbandono / $somaAbandonadas,0) : 0); - $mediaNS = $somaFila > 0 ? ($somaAtend30 / $somaFila) * 100.0 : 0; - $mediaIAB = $somaFila > 0 ? ($somaAbandonadas / $somaFila) * 100.0 : 0; - $mediaIA = $somaFila > 0 ? (($somaFila - ($somaAbandonadas + $somaEspera)) / $somaFila) * 100.0 : 0; - + $somaTME = SecondToStrTime($somaEspera ? round($somaTempoEspera / $somaEspera, 0) : 0); + $somaPA = SecondToStrTime($somaTempoAtendimento ? round($somaTempoAtendimento / $somaAtendPA, 0) : 0); + $somaAbandono = SecondToStrTime($somaTempoAbandono ? round($somaTempoAbandono / $somaAbandonadas, 0) : 0); + $mediaNS = $somaFila > 0 ? ($somaAtend30 / $somaFila) * 100.0 : 0; + $mediaIAB = $somaFila > 0 ? ($somaAbandonadas / $somaFila) * 100.0 : 0; + $mediaIA = $somaFila > 0 ? (($somaFila - ($somaAbandonadas + $somaEspera)) / $somaFila) * 100.0 : 0; + + $totalDias = count($numDiasRelatorio); + if ($mostraColunaServicos) { + $widthHeader = array(26, 7, 8, 10, 10, 10, 10, 13, 12, 12, 12, 13, 13, 13, 8, 8, 8); + $totaliza = array('Media', '', round($somaFila / $totalDias), round($somaTransbordada / $totalDias), round($somaTransbordando / $totalDias), round($somaAbandonadas / $totalDias), round($somaAtendRamal / $totalDias), round($somaAtendPA / $totalDias), round($somaAtend30 / $totalDias), round($somaTransferidas / $totalDias), round($somaEspera / $totalDias), $somaTME, $somaPA, $somaAbandono, round($mediaNS, 2), round($mediaIAB, 2), round($mediaIA, 2)); + $table = array($dadosCabecalio, $dadosField, $dadosTable, $widthHeader, $totaliza, 0); + $totalizaGeral = array('Total', '', $somaFila, $somaTransbordada, $somaTransbordando, $somaAbandonadas, $somaAtendRamal, $somaAtendPA, $somaAtend30, $somaTransferidas, $somaEspera, '-', '-', '-', ' - ', ' - ', ' - '); + $table1 = array('', '', '', $widthHeader, $totalizaGeral, 0); + } else { $widthHeader = array(7, 8, 17, 17, 17, 15, 13, 12, 12, 12, 13, 13, 13, 8, 8, 8); - $totaliza = array('Media', round($somaFila / $somaReg), round($somaTransbordada / $somaReg), round($somaTransbordando / $somaReg), round($somaAbandonadas / $somaReg), round($somaAtendRamal / $somaReg), round($somaAtendPA / $somaReg), round($somaAtend30 / $somaReg), round($somaTransferidas / $somaReg), round($somaEspera / $somaReg), $somaTME , $somaPA , $somaAbandono , round($mediaNS,2), round($mediaIAB,2), round($mediaIA,2)); - $table = array($dadosCabecalio, $dadosField, $dados, $widthHeader, $totaliza, 0); + $totaliza = array('Media', round($somaFila / $totalDias), round($somaTransbordada / $totalDias), round($somaTransbordando / $totalDias), round($somaAbandonadas / $totalDias), round($somaAtendRamal / $totalDias), round($somaAtendPA / $totalDias), round($somaAtend30 / $totalDias), round($somaTransferidas / $totalDias), round($somaEspera / $totalDias), $somaTME, $somaPA, $somaAbandono, round($mediaNS, 2), round($mediaIAB, 2), round($mediaIA, 2)); + $table = array($dadosCabecalio, $dadosField, $dadosTable, $widthHeader, $totaliza, 0); - $totalizaGeral = array('Total', $somaFila, $somaTransbordada, $somaTransbordando, $somaAbandonadas, $somaAtendRamal, $somaAtendPA, $somaAtend30, $somaTransferidas, $somaEspera, '-', '-', '-', ' - ', ' - ', ' - '); + $totalizaGeral = array('Total', $somaFila, $somaTransbordada, $somaTransbordando, $somaAbandonadas, $somaAtendRamal, $somaAtendPA, $somaAtend30, $somaTransferidas, $somaEspera, '-', '-', '-', ' - ', ' - ', ' - '); $table1 = array('', '', '', $widthHeader, $totalizaGeral, 0); + } - $totalCabecalio = array( - "Tempo de Espera" => 'C', - "TE <= 10" => 'C', - '10 < TE <= 20' => 'C', - '20 < TE <= 30' => 'C', - '30 < TE <= 60' => 'C', - '60 < TE <= 120' => 'C', - '120 < TE <= 180' => 'C', - '180 < TE <= 300' => 'C', - '300 < TE' => 'C', - 'Total' => 'C' - ); - - $totalField = array( - 'tipo' => 'C', - 'ate_10' => 'C', - 'ate_20' => 'C', - 'ate_30' => 'C', - 'ate_60' => 'C', - 'ate_120' => 'C', - 'ate_180' => 'C', - 'ate_300' => 'C', - 'ate_maior' => 'C', - 'total' => 'C' - ); - $x = 0; - $dadosTotal = $this->GetData()[1]; - foreach ($dadosTotal as $row) { - $dadosTotal[$x]['total'] = $row['ate_10'] + $row['ate_20'] + $row['ate_30'] + $row['ate_60'] + $row['ate_120'] + $row['ate_180'] + $row['ate_300'] + $row['ate_maior']; - $x++; - } - $totalHeader = array(30, 17, 17, 18, 17, 20, 20, 20, 17, 17); - $table2 = array($totalCabecalio, $totalField, $dadosTotal, $totalHeader, 0, 1); - - $legendaCabecalio = array( - "NS" => 'C', - "IAB" => 'C', - 'IA' => 'C' - ); - - $legendaField = array( - 1 => 'C', - 2 => 'C', - 3 => 'C' - ); - - $legDadosField = array(array( - 1 => 'Nível de Serviço', - 2 => 'Índice de Abandono', - 3 => 'Índice de Atendimento') - ); - - $legendaHeader = array(64,64,65); - $table3 = array($legendaCabecalio, $legendaField, $legDadosField, $legendaHeader, 0, 1); - - $this->___dataRel = array($table, $table1, $table2, $table3); + + + $totalCabecalio = array( + "Tempo de Espera" => 'C', + "TE <= 10" => 'C', + '10 < TE <= 20' => 'C', + '20 < TE <= 30' => 'C', + '30 < TE <= 60' => 'C', + '60 < TE <= 120' => 'C', + '120 < TE <= 180' => 'C', + '180 < TE <= 300' => 'C', + '300 < TE' => 'C', + 'Total' => 'C' + ); + + $totalField = array( + 'tipo' => 'C', + 'ate_10' => 'C', + 'ate_20' => 'C', + 'ate_30' => 'C', + 'ate_60' => 'C', + 'ate_120' => 'C', + 'ate_180' => 'C', + 'ate_300' => 'C', + 'ate_maior' => 'C', + 'total' => 'C' + ); + $x = 0; + $dadosTotal = $this->GetData()[1]; + foreach ($dadosTotal as $row) { + $dadosTotal[$x]['total'] = $row['ate_10'] + $row['ate_20'] + $row['ate_30'] + $row['ate_60'] + $row['ate_120'] + $row['ate_180'] + $row['ate_300'] + $row['ate_maior']; + $x++; } + $totalHeader = array(30, 17, 17, 18, 17, 20, 20, 20, 17, 17); + $table2 = array($totalCabecalio, $totalField, $dadosTotal, $totalHeader, 0, 1); + + $legendaCabecalio = array( + "NS" => 'C', + "IAB" => 'C', + 'IA' => 'C' + ); + + $legendaField = array( + 1 => 'C', + 2 => 'C', + 3 => 'C' + ); + + $legDadosField = array(array( + 1 => 'Nível de Serviço', + 2 => 'Índice de Abandono', + 3 => 'Índice de Atendimento') + ); + + $legendaHeader = array(64, 64, 65); + $table3 = array($legendaCabecalio, $legendaField, $legDadosField, $legendaHeader, 0, 1); + + $this->___dataRel = array($table, $table1, $table2, $table3); + } - public function ExecutaRelatorio() { - global $jsStartup, $jsJQuery, $smarty; - try { - /* - * Formata as linha da função date - */ - setlocale(LC_ALL, "pt_BR", "pt_BR.iso-8859-1", "pt_BR.utf-8", "portuguese"); - /* - * 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(); - } + public function ExecutaRelatorio() { + global $jsStartup, $jsJQuery, $smarty; + try { + /* + * Formata as linha da função date + */ + setlocale(LC_ALL, "pt_BR", "pt_BR.iso-8859-1", "pt_BR.utf-8", "portuguese"); + /* + * Use esta função para validar dados do formulário. + */ + $this->___ValidaForm(); /* - * Inclua os scripts necessários aqui. + * Recupera os dados do banco. */ - $jsJQuery[] = "\$('#dataIni').keypress(function(){formataDataHora(this);}) "; - $jsJQuery[] = "\$('#dataFim').keypress(function(){formataDataHora(this);}) "; + $this->___ConteudoRelatorio(); - $smarty->assign('filtros', $this->___FiltrosRelatorio()); - $smarty->assign('conteudo', $conteudoRelatorio); - $smarty->assign('msg', $this->GetMsg()); - GetTemplate($smarty, 'relatoriosGrid.tpl'); + /* + * 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'); } - $relMetricasMensal = new RelMetricasMensal($idProg, $dbcon, 1); - $relMetricasMensal->ExecutaRelatorio(); - /* - * Relatório mostra a produtividade de um agente - - //require_once("bd.php"); - $isValid = 1; - $msg = ''; - - //variaveis para manter o estado - $mesAtu = ((int) date('m')); - $_SESSION["listaDacs"] = isset($_POST["listaDacs"]) ? $_POST["listaDacs"] : GetIdDacPadrao($dbcon, $_SESSION["SSidUser"]); - $_SESSION["listaMes"] = isset($_POST["listaMes"]) ? $_POST["listaMes"] : $mesAtu; - $_SESSION["listaAno"] = $_POST["listaAno"] ? $_POST["listaAno"] : date('Y'); - $_SESSION["listaServico"] = isset($_POST["listaServico"]) ? $_POST["listaServico"] : 0; - - - //carrega dacs - $dacs = GetDac($dbcon, $_SESSION["listaDacs"]); - $_SESSION[SSdacDesc] = GetDacDesc($dbcon, $_SESSION["listaDacs"]); - - // carrega lista de identificadores das rotas - $listaServico = GetIdentRota($dbcon, $_SESSION["listaServico"]); - - - $listaMes = GetMes((int) $_SESSION["listaMes"], 0, 0); - $ano = GetAno($_SESSION["listaAno"]); - - //emite relatorio - $dac = $_SESSION["listaDacs"]; - $codMes = $_SESSION["listaMes"]; - - $dados = array(); - $mediaOf = array(); - $sum = array(); - $somaOf = array(); - - //dados da sumarização relatorio - if (IsPostBack() && $isValid) { - if (!$_SESSION["listaDacs"]) { - $isValid = 0; - $msg = "Selecione um Dispositivo!"; - } else { - $query = GetQuerySum($_SESSION[SSdacDesc], $codMes, $_SESSION["listaAno"]); - $result = @pg_query($dbcon, $query); - - $i = 0; - $imp = 0; - while ($sum[$i] = @pg_fetch_array($result)) { - $i++; - $imp++; - } - - $sumTotalAb = 0; - for ($i = 0; $i < count($sum[0]); $i++) - if ($sum[0][$i]) - $sumTotalAb += $sum[0][$i]; - - $sumTotalAt = 0; - for ($i = 0; $i < count($sum[1]); $i++) - if ($sum[1][$i]) - $sumTotalAt += $sum[1][$i]; - - $sumTotalIe = 0; - for ($i = 0; $i < count($sum[2]); $i++) - if ($sum[2][$i]) - $sumTotalIe += $sum[2][$i]; - - - //dados do relatorio - $result = @pg_query($dbcon, GetQuery($_SESSION[SSdacDesc], $codMes, $_SESSION["listaAno"])); - - $i = 0; - while ($dados[$i] = @pg_fetch_row($result)) - $i++; - - $somaOf = array(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0); - foreach ($dados as $value) { - $somaOf[0] += $value[1]; //oferecidas - $somaOf[1] += $value[2]; //atendidas_ura - $somaOf[2] += $value[3]; //transbordo Entrada - $somaOf[3] += $value[4]; //transbordo Saida - $somaOf[4] += $value[5]; //abandonadas - $somaOf[5] += $value[6]; //atendidas ramal - $somaOf[6] += $value[7]; //atendidas pa - $somaOf[7] += $value[8]; //atendiadas 30 - $somaOf[8] += $value[9]; //transferidas - $somaOf[9] += $value[10]; //fila em espera - - $somaOf[10] += $value[21]; //TEMPO_ESPERA - $somaOf[11] += $value[22]; //TEMPO_ATENDIMENTO - $somaOf[12] += $value[23]; //TEMPO_ABANDONO - } - $mediaOf = array(); - if ($i > 0) { - $mediaOf[0] = round($somaOf[0] / $i, 0); //oferecidas - $mediaOf[1] = round($somaOf[1] / $i, 0); //atendidas_ura - $mediaOf[2] = round($somaOf[2] / $i, 0); //transbordo Entrada - $mediaOf[3] = round($somaOf[3] / $i, 0); //transbordo Saida - $mediaOf[4] = round($somaOf[4] / $i, 0); //abandonadas - $mediaOf[5] = round($somaOf[5] / $i, 0); //atendidas ramal - $mediaOf[6] = round($somaOf[6] / $i, 0); //atendidas pa - $mediaOf[7] = round($somaOf[7] / $i, 0); //atendiadas 30 - $mediaOf[8] = round($somaOf[8] / $i, 0); //transferidas - $mediaOf[9] = round($somaOf[9] / $i, 0); //fila em espera - - $mediaOf[10] = SecondToStrTime($somaOf[9] ? round($somaOf[10] / $somaOf[9], 0) : 0); //espera - $mediaOf[11] = SecondToStrTime($somaOf[6] ? round($somaOf[11] / $somaOf[6], 0) : 0); //atendimento - $mediaOf[12] = SecondToStrTime($somaOf[4] ? round($somaOf[12] / $somaOf[4], 0) : 0); //abandono - - $oferTotal = $somaOf[0]; // total de chamadas oferecidas. - $abdTotal = $somaOf[4]; //total de chamadas abandonadas. - /* - * Nível de serviço: - * É calculado pela relação entre chamadas atendidas até 30s pela soma total das - * chamadas atendidas no pa + o total de abandonadas. - * Atendidas-30 / (atendidas-pa + abandonadas) * 100.0; - - $atendida30Total = $somaOf[7]; - $atdPaAbd = $somaOf[6] + $somaOf[4]; - $mediaOf[13] = $atdPaAbd > 0 ? ($atendida30Total / $atdPaAbd) * 100.0 : 0; - $mediaOf[13] = round($mediaOf[13], 2); //NS - - /* - * Indice de abandono: - * É o simples percentual de chamadas abandonadas em relacao as ofereciadas. - - $mediaOf[14] = $oferTotal > 0 ? ($abdTotal / $oferTotal) * 100.0 : 0; - $mediaOf[14] = round($mediaOf[14], 2); //IAB - - /* - * Indice de Atendimento: - * É o percentual de chamadas que foram atendidas sem ficar em espera em realação - * ao total de chamdas oferecidas na fila. - - $abdEspera = $somaOf[4] + $somaOf[9]; - $mediaOf[15] = !$oferTotal ? 0 : (($oferTotal - $abdEspera) * 100.0) / $oferTotal; - $mediaOf[15] = round($mediaOf[15], 2); //IE - } - - //guarda query relatorio para impressao - $_SESSION["SSquerySumRm"] = $sum; - $_SESSION["sumTotalAbRm"] = $sumTotalAb; - $_SESSION["sumTotalAtRm"] = $sumTotalAt; - $_SESSION["sumTotaletRm"] = $sumTotalIe; - $_SESSION["SSdadosRm"] = $dados; - $_SESSION["somaOfRm"] = $somaOf; - $_SESSION["mediaOfRm"] = $mediaOf; - $erro = ""; - if (pg_last_error($dbcon)) - $erro = "Ocorreram erros durante a operação."; - } - }//post back - //if(IsAdmin()) echo sprintf("Tempo Atendimento: %s Atendidas: %s Media: %s", $somaOf[11], $somaOf[6], $somaOf[11] / $somaOf[6]); - if (!$isValid) - $jsStartup[] = "alert('$msg');"; - - $smarty->assign('imp', $imp); - $smarty->assign('ano', $ano); - $smarty->assign('dacs', $dacs); - $smarty->assign('meses', $listaMes); - $smarty->assign('somaOf', $somaOf); - $smarty->assign('mediaOf', $mediaOf); - $smarty->assign('dados', $dados); - $smarty->assign('sum', $sum); - $smarty->assign('sumTotalAb', $sumTotalAb); - $smarty->assign('sumTotalAt', $sumTotalAt); - $smarty->assign('sumTotalIe', $sumTotalIe); - $smarty->assign('erro', $erro); - $smarty->assign('listaServico', $listaServico); - GetTemplate($smarty, 'callcenter/relatorios/metas/relMetricaMes.tpl'); - - function GetQuery($dac, $codMes, $ano) { - $mes = str_pad($codMes, 2, '0', STR_PAD_LEFT); - $iniMes = "$ano-$mes-01"; - $fimMes = "$ano-$mes-" . GetLastDayofMonth($ano, $mes); - $servico = $_SESSION["listaServico"]; - $query = "SELECT - DIA - ,OFERECIDAS - ,ATENDIDAS_URA - ,TRANSBORDADA - ,TRANSBORDANDO - ,ABANDONADAS - ,ATENDIDAS_FILA - ,ATENDIDAS_PA - ,ATENDIDAS_30 - ,TRANSFERIDAS - ,ESPERA - ,round( CASE WHEN(ESPERA = 0)THEN 0 ELSE (TEMPO_ESPERA / ESPERA) END ) * INTERVAL '1 SECOND' AS TME - ,round( CASE WHEN(ATENDIDAS_PA = 0)THEN 0 ELSE (TEMPO_ATENDIMENTO / ATENDIDAS_PA)END) * INTERVAL '1 SECOND' AS TMA - ,round(CASE WHEN(ABANDONADAS = 0)THEN 0 ELSE (TEMPO_ABANDONO / ABANDONADAS) END) * INTERVAL '1 SECOND' AS TMAB - ,(CASE WHEN((ATENDIDAS_PA::FLOAT + ABANDONADAS::FLOAT) = 0)THEN 0 ELSE ATENDIDAS_30::FLOAT / (ATENDIDAS_PA::FLOAT + ABANDONADAS::FLOAT) END * 100)::numeric(5,2) as INB - ,(CASE WHEN(OFERECIDAS::FLOAT = 0)THEN 0 ELSE (ABANDONADAS::FLOAT / OFERECIDAS::FLOAT) END * 100)::numeric(5,2) as IAB - ,(CASE WHEN(OFERECIDAS::INT = 0)THEN 0 ELSE ((OFERECIDAS::FLOAT - (ABANDONADAS::FLOAT + ESPERA::FLOAT))) / (OFERECIDAS::FLOAT / 100.0)::FLOAT END)::numeric(5,2) as IE - ,0 AS OCUPADAS - ,0 AS RECEBIDAS_PESSOALMENTE - ,0 AS ATENDIMENTO_URA - ,0 AS ICO - ,TEMPO_ESPERA - ,TEMPO_ATENDIMENTO - ,TEMPO_ABANDONO - FROM ( - - select extract(day from a.data_bilhete) as dia - ,SUM (CASE WHEN EVENTO in('ABANDON', 'COMPLETEAGENT','COMPLETECALLER','TRANSFER','TRANSBORDANDO') THEN 1 ELSE 0 END) AS OFERECIDAS - ,0 AS ATENDIDAS_URA - ,SUM (CASE WHEN EVENTO = 'ABANDON' THEN 1 ELSE 0 END) AS ABANDONADAS - ,SUM (CASE WHEN EVENTO IN ('COMPLETEAGENT','COMPLETECALLER','TRANSFER') AND SUBSTRING(AGENTE,1,5) <> 'Agent' THEN 1 ELSE 0 END) AS ATENDIDAS_FILA - ,SUM (CASE WHEN EVENTO IN ('COMPLETEAGENT','COMPLETECALLER','TRANSFER') AND SUBSTRING(AGENTE,1,5) = 'Agent' THEN 1 ELSE 0 END) AS ATENDIDAS_PA - ,SUM (CASE WHEN EVENTO IN ('COMPLETEAGENT','COMPLETECALLER','TRANSFER') AND strtoint(param1) <= '30' AND SUBSTRING(AGENTE,1,5) = 'Agent' THEN 1 ELSE 0 END) AS ATENDIDAS_30 - ,SUM (CASE WHEN (EVENTO = 'TRANSFER') THEN 1 ELSE 0 END) AS TRANSFERIDAS - ,SUM (CASE WHEN EVENTO IN ('CONNECT') AND strtoint(param1) > '3' THEN 1 ELSE 0 END) AS ESPERA - ,SUM (CASE WHEN EVENTO IN ('CONNECT') AND strtoint(param1) > '3' THEN strtoint(param1) ELSE 0 END) AS TEMPO_ESPERA - ,SUM (CASE WHEN EVENTO IN ('COMPLETEAGENT','COMPLETECALLER') THEN strtoint(param2) ELSE 0 END) AS TEMPO_ATENDIMENTO - ,SUM (CASE WHEN EVENTO = 'ABANDON' THEN strtoint(param3) ELSE 0 END) AS TEMPO_ABANDONO - ,SUM (CASE WHEN EVENTO IN ('TRANSBORDANDO') THEN 1 ELSE 0 END) AS TRANSBORDANDO - ,SUM (case when EVENTO = 'TRANSBORDADO' THEN 1 else 0 end) AS TRANSBORDADA - from pbx_bilhetes a, pbx_eventos_dacs b - where b.uid2 = a.uniqueid - AND b.evento in ('ABANDON','COMPLETEAGENT','COMPLETECALLER', 'CONNECT','ENTERQUEUE','TRANSFER', 'TRANSBORDANDO', 'TRANSBORDADO') - AND a.data_bilhete >= '$iniMes' - AND a.data_bilhete <= '$fimMes' - AND a.lastapp <> 'Transferred Call' - AND b.fila = '$dac'\n"; - if ($servico) { - //$query .= " AND substring(a.clid,2,3) = '$servico'"; - $query .= sprintf(" AND exists(select '' from pbx_servicos_registra where uniqueid = a.uniqueid and serv_id = %s)", QuotedStr($servico)); - } - - $query .= " group by a.data_bilhete order by a.data_bilhete) as dados"; - - - // if(IsAdmin()){ echo $query; exit;} - return $query; - } - - function GetQuerySum($dac, $codMes, $ano) { - $mes = str_pad($codMes, 2, '0', STR_PAD_LEFT); - $iniMes = "$ano-$mes-01"; - $fimMes = "$ano-$mes-" . GetLastDayofMonth($ano, $mes); - $servico = $_SESSION["listaServico"]; - $query = "SELECT 'ab' as tipo - ,SUM (CASE WHEN( (strtoint(param3) <= 10)) THEN 1 ELSE 0 END) as ATE_10 - ,SUM (CASE WHEN( (strtoint(param3) > 10) AND (strtoint(param3) <= 20) ) THEN 1 ELSE 0 END) as ATE_20 - ,SUM (CASE WHEN( (strtoint(param3) > 20) AND (strtoint(param3) <= 30) ) THEN 1 ELSE 0 END) as ATE_30 - ,SUM (CASE WHEN( (strtoint(param3) > 30) AND (strtoint(param3) <= 60) ) THEN 1 ELSE 0 END) as ATE_60 - ,SUM (CASE WHEN( (strtoint(param3) > 60) AND (strtoint(param3) <= 120) ) THEN 1 ELSE 0 END) as ATE_120 - ,SUM (CASE WHEN( (strtoint(param3) > 120) AND (strtoint(param3) <= 180) ) THEN 1 ELSE 0 END) as ATE_180 - ,SUM (CASE WHEN( (strtoint(param3) > 180) AND (strtoint(param3) <= 300) ) THEN 1 ELSE 0 END) as ATE_300 - ,SUM (CASE WHEN( (strtoint(param3) > 300) ) THEN 1 ELSE 0 END) as ATE_MAIOR - FROM ( - SELECT to_char(a.calldate,'YYYY-MM-DD') AS DATA - ,a.calldate - ,b.fila - ,b.evento - ,b.param1 - ,b.param2 - ,b.param3 - ,b.param4 - FROM pbx_eventos_dacs b, pbx_bilhetes a - where a.uniqueid = b.uid2 - and a.lastapp <> 'Transferred Call' - and b.evento = 'ABANDON' - and a.data_bilhete >= '$iniMes' - and a.data_bilhete <= '$fimMes' - and b.fila = '$dac'\n"; - if ($servico) { - $query .= " AND substring(clid,2,3) = '$servico'"; - $query .= sprintf(" AND exists(select '' from pbx_servicos_registra where uniqueid = a.uniqueid and serv_id = %s)", QuotedStr($servico)); - } - $query .= " ) AS DADOS - UNION ALL - SELECT 'at' as tipo - ,SUM (CASE WHEN( (strtoint(param1) <= 10)) THEN 1 ELSE 0 END) as ATE_10 - ,SUM (CASE WHEN( (strtoint(param1) > 10) AND (strtoint(param1) <= 20) ) THEN 1 ELSE 0 END) as ATE_20 - ,SUM (CASE WHEN( (strtoint(param1) > 20) AND (strtoint(param1) <= 30) ) THEN 1 ELSE 0 END) as ATE_30 - ,SUM (CASE WHEN( (strtoint(param1) > 30) AND (strtoint(param1) <= 60) ) THEN 1 ELSE 0 END) as ATE_60 - ,SUM (CASE WHEN( (strtoint(param1) > 60) AND (strtoint(param1) <= 120) ) THEN 1 ELSE 0 END) as ATE_120 - ,SUM (CASE WHEN( (strtoint(param1) > 120) AND (strtoint(param1) <= 180) ) THEN 1 ELSE 0 END) as ATE_180 - ,SUM (CASE WHEN( (strtoint(param1) > 180) AND (strtoint(param1) <= 300) ) THEN 1 ELSE 0 END) as ATE_300 - ,SUM (CASE WHEN( (strtoint(param1) > 300) ) THEN 1 ELSE 0 END) as ATE_MAIOR - FROM ( - SELECT to_char(a.calldate,'YYYY-MM-DD') AS DATA, a.calldate,b.fila, - b.evento,b.param1,b.param2,b.param3,b.param4 - FROM pbx_eventos_dacs b, pbx_bilhetes a - WHERE a.uniqueid = b.uid2 and a.lastapp <> 'Transferred Call' - AND b.evento IN ('COMPLETEAGENT','COMPLETECALLER','TRANSFER') - AND a.data_bilhete >= '$iniMes' - AND a.data_bilhete <= '$fimMes' - AND b.fila = '$dac'\n"; - if ($servico) { - $query .= sprintf(" AND exists(select '' from pbx_servicos_registra where uniqueid = a.uniqueid and serv_id = %s)", QuotedStr($servico)); - } - - $query .= " ) AS DADOS - - - UNION ALL - SELECT 'ie' as tipo - ,SUM (CASE WHEN( (strtoint(param1) <= 10)) THEN 1 ELSE 0 END) as ATE_10 - ,SUM (CASE WHEN( (strtoint(param1) > 10) AND (strtoint(param1) <= 20) ) THEN 1 ELSE 0 END) as ATE_20 - ,SUM (CASE WHEN( (strtoint(param1) > 20) AND (strtoint(param1) <= 30) ) THEN 1 ELSE 0 END) as ATE_30 - ,SUM (CASE WHEN( (strtoint(param1) > 30) AND (strtoint(param1) <= 60) ) THEN 1 ELSE 0 END) as ATE_60 - ,SUM (CASE WHEN( (strtoint(param1) > 60) AND (strtoint(param1) <= 120) ) THEN 1 ELSE 0 END) as ATE_120 - ,SUM (CASE WHEN( (strtoint(param1) > 120) AND (strtoint(param1) <= 180) ) THEN 1 ELSE 0 END) as ATE_180 - ,SUM (CASE WHEN( (strtoint(param1) > 180) AND (strtoint(param1) <= 300) ) THEN 1 ELSE 0 END) as ATE_300 - ,SUM (CASE WHEN( (strtoint(param1) > 300) ) THEN 1 ELSE 0 END) as ATE_MAIOR - - FROM ( - SELECT to_char(a.calldate,'YYYY-MM-DD') AS DATA, a.calldate,b.fila, - b.evento,b.param1,b.param2,b.param3,b.param4 - FROM pbx_eventos_dacs b, pbx_bilhetes a - WHERE a.uniqueid = b.uid2 - and a.lastapp <> 'Transferred Call' - and b.evento = 'CONNECT' - AND strtoint(param1) > 3 - AND a.data_bilhete >= '$iniMes' - AND a.data_bilhete <= '$fimMes' - AND b.fila = '$dac'\n"; - if ($servico) { - $query .= sprintf(" AND exists(select '' from pbx_servicos_registra where uniqueid = a.uniqueid and serv_id = %s)", QuotedStr($servico)); - } - $query .= " ) AS DADOS ORDER BY 1 "; - //if(IsAdmin()){ echo $query; exit; } - return $query; - } - */ +} + +$relMetricasMensal = new RelMetricasMensal($idProg, $dbcon, 1); +$relMetricasMensal->ExecutaRelatorio(); +/* + * Relatório mostra a produtividade de um agente + + //require_once("bd.php"); + $isValid = 1; + $msg = ''; + + //variaveis para manter o estado + $mesAtu = ((int) date('m')); + $_SESSION["listaDacs"] = isset($_POST["listaDacs"]) ? $_POST["listaDacs"] : GetIdDacPadrao($dbcon, $_SESSION["SSidUser"]); + $_SESSION["listaMes"] = isset($_POST["listaMes"]) ? $_POST["listaMes"] : $mesAtu; + $_SESSION["listaAno"] = $_POST["listaAno"] ? $_POST["listaAno"] : date('Y'); + $_SESSION["listaServico"] = isset($_POST["listaServico"]) ? $_POST["listaServico"] : 0; + + + //carrega dacs + $dacs = GetDac($dbcon, $_SESSION["listaDacs"]); + $_SESSION[SSdacDesc] = GetDacDesc($dbcon, $_SESSION["listaDacs"]); + + // carrega lista de identificadores das rotas + $listaServico = GetIdentRota($dbcon, $_SESSION["listaServico"]); + + + $listaMes = GetMes((int) $_SESSION["listaMes"], 0, 0); + $ano = GetAno($_SESSION["listaAno"]); + + //emite relatorio + $dac = $_SESSION["listaDacs"]; + $codMes = $_SESSION["listaMes"]; + + $dados = array(); + $mediaOf = array(); + $sum = array(); + $somaOf = array(); + + //dados da sumarização relatorio + if (IsPostBack() && $isValid) { + if (!$_SESSION["listaDacs"]) { + $isValid = 0; + $msg = "Selecione um Dispositivo!"; + } else { + $query = GetQuerySum($_SESSION[SSdacDesc], $codMes, $_SESSION["listaAno"]); + $result = @pg_query($dbcon, $query); + + $i = 0; + $imp = 0; + while ($sum[$i] = @pg_fetch_array($result)) { + $i++; + $imp++; + } + + $sumTotalAb = 0; + for ($i = 0; $i < count($sum[0]); $i++) + if ($sum[0][$i]) + $sumTotalAb += $sum[0][$i]; + + $sumTotalAt = 0; + for ($i = 0; $i < count($sum[1]); $i++) + if ($sum[1][$i]) + $sumTotalAt += $sum[1][$i]; + + $sumTotalIe = 0; + for ($i = 0; $i < count($sum[2]); $i++) + if ($sum[2][$i]) + $sumTotalIe += $sum[2][$i]; + + + //dados do relatorio + $result = @pg_query($dbcon, GetQuery($_SESSION[SSdacDesc], $codMes, $_SESSION["listaAno"])); + + $i = 0; + while ($dados[$i] = @pg_fetch_row($result)) + $i++; + + $somaOf = array(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0); + foreach ($dados as $value) { + $somaOf[0] += $value[1]; //oferecidas + $somaOf[1] += $value[2]; //atendidas_ura + $somaOf[2] += $value[3]; //transbordo Entrada + $somaOf[3] += $value[4]; //transbordo Saida + $somaOf[4] += $value[5]; //abandonadas + $somaOf[5] += $value[6]; //atendidas ramal + $somaOf[6] += $value[7]; //atendidas pa + $somaOf[7] += $value[8]; //atendiadas 30 + $somaOf[8] += $value[9]; //transferidas + $somaOf[9] += $value[10]; //fila em espera + + $somaOf[10] += $value[21]; //TEMPO_ESPERA + $somaOf[11] += $value[22]; //TEMPO_ATENDIMENTO + $somaOf[12] += $value[23]; //TEMPO_ABANDONO + } + $mediaOf = array(); + if ($i > 0) { + $mediaOf[0] = round($somaOf[0] / $i, 0); //oferecidas + $mediaOf[1] = round($somaOf[1] / $i, 0); //atendidas_ura + $mediaOf[2] = round($somaOf[2] / $i, 0); //transbordo Entrada + $mediaOf[3] = round($somaOf[3] / $i, 0); //transbordo Saida + $mediaOf[4] = round($somaOf[4] / $i, 0); //abandonadas + $mediaOf[5] = round($somaOf[5] / $i, 0); //atendidas ramal + $mediaOf[6] = round($somaOf[6] / $i, 0); //atendidas pa + $mediaOf[7] = round($somaOf[7] / $i, 0); //atendiadas 30 + $mediaOf[8] = round($somaOf[8] / $i, 0); //transferidas + $mediaOf[9] = round($somaOf[9] / $i, 0); //fila em espera + + $mediaOf[10] = SecondToStrTime($somaOf[9] ? round($somaOf[10] / $somaOf[9], 0) : 0); //espera + $mediaOf[11] = SecondToStrTime($somaOf[6] ? round($somaOf[11] / $somaOf[6], 0) : 0); //atendimento + $mediaOf[12] = SecondToStrTime($somaOf[4] ? round($somaOf[12] / $somaOf[4], 0) : 0); //abandono + + $oferTotal = $somaOf[0]; // total de chamadas oferecidas. + $abdTotal = $somaOf[4]; //total de chamadas abandonadas. + /* + * Nível de serviço: + * É calculado pela relação entre chamadas atendidas até 30s pela soma total das + * chamadas atendidas no pa + o total de abandonadas. + * Atendidas-30 / (atendidas-pa + abandonadas) * 100.0; + + $atendida30Total = $somaOf[7]; + $atdPaAbd = $somaOf[6] + $somaOf[4]; + $mediaOf[13] = $atdPaAbd > 0 ? ($atendida30Total / $atdPaAbd) * 100.0 : 0; + $mediaOf[13] = round($mediaOf[13], 2); //NS + + /* + * Indice de abandono: + * É o simples percentual de chamadas abandonadas em relacao as ofereciadas. + + $mediaOf[14] = $oferTotal > 0 ? ($abdTotal / $oferTotal) * 100.0 : 0; + $mediaOf[14] = round($mediaOf[14], 2); //IAB + + /* + * Indice de Atendimento: + * É o percentual de chamadas que foram atendidas sem ficar em espera em realação + * ao total de chamdas oferecidas na fila. + + $abdEspera = $somaOf[4] + $somaOf[9]; + $mediaOf[15] = !$oferTotal ? 0 : (($oferTotal - $abdEspera) * 100.0) / $oferTotal; + $mediaOf[15] = round($mediaOf[15], 2); //IE + } + + //guarda query relatorio para impressao + $_SESSION["SSquerySumRm"] = $sum; + $_SESSION["sumTotalAbRm"] = $sumTotalAb; + $_SESSION["sumTotalAtRm"] = $sumTotalAt; + $_SESSION["sumTotaletRm"] = $sumTotalIe; + $_SESSION["SSdadosRm"] = $dados; + $_SESSION["somaOfRm"] = $somaOf; + $_SESSION["mediaOfRm"] = $mediaOf; + $erro = ""; + if (pg_last_error($dbcon)) + $erro = "Ocorreram erros durante a operação."; + } + }//post back + //if(IsAdmin()) echo sprintf("Tempo Atendimento: %s Atendidas: %s Media: %s", $somaOf[11], $somaOf[6], $somaOf[11] / $somaOf[6]); + if (!$isValid) + $jsStartup[] = "alert('$msg');"; + + $smarty->assign('imp', $imp); + $smarty->assign('ano', $ano); + $smarty->assign('dacs', $dacs); + $smarty->assign('meses', $listaMes); + $smarty->assign('somaOf', $somaOf); + $smarty->assign('mediaOf', $mediaOf); + $smarty->assign('dados', $dados); + $smarty->assign('sum', $sum); + $smarty->assign('sumTotalAb', $sumTotalAb); + $smarty->assign('sumTotalAt', $sumTotalAt); + $smarty->assign('sumTotalIe', $sumTotalIe); + $smarty->assign('erro', $erro); + $smarty->assign('listaServico', $listaServico); + GetTemplate($smarty, 'callcenter/relatorios/metas/relMetricaMes.tpl'); + + function GetQuery($dac, $codMes, $ano) { + $mes = str_pad($codMes, 2, '0', STR_PAD_LEFT); + $iniMes = "$ano-$mes-01"; + $fimMes = "$ano-$mes-" . GetLastDayofMonth($ano, $mes); + $servico = $_SESSION["listaServico"]; + $query = "SELECT + DIA + ,OFERECIDAS + ,ATENDIDAS_URA + ,TRANSBORDADA + ,TRANSBORDANDO + ,ABANDONADAS + ,ATENDIDAS_FILA + ,ATENDIDAS_PA + ,ATENDIDAS_30 + ,TRANSFERIDAS + ,ESPERA + ,round( CASE WHEN(ESPERA = 0)THEN 0 ELSE (TEMPO_ESPERA / ESPERA) END ) * INTERVAL '1 SECOND' AS TME + ,round( CASE WHEN(ATENDIDAS_PA = 0)THEN 0 ELSE (TEMPO_ATENDIMENTO / ATENDIDAS_PA)END) * INTERVAL '1 SECOND' AS TMA + ,round(CASE WHEN(ABANDONADAS = 0)THEN 0 ELSE (TEMPO_ABANDONO / ABANDONADAS) END) * INTERVAL '1 SECOND' AS TMAB + ,(CASE WHEN((ATENDIDAS_PA::FLOAT + ABANDONADAS::FLOAT) = 0)THEN 0 ELSE ATENDIDAS_30::FLOAT / (ATENDIDAS_PA::FLOAT + ABANDONADAS::FLOAT) END * 100)::numeric(5,2) as INB + ,(CASE WHEN(OFERECIDAS::FLOAT = 0)THEN 0 ELSE (ABANDONADAS::FLOAT / OFERECIDAS::FLOAT) END * 100)::numeric(5,2) as IAB + ,(CASE WHEN(OFERECIDAS::INT = 0)THEN 0 ELSE ((OFERECIDAS::FLOAT - (ABANDONADAS::FLOAT + ESPERA::FLOAT))) / (OFERECIDAS::FLOAT / 100.0)::FLOAT END)::numeric(5,2) as IE + ,0 AS OCUPADAS + ,0 AS RECEBIDAS_PESSOALMENTE + ,0 AS ATENDIMENTO_URA + ,0 AS ICO + ,TEMPO_ESPERA + ,TEMPO_ATENDIMENTO + ,TEMPO_ABANDONO + FROM ( + + select extract(day from a.data_bilhete) as dia + ,SUM (CASE WHEN EVENTO in('ABANDON', 'COMPLETEAGENT','COMPLETECALLER','TRANSFER','TRANSBORDANDO') THEN 1 ELSE 0 END) AS OFERECIDAS + ,0 AS ATENDIDAS_URA + ,SUM (CASE WHEN EVENTO = 'ABANDON' THEN 1 ELSE 0 END) AS ABANDONADAS + ,SUM (CASE WHEN EVENTO IN ('COMPLETEAGENT','COMPLETECALLER','TRANSFER') AND SUBSTRING(AGENTE,1,5) <> 'Agent' THEN 1 ELSE 0 END) AS ATENDIDAS_FILA + ,SUM (CASE WHEN EVENTO IN ('COMPLETEAGENT','COMPLETECALLER','TRANSFER') AND SUBSTRING(AGENTE,1,5) = 'Agent' THEN 1 ELSE 0 END) AS ATENDIDAS_PA + ,SUM (CASE WHEN EVENTO IN ('COMPLETEAGENT','COMPLETECALLER','TRANSFER') AND strtoint(param1) <= '30' AND SUBSTRING(AGENTE,1,5) = 'Agent' THEN 1 ELSE 0 END) AS ATENDIDAS_30 + ,SUM (CASE WHEN (EVENTO = 'TRANSFER') THEN 1 ELSE 0 END) AS TRANSFERIDAS + ,SUM (CASE WHEN EVENTO IN ('CONNECT') AND strtoint(param1) > '3' THEN 1 ELSE 0 END) AS ESPERA + ,SUM (CASE WHEN EVENTO IN ('CONNECT') AND strtoint(param1) > '3' THEN strtoint(param1) ELSE 0 END) AS TEMPO_ESPERA + ,SUM (CASE WHEN EVENTO IN ('COMPLETEAGENT','COMPLETECALLER') THEN strtoint(param2) ELSE 0 END) AS TEMPO_ATENDIMENTO + ,SUM (CASE WHEN EVENTO = 'ABANDON' THEN strtoint(param3) ELSE 0 END) AS TEMPO_ABANDONO + ,SUM (CASE WHEN EVENTO IN ('TRANSBORDANDO') THEN 1 ELSE 0 END) AS TRANSBORDANDO + ,SUM (case when EVENTO = 'TRANSBORDADO' THEN 1 else 0 end) AS TRANSBORDADA + from pbx_bilhetes a, pbx_eventos_dacs b + where b.uid2 = a.uniqueid + AND b.evento in ('ABANDON','COMPLETEAGENT','COMPLETECALLER', 'CONNECT','ENTERQUEUE','TRANSFER', 'TRANSBORDANDO', 'TRANSBORDADO') + AND a.data_bilhete >= '$iniMes' + AND a.data_bilhete <= '$fimMes' + AND a.lastapp <> 'Transferred Call' + AND b.fila = '$dac'\n"; + if ($servico) { + //$query .= " AND substring(a.clid,2,3) = '$servico'"; + $query .= sprintf(" AND exists(select '' from pbx_servicos_registra where uniqueid = a.uniqueid and serv_id = %s)", QuotedStr($servico)); + } + + $query .= " group by a.data_bilhete order by a.data_bilhete) as dados"; + + + // if(IsAdmin()){ echo $query; exit;} + return $query; + } + + function GetQuerySum($dac, $codMes, $ano) { + $mes = str_pad($codMes, 2, '0', STR_PAD_LEFT); + $iniMes = "$ano-$mes-01"; + $fimMes = "$ano-$mes-" . GetLastDayofMonth($ano, $mes); + $servico = $_SESSION["listaServico"]; + $query = "SELECT 'ab' as tipo + ,SUM (CASE WHEN( (strtoint(param3) <= 10)) THEN 1 ELSE 0 END) as ATE_10 + ,SUM (CASE WHEN( (strtoint(param3) > 10) AND (strtoint(param3) <= 20) ) THEN 1 ELSE 0 END) as ATE_20 + ,SUM (CASE WHEN( (strtoint(param3) > 20) AND (strtoint(param3) <= 30) ) THEN 1 ELSE 0 END) as ATE_30 + ,SUM (CASE WHEN( (strtoint(param3) > 30) AND (strtoint(param3) <= 60) ) THEN 1 ELSE 0 END) as ATE_60 + ,SUM (CASE WHEN( (strtoint(param3) > 60) AND (strtoint(param3) <= 120) ) THEN 1 ELSE 0 END) as ATE_120 + ,SUM (CASE WHEN( (strtoint(param3) > 120) AND (strtoint(param3) <= 180) ) THEN 1 ELSE 0 END) as ATE_180 + ,SUM (CASE WHEN( (strtoint(param3) > 180) AND (strtoint(param3) <= 300) ) THEN 1 ELSE 0 END) as ATE_300 + ,SUM (CASE WHEN( (strtoint(param3) > 300) ) THEN 1 ELSE 0 END) as ATE_MAIOR + FROM ( + SELECT to_char(a.calldate,'YYYY-MM-DD') AS DATA + ,a.calldate + ,b.fila + ,b.evento + ,b.param1 + ,b.param2 + ,b.param3 + ,b.param4 + FROM pbx_eventos_dacs b, pbx_bilhetes a + where a.uniqueid = b.uid2 + and a.lastapp <> 'Transferred Call' + and b.evento = 'ABANDON' + and a.data_bilhete >= '$iniMes' + and a.data_bilhete <= '$fimMes' + and b.fila = '$dac'\n"; + if ($servico) { + $query .= " AND substring(clid,2,3) = '$servico'"; + $query .= sprintf(" AND exists(select '' from pbx_servicos_registra where uniqueid = a.uniqueid and serv_id = %s)", QuotedStr($servico)); + } + $query .= " ) AS DADOS + UNION ALL + SELECT 'at' as tipo + ,SUM (CASE WHEN( (strtoint(param1) <= 10)) THEN 1 ELSE 0 END) as ATE_10 + ,SUM (CASE WHEN( (strtoint(param1) > 10) AND (strtoint(param1) <= 20) ) THEN 1 ELSE 0 END) as ATE_20 + ,SUM (CASE WHEN( (strtoint(param1) > 20) AND (strtoint(param1) <= 30) ) THEN 1 ELSE 0 END) as ATE_30 + ,SUM (CASE WHEN( (strtoint(param1) > 30) AND (strtoint(param1) <= 60) ) THEN 1 ELSE 0 END) as ATE_60 + ,SUM (CASE WHEN( (strtoint(param1) > 60) AND (strtoint(param1) <= 120) ) THEN 1 ELSE 0 END) as ATE_120 + ,SUM (CASE WHEN( (strtoint(param1) > 120) AND (strtoint(param1) <= 180) ) THEN 1 ELSE 0 END) as ATE_180 + ,SUM (CASE WHEN( (strtoint(param1) > 180) AND (strtoint(param1) <= 300) ) THEN 1 ELSE 0 END) as ATE_300 + ,SUM (CASE WHEN( (strtoint(param1) > 300) ) THEN 1 ELSE 0 END) as ATE_MAIOR + FROM ( + SELECT to_char(a.calldate,'YYYY-MM-DD') AS DATA, a.calldate,b.fila, + b.evento,b.param1,b.param2,b.param3,b.param4 + FROM pbx_eventos_dacs b, pbx_bilhetes a + WHERE a.uniqueid = b.uid2 and a.lastapp <> 'Transferred Call' + AND b.evento IN ('COMPLETEAGENT','COMPLETECALLER','TRANSFER') + AND a.data_bilhete >= '$iniMes' + AND a.data_bilhete <= '$fimMes' + AND b.fila = '$dac'\n"; + if ($servico) { + $query .= sprintf(" AND exists(select '' from pbx_servicos_registra where uniqueid = a.uniqueid and serv_id = %s)", QuotedStr($servico)); + } + + $query .= " ) AS DADOS + + + UNION ALL + SELECT 'ie' as tipo + ,SUM (CASE WHEN( (strtoint(param1) <= 10)) THEN 1 ELSE 0 END) as ATE_10 + ,SUM (CASE WHEN( (strtoint(param1) > 10) AND (strtoint(param1) <= 20) ) THEN 1 ELSE 0 END) as ATE_20 + ,SUM (CASE WHEN( (strtoint(param1) > 20) AND (strtoint(param1) <= 30) ) THEN 1 ELSE 0 END) as ATE_30 + ,SUM (CASE WHEN( (strtoint(param1) > 30) AND (strtoint(param1) <= 60) ) THEN 1 ELSE 0 END) as ATE_60 + ,SUM (CASE WHEN( (strtoint(param1) > 60) AND (strtoint(param1) <= 120) ) THEN 1 ELSE 0 END) as ATE_120 + ,SUM (CASE WHEN( (strtoint(param1) > 120) AND (strtoint(param1) <= 180) ) THEN 1 ELSE 0 END) as ATE_180 + ,SUM (CASE WHEN( (strtoint(param1) > 180) AND (strtoint(param1) <= 300) ) THEN 1 ELSE 0 END) as ATE_300 + ,SUM (CASE WHEN( (strtoint(param1) > 300) ) THEN 1 ELSE 0 END) as ATE_MAIOR + + FROM ( + SELECT to_char(a.calldate,'YYYY-MM-DD') AS DATA, a.calldate,b.fila, + b.evento,b.param1,b.param2,b.param3,b.param4 + FROM pbx_eventos_dacs b, pbx_bilhetes a + WHERE a.uniqueid = b.uid2 + and a.lastapp <> 'Transferred Call' + and b.evento = 'CONNECT' + AND strtoint(param1) > 3 + AND a.data_bilhete >= '$iniMes' + AND a.data_bilhete <= '$fimMes' + AND b.fila = '$dac'\n"; + if ($servico) { + $query .= sprintf(" AND exists(select '' from pbx_servicos_registra where uniqueid = a.uniqueid and serv_id = %s)", QuotedStr($servico)); + } + $query .= " ) AS DADOS ORDER BY 1 "; + //if(IsAdmin()){ echo $query; exit; } + return $query; + } + */ ?> diff --git a/templates/confSistema.tpl b/templates/confSistema.tpl index 95374d2d..9cc6d70f 100644 --- a/templates/confSistema.tpl +++ b/templates/confSistema.tpl @@ -329,6 +329,15 @@ Pausa Clique aqui para configurar! + + + Habilita Serviços em Relatórios + + Desabilita + Habilita + Hbilita Filtros + +   diff --git a/templates/relatoriosGrid.tpl b/templates/relatoriosGrid.tpl index 4263ecee..b7a852e3 100644 --- a/templates/relatoriosGrid.tpl +++ b/templates/relatoriosGrid.tpl @@ -1,5 +1,5 @@ {capture name="display"} - +
@@ -17,8 +17,13 @@ -
- * C.I.E.I.V: CHAMADAS INTERNAS/EMERGENCIA/INTERNACIONAL/VOIP. + + {if !$legendas} + * C.I.E.I.V: CHAMADAS INTERNAS/EMERGENCIA/INTERNACIONAL/VOIP. + {else} + {$legendas} + {/if} +