|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
// *************************************************************************
|
|
|
|
|
// *
|
|
|
|
|
// * URA Desempenho
|
|
|
|
|
// * Autor
|
|
|
|
|
// * Lucas Awade
|
|
|
|
|
// *
|
|
|
|
|
// *************************************************************************
|
|
|
|
|
/*
|
|
|
|
|
Defini<EFBFBD><EFBFBD>es do Projeto
|
|
|
|
|
Nome: RelUraDesempenho
|
|
|
|
|
Data in<EFBFBD>cio: 13/09/2018
|
|
|
|
|
Equipe: Amarildo Pereira
|
|
|
|
|
Descri<EFBFBD><EFBFBD>o:
|
|
|
|
|
Este relat<EFBFBD>rio tem a finalidade de apresenta um fluxo de URA para que tenha
|
|
|
|
|
o acompanhamento de cada se<EFBFBD><EFBFBD>o e sele<EFBFBD><EFBFBD>o da URA. Para isso foi composto uma
|
|
|
|
|
tela auxiliar para examinar cada chamada de URA realizada durante um periodo
|
|
|
|
|
entre datas.
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
// *************************************************************************
|
|
|
|
|
// * Copyright (c) 2018, Simples IP *
|
|
|
|
|
// *************************************************************************
|
|
|
|
|
|
|
|
|
|
include_once 'util/relatoriosBase.php';
|
|
|
|
|
|
|
|
|
|
class RelUraDesempenho extends Relatorios {
|
|
|
|
|
|
|
|
|
|
private $___ura;
|
|
|
|
|
|
|
|
|
|
public function __construct($idProg, $dbcon, $incDac) {
|
|
|
|
|
parent::__construct($idProg, $dbcon, $incDac);
|
|
|
|
|
$this->___ura = isset($_POST["listaUra"]) ? $_POST["listaUra"] : '';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function ___FiltrosRelatorio() {
|
|
|
|
|
$ura = $this->___GetURA();
|
|
|
|
|
if ($this->___media != MEDIA_PRINT_GRID) {
|
|
|
|
|
/*
|
|
|
|
|
* Recupera os filtros da sessao do usuario.
|
|
|
|
|
*/
|
|
|
|
|
list($this->___dataIni, $this->___dataFim) = $_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();
|
|
|
|
|
$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 ($_POST['btConsulta']) {
|
|
|
|
|
$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 op<EFBFBD><EFBFBD>es 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>Ura </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 .= "<td>$ura</td>";
|
|
|
|
|
$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?ios para impress<EFBFBD>o.
|
|
|
|
|
*/
|
|
|
|
|
$_SESSION["SSstorageFiltros"] = array($this->___dataIni, $this->___dataFim);
|
|
|
|
|
|
|
|
|
|
return sprintf($filtro, $this->___dataIni, $this->___dataFim, $lkPrint);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function ___GetDadosDb() {
|
|
|
|
|
$dataIni = FormatDtMssql($this->___dataIni);
|
|
|
|
|
$dataFim = FormatDtMssql($this->___dataFim);
|
|
|
|
|
|
|
|
|
|
$query = "SELECT umv_ura_nome, count(umv_ura_opcao) AS qtd_opcao, umv_ura_opcao, umv_opcao, nome_comando, umv_ura_id
|
|
|
|
|
FROM pbx_ura_movimento a
|
|
|
|
|
INNER JOIN pbx_ura_destino b ON a.umv_ura_id = b.id_ura AND umv_ura_opcao = numero
|
|
|
|
|
WHERE umv_data >= '$dataIni' AND umv_data <= '$dataFim'
|
|
|
|
|
AND umv_ura_opcao IS NOT NULL ";
|
|
|
|
|
$query .= $this->___ura ? "AND id_ura = $this->___ura " : "";
|
|
|
|
|
$query .= " GROUP BY 1,3,4,5,6 ";
|
|
|
|
|
|
|
|
|
|
$query .= "UNION
|
|
|
|
|
SELECT umv_ura_nome, SUM(CASE WHEN((SELECT COUNT(umv_tipo) FROM pbx_ura_movimento bx WHERE bx.uniqueid = ax.uniqueid AND umv_tipo IN ('seq', 'opc')) = 0) THEN 1 ELSE 0 END) AS qtd_opcao,
|
|
|
|
|
'NULO' AS umv_ura_opcao, 'desligou' AS umv_opcao, 'FINALIZOU NA URA' AS nome_comando, umv_ura_id
|
|
|
|
|
FROM pbx_ura_movimento ax
|
|
|
|
|
WHERE NOT EXISTS (SELECT umv_tipo FROM pbx_ura_movimento bx WHERE bx.uniqueid = ax.uniqueid AND umv_tipo IN ('seq', 'opc'))
|
|
|
|
|
AND umv_data >= '$dataIni' AND umv_data <= '$dataFim' ";
|
|
|
|
|
$query .= $this->___ura ? "AND umv_ura_id = $this->___ura " : "";
|
|
|
|
|
$query .= "GROUP BY 1,3,4,5,6 ";
|
|
|
|
|
|
|
|
|
|
$query .= "UNION
|
|
|
|
|
SELECT umv_ura_nome, SUM(CASE WHEN(length(umv_ura_opcao) > 1)THEN 1 END) AS qtd_opcao, 'INTEGRACAO > ' || b.numero AS umv_ura_opcao, umv_opcao, nome_comando, umv_ura_id
|
|
|
|
|
FROM pbx_ura_movimento a
|
|
|
|
|
INNER JOIN pbx_ura_destino b ON b.id_ura = a.umv_ura_id AND tipo = umv_opcao
|
|
|
|
|
WHERE umv_data >= '$dataIni' AND umv_data <= '$dataFim'
|
|
|
|
|
AND tipo = 'integativa'
|
|
|
|
|
AND numero = '_X.' ";
|
|
|
|
|
$query .= $this->___ura ? "AND id_ura = $this->___ura " : "";
|
|
|
|
|
$query .= "GROUP BY 1,3,4,5,6";
|
|
|
|
|
|
|
|
|
|
$query .= "UNION
|
|
|
|
|
SELECT distinct umv_ura_nome,(select count(*) from pbx_ura_movimento bx WHERE umv_data >= '$dataIni' AND umv_data <= '$dataFim' AND bx.umv_ura_opcao IS NOT NULL and bx.umv_ura_id = a.id_ura AND bx.umv_ura_opcao = a.numero) AS qtd_opcao,
|
|
|
|
|
numero,tipo,nome_comando,umv_ura_id
|
|
|
|
|
FROM pbx_ura_destino a
|
|
|
|
|
inner join pbx_ura_movimento b on b.umv_ura_id = a.id_ura
|
|
|
|
|
WHERE umv_data >= '$dataIni'
|
|
|
|
|
AND umv_data <= '$dataFim'
|
|
|
|
|
AND (select count(*) from pbx_ura_movimento bx WHERE umv_data >= '$dataIni' AND umv_data <= '$dataFim' AND bx.umv_ura_opcao IS NOT NULL and bx.umv_ura_id = a.id_ura AND bx.umv_ura_opcao = a.numero) = 0
|
|
|
|
|
AND umv_opcao is not null
|
|
|
|
|
AND numero <> '_X.' ";
|
|
|
|
|
$query .= $this->___ura ? "AND id_ura = $this->___ura " : "";
|
|
|
|
|
$query .= "ORDER BY umv_ura_nome,umv_ura_opcao, umv_ura_id";
|
|
|
|
|
|
|
|
|
|
//if(IsAdmin()){echo $query;}
|
|
|
|
|
$result = $this->___GetQuery($query);
|
|
|
|
|
$row = pg_fetch_all($result);
|
|
|
|
|
$this->SetData($row ? $row : array());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function ___PreparaCsv() {
|
|
|
|
|
$dataRel = array();
|
|
|
|
|
$filtro = $this->___FiltrosRelatorio();
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Inicia o relat<EFBFBD>rio.
|
|
|
|
|
*/
|
|
|
|
|
$dataRel[] = GenerateCsvFromArray($filtro);
|
|
|
|
|
|
|
|
|
|
$ultClass = '';
|
|
|
|
|
$somaReg = 0;
|
|
|
|
|
$dados = $this->GetData()[0];
|
|
|
|
|
$regUra = 0;
|
|
|
|
|
|
|
|
|
|
foreach ($dados as $row) {
|
|
|
|
|
$count++;
|
|
|
|
|
if ($count != 1) {
|
|
|
|
|
if ($ultClass != $row['umv_ura_nome']) {
|
|
|
|
|
$dataRel[] = GenerateCsvFromArray(array("Registros: ", $somaReg, 'Total: ', $regUra));
|
|
|
|
|
$dataRel[] = GenerateCsvFromArray(array('', ''));
|
|
|
|
|
unset($somaReg);
|
|
|
|
|
$dataRel[] = GenerateCsvFromArray(array('Nome', 'Opcao', 'Destino', 'Quantidade Selecao'));
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
unset($somaReg);
|
|
|
|
|
$dataRel[] = GenerateCsvFromArray(array('Nome', 'Opcao', 'Destino', 'Quantidade Selecao'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unset($regUra);
|
|
|
|
|
foreach ($dados as $reg) {
|
|
|
|
|
if ($reg['umv_ura_nome'] == $row['umv_ura_nome']) {
|
|
|
|
|
$regUra += $reg['qtd_opcao'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$somaReg++;
|
|
|
|
|
$row['umv_ura_nome'] = RemoveAcentos($row['umv_ura_nome']);
|
|
|
|
|
$row['umv_ura_opcao'] = RemoveAcentos($row['umv_ura_opcao']);
|
|
|
|
|
$row['umv_opcao'] = strtoupper($row['umv_opcao']) . ' > ' . strtoupper($row['nome_comando']);
|
|
|
|
|
$row['qtd_opcao'] = strtoupper($row['qtd_opcao']) . ' ' . $this->___GetPorcentagem($row['qtd_opcao'], $regUra);
|
|
|
|
|
|
|
|
|
|
// Formata linha de dados.
|
|
|
|
|
$dataRel[] = GenerateCsvFromArray(array($row['umv_ura_nome'], $row['umv_ura_opcao'], $row['umv_opcao'], $row['qtd_opcao']));
|
|
|
|
|
$ultClass = $row['umv_ura_nome'];
|
|
|
|
|
|
|
|
|
|
if (count($dados) == $count) {
|
|
|
|
|
$dataRel[] = GenerateCsvFromArray(array("Registros: ", $somaReg, 'Total: ', $regUra));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$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;
|
|
|
|
|
|
|
|
|
|
$dadosField = array('umv_ura_nome', 'umv_ura_opcao', 'umv_opcao', 'qtd_opcao');
|
|
|
|
|
|
|
|
|
|
$linha = array('LABEL');
|
|
|
|
|
foreach ($dadosCabecalio as $value) {
|
|
|
|
|
$linha[] = $value;
|
|
|
|
|
}
|
|
|
|
|
$dataRel[] = $linha;
|
|
|
|
|
|
|
|
|
|
$ultClass = '';
|
|
|
|
|
$somaReg = 0;
|
|
|
|
|
$regUra = 0;
|
|
|
|
|
$dados = $this->GetData()[0];
|
|
|
|
|
|
|
|
|
|
foreach ($dados as $row) {
|
|
|
|
|
$count++;
|
|
|
|
|
|
|
|
|
|
if ($count != 1) {
|
|
|
|
|
if ($ultClass != $row['umv_ura_nome']) {
|
|
|
|
|
$dataRel[] = array('LABEL', "Registros: ", 'Total: ', $somaReg);
|
|
|
|
|
$dataRel[] = array('LABEL', '', '');
|
|
|
|
|
unset($somaReg);
|
|
|
|
|
$dataRel[] = array('LABEL', 'Nome', 'Opcao', 'Destino', 'Quantidade Selecao');
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$dataRel[] = array('LABEL', 'Nome', 'Opcao', 'Destino', 'Quantidade Selecao');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unset($regUra);
|
|
|
|
|
foreach ($dados as $reg) {
|
|
|
|
|
if ($reg['umv_ura_nome'] == $row['umv_ura_nome']) {
|
|
|
|
|
$regUra += $reg['qtd_opcao'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$somaReg++;
|
|
|
|
|
|
|
|
|
|
$row['umv_ura_nome'] = RemoveAcentos($row['umv_ura_nome']);
|
|
|
|
|
$row['umv_ura_opcao'] = RemoveAcentos($row['umv_ura_opcao']);
|
|
|
|
|
$row['umv_opcao'] = strtoupper($row['umv_opcao']) . ' > ' . strtoupper($row['nome_comando']);
|
|
|
|
|
$row['qtd_opcao'] = strtoupper($row['qtd_opcao']) . ' ' . $this->___GetPorcentagem($row['qtd_opcao'], $regUra);
|
|
|
|
|
|
|
|
|
|
$linha = array('DADOS');
|
|
|
|
|
foreach ($dadosField as $key) {
|
|
|
|
|
$linha[] = $row["$key"];
|
|
|
|
|
}
|
|
|
|
|
$dataRel[] = $linha;
|
|
|
|
|
$ultClass = $row['umv_ura_nome'];
|
|
|
|
|
|
|
|
|
|
if (count($dados) == $count) {
|
|
|
|
|
$dataRel[] = array('LABEL', "Registros: ", $somaReg, 'Total: ', $somaReg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->___dataRel[] = $dataRel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function ___PreparaGrid() {
|
|
|
|
|
$dataRel = array();
|
|
|
|
|
|
|
|
|
|
$colspan = 4;
|
|
|
|
|
|
|
|
|
|
$dadosCabecalio = array(
|
|
|
|
|
'Nome' => 'align="center"',
|
|
|
|
|
'Op<EFBFBD><EFBFBD>o' => 'align="center"',
|
|
|
|
|
'Destino' => 'align="center"',
|
|
|
|
|
'Quantidade Sele<EFBFBD><EFBFBD>o' => 'align="center"'
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$dadosField = array(
|
|
|
|
|
'umv_ura_nome' => 'align="center"',
|
|
|
|
|
'umv_ura_opcao' => 'align="center"',
|
|
|
|
|
'umv_opcao' => 'align="center"',
|
|
|
|
|
'qtd_opcao' => 'align="center"'
|
|
|
|
|
);
|
|
|
|
|
/*
|
|
|
|
|
* Inicia o relat<EFBFBD>rio.
|
|
|
|
|
*/
|
|
|
|
|
$dataRel[] = '<table width="80%" cellpadding="2" class="grid">';
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Monta a linha de cabecalio.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
$dataRel[] = "<tr><th colspan='$colspan'>Relat<EFBFBD>rio URA</th></tr>";
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Verifica se retornou dados
|
|
|
|
|
*/
|
|
|
|
|
if (!IsPostBack() || !count($this->GetData()[0])) {
|
|
|
|
|
$dataRel[] = sprintf("<tr><td align=\"center\" colspan=\"%s\">%s</td></tr></table>", count($dadosCabecalio), (!IsPostBack() ? 'Informe os parametros e clique em consultar!' : 'Nenhum registro encontado!'));
|
|
|
|
|
$this->___dataRel[] = $dataRel;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$somaReg = 0;
|
|
|
|
|
$ultUra = "";
|
|
|
|
|
$count = 0;
|
|
|
|
|
$regUra = 0;
|
|
|
|
|
$dados = $this->GetData()[0];
|
|
|
|
|
/*
|
|
|
|
|
* Linhas de dados.
|
|
|
|
|
*/
|
|
|
|
|
foreach ($dados as $row) {
|
|
|
|
|
|
|
|
|
|
if ($ultUra != $row['umv_ura_nome']) {
|
|
|
|
|
if ($count > 0) {
|
|
|
|
|
$linha = "<tr><th align='left' colspan='3'>Registros: %s</th><th>Total: %s</th></tr>";
|
|
|
|
|
$dataRel[] = sprintf($linha, $somaReg, $regUra);
|
|
|
|
|
$dataRel[] = "<tr><td colspan='$colspan'> </td></tr>";
|
|
|
|
|
unset($somaReg);
|
|
|
|
|
unset($regUra);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach ($dados as $reg) {
|
|
|
|
|
if ($reg['umv_ura_nome'] == $row['umv_ura_nome']) {
|
|
|
|
|
$regUra += $reg['qtd_opcao'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$linha = "<tr><th colspan='$colspan'> URA {$row['umv_ura_nome']} </th></tr>";
|
|
|
|
|
$linha .= '<tr>';
|
|
|
|
|
foreach ($dadosCabecalio as $key => $value) {
|
|
|
|
|
$linha .= sprintf("<th %s>%s</th>", $value, $key);
|
|
|
|
|
}
|
|
|
|
|
$linha .= "</tr>";
|
|
|
|
|
$dataRel[] = $linha;
|
|
|
|
|
}
|
|
|
|
|
$count++;
|
|
|
|
|
$somaReg++;
|
|
|
|
|
$ultUra = $row['umv_ura_nome'];
|
|
|
|
|
|
|
|
|
|
// Formata linha de dados.
|
|
|
|
|
$link = $row['umv_ura_nome'] ? sprintf("<a style=\"color: #000;\" href=\"javaScript:NovaJanela('index.php?idProg=323&ura_opcao={$row['umv_ura_opcao']}&opcao=%s&dataIni=%s&dataFim=%s&ura_id={$row['umv_ura_id']}', 'uraGeral', '750', '450', 'resizable=NO,scrollbars=1');\">%s</a>", $row['umv_opcao'], $this->___dataIni, $this->___dataFim, strtoupper($row['qtd_opcao'])) : '--';
|
|
|
|
|
$linha = "<tr>";
|
|
|
|
|
$linha .= sprintf("<td aling=\"center\">%s</td>", $row['umv_ura_nome']);
|
|
|
|
|
$linha .= sprintf("<td align=\"center\">%s</td>", $row['umv_ura_opcao']);
|
|
|
|
|
$linha .= sprintf("<td align=\"center\">%s</td>", strtoupper($row['nome_comando']));
|
|
|
|
|
|
|
|
|
|
$opcoesUraLink = ["INTEGRACAO > _X.", "NULO"];
|
|
|
|
|
|
|
|
|
|
if (!in_array($row['umv_ura_opcao'], $opcoesUraLink) && $row['qtd_opcao'] > 0) {
|
|
|
|
|
$linha .= sprintf("<td align=\"center\">%s [ %s ]</td>", $link, $this->___GetPorcentagem($row['qtd_opcao'], $regUra));
|
|
|
|
|
} else {
|
|
|
|
|
$linha .= sprintf("<td align=\"center\">%s [ %s ]</td>", $row['qtd_opcao'] ? $row['qtd_opcao'] : "0", $this->___GetPorcentagem($row['qtd_opcao'], $regUra));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$linha .= "</tr>";
|
|
|
|
|
$dataRel[] = $linha;
|
|
|
|
|
|
|
|
|
|
if (count($dados) == $count) {
|
|
|
|
|
$linha = "<tr><th align='left' colspan='3'>Registros: %s </th><th>Total: %s</th></tr>";
|
|
|
|
|
$dataRel[] = sprintf($linha, $somaReg, $regUra);
|
|
|
|
|
unset($somaReg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Fecha relatorio.
|
|
|
|
|
*/
|
|
|
|
|
$dataRel[] = '</table>';
|
|
|
|
|
$this->___dataRel[] = $dataRel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function ___PreparaHtml() {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function ___PreparaPdf() {
|
|
|
|
|
list($this->___dataIni, $this->___dataFim) = $_SESSION["SSstorageFiltros"];
|
|
|
|
|
|
|
|
|
|
$dados = array();
|
|
|
|
|
$tables = array();
|
|
|
|
|
$header = null;
|
|
|
|
|
|
|
|
|
|
$x = 0;
|
|
|
|
|
$t = 0;
|
|
|
|
|
|
|
|
|
|
$ultUra = "";
|
|
|
|
|
$regUra = 0;
|
|
|
|
|
$somaReg = 0;
|
|
|
|
|
|
|
|
|
|
$dataHeader = array(
|
|
|
|
|
'umv_ura_nome' => 'C',
|
|
|
|
|
'umv_ura_opcao' => 'C',
|
|
|
|
|
'umv_opcao' => 'C',
|
|
|
|
|
'qtd_opcao' => 'C'
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$widthHeader = array(50, 20, 70, 35);
|
|
|
|
|
|
|
|
|
|
foreach ($this->GetData()[0] as $row) {
|
|
|
|
|
$count++;
|
|
|
|
|
|
|
|
|
|
if ($x) {
|
|
|
|
|
if ($ultUra != $row['umv_ura_nome']) {
|
|
|
|
|
$totalizador = array("Registros: $somaReg", '', '', 'Total: ' . $regUra);
|
|
|
|
|
${'table' . $t} = array($header, $dataHeader, $dados, $widthHeader, $totalizador, 0);
|
|
|
|
|
array_push($tables, ${"table" . $t});
|
|
|
|
|
$t++;
|
|
|
|
|
unset($somaReg);
|
|
|
|
|
unset($dados);
|
|
|
|
|
unset($regUra);
|
|
|
|
|
$x = 0;
|
|
|
|
|
$header = array('Nome' => 'C', 'Op<EFBFBD><EFBFBD>o' => 'C', 'Destino' => 'C', 'Quantidade Sele<EFBFBD><EFBFBD>o' => 'C');
|
|
|
|
|
foreach ($this->GetData()[0] as $reg) {
|
|
|
|
|
if ($reg['umv_ura_nome'] == $row['umv_ura_nome']) {
|
|
|
|
|
$regUra += $reg['qtd_opcao'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
foreach ($this->GetData()[0] as $reg) {
|
|
|
|
|
if ($reg['umv_ura_nome'] == $row['umv_ura_nome']) {
|
|
|
|
|
$regUra += $reg['qtd_opcao'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$header = array('Nome' => 'C', 'Op<EFBFBD><EFBFBD>o' => 'C', 'Destino' => 'C', 'Quantidade Sele<EFBFBD><EFBFBD>o' => 'C');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$somaReg++;
|
|
|
|
|
$ultUra = $row['umv_ura_nome'];
|
|
|
|
|
|
|
|
|
|
$dados[$x]["umv_ura_nome"] = $row["umv_ura_nome"];
|
|
|
|
|
$dados[$x]["umv_ura_opcao"] = $row['umv_ura_opcao'];
|
|
|
|
|
$dados[$x]["umv_opcao"] = strtoupper($row['umv_opcao']) . ' > ' . strtoupper($row['nome_comando']);
|
|
|
|
|
$dados[$x]["qtd_opcao"] = strtoupper($row['qtd_opcao']) . ' [ ' . $this->___GetPorcentagem($row['qtd_opcao'], $regUra) . ' ]';
|
|
|
|
|
$x++;
|
|
|
|
|
$z++;
|
|
|
|
|
|
|
|
|
|
if (count($this->GetData()[0]) == $count) {
|
|
|
|
|
$totalizador = array("Registros: $somaReg", '', '', 'Total: ' . $regUra);
|
|
|
|
|
${'table' . $t} = array($header, $dataHeader, $dados, $widthHeader, $totalizador, 0);
|
|
|
|
|
array_push($tables, ${"table" . $t});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->___dataRel = $tables;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function ___GetPorcentagem($parcial, $total) {
|
|
|
|
|
$result = ($parcial * 100) / $total;
|
|
|
|
|
return round($result, 2) . '%';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function ___GetURA() {
|
|
|
|
|
global $dbcon;
|
|
|
|
|
|
|
|
|
|
$query = sprintf("SELECT DISTINCT umv_ura_nome, umv_ura_id
|
|
|
|
|
FROM pbx_ura_movimento
|
|
|
|
|
WHERE umv_data >= '%s' AND umv_data <= '%s'
|
|
|
|
|
AND umv_ura_opcao IS NOT NULL
|
|
|
|
|
AND umv_tipo = 'opc'", FormatDtMssql($this->___dataIni), FormatDtMssql($this->___dataFim));
|
|
|
|
|
|
|
|
|
|
$resp = pg_query($dbcon, $query);
|
|
|
|
|
$result = pg_fetch_all($resp);
|
|
|
|
|
|
|
|
|
|
$row = "<select name=\"listaUra\">";
|
|
|
|
|
!$result ? $row .= "<option value=\"0\"> ----- </option>" : $row .= "<option value=\"0\">Todas</option>";
|
|
|
|
|
foreach ($result as $uraMov) {
|
|
|
|
|
$sel = $this->___ura == $uraMov['umv_ura_id'] ? "selected" : '';
|
|
|
|
|
if ($uraMov['umv_ura_nome']) {
|
|
|
|
|
$row .= sprintf("<option value=\"%s\" $sel>%s</option>", $uraMov['umv_ura_id'], $uraMov['umv_ura_nome']);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$row .= "</select>";
|
|
|
|
|
return $row;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$relUraGeral = new RelUraDesempenho($idProg, $dbcon, 0);
|
|
|
|
|
$relUraGeral->ExecutaRelatorio();
|
|
|
|
|
|