|
|
@ -10,11 +10,24 @@ |
|
|
|
private $___ppId = 0; |
|
|
|
private $___ppId = 0; |
|
|
|
private $___ppNome = ''; |
|
|
|
private $___ppNome = ''; |
|
|
|
private $___datas = array(); |
|
|
|
private $___datas = array(); |
|
|
|
|
|
|
|
private $___servico; |
|
|
|
|
|
|
|
private $___tipoRelatorio; |
|
|
|
|
|
|
|
|
|
|
|
public function __construct($idProg, $dbcon, $incDac) { |
|
|
|
public function __construct($idProg, $dbcon, $incDac) { |
|
|
|
parent::__construct($idProg, $dbcon, $incDac); |
|
|
|
parent::__construct($idProg, $dbcon, $incDac); |
|
|
|
$this->___dac = isset($_POST["listaDacs"]) ? $_POST["listaDacs"] : 0; |
|
|
|
$this->___dac = isset($_POST["listaDacs"]) ? $_POST["listaDacs"] : 0; |
|
|
|
$this->___lstPesquisa = isset($_POST["lstPesquisa"]) ? $_POST["lstPesquisa"] : '0| | | |0| '; |
|
|
|
$this->___lstPesquisa = isset($_POST["lstPesquisa"]) ? $_POST["lstPesquisa"] : '0| | | |0| '; |
|
|
|
|
|
|
|
$this->___servico = isset($_POST["listaServico"]) ? $_POST["listaServico"] : 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function ___ValidaForm() { |
|
|
|
|
|
|
|
parent::___ValidaForm(); |
|
|
|
|
|
|
|
if (!IsPostBack()) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (!$this->___lstPesquisa) { |
|
|
|
|
|
|
|
GeraExcept('Informe uma Pesquisa!'); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function ___FiltrosRelatorio() { |
|
|
|
function ___FiltrosRelatorio() { |
|
|
@ -73,6 +86,7 @@ |
|
|
|
$filtro .= '<td>Pesquisa</td>'; |
|
|
|
$filtro .= '<td>Pesquisa</td>'; |
|
|
|
if ($this->GetIncDac()) |
|
|
|
if ($this->GetIncDac()) |
|
|
|
$filtro .= '<td>Fila</td>'; |
|
|
|
$filtro .= '<td>Fila</td>'; |
|
|
|
|
|
|
|
$filtro .= GetUsoServico() ? '<td>Serviço</td>' : ''; |
|
|
|
$filtro .= '<td>Data Inicial</td>'; |
|
|
|
$filtro .= '<td>Data Inicial</td>'; |
|
|
|
$filtro .= '<td>Data Final </td>'; |
|
|
|
$filtro .= '<td>Data Final </td>'; |
|
|
|
$filtro .= '<td align="center" valign="middle"> </td>'; |
|
|
|
$filtro .= '<td align="center" valign="middle"> </td>'; |
|
|
@ -85,6 +99,9 @@ |
|
|
|
$filtro .= "<td><select name=\"lstPesquisa\">$lstPesquisa</select></td>"; |
|
|
|
$filtro .= "<td><select name=\"lstPesquisa\">$lstPesquisa</select></td>"; |
|
|
|
if ($this->GetIncDac()) |
|
|
|
if ($this->GetIncDac()) |
|
|
|
$filtro .= sprintf('<td>%s</td>', $dacs); |
|
|
|
$filtro .= sprintf('<td>%s</td>', $dacs); |
|
|
|
|
|
|
|
if (GetUsoServico()) { |
|
|
|
|
|
|
|
$filtro .= sprintf('<td>%s</td>', GetIdentRota(false, $this->___servico)); |
|
|
|
|
|
|
|
} |
|
|
|
$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="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="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><input type="submit" name="btConsulta" id="btConsulta" value="Consultar"></td>'; |
|
|
@ -111,43 +128,67 @@ |
|
|
|
$ppNome = $this->___ppNome; |
|
|
|
$ppNome = $this->___ppNome; |
|
|
|
$plDescricao = $this->___plDescricao; |
|
|
|
$plDescricao = $this->___plDescricao; |
|
|
|
$datas = $this->___datas; |
|
|
|
$datas = $this->___datas; |
|
|
|
|
|
|
|
$srv = $this->___servico; |
|
|
|
|
|
|
|
$mostraColunaServicos = GetUsoServico() == RELATORIO_SERVICOS_HABILITA; |
|
|
|
|
|
|
|
|
|
|
|
GetDadosPesq($dbcon, $this->___lstPesquisa, $plId, $plDescricao, $ppId, $ppNome, $datas); |
|
|
|
GetDadosPesq($dbcon, $this->___lstPesquisa, $plId, $plDescricao, $ppId, $ppNome, $datas); |
|
|
|
|
|
|
|
|
|
|
|
$query = "SELECT pq_display, pq_questao, |
|
|
|
$query = "SELECT pq_display, pq_questao, |
|
|
|
(select count(*) |
|
|
|
(select count(*) |
|
|
|
from pbx_pesquisa_movimento |
|
|
|
from pbx_pesquisa_movimento a "; |
|
|
|
where pl_id = $plId |
|
|
|
|
|
|
|
|
|
|
|
if (GetUsoServico()) { |
|
|
|
|
|
|
|
$query .= " left join pbx_servicos_registra c on c.uniqueid = a.uniqueid "; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$query .= " where pl_id = $plId |
|
|
|
and pp_id = a.pp_id |
|
|
|
and pp_id = a.pp_id |
|
|
|
and pq_id = a.pq_id |
|
|
|
and pq_id = a.pq_id |
|
|
|
and id_dac = $dac |
|
|
|
and id_dac = $dac "; |
|
|
|
and pm_data >= '$dataIni' |
|
|
|
|
|
|
|
|
|
|
|
if (GetUsoServico() && $srv) { |
|
|
|
|
|
|
|
$query .= " AND c.serv_id = '{$srv}'"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$query .= "and pm_data >= '$dataIni' |
|
|
|
and pm_data <= '$dataFim') |
|
|
|
and pm_data <= '$dataFim') |
|
|
|
as num_resp,pq_id |
|
|
|
as num_resp,pq_id |
|
|
|
from pbx_pesquisa_questoes a, pbx_pesquisa_liberacao b |
|
|
|
from pbx_pesquisa_questoes a, pbx_pesquisa_liberacao b |
|
|
|
where b.pp_id = a.pp_id |
|
|
|
where b.pp_id = a.pp_id |
|
|
|
and b.pl_id = '$plId' |
|
|
|
and b.pl_id = '$plId' |
|
|
|
and pq_status = 1 order by 1"; |
|
|
|
and pq_status = 1 order by 1"; |
|
|
|
|
|
|
|
|
|
|
|
$result = $this->___GetQuery($query); |
|
|
|
$result = $this->___GetQuery($query); |
|
|
|
$row = pg_fetch_all($result); |
|
|
|
$row = pg_fetch_all($result); |
|
|
|
$this->SetData($row ? $row : array()); |
|
|
|
$this->SetData($row ? $row : array()); |
|
|
|
|
|
|
|
|
|
|
|
foreach ($row as $dataPsq) { |
|
|
|
foreach ($row as $dataPsq) { |
|
|
|
$sql = "select a.po_id, a.po_tecla, a.po_opcao, count(b.po_id) as num_resp |
|
|
|
$sql = "select a.po_id, a.po_tecla, a.po_opcao, count(b.po_id) as num_resp |
|
|
|
from pbx_pesquisa_opcoes a |
|
|
|
from pbx_pesquisa_opcoes a |
|
|
|
left outer join pbx_pesquisa_movimento b on b.po_id = a.po_id |
|
|
|
left outer join pbx_pesquisa_movimento b on b.po_id = a.po_id |
|
|
|
and pl_id = $plId |
|
|
|
and pl_id = $plId |
|
|
|
and b.pq_id = a.pq_id |
|
|
|
and b.pq_id = a.pq_id |
|
|
|
and b.id_dac = $dac |
|
|
|
and b.id_dac = $dac |
|
|
|
and b.pm_data >= '$dataIni' |
|
|
|
and b.pm_data >= '$dataIni' |
|
|
|
and b.pm_data <= '$dataFim' |
|
|
|
and b.pm_data <= '$dataFim' "; |
|
|
|
where a.pq_id = {$dataPsq['pq_id']} |
|
|
|
|
|
|
|
group by a.po_id, a.po_tecla, a.po_opcao |
|
|
|
if (GetUsoServico()) { |
|
|
|
order by 2"; |
|
|
|
$sql .= " left join pbx_servicos_registra c on c.uniqueid = b.uniqueid "; |
|
|
|
$res = $this->___GetQuery($sql); |
|
|
|
} |
|
|
|
$rows = pg_fetch_all($res); |
|
|
|
|
|
|
|
$this->SetData($rows ? $rows : array()); |
|
|
|
$sql .= " where a.pq_id = {$dataPsq['pq_id']} "; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (GetUsoServico() && $srv) { |
|
|
|
|
|
|
|
$sql .= " AND c.serv_id = '{$srv}'"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$sql .= " 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 = "SELECT fila, d.matricula, apelido, |
|
|
|
$query = "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_reg IS NOT NULL)THEN 1 ELSE 0 END) AS envio_pesquisa, |
|
|
@ -157,12 +198,21 @@ |
|
|
|
INNER JOIN pbx_eventos_dacs b ON a.uniqueid = b.uid2 |
|
|
|
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_pesquisa_regitra c ON a.uniqueid = c.uniqueid |
|
|
|
LEFT JOIN pbx_usuarios d ON d.matricula = SUBSTRING(b.agente, 7, 4) |
|
|
|
LEFT JOIN pbx_usuarios d ON d.matricula = SUBSTRING(b.agente, 7, 4) |
|
|
|
LEFT JOIN pbx_queues_grupos e ON e.nome = b.fila |
|
|
|
LEFT JOIN pbx_queues_grupos e ON e.nome = b.fila"; |
|
|
|
WHERE calldate::DATE >= '$dataIni' |
|
|
|
if (GetUsoServico()) { |
|
|
|
AND calldate::DATE <= '$dataFim' |
|
|
|
$query .= " LEFT JOIN pbx_servicos_registra s ON s.uniqueid = a.uniqueid "; |
|
|
|
AND b.evento IN('COMPLETEAGENT','COMPLETECALLER', 'TRANSFER','COMPLETEAGENTRAMAL','COMPLETECALLERRAMAL', 'COMPLETACALLER', 'COMPLETAAGENT') |
|
|
|
} |
|
|
|
AND e.id = '$dac' |
|
|
|
|
|
|
|
GROUP BY fila, d.matricula, apelido"; |
|
|
|
$query .= " WHERE calldate::DATE >= '$dataIni' |
|
|
|
|
|
|
|
AND calldate::DATE <= '$dataFim' |
|
|
|
|
|
|
|
AND b.evento IN('COMPLETEAGENT','COMPLETECALLER', 'TRANSFER','COMPLETEAGENTRAMAL','COMPLETECALLERRAMAL', 'COMPLETACALLER', 'COMPLETAAGENT') |
|
|
|
|
|
|
|
AND e.id = '$dac' "; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (GetUsoServico() && $srv) { |
|
|
|
|
|
|
|
$query .= " AND s.serv_id = '{$srv}'"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$query .= " GROUP BY fila, d.matricula, apelido"; |
|
|
|
|
|
|
|
|
|
|
|
$result = $this->___GetQuery($query); |
|
|
|
$result = $this->___GetQuery($query); |
|
|
|
$row = pg_fetch_all($result); |
|
|
|
$row = pg_fetch_all($result); |
|
|
|