|
|
<?php |
|
|
include_once 'util/relatoriosBase.php'; |
|
|
require("pesquisaFuncoes.php"); |
|
|
|
|
|
class RelPesquisaAudio extends Relatorios { |
|
|
|
|
|
private $___lstPesquisa = ''; |
|
|
private $___plId = 0; |
|
|
private $___plDescricao = ''; |
|
|
private $___ppId = 0; |
|
|
private $___ppNome = ''; |
|
|
private $___datas = array(); |
|
|
private $___protocolo = 0; |
|
|
private $___matricula; |
|
|
private $___opcResposta; |
|
|
private $___servico; |
|
|
|
|
|
public function __construct($idProg, $dbcon, $incDac) { |
|
|
parent::__construct($idProg, $dbcon, $incDac); |
|
|
$this->___dac = isset($_POST["listaDacs"]) ? $_POST["listaDacs"] : 0; |
|
|
$this->___lstPesquisa = isset($_POST["lstPesquisa"]) ? $_POST["lstPesquisa"] : '0| | | |0| '; |
|
|
$this->___protocolo = isset($_POST['protocolo']) ? $_POST['protocolo'] : ''; |
|
|
$this->___matricula = isset($_POST["matricula"]) ? $_POST["matricula"] : 0; |
|
|
$this->___opcResposta = isset($_POST["lstOpcoes"]) ? $_POST["lstOpcoes"] : -1; |
|
|
$this->___servico = isset($_POST["listaServico"]) ? $_POST["listaServico"] : 0; |
|
|
$this->___GetRelAudio(); |
|
|
} |
|
|
|
|
|
function ___ValidaForm() { |
|
|
parent::___ValidaForm(); |
|
|
if (!IsPostBack()) { |
|
|
return; |
|
|
} |
|
|
if (!$this->___lstPesquisa) { |
|
|
GeraExcept('Informe uma pesquisa!'); |
|
|
} |
|
|
} |
|
|
|
|
|
function ___FiltrosRelatorio() { |
|
|
global $dbcon; |
|
|
|
|
|
if ($this->___lstPesquisa) { |
|
|
$lstPesq = explode('|', $this->___lstPesquisa); |
|
|
$this->___plId = $lstPesq[0]; |
|
|
$this->___ppId = $lstPesq[4]; |
|
|
} |
|
|
|
|
|
$lstPesquisa = GetPesquisaRel($dbcon, $this->___plId, $this->___matricula); |
|
|
if ($this->___media != MEDIA_PRINT_GRID) { |
|
|
/* |
|
|
* Recupera os filtros da sessao do usuario. |
|
|
*/ |
|
|
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("%sData Inicial: %s Data Final: %s Tipo: %s", $fila, $this->___dataIni, $this->___dataFim, ($this->___tipoRelatorio ? 'Anal<EFBFBD>tico' : 'Sint<EFBFBD>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 = '<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 opnioes de filtro. |
|
|
*/ |
|
|
$filtro = '<table border="0" cellspacing="1" cellpadding="1">'; |
|
|
/* |
|
|
* Rotulos. |
|
|
*/ |
|
|
$filtro .= '<tr>'; |
|
|
$filtro .= '<td>Pesquisa</td><td> </td><td> </td>'; |
|
|
$filtro .= '<td>Op<EFBFBD><EFBFBD>o</td><td> </td><td> </td>'; |
|
|
$filtro .= '</tr>'; |
|
|
$filtro .= '<tr>'; |
|
|
$filtro .= "<td colspan='3'><select style=\"width:400px\" name=\"lstPesquisa\">$lstPesquisa</select></td>"; |
|
|
$filtro .= "<td colspan='4'>" . $this->GetOpcoesPesquisa($dbcon, $this->___ppId, $this->___opcResposta) . "</td>"; |
|
|
$filtro .= "</tr>"; |
|
|
|
|
|
$filtro .= "<tr>"; |
|
|
if ($this->GetIncDac()) |
|
|
$filtro .= '<td>Fila</td>'; |
|
|
$filtro .= GetUsoServico() ? '<td>Servi<EFBFBD>o</td>' : ''; |
|
|
$filtro .= '<td>Agente </td>'; |
|
|
$filtro .= '<td>Data Inicial</td>'; |
|
|
$filtro .= '<td>Data Final </td>'; |
|
|
$filtro .= '<td>Protocolo</td>'; |
|
|
$filtro .= '<td align="center" valign="middle"> </td>'; |
|
|
$filtro .= '</tr>'; |
|
|
|
|
|
/* |
|
|
* Valores. |
|
|
*/ |
|
|
$filtro .= '<tr>'; |
|
|
if ($this->GetIncDac()) |
|
|
$filtro .= sprintf('<td>%s</td>', $dacs); |
|
|
if (GetUsoServico()) { |
|
|
$filtro .= sprintf('<td>%s</td>', GetIdentRota(false, $this->___servico)); |
|
|
} |
|
|
$filtro .= "<td><select name='matricula'>" . GetPesquisaAgente($dbcon, $this->___plId, $this->___matricula, $this->___dac, FormatDtMssql($this->___dataIni), FormatDtMssql($this->___dataFim), 1) . "</select></td>"; |
|
|
$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>'; |
|
|
$filtro .= "<td><input name=\"protocolo\" id=\"prot\" type=\"text\" size=\"15\" maxlength=\"15\" value=\"\" title=\"Protocolo de Atendimento\"></td>"; |
|
|
$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 emissao dos relatoios para impressao. |
|
|
*/ |
|
|
$_SESSION["SSstorageFiltros"] = array($this->___dac, $this->___dataIni, $this->___dataFim); |
|
|
|
|
|
return sprintf($filtro, $this->___dataIni, $this->___dataFim, $lkPrint); |
|
|
} |
|
|
|
|
|
protected function ___GetDadosDb($pqId = null) { |
|
|
global $dbcon; |
|
|
|
|
|
$dataIni = FormatDtMssql($this->___dataIni); |
|
|
$dataFim = FormatDtMssql($this->___dataFim); |
|
|
$plId = $this->___plId; |
|
|
$ppId = $this->___ppId; |
|
|
$dac = $this->___dac; |
|
|
$ppNome = $this->___ppNome; |
|
|
$plDescricao = $this->___plDescricao; |
|
|
$datas = $this->___datas; |
|
|
$protocolo = $this->___protocolo; |
|
|
$matricula = $this->___matricula; |
|
|
$srv = $this->___servico; |
|
|
$mostraColunaServicos = GetUsoServico() == RELATORIO_SERVICOS_HABILITA; |
|
|
|
|
|
GetDadosPesq($dbcon, $this->___lstPesquisa, $plId, $plDescricao, $ppId, $ppNome, $datas); |
|
|
|
|
|
$query = "SELECT DISTINCT e.pp_nome, a.id_dac, f.nome AS nome_dac, a.pm_data, |
|
|
a.user_reg, c.nome AS agente, b.userfield, d.protocolo, |
|
|
b.src, g.po_opcao |
|
|
FROM pbx_pesquisa_movimento a |
|
|
INNER JOIN pbx_bilhetes b ON (substring(dcontext,1,3) = 'psq' AND b.accountcode = a.uniqueid) OR (b.accountcode = '' AND b.uniqueid = a.uniqueid) |
|
|
INNER JOIN pbx_eventos_dacs h ON h.uid2 = b.uniqueid |
|
|
INNER JOIN pbx_usuarios c ON c.matricula = substring(h.agente, 7,4) |
|
|
LEFT JOIN pbx_protocolo_reg d ON d.uniqueid = a.uniqueid |
|
|
INNER JOIN pbx_pesquisa e ON e.pp_id = a.pp_id |
|
|
INNER JOIN pbx_dacs f ON f.id = a.id_dac |
|
|
INNER JOIN pbx_pesquisa_opcoes g ON g.pp_id = a.pp_id AND g.po_id = a.po_id\n"; |
|
|
|
|
|
if (GetUsoServico()) { |
|
|
$query .= " LEFT JOIN pbx_servicos_registra s ON s.uniqueid = a.uniqueid \n"; |
|
|
} |
|
|
|
|
|
$query .= " |
|
|
WHERE b.lastapp <> 'Transferred Call' |
|
|
AND COALESCE(b.userfield, '') <> '' |
|
|
AND duration > 0 |
|
|
AND evento IN ('COMPLETEAGENT','COMPLETECALLER', 'TRANSFER','COMPLETEAGENTRAMAL','COMPLETECALLERRAMAL', 'COMPLETACALLER', 'COMPLETAAGENT') "; |
|
|
|
|
|
if (!$protocolo) { |
|
|
$query .= "AND a.id_dac = '$dac' |
|
|
AND a.pp_id = '$ppId' |
|
|
AND a.pm_data >= '$dataIni' |
|
|
AND a.pm_data <= '$dataFim' "; |
|
|
} |
|
|
|
|
|
if ($matricula && !$protocolo) { |
|
|
$query .= " AND a.user_reg = '$matricula' "; |
|
|
} |
|
|
|
|
|
if (!$protocolo && ($this->___opcResposta != '-1')) { |
|
|
$query .= "AND g.po_id = '{$this->___opcResposta}' "; |
|
|
} |
|
|
|
|
|
if ($protocolo) { |
|
|
$query .= "AND d.protocolo = '$protocolo' "; |
|
|
} |
|
|
|
|
|
if (GetUsoServico() && $srv) { |
|
|
$query .= " AND s.serv_id = '{$srv}' \n"; |
|
|
} |
|
|
|
|
|
$query .= " ORDER BY c.nome, a.pm_data"; |
|
|
|
|
|
$result = $this->___GetQuery($query); |
|
|
$row = pg_fetch_all($result); |
|
|
$this->SetData($row ? $row : array()); |
|
|
} |
|
|
|
|
|
protected function ___PreparaCsv() { |
|
|
global $dbcon; |
|
|
$dataRel = array(); |
|
|
$filtro = $this->___FiltrosRelatorio(); |
|
|
|
|
|
/* |
|
|
* Inicia o relat<EFBFBD>rio. |
|
|
*/ |
|
|
$dataRel[] = GenerateCsvFromArray($filtro); |
|
|
|
|
|
$dadosCabecalio = array('Data', 'Agente', 'Numero Cliente', 'Protocolo', 'Op<EFBFBD><EFBFBD>o', 'Audio'); |
|
|
$dadosField = array('pm_data', 'agente', 'src', 'protocolo', 'po_opcao', 'userfield'); |
|
|
|
|
|
$dataRel[] = GenerateCsvFromArray($dadosCabecalio); |
|
|
|
|
|
/* |
|
|
* Monta a linha de cabecalio. |
|
|
*/ |
|
|
|
|
|
/* |
|
|
* Linhas de dados. |
|
|
*/ |
|
|
foreach ($this->GetData()[0] as $row) { |
|
|
$dac = GetDacDesc($dbcon, $this->___dac); |
|
|
$downloadAudio = VerificaPerfilAcesso($dbcon, GetIdProgFromNomeArq('downloadAudio.php')); |
|
|
$acessoAudio = GetAcessoAudio($dac); |
|
|
|
|
|
if (!$downloadAudio || IsAdmin() || !$acessoAudio) { |
|
|
$msgAudio = "[ SEM PERMISSAO ]"; |
|
|
} else { |
|
|
$msgAudio = sprintf("[ %s ]", RemoveAcentos($row['userfield'])); |
|
|
} |
|
|
|
|
|
$row['src'] = ocultarTelefone($row['src']); |
|
|
$row['agente'] = RemoveAcentos($row['agente']); |
|
|
$row['pm_data'] = date('d/m/Y', strtotime($row['pm_data'])); |
|
|
$row['protocolo'] = $row['protocolo'] ? $row['protocolo'] : ' ---- '; |
|
|
$row['userfield'] = $msgAudio; |
|
|
|
|
|
$linha = array(); |
|
|
foreach ($dadosField as $key) { |
|
|
$linha[] = $row["$key"]; |
|
|
} |
|
|
|
|
|
$dataRel[] = GenerateCsvFromArray($linha); |
|
|
} |
|
|
|
|
|
$this->___dataRel[] = $dataRel; |
|
|
} |
|
|
|
|
|
protected function ___PreparaExcel() { |
|
|
global $dbcon; |
|
|
$dataRel = array(); |
|
|
$filtro = $this->___FiltrosRelatorio(); |
|
|
|
|
|
/* |
|
|
* 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', 'Numero Cliente', 'Protocolo', 'Opcao', 'Audio'); |
|
|
$dadosField = array('pm_data', 'agente', 'src', 'protocolo', 'po_opcao', 'userfield'); |
|
|
|
|
|
$linha = array('LABEL'); |
|
|
foreach ($dadosCabecalio as $value) { |
|
|
$linha[] = $value; |
|
|
} |
|
|
|
|
|
$dataRel[] = $linha; |
|
|
|
|
|
/* |
|
|
* Monta a linha de cabecalio. |
|
|
*/ |
|
|
|
|
|
|
|
|
/* |
|
|
* Linhas de dados. |
|
|
*/ |
|
|
foreach ($this->GetData()[0] as $row) { |
|
|
|
|
|
$dac = GetDacDesc($dbcon, $this->___dac); |
|
|
$downloadAudio = VerificaPerfilAcesso($dbcon, GetIdProgFromNomeArq('downloadAudio.php')); |
|
|
$acessoAudio = GetAcessoAudio($dac); |
|
|
|
|
|
if (!$downloadAudio || IsAdmin() || !$acessoAudio) { |
|
|
$msgAudio = "[ SEM PERMISSAO ]"; |
|
|
} else { |
|
|
$msgAudio = sprintf("[ %s ]", RemoveAcentos($row['userfield'])); |
|
|
} |
|
|
|
|
|
$row['src'] = ocultarTelefone($row['src']); |
|
|
$row['agente'] = RemoveAcentos($row['agente']); |
|
|
$row['pm_data'] = date('d/m/Y', strtotime($row['pm_data'])); |
|
|
$row['protocolo'] = $row['protocolo'] ? $row['protocolo'] : ' ---- '; |
|
|
$row['userfield'] = $msgAudio; |
|
|
|
|
|
$linha = array('DADOS'); |
|
|
foreach ($dadosField as $key) { |
|
|
$linha[] = $row["$key"]; |
|
|
} |
|
|
|
|
|
$dataRel[] = $linha; |
|
|
} |
|
|
|
|
|
$this->___dataRel[] = $dataRel; |
|
|
} |
|
|
|
|
|
protected function ___PreparaGrid() { |
|
|
global $dbcon, $infoDispositivo; |
|
|
$dataRel = array(); |
|
|
|
|
|
$dadosCabecalio = array( |
|
|
'Data' => 'align="left"', |
|
|
'Agente' => 'align="left"', |
|
|
'Numero Cliente' => 'align="left"', |
|
|
'Protocolo' => 'align="center"', |
|
|
'Op<EFBFBD><EFBFBD>o' => 'align="center"', |
|
|
'<EFBFBD>udio' => 'align="center"' |
|
|
); |
|
|
|
|
|
$dadosField = array( |
|
|
'pm_data' => 'align="left"', |
|
|
'agente' => 'align="left"', |
|
|
'src' => 'align="left"', |
|
|
'protocolo' => 'align="center"', |
|
|
'po_opcao' => 'align="right"', |
|
|
'userfield' => 'align="center"' |
|
|
); |
|
|
|
|
|
/* |
|
|
* Monta a linha de cabecalio. |
|
|
*/ |
|
|
$dataRel[] = '<table width="50%" cellpadding="2" class="grid">'; |
|
|
$dataRel[] = "<tr><th colspan='6'>Relat<EFBFBD>rio Pesquisa de <EFBFBD>udio</th></tr>"; |
|
|
$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. |
|
|
*/ |
|
|
$total = 0; |
|
|
foreach ($this->GetData()[0] as $row) { |
|
|
$row['src'] = ocultarTelefone($row['src']); |
|
|
$row['pm_data'] = date('d/m/Y', strtotime($row['pm_data'])); |
|
|
$row['protocolo'] = $row['protocolo'] ? $row['protocolo'] : ' ---- '; |
|
|
$dac = GetDacDesc($dbcon, $this->___dac); |
|
|
$downloadAudio = VerificaPerfilAcesso($dbcon, GetIdProgFromNomeArq('downloadAudio.php')); |
|
|
$acessoAudio = GetAcessoAudio($dac); |
|
|
|
|
|
if (!$downloadAudio || IsAdmin() || !$acessoAudio) { |
|
|
if (IsAdmin()) { |
|
|
$msgAudio = "Usu<EFBFBD>rio Administrador n<EFBFBD>o tem permiss<EFBFBD>o para acessar <EFBFBD>udios!"; |
|
|
} else { |
|
|
$msgAudio = "Este usu<EFBFBD>rio n<EFBFBD>o possui permiss<EFBFBD>es para acessar <EFBFBD>udios!"; |
|
|
} |
|
|
|
|
|
$linkAudio = sprintf("<img src=\"imgSite/lockClose.gif\" width=\"22\" height=\"22\" title=\"%s\" border=\"0\">", $msgAudio); |
|
|
} else { |
|
|
if ($infoDispositivo->isMobile()) { |
|
|
$audioMobile = str_ireplace(".WAV", ".MP3", $row['userfield']); |
|
|
$linkAudio = "<a href=\"index.php?idProg=208&audioMobile=$audioMobile&audio={$row['userfield']}\" style=\"color: #000;\" target=\"_blank\">" . "<img src=\"imgSite/sound22.png\" width=\"22\" height=\"22\" border=\"0\">" . "</a>"; |
|
|
} else { |
|
|
$linkAudio = "<a href=\"index.php?idProg=208&audio={$row['userfield']}\" style=\"color: #000;\">" . "<img src=\"imgSite/sound22.png\" width=\"22\" height=\"22\" border=\"0\">" . "</a>"; |
|
|
} |
|
|
} |
|
|
|
|
|
$row['userfield'] = $linkAudio; |
|
|
|
|
|
// Formata linha de dados. |
|
|
$linha = "<tr>"; |
|
|
foreach ($dadosField as $key => $value) { |
|
|
$linha .= sprintf("<td %s>%s</td>", $value, $row["$key"]); |
|
|
} |
|
|
$linha .= "</tr>"; |
|
|
$dataRel[] = $linha; |
|
|
$total++; |
|
|
} |
|
|
$dataRel[] = "<tr><th colspan='3'>Total</th> <th colspan='3'>$total</th></tr>"; |
|
|
/* |
|
|
* Fecha relatorio. |
|
|
*/ |
|
|
$dataRel[] = '</table>'; |
|
|
$this->___dataRel[] = $dataRel; |
|
|
} |
|
|
|
|
|
protected function ___PreparaHtml() { |
|
|
|
|
|
} |
|
|
|
|
|
protected function ___PreparaPdf() { |
|
|
global $dbcon; |
|
|
list($this->___dac, $this->___dataIni, $this->___dataFim) = $_SESSION["SSstorageFiltros"]; |
|
|
|
|
|
/** |
|
|
* TABELA DADOS PRINCIPAIS |
|
|
*/ |
|
|
$dadosCabecalio = array( |
|
|
'Data' => 'C', |
|
|
'Agente' => 'C', |
|
|
'Numero Cliente' => 'C', |
|
|
'Protocolo' => 'C', |
|
|
'Op<EFBFBD><EFBFBD>o' => 'C', |
|
|
'<EFBFBD>udio' => 'C' |
|
|
); |
|
|
|
|
|
$dadosField = array( |
|
|
'pm_data' => 'C', |
|
|
'agente' => 'L', |
|
|
'src' => 'C', |
|
|
'protocolo' => 'C', |
|
|
'po_opcao' => 'C', |
|
|
'userfield' => 'C' |
|
|
); |
|
|
|
|
|
$dados = $this->GetData()[0]; |
|
|
$z = 0; |
|
|
|
|
|
$dataQst = array(); |
|
|
$widthHeader = array(15, 37, 37, 10, 15, 45); |
|
|
|
|
|
foreach ($dados as $row) { |
|
|
$dac = GetDacDesc($dbcon, $this->___dac); |
|
|
$downloadAudio = VerificaPerfilAcesso($dbcon, GetIdProgFromNomeArq('downloadAudio.php')); |
|
|
$acessoAudio = GetAcessoAudio($dac); |
|
|
|
|
|
if (!$downloadAudio || IsAdmin() || !$acessoAudio) { |
|
|
$msgAudio = "[ SEM PERMISS<EFBFBD>O ]"; |
|
|
} else { |
|
|
$msgAudio = "[ {$row['userfield']} ]"; |
|
|
} |
|
|
|
|
|
$dataQst[$z]['pm_data'] = date('d/m/Y', strtotime($row['pm_data'])); |
|
|
$dataQst[$z]['agente'] = $row['agente']; |
|
|
$dataQst[$z]['src'] = ocultarTelefone($row['src']); |
|
|
$dataQst[$z]['protocolo'] = $row['protocolo'] ? $row['protocolo'] : ' ---- '; |
|
|
$dataQst[$z]['po_opcao'] = $row['po_opcao']; |
|
|
$dataQst[$z]['userfield'] = $msgAudio; |
|
|
$z++; |
|
|
} |
|
|
//$totalizador = array('Total: ', $row['pq_questao'], 'Resp.: ' . $somaTotalQtd, number_format(($somaTotalQtd / $somaTotalQtd) * 100.0, 2, ',', '.') . '%'); |
|
|
$tables = array($dadosCabecalio, $dadosField, $dataQst, $widthHeader, '', 0); |
|
|
$this->___dataRel = array($tables); |
|
|
} |
|
|
|
|
|
protected function __CalculaPorcentagem($coluna, $array) { |
|
|
$somaQtd = 0; |
|
|
foreach ($array as $value) { |
|
|
if ($value['pq_questao'] == $coluna) { |
|
|
$somaQtd += $value['num_resp']; |
|
|
} |
|
|
} |
|
|
|
|
|
return $somaQtd; |
|
|
} |
|
|
|
|
|
private function ___GetRelAudio() { |
|
|
|
|
|
if (isset($_GET['audioMobile'])) { |
|
|
$dir = "/var/www/html/aplicativo/audio/"; |
|
|
$filepath = VerificaCharFinal($_SESSION[SS_PRM_PATH_AUDIO]) . $_GET["audio"]; |
|
|
$fileOrig = $dir . $_GET["audio"]; |
|
|
@file_put_contents($fileOrig, @file_get_contents($filepath)); |
|
|
|
|
|
$audioMobile = $_GET['audioMobile']; |
|
|
$file = $dir . $audioMobile; |
|
|
|
|
|
if (!file_exists($file)) { |
|
|
$cmd = "ffmpeg -i $fileOrig -acodec libmp3lame $file"; |
|
|
//$cmd = "ffmpeg -i $fileOrig -f mp3 $file"; |
|
|
$dbcon = $GLOBALS['dbcon']; |
|
|
ExecutaComando($cmd, $dbcon); |
|
|
} |
|
|
$file = "/audio/" . $audioMobile; |
|
|
@header("Location: $file"); |
|
|
exit; |
|
|
} |
|
|
|
|
|
if (isset($_GET["audio"]) || isset($_GET["repAudio"])) { |
|
|
$file = $_GET["audio"] ? $_GET["audio"] : $_GET["repAudio"]; |
|
|
$filepath = VerificaCharFinal($_SESSION[SS_PRM_PATH_AUDIO]) . $_GET["audio"]; |
|
|
|
|
|
if (!@file_get_contents($filepath)) { |
|
|
$jsStartup[] = "alert('Arquivo n<EFBFBD>o encontrado!');"; |
|
|
$exitAudio = 1; |
|
|
} else { |
|
|
if (isset($_GET["audio"])) { |
|
|
DownloadAudio($file, $filepath); |
|
|
exit; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
private function GetOpcoesPesquisa($db, $ppId, $id) { |
|
|
$query = "select distinct po_opcao, b.pq_questao,po_id " |
|
|
. "from pbx_pesquisa_opcoes a " |
|
|
. "inner join pbx_pesquisa_questoes b ON a.pq_id = b.pq_id " |
|
|
. "where a.pp_id = '$ppId' " |
|
|
. "and exists (select '' from pbx_pesquisa_movimento where pp_id = a.pp_id and po_id = a.po_id) order by po_opcao "; |
|
|
$result = pg_query($db, $query); |
|
|
//echo $query; |
|
|
$sel = ''; |
|
|
if ($id == -1) { |
|
|
$sel = "selected=\"selected\""; |
|
|
} |
|
|
$ret = "<select name=\"lstOpcoes\" id=\"lstOpcoes\" style=\"width:330px\" >"; |
|
|
$ret .= "<option value=\"-1\" $sel>---------------------</option>"; |
|
|
$sel = ''; |
|
|
|
|
|
while ($linhaBd = pg_fetch_array($result)) { |
|
|
$opc = $linhaBd["po_opcao"]; |
|
|
$sel = ($id == $linhaBd["po_id"]) ? 'selected="selected"' : ""; |
|
|
$ret .= sprintf('<option value="%s" %s> %s - %s</option>', $linhaBd["po_id"], $sel, $opc, $linhaBd["pq_questao"]); |
|
|
} |
|
|
$ret .= "</select>"; |
|
|
return $ret; |
|
|
} |
|
|
|
|
|
public function ExecutaRelatorio() { |
|
|
global $jsStartup, $jsJQuery, $smarty; |
|
|
try { |
|
|
/* |
|
|
* Use esta fun<EFBFBD><EFBFBD>o para validar dados do formul<EFBFBD>rio. |
|
|
*/ |
|
|
$this->___ValidaForm(); |
|
|
|
|
|
/* |
|
|
* Recupera os dados do banco. |
|
|
*/ |
|
|
$this->___ConteudoRelatorio(); |
|
|
|
|
|
/* |
|
|
* Imprime relat<EFBFBD>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<EFBFBD>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'); |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
$relPesquisa = new RelPesquisaAudio($idProg, $dbcon, 1); |
|
|
$relPesquisa->ExecutaRelatorio(); |
|
|
?>
|
|
|
|