|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
include_once 'util/relatoriosBase.php';
|
|
|
|
|
$tpLayout = 1;
|
|
|
|
|
|
|
|
|
|
class RelAgtDetalhe extends Relatorios{
|
|
|
|
|
|
|
|
|
|
private $___matricula;
|
|
|
|
|
|
|
|
|
|
public function __construct($idProg, $dbcon, $incDac) {
|
|
|
|
|
parent::__construct($idProg, $dbcon, $incDac);
|
|
|
|
|
$this->___matricula = isset($_GET["mat"]) ? $_GET["mat"] : '';
|
|
|
|
|
$this->___dataIni = isset($_GET["dataIni"]) ? $_GET["dataIni"] : '';
|
|
|
|
|
$this->___dataFim = isset($_GET["dataFim"]) ? $_GET["dataFim"] : '';
|
|
|
|
|
$_POST['btConsulta'] = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function ___ValidaForm() {
|
|
|
|
|
|
|
|
|
|
if (!$_SESSION["SSstorageFiltros"]) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (empty($this->___matricula)) {
|
|
|
|
|
GeraExcept('Informe uma matricula v<EFBFBD>lida!');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function ___FiltrosRelatorio() {
|
|
|
|
|
|
|
|
|
|
if ($this->___media != MEDIA_PRINT_GRID) {
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Recupera os filtros da sess<EFBFBD>o do usu<EFBFBD>rio.
|
|
|
|
|
*/
|
|
|
|
|
list($this->___dataIni, $this->___dataFim, $this->___matricula, $this->___tipoRelatorio) = $_SESSION["SSstorageFiltros"];
|
|
|
|
|
|
|
|
|
|
$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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$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');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$_SESSION["SSstorageFiltros"] = array($this->___dataIni, $this->___dataFim, $this->___matricula, $this->___tipoRelatorio);
|
|
|
|
|
|
|
|
|
|
return sprintf($lkPrint);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function ___GetDadosDb() {
|
|
|
|
|
$dataIni = FormatDtMssql($this->___dataIni);
|
|
|
|
|
$dataFim = FormatDtMssql($this->___dataFim);
|
|
|
|
|
$matricula = $this->___matricula;
|
|
|
|
|
|
|
|
|
|
$query = "select a.calldate as data, c.apelido as agente, a.src as fone,
|
|
|
|
|
(select q.destino from pbx_bilhetes_complemento q where q.uniqueid2 = a.uniqueid order by data_registro desc limit 1)as dst,
|
|
|
|
|
d.fila, a.billsec as tempo,
|
|
|
|
|
case when(a.disposition = 'ANSWERED')then 'ATENDIDA' else 'ABANCONADA' end as status
|
|
|
|
|
from pbx_bilhetes a,pbx_usuarios c, pbx_eventos_dacs d
|
|
|
|
|
where c.matricula = substring(d.agente, 7, 4)
|
|
|
|
|
and d.uid2 = a.uniqueid
|
|
|
|
|
and d.evento in('COMPLETEAGENT','COMPLETECALLER','COMPLETAAGENT','COMPLETACALLER')
|
|
|
|
|
and a.lastapp <> 'Transferred Call'
|
|
|
|
|
and a.data_bilhete >= '$dataIni'
|
|
|
|
|
and a.data_bilhete <= '$dataFim'
|
|
|
|
|
and c.matricula = '$matricula'
|
|
|
|
|
and exists(select '' from pbx_bilhetes where data_bilhete = a.data_bilhete and accountcode = a.uniqueid)
|
|
|
|
|
order by a.calldate desc";
|
|
|
|
|
|
|
|
|
|
$result = $this->___GetQuery($query);
|
|
|
|
|
$row = pg_fetch_all($result);
|
|
|
|
|
$this->SetData($row ? $row : array());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function ___PreparaCsv() {
|
|
|
|
|
$dataRel = array();
|
|
|
|
|
$filtro = $this->___FiltrosRelatorio();
|
|
|
|
|
$dataRel[] = GenerateCsvFromArray($filtro);
|
|
|
|
|
|
|
|
|
|
$dadosCabecalio = array('Data','Agente','Fone','Destino','Fila','Duracao','Status');
|
|
|
|
|
$dadosField = array('data','agente','fone','dst','fila','tempo','status');
|
|
|
|
|
|
|
|
|
|
$dataRel[] = GenerateCsvFromArray($dadosCabecalio);
|
|
|
|
|
|
|
|
|
|
$somaReg = 0;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Linhas de dados.
|
|
|
|
|
*/
|
|
|
|
|
foreach ($this->GetData()[0] as $row) {
|
|
|
|
|
$somaReg ++;
|
|
|
|
|
$row['data'] = date('d/m/Y H:i:s', strtotime($row['data']));
|
|
|
|
|
$row['tempo'] = SecondToStrTime(round($row['tempo']));
|
|
|
|
|
|
|
|
|
|
$linha = array();
|
|
|
|
|
foreach ($dadosField as $key) {
|
|
|
|
|
$linha[] = $row["$key"];
|
|
|
|
|
}
|
|
|
|
|
$dataRel[] = GenerateCsvFromArray($linha);
|
|
|
|
|
}
|
|
|
|
|
$dataRel[] = GenerateCsvFromArray(array('Total:'. $somaReg));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$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('Data','Agente','Fone','Destino','Fila','Duracao','Status');
|
|
|
|
|
$dadosField = array('data','agente','fone','dst','fila','tempo','status');
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Monta a linha de cabecalio.
|
|
|
|
|
*/
|
|
|
|
|
$linha = array('LABEL');
|
|
|
|
|
foreach ($dadosCabecalio as $value) {
|
|
|
|
|
$linha[] = $value;
|
|
|
|
|
}
|
|
|
|
|
$dataRel[] = $linha;
|
|
|
|
|
|
|
|
|
|
$somaReg = 0;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Linhas de dados.
|
|
|
|
|
*/
|
|
|
|
|
foreach ($this->GetData()[0] as $row) {
|
|
|
|
|
$somaReg ++;
|
|
|
|
|
$row['data'] = date('d/m/Y H:i:s', strtotime($row['data']));
|
|
|
|
|
$row['tempo'] = SecondToStrTime(round($row['tempo']));
|
|
|
|
|
|
|
|
|
|
// Formata linha de dados.
|
|
|
|
|
$linha = array('DADOS');
|
|
|
|
|
foreach ($dadosField as $key) {
|
|
|
|
|
$linha[] = $row["$key"];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$dataRel[] = $linha;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$dataRel[] = array('LABEL', 'Total: '. $somaReg);
|
|
|
|
|
|
|
|
|
|
$this->___dataRel[] = $dataRel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function ___PreparaGrid() {
|
|
|
|
|
$dataRel = array();
|
|
|
|
|
|
|
|
|
|
$dadosCabecalio = array(
|
|
|
|
|
'Data' => 'align="center"',
|
|
|
|
|
'Agente' => 'align="center"',
|
|
|
|
|
'Fone' => 'align="center"',
|
|
|
|
|
'Destino' => 'align="center"',
|
|
|
|
|
'Fila' => 'align="center"',
|
|
|
|
|
'Dura<EFBFBD><EFBFBD>o' => 'align="center"',
|
|
|
|
|
'Status' => 'align="center"'
|
|
|
|
|
);
|
|
|
|
|
$dadosField = array(
|
|
|
|
|
'data' => 'align="center"',
|
|
|
|
|
'agente' => 'align="center"',
|
|
|
|
|
'fone' => 'align="center"',
|
|
|
|
|
'dst' => 'align="center"',
|
|
|
|
|
'fila' => 'align="center"',
|
|
|
|
|
'tempo' => 'align="center"',
|
|
|
|
|
'status' => 'align="center"'
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Inicia o relat<EFBFBD>rio.
|
|
|
|
|
*/
|
|
|
|
|
$dataRel[] = '<table align="center"><tr><td><img src="imgSite/agenda.png" width="32" height="32"/>Transfer<EFBFBD>ncia</td></tr></table>';
|
|
|
|
|
$dataRel[] = '<table width="100%" cellpadding="2" class="grid">';
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* 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;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Linhas de dados.
|
|
|
|
|
*/
|
|
|
|
|
foreach ($this->GetData()[0] as $row) {
|
|
|
|
|
|
|
|
|
|
$somaReg ++;
|
|
|
|
|
$row['data'] = date('d/m/Y H:i:s', strtotime($row['data']));
|
|
|
|
|
$row['tempo'] = SecondToStrTime(round($row['tempo']));
|
|
|
|
|
$row['fone'] = ocultarTelefone($row['fone']);
|
|
|
|
|
$row['dst'] = ocultarTelefone($row['dst']);
|
|
|
|
|
|
|
|
|
|
$linha = "<tr>";
|
|
|
|
|
foreach ($dadosField as $key => $value) {
|
|
|
|
|
$linha .= sprintf("<td %s>%s</td>", $value, $row["$key"]);
|
|
|
|
|
}
|
|
|
|
|
$linha .= "</tr>";
|
|
|
|
|
$dataRel[] = $linha;
|
|
|
|
|
}
|
|
|
|
|
$dataRel[] = "<tr><th colspan='7' align='center'>Total: $somaReg</th></tr>";
|
|
|
|
|
$dataRel[] = "</table>";
|
|
|
|
|
|
|
|
|
|
$this->___dataRel[] = $dataRel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function ___PreparaHtml() {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function ___PreparaPdf() {
|
|
|
|
|
list($this->___dataIni, $this->___dataFim, $this->___matricula, $this->___tipoRelatorio) = $_SESSION["SSstorageFiltros"];
|
|
|
|
|
|
|
|
|
|
$dadosCabecalio = array(
|
|
|
|
|
'Data' => 'C',
|
|
|
|
|
'Agente' => 'C',
|
|
|
|
|
'Fone' => 'C',
|
|
|
|
|
'Destino' => 'C',
|
|
|
|
|
'Fila' => 'C',
|
|
|
|
|
'Dura<EFBFBD><EFBFBD>o' => 'C',
|
|
|
|
|
'Status' => 'C'
|
|
|
|
|
);
|
|
|
|
|
$dadosField = array(
|
|
|
|
|
'data' => 'C',
|
|
|
|
|
'agente' => 'C',
|
|
|
|
|
'fone' => 'C',
|
|
|
|
|
'dst' => 'C',
|
|
|
|
|
'fila' => 'C',
|
|
|
|
|
'tempo' => 'C',
|
|
|
|
|
'status' => 'C'
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$somaReg = 0;
|
|
|
|
|
$x = 0;
|
|
|
|
|
$dados = $this->GetData()[0];
|
|
|
|
|
/*
|
|
|
|
|
* Linhas de dados.
|
|
|
|
|
*/
|
|
|
|
|
foreach ($dados as $row) {
|
|
|
|
|
$somaReg ++;
|
|
|
|
|
$dados[$x]['data'] = date('d/m/Y H:i:s', strtotime($row['data']));
|
|
|
|
|
$dados[$x]['tempo'] = SecondToStrTime(round($row['tempo']));
|
|
|
|
|
$x++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$widthHeader = array(28, 28, 28, 28, 28, 26, 26);
|
|
|
|
|
$totaliza = array("Total: ".$somaReg,'','','','','','');
|
|
|
|
|
$table = array($dadosCabecalio, $dadosField, $dados, $widthHeader, $totaliza, 0);
|
|
|
|
|
|
|
|
|
|
$this->___dataRel = array($table);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function ExecutaRelatorio() {
|
|
|
|
|
global $jsStartup, $jsJQuery, $smarty;
|
|
|
|
|
try {
|
|
|
|
|
$this->___FiltrosRelatorio();
|
|
|
|
|
/*
|
|
|
|
|
* 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');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$relTransferAgenteDet = new RelAgtDetalhe($idProg, $dbcon, 0);
|
|
|
|
|
$relTransferAgenteDet->ExecutaRelatorio();
|
|
|
|
|
|
|
|
|
|
?>
|