___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 ___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'); } /* * Personalise esta função se necessitar de outras opções de filtro. */ $filtro = ''; /* * 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); 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() { $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, CASE WHEN (disponivel = 1)THEN 'DISPONIVEL' ELSE 'INDISPONIVEL' END AS disponivel, CASE WHEN (classificado = -1) THEN 'NAO OBRIGATORIO' WHEN (classificado = 0) THEN 'NAO CLASSIFICADO' WHEN (classificado = 1 OR classificado = 2) THEN 'CLASSIFICADO' END AS classificado, 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"; 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'"; 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"; 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'"; if (GetUsoServico() && $srv) { $query .= "\nand s.serv_id = '{$srv}'"; } $query .= " GROUP BY a.matricula,apelido,d.nome, login, logoff ORDER BY login"; } $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(); /* * 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"]; } $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) { // 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"]; } $dataRel[] = GenerateCsvFromArray($linha); } $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', '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; /* * 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; /* * 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; 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"]; } $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); } $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"]); } $linha .= ""; $dataRel[] = $linha; } $dataRel[] = '
%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; /* * Fecha relatorio. */ $dataRel1[] = '
%s
%s%s%s%s%s%s%s%s%s
'; } $this->___dataRel[] = $dataRel1; } protected function ___PreparaHtml() { } 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); $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(); } /* * 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(); ?>