___agente = isset($_POST['agente']) ? $_POST['agente'] : ''; $this->___fila = isset($_POST['fila']) ? $_POST['fila'] : ''; } function ___FiltrosRelatorio() { $agente = $this->getAgente($this->___agente); if ($this->___media != MEDIA_PRINT_GRID) { /* * Recupera os filtros da sessão do usuário. */ list($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'); } // $tipoRel = !$this->___tipoRelatorio ? '' : 'checked="checked"'; /* * Personalise esta função se necessitar de outras op��es de filtro. */ $filtro = ''; /* * Rotulos. */ $filtro .= ''; $filtro .= ''; $filtro .= ''; $filtro .= ''; $filtro .= ''; $filtro .= ''; $filtro .= ''; /* * Valores. */ $filtro .= ''; $filtro .= sprintf('', $this->getDac($this->___fila)); $filtro .= ''; $filtro .= ''; $filtro .= sprintf('', $agente); $filtro .= ''; $filtro .= ''; $filtro .= ''; $filtro .= '
FilaData InicialData Final Agente 
%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->___tipoRelatorio); return sprintf($filtro, $this->___dataIni, $this->___dataFim, $lkPrint); } protected function ___GetDadosDb() { $dataIni = FormatDtMssql($this->___dataIni); $dataFim = FormatDtMssql($this->___dataFim); $agente = $this->___agente; $fila = $this->___fila; $query = "SELECT DISTINCT a.uniqueid, cliente_id, fila, a.nome, a.matricula, evento, a.data_reg, a.context FROM md_atendimento a INNER JOIN md_evento b ON a.uniqueid = b.uniqueid INNER JOIN pbx_usuarios c ON c.matricula = b.matricula INNER JOIN pbx_queues_grupos d ON d.nome = b.fila WHERE a.data_reg::DATE >= '$dataIni' AND a.data_reg::DATE <= '$dataFim' AND evento = 'START' "; if ($agente) { $query .= " AND a.nome = '$agente' "; } if ($fila) { $query .= " AND b.fila = '$fila' "; } $query .= " ORDER BY a.data_reg"; $result = $this->___GetQuery($query); $row = pg_fetch_all($result); if (!$agente && !$fila) { $_SESSION['SSDataWPP'] = $row; } $this->SetData($row ? $row : array()); $queryDac = "SELECT * FROM pbx_queues_grupos WHERE midiafila = 'S';"; $resultDac = $this->___GetQuery($queryDac); $rowDac = pg_fetch_all($resultDac); $this->SetData($rowDac ? $rowDac : array()); } protected function ___PreparaCsv() { } protected function ___PreparaExcel() { } protected function ___PreparaGrid() { $dataRel = array(); $dadosCabecalio = array( 'Data/Hora' => 'align="center"', 'Origem' => 'align="center"', 'Matricula' => 'align="center"', 'Fila' => 'align=center', 'Perfil' => 'align=center', 'Plataforma' => 'align=center', 'Status' => 'align=center', 'Visualizar' => 'align=center' ); $dadosField = array( 'data_reg' => 'align="center"', 'cliente_id' => 'align="center"', 'matricula' => 'align="center"', 'fila' => 'align="center"', 'nome' => 'align="center"', 'context' => 'align=center', 'evento' => 'align="center"', 'detalhes' => 'align=center' ); /* * 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("
Atendimento WhatsApp
%s
", count(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; /* * Linhas de dados. */ $count = 0; $imgrel = "\"Detalhes"; foreach ($this->GetData()[0] as $row) { $count++; $linkRel = sprintf("%s", base64_encode($row['uniqueid']), $imgrel); $row['data_reg'] = date('d/m/Y H:i:s', strtotime($row['data_reg'])); $row['detalhes'] = $linkRel; $row['nome'] = utf8_decode($row['nome']); $row['context'] = strtoupper($row['context']); // Formata linha de dados. $linha = ""; foreach ($dadosField as $key => $value) { $linha .= sprintf("%s", $value, $row["$key"]); } $linha .= ""; $dataRel[] = $linha; } $dataRel[] = "Total: {$count}"; $dataRel[] = ''; $this->___dataRel[] = $dataRel; } protected function ___PreparaHtml() { } protected function ___PreparaPdf() { } private function getAgente($select = null) { $agentes = array(); foreach ($_SESSION['SSDataWPP'] as $agente) { if (!in_array($agente['nome'], $agentes)) { array_push($agentes, $agente['nome']); } } $opt = ""; return $opt; } private function getDac($select = null) { $filas = array(); foreach ($this->GetData()[1] as $fila) { if (!in_array($fila['nome'], $filas)) { array_push($filas, $fila['nome']); } } $opt = ""; return $filas ? $opt : null; } 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(); } $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'); } } $relMsgWhatsapp = new RelMsgWhatsapp($idProg, $dbcon, 0); $relMsgWhatsapp->ExecutaRelatorio(); ?>