___matricula = isset($_GET["mat"]) ? $_GET["mat"] : ''; $this->___dataIni = isset($_GET["dataIni"]) ? $_GET["dataIni"] : ''; $this->___dataFim = isset($_GET["dataFim"]) ? $_GET["dataFim"] : ''; $_POST['btConsulta'] = 1; } public function ___ValidaForm() { if (!$_SESSION["SSstorageFiltros"]) { return; } if (empty($this->___matricula)) { GeraExcept('Informe uma matricula válida!'); } } function ___FiltrosRelatorio() { if ($this->___media != MEDIA_PRINT_GRID) { /* * Recupera os filtros da sessão do usuário. */ list($this->___dataIni, $this->___dataFim, $this->___matricula, $this->___tipoRelatorio) = $_SESSION["SSstorageFiltros"]; $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, $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'); } $_SESSION["SSstorageFiltros"] = array($this->___dataIni, $this->___dataFim, $this->___matricula, $this->___tipoRelatorio); return sprintf($lkPrint); } protected function ___GetDadosDb() { $dataIni = FormatDtMssql($this->___dataIni); $dataFim = FormatDtMssql($this->___dataFim); $matricula = $this->___matricula; $query = "select a.calldate as data, c.apelido as agente, a.src as fone, (select q.destino from pbx_bilhetes_complemento q where q.uniqueid2 = a.uniqueid order by data_registro desc limit 1)as dst, d.fila, a.billsec as tempo, case when(a.disposition = 'ANSWERED')then 'ATENDIDA' else 'ABANCONADA' end as status from pbx_bilhetes a,pbx_usuarios c, pbx_eventos_dacs d where c.matricula = substring(d.agente, 7, 4) and d.uid2 = a.uniqueid and d.evento in('COMPLETEAGENT','COMPLETECALLER','COMPLETAAGENT','COMPLETACALLER') and a.lastapp <> 'Transferred Call' and a.data_bilhete >= '$dataIni' and a.data_bilhete <= '$dataFim' and c.matricula = '$matricula' and exists(select '' from pbx_bilhetes where data_bilhete = a.data_bilhete and accountcode = a.uniqueid) order by a.calldate desc"; $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); $dadosCabecalio = array('Data','Agente','Fone','Destino','Fila','Duracao','Status'); $dadosField = array('data','agente','fone','dst','fila','tempo','status'); $dataRel[] = GenerateCsvFromArray($dadosCabecalio); $somaReg = 0; /* * Linhas de dados. */ foreach ($this->GetData()[0] as $row) { $somaReg ++; $row['data'] = date('d/m/Y H:i:s', strtotime($row['data'])); $row['tempo'] = SecondToStrTime(round($row['tempo'])); $row['fone'] = ocultarTelefone($row['fone']); $row['dst'] = ocultarTelefone($row['dst']); $linha = array(); foreach ($dadosField as $key) { $linha[] = $row["$key"]; } $dataRel[] = GenerateCsvFromArray($linha); } $dataRel[] = GenerateCsvFromArray(array('Total:'. $somaReg)); $this->___dataRel[] = $dataRel; } 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; } $dataRel[] = $linha; $dadosCabecalio = array('Data','Agente','Fone','Destino','Fila','Duracao','Status'); $dadosField = array('data','agente','fone','dst','fila','tempo','status'); /* * Monta a linha de cabecalio. */ $linha = array('LABEL'); foreach ($dadosCabecalio as $value) { $linha[] = $value; } $dataRel[] = $linha; $somaReg = 0; /* * Linhas de dados. */ foreach ($this->GetData()[0] as $row) { $somaReg ++; $row['data'] = date('d/m/Y H:i:s', strtotime($row['data'])); $row['tempo'] = SecondToStrTime(round($row['tempo'])); $row['fone'] = ocultarTelefone($row['fone']); $row['dst'] = ocultarTelefone($row['dst']); // Formata linha de dados. $linha = array('DADOS'); foreach ($dadosField as $key) { $linha[] = $row["$key"]; } $dataRel[] = $linha; } $dataRel[] = array('LABEL', 'Total: '. $somaReg); $this->___dataRel[] = $dataRel; } protected function ___PreparaGrid() { $dataRel = array(); $dadosCabecalio = array( 'Data' => 'align="center"', 'Agente' => 'align="center"', 'Fone' => 'align="center"', 'Destino' => 'align="center"', 'Fila' => 'align="center"', 'Duração' => 'align="center"', 'Status' => 'align="center"' ); $dadosField = array( 'data' => 'align="center"', 'agente' => 'align="center"', 'fone' => 'align="center"', 'dst' => 'align="center"', 'fila' => 'align="center"', 'tempo' => 'align="center"', 'status' => 'align="center"' ); /* * Inicia o relatório. */ $dataRel[] = '
Transferência
'; $dataRel[] = ''; /* * 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; } $linhaC = ""; foreach ($dadosCabecalio as $key => $value) { $linhaC .= sprintf("%s", $value, $key); } $linhaC .= ""; $dataRel[] = $linhaC; $somaReg = 0; /* * Linhas de dados. */ foreach ($this->GetData()[0] as $row) { $somaReg ++; $row['data'] = date('d/m/Y H:i:s', strtotime($row['data'])); $row['tempo'] = SecondToStrTime(round($row['tempo'])); $row['fone'] = ocultarTelefone($row['fone']); $row['dst'] = ocultarTelefone($row['dst']); $linha = ""; foreach ($dadosField as $key => $value) { $linha .= sprintf("%s", $value, $row["$key"]); } $linha .= ""; $dataRel[] = $linha; } $dataRel[] = "Total: $somaReg"; $dataRel[] = ""; $this->___dataRel[] = $dataRel; } protected function ___PreparaHtml() { } protected function ___PreparaPdf() { list($this->___dataIni, $this->___dataFim, $this->___matricula, $this->___tipoRelatorio) = $_SESSION["SSstorageFiltros"]; $dadosCabecalio = array( 'Data' => 'C', 'Agente' => 'C', 'Fone' => 'C', 'Destino' => 'C', 'Fila' => 'C', 'Duração' => 'C', 'Status' => 'C' ); $dadosField = array( 'data' => 'C', 'agente' => 'C', 'fone' => 'C', 'dst' => 'C', 'fila' => 'C', 'tempo' => 'C', 'status' => 'C' ); $somaReg = 0; $x = 0; $dados = $this->GetData()[0]; /* * Linhas de dados. */ foreach ($dados as $row) { $somaReg ++; $dados[$x]['data'] = date('d/m/Y H:i:s', strtotime($row['data'])); $dados[$x]['tempo'] = SecondToStrTime(round($row['tempo'])); $dados[$x]['fone'] = ocultarTelefone($row['fone']); $dados[$x]['dst'] = ocultarTelefone($row['dst']); $x++; } $widthHeader = array(28, 28, 28, 28, 28, 26, 26); $totaliza = array("Total: ".$somaReg,'','','','','',''); $table = array($dadosCabecalio, $dadosField, $dados, $widthHeader, $totaliza, 0); $this->___dataRel = array($table); } public function ExecutaRelatorio() { global $jsStartup, $jsJQuery, $smarty; try { $this->___FiltrosRelatorio(); /* * 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'); } } $relTransferAgenteDet = new RelAgtDetalhe($idProg, $dbcon, 0); $relTransferAgenteDet->ExecutaRelatorio(); ?>