|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
include_once 'util/relatoriosBase.php';
|
|
|
|
|
require("pesquisaFuncoes.php");
|
|
|
|
|
|
|
|
|
|
class RelPesquisaAgente extends Relatorios {
|
|
|
|
|
|
|
|
|
|
private $___lstPesquisa = '';
|
|
|
|
|
private $___plId = 0;
|
|
|
|
|
private $___plDescricao = '';
|
|
|
|
|
private $___ppId = 0;
|
|
|
|
|
private $___ppNome = '';
|
|
|
|
|
private $___datas = array();
|
|
|
|
|
private $___matricula;
|
|
|
|
|
|
|
|
|
|
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->___matricula = isset($_POST["matricula"]) ? $_POST["matricula"] : 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function ___FiltrosRelatorio() {
|
|
|
|
|
global $dbcon;
|
|
|
|
|
|
|
|
|
|
if ($this->___lstPesquisa) {
|
|
|
|
|
$this->___plId = explode('|', $this->___lstPesquisa)[0];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$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>';
|
|
|
|
|
if ($this->GetIncDac())
|
|
|
|
|
$filtro .= '<td>Fila</td>';
|
|
|
|
|
$filtro .= '<td>Agente</td>';
|
|
|
|
|
$filtro .= '<td>Data Inicial</td>';
|
|
|
|
|
$filtro .= '<td>Data Final </td>';
|
|
|
|
|
$filtro .= '<td align="center" valign="middle"> </td>';
|
|
|
|
|
$filtro .= '</tr>';
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Valores.
|
|
|
|
|
*/
|
|
|
|
|
$filtro .= '<tr>';
|
|
|
|
|
$filtro .= "<td><select name=\"lstPesquisa\">$lstPesquisa</select></td>";
|
|
|
|
|
if ($this->GetIncDac())
|
|
|
|
|
$filtro .= sprintf('<td>%s</td>', $dacs);
|
|
|
|
|
$filtro .= "<td> <select name='matricula'>" . GetPesquisaAgente($dbcon, $this->___plId, $this->___matricula, $this->___dac, FormatDtMssql($this->___dataIni), FormatDtMssql($this->___dataFim)) . "</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 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() {
|
|
|
|
|
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;
|
|
|
|
|
$matricula = $this->___matricula;
|
|
|
|
|
|
|
|
|
|
GetDadosPesq($dbcon, $this->___lstPesquisa, $plId, $plDescricao, $ppId, $ppNome, $datas);
|
|
|
|
|
|
|
|
|
|
$query = "SELECT pq_display, pq_questao,
|
|
|
|
|
(select count(*)
|
|
|
|
|
from pbx_pesquisa_movimento
|
|
|
|
|
where pl_id = $plId
|
|
|
|
|
and pp_id = a.pp_id
|
|
|
|
|
and pq_id = a.pq_id
|
|
|
|
|
and id_dac = $dac
|
|
|
|
|
and user_reg = '$matricula'
|
|
|
|
|
and pm_data >= '$dataIni'
|
|
|
|
|
and pm_data <= '$dataFim')
|
|
|
|
|
as num_resp,pq_id
|
|
|
|
|
from pbx_pesquisa_questoes a, pbx_pesquisa_liberacao b
|
|
|
|
|
where b.pp_id = a.pp_id
|
|
|
|
|
and b.pl_id = '$plId'
|
|
|
|
|
and pq_status = 1 order by 1";
|
|
|
|
|
$result = $this->___GetQuery($query);
|
|
|
|
|
$row = pg_fetch_all($result);
|
|
|
|
|
$this->SetData($row ? $row : array());
|
|
|
|
|
|
|
|
|
|
foreach ($row as $dataPsq) {
|
|
|
|
|
$sql = "select a.po_id, a.po_tecla, a.po_opcao, count(b.po_id) as num_resp
|
|
|
|
|
from pbx_pesquisa_opcoes a
|
|
|
|
|
left outer join pbx_pesquisa_movimento b on b.po_id = a.po_id
|
|
|
|
|
and pl_id = $plId
|
|
|
|
|
and b.pq_id = a.pq_id
|
|
|
|
|
and b.id_dac = $dac
|
|
|
|
|
and b.user_reg = '$matricula'
|
|
|
|
|
and b.pm_data >= '$dataIni'
|
|
|
|
|
and b.pm_data <= '$dataFim'
|
|
|
|
|
where a.pq_id = {$dataPsq['pq_id']}
|
|
|
|
|
group by a.po_id, a.po_tecla, a.po_opcao
|
|
|
|
|
order by 2";
|
|
|
|
|
$res = $this->___GetQuery($sql);
|
|
|
|
|
$rows = pg_fetch_all($res);
|
|
|
|
|
$this->SetData($rows ? $rows : array());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$query_status = "SELECT fila, d.matricula, apelido,
|
|
|
|
|
SUM(CASE WHEN (c.data_reg IS NOT NULL)THEN 1 ELSE 0 END) AS envio_pesquisa,
|
|
|
|
|
SUM(CASE WHEN (c.data_fim IS NOT NULL)THEN 1 ELSE 0 END) AS completou_pesquisa,
|
|
|
|
|
COUNT(*) AS chamadas_realizadas
|
|
|
|
|
FROM pbx_bilhetes a
|
|
|
|
|
INNER JOIN pbx_eventos_dacs b ON a.uniqueid = b.uid2
|
|
|
|
|
LEFT JOIN pbx_pesquisa_regitra c ON a.uniqueid = c.uniqueid
|
|
|
|
|
LEFT JOIN pbx_usuarios d ON d.matricula = SUBSTRING(b.agente, 7, 4)
|
|
|
|
|
INNER JOIN pbx_queues_grupos e ON e.nome = b.fila
|
|
|
|
|
WHERE calldate::DATE >= '{$dataIni}' AND calldate::DATE <= '{$dataFim}'
|
|
|
|
|
AND b.evento IN('COMPLETEAGENT','COMPLETECALLER', 'TRANSFER','COMPLETEAGENTRAMAL','COMPLETECALLERRAMAL', 'COMPLETACALLER', 'COMPLETAAGENT')
|
|
|
|
|
AND e.id = {$dac}
|
|
|
|
|
AND d.matricula = '{$matricula}'
|
|
|
|
|
GROUP BY fila, d.matricula, apelido";
|
|
|
|
|
|
|
|
|
|
$res = $this->___GetQuery($query_status);
|
|
|
|
|
$rows = pg_fetch_all($res);
|
|
|
|
|
$this->SetData($rows ? $rows : array());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function ___PreparaCsv() {
|
|
|
|
|
$dataRel = array();
|
|
|
|
|
$filtro = $this->___FiltrosRelatorio();
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Inicia o relat<EFBFBD>rio.
|
|
|
|
|
*/
|
|
|
|
|
$dataRel[] = GenerateCsvFromArray($filtro);
|
|
|
|
|
|
|
|
|
|
$dadosCabecalio = array('Opcao', 'Resposta', 'Quantidade', 'Porcentagem');
|
|
|
|
|
$dadosField = array('po_tecla', 'po_opcao', 'num_resp', 'por_resp');
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Monta a linha de cabecalio.
|
|
|
|
|
*/
|
|
|
|
|
$dataRel[] = GenerateCsvFromArray($dadosCabecalio);
|
|
|
|
|
|
|
|
|
|
$x = 1;
|
|
|
|
|
$somaResp = 0;
|
|
|
|
|
/*
|
|
|
|
|
* Linhas de dados.
|
|
|
|
|
*/
|
|
|
|
|
foreach ($this->GetData()[0] as $row) {
|
|
|
|
|
$somaResp = $this->__CalculaPorcentagem($row['pq_questao'], $this->GetData()[0]);
|
|
|
|
|
$dataRel[] = GenerateCsvFromArray(array('', '', RemoveAcentos($row['pq_questao'])));
|
|
|
|
|
|
|
|
|
|
$linha = array();
|
|
|
|
|
foreach ($dadosCabecalio as $value) {
|
|
|
|
|
$linha[] = $value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$dataRel[] = $linha;
|
|
|
|
|
//$row['po_opcao'] = RemoveAcentos($row['po_opcao']);
|
|
|
|
|
// Formata linha de dados.
|
|
|
|
|
|
|
|
|
|
foreach ($this->GetData()[$x] as $dataPsq) {
|
|
|
|
|
$linha = array();
|
|
|
|
|
foreach ($dadosField as $key) {
|
|
|
|
|
|
|
|
|
|
if ($key == 'po_opcao') {
|
|
|
|
|
$linha[] = RemoveAcentos($dataPsq["$key"]);
|
|
|
|
|
} else if ($key == 'por_resp') {
|
|
|
|
|
$dataPsq['por_resp'] = number_format(($dataPsq["num_resp"] / $somaResp) * 100.0, 2, ',', '.') . '%';
|
|
|
|
|
$linha[] = $dataPsq['por_resp'];
|
|
|
|
|
} else {
|
|
|
|
|
$linha[] = $dataPsq["$key"];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$dataRel[] = GenerateCsvFromArray($linha);
|
|
|
|
|
unset($linha);
|
|
|
|
|
}
|
|
|
|
|
$dataRel[] = GenerateCsvFromArray(array('Total', '', 'Resp.: ' . $somaResp, number_format(($somaResp / $somaResp) * 100.0, 2, ',', '.') . '%'));
|
|
|
|
|
$x++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$dataRel[] = GenerateCsvFromArray(array(''));
|
|
|
|
|
|
|
|
|
|
$dadosCabecalio = array('Fila', 'Apelido', 'Direcionamento Pesquisa', 'Conclusao Pesquisa', 'Chamadas');
|
|
|
|
|
$dadosField = array('fila', 'apelido', 'envio_pesquisa', 'completou_pesquisa', 'chamadas_realizadas');
|
|
|
|
|
$linha = array();
|
|
|
|
|
$dataRel[] = GenerateCsvFromArray($dadosCabecalio);
|
|
|
|
|
|
|
|
|
|
$linha = array();
|
|
|
|
|
foreach ($this->GetData()[$x] as $stat) {
|
|
|
|
|
$linha = array();
|
|
|
|
|
foreach ($dadosField as $key) {
|
|
|
|
|
$linha[] = $stat[$key];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$dataRel[] = GenerateCsvFromArray($linha);
|
|
|
|
|
|
|
|
|
|
$this->___dataRel[] = $dataRel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function ___PreparaExcel() {
|
|
|
|
|
$dataRel = array();
|
|
|
|
|
$filtro = $this->___FiltrosRelatorio();
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Inicia o relat<EFBFBD>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('Opcao', 'Resposta', 'Quantidade', 'Porcentagem');
|
|
|
|
|
$dadosField = array('po_tecla', 'po_opcao', 'num_resp', 'por_resp');
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Monta a linha de cabecalio.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
$x = 1;
|
|
|
|
|
$somaResp = 0;
|
|
|
|
|
/*
|
|
|
|
|
* Linhas de dados.
|
|
|
|
|
*/
|
|
|
|
|
foreach ($this->GetData()[0] as $row) {
|
|
|
|
|
|
|
|
|
|
$somaResp = $this->__CalculaPorcentagem($row['pq_questao'], $this->GetData()[0]);
|
|
|
|
|
$dataRel[] = array('LABEL', '', '', RemoveAcentos($row['pq_questao']));
|
|
|
|
|
|
|
|
|
|
$linha = array('LABEL');
|
|
|
|
|
foreach ($dadosCabecalio as $value) {
|
|
|
|
|
$linha[] = $value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$dataRel[] = $linha;
|
|
|
|
|
//$row['po_opcao'] = RemoveAcentos($row['po_opcao']);
|
|
|
|
|
// Formata linha de dados.
|
|
|
|
|
|
|
|
|
|
foreach ($this->GetData()[$x] as $dataPsq) {
|
|
|
|
|
$linha = array('DADOS');
|
|
|
|
|
foreach ($dadosField as $key) {
|
|
|
|
|
|
|
|
|
|
if ($key == 'po_opcao') {
|
|
|
|
|
$linha[] = RemoveAcentos($dataPsq["$key"]);
|
|
|
|
|
} else if ($key == 'por_resp') {
|
|
|
|
|
$dataPsq['por_resp'] = number_format(($dataPsq["num_resp"] / $somaResp) * 100.0, 2, ',', '.') . '%';
|
|
|
|
|
$linha[] = $dataPsq['por_resp'];
|
|
|
|
|
} else {
|
|
|
|
|
$linha[] = $dataPsq["$key"];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$dataRel[] = $linha;
|
|
|
|
|
unset($linha);
|
|
|
|
|
}
|
|
|
|
|
$dataRel[] = array('LABEL', 'Total', '', 'Resp.: ' . $somaResp, number_format(($somaResp / $somaResp) * 100.0, 2, ',', '.') . '%');
|
|
|
|
|
$x++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$dataRel[] = array('LABEL', '');
|
|
|
|
|
|
|
|
|
|
$dadosCabecalio = array('Fila', 'Apelido', 'Direcionamento Pesquisa', 'Conclusao Pesquisa', 'Chamadas');
|
|
|
|
|
$linha = array('LABEL');
|
|
|
|
|
foreach ($dadosCabecalio as $value) {
|
|
|
|
|
$linha[] = $value;
|
|
|
|
|
}
|
|
|
|
|
$dataRel[] = $linha;
|
|
|
|
|
|
|
|
|
|
$dadosField = array('fila', 'apelido', 'envio_pesquisa', 'completou_pesquisa', 'chamadas_realizadas');
|
|
|
|
|
$linha = array('DADOS');
|
|
|
|
|
foreach ($this->GetData()[$x] as $stat) {
|
|
|
|
|
$linha = array('DADOS');
|
|
|
|
|
foreach ($dadosField as $key) {
|
|
|
|
|
$linha[] = $stat[$key];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$dataRel[] = $linha;
|
|
|
|
|
|
|
|
|
|
$this->___dataRel[] = $dataRel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function ___PreparaGrid() {
|
|
|
|
|
|
|
|
|
|
$dataRel = array();
|
|
|
|
|
|
|
|
|
|
$dadosCabecalio = array(
|
|
|
|
|
'Op<EFBFBD><EFBFBD>o' => 'align="center"',
|
|
|
|
|
'Resposta' => 'align="center"',
|
|
|
|
|
'Quantidade' => 'align="center"',
|
|
|
|
|
'Porcentagem [ % ]' => 'align="center"'
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$dadosField = array(
|
|
|
|
|
'po_tecla' => 'align="center"',
|
|
|
|
|
'po_opcao' => 'align="center"',
|
|
|
|
|
'num_resp' => 'align="center"',
|
|
|
|
|
'por_resp' => 'align="center"'
|
|
|
|
|
);
|
|
|
|
|
/*
|
|
|
|
|
* Inicia o relat<EFBFBD>rio.
|
|
|
|
|
*/
|
|
|
|
|
$dataRel[] = '<table width="50%" cellpadding="2" class="grid">';
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Monta a linha de cabecalio.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
$dataRel[] = "<tr><th colspan='4'>Relat<EFBFBD>rio Pesquisa</th></tr>";
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* 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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//print_r($this->GetData());
|
|
|
|
|
$x = 1;
|
|
|
|
|
$somaResp = 0;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Linhas de dados.
|
|
|
|
|
*/
|
|
|
|
|
foreach ($this->GetData()[0] as $row) {
|
|
|
|
|
|
|
|
|
|
//Monta a Quest<EFBFBD>o da Pergunta da pesquisa.
|
|
|
|
|
$linhas .= sprintf("<tr><th colspan=\"4\"><span style='color:#404040'>%s</span></th></tr>", $row['pq_questao']);
|
|
|
|
|
|
|
|
|
|
$linhas .= "<tr>";
|
|
|
|
|
foreach ($dadosCabecalio as $key => $value) {
|
|
|
|
|
$linhas .= sprintf("<th %s>%s</th>", $value, $key);
|
|
|
|
|
}
|
|
|
|
|
$linhas .= "</tr>";
|
|
|
|
|
$dataRel[] = $linhas;
|
|
|
|
|
unset($linhas);
|
|
|
|
|
|
|
|
|
|
//Cria as linha dos resultado de acordo com as respostas
|
|
|
|
|
$somaResp = $this->__CalculaPorcentagem($row['pq_questao'], $this->GetData()[0]);
|
|
|
|
|
foreach ($this->GetData()[$x] as $dataPesquisa) {
|
|
|
|
|
$linhas .= "<tr>";
|
|
|
|
|
foreach ($dadosField as $k => $value) {
|
|
|
|
|
if ($k == 'por_resp') {
|
|
|
|
|
$linhas .= sprintf("<td %s>%s%%</td>", $value, number_format(($dataPesquisa["num_resp"] / $somaResp) * 100.0, 2, ',', '.'));
|
|
|
|
|
} else {
|
|
|
|
|
$linhas .= sprintf("<td %s>%s</td>", $value, $dataPesquisa["$k"]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$linhas .= "</tr>";
|
|
|
|
|
}
|
|
|
|
|
$linhas .= sprintf("<tr><td colspan='2' align='center'><b>Total</b></td><td align='center'><b>$somaResp</b></td><td align='center'><b>%s</b></td></tr>", number_format(($somaResp / $somaResp) * 100.0, 2, ',', '.') . '%');
|
|
|
|
|
|
|
|
|
|
$x++;
|
|
|
|
|
|
|
|
|
|
$dataRel[] = $linhas;
|
|
|
|
|
unset($linhas);
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
* Fecha relatorio.
|
|
|
|
|
*/
|
|
|
|
|
$dataRel[] = '</table>';
|
|
|
|
|
|
|
|
|
|
$dataRel[] = "<br>";
|
|
|
|
|
$dataRel[] = '<table width="50%" cellpadding="2" class="grid">';
|
|
|
|
|
$dataRel[] = "<tr><th colspan='5'>Est<EFBFBD>tistica Agente</th></tr>";
|
|
|
|
|
$dataRel[] = "<tr>"
|
|
|
|
|
. "<th align='center'>Fila</th>"
|
|
|
|
|
. "<th align='center'>Agente</th>"
|
|
|
|
|
. "<th align='center'>Direcionamento Pesquisa</th>"
|
|
|
|
|
. "<th align='center'>Conclusao Pesquisa</th>"
|
|
|
|
|
. "<th align='center'>Chamadas</th>"
|
|
|
|
|
. "</tr>";
|
|
|
|
|
foreach ($this->GetData()[$x] as $est) {
|
|
|
|
|
$dataRel[] = "<tr>"
|
|
|
|
|
. "<td align='center'>{$est['fila']}</td>"
|
|
|
|
|
. "<td align='center'>{$est['apelido']}</td>"
|
|
|
|
|
. "<td align='center'>{$est['envio_pesquisa']}</td>"
|
|
|
|
|
. "<td align='center'>{$est['completou_pesquisa']}</td>"
|
|
|
|
|
. "<td align='center'>{$est['chamadas_realizadas']}</td>"
|
|
|
|
|
. "</tr>";
|
|
|
|
|
}
|
|
|
|
|
$dataRel[] = '</table>';
|
|
|
|
|
|
|
|
|
|
$this->___dataRel[] = $dataRel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function ___PreparaHtml() {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function ___PreparaPdf() {
|
|
|
|
|
list($this->___dac, $this->___dataIni, $this->___dataFim) = $_SESSION["SSstorageFiltros"];
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* TABELA DADOS PRINCIPAIS
|
|
|
|
|
*/
|
|
|
|
|
$dadosCabecalio = array(
|
|
|
|
|
'Op<EFBFBD><EFBFBD>o' => 'C',
|
|
|
|
|
'Resposta' => 'C',
|
|
|
|
|
'Quantidade' => 'C',
|
|
|
|
|
'Porcentagem [ % ]' => 'C'
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$dadosField = array(
|
|
|
|
|
'po_tecla' => 'C',
|
|
|
|
|
'po_opcao' => 'C',
|
|
|
|
|
'num_resp' => 'C',
|
|
|
|
|
'por_resp' => 'C'
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$somaTotalQtd = 0;
|
|
|
|
|
$dados = $this->GetData()[0];
|
|
|
|
|
$x = 1;
|
|
|
|
|
$z = 0;
|
|
|
|
|
|
|
|
|
|
$dataQst = array();
|
|
|
|
|
$tables = array();
|
|
|
|
|
$widthHeader = array(37, 77, 37, 37);
|
|
|
|
|
|
|
|
|
|
foreach ($dados as $row) {
|
|
|
|
|
$somaTotalQtd = $this->__CalculaPorcentagem($row['pq_questao'], $this->GetData()[0]);
|
|
|
|
|
foreach ($this->GetData()[$x] as $data) {
|
|
|
|
|
$dataQst[$z]['pq_questao'] = $data['pq_questao'];
|
|
|
|
|
$dataQst[$z]['po_opcao'] = $data['po_opcao'];
|
|
|
|
|
$dataQst[$z]['num_resp'] = $data['num_resp'];
|
|
|
|
|
$dataQst[$z]['po_tecla'] = $data['po_tecla'];
|
|
|
|
|
$dataQst[$z]['por_resp'] = number_format(($data["num_resp"] / $somaTotalQtd) * 100.0, 2, ',', '.') . '%';
|
|
|
|
|
$z++;
|
|
|
|
|
}
|
|
|
|
|
$totalizador = array('Total: ', $row['pq_questao'], 'Resp.: ' . $somaTotalQtd, number_format(($somaTotalQtd / $somaTotalQtd) * 100.0, 2, ',', '.') . '%');
|
|
|
|
|
$tables[] = array($dadosCabecalio, $dadosField, $dataQst, $widthHeader, $totalizador, 0);
|
|
|
|
|
$x++;
|
|
|
|
|
unset($dataQst);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$dadosCabecalio = array(
|
|
|
|
|
'Fila' => 'C',
|
|
|
|
|
'Agente' => 'C',
|
|
|
|
|
'Direcionamento Pesquisa' => 'C',
|
|
|
|
|
'Conclusao Pesquisa' => 'C',
|
|
|
|
|
'Chamadas' => 'C'
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$dadosField = array(
|
|
|
|
|
'fila' => 'C',
|
|
|
|
|
'apelido' => 'C',
|
|
|
|
|
'envio_pesquisa' => 'C',
|
|
|
|
|
'completou_pesquisa' => 'C',
|
|
|
|
|
'chamadas_realizadas' => 'C'
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$widthHeader = array(20, 20, 40, 40, 20);
|
|
|
|
|
$tables[] = array($dadosCabecalio, $dadosField, $this->GetData()[$x], $widthHeader, 0, 0);
|
|
|
|
|
|
|
|
|
|
$this->___dataRel = $tables;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function __CalculaPorcentagem($coluna, $array) {
|
|
|
|
|
$somaQtd = 0;
|
|
|
|
|
foreach ($array as $value) {
|
|
|
|
|
if ($value['pq_questao'] == $coluna) {
|
|
|
|
|
$somaQtd += $value['num_resp'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $somaQtd;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$relPesquisaAgt = new RelPesquisaAgente($idProg, $dbcon, 1);
|
|
|
|
|
$relPesquisaAgt->ExecutaRelatorio();
|
|
|
|
|
|