Browse Source

ajuste relatorio de pesquisa para que realize o filtro por servico

1.8-dev
douglas.strappasson 1 year ago
parent
commit
503e0f5a0f
  1. 108
      cadastros/pesquisa/pesquisaRel.php
  2. 97
      cadastros/pesquisa/pesquisaRelAgente.php
  3. 28
      cadastros/pesquisa/pesquisaRelAudio.php

108
cadastros/pesquisa/pesquisaRel.php

@ -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">&nbsp;</td>'; $filtro .= '<td align="center" valign="middle">&nbsp;</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);

97
cadastros/pesquisa/pesquisaRelAgente.php

@ -12,12 +12,25 @@
private $___datas = array(); private $___datas = array();
private $___matricula; private $___matricula;
private $___tipoRelatorio; private $___tipoRelatorio;
private $___servico;
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->___matricula = isset($_POST["matricula"]) ? $_POST["matricula"] : 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() { function ___FiltrosRelatorio() {
@ -76,6 +89,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>Agente</td>'; $filtro .= '<td>Agente</td>';
$filtro .= '<td>Data Inicial</td>'; $filtro .= '<td>Data Inicial</td>';
$filtro .= '<td>Data Final </td>'; $filtro .= '<td>Data Final </td>';
@ -89,6 +103,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> <select name='matricula'>" . GetPesquisaAgente($dbcon, $this->___plId, $this->___matricula, $this->___dac, FormatDtMssql($this->___dataIni), FormatDtMssql($this->___dataFim), 1) . "</select></td>"; $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="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>';
@ -117,24 +134,39 @@
$plDescricao = $this->___plDescricao; $plDescricao = $this->___plDescricao;
$datas = $this->___datas; $datas = $this->___datas;
$matricula = $this->___matricula; $matricula = $this->___matricula;
$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 \n";
where pl_id = $plId
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 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 \n";
and user_reg = '$matricula'
and pm_data >= '$dataIni' if (GetUsoServico() && $srv) {
and pm_data <= '$dataFim') $query .= " AND c.serv_id = '{$srv}' \n";
as num_resp,pq_id }
from pbx_pesquisa_questoes a, pbx_pesquisa_liberacao b
where b.pp_id = a.pp_id $matricula ? $query .= "and user_reg = '$matricula' \n" : '';
and b.pl_id = '$plId'
and pq_status = 1 order by 1"; $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); $result = $this->___GetQuery($query);
$row = pg_fetch_all($result); $row = pg_fetch_all($result);
$this->SetData($row ? $row : array()); $this->SetData($row ? $row : array());
@ -146,12 +178,23 @@
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.user_reg = '$matricula'
and b.pm_data >= '$dataIni' and b.pm_data >= '$dataIni'
and b.pm_data <= '$dataFim' and b.pm_data <= '$dataFim' \n";
where a.pq_id = {$dataPsq['pq_id']} $matricula ? $sql .= " and b.user_reg = '$matricula' \n" : '';
group by a.po_id, a.po_tecla, a.po_opcao
order by 2"; 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); $res = $this->___GetQuery($sql);
$rows = pg_fetch_all($res); $rows = pg_fetch_all($res);
$this->SetData($rows ? $rows : array()); $this->SetData($rows ? $rows : array());
@ -165,12 +208,22 @@
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}' AND calldate::DATE <= '{$dataFim}' if (GetUsoServico()) {
AND b.evento IN('COMPLETEAGENT','COMPLETECALLER', 'TRANSFER','COMPLETEAGENTRAMAL','COMPLETECALLERRAMAL', 'COMPLETACALLER', 'COMPLETAAGENT') $query_status .= " LEFT JOIN pbx_servicos_registra s ON s.uniqueid = a.uniqueid ";
AND e.id = {$dac} }
AND d.matricula = '{$matricula}'
GROUP BY fila, d.matricula, apelido"; $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); $res = $this->___GetQuery($query_status);
$rows = pg_fetch_all($res); $rows = pg_fetch_all($res);

28
cadastros/pesquisa/pesquisaRelAudio.php

@ -13,6 +13,7 @@
private $___protocolo = 0; private $___protocolo = 0;
private $___matricula; private $___matricula;
private $___opcResposta; private $___opcResposta;
private $___servico;
public function __construct($idProg, $dbcon, $incDac) { public function __construct($idProg, $dbcon, $incDac) {
parent::__construct($idProg, $dbcon, $incDac); parent::__construct($idProg, $dbcon, $incDac);
@ -21,6 +22,7 @@
$this->___protocolo = isset($_POST['protocolo']) ? $_POST['protocolo'] : ''; $this->___protocolo = isset($_POST['protocolo']) ? $_POST['protocolo'] : '';
$this->___matricula = isset($_POST["matricula"]) ? $_POST["matricula"] : 0; $this->___matricula = isset($_POST["matricula"]) ? $_POST["matricula"] : 0;
$this->___opcResposta = isset($_POST["lstOpcoes"]) ? $_POST["lstOpcoes"] : -1; $this->___opcResposta = isset($_POST["lstOpcoes"]) ? $_POST["lstOpcoes"] : -1;
$this->___servico = isset($_POST["listaServico"]) ? $_POST["listaServico"] : 0;
$this->___GetRelAudio(); $this->___GetRelAudio();
} }
@ -100,9 +102,10 @@
$filtro .= "<tr>"; $filtro .= "<tr>";
if ($this->GetIncDac()) if ($this->GetIncDac())
$filtro .= '<td>Fila</td>'; $filtro .= '<td>Fila</td>';
$filtro .= GetUsoServico() ? '<td>Serviço</td>' : '';
$filtro .= '<td>Agente </td>';
$filtro .= '<td>Data Inicial</td>'; $filtro .= '<td>Data Inicial</td>';
$filtro .= '<td>Data Final </td>'; $filtro .= '<td>Data Final </td>';
$filtro .= '<td>Agente </td>';
$filtro .= '<td>Protocolo</td>'; $filtro .= '<td>Protocolo</td>';
$filtro .= '<td align="center" valign="middle">&nbsp;</td>'; $filtro .= '<td align="center" valign="middle">&nbsp;</td>';
$filtro .= '</tr>'; $filtro .= '</tr>';
@ -113,9 +116,12 @@
$filtro .= '<tr>'; $filtro .= '<tr>';
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><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="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><select name='matricula'>" . GetPesquisaAgente($dbcon, $this->___plId, $this->___matricula, $this->___dac, FormatDtMssql($this->___dataIni), FormatDtMssql($this->___dataFim), 1) . "</select></td>";
$filtro .= "<td><input name=\"protocolo\" id=\"prot\" type=\"text\" size=\"15\" maxlength=\"15\" value=\"\" title=\"Protocolo de Atendimento\"></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><input type="submit" name="btConsulta" id="btConsulta" value="Consultar"></td>';
$filtro .= '<td>%s</td>'; $filtro .= '<td>%s</td>';
@ -143,6 +149,8 @@
$datas = $this->___datas; $datas = $this->___datas;
$protocolo = $this->___protocolo; $protocolo = $this->___protocolo;
$matricula = $this->___matricula; $matricula = $this->___matricula;
$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);
@ -156,14 +164,20 @@
LEFT JOIN pbx_protocolo_reg d ON d.uniqueid = a.uniqueid 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_pesquisa e ON e.pp_id = a.pp_id
INNER JOIN pbx_dacs f ON f.id = a.id_dac 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' WHERE b.lastapp <> 'Transferred Call'
AND COALESCE(b.userfield, '') <> '' AND COALESCE(b.userfield, '') <> ''
AND duration > 0 AND duration > 0
AND evento IN ('COMPLETEAGENT','COMPLETECALLER', 'TRANSFER','COMPLETEAGENTRAMAL','COMPLETECALLERRAMAL', 'COMPLETACALLER', 'COMPLETAAGENT') "; AND evento IN ('COMPLETEAGENT','COMPLETECALLER', 'TRANSFER','COMPLETEAGENTRAMAL','COMPLETECALLERRAMAL', 'COMPLETACALLER', 'COMPLETAAGENT') ";
if (!$protocolo) { if (!$protocolo) {
$query .= "AND a.id_dac = '$dac' $query .= "AND a.id_dac = '$dac'
AND a.pp_id = '$ppId' AND a.pp_id = '$ppId'
AND a.pm_data >= '$dataIni' AND a.pm_data >= '$dataIni'
AND a.pm_data <= '$dataFim' "; AND a.pm_data <= '$dataFim' ";
@ -181,8 +195,12 @@
$query .= "AND d.protocolo = '$protocolo' "; $query .= "AND d.protocolo = '$protocolo' ";
} }
if (GetUsoServico() && $srv) {
$query .= " AND s.serv_id = '{$srv}' \n";
}
$query .= " ORDER BY c.nome, a.pm_data"; $query .= " ORDER BY c.nome, a.pm_data";
$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());

Loading…
Cancel
Save