diff --git a/cadastros/pesquisa/pesquisaRel.php b/cadastros/pesquisa/pesquisaRel.php
index ac7aa51..5ccb6a1 100644
--- a/cadastros/pesquisa/pesquisaRel.php
+++ b/cadastros/pesquisa/pesquisaRel.php
@@ -10,11 +10,24 @@
private $___ppId = 0;
private $___ppNome = '';
private $___datas = array();
+ private $___servico;
+ private $___tipoRelatorio;
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->___servico = isset($_POST["listaServico"]) ? $_POST["listaServico"] : 0;
+ }
+
+ function ___ValidaForm() {
+ parent::___ValidaForm();
+ if (!IsPostBack()) {
+ return;
+ }
+ if (!$this->___lstPesquisa) {
+ GeraExcept('Informe uma Pesquisa!');
+ }
}
function ___FiltrosRelatorio() {
@@ -73,6 +86,7 @@
$filtro .= '
Pesquisa | ';
if ($this->GetIncDac())
$filtro .= 'Fila | ';
+ $filtro .= GetUsoServico() ? 'Serviço | ' : '';
$filtro .= 'Data Inicial | ';
$filtro .= 'Data Final | ';
$filtro .= ' | ';
@@ -85,6 +99,9 @@
$filtro .= " | ";
if ($this->GetIncDac())
$filtro .= sprintf('%s | ', $dacs);
+ if (GetUsoServico()) {
+ $filtro .= sprintf('%s | ', GetIdentRota(false, $this->___servico));
+ }
$filtro .= ' | ';
$filtro .= ' | ';
$filtro .= ' | ';
@@ -111,43 +128,67 @@
$ppNome = $this->___ppNome;
$plDescricao = $this->___plDescricao;
$datas = $this->___datas;
+ $srv = $this->___servico;
+ $mostraColunaServicos = GetUsoServico() == RELATORIO_SERVICOS_HABILITA;
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
+ from pbx_pesquisa_movimento a ";
+
+ 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 pq_id = a.pq_id
- and id_dac = $dac
- and pm_data >= '$dataIni'
+ and id_dac = $dac ";
+
+ if (GetUsoServico() && $srv) {
+ $query .= " AND c.serv_id = '{$srv}'";
+ }
+
+ $query .= "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";
+ 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.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());
- }
+ 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.pm_data >= '$dataIni'
+ and b.pm_data <= '$dataFim' ";
+
+ if (GetUsoServico()) {
+ $sql .= " left join pbx_servicos_registra c on c.uniqueid = b.uniqueid ";
+ }
+
+ $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,
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
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_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'
- GROUP BY fila, d.matricula, apelido";
+ LEFT JOIN pbx_queues_grupos e ON e.nome = b.fila";
+ if (GetUsoServico()) {
+ $query .= " LEFT JOIN pbx_servicos_registra s ON s.uniqueid = a.uniqueid ";
+ }
+
+ $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);
$row = pg_fetch_all($result);
diff --git a/cadastros/pesquisa/pesquisaRelAgente.php b/cadastros/pesquisa/pesquisaRelAgente.php
index e2f0a92..8b45143 100644
--- a/cadastros/pesquisa/pesquisaRelAgente.php
+++ b/cadastros/pesquisa/pesquisaRelAgente.php
@@ -12,12 +12,25 @@
private $___datas = array();
private $___matricula;
private $___tipoRelatorio;
+ 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->___matricula = isset($_POST["matricula"]) ? $_POST["matricula"] : 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() {
@@ -76,6 +89,7 @@
$filtro .= 'Pesquisa | ';
if ($this->GetIncDac())
$filtro .= 'Fila | ';
+ $filtro .= GetUsoServico() ? 'Serviço | ' : '';
$filtro .= 'Agente | ';
$filtro .= 'Data Inicial | ';
$filtro .= 'Data Final | ';
@@ -89,6 +103,9 @@
$filtro .= " | ";
if ($this->GetIncDac())
$filtro .= sprintf('%s | ', $dacs);
+ if (GetUsoServico()) {
+ $filtro .= sprintf('%s | ', GetIdentRota(false, $this->___servico));
+ }
$filtro .= " | ";
$filtro .= ' | ';
$filtro .= ' | ';
@@ -117,24 +134,39 @@
$plDescricao = $this->___plDescricao;
$datas = $this->___datas;
$matricula = $this->___matricula;
+ $srv = $this->___servico;
+ $mostraColunaServicos = GetUsoServico() == RELATORIO_SERVICOS_HABILITA;
+
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
+ from pbx_pesquisa_movimento a \n";
+
+ if (GetUsoServico()) {
+ $query .= " left join pbx_servicos_registra c on c.uniqueid = a.uniqueid \n";
+ }
+
+ $query .= " 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";
+ and id_dac = $dac \n";
+
+ if (GetUsoServico() && $srv) {
+ $query .= " AND c.serv_id = '{$srv}' \n";
+ }
+
+ $matricula ? $query .= "and user_reg = '$matricula' \n" : '';
+
+ $query .= "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());
@@ -146,12 +178,23 @@
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";
+ and b.pm_data <= '$dataFim' \n";
+ $matricula ? $sql .= " and b.user_reg = '$matricula' \n" : '';
+
+ if (GetUsoServico()) {
+ $sql .= " left join pbx_servicos_registra c on c.uniqueid = b.uniqueid ";
+ }
+
+ $sql .= " where a.pq_id = {$dataPsq['pq_id']} ";
+
+ if (GetUsoServico() && $srv) {
+ $sql .= " AND c.serv_id = '{$srv}' \n";
+ }
+
+ $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());
@@ -165,12 +208,22 @@
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)
- LEFT 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";
+ LEFT JOIN pbx_queues_grupos e ON e.nome = b.fila";
+ if (GetUsoServico()) {
+ $query_status .= " LEFT JOIN pbx_servicos_registra s ON s.uniqueid = a.uniqueid ";
+ }
+
+ $query_status .= " WHERE calldate::DATE >= '{$dataIni}' AND calldate::DATE <= '{$dataFim}'
+ AND b.evento IN('COMPLETEAGENT','COMPLETECALLER', 'TRANSFER','COMPLETEAGENTRAMAL','COMPLETECALLERRAMAL', 'COMPLETACALLER', 'COMPLETAAGENT')
+ AND e.id = {$dac} \n";
+
+ if (GetUsoServico() && $srv) {
+ $query_status .= " AND s.serv_id = '{$srv}' \n";
+ }
+
+ $matricula ? $query_status .= "and d.matricula = '$matricula' \n" : '';
+
+ $query_status .= "GROUP BY fila, d.matricula, apelido";
$res = $this->___GetQuery($query_status);
$rows = pg_fetch_all($res);
diff --git a/cadastros/pesquisa/pesquisaRelAudio.php b/cadastros/pesquisa/pesquisaRelAudio.php
index 0ccd7f3..653b510 100644
--- a/cadastros/pesquisa/pesquisaRelAudio.php
+++ b/cadastros/pesquisa/pesquisaRelAudio.php
@@ -13,6 +13,7 @@
private $___protocolo = 0;
private $___matricula;
private $___opcResposta;
+ private $___servico;
public function __construct($idProg, $dbcon, $incDac) {
parent::__construct($idProg, $dbcon, $incDac);
@@ -21,6 +22,7 @@
$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();
}
@@ -100,9 +102,10 @@
$filtro .= "";
if ($this->GetIncDac())
$filtro .= 'Fila | ';
+ $filtro .= GetUsoServico() ? 'Serviço | ' : '';
+ $filtro .= 'Agente | ';
$filtro .= 'Data Inicial | ';
$filtro .= 'Data Final | ';
- $filtro .= 'Agente | ';
$filtro .= 'Protocolo | ';
$filtro .= ' | ';
$filtro .= '
';
@@ -113,9 +116,12 @@
$filtro .= '';
if ($this->GetIncDac())
$filtro .= sprintf('%s | ', $dacs);
+ if (GetUsoServico()) {
+ $filtro .= sprintf('%s | ', GetIdentRota(false, $this->___servico));
+ }
+ $filtro .= " | ";
$filtro .= ' | ';
$filtro .= ' | ';
- $filtro .= " | ";
$filtro .= " | ";
$filtro .= ' | ';
$filtro .= '%s | ';
@@ -143,6 +149,8 @@
$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);
@@ -156,14 +164,20 @@
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
+ 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'
+ $query .= "AND a.id_dac = '$dac'
AND a.pp_id = '$ppId'
AND a.pm_data >= '$dataIni'
AND a.pm_data <= '$dataFim' ";
@@ -181,8 +195,12 @@
$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());