|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
include_once 'util/relatoriosBase.php';
|
|
|
|
|
|
|
|
|
|
class RelTransfer extends Relatorios {
|
|
|
|
|
|
|
|
|
|
private $___ramal;
|
|
|
|
|
private $___agente;
|
|
|
|
|
private $___status;
|
|
|
|
|
|
|
|
|
|
public function __construct($idProg, $dbcon, $incDac) {
|
|
|
|
|
parent::__construct($idProg, $dbcon, $incDac);
|
|
|
|
|
$this->___ramal = isset($_POST["ramal"]) ? $_POST["ramal"] : '';
|
|
|
|
|
$this->___agente = isset($_POST["listaAgente"]) ? $_POST["listaAgente"] : '';
|
|
|
|
|
$this->___status = isset($_POST["lstStatus"]) ? $_POST["lstStatus"] : '';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function ___FiltrosRelatorio() {
|
|
|
|
|
$agente = $this->___GetAgente();
|
|
|
|
|
|
|
|
|
|
if ($this->___media != MEDIA_PRINT_GRID) {
|
|
|
|
|
/*
|
|
|
|
|
* Recupera os filtros da sess<EFBFBD>o do usu<EFBFBD>rio.
|
|
|
|
|
*/
|
|
|
|
|
list($this->___dac, $this->___dataIni, $this->___dataFim, $this->___tipoRelatorio) = $_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 fun<EFBFBD><EFBFBD>o se necessitar de outras opnioes de filtro.
|
|
|
|
|
*/
|
|
|
|
|
$filtro = '<table border="0" cellspacing="1" cellpadding="1">';
|
|
|
|
|
/*
|
|
|
|
|
* Rotulos.
|
|
|
|
|
*/
|
|
|
|
|
$filtro .= '<tr>';
|
|
|
|
|
if ($this->GetIncDac())
|
|
|
|
|
$filtro .= '<td>Fila</td>';
|
|
|
|
|
$filtro .= '<td>Data Inicial</td>';
|
|
|
|
|
$filtro .= '<td>Data Final </td>';
|
|
|
|
|
$filtro .= '<td>Ramal</td>';
|
|
|
|
|
$filtro .= '<td>Agente</td>';
|
|
|
|
|
$filtro .= '<td>Status</td>';
|
|
|
|
|
$filtro .= '<td align="center" valign="middle"> </td>';
|
|
|
|
|
$filtro .= '</tr>';
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Valores.
|
|
|
|
|
*/
|
|
|
|
|
$filtro .= '<tr>';
|
|
|
|
|
if ($this->GetIncDac())
|
|
|
|
|
$filtro .= sprintf('<td>%s</td>', $dacs);
|
|
|
|
|
$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 .= sprintf('<td><input name="ramal" id="ramal" type="text" size="15" value="%s" /></td>', $this->___ramal);
|
|
|
|
|
$filtro .= sprintf('<td>%s</td>', $agente);
|
|
|
|
|
$filtro .= sprintf('<td>%s</td>', $this->___GetStatus($this->___status));
|
|
|
|
|
$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 emiss<EFBFBD>o dos relat<EFBFBD>ios para impress<EFBFBD>o.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
$_SESSION["SSstorageFiltros"] = array($this->___dac, $this->___dataIni, $this->___dataFim, $this->___tipoRelatorio, $this->___agente);
|
|
|
|
|
|
|
|
|
|
return sprintf($filtro, $this->___dataIni, $this->___dataFim, $lkPrint);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function ___GetDadosDb() {
|
|
|
|
|
|
|
|
|
|
$dataIni = FormatDtMssql($this->___dataIni);
|
|
|
|
|
$dataFim = FormatDtMssql($this->___dataFim);
|
|
|
|
|
$dac = $this->___dac;
|
|
|
|
|
$dataCorte = GetDataRelatorio();
|
|
|
|
|
$ramal = $this->___ramal;
|
|
|
|
|
$agente = $this->___agente;
|
|
|
|
|
$status = $this->___status;
|
|
|
|
|
|
|
|
|
|
$query = "select * from(
|
|
|
|
|
select d.fila, a.calldate, a.src,
|
|
|
|
|
case when(d.evento in('COMPLETECALLER','COMPLETEAGENT'))
|
|
|
|
|
then(select q.destino from pbx_bilhetes_complemento q where q.uniqueid2 = a.uniqueid and q.direcao = 'fila-ramal')
|
|
|
|
|
else(select q.destino from pbx_bilhetes_complemento q where q.uniqueid2 = a.uniqueid order by data_registro limit 1)
|
|
|
|
|
end as dst,
|
|
|
|
|
c.apelido, a.billsec, a.duration,
|
|
|
|
|
case when(a.disposition = 'ANSWERED')then 'ATENDIDA' else 'ABANDONADA' end as status
|
|
|
|
|
from pbx_bilhetes a,pbx_usuarios c, pbx_eventos_dacs d, pbx_dacs e
|
|
|
|
|
where c.matricula = substring(d.agente, 7, 4)
|
|
|
|
|
and d.uid2 = a.uniqueid
|
|
|
|
|
and e.nome = d.fila
|
|
|
|
|
and d.evento in('COMPLETEAGENT','COMPLETECALLER','COMPLETAAGENT','COMPLETACALLER')
|
|
|
|
|
and a.lastapp <> 'Transferred Call'
|
|
|
|
|
and a.data_bilhete >= '$dataIni'
|
|
|
|
|
and a.data_bilhete <= '$dataFim'
|
|
|
|
|
and exists(select '' from pbx_bilhetes where data_bilhete = a.data_bilhete and accountcode = a.uniqueid) ";
|
|
|
|
|
|
|
|
|
|
$dataIni ? $query .= " and a.calldate::date >= '$dataIni' " : '';
|
|
|
|
|
$dataFim ? $query .= " and a.calldate::date <= '$dataFim' " : '';
|
|
|
|
|
$ramal ? $query .= " and a.dst = '$ramal' " : '';
|
|
|
|
|
$agente ? $query .= " and c.matricula = '$agente' " : '';
|
|
|
|
|
$status ? $query .= " and a.disposition = '$status' " : '';
|
|
|
|
|
$dac ? $query .= " and e.id = '$dac' " : '';
|
|
|
|
|
|
|
|
|
|
$query .= " union all
|
|
|
|
|
select d.fila, a.calldate, a.src, (select q.destino from pbx_bilhetes_complemento q where q.uniqueid2 = a.uniqueid order by data_registro desc limit 1)as dst, c.apelido, d.param4::bigint as billsec, a.duration,
|
|
|
|
|
case when(a.disposition = 'ANSWERED' or d.param4 > '0')then 'ATENDIDA' else 'ABANDONADA' end as status
|
|
|
|
|
from pbx_bilhetes a,pbx_usuarios c, pbx_eventos_dacs d, pbx_dacs e
|
|
|
|
|
where c.matricula = substring(d.agente, 7, 4)
|
|
|
|
|
and d.uid2 = a.uniqueid
|
|
|
|
|
and e.nome = d.fila
|
|
|
|
|
and d.param4 <> ''
|
|
|
|
|
and d.evento in('TRANSFER','TRANSFERORIG')
|
|
|
|
|
and a.lastapp <> 'Transferred Call'
|
|
|
|
|
and a.data_bilhete >= '$dataIni'
|
|
|
|
|
and a.data_bilhete <= '$dataFim' ";
|
|
|
|
|
|
|
|
|
|
$dataIni ? $query .= " and a.calldate::date >= '$dataIni' " : '';
|
|
|
|
|
$dataFim ? $query .= " and a.calldate::date <= '$dataFim' " : '';
|
|
|
|
|
$ramal ? $query .= " and a.dst = '$ramal' " : '';
|
|
|
|
|
$agente ? $query .= " and c.matricula = '$agente' " : '';
|
|
|
|
|
$status ? $query .= " and a.disposition = '$status' " : '';
|
|
|
|
|
$dac ? $query .= " and e.id = '$dac' " : '';
|
|
|
|
|
|
|
|
|
|
$query .= ")as transferencia order by 2";
|
|
|
|
|
|
|
|
|
|
//echo $query;
|
|
|
|
|
|
|
|
|
|
$result = $this->___GetQuery($query);
|
|
|
|
|
$row = pg_fetch_all($result);
|
|
|
|
|
$this->SetData($row ? $row : array());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function ___PreparaCsv() {
|
|
|
|
|
$dataRel = array();
|
|
|
|
|
$chmTotal = array();
|
|
|
|
|
$filtro = $this->___FiltrosRelatorio();
|
|
|
|
|
$dataRel[] = GenerateCsvFromArray($filtro);
|
|
|
|
|
|
|
|
|
|
$dadosCabecalio = array('Ramal', 'Origem', 'Data/Hora', 'Tempo', 'Status');
|
|
|
|
|
$dadosField = array('dst', 'src', 'calldate', 'billsec', 'status');
|
|
|
|
|
|
|
|
|
|
$dataRel[] = GenerateCsvFromArray($dadosCabecalio);
|
|
|
|
|
|
|
|
|
|
$somaReg = 0;
|
|
|
|
|
$somaChm = 0;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Linhas de dados.
|
|
|
|
|
*/
|
|
|
|
|
foreach ($this->GetData()[0] as $row) {
|
|
|
|
|
$somaReg ++;
|
|
|
|
|
$row['status'] == 'ATENDIDA' ? $somaChm++ : '';
|
|
|
|
|
|
|
|
|
|
$row['billsec'] = SecondToStrTime($row['billsec']);
|
|
|
|
|
$row['calldate'] = date('d/m/Y H:i:s', strtotime($row['calldate']));
|
|
|
|
|
|
|
|
|
|
$chmTotal[$row['dst']] += 1;
|
|
|
|
|
|
|
|
|
|
$linha = array();
|
|
|
|
|
foreach ($dadosField as $key) {
|
|
|
|
|
$linha[] = $row["$key"];
|
|
|
|
|
}
|
|
|
|
|
$dataRel[] = GenerateCsvFromArray($linha);
|
|
|
|
|
}
|
|
|
|
|
$dataRel[] = GenerateCsvFromArray(array('Total Atendidadas:', '', '', '', $somaChm));
|
|
|
|
|
$dataRel[] = GenerateCsvFromArray(array('Total Chamadas:', '', '', '', $somaReg));
|
|
|
|
|
$dataRel[] = GenerateCsvFromArray(array(''));
|
|
|
|
|
$dataRel[] = GenerateCsvFromArray(array('Ramal','Quantidade'));
|
|
|
|
|
foreach($chmTotal as $k => $v){
|
|
|
|
|
$dataRel[] = GenerateCsvFromArray(array($k,$v));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->___dataRel[] = $dataRel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function ___PreparaExcel() {
|
|
|
|
|
$dataRel = array();
|
|
|
|
|
$chmTotal = 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('Ramal', 'Origem', 'Data/Hora', 'Tempo', 'Status');
|
|
|
|
|
$dadosField = array('dst', 'src', 'calldate', 'billsec', 'status');
|
|
|
|
|
|
|
|
|
|
$linha = array('LABEL');
|
|
|
|
|
foreach ($dadosCabecalio as $value) {
|
|
|
|
|
$linha[] = $value;
|
|
|
|
|
}
|
|
|
|
|
$dataRel[] = $linha;
|
|
|
|
|
|
|
|
|
|
$somaReg = 0;
|
|
|
|
|
$somaChm = 0;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Linhas de dados.
|
|
|
|
|
*/
|
|
|
|
|
foreach ($this->GetData()[0] as $row) {
|
|
|
|
|
$somaReg ++;
|
|
|
|
|
$row['status'] == 'ATENDIDA' ? $somaChm++ : '';
|
|
|
|
|
|
|
|
|
|
$row['billsec'] = SecondToStrTime($row['billsec']);
|
|
|
|
|
$row['calldate'] = date('d/m/Y H:i:s', strtotime($row['calldate']));
|
|
|
|
|
|
|
|
|
|
$chmTotal[$row['dst']] += 1;
|
|
|
|
|
|
|
|
|
|
$linha = array('DADOS');
|
|
|
|
|
foreach ($dadosField as $key) {
|
|
|
|
|
$linha[] = $row["$key"];
|
|
|
|
|
}
|
|
|
|
|
$dataRel[] = $linha;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$dataRel[] = array('LABEL', 'Chamadas Atendidas: ', '', '', '', $somaChm);
|
|
|
|
|
$dataRel[] = array('LABEL', 'Total Chamadas: ', '', '', '', $somaReg);
|
|
|
|
|
$dataRel[] = array('LABEL', '');
|
|
|
|
|
$dataRel[] = array('LABEL', 'Ramal ', 'Quantidade');
|
|
|
|
|
foreach ($chmTotal as $k => $v){
|
|
|
|
|
$dataRel[] = array('DADOS', $k, $v);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->___dataRel[] = $dataRel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function ___PreparaGrid() {
|
|
|
|
|
$dataRel = array();
|
|
|
|
|
$chmTotal = array();
|
|
|
|
|
|
|
|
|
|
$dadosCabecalio = array(
|
|
|
|
|
'Ramal' => 'align="center"',
|
|
|
|
|
'Origem' => 'align="center"',
|
|
|
|
|
'Data/Hora' => 'align="center"',
|
|
|
|
|
'Tempo' => 'align="center"',
|
|
|
|
|
'Status' => 'align="center"'
|
|
|
|
|
);
|
|
|
|
|
$dadosField = array(
|
|
|
|
|
'dst' => 'align="center"',
|
|
|
|
|
'src' => 'align="center"',
|
|
|
|
|
'calldate' => 'align="center"',
|
|
|
|
|
'billsec' => 'align="center"',
|
|
|
|
|
'status' => 'align="center"'
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Inicia o relat<EFBFBD>rio.
|
|
|
|
|
*/
|
|
|
|
|
$dataRel[] = '<table width="70%" cellpadding="2" class="grid">';
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Monta a linha de cabecalio.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
$linha = '<tr>';
|
|
|
|
|
$linha .= "<th align=\"center\" colspan=\"5\">Transfer<EFBFBD>ncia de chamada</th>";
|
|
|
|
|
$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(1) - 1, (!IsPostBack() ? 'Informe os parametros e clique em consultar!' : 'Nenhum registro encontado!'));
|
|
|
|
|
$this->___dataRel[] = $dataRel;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$linhaC = "<tr>";
|
|
|
|
|
foreach ($dadosCabecalio as $key => $value) {
|
|
|
|
|
$linhaC .= sprintf("<th %s>%s</th>", $value, $key);
|
|
|
|
|
}
|
|
|
|
|
$linhaC .= "</tr>";
|
|
|
|
|
$dataRel[] = $linhaC;
|
|
|
|
|
|
|
|
|
|
$somaReg = 0;
|
|
|
|
|
$somaChm = 0;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Linhas de dados.
|
|
|
|
|
*/
|
|
|
|
|
foreach ($this->GetData()[0] as $row) {
|
|
|
|
|
$somaReg ++;
|
|
|
|
|
$row['status'] == 'ATENDIDA' ? $somaChm++ : '';
|
|
|
|
|
$row['dst'] = ocultarTelefone($row['dst']);
|
|
|
|
|
$row['src'] = ocultarTelefone($row['src']);
|
|
|
|
|
$row['billsec'] = SecondToStrTime($row['billsec']);
|
|
|
|
|
$row['calldate'] = date('d/m/Y H:i:s', strtotime($row['calldate']));
|
|
|
|
|
|
|
|
|
|
$chmTotal[$row['dst']] += 1;
|
|
|
|
|
|
|
|
|
|
$linha = "<tr>";
|
|
|
|
|
foreach ($dadosField as $key => $value) {
|
|
|
|
|
$linha .= sprintf("<td %s>%s</td>", $value, $row["$key"]);
|
|
|
|
|
}
|
|
|
|
|
$linha .= "</tr>";
|
|
|
|
|
$dataRel[] = $linha;
|
|
|
|
|
}
|
|
|
|
|
$dataRel[] = "<tr><th colspan=\"4\">Chamadas Atendidas: </th><th align=\"center\">$somaChm</th></tr>";
|
|
|
|
|
$dataRel[] = "<tr><th colspan=\"4\">Total de chamadas: </th><th align=\"center\">$somaReg</th></tr>";
|
|
|
|
|
|
|
|
|
|
$dataRel[] = "</table><br>";
|
|
|
|
|
|
|
|
|
|
$tabletotal = "<table width=\"30%\" cellpadding=\"2\" class=\"grid\"><tr><th colspan=\"2\">Resumo de chamadas: </th></tr>";
|
|
|
|
|
$tabletotal .= "<tr><th>Ramal</th><th>Quantidade</th></tr>";
|
|
|
|
|
foreach ($chmTotal as $chave => $valores) {
|
|
|
|
|
$tabletotal .= "<tr><td>$chave </td><td>$valores</td></tr>";
|
|
|
|
|
}
|
|
|
|
|
$tabletotal .= "</table>";
|
|
|
|
|
$dataRel[] = $tabletotal;
|
|
|
|
|
$this->___dataRel[] = $dataRel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function ___PreparaHtml() {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function ___PreparaPdf() {
|
|
|
|
|
list($this->___dac, $this->___dataIni, $this->___dataFim, $this->___tipoRelatorio) = $_SESSION["SSstorageFiltros"];
|
|
|
|
|
$chmTotal = array();
|
|
|
|
|
$dadosCabecalio = array(
|
|
|
|
|
'Ramal' => 'C',
|
|
|
|
|
'Origem' => 'C',
|
|
|
|
|
'Data/Hora' => 'C',
|
|
|
|
|
'Tempo' => 'C',
|
|
|
|
|
'Status' => 'C'
|
|
|
|
|
);
|
|
|
|
|
$dadosField = array(
|
|
|
|
|
'dst' => 'C',
|
|
|
|
|
'src' => 'C',
|
|
|
|
|
'calldate' => 'C',
|
|
|
|
|
'billsec' => 'C',
|
|
|
|
|
'status' => 'C'
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$somaChm = 0;
|
|
|
|
|
$x = 0;
|
|
|
|
|
$dados = $this->GetData()[0];
|
|
|
|
|
$chave = '';
|
|
|
|
|
/*
|
|
|
|
|
* Linhas de dados.
|
|
|
|
|
*/
|
|
|
|
|
foreach ($dados as $row) {
|
|
|
|
|
$row['status'] == 'ATENDIDA' ? $somaChm++ : '';
|
|
|
|
|
|
|
|
|
|
$row['billsec'] = SecondToStrTime($row['billsec']);
|
|
|
|
|
$row['calldate'] = date('d/m/Y H:i:s', strtotime($row['calldate']));
|
|
|
|
|
|
|
|
|
|
foreach ($chmTotal as $key => $v) {
|
|
|
|
|
if ($v['ramal'] == $row['dst']) {
|
|
|
|
|
$chave = $key;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$x++;
|
|
|
|
|
|
|
|
|
|
if ($chave) {
|
|
|
|
|
$chmTotal[$chave]['quantidade'] ++;
|
|
|
|
|
$chave = '';
|
|
|
|
|
} else {
|
|
|
|
|
$chmTotal[$x]['ramal'] = $row['dst'];
|
|
|
|
|
$chmTotal[$x]['quantidade'] = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
$widthHeader = array(38, 38, 38, 38, 38);
|
|
|
|
|
$totaliza = array("Total Chamadas: $x", '', '', '', "Total Atendidas: $somaChm");
|
|
|
|
|
$table = array($dadosCabecalio, $dadosField, $dados, $widthHeader, $totaliza, 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$table1 = array(array('Ramal' => 'C', 'Quantidade' => 'C'), array('ramal' => 'C', 'quantidade' => 'C'), $chmTotal, array(38, 38), 0, 1);
|
|
|
|
|
|
|
|
|
|
$this->___dataRel = array($table, $table1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function ___GetAgente() {
|
|
|
|
|
global $dbcon;
|
|
|
|
|
|
|
|
|
|
$query = sprintf("SELECT DISTINCT c.matricula, c.apelido as nome
|
|
|
|
|
FROM pbx_bilhetes a, pbx_eventos_dacs b, pbx_usuarios c
|
|
|
|
|
WHERE b.uid2 = a.uniqueid
|
|
|
|
|
AND c.matricula = substring(b.agente, 7, 4)
|
|
|
|
|
AND a.calldate::date >= '%s'
|
|
|
|
|
AND a.calldate::date <= '%s'
|
|
|
|
|
AND b.fila = case when(%s = 0)then b.fila else (select nome from pbx_dacs where id = %s) end
|
|
|
|
|
ORDER BY 2", FormatDtMssql($this->___dataIni), FormatDtMssql($this->___dataFim), $this->___dac, $this->___dac);
|
|
|
|
|
|
|
|
|
|
$resp = pg_query($dbcon, $query);
|
|
|
|
|
$result = pg_fetch_all($resp);
|
|
|
|
|
|
|
|
|
|
$row = "<select name=\"listaAgente\">";
|
|
|
|
|
!$result ? $row .= "<option value=\"0\"> ----- </option>" : $row .= "<option value=\"0\">Todos</option>";
|
|
|
|
|
foreach ($result as $agentes) {
|
|
|
|
|
$sel = $this->___agente == $agentes['matricula'] ? "selected" : '';
|
|
|
|
|
$row .= sprintf("<option value=\"%s\" $sel>%s</option>", $agentes['matricula'], $agentes['nome']);
|
|
|
|
|
}
|
|
|
|
|
$row .= "</select>";
|
|
|
|
|
return $row;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function ___GetStatus($st) {
|
|
|
|
|
$status = "<select name=\"lstStatus\" id=\"lstStatus\">";
|
|
|
|
|
$status .= str_replace("{SEL}", (!$st ? "selected" : ""), "<option value=\"\" {SEL}>Todos</option>");
|
|
|
|
|
$status .= str_replace("{SEL}", ($st == "ANSWERED" ? "selected" : ""), "<option value=\"ANSWERED\" {SEL}>ATENDIDA</option>");
|
|
|
|
|
$status .= str_replace("{SEL}", ($st == "BUSY" ? "selected" : ""), "<option value=\"BUSY\" {SEL}>OCUPADO</option>");
|
|
|
|
|
$status .= str_replace("{SEL}", ($st == "ENQUIRY" ? "selected" : ""), "<option value=\"ENQUIRY\" {SEL}>CONSULTA</option>");
|
|
|
|
|
$status .= str_replace("{SEL}", ($st == "NO ANSWER" ? "selected" : ""), "<option value=\"NO ANSWER\" {SEL}>ABANDONADA</option>");
|
|
|
|
|
$status .= "</select>";
|
|
|
|
|
|
|
|
|
|
return $status;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$relTransfer = new RelTransfer($idProg, $dbcon, 1);
|
|
|
|
|
$relTransfer->ExecutaRelatorio();
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Relatório mostra a produtividade de um agente
|
|
|
|
|
|
|
|
|
|
require_once("bd.php");
|
|
|
|
|
|
|
|
|
|
//variaveis para manter o estado
|
|
|
|
|
if ($_POST["btConsulta"]) {
|
|
|
|
|
$_SESSION["listaDacs"] = $_POST["listaDacs"];
|
|
|
|
|
$_SESSION["listaAgente"] = $_POST["listaAgente"];
|
|
|
|
|
$_SESSION["dataIni"] = $_POST["dataIni"];
|
|
|
|
|
$_SESSION["dataFim"] = $_POST["dataFim"];
|
|
|
|
|
$_SESSION["ramal"] = $_POST["ramal"];
|
|
|
|
|
$_SESSION["lstStatus"] = $_POST["lstStatus"];
|
|
|
|
|
} else {
|
|
|
|
|
$_SESSION["listaAgente"] = 0;
|
|
|
|
|
$_SESSION["listaDacs"] = !IsAjax() ? GetIdDacPadrao($dbcon, $_SESSION["SSidUser"]) : $_GET["listaDacs"];
|
|
|
|
|
$_SESSION["dataIni"] = !IsAjax() ? date('d/m/Y') . " 00:00" : $_GET["dataIni"];
|
|
|
|
|
$_SESSION["dataFim"] = !IsAjax() ? date('d/m/Y') . " 23:59" : $_GET["dataFim"];
|
|
|
|
|
$_SESSION["lstStatus"] = "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Verifica se <EFBFBD> o primeiro acesso a pagia
|
|
|
|
|
$isPostBack = isset($_GET["idProg"]) ? 0 : 1;
|
|
|
|
|
|
|
|
|
|
$codSel = $_SESSION["listaDacs"];
|
|
|
|
|
//carrega dacs
|
|
|
|
|
if (!IsAjax())
|
|
|
|
|
$dacs = GetDac($dbcon, $codSel, "", 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//carrega Atendente
|
|
|
|
|
if (!IsAjax())
|
|
|
|
|
$codSel = ((!$_SESSION["listaAgente"]) || ($trocaDac)) ? 0 : $_SESSION["listaAgente"];
|
|
|
|
|
else
|
|
|
|
|
$codSel = !empty($_GET["codAgt"]) ? $_GET["codAgt"] : 0;
|
|
|
|
|
|
|
|
|
|
$sel = !$codSel ? "selected" : "";
|
|
|
|
|
|
|
|
|
|
$agentes = "<select name=\"listaAgente\" id=\"listaAgente\" size=\"1\">";
|
|
|
|
|
$agentes .= "<option value=\"0\" $sel>Todos</option>";
|
|
|
|
|
|
|
|
|
|
$idDac = $_SESSION["listaDacs"];
|
|
|
|
|
|
|
|
|
|
$dtAgtIni = FormatDtMssql(substr($_SESSION["dataIni"], 0, 10));
|
|
|
|
|
$dtAgtFim = FormatDtMssql(substr($_SESSION["dataFim"], 0, 10));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$query = "select distinct c.matricula, c.apelido as nome
|
|
|
|
|
from pbx_bilhetes a, pbx_eventos_dacs b, pbx_usuarios c
|
|
|
|
|
where b.uid2 = a.uniqueid
|
|
|
|
|
and c.matricula = substring(b.agente, 7, 4)
|
|
|
|
|
and a.calldate::date >= '$dtAgtIni'
|
|
|
|
|
and a.calldate::date <= '$dtAgtFim'
|
|
|
|
|
and b.fila = case when($idDac = 0)then b.fila else (select nome from pbx_dacs where id = $idDac) end
|
|
|
|
|
order by 2 ";
|
|
|
|
|
|
|
|
|
|
//if(IsAdmin()) echo $query;
|
|
|
|
|
$result = pg_query($dbcon, $query);
|
|
|
|
|
|
|
|
|
|
$numAgt = 0;
|
|
|
|
|
while ($dados = @pg_fetch_row($result)) {
|
|
|
|
|
if ($codSel == $dados[0]) {
|
|
|
|
|
$sel = "selected";
|
|
|
|
|
$i = 1;
|
|
|
|
|
} else {
|
|
|
|
|
$sel = "";
|
|
|
|
|
}
|
|
|
|
|
$agentes .= "<option value=\"$dados[0]\" $sel>$dados[1]</option>";
|
|
|
|
|
$numAgt++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$agentes .= "</select>";
|
|
|
|
|
|
|
|
|
|
if (!$numAgt)
|
|
|
|
|
$agentes = str_replace('Todos', '------', $agentes);
|
|
|
|
|
|
|
|
|
|
//relatorio
|
|
|
|
|
if (IsAjax()) {
|
|
|
|
|
echo $agentes;
|
|
|
|
|
} else {
|
|
|
|
|
$imp = 0;
|
|
|
|
|
$linhas = "";
|
|
|
|
|
|
|
|
|
|
//valida data inicial
|
|
|
|
|
$hora = array();
|
|
|
|
|
$valDate = substr($_SESSION["dataIni"], 0, 10);
|
|
|
|
|
$hora = split(":", substr($_SESSION["dataIni"], 11, 5));
|
|
|
|
|
$hora[0] = (int) $hora[0];
|
|
|
|
|
$hora[1] = (int) $hora[1];
|
|
|
|
|
$valIni = is_date($valDate);
|
|
|
|
|
if ($valIni)
|
|
|
|
|
$valIni = !$hora[0] && !$hora[1] ? true : (($hora[0] > 23) || ($hora[1] > 59) ? false : true);
|
|
|
|
|
|
|
|
|
|
//valida data final
|
|
|
|
|
$hora = array();
|
|
|
|
|
$valDate = substr($_SESSION["dataFim"], 0, 10);
|
|
|
|
|
$hora = split(":", substr($_SESSION["dataFim"], 11, 5));
|
|
|
|
|
|
|
|
|
|
$hora[0] = (int) $hora[0];
|
|
|
|
|
$hora[1] = (int) $hora[1];
|
|
|
|
|
|
|
|
|
|
$valFim = is_date($valDate);
|
|
|
|
|
if ($valFim)
|
|
|
|
|
$valFim = (!$hora[0] && !$hora[1]) ? true : (($hora[0] > 23) || ($hora[1] > 59) ? false : true);
|
|
|
|
|
|
|
|
|
|
if (IsPostBack() && !$_SESSION["listaDacs"]) {
|
|
|
|
|
$jsStartup[] = "alert('Selecione um DAC!');";
|
|
|
|
|
$msg = "Selecione um DAC!";
|
|
|
|
|
} else if (!$valIni) {
|
|
|
|
|
$jsStartup[] = "alert('Data inicial inv<EFBFBD>lida!');";
|
|
|
|
|
$msg = "Data inicial inv<EFBFBD>lida!";
|
|
|
|
|
} else if (!$valFim) {
|
|
|
|
|
$jsStartup[] = "alert('Data final inv<EFBFBD>lida!');";
|
|
|
|
|
$msg = "Data final inv<EFBFBD>lida!";
|
|
|
|
|
} else {
|
|
|
|
|
if ($isPostBack) {
|
|
|
|
|
$setQuery = "";
|
|
|
|
|
$setQuery = utf8_encode(GetQuery($trocaDac));
|
|
|
|
|
$result = @pg_query($dbcon, $setQuery);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$resumo = array();
|
|
|
|
|
$total = 0;
|
|
|
|
|
$buffDados = array();tempo_atende
|
|
|
|
|
$dacSel = "";
|
|
|
|
|
$totais = array();
|
|
|
|
|
while ($dados = @pg_fetch_array($result)) {
|
|
|
|
|
$dados["dac"] = $dados["fila"];
|
|
|
|
|
$dados["data"] = $dados["calldate"];
|
|
|
|
|
$dados["agente"] = $dados["apelido"];
|
|
|
|
|
$dados["destino"] = $dados["dst"];
|
|
|
|
|
$dados["fone"] = $dados["src"];
|
|
|
|
|
// fila, calldate, src, dst, apelido, disposition, billsec, duration
|
|
|
|
|
|
|
|
|
|
$buffDados[] = $dados;
|
|
|
|
|
$data = FormataDBDataHora($dados["data"]);
|
|
|
|
|
$fone = FormataFone($dados["fone"]);
|
|
|
|
|
$agente = $dados["agente"];
|
|
|
|
|
$destino = $dados["destino"]; // == 200 ? $dados["dac"] : $dados["destino"];
|
|
|
|
|
$status = $dados["status"];
|
|
|
|
|
$dacSel = $dados["dac"];
|
|
|
|
|
$tipo = SecondToStrTime($dados["billsec"]);
|
|
|
|
|
$totais[$dados["status"]] ++;
|
|
|
|
|
|
|
|
|
|
//Ramal, Origem, Data/Hora, Tipo, Status
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!array_key_exists($dados["destino"], $resumo))
|
|
|
|
|
$resumo[$dados["destino"]] = 1;
|
|
|
|
|
else
|
|
|
|
|
$resumo[$dados["destino"]] ++;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$linhas .= "<tr>
|
|
|
|
|
<td align=\"left\" class=\"headColun\">$destino</td>
|
|
|
|
|
<td align=\"left\" class=\"headColun\">$fone</td>
|
|
|
|
|
<td align=\"left\" class=\"headColun\">$data</td>
|
|
|
|
|
<td align=\"left\" class=\"headColun\">$tipo</td>
|
|
|
|
|
<td align=\"center\" class=\"headColun\">$status</td>
|
|
|
|
|
</tr>";
|
|
|
|
|
|
|
|
|
|
$total++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ksort($resumo);
|
|
|
|
|
$totalRes = 0;
|
|
|
|
|
$akey = array();
|
|
|
|
|
$totalResumo = 0;
|
|
|
|
|
foreach ($resumo as $key => $value) {
|
|
|
|
|
$akey[] = array($key, $value);
|
|
|
|
|
$linhaResumo .= "<tr> <td align=\"center\">$key</td><td align=\"right\">$value</td></tr>";
|
|
|
|
|
$totalRes += $value;
|
|
|
|
|
$totalResumo++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//dados para relatorio
|
|
|
|
|
$_SESSION["dadosRelTrans"] = $buffDados;
|
|
|
|
|
$_SESSION["relTransTotal"] = $total;
|
|
|
|
|
$_SESSION["dacSel"] = $dacSel;
|
|
|
|
|
$_SESSION["dadosRelResumo"] = $akey;
|
|
|
|
|
$_SESSION["relTransResumoTotal"] = $totalResumo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$jsJQuery[] = "\$('#listaDacs').change(function(){GetAgtFromTransfer();}) ";
|
|
|
|
|
|
|
|
|
|
$jsJQuery[] = "\$('#dataIni').keypress(function(){formataDataHora(this);}) ";
|
|
|
|
|
$jsJQuery[] = "\$('#dataIni').change(function(){GetAgtFromTransfer();}) ";
|
|
|
|
|
|
|
|
|
|
$jsJQuery[] = "\$('#dataFim').keypress(function(){formataDataHora(this);}) ";
|
|
|
|
|
$jsJQuery[] = "\$('#dataFim').change(function(){GetAgtFromTransfer();}) ";
|
|
|
|
|
|
|
|
|
|
//totalizacao
|
|
|
|
|
if ($total) {
|
|
|
|
|
$linhaTotal = "";
|
|
|
|
|
foreach ($totais as $key => $value)
|
|
|
|
|
$linhaTotal .= "<tr><th colspan=\"4\" align=\"left\">Total de $key</th><th align=\"right\">$value</th></tr>";
|
|
|
|
|
|
|
|
|
|
$linhaTotal .= "<tr><th colspan=\"4\" align=\"left\">Total Geral</th><th align=\"right\">$total</th></tr>";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($isPostBack) {
|
|
|
|
|
$erro = "";
|
|
|
|
|
if (pg_last_error($dbcon))
|
|
|
|
|
$erro = "Ocorreram erros durante a opera<EFBFBD><EFBFBD>o. Erro: " . pg_last_error($dbcon);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$smarty->assign('imp', $total);
|
|
|
|
|
$smarty->assign('dtIni', $_SESSION["dataIni"]);
|
|
|
|
|
$smarty->assign('dtFim', $_SESSION["dataFim"]);
|
|
|
|
|
$smarty->assign('ramal', $_SESSION["ramal"]);
|
|
|
|
|
$smarty->assign('dacs', $dacs);
|
|
|
|
|
$smarty->assign('agentes', $agentes);
|
|
|
|
|
$smarty->assign('status', GetStatus($_SESSION["lstStatus"]));
|
|
|
|
|
$smarty->assign('linhas', $linhas);
|
|
|
|
|
$smarty->assign('totais', $linhaTotal);
|
|
|
|
|
$smarty->assign('linhaResumo', $linhaResumo);
|
|
|
|
|
$smarty->assign('totalRes', $totalRes);
|
|
|
|
|
$smarty->assign('erro', $erro);
|
|
|
|
|
DispRel($smarty);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function DispRel($smarty) {
|
|
|
|
|
$smarty->display('transferenciaGrid.tpl');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function GetQuery($trocaDac) {
|
|
|
|
|
$dac = trim($_SESSION["listaDacs"]);
|
|
|
|
|
$agente = trim($_SESSION["agente"]);
|
|
|
|
|
$dt = trim($_SESSION["dataIni"]);
|
|
|
|
|
$dtFim = trim($_SESSION["dataFim"]);
|
|
|
|
|
$ramal = trim($_SESSION["ramal"]);
|
|
|
|
|
$status = trim($_SESSION["lstStatus"]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$dataInicial = FormatDtMssql(substr($_SESSION["dataIni"], 0, 10));
|
|
|
|
|
$dataFinal = FormatDtMssql(substr($_SESSION["dataFim"], 0, 10));
|
|
|
|
|
|
|
|
|
|
$dt = soNumero($dt) <= 8 ? '' : FormatDtHoraBD($dt);
|
|
|
|
|
$dtFim = soNumero($dtFim) <= 8 ? '' : FormatDtHoraBD($dtFim);
|
|
|
|
|
$dataCorte = GetDataRelatorio();
|
|
|
|
|
|
|
|
|
|
$query = " select * from(
|
|
|
|
|
select d.fila, a.calldate, a.src,
|
|
|
|
|
case when(d.evento in('COMPLETECALLER','COMPLETEAGENT'))
|
|
|
|
|
then(select q.destino from pbx_bilhetes_complemento q where q.uniqueid2 = a.uniqueid and q.direcao = 'fila-ramal') -- entrada
|
|
|
|
|
else(select q.destino from pbx_bilhetes_complemento q where q.uniqueid2 = a.uniqueid order by data_registro limit 1) -- sa<EFBFBD>da
|
|
|
|
|
end as dst,
|
|
|
|
|
c.apelido, a.billsec, a.duration,
|
|
|
|
|
case when(a.disposition = 'ANSWERED')then 'ATENDIDA' else 'ABANDONADA' end as status
|
|
|
|
|
from pbx_bilhetes a,pbx_usuarios c, pbx_eventos_dacs d, pbx_dacs e
|
|
|
|
|
where c.matricula = substring(d.agente, 7, 4)
|
|
|
|
|
and d.uid2 = a.uniqueid
|
|
|
|
|
and e.nome = d.fila
|
|
|
|
|
and d.evento in('COMPLETEAGENT','COMPLETECALLER','COMPLETAAGENT','COMPLETACALLER')
|
|
|
|
|
and a.lastapp <> 'Transferred Call'
|
|
|
|
|
and a.data_bilhete >= '$dataCorte'
|
|
|
|
|
and a.data_bilhete >= '$dataInicial'
|
|
|
|
|
and a.data_bilhete <= '$dataFinal'
|
|
|
|
|
and exists(select '' from pbx_bilhetes where data_bilhete = a.data_bilhete and accountcode = a.uniqueid)\n";
|
|
|
|
|
|
|
|
|
|
if ($dt)
|
|
|
|
|
$query .= " and date_trunc('minute', a.calldate) >= '$dt'\n";
|
|
|
|
|
if ($dtFim)
|
|
|
|
|
$query .= " and date_trunc('minute', a.calldate) <= '$dtFim'\n";
|
|
|
|
|
if ($ramal)
|
|
|
|
|
$query .= " and a.dst = '$ramal'\n";
|
|
|
|
|
if ($agente)
|
|
|
|
|
$query .= " and c.matricula = '$agente'\n";
|
|
|
|
|
if ($status)
|
|
|
|
|
$query .= " and a.disposition = '$status'\n";
|
|
|
|
|
if ($dac)
|
|
|
|
|
$query .= " and e.id = '$dac' \n";
|
|
|
|
|
|
|
|
|
|
$query .= "union all
|
|
|
|
|
select d.fila, a.calldate, a.src, (select q.destino from pbx_bilhetes_complemento q where q.uniqueid2 = a.uniqueid order by data_registro desc limit 1)as dst, c.apelido, d.param4::bigint as billsec, a.duration,
|
|
|
|
|
case when(a.disposition = 'ANSWERED' or d.param4 > '0')then 'ATENDIDA' else 'ABANDONADA' end as status
|
|
|
|
|
from pbx_bilhetes a,pbx_usuarios c, pbx_eventos_dacs d, pbx_dacs e
|
|
|
|
|
where c.matricula = substring(d.agente, 7, 4)
|
|
|
|
|
and d.uid2 = a.uniqueid
|
|
|
|
|
and e.nome = d.fila
|
|
|
|
|
and d.param4 <> ''
|
|
|
|
|
and d.evento in('TRANSFER','TRANSFERORIG')
|
|
|
|
|
and a.lastapp <> 'Transferred Call'
|
|
|
|
|
and a.data_bilhete < '$dataCorte'
|
|
|
|
|
and a.data_bilhete >= '$dataInicial'
|
|
|
|
|
and a.data_bilhete <= '$dataFinal' \n";
|
|
|
|
|
|
|
|
|
|
if ($dt)
|
|
|
|
|
$query .= " and date_trunc('minute', a.calldate) >= '$dt'\n";
|
|
|
|
|
if ($dtFim)
|
|
|
|
|
$query .= " and date_trunc('minute', a.calldate) <= '$dtFim'\n";
|
|
|
|
|
if ($ramal)
|
|
|
|
|
$query .= " and a.dst = '$ramal'\n";
|
|
|
|
|
if ($agente)
|
|
|
|
|
$query .= " and c.matricula = '$agente'\n";
|
|
|
|
|
if ($status)
|
|
|
|
|
$query .= " and a.disposition = '$status'\n";
|
|
|
|
|
if ($dac)
|
|
|
|
|
$query .= " and e.id = '$dac' ";
|
|
|
|
|
|
|
|
|
|
$query .= ")as transferencia
|
|
|
|
|
order by 2 \n";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//if(IsAdmin()) echo $query;
|
|
|
|
|
return $query;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function HoraZero($h) {
|
|
|
|
|
$hora = split(":", $h);
|
|
|
|
|
if (((int) $hora[0] == true) || ((int) $hora[1] == true))
|
|
|
|
|
return false;
|
|
|
|
|
else
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function GetStatus($st) {
|
|
|
|
|
$status = "<select name=\"lstStatus\" id=\"lstStatus\">";
|
|
|
|
|
$status .= str_replace("{SEL}", (!$st ? "selected" : ""), "<option value=\"\" {SEL}>Todos</option>");
|
|
|
|
|
$status .= str_replace("{SEL}", ($st == "ANSWERED" ? "selected" : ""), "<option value=\"ANSWERED\" {SEL}>ATENDIDA</option>");
|
|
|
|
|
$status .= str_replace("{SEL}", ($st == "BUSY" ? "selected" : ""), "<option value=\"BUSY\" {SEL}>OCUPADO</option>");
|
|
|
|
|
$status .= str_replace("{SEL}", ($st == "ENQUIRY" ? "selected" : ""), "<option value=\"ENQUIRY\" {SEL}>CONSULTA</option>");
|
|
|
|
|
$status .= str_replace("{SEL}", ($st == "NO ANSWER" ? "selected" : ""), "<option value=\"NO ANSWER\" {SEL}>ABANDONADA</option>");
|
|
|
|
|
$status .= "</select>";
|
|
|
|
|
|
|
|
|
|
return $status;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
?>
|
|
|
|
|
|