From fdb132a2c02acafab47249ecbedc19e5c2a92ebc Mon Sep 17 00:00:00 2001 From: root Date: Fri, 11 Nov 2022 15:29:19 -0300 Subject: [PATCH] =?UTF-8?q?ATUALIZA=C3=87=C3=95ES?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/cadQgrupos.php | 22 +- agente/agentert.php | 8 + discador/campanha/retornoCampanha.php | 525 ++++++++++ projeto/base/sql/versao-1.7.11.4.sql | 21 + .../callcenter/geral/recebidasAgente.php | 964 ++++++++---------- scriptApl/functions15.js | 13 +- 6 files changed, 990 insertions(+), 563 deletions(-) create mode 100644 projeto/base/sql/versao-1.7.11.4.sql diff --git a/admin/cadQgrupos.php b/admin/cadQgrupos.php index 06b83df..b96d4b1 100644 --- a/admin/cadQgrupos.php +++ b/admin/cadQgrupos.php @@ -190,7 +190,7 @@ $modoAtendimento = $_POST["modo_atendimento"]; $pesquisaLiberacao = $_POST["pesquisa_liberacao"]; $ativaFila = isset($_POST['ativaFila']) ? 'A' : 'I'; - $midiafila = isset($_POST['midiafila']) ? 'S' : 'N'; + $disponivelfila = $_POST['disponivelfila']; $nome = LimpaString($_POST["nome"], true); $musicclass = trim($_POST["musicclass"]); $strategy = trim($_POST["strategy"]); @@ -251,12 +251,12 @@ $query = "INSERT INTO pbx_queues_grupos(nome, musicclass, strategy, servicelevel, timeout, retry, maxlen, joinempty, eventwhencalled, eventmemberstatus, ringinuse, periodic_announce_frequency,wrapuptime,autofill,autopause,\"announce-frequency\",\"announce-holdtime\",\"announce-round-seconds\",\"monitor-format\",\"monitor-type\",reportholdtime,timeoutrestart - ,numero,timeout2,m_espera,opcao,acao,setinterfacevar,anuncio, id_transbordo, max_agente_pausa, tempo_ring, exige_classificacao, justificativa_pausa, context, retornar_abandonadas,status $dataClass,modo_atendimento,id_pesquisa_liberacao, midiafila) + ,numero,timeout2,m_espera,opcao,acao,setinterfacevar,anuncio, id_transbordo, max_agente_pausa, tempo_ring, exige_classificacao, justificativa_pausa, context, retornar_abandonadas,status $dataClass,modo_atendimento,id_pesquisa_liberacao, disponivelfila) VALUES ('$nome', '$musicclass', '$strategy', $servicelevel, $timeout, $retry, $maxlen, '$joinempty', '$eventwhencalled', '$eventmemberstatus', '$ringinuse', $periodic_announce_frequency, '$wrapuptime','$autofill','$autopause','$announce_frequency','$announce_holdtime','$announce_round_seconds','$monitor_format', - '$monitor_type','$reportholdtime','$timeoutrestart','$numero','$timeout2','$m_espera','$opcao','$acao_opcao','$setinterfacevar','$som_ura', $idTransbordo, $max_agente_pausa, $tempoRing, $exige_classificacao, $justificativa_pausa, '$context', $retornar_abandonadas,'$ativaFila' $dateClass,'$modoAtendimento',$pesquisaLiberacao, '$midiafila')"; + '$monitor_type','$reportholdtime','$timeoutrestart','$numero','$timeout2','$m_espera','$opcao','$acao_opcao','$setinterfacevar','$som_ura', $idTransbordo, $max_agente_pausa, $tempoRing, $exige_classificacao, $justificativa_pausa, '$context', $retornar_abandonadas,'$ativaFila' $dateClass,'$modoAtendimento',$pesquisaLiberacao, '$disponivelfila')"; pg_query($dbcon, $query); $query2 = "select id from pbx_queues_grupos order by id desc limit 1"; @@ -297,7 +297,7 @@ maxlen='$maxlen', joinempty='$joinempty', eventwhencalled='$eventwhencalled', eventmemberstatus='$eventmemberstatus', ringinuse='$ringinuse', periodic_announce_frequency='$periodic_announce_frequency',wrapuptime='$wrapuptime',autofill='$autofill',autopause='$autopause',\"announce-frequency\"='$announce_frequency',\"announce-holdtime\"='$announce_holdtime',\"announce-round-seconds\"='$announce_round_seconds',\"monitor-format\"='$monitor_format', \"monitor-type\" ='$monitor_type',reportholdtime='$reportholdtime',timeoutrestart='$timeoutrestart',numero='$numero',timeout2='$timeout2',m_espera='$m_espera',opcao='$opcao',acao='$acao_opcao',setinterfacevar='$setinterfacevar', anuncio='$som_ura', id_transbordo = '$idTransbordo', max_agente_pausa = '$max_agente_pausa', - tempo_ring = '$tempoRing', exige_classificacao = '$exige_classificacao', justificativa_pausa = '$justificativa_pausa', context = '$context', retornar_abandonadas = '$retornar_abandonadas', modo_atendimento = '$modoAtendimento',id_pesquisa_liberacao = $pesquisaLiberacao,midiafila = '$midiafila',status = '$ativaFila' $dataClass + tempo_ring = '$tempoRing', exige_classificacao = '$exige_classificacao', justificativa_pausa = '$justificativa_pausa', context = '$context', retornar_abandonadas = '$retornar_abandonadas', modo_atendimento = '$modoAtendimento',id_pesquisa_liberacao = $pesquisaLiberacao,disponivelfila = '$disponivelfila',status = '$ativaFila' $dataClass WHERE id=$id"; pg_query($dbcon, $query); @@ -341,9 +341,6 @@ $closeWin = 1; $msgValida = ($a > 1) ? "Os ramais \"$log\" já estão sendo utilizados por um agente logado!" : "O ramal \"$log\" já está sendo utilizado por um agente logado!"; } - if($midiafila == 'N'){ - gera_arquivos($dbcon, 'QUEUES_GRUPOS'); - } ?> @@ -384,7 +381,7 @@ $modoAtendimento = $dados["modo_atendimento"]; $pesquisaLiberacao = $dados["id_pesquisa_liberacao"]; $ativaFila = $dados['status']; - $midiafila = $dados['midiafila']; + $disponivelfila = $dados['disponivelfila']; $nome = trim($dados['nome']); $musicclass = trim($dados['musicclass']); $strategy = trim($dados['strategy']); @@ -992,12 +989,9 @@
- Fila Mídia - /> Ativar + Disponível Fila + /> Sim + /> Não
diff --git a/agente/agentert.php b/agente/agentert.php index cb09c90..6e60e17 100644 --- a/agente/agentert.php +++ b/agente/agentert.php @@ -1479,6 +1479,14 @@ function ConnectaAgenteRt($db, $dac, $tpAtend) { $_SESSION[SS_MODO_ATENDIMENTO_COD] = $tpAtend; } + /** + * Verifica a disponibilidade da fila + */ + $q = "SELECT disponivelfila FROM pbx_queues_grupos WHERE id = '$dac'"; + $res = pg_query($db, $q); + $ret = pg_fetch_assoc($res); + $_SESSION["prm_disponivel_fila"] = $ret['disponivelfila']; + $moduAtendDesc = $_SESSION[SS_MODO_ATENDIMENTO]; $_SESSION[SS_DAC_CODIGO] = $dac; $matricula = GetMatricula(); diff --git a/discador/campanha/retornoCampanha.php b/discador/campanha/retornoCampanha.php index 1d9486b..133252f 100644 --- a/discador/campanha/retornoCampanha.php +++ b/discador/campanha/retornoCampanha.php @@ -1,5 +1,530 @@ ___campanha = isset($_REQUEST['campanha']) ? $_REQUEST['campanha'] : 0; + $this->___lista = isset($_REQUEST['lista']) ? $_REQUEST['lista'] : 0; + $this->___telefone = isset($_REQUEST['telefone']) ? $_REQUEST['telefone'] : ''; + $this->___btnConsulta = isset($_POST['btConsulta']) ? $_POST['btConsulta'] : ''; + } + + function ___ValidaForm() { + parent::___ValidaForm(); + if (empty($this->___campanha) && $this->___btnConsulta) { + GeraExcept('Informe uma campanha!'); + } + + if (empty($this->___lista) && $this->___campanha && $this->___btnConsulta) { + GeraExcept('Informe uma lista!'); + } + + } + + function ___FiltrosRelatorio() { + if ($this->___media != MEDIA_PRINT_GRID) { + /* + * Recupera os filtros da sess�o do usu�rio. + */ + list($this->___dataIni, $this->___dataFim, $this->___telefone) = $_SESSION["SSstorageFiltros"]; + + if ($this->___media == MEDIA_PRINT_HTML) { + return sprintf("Data Inicial: %s Data Final: %s ", $this->___dataIni, $this->___dataFim); + } + + $fltCsv = array(); + $fltCsv[] = "Data Inicial: " . $this->___dataIni; + $fltCsv[] = "Data Final: " . $this->___dataFim; + $fltCsv[] = "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'); + } + + /* + * Personalise esta função se necessitar de outras opções de filtro. + */ + $filtro = ''; + /* + * Rotulos. + */ + $filtro .= ''; + $filtro .= ''; + $filtro .= ''; + $filtro .= ''; + $filtro .= ''; + $filtro .= ''; + $filtro .= ''; + $filtro .= ''; + $filtro .= ''; + + /* + * Valores. + */ + $filtro .= '' + . ''; + $filtro .= ''; + $filtro .= ''; + $filtro .= sprintf('', $this->getCampanha($this->___campanha)); + $filtro .= sprintf('', $this->getListaCampanha($this->___lista)); + $filtro .= sprintf('', $this->___telefone); + $filtro .= ''; + $filtro .= ''; + $filtro .= ''; + $filtro .= '
 Data Inicial Data Final CampanhaListaOrigem/Destino 
 %s%s
'; + + /* + * Guarda os filtros passados para recuperar na emiss�o dos relat?ios para impress�o. + */ + $_SESSION["SSstorageFiltros"] = array($this->___dataIni, $this->___dataFim); + + return sprintf($filtro, $this->___dataIni, $this->___dataFim, $lkPrint); + } + + protected function ___GetDadosDb() { + $dataIni = $this->___dataIni ? FormatDtMssql($this->___dataIni) : ''; + $dataFim = $this->___dataFim ? FormatDtMssql($this->___dataFim) : ''; + + $query = "SELECT DISTINCT b.id AS fila_id, a.cmp_id, a.data_registro::date, d.cont_id, src, f.conf_fone as contato_numero, b.nome as fila_nome, j.apelido, billsec, a.cmp_descricao, + d.cont_param1 AS contato_descricao, + d.cont_discado AS contato_discado, + COALESCE(h.ctst_nome, 'Número Não Discado') AS contato_status, calldate + FROM pbx_campanha a + INNER JOIN pbx_dacs b ON b.id = a.id_dac + INNER JOIN pbx_campanha_lista c ON c.cmp_id = a.cmp_id + INNER JOIN pbx_campanha_contato d ON d.cmp_id = c.cmp_id AND d.list_id = c.list_id + INNER JOIN pbx_campanha_contato_fone f ON f.cmp_id = d.cmp_id AND f.list_id = d.list_id AND f.cont_id = d.cont_id + INNER JOIN pbx_bilhetes i ON i.uniqueid = f.conf_uid + LEFT JOIN pbx_campanha_operacao g ON g.cmp_id = f.cmp_id AND g.list_id = f.list_id AND g.conf_id = f.conf_id + LEFT JOIN pbx_campanha_contato_status h ON h.ctst_id = d.cont_status::int + LEFT JOIN pbx_usuarios j ON j.matricula = f.conf_agente_matricula + WHERE 1 = 1 "; + $query .= " AND i.data_bilhete::DATE >= '{$dataIni}' AND i.data_bilhete::DATE <= '{$dataFim}'"; + $query .= $this->___campanha ? " AND a.cmp_id = {$this->___campanha}" : ''; + $query .= $this->___lista ? " AND c.list_id = {$this->___lista}" : ''; + $query .= $this->___telefone ? " AND (src = '{$this->___telefone}' OR f.conf_fone = '{$this->___telefone}') " : ''; + $query .= " ORDER BY a.cmp_id"; + + $result = $this->___GetQuery($query); + $row = pg_fetch_all($result); + $this->SetData($row ? $row : array()); + } + + protected function ___PreparaCsv() { + $nomeDac = ""; + $dataRel = array(); + $dataAgrup = array(); + $filtro = $this->___FiltrosRelatorio(); + + $dataRel[] = GenerateCsvFromArray($filtro); + + $dadosCabecalio = array( + 'Data Campanha' => 'align="center"', + 'Origem' => 'align="center"', + 'Destino' => 'align="center"', + 'Fila' => 'align="center"', + 'Duracao' => 'align="center"', + 'Agente' => 'align="center"', + 'Campanha' => 'align="center"', + 'Contato' => 'align="center"', + 'Status' => 'align="center"', + 'Data Chamada' => 'align="center"' + ); + $dadosField = array( + 'data_registro' => 'align="center"', + 'src' => 'align="center"', + 'contato_numero' => 'align="center"', + 'fila_nome' => 'align="center"', + 'billsec' => 'align="center"', + 'apelido' => 'align="center"', + 'cmp_descricao' => 'align="center"', + 'contato_descricao' => 'align="center"', + 'contato_status' => 'align="center"', + 'calldate' => 'align="center"' + ); + + $dataRel[] = GenerateCsvFromArray(array_keys($dadosCabecalio)); + + $somaTempo = 0; + $somaQuantidade = 0; + + /* + * Inicia o relat�rio. + */ + foreach ($this->GetData()[0] as $row) { + $row['src'] = $row['src']; + $row["data_registro"] = $row["data_registro"] ? date('d/m/Y', strtotime($row["data_registro"])) : '-'; + $row["calldate"] = $row["calldate"] ? date('d/m/Y H:i:s', strtotime($row["calldate"])) : '-'; + $row["apelido"] = $row["apelido"] ? $row["apelido"] : '-'; + $row['cmp_descricao'] = RemoveAcentos($row['cmp_descricao']); + $row['contato_status'] = RemoveAcentos($row['contato_status']); + $row["billsec"] = SecondToStrTime($row["billsec"]); + $somaQuantidade++; + + $linha = array(); + foreach ($dadosField as $key => $value) { + $linha[] = $row["$key"]; + } + $dataRel[] = GenerateCsvFromArray($linha); + } + + $dataRel[] = $linha; + $linha1 = array('Total', 'Registros: ' . $somaQuantidade); + $dataRel[] = GenerateCsvFromArray($linha1); + $dataRel[] = $linha1; + + $this->___dataRel[] = $dataRel; + } + + protected function ___PreparaExcel() { + //list($this->___dataIni, $this->___dataFim) = $_SESSION["SSstorageFiltros"]; + + $dataRel = array(); + $dataAgrup = 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; + } + + $dataRel[] = $linha; + + $dadosCabecalio = array( + 'Data Campanha', + 'Origem', + 'Destino', + 'Fila', + 'Duracao', + 'Agente', + 'Campanha', + 'Contato', + 'Status', + 'Data Chamada' + ); + $dadosField = array( + 'data_registro', + 'src', + 'contato_numero', + 'fila_nome', + 'billsec', + 'apelido', + 'cmp_descricao', + 'contato_descricao', + 'contato_status', + 'calldate' + ); + + /* + * Monta a linha de cabecalio. + */ + $linha = array('LABEL'); + foreach ($dadosCabecalio as $value) { + $linha[] = $value; + } + $dataRel[] = $linha; + + $somaTempo = 0; + $somaQuantidade = 0; + /* + * Linhas de dados. + */ + foreach ($this->GetData()[0] as $row) { + $row['src'] = $row['src']; + $row["data_registro"] = $row["data_registro"] ? date('d/m/Y', strtotime($row["data_registro"])) : '-'; + $row["calldate"] = $row["calldate"] ? date('d/m/Y H:i:s', strtotime($row["calldate"])) : '-'; + $row["apelido"] = $row["apelido"] ? $row["apelido"] : '-'; + $row['cmp_descricao'] = RemoveAcentos($row['cmp_descricao']); + $row['contato_status'] = RemoveAcentos($row['contato_status']); + $row["billsec"] = SecondToStrTime($row["billsec"]); + $somaQuantidade++; + + // Formata linha de dados. + $linha = array('DADOS'); + foreach ($dadosField as $key) { + $linha[] = $row["$key"]; + } + + $dataRel[] = $linha; + } + + $linha = array('LABEL', 'Total', 'Registros: ' . $somaQuantidade); + + $dataRel[] = $linha; + + $this->___dataRel[] = $dataRel; + } + + protected function ___PreparaGrid() { + $dadosCabecalio = array( + 'Data Campanha' => 'align="center"', + 'Origem' => 'align="center"', + 'Destino' => 'align="center"', + 'Fila' => 'align="center"', + 'Duração' => 'align="center"', + 'Agente' => 'align="center"', + 'Campanha' => 'align="center"', + 'Contato' => 'align="center"', + 'Status' => 'align="center"', + 'Data Chamada' => 'align="center"', + 'Retornar' => 'align="center"' + ); + $dadosField = array( + 'data_registro' => 'align="center"', + 'src' => 'align="center"', + 'contato_numero' => 'align="center"', + 'fila_nome' => 'align="center"', + 'billsec' => 'align="center"', + 'apelido' => 'align="center"', + 'cmp_descricao' => 'align="center"', + 'contato_descricao' => 'align="center"', + 'contato_status' => 'align="center"', + 'calldate' => 'align="center"', + 'retornar' => 'align="center"' + ); + /* + * 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; + } + + $somaTempo = 0; + $somaQuantidade = 0; + /* + * Linhas de dados. + */ + foreach ($this->GetData()[0] as $row) { + $row['src'] = $row['src']; + $row["data_registro"] = $row["data_registro"] ? date('d/m/Y', strtotime($row["data_registro"])) : '-'; + $row["calldate"] = $row["calldate"] ? date('d/m/Y H:i:s', strtotime($row["calldate"])) : '-'; + $row["apelido"] = $row["apelido"] ? $row["apelido"] : '-'; + $row["billsec"] = SecondToStrTime($row["billsec"]); + if($row['contato_status'] == 'Não Atendida'){ + $row["retornar"] = sprintf('Retornar Chamada', $row['contato_numero']); + } else if($row['contato_status'] == 'Atendida'){ + $row["retornar"] = sprintf('Chamada já efetuada'); + } else if($row['contato_status']){ + $row["retornar"] = sprintf('Retornar Chamada', $row['contato_numero']); + } + $somaQuantidade++; + + // Formata linha de dados. + $linha = ""; + foreach ($dadosField as $key => $value) { + $linha .= sprintf("%s", $value, $row["$key"]); + } + $linha .= ""; + $dataRel[] = $linha; + } + /* + * Linha de totalizacao. + */ + $linha = 'TotalRegistros: %s'; + $dataRel[] = sprintf($linha, $somaQuantidade, SecondToStrTime($somaTempo)); + + /* + * Fecha relatorio. + */ + $dataRel[] = ''; + $this->___dataRel[] = $dataRel; + } + + protected function ___PreparaHtml() { + + } + + protected function ___PreparaPdf() { + list($this->___dataIni, $this->___dataFim) = $_SESSION["SSstorageFiltros"]; + + $dados = $this->GetData()[0]; + $x = 0; + $somaQtd = 0; + foreach ($dados as $row) { + $dados[$x]["cmpo_fim"] = $row["cmpo_fim"] ? date('d/m/Y H:i', strtotime($row["cmpo_fim"])) : '-'; + $dados[$x]["apelido"] = $row["apelido"] ? $row["apelido"] : '-'; + $dados[$x]["cmp_descricao"] = RemoveAcentos($row['cmp_descricao']); + $dados[$x]["contato_status"] = RemoveAcentos($row['contato_status']); + $dados[$x]["billsec"] = SecondToStrTime($row["billsec"]); + $somaQtd++; + $x++; + } + + //HEADER DA TABELA DO PDF -> DADOS EM ARRAY + $header = array( + 'Data/Hora' => 'C', + 'Origem' => 'C', + 'Destino' => 'C', + 'Fila' => 'C', + 'Duracao' => 'C', + 'Agente' => 'C', + 'Campanha' => 'C', + 'Contato' => 'C', + 'Status' => 'C' + ); + $dataHeader = array( + 'cmpo_fim' => 'C', + 'src' => 'C', + 'contato_numero' => 'C', + 'fila_nome' => 'C', + 'billsec' => 'C', + 'apelido' => 'C', + 'cmp_descricao' => 'C', + 'contato_descricao' => 'C', + 'contato_status' => 'C' + ); + + $widthHeader = array(20, 13, 15, 20, 15, 15, 30, 60, 15); + $totaliza = array('Total', "Registros: ", $somaQtd); + + //Monta o array para passar para o prepara; Necessário passar 6 parametros + $table1 = array($header, $dataHeader, $dados, $widthHeader, $totaliza, 1); + + $this->___dataRel = array($table1); + } + + private function getCampanha($select = null) { + global $dbcon; + + $query = sprintf("SELECT DISTINCT cmp_id as id, cmp_descricao as nome + FROM pbx_grupo_usuario a + INNER JOIN pbx_fila_audios b ON b.gp_id = a.gp_id + INNER JOIN pbx_queues_grupos c ON c.id = b.id + INNER JOIN pbx_campanha d ON d.id_dac = b.id + WHERE user_id = %s + ORDER BY 2", GetIdUser()); + $result = pg_query($dbcon, $query); + $res = pg_fetch_all($result); + + $opt = ""; + return $opt; + } + + public function getListaCampanha($select = null, $cmp = null) { + global $dbcon; + + if ($this->___campanha || $cmp) { + $query = sprintf("SELECT DISTINCT a.list_id as id, a.list_nome || ' [' || a.list_id::text || ']' as nome + FROM pbx_campanha_lista a + INNER JOIN pbx_campanha_contato_fone b ON b.cmp_id = a.cmp_id AND b.list_id = a.list_id + WHERE a.cmp_id IN (%s) + ORDER BY 2", $cmp ? $cmp : $this->___campanha); + + $result = pg_query($dbcon, $query); + $res = pg_fetch_all($result); + } + + if(!$res){ + $opt .= ""; + } + + foreach ($res as $val) { + $selected = $select == $val['id'] ? 'selected' : ''; + $opt .= ""; + } + return $opt; + } + + 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(); + } + + /* + * 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'); + } + + } + + $rel = new RelCampanhaRetorno($idProg, $dbcon, 0); + if($_GET['a'] && $_GET['slc']){ + echo $rel->getListaCampanha(null, $_GET['slc']); + exit; + } + $rel->ExecutaRelatorio(); + + /** $templateName = 'discador/retornoCampanha.tpl'; $vAlineMaster = 'middle'; $_SESSION["dataIni"] = IsPostBack() ? $_POST["dataIni"] : ""; //date('d/m/Y'); diff --git a/projeto/base/sql/versao-1.7.11.4.sql b/projeto/base/sql/versao-1.7.11.4.sql new file mode 100644 index 0000000..752930e --- /dev/null +++ b/projeto/base/sql/versao-1.7.11.4.sql @@ -0,0 +1,21 @@ +CREATE OR REPLACE VIEW pbx_ramais_mesa AS +SELECT 0 AS tipo, pbx_sip_ramais.id, pbx_sip_ramais.nome, + pbx_sip_ramais.dispositivo, pbx_sip_ramais.callerid, + 'SIP'::text AS tipo_table, pbx_sip_ramais.conta_senha, + ''::character varying AS ddd, pbx_sip_ramais.context AS contexto + FROM pbx_sip_ramais +UNION ALL + SELECT 1 AS tipo, 0 AS id, pbx_ramais_agenda.rma_telefone AS nome, + pbx_ramais_agenda.rma_telefone AS dispositivo, + pbx_ramais_agenda.rma_nome AS callerid, 'AGD'::text AS tipo_table, + 'F'::character varying AS conta_senha, pbx_ramais_agenda.ddd, + ' '::character varying AS contexto + FROM pbx_ramais_agenda +UNION ALL + SELECT 0 AS tipo,id, nome, dispositivo, nome AS callerid,'IAX'::text AS tipo_table, + conta_senha, ''::character varying AS ddd, context AS contexto + FROM pbx_iax_pbx +ORDER BY callerid; + +ALTER TABLE pbx_queues_grupos DROP COLUMN midiafila; +ALTER TABLE pbx_queues_grupos ADD COLUMN disponivelfila INT DEFAULT(1); \ No newline at end of file diff --git a/relatorios/callcenter/geral/recebidasAgente.php b/relatorios/callcenter/geral/recebidasAgente.php index 11d05e4..2892ea2 100644 --- a/relatorios/callcenter/geral/recebidasAgente.php +++ b/relatorios/callcenter/geral/recebidasAgente.php @@ -1,624 +1,492 @@ ___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!'); + private $___agente; + private $___tempoAtendimento; + + 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; } - if ($this->___tempoAtendimento && $this->___tempoAtendimento < 10) { - GeraExcept('Por favor, informe a duração maior que 10 segundos!'); + 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!'); + } } - } - - 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')); + 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; } - $fltCsv = array(); if ($this->GetIncDac()) { - $fltCsv[] = 'Fila:' . GetDacDesc($this->GetDbCon(), $this->___dac); + $dacs = GetDac($this->GetDbCon(), $this->___dac, "", 0, 1, 0, 0, 1); } - $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'); + } - $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 .= ''; + $filtro .= ''; + $filtro .= ''; + $filtro .= ''; + $filtro .= ''; - $tipoRel = !$this->___tipoRelatorio ? '' : 'checked="checked"'; - /* - * Personalise esta função se necessitar de outras op��es de filtro. - */ - $filtro = '
FilaData InicialData Final AgenteDuração (Segundos) 
'; - /* - * 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
'; + /* + * Valores. + */ + $filtro .= ''; + if ($this->GetIncDac()) + $filtro .= sprintf('%s', $dacs); + $filtro .= ''; + $filtro .= ''; + $filtro .= sprintf('%s', $agente); + $filtro .= ""; + $filtro .= ''; + $filtro .= '%s'; + $filtro .= ''; + $filtro .= ''; - /* - * 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); - $srv = $this->___servico; - $agente = $this->___agente; - $dac = $this->___dac; - $mostraColunaServicos = GetUsoServico() == RELATORIO_SERVICOS_HABILITA; + protected function ___GetDadosDb() { + $dataIni = FormatDtMssql($this->___dataIni); + $dataFim = FormatDtHoraBD($this->___dataFim); + $agente = $this->___agente; + $dac = $this->___dac; - $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" . ($mostraColunaServicos ? ", s.serv_id" : ""); - - $query2 = "SELECT DISTINCT c.matricula, c.apelido"; - - $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'"; - } - - if (GetUsoServico() && $srv) { - $query .= "\nAND s.serv_id = '{$srv}'"; - } - - $sqlTempo = $this->___tempoAtendimento && $this->___tempoAtendimento > 10 ? "\nAND strtoint(b.param2) >= " . $this->___tempoAtendimento : ''; - - $query1 = ($query1 . $query . $addAgente . $sqlTempo . sprintf("\nORDER BY %s ", $mostraColunaServicos ? 's.serv_id, a.calldate' : 'a.calldate')); - - $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"]; + 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'"; } - $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)); + + $sqlTempo = $this->___tempoAtendimento && $this->___tempoAtendimento > 10 ? " AND strtoint(b.param2) >= ".$this->___tempoAtendimento : ''; - $this->___dataRel[] = $dataRel; - } + $result = $this->___GetQuery($query1 . $query . $sqlTempo ." ORDER BY 1 "); + $row = pg_fetch_all($result); + $this->SetData($row ? $row : array()); - 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; + $result2 = $this->___GetQuery($query2 . $query . " ORDER BY 2 "); + $row2 = pg_fetch_all($result2); + $this->SetData($row2 ? $row2 : array()); } - $dataRel[] = $linha; - $linha = array('DADOS'); - foreach ($filtro as $values) { - list($label, $value) = explode(":", $values); - $linha[] = $value; + 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; + } - $dataRel[] = $linha; - $dadosCabecalio = array( - 'Data', 'Hora', 'Origem', 'Tempo', 'Agente', 'Status' - ); + protected function ___PreparaExcel() { + $dataRel = array(); + $filtro = $this->___FiltrosRelatorio(); - $dadosField = array( - 'data', 'hora', 'origem', 'tmo', 'agente', 'status' - ); - - if ($mostraColunaServicos) { - $dadosCabecalio = array_merge(['Servico'], $dadosCabecalio); - $dadosField = array_merge(['serv_id'], $dadosField); - } + /* + * Inicia o relatório. + */ - $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"; + /* + * Cria os filtros + */ + $linha = array('LABEL'); + foreach ($filtro as $values) { + list($label, $value) = explode(":", $values); + $linha[] = $label; + } + $dataRel[] = $linha; $linha = array('DADOS'); - foreach ($dadosField as $key) { - $linha[] = $row["$key"]; + foreach ($filtro as $values) { + list($label, $value) = explode(":", $values); + $linha[] = $value; } $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); - $this->___dataRel[] = $dataRel; - } + $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; - 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); - } + $somaReg = 0; + $somaDuracao = 0; + $somaAtendida = 0; + $somaNAtendida = 0; - /* - * 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!')); + /* + * 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); + $this->___dataRel[] = $dataRel; - return; } - $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) { + 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"' + ); - $dataRel[] = sprintf("Total [%s] DURAÇÃO%sATENDIDAS / NA%s / %s", $oldSrv, SecondToStrTime($somaDuracaoServico), $somaAtendidaServico, $somaNAtendidaServico); - $oldSrv = $srv; - $somaDuracaoServico = 0; - $somaAtendidaServico = 0; - $somaNAtendidaServico = 0; - } + /* + * Inicia o relatório. + */ + $dataRel[] = ''; - $somaDuracaoServico += $row['tmo']; - $row['status'] == 1 ? $somaAtendidaServico++ : $somaNAtendidaServico++; - }; + /* + * Monta a linha de cabecalio. + */ - /* - * Linhas de dados. - */ - foreach ($this->GetData()[0] as $row) { + $linha = ''; + $linha .= ""; + $linha .= ""; + $dataRel[] = $linha; - if ($mostraColunaServicos) { - $agrupaServico($row); + /* + * 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; } - $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 = ""; + foreach ($dadosCabecalio as $key => $value) { + $linhaC .= sprintf("%s", $value, $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; + } - $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
'; $dataRel[] = $linha; - } - 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 ___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); + $this->___dataRel[] = $dataRel; } - $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; - } - - $somaDuracaoServico += $row['tmo']; - $row['status'] == 1 ? $somaAtendidaServico++ : $somaNAtendidaServico++; - }; + protected function ___PreparaHtml() { + + } + protected function ___PreparaPdf() { + list($this->___dac, $this->___dataIni, $this->___dataFim, $this->___tipoRelatorio) = $_SESSION["SSstorageFiltros"]; - /* - * Linhas de dados. - */ - foreach ($dados as $row) { + $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; - if ($mostraColunaServicos) { - $agrupaServico($row); + /* + * 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++; } - $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; - } - - if ($mostraColunaServicos) { - $agrupaServico(false); - $widthHeader = array(26, 26, 26, 26, 26, 26, 26); - } else { - $widthHeader = array(26, 26, 26, 26, 26, 26); + $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); } - $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); - } - protected function ___GetAgente() { + protected function ___GetAgente() { - $result = $this->GetData()[1]; + $result = $this->GetData()[1]; - $row = ""; + !$result ? $row .= "" : $row .= ""; + foreach ($result as $agentes) { + $sel = $this->___agente == $agentes['matricula'] ? "selected" : ''; + $row .= sprintf("", $agentes['matricula'], $agentes['apelido']); + } + $row .= ""; + return $row; } - $row .= ""; - return $row; - } - public function ExecutaRelatorio() { - global $jsStartup, $jsJQuery, $smarty; - try { - /* - * Use esta função para validar dados do formulário. - */ - $this->___ValidaForm(); + 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(); + } /* - * Recupera os dados do banco. + * Inclua os scripts necessários aqui. */ - $this->___ConteudoRelatorio(); + $jsJQuery[] = "\$('#dataIni').keypress(function(){formataDataHora(this);}) "; + $jsJQuery[] = "\$('#dataFim').keypress(function(){formataDataHora(this);}) "; - /* - * 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(); + $smarty->assign('filtros', $this->___FiltrosRelatorio()); + $smarty->assign('conteudo', $conteudoRelatorio); + $smarty->assign('msg', $this->GetMsg()); + GetTemplate($smarty, 'relatoriosGrid.tpl'); } - $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 RelRecebidasAgenteSrv($idProg, $dbcon, 1); -$relRecebidasAgente->ExecutaRelatorio(); + $relRecebidasAgente = new RelRecebidasAgente($idProg, $dbcon, 1); + $relRecebidasAgente->ExecutaRelatorio(); ?> diff --git a/scriptApl/functions15.js b/scriptApl/functions15.js index 860a3be..2c5e9f6 100644 --- a/scriptApl/functions15.js +++ b/scriptApl/functions15.js @@ -889,7 +889,7 @@ function ClassificaRegistraRt() var listaClasItem = document.getElementById("listaClasItem"); var classNome = listClas.options[listClas.selectedIndex].text; var proto = ''; - if ((classNome.toUpperCase() == 'VENDA') && ExigeProtoExt()) + if ((classNome.toUpperCase() == 'VENDA' || classNome.toUpperCase() == 'PROTOCOLO') && ExigeProtoExt()) { proto = soNumero(prompt('Informe o Protocolo', '')); @@ -3298,4 +3298,15 @@ function ComplementoCampanha() { ; } +} + +function SelectRel(prog){ + $.ajax({ + url: 'index.php?a=1&idProg=' + prog + "&slc=" + $('#campanha').val(), + type: 'GET', + success: function (res) { + $('#lista option').remove() + $('#lista').append(res) + } + }) } \ No newline at end of file