PABX da Simples IP
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

640 lines
29 KiB

<?php
include_once 'util/relatoriosBase.php';
class RelChamadasGeral extends Relatorios {
private $__agente;
private $__tipoLigacao;
private $__classificacao;
private $__pesquisa;
private $__filtro;
private $___servico;
private $__tronco;
public function __construct($idProg, $dbcon, $incDac) {
parent::__construct($idProg, $dbcon, $incDac);
$this->__agente = isset($_POST["listaAgente"]) ? $_POST["listaAgente"] : '';
$this->__tipoLigacao = isset($_POST["tipoLigacao"]) ? $_POST["tipoLigacao"] : 0;
$this->__filtro = isset($_POST["filtro"]) ? $_POST["filtro"] : '';
$this->__classificacao = isset($_POST["classificacao"]) ? $_POST["classificacao"] : '';
$this->__pesquisa = isset($_POST["pesquisa"]) ? $_POST["pesquisa"] : '';
$this->___servico = isset($_POST["listaServico"]) ? $_POST["listaServico"] : 0;
$this->__tronco = isset($_POST["tronco"]) ? $_POST["tronco"] : 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, $this->___agente, $this->__classificacao, $this->__pesquisa) = $_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);
}
$agentes = $this->getAgentes();
$lkPrint = "";
if ($this->___dataCount) {
$prt = '<a href="index.php?idProg=%s&media=%s&tipoRelatorio=%s"><img src="imgSite/%s" alt="Clique aqui para imprimir!" width="24" height="24" border="0"></a>';
$prtHtml = "<a href=\"javaScript:NovaJanela('index.php?idProg=%s&media=%s&tipoRelatorio=%s', '%s', '720', '700', 'scrollbars=YES');\"><img src=\"imgSite/%s\" alt=\"Clique aqui para imprimir!\" width=\"24\" height=\"24\" border=\"0\"></a>";
$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 funcao se necessitar de outras opcoes de filtro.
*/
$filtro = '<table border="0" cellspacing="1" cellpadding="1">';
/*
* Rotulos.
*/
$filtro .= '<tr>';
$filtro .= '<td>Data Inicial</td>';
$filtro .= '<td>Data Final </td>';
if ($this->GetIncDac()){
$filtro .= '<td align="center" valign="middle">Fila</td>';
}
if (GetUsoServico()) {
$filtro .= '<td align="center" valign="middle">Serviço </td>';
}
$filtro .= '<td align="center" valign="middle">Agente</td>';
$filtro .= '<td align="center" valign="middle">Filtro</td>';
$class = $this->__classificacao ? "checked" : '';
$pesq = $this->__pesquisa ? "checked" : '';
$tronco = $this->__tronco ? "checked" : '';
$filtro .= sprintf('<td>'
. '<table>'
. '<tr><td>'
. '<div class="geral">'
. '<input name="classificacao" id="tipoLigacao" type="checkbox" size="15" class="clean" %s value="classificacao"/> Classificação &nbsp'
. '<input name="pesquisa" id="tipoLigacao" type="checkbox" size="15" class="clean" %s value="pesquisa"/> Pesquisa &nbsp'
. '<input name="tronco" id="tipoLigacao" type="checkbox" size="15" class="clean" %s value="tronco"/> Tronco &nbsp'
. '</div>'
. '</td></tr>'
. '</table></td>', $class, $pesq, $tronco);
$filtro .= '</tr>';
/*
* Valores.
*/
$filtro .= '<tr>';
$filtro .= '<td><input name="dataIni" id="dataIni" type="text" size="15" maxlength="10" value="%s" onkeyup="formataData(this)" title="dd/mm/aaaa"></td>';
$filtro .= '<td><input name="dataFim" id="dataFim" type="text" size="15" maxlength="10" value="%s" onkeyup="formataData(this)" title="dd/mm/aaaa"></td>';
if ($this->GetIncDac()){
$filtro .= sprintf('<td>%s</td>', $dacs);
}
if (GetUsoServico()) {
$filtro .= sprintf('<td>%s</td>', GetIdentRota(false, $this->___servico));
}
$filtro .= "<td>$agentes</td>";
$filtro .= sprintf('<td><input name="filtro" id="filtro" type="text" size="24" placeholder="Protocolo/Telefone/Ramal" value="%s" /></td>', $this->__filtro);
$entrada = $this->__tipoLigacao == 2 ? "checked" : "";
$saida = $this->__tipoLigacao == 3 ? "checked" : "";
$ambos = $this->__tipoLigacao == 0 ? "checked" : "";
$filtro .= sprintf('<td>'
. '<table><tr><td><div class="geral" >'
. '<input name="tipoLigacao" id="tipoLigacao" type="radio" size="50" style="margin-left: 25px;" class="clean" %s value="2"/>Entrada &nbsp'
. '<input name="tipoLigacao" id="tipoLigacao" type="radio" size="50" style="margin-left: 25px;" class="clean" %s value="3"/>Saída &nbsp'
. '<input name="tipoLigacao" id="tipoLigacao" type="radio" size="50" style="margin-left: 25px;" class="clean" %s value="0"/>Ambos'
. '</div></td></tr></table>'
. '</td>', $entrada, $saida, $ambos);
$filtro .= '<td><input type="submit" name="btConsulta" id="btConsulta" value="Consultar"></td>';
$filtro .= '<td>%s</td>';
$filtro .= '</tr>';
$filtro .= '</table>';
/*
* 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, $this->__classificacao, $this->__pesquisa);
return sprintf($filtro, $this->___dataIni, $this->___dataFim, $lkPrint);
}
protected function ___GetDadosDb() {
$dataIni = FormatDtMssql($this->___dataIni);
$dataFim = FormatDtMssql($this->___dataFim);
$classificacao = $this->__classificacao ? "LEFT JOIN (SELECT id_bilhetes, STRING_AGG(remove_acentos(clas_descricao || ' -> ' || clit_descricao) , '; ' ORDER BY cr.clas_id) AS classificacao
FROM pbx_classifica_reg cr
INNER JOIN pbx_classifica_atendimento ca ON cr.clas_id = ca.clas_id
INNER JOIN pbx_classifica_item ci ON cr.clit_id = ci.clit_id
WHERE data_reg::DATE >= '$dataIni' AND data_reg::DATE <= '$dataFim'
GROUP BY id_bilhetes) AS class ON class.id_bilhetes = a.uniqueid": '';
$pesquisa = $this->__pesquisa ? "LEFT JOIN (SELECT a.uniqueid, STRING_AGG(remove_acentos(pq_questao || ' -> ' || po_opcao) , '; ' ORDER BY po_display) AS pesquisa
FROM pbx_pesquisa_movimento a
INNER JOIN pbx_pesquisa_questoes b ON b.pp_id = a.pp_id AND b.pq_id = a.pq_id
INNER JOIN pbx_pesquisa_opcoes c ON c.pp_id = b.pp_id AND c.pq_id = b.pq_id AND c.po_id = a.po_id
INNER JOIN pbx_pesquisa_regitra d ON d.uniqueid = a.uniqueid
INNER JOIN pbx_pesquisa e ON e.pp_id = a.pp_id
WHERE a.data_reg::DATE >= '$dataIni' AND a.data_reg::DATE <= '$dataFim'
GROUP BY a.uniqueid) AS pesq ON pesq.uniqueid = a.uniqueid" : '';
$servico = GetUsoServico() ? "\n LEFT JOIN pbx_servicos_registra sr ON sr.uniqueid = a.uniqueid" : '';
$tronco = $this->__tronco ? "\n LEFT JOIN pbx_troncos pt ON a.channel LIKE CONCAT('%', pt.nome, '%') OR a.dstchannel LIKE CONCAT('%', pt.nome, '%')" : '';
$columnPesq = $this->__pesquisa ? "pesquisa," : "";
$columnClass = $this->__classificacao ? "classificacao," : "";
$columnServico = GetUsoServico() ? "coalesce(sr.serv_id, ' - ') as servico," : '';
$columnTronco = $this->__tronco ? "coalesce(pt.nome, ' - ') as tronco," : "";
$query = "SELECT calldate, protocolo, src, dst, tplg_descricao, $columnTronco
CASE WHEN(ed.evento = 'ABANDON')THEN strtoint(ed.param3) ELSE a.billsec END AS tempo_atendimento,
userfield, fila, apelido, evento, $columnClass $columnPesq $columnServico
REPLACE(SUBSTRING(retorno_cliente, POSITION('||' in retorno_cliente), 99999), '||', '') AS dados_cliente,
CASE WHEN (abdsr_agente IS NOT NULL) THEN 'RETORNADA' ELSE '-' END AS retorno_abd
FROM pbx_bilhetes a
LEFT JOIN pbx_eventos_dacs ed ON a.uniqueid = ed.uid2 AND evento IN ('COMPLETAAGENT','COMPLETACALLERRAMAL','COMPLETACALLER','COMPLETECALLERRAMAL','COMPLETEAGENT','COMPLETEAGENTRAMAL','COMPLETECALLER','ABANDON')
LEFT JOIN pbx_usuarios us ON us.matricula = substring(ed.agente,7,4)
LEFT JOIN pbx_protocolo_reg pr ON pr.uniqueid = a.uniqueid
LEFT JOIN pbx_tipo_ligacao tp ON tp.tplg_codigo = a.tipo_chamada
$classificacao
$pesquisa
$servico
$tronco
LEFT JOIN pbx_abandonadas_semretorno asr ON asr.abdsr_uniqueid = a.uniqueid
LEFT JOIN pbx_integracao_reg ir ON ir.reg_uniqueid = a.uniqueid
LEFT JOIN pbx_queues_grupos qg ON qg.nome = ed.fila
WHERE calldate::DATE >= '$dataIni' AND calldate::DATE <= '$dataFim'
AND a.lastapp NOT IN ('Transferred Call','Playback','BackGround', 'AppDial2', 'Goto') ";
if($this->__filtro){
$query .= "AND ((src LIKE '%{$this->__filtro}%') OR (dst LIKE '%{$this->__filtro}%') OR (protocolo::VARCHAR LIKE '%{$this->__filtro}%')) ";
}
if($this->___dac){
$query .= "AND qg.id = {$this->___dac}";
}
if($this->__tipoLigacao){
$query .= "AND tplg_tipo = {$this->__tipoLigacao}";
}
if($this->__agente){
$query .= "AND apelido = '{$this->__agente}' ";
}
if($this->___servico){
$query .= "AND sr.serv_id = '{$this->___servico}'";
}
$query .= "ORDER BY a.uniqueid";
$result = $this->___GetQuery($query);
$row = pg_fetch_all($result);
$this->SetData($row ? $row : array());
}
protected function ___PreparaCsv() {
$dataRel = array();
$filtro = $this->___FiltrosRelatorio();
/*
* Inicia o relatório.
*/
$dataRel[] = GenerateCsvFromArray($filtro);
$dadosCabecalio = array(
'Data Hora',
'Tipo',
'Protocolo',
'Origem',
'Destino',
'Duração',
'Fila',
'Agente',
'Status',
'Retornada ABD.',
);
GetUsoServico() ? $dadosCabecalio[] = 'Servico' : '';
$this->__classificacao ? $dadosCabecalio[] = 'Classificação' : '';
$this->__pesquisa ? $dadosCabecalio[] = 'Pesquisa' : '';
$this->__tronco ? $dadosCabecalio[] = 'Tronco' : '';
$dadosField = array(
'calldate',
'tplg_descricao',
'protocolo',
'src',
'dst',
'tempo_atendimento',
'fila',
'apelido',
'evento',
'retorno_abd'
);
GetUsoServico() ? $dadosField[] = 'servico' : '';
$this->__classificacao ? $dadosField[] = 'classificacao' : '';
$this->__pesquisa ? $dadosField[] = 'pesquisa' : '';
$this->__tronco ? $dadosField[] = 'tronco' : '';
/*
* Monta a linha de cabecalio.
*/
$dataRel[] = GenerateCsvFromArray($dadosCabecalio);
/*
* Linhas de dados.
*/
foreach ($this->GetData()[0] as $row) {
$row['calldate'] = date('d/m/Y H:i:s', strtotime($row['calldate']));
$row['tempo_atendimento'] = SecondToStrTime($row["tempo_atendimento"]);
$row['retorno_abd'] = $row["retorno_abd"] ? $row["retorno_abd"] : '-';
$row['evento'] = $this->__statusEventos($row['evento']);
$row['protocolo'] = $row['protocolo'] ? $row['protocolo'] : '-';
$row['apelido'] = $row['apelido'] ? $row['apelido'] : '-';
$row['classificacao'] = $row['classificacao'] ? RemoveAcentos($row['classificacao']) : '-';
$row['pesquisa'] = $row['pesquisa'] ? RemoveAcentos($row['pesquisa']) : '-';
$row['servico'] = $row['servico'] ? RemoveAcentos($row['servico']) : '-';
// Formata linha de dados.
$linha = array();
foreach ($dadosField as $value) {
$linha[] = $row["$value"];
}
$dataRel[] = GenerateCsvFromArray($linha);
}
$dataRel[] = GenerateCsvFromArray(array('Total', ''));
$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 Hora',
'Tipo',
'Protocolo',
'Origem',
'Destino',
'Duracao',
'Fila',
'Agente',
'Status',
'Retornada ABD.',
);
GetUsoServico() ? $dadosCabecalio[] = 'Servico' : '';
$this->__classificacao ? $dadosCabecalio[] = 'Classificacao' : '';
$this->__pesquisa ? $dadosCabecalio[] = 'Pesquisa' : '';
$this->__tronco ? $dadosCabecalio[] = 'Tronco' : '';
$dadosField = array(
'calldate',
'tplg_descricao',
'protocolo',
'src',
'dst',
'tempo_atendimento',
'fila',
'apelido',
'evento',
'retorno_abd'
);
GetUsoServico() ? $dadosField[] = 'servico' : '';
$this->__classificacao ? $dadosField[] = 'classificacao' : '';
$this->__pesquisa ? $dadosField[] = 'pesquisa' : '';
$this->__tronco ? $dadosField[] = 'tronco' : '';
/*
* 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['calldate'] = date('d/m/Y H:i:s', strtotime($row['calldate']));
$row['tempo_atendimento'] = SecondToStrTime($row["tempo_atendimento"]);
$row['retorno_abd'] = $row["retorno_abd"] ? $row["retorno_abd"] : '-';
$row['evento'] = $this->__statusEventos($row['evento']);
$row['protocolo'] = $row['protocolo'] ? $row['protocolo'] : '-';
$row['apelido'] = $row['apelido'] ? $row['apelido'] : '-';
$row['classificacao'] = $row['classificacao'] ? RemoveAcentos($row['classificacao']) : '-';
$row['pesquisa'] = $row['pesquisa'] ? RemoveAcentos($row['pesquisa']) : '-';
$row['servico'] = $row['servico'] ? RemoveAcentos($row['servico']) : '-';
// Formata linha de dados.
$linha = array('DADOS');
foreach ($dadosField as $key) {
$linha[] = $row["$key"];
}
$dataRel[] = $linha;
}
$dataRel[] = array('LABEL', 'Total');
$this->___dataRel[] = $dataRel;
}
protected function ___PreparaGrid() {
$dataRel = array();
$dadosCabecalio = array(
'Data Hora' => 'align="center"',
'Tipo' => 'align="center"',
'Protocolo' => 'align="center"',
'Origem' => 'align="center"',
'Destino' => 'align="center"',
'Duração' => 'align="center"',
'Fila' => 'align="center"',
'Agente' => 'align="center"',
'Status' => 'align="center"',
'Retornada ABD.' => 'align="center"',
);
GetUsoServico() ? $dadosCabecalio['Serviço'] = 'align="center"' : '';
$this->__classificacao ? $dadosCabecalio['Classificação'] = 'align="center"' : '';
$this->__pesquisa ? $dadosCabecalio['Pesquisa'] = 'align="center"' : '';
$this->__tronco ? $dadosCabecalio['Tronco'] = 'align="center"' : '';
$dadosField = array(
'calldate' => 'align="center"',
'tplg_descricao' => 'align="center"',
'protocolo' => 'align="center"',
'src' => 'align="center"',
'dst' => 'align="center"',
'tempo_atendimento' => 'align="center"',
'fila' => 'align="center"',
'apelido' => 'align="center"',
'evento' => 'align="center"',
'retorno_abd' => 'align="center"'
);
GetUsoServico() ? $dadosField['servico'] = 'align="center"' : '';
$this->__classificacao ? $dadosField['classificacao'] = 'align="center"' : '';
$this->__pesquisa ? $dadosField['pesquisa'] = 'align="center"' : '';
$this->__tronco ? $dadosField['tronco'] = 'align="center"' : '';
/*
* Inicia o relatório.
*/
$dataRel[] = '<table width="100%" cellpadding="2" class="grid">';
/*
* Monta a linha de cabecalio.
*/
$linha = '<tr>';
foreach ($dadosCabecalio as $key => $value) {
$linha .= sprintf("<th %s>%s</th>", $value, $key);
}
$linha .= "</tr>";
$dataRel[] = $linha;
/*
* Verifica se retornou dados
*/
if (!IsPostBack() || !count($this->GetData()[0])) {
$dataRel[] = sprintf("<tr><td align=\"center\" colspan=\"%s\">%s</td></tr></table>", count($dadosCabecalio), (!IsPostBack() ? 'Informe os parametros e clique em consultar!' : 'Nenhum registro encontado!'));
$this->___dataRel[] = $dataRel;
return;
}
/*
* Linhas de dados.
*/
foreach ($this->GetData()[0] as $row) {
$row['calldate'] = date('d/m/Y H:i:s', strtotime($row['calldate']));
$row['tempo_atendimento'] = SecondToStrTime($row["tempo_atendimento"]);
$row['retorno_abd'] = $row["retorno_abd"] ? $row["retorno_abd"] : '-';
$row['evento'] = $this->__statusEventos($row['evento']);
$row['protocolo'] = $row['protocolo'] ? $row['protocolo'] : '-';
$row['apelido'] = $row['apelido'] ? $row['apelido'] : '-';
$row['classificacao'] = $row['classificacao'] ? $row['classificacao'] : '-';
$row['pesquisa'] = $row['pesquisa'] ? $row['pesquisa'] : '-';
// Formata linha de dados.
$linha = "<tr>";
foreach ($dadosField as $key => $value) {
$linha .= sprintf("<td %s>%s</td>", $value, $row["$key"]);
}
$linha .= "</tr>";
$dataRel[] = $linha;
}
/*
* Fecha relatorio.
*/
$dataRel[] = '</table>';
$this->___dataRel[] = $dataRel;
}
protected function ___PreparaHtml() {
}
protected function ___PreparaPdf() {
list($this->___dac, $this->___dataIni, $this->___dataFim, $this->___tipoRelatorio, $this->___agente, $this->__classificacao, $this->__pesquisa) = $_SESSION["SSstorageFiltros"];
$this->settype("L");
/**
* TABELA DADOS PRINCIPAIS
*/
$dadosCabecalio = array(
'Data Hora' => 'C',
'Tipo' => 'C',
'Protocolo' => 'C',
'Origem' => 'C',
'Destino' => 'C',
'Duração' => 'C',
'Fila' => 'C',
'Agente' => 'C',
'Status' => 'C',
'Retornada ABD.' => 'C',
);
GetUsoServico() ? $dadosCabecalio['Serviço'] = 'C' : '';
$this->__classificacao ? $dadosCabecalio['Classificação'] = 'C' : '';
$this->__pesquisa ? $dadosCabecalio['Pesquisa'] = 'C' : '';
$dadosField = array(
'calldate' => 'C',
'tplg_descricao' => 'C',
'protocolo' => 'C',
'src' => 'C',
'dst' => 'C',
'tempo_atendimento' => 'C',
'fila' => 'C',
'apelido' => 'C',
'evento' => 'C',
'retorno_abd' => 'C'
);
GetUsoServico() ? $dadosField['servico'] = 'C' : '';
$this->__classificacao ? $dadosField['classificacao'] = 'C' : '';
$this->__pesquisa ? $dadosField['pesquisa'] = 'C' : '';
$dados = $this->GetData()[0];
$x = 0;
foreach ($dados as $row) {
$dados[$x]['calldate'] = date('d/m/Y H:i:s', strtotime($row['calldate']));
$dados[$x]['tempo_atendimento'] = SecondToStrTime($row["tempo_atendimento"]);
$dados[$x]['retorno_abd'] = $row["retorno_abd"] ? $row["retorno_abd"] : '-';
$dados[$x]['evento'] = $this->__statusEventos($row['evento']);
$dados[$x]['protocolo'] = $row['protocolo'] ? $row['protocolo'] : '-';
$dados[$x]['apelido'] = $row['apelido'] ? $row['apelido'] : '-';
$dados[$x]['classificacao'] = $row['classificacao'] ? $row['classificacao'] : '-';
$dados[$x]['pesquisa'] = $row['pesquisa'] ? $row['pesquisa'] : '-';
$dados[$x]['servico'] = $row['servico'] ? $row['servico'] : '-';
$x++;
}
$widthHeader = array(25, 30, 17, 17, 17, 13, 30, 30, 35, 30);
GetUsoServico() ? $widthHeader[] = 30 : '';
$this->__classificacao ? $widthHeader[] = 30 : '';
$this->__pesquisa ? $widthHeader[] = 30 : '';
//Monta o array para passar para o prepara; Necessário passar 6 parametros
$table1 = array($dadosCabecalio, $dadosField, $dados, $widthHeader, 0, 1);
$this->___dataRel = array($table1);
}
protected function getAgentes() {
$codSel = $this->__agente;
$sel = $this->__agente ? '' : 'selected';
$agentes = "<select name=\"listaAgente\" id=\"listaAgente\" size=\"1\">";
$agentes .= "<option value=\"0\" $sel>Todos</option>";
$query = sprintf("SELECT apelido AS nome
FROM pbx_usuarios u
WHERE EXISTS(SELECT '' FROM pbx_eventos_agentes WHERE matricula = u.matricula
AND CAST(login as date) >= '%s'
AND CAST(login as date) <= '%s')", FormatDtMssql($this->___dataIni), FormatDtMssql($this->___dataFim));
$result = pg_query($query);
if($result){
while ($dados = pg_fetch_row($result)) {
if ($codSel == $dados[0]) {
$sel = "selected";
$codSel = $dados[0];
} else {
$sel = "";
}
$agentes .= "<option value=\"$dados[0]\" $sel>$dados[0]</option>";
}
}
$agentes .= "</select>";
return $agentes;
}
public function __statusEventos($status){
// 'COMPLETECALLER', 'COMPLETEAGENTRAMAL'
$eventos = [
'COMPLETAAGENT' => "ATENDIDA - DESL. AGENTE",
'COMPLETACALLERRAMAL' => "ATENDIDA - DESL. CLIENTE",
'COMPLETACALLER' => "ATENDIDA - DESL. CLIENTE",
'COMPLETECALLERRAMAL' => "ATENDIDA - DESL. CLIENTE",
'COMPLETEAGENT' => "ATENDIDA - DESL. AGENTE",
'COMPLETEAGENTRAMAL' => "ATENDIDA - DESL. AGENTE",
'COMPLETECALLER' => "ATENDIDA - DESL. CLIENTE",
'ABANDON' => "ABANDONADA",
'TRANSFER' => "TRANSFERIDA",
'BUSY' => "OCUPADA",
];
return $eventos[$status];
}
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');
}
}
$relChamadasGeral = new RelChamadasGeral($idProg, $dbcon, 1);
$relChamadasGeral->ExecutaRelatorio();
?>