[5307] | 1 | <?php |
---|
| 2 | /** |
---|
| 3 | * Listagem |
---|
| 4 | * |
---|
| 5 | * Implementaçao de Listagens padroes do sistema. |
---|
| 6 | */ |
---|
| 7 | /** |
---|
| 8 | * Listagem |
---|
| 9 | * |
---|
| 10 | * Implementaçao de Listagens padroes do sistema. |
---|
| 11 | * |
---|
| 12 | * |
---|
| 13 | * @author Jair Pereira <pereira.jair@gmail.com> |
---|
| 14 | * @since 01/06/2009 |
---|
| 15 | * |
---|
| 16 | * @package Listagem |
---|
| 17 | */ |
---|
| 18 | |
---|
| 19 | include_once("ListagemColuna.class.php"); |
---|
| 20 | include_once("ListagemIndicador.class.php"); |
---|
| 21 | include_once("SqlParser.class.php"); |
---|
| 22 | |
---|
| 23 | class Listagem { |
---|
[6413] | 24 | |
---|
[5307] | 25 | /** |
---|
| 26 | * Identificador da Listagem. |
---|
| 27 | */ |
---|
| 28 | private $idlistagem; |
---|
[6413] | 29 | |
---|
[5307] | 30 | /** |
---|
| 31 | * Tï¿œtulo da Listagem |
---|
| 32 | */ |
---|
| 33 | private $titulo; |
---|
[6413] | 34 | |
---|
[5307] | 35 | /** |
---|
| 36 | * Array de Colunas. |
---|
| 37 | */ |
---|
| 38 | private $colunas = array(); |
---|
[6413] | 39 | |
---|
[5307] | 40 | /** |
---|
| 41 | * Array de Linhas de Detalhamento. |
---|
| 42 | */ |
---|
| 43 | private $linhasdetalhamento = array(); |
---|
[6413] | 44 | |
---|
[5307] | 45 | /** |
---|
| 46 | * Array de Linhas Agrupadas |
---|
| 47 | */ |
---|
| 48 | private $linhasagrupamento = array(); |
---|
[6413] | 49 | |
---|
[5307] | 50 | /** |
---|
| 51 | * Array de Dados. |
---|
| 52 | */ |
---|
| 53 | private $dados = array(); |
---|
[6413] | 54 | |
---|
[5307] | 55 | /** |
---|
| 56 | * Exibe Header das Tables. (Tï¿œtulos das Colunas). |
---|
| 57 | */ |
---|
| 58 | private $showthead = true; |
---|
[6413] | 59 | |
---|
[5307] | 60 | /** |
---|
| 61 | * Array de Totalizadores. |
---|
| 62 | */ |
---|
| 63 | private $totalizadores = array(); |
---|
[6413] | 64 | |
---|
[5307] | 65 | /** |
---|
| 66 | * Alterado para Protegido nᅵo serᅵ instanciado na classe. |
---|
| 67 | */ |
---|
| 68 | //protected $form = Formulario; |
---|
[6413] | 69 | |
---|
[5307] | 70 | /** |
---|
| 71 | * Formulï¿œrio de Pesquisa. |
---|
| 72 | */ |
---|
| 73 | //protected $formpesquisa = Formulario; |
---|
[6413] | 74 | |
---|
[5307] | 75 | /** |
---|
| 76 | * Agrupar Resultados Alfabeticamente (True ou False) |
---|
| 77 | */ |
---|
| 78 | private $agruparAlfabeticamente = false; |
---|
| 79 | |
---|
| 80 | /** |
---|
| 81 | * Array de Indicadores |
---|
| 82 | */ |
---|
| 83 | private $arrindicadores = array(); |
---|
[6413] | 84 | |
---|
[5307] | 85 | /** |
---|
| 86 | * Array de Parï¿œmetros |
---|
| 87 | */ |
---|
| 88 | private $arrparametros = array(); |
---|
[6413] | 89 | |
---|
[5307] | 90 | /** |
---|
| 91 | * Array de Agrupamentos |
---|
| 92 | */ |
---|
| 93 | private $arragrupamentos = array(); |
---|
[6413] | 94 | |
---|
[5307] | 95 | /** |
---|
| 96 | * SubListagem. |
---|
| 97 | */ |
---|
| 98 | public $subListagem; |
---|
[6413] | 99 | |
---|
[5307] | 100 | /** |
---|
| 101 | * Indica se este objeto ᅵ uma SubListagem. |
---|
| 102 | */ |
---|
| 103 | private $issublist = false; |
---|
[6413] | 104 | |
---|
[5307] | 105 | /** |
---|
| 106 | * Conexao com o Banco de Dados. |
---|
| 107 | */ |
---|
| 108 | private $conexao; |
---|
[6413] | 109 | |
---|
[5307] | 110 | /** |
---|
| 111 | * SQL da Listagem. |
---|
| 112 | */ |
---|
| 113 | private $sql; |
---|
[6413] | 114 | |
---|
[5307] | 115 | /** |
---|
| 116 | * Exibir SubTotalizadores |
---|
| 117 | */ |
---|
| 118 | private $exibesubtotais = false; |
---|
[6413] | 119 | |
---|
[5307] | 120 | private $exibedivcolunas = true; |
---|
[6413] | 121 | |
---|
[5307] | 122 | /** |
---|
| 123 | * Exibir Totalizadores |
---|
| 124 | */ |
---|
| 125 | private $_exibetotalizadores = true; |
---|
[6413] | 126 | |
---|
[5307] | 127 | /** |
---|
| 128 | * Exibir Quantidade de Registros Encontrados |
---|
| 129 | */ |
---|
| 130 | private $_exibeqtdregistros = true; |
---|
[6413] | 131 | |
---|
[5307] | 132 | /** |
---|
| 133 | * Modo DEBUG |
---|
| 134 | */ |
---|
| 135 | private $_debug = true; |
---|
[6413] | 136 | |
---|
[5307] | 137 | /** |
---|
| 138 | * Array de Erros |
---|
| 139 | */ |
---|
| 140 | private $_errors = array(); |
---|
[6413] | 141 | |
---|
[5307] | 142 | /** |
---|
| 143 | * Indica se a Listagem Possui algum checkbox |
---|
| 144 | */ |
---|
| 145 | private $temcheck = false; |
---|
[6413] | 146 | |
---|
[5307] | 147 | /** |
---|
[6413] | 148 | * Repetir Tï¿œtulo do Agrupamento. |
---|
[5307] | 149 | */ |
---|
| 150 | private $_repetirtituloagrupamento = true; |
---|
[6413] | 151 | |
---|
[5307] | 152 | /** |
---|
| 153 | * Quantidade de Registros da Listagem Principal (Usada somente quando a listagem ᅵ uma sublistagem.) |
---|
| 154 | */ |
---|
| 155 | private $_qtdregistroslistagemprincipal = 0; |
---|
[6413] | 156 | |
---|
[5307] | 157 | /** |
---|
| 158 | * Gerar Arquivo CSV. |
---|
| 159 | */ |
---|
| 160 | private $_temarquivocsv = false; |
---|
[6413] | 161 | |
---|
| 162 | |
---|
[5307] | 163 | /** |
---|
| 164 | * Exibir Resultados na tela. (Usado quando somente serᅵ exibido os resultados em CSV). |
---|
| 165 | */ |
---|
| 166 | private $_exiberesultados = true; |
---|
[6413] | 167 | |
---|
[5307] | 168 | /** |
---|
| 169 | * Gerar Automaticamente Arquivo CSV. |
---|
| 170 | */ |
---|
| 171 | private $_exibearquivocsv = false; |
---|
[6413] | 172 | |
---|
[5307] | 173 | /** |
---|
| 174 | * Colunas Arquivo CSV. |
---|
| 175 | */ |
---|
| 176 | private $_colunasarquivo = array(); |
---|
[6413] | 177 | |
---|
[5307] | 178 | /** |
---|
| 179 | * Texto do Arquivo CSV. |
---|
| 180 | */ |
---|
| 181 | private $_txtarquivocsv = ""; |
---|
[6413] | 182 | |
---|
| 183 | |
---|
[5307] | 184 | /** |
---|
| 185 | * Array de Totalizadores. |
---|
| 186 | */ |
---|
| 187 | private $arrtotais = array(); |
---|
[6413] | 188 | |
---|
[5307] | 189 | /** |
---|
| 190 | * Array de SubTotalizadores |
---|
| 191 | */ |
---|
| 192 | private $arrsubtotais = array(); |
---|
[6413] | 193 | |
---|
| 194 | |
---|
[5307] | 195 | /** |
---|
| 196 | * Mesagem: Nenhum Resultado Encontrado. |
---|
| 197 | */ |
---|
| 198 | public $msgnenhumresultado = "Nenhum resultado encontrado."; |
---|
[6413] | 199 | |
---|
[5307] | 200 | /** |
---|
| 201 | * Mensagem: registro(s) encontrado(s) |
---|
| 202 | */ |
---|
| 203 | public $msgregistros = "registro(s) encontrado(s)."; |
---|
[6413] | 204 | |
---|
[5307] | 205 | /** |
---|
| 206 | * Mensagem: TOTAL: |
---|
| 207 | */ |
---|
| 208 | public $msgtotalizador = "TOTAL:"; |
---|
[6413] | 209 | |
---|
[5307] | 210 | /** |
---|
| 211 | * Mensagem: SUB-TOTAL; |
---|
| 212 | */ |
---|
| 213 | public $msgsubtotalizador = "SUB-TOTAL:"; |
---|
[6413] | 214 | |
---|
[5307] | 215 | private $_mostraLegendaTopo = true; |
---|
[6413] | 216 | |
---|
[5307] | 217 | private $_mostraLegendaRodape = false; |
---|
[6413] | 218 | |
---|
[5307] | 219 | private $_exibelinhasvazias = true; |
---|
[6413] | 220 | |
---|
[5307] | 221 | private $_colunascsv; |
---|
[6413] | 222 | |
---|
[5307] | 223 | private $_isarray = false; |
---|
[6413] | 224 | |
---|
[5307] | 225 | private $_totalizadorprecisao = 2; |
---|
[6413] | 226 | |
---|
[5307] | 227 | /* |
---|
| 228 | * ID da Listagem. que foi carregado. |
---|
| 229 | */ |
---|
| 230 | private $_lstoid = ""; |
---|
[6413] | 231 | |
---|
[5307] | 232 | private $_url_base_path; |
---|
[6413] | 233 | |
---|
[5307] | 234 | private $_tmp_file_path = "/tmp/"; |
---|
[6413] | 235 | |
---|
| 236 | |
---|
[5307] | 237 | /** |
---|
| 238 | * Construᅵᅵo da Classe. |
---|
[6413] | 239 | * |
---|
[5307] | 240 | * @idlistagem Identificador da Listagem. |
---|
| 241 | * @titulo Tï¿œtulo da Listagem. |
---|
| 242 | * @conexao Conexï¿œo com o Banco de Dados. |
---|
| 243 | * @subListagem Indica se a Listagem ᅵ uma SubListagem. (default: false) |
---|
| 244 | */ |
---|
| 245 | public function __construct($idlistagem,$titulo,$conexao,$subListagem = false) { |
---|
| 246 | $this->setTitulo($titulo); |
---|
| 247 | $this->setIdListagem($idlistagem); |
---|
| 248 | if (!$subListagem) { |
---|
| 249 | $novoidlistagem = $idlistagem . "_sublist"; |
---|
| 250 | $this->subListagem = new Listagem($novoidlistagem,"",$conexao,true); |
---|
| 251 | $this->subListagem->setMostrarQuantidadeRegistros(false); |
---|
[6413] | 252 | $this->subListagem->setIdListagem($novoidlistagem); |
---|
[5307] | 253 | } |
---|
| 254 | $this->setSubListagem($subListagem); |
---|
| 255 | $this->setConexao($conexao); |
---|
| 256 | } |
---|
[6413] | 257 | |
---|
[5307] | 258 | /** |
---|
| 259 | * Indica se a Listagem ᅵ uma SubListagem. |
---|
[6413] | 260 | * |
---|
[5307] | 261 | * @param $value (true,false) |
---|
| 262 | */ |
---|
| 263 | protected function setSubListagem($value) { |
---|
| 264 | $this->issublist = $value; |
---|
| 265 | } |
---|
[6413] | 266 | |
---|
[5307] | 267 | public function setTotalizadorPrecisao($value) { |
---|
| 268 | $this->_totalizadorprecisao = $value; |
---|
| 269 | } |
---|
[6413] | 270 | |
---|
[5307] | 271 | /** |
---|
| 272 | * Identificador da Listagem. |
---|
[6413] | 273 | * |
---|
[5307] | 274 | * @param $value (true,false) |
---|
| 275 | */ |
---|
| 276 | public function setIdListagem($value) { |
---|
| 277 | $this->idlistagem = $value; |
---|
| 278 | } |
---|
[6413] | 279 | |
---|
[5307] | 280 | public function setExibirOpcoesDeColunas($value) { |
---|
| 281 | $this->exibedivcolunas = $value; |
---|
| 282 | } |
---|
[6413] | 283 | |
---|
[5307] | 284 | /** |
---|
| 285 | * Retorna o Identificador da Listagem. |
---|
| 286 | */ |
---|
| 287 | public function getIdListagem() { |
---|
| 288 | return $this->idlistagem; |
---|
| 289 | } |
---|
[6413] | 290 | |
---|
[5307] | 291 | public function setUrlBasePath($base_path) { |
---|
| 292 | $this->_url_base_path = $base_path; |
---|
| 293 | } |
---|
| 294 | |
---|
| 295 | /** |
---|
| 296 | * Funᅵᅵo Interna para Alterar a Varᅵavel de Conexᅵo com o Banco de Dados. |
---|
[6413] | 297 | * |
---|
[5307] | 298 | * @param $conexao |
---|
| 299 | * @return unknown_type |
---|
| 300 | */ |
---|
| 301 | protected function setConexao($conexao) { $this->conexao = $conexao; } |
---|
[6413] | 302 | |
---|
[5307] | 303 | /** |
---|
| 304 | * Funᅵᅵo Interna para Alterar O SQL que serᅵ executado na listagem. |
---|
[6413] | 305 | * |
---|
[5307] | 306 | * @param $sql |
---|
| 307 | * @return unknown_type |
---|
| 308 | */ |
---|
| 309 | protected function setSQL($sql) { $this->sql = $sql; } |
---|
[6413] | 310 | |
---|
[5307] | 311 | /** |
---|
| 312 | * Funᅵᅵo Interna para Recuperar o SQL que serᅵ executado na listagem. |
---|
[6413] | 313 | * |
---|
[5307] | 314 | * @return unknown_type |
---|
| 315 | */ |
---|
| 316 | public function getSQL() { return $this->sql; } |
---|
[6413] | 317 | |
---|
[5307] | 318 | /** |
---|
| 319 | * Funᅵᅵo para Alterar o Tᅵtulo da Listagem. |
---|
[6413] | 320 | * |
---|
[5307] | 321 | * @param $titulo |
---|
| 322 | * @return unknown_type |
---|
| 323 | */ |
---|
| 324 | public function setTitulo($titulo) { $this->titulo = $titulo; } |
---|
[6413] | 325 | |
---|
[5307] | 326 | /** |
---|
| 327 | * Funᅵᅵo para Alterar a forma de Exibiᅵᅵo da Listagem |
---|
[6413] | 328 | * |
---|
[5307] | 329 | * @param $exiberesultados |
---|
| 330 | * @return unknown_type |
---|
| 331 | */ |
---|
| 332 | public function setExibirResultadosTela($exiberesultados) { $this->_exiberesultados = $exiberesultados; } |
---|
[6413] | 333 | |
---|
[5307] | 334 | /** |
---|
| 335 | * Funᅵᅵo para Alterar a exibiᅵᅵo de linhas que nᅵo exibem nenhum resultado, (linhas vazias) |
---|
[6413] | 336 | * |
---|
[5307] | 337 | * @param $exiberesultados |
---|
| 338 | * @return unknown_type |
---|
| 339 | */ |
---|
| 340 | public function setExibirLinhasVazias($valor) { $this->_exibelinhasvazias = $valor; } |
---|
| 341 | |
---|
| 342 | /** |
---|
| 343 | * Funᅵᅵo para Alterar o Resultado da SQL executada. |
---|
[6413] | 344 | * |
---|
[5307] | 345 | * @param $dados |
---|
| 346 | * @return unknown_type |
---|
| 347 | */ |
---|
| 348 | public function setDados($dados) { |
---|
[6413] | 349 | $this->dados = &$dados; |
---|
[5307] | 350 | if (is_resource($this->dados)) { |
---|
| 351 | $this->_isarray = false; |
---|
| 352 | } else { |
---|
| 353 | $this->_isarray = true; |
---|
| 354 | } |
---|
| 355 | } |
---|
[6413] | 356 | |
---|
| 357 | |
---|
[5307] | 358 | /** |
---|
| 359 | * Funᅵᅵo utilizada para Executar o SQL e Carregar os dados a serem listados. |
---|
| 360 | * @param $sql |
---|
| 361 | * @return unknown_type |
---|
| 362 | */ |
---|
| 363 | public function carregar($sql) { |
---|
| 364 | $parser = new SqlParser($sql); |
---|
| 365 | $ret_parser = $parser->verificaSql(); |
---|
[6413] | 366 | |
---|
[5307] | 367 | if ($ret_parser === false) { |
---|
| 368 | $msg = $parser->getErro(); |
---|
| 369 | $this->adicionarErro($msg,true); |
---|
| 370 | } |
---|
[6413] | 371 | |
---|
[5307] | 372 | $ret_parser = $parser->verificaCondicoes(); |
---|
| 373 | if ($ret_parser === false) { |
---|
| 374 | $msg = $parser->getErro(); |
---|
| 375 | $this->adicionarErro($msg,true); |
---|
| 376 | } |
---|
| 377 | $sql = $parser->getSql(); |
---|
[6413] | 378 | |
---|
[5307] | 379 | try { |
---|
| 380 | $this->setSQL($sql); |
---|
| 381 | $res = pg_query($this->conexao,"begin;"); |
---|
| 382 | $resu = pg_query($this->conexao,$this->sql); |
---|
| 383 | $res = pg_query($this->conexao,"rollback;"); |
---|
| 384 | if (!$resu) { throw new Exception($this->sql); } |
---|
| 385 | $this->setDados($resu); |
---|
[6413] | 386 | |
---|
[5307] | 387 | return $resu; |
---|
[6413] | 388 | |
---|
[5307] | 389 | } catch (exception $e) { |
---|
| 390 | $msg = $e->getMessage(); |
---|
| 391 | $this->adicionarErro("Erro ao Executar a consulta: $msg",true); |
---|
| 392 | } |
---|
[6413] | 393 | |
---|
[5307] | 394 | } |
---|
[6413] | 395 | |
---|
[5307] | 396 | /** |
---|
| 397 | * Funᅵᅵo utilizada para Executar o SQL e Carregar os dados a serem listados. |
---|
| 398 | * @param $sql |
---|
| 399 | * @return unknown_type |
---|
| 400 | */ |
---|
| 401 | public function carregarIDListagem($idlistagem,$previsualizacao = false) { |
---|
| 402 | |
---|
[6413] | 403 | $sql = "select |
---|
[5307] | 404 | lstoid, |
---|
| 405 | lstversao, |
---|
| 406 | lstidlistagem, |
---|
| 407 | lstdescricao, |
---|
| 408 | lstnome, |
---|
| 409 | lsttitulo, |
---|
| 410 | lstsql, |
---|
| 411 | lstexibe_header, |
---|
| 412 | lstexibe_totalizadores, |
---|
| 413 | lstexibe_subtotais, |
---|
| 414 | lstexibe_qtdregistros, |
---|
| 415 | lstexibe_checkbox, |
---|
| 416 | lstexibe_csv, |
---|
| 417 | lstexibe_legendatopo, |
---|
| 418 | lstexibe_legendarodape, |
---|
| 419 | lstexibe_titagrupamento, |
---|
| 420 | lstexibe_agrupamento_alfabetico, |
---|
| 421 | lstagrupamento_campo, |
---|
| 422 | lstagrupamento_titulo, |
---|
| 423 | lstmsg_totalizador, |
---|
| 424 | lstmsg_subtotalizador, |
---|
| 425 | lstmsg_registrosencontrados, |
---|
| 426 | lstmsg_nenhumresultado, |
---|
| 427 | lstexclusao, |
---|
| 428 | lstexibe_resultados |
---|
[6413] | 429 | from |
---|
| 430 | listagem.listagem |
---|
[5307] | 431 | where lstidlistagem = '$idlistagem'"; |
---|
| 432 | $resu = pg_query($this->conexao,$sql); |
---|
[6413] | 433 | |
---|
[5307] | 434 | $this->setIdListagem($idlistagem); |
---|
[6413] | 435 | |
---|
[5307] | 436 | $arquivo = $_SERVER['PHP_SELF']; |
---|
[6413] | 437 | |
---|
[5307] | 438 | if (stristr($arquivo,"cad_listagem.php")) { |
---|
| 439 | $arquivo = "null"; |
---|
| 440 | } |
---|
| 441 | |
---|
| 442 | if (pg_num_rows($resu)) { |
---|
| 443 | $dados = pg_fetch_object($resu); |
---|
[6413] | 444 | |
---|
[5307] | 445 | $lstexclusao = $dados->lstexclusao; |
---|
[6413] | 446 | |
---|
[5307] | 447 | if (($lstexclusao) && ($arquivo != "null")) { |
---|
| 448 | $this->_debug = true; |
---|
| 449 | $this->adicionarErro("Esta Consulta estᅵ inativada, contate o suporte tᅵcnico de sistemas.",true); |
---|
| 450 | } |
---|
[6413] | 451 | |
---|
[5307] | 452 | $lstoid = $dados->lstoid; |
---|
| 453 | $this->_lstoid = $lstoid; |
---|
[6413] | 454 | |
---|
| 455 | |
---|
[5307] | 456 | /* if ($arquivo != "null") { |
---|
| 457 | $sql = "select lsdoid from listagem_dependencia where lsdlstoid = '$lstoid' and lsdarquivo ilike '%$arquivo%'"; |
---|
| 458 | $res_dependencia = pg_query($this->conexao,$sql); |
---|
| 459 | $qtd_dependencia = pg_num_rows($res_dependencia); |
---|
[6413] | 460 | |
---|
| 461 | |
---|
[5307] | 462 | if ($qtd_dependencia == 0) { |
---|
| 463 | $sql = "insert into listagem_dependencia (lsdlstoid,lsdarquivo,lsdacesso) values ($lstoid,'$arquivo',now())"; |
---|
| 464 | $atualiza_dependencia = pg_query($this->conexao,$sql); |
---|
| 465 | } else { |
---|
| 466 | $listagem_dependencia = pg_fetch_object($res_dependencia); |
---|
| 467 | $lsdoid = $listagem_dependencia->lsdoid; |
---|
| 468 | $sql = "update listagem_dependencia set lsdacesso = now() where lsdoid = $lsdoid"; |
---|
| 469 | $atualiza_dependencia = pg_query($this->conexao,$sql); |
---|
| 470 | } |
---|
| 471 | } |
---|
| 472 | */ |
---|
[6413] | 473 | |
---|
| 474 | |
---|
[5307] | 475 | $sql = html_entity_decode( $dados->lstsql, ENT_QUOTES); |
---|
[6413] | 476 | |
---|
[5307] | 477 | $this->sql = $sql; |
---|
[6413] | 478 | |
---|
[5307] | 479 | // if ($previsualizacao) { $addsql = " limit 20"; } |
---|
| 480 | |
---|
[6413] | 481 | $sql_par = "select |
---|
[5307] | 482 | lspoid, |
---|
| 483 | lsplstoid, |
---|
| 484 | lspidparametro, |
---|
| 485 | lsptipo, |
---|
| 486 | lspvalor_padrao, |
---|
[6413] | 487 | lspobrigatorio |
---|
| 488 | from |
---|
| 489 | listagem.listagem_parametro |
---|
| 490 | where |
---|
[5307] | 491 | lsplstoid = $lstoid "; |
---|
| 492 | $resu_par = pg_query($this->conexao,$sql_par); |
---|
[6413] | 493 | |
---|
[5307] | 494 | while ($parametro = pg_fetch_object($resu_par)) { |
---|
| 495 | $idparametro = $parametro->lspidparametro; |
---|
| 496 | $tipo = $parametro->lsptipo; |
---|
| 497 | //$valor = $parametro->lspvalor; |
---|
| 498 | $valor = ""; |
---|
| 499 | $obrigatorio = $parametro->lspobrigatorio; |
---|
| 500 | $valor_padrao = $parametro->lspvalor_padrao; |
---|
[6413] | 501 | |
---|
[5307] | 502 | $this->adicionarParametro($idparametro,$tipo,$obrigatorio,$valor,$valor_padrao); |
---|
[6413] | 503 | |
---|
[5307] | 504 | if ($previsualizacao) { |
---|
| 505 | $this->setParametro($idparametro,$valor_padrao); |
---|
| 506 | } |
---|
| 507 | } |
---|
[6413] | 508 | |
---|
| 509 | $sql_par = "select |
---|
[5307] | 510 | lsioid, |
---|
| 511 | lsilstoid, |
---|
| 512 | lsiidindicador, |
---|
| 513 | lsitipo, |
---|
| 514 | lsiimagem, |
---|
| 515 | lsilegenda, |
---|
| 516 | lsilegenda_csv, |
---|
[6413] | 517 | lsicondicao |
---|
| 518 | from |
---|
| 519 | listagem.listagem_indicador |
---|
[5307] | 520 | where lsilstoid = $lstoid "; |
---|
| 521 | $resu_par = pg_query($this->conexao,$sql_par); |
---|
[6413] | 522 | |
---|
[5307] | 523 | while ($indicador = pg_fetch_object($resu_par)) { |
---|
| 524 | $idindicador = $indicador->lsiidindicador; |
---|
| 525 | $tipo = $indicador->lsitipo; |
---|
| 526 | $imagem = $indicador->lsiimagem; |
---|
| 527 | $condicao = html_entity_decode($indicador->lsicondicao, ENT_QUOTES); |
---|
| 528 | $legenda_csv = html_entity_decode($indicador->lsilegenda_csv, ENT_QUOTES); |
---|
| 529 | $legenda = html_entity_decode($indicador->lsilegenda, ENT_QUOTES); |
---|
[6413] | 530 | |
---|
| 531 | |
---|
| 532 | if ($legenda_csv == "") { |
---|
[5307] | 533 | $legenda_csv = $legenda; |
---|
| 534 | } |
---|
| 535 | $this->adicionarIndicador($idindicador,$condicao,$tipo,$imagem,$legenda,$legenda_csv); |
---|
| 536 | } |
---|
[6413] | 537 | |
---|
| 538 | |
---|
| 539 | $this->setTitulo($dados->lsttitulo); |
---|
[5307] | 540 | $this->setMensagemTotalizador($dados->lstmsg_totalizador); |
---|
[6413] | 541 | $this->setMensagemRegistrosEncontrados($dados->lstmsg_registrosencontrados); |
---|
[5307] | 542 | $this->setMensagemSubTotalizador($dados->lstmsg_subtotalizador); |
---|
| 543 | $this->setMensagemNenhumResultado($dados->lstmsg_nenhumresultado); |
---|
[6413] | 544 | |
---|
[5307] | 545 | if ($dados->lstagrupamento_campo != "") { |
---|
| 546 | if ($dados->lstagrupamento_titulo == "") { |
---|
| 547 | $lstagrupamento_titulo = "{" . $dados->lstagrupamento_campo . "}"; |
---|
| 548 | } else { |
---|
| 549 | $lstagrupamento_titulo = $dados->lstagrupamento_titulo; |
---|
| 550 | } |
---|
| 551 | if ($dados->lstexibe_titagrupamento == "t") { |
---|
| 552 | $lstexibe_titagrupamento = true; |
---|
| 553 | } else { |
---|
| 554 | $lstexibe_titagrupamento = false; |
---|
| 555 | } |
---|
[6413] | 556 | |
---|
| 557 | |
---|
[5307] | 558 | if ($dados->lstexibe_agrupamento_alfabetico == "t") { |
---|
| 559 | $lstexibe_agrupamento_alfabetico = true; |
---|
| 560 | } else { |
---|
| 561 | $lstexibe_agrupamento_alfabetico = false; |
---|
| 562 | } |
---|
| 563 | $this->setAgrupamento("{" . $dados->lstagrupamento_campo . "}",$lstagrupamento_titulo,$lstexibe_titagrupamento); |
---|
| 564 | $this->setAgruparAlfabeticamente($lstexibe_agrupamento_alfabetico); |
---|
| 565 | } |
---|
[6413] | 566 | |
---|
[5307] | 567 | if ($dados->lstexibe_csv == "f") { |
---|
| 568 | $lstexibe_csv = false; |
---|
| 569 | } else { |
---|
| 570 | $lstexibe_csv = true; |
---|
| 571 | } |
---|
| 572 | if ($dados->lstexibe_resultados == "f") { |
---|
| 573 | $lstexibe_resultados = false; |
---|
| 574 | } else { |
---|
| 575 | $lstexibe_resultados = true; |
---|
| 576 | } |
---|
| 577 | if ($dados->lstexibe_totalizadores == "f") { |
---|
| 578 | $lstexibe_totalizadores = false; |
---|
| 579 | } else { |
---|
| 580 | $lstexibe_totalizadores = true; |
---|
| 581 | } |
---|
| 582 | if ($dados->lstexibe_subtotais == "f") { |
---|
| 583 | $lstexibe_subtotais = false; |
---|
| 584 | } else { |
---|
| 585 | $lstexibe_subtotais = true; |
---|
| 586 | } |
---|
[6413] | 587 | if ($dados->lstexibe_header == "f") { |
---|
[5307] | 588 | $showthead = false; |
---|
| 589 | } else { |
---|
| 590 | $showthead = true; |
---|
| 591 | } |
---|
| 592 | if ($dados->lstexibe_qtdregistros == "f") { |
---|
| 593 | $lstexibe_qtdregistros = false; |
---|
| 594 | } else { |
---|
| 595 | $lstexibe_qtdregistros = true; |
---|
| 596 | } |
---|
| 597 | if ($dados->lstexibe_legendatopo == "f") { |
---|
| 598 | $lstexibe_legendatopo = false; |
---|
| 599 | } else { |
---|
| 600 | $lstexibe_legendatopo = true; |
---|
| 601 | } |
---|
| 602 | if ($dados->lstexibe_checkbox == "f") { |
---|
| 603 | $lstexibe_checkbox = false; |
---|
| 604 | } else { |
---|
| 605 | $lstexibe_checkbox = true; |
---|
| 606 | } |
---|
| 607 | if ($dados->lstexibe_legendarodape == "f") { |
---|
| 608 | $lstexibe_legendarodape = false; |
---|
| 609 | } else { |
---|
| 610 | $lstexibe_legendarodape = true; |
---|
| 611 | } |
---|
| 612 | $this->_exibearquivocsv = $lstexibe_csv; |
---|
| 613 | $this->_mostraLegendaTopo = $lstexibe_legendatopo; |
---|
| 614 | $this->_mostraLegendaRodape = $lstexibe_legendarodape; |
---|
| 615 | $this->exibesubtotais = $lstexibe_subtotais; |
---|
| 616 | $this->_exibeqtdregistros = $lstexibe_qtdregistros; |
---|
| 617 | $this->showthead = $showthead; |
---|
| 618 | $this->_exibetotalizadores = $lstexibe_totalizadores; |
---|
| 619 | $this->_exiberesultados = $lstexibe_resultados; |
---|
[6413] | 620 | |
---|
| 621 | |
---|
| 622 | |
---|
| 623 | $sql_colunas = "select |
---|
[5307] | 624 | lslcoid, |
---|
| 625 | lslclstoid, |
---|
| 626 | lslcidcoluna, |
---|
| 627 | lslcordem, |
---|
| 628 | lslctipo, |
---|
| 629 | lslctitulo, |
---|
| 630 | lslchtml, |
---|
| 631 | lslcalign, |
---|
| 632 | lslcwidth, |
---|
| 633 | lslcnowrap, |
---|
| 634 | lslcvisivel, |
---|
| 635 | lslcexibe_csv, |
---|
| 636 | lslccalculada, |
---|
| 637 | lslccheckbox, |
---|
| 638 | lslclink, |
---|
| 639 | lslclink_condicao, |
---|
| 640 | lslclink_blank, |
---|
| 641 | lslctotalizador_condicao, |
---|
| 642 | lslcsubtotalizador_condicao, |
---|
| 643 | lslccheckbox_condicao |
---|
[6413] | 644 | from |
---|
| 645 | listagem.listagem_coluna |
---|
| 646 | where |
---|
| 647 | lslclstoid = $lstoid |
---|
[5307] | 648 | order by lslcordem"; |
---|
| 649 | $resu_colunas = pg_query($this->conexao,$sql_colunas); |
---|
[6413] | 650 | |
---|
[5307] | 651 | while ($coluna = pg_fetch_object($resu_colunas)) { |
---|
| 652 | // print_r($coluna); |
---|
| 653 | $idcoluna = $coluna->lslcidcoluna; |
---|
| 654 | $tipo = $coluna->lslctipo; |
---|
| 655 | $titulo = $coluna->lslctitulo; |
---|
| 656 | $html = $coluna->lslchtml; |
---|
| 657 | $align = $coluna->lslcalign; |
---|
| 658 | $width = $coluna->lslcwidth; |
---|
| 659 | $condicao_totalizador = $coluna->lslctotalizador_condicao; |
---|
| 660 | $condicao_subtotalizador = $coluna->lslcsubtotalizador_condicao; |
---|
| 661 | $link = $coluna->lslclink; |
---|
| 662 | $link_condicao = $coluna->lslclink_condicao; |
---|
[6413] | 663 | |
---|
[5307] | 664 | $idcoluna = html_entity_decode($idcoluna, ENT_QUOTES); |
---|
| 665 | $titulo = html_entity_decode($titulo, ENT_QUOTES); |
---|
| 666 | $html = html_entity_decode($html, ENT_QUOTES); |
---|
| 667 | $link = html_entity_decode($link, ENT_QUOTES); |
---|
| 668 | $link_condicao = html_entity_decode($link_condicao, ENT_QUOTES); |
---|
[6413] | 669 | |
---|
[5307] | 670 | if ($coluna->lslccalculada == "t") { |
---|
| 671 | $lslccalculada = true; |
---|
| 672 | } else { |
---|
| 673 | $lslccalculada = false; |
---|
| 674 | } |
---|
| 675 | if ($coluna->lslccheckbox == "t") { |
---|
| 676 | $lslccheckbox = true; |
---|
| 677 | } else { |
---|
| 678 | $lslccheckbox = false; |
---|
| 679 | } |
---|
| 680 | if ($coluna->lslcnowrap == "t") { |
---|
| 681 | $lslcnowrap = true; |
---|
| 682 | } else { |
---|
| 683 | $lslcnowrap = false; |
---|
| 684 | } |
---|
| 685 | if ($coluna->lslcvisivel == "t") { |
---|
| 686 | $lslcvisivel = true; |
---|
| 687 | } else { |
---|
| 688 | $lslcvisivel = false; |
---|
| 689 | } |
---|
| 690 | if ($coluna->lslclink_blank == "t") { |
---|
| 691 | $lslclink_blank = true; |
---|
| 692 | } else { |
---|
| 693 | $lslclink_blank = false; |
---|
| 694 | } |
---|
[6413] | 695 | |
---|
[5307] | 696 | if ($coluna->lslcexibe_csv == "t") { |
---|
| 697 | $lslcexibe_csv = true; |
---|
| 698 | } else { |
---|
| 699 | $lslcexibe_csv = false; |
---|
| 700 | } |
---|
[6413] | 701 | |
---|
[5307] | 702 | if ($lslcexibe_csv) { |
---|
[6413] | 703 | $this->_colunascsv .= "$idcoluna,"; |
---|
[5307] | 704 | } |
---|
[6413] | 705 | |
---|
| 706 | |
---|
[5307] | 707 | if (($tipo == "text") || ($tipo == "data") || ($tipo == "hora") || ($tipo == "int") || ($tipo == "moeda")) { |
---|
[6413] | 708 | |
---|
[5307] | 709 | if (($tipo == "int") && ($lslccheckbox)) { |
---|
| 710 | if ($lstexibe_checkbox) { |
---|
| 711 | $this->adicionarColunaCheckBox($idcoluna,$titulo,$html,$coluna->lslccheckbox_condicao); |
---|
| 712 | } |
---|
| 713 | } else { |
---|
| 714 | //echo "idcoluna: $idcoluna -> $lslcnowrap"; |
---|
[6413] | 715 | $this->adicionarColuna($idcoluna,$titulo,$html,$tipo,$align,$width,$lslcnowrap,$lslcvisivel); |
---|
[5307] | 716 | } |
---|
[6413] | 717 | |
---|
[5307] | 718 | if ($link != "") { |
---|
| 719 | $this->adicionarLink($idcoluna,$link,$link_condicao,$lslclink_blank); |
---|
| 720 | } |
---|
[6413] | 721 | |
---|
[5307] | 722 | if ($lslccalculada) { |
---|
| 723 | $this->adicionarTotalizador($idcoluna,$condicao_totalizador,$condicao_subtotalizador); |
---|
| 724 | } |
---|
| 725 | } |
---|
| 726 | } |
---|
[6413] | 727 | |
---|
[5307] | 728 | } else { |
---|
| 729 | $this->_debug = true; |
---|
| 730 | $this->adicionarErro("Listagem nï¿œo encontrada."); |
---|
| 731 | } |
---|
| 732 | |
---|
[6413] | 733 | |
---|
[5307] | 734 | } |
---|
| 735 | |
---|
| 736 | public function getQuantidadeRegistros() { |
---|
| 737 | if ($this->_isarray) { |
---|
| 738 | $ret = count($this->dados); |
---|
| 739 | } else { |
---|
| 740 | if (count($this->dados)) { |
---|
| 741 | $ret = pg_num_rows($this->dados); |
---|
| 742 | } else { |
---|
| 743 | $ret = 0; |
---|
| 744 | } |
---|
| 745 | } |
---|
| 746 | // if ($this->issublist) { |
---|
[6413] | 747 | if (is_object($this->subListagem)) { |
---|
[5307] | 748 | $ret = $ret + $this->subListagem->getQuantidadeRegistros(); |
---|
| 749 | } |
---|
| 750 | // } |
---|
| 751 | return $ret; |
---|
| 752 | } |
---|
| 753 | |
---|
| 754 | /** |
---|
| 755 | * Funᅵᅵo para Alterar a Mensagem de Registros Encontrados. |
---|
[6413] | 756 | * |
---|
[5307] | 757 | * @param $msg |
---|
| 758 | */ |
---|
| 759 | public function setMensagemRegistrosEncontrados($msg) { $this->msgregistros = $msg; } |
---|
[6413] | 760 | |
---|
[5307] | 761 | /** |
---|
| 762 | * Funᅵᅵo para Alterar a Mensagem de Total de Registros Encontrados. |
---|
[6413] | 763 | * |
---|
[5307] | 764 | * @param $msg |
---|
| 765 | */ |
---|
| 766 | public function setMensagemTotalizador($msg) { $this->msgtotalizador = $msg; } |
---|
[6413] | 767 | |
---|
[5307] | 768 | /** |
---|
| 769 | * Funᅵᅵo para Alterar a Mensagem de Sub-Total de Registros Encontrados |
---|
[6413] | 770 | * |
---|
[5307] | 771 | * @param $msg |
---|
| 772 | */ |
---|
| 773 | public function setMensagemSubTotalizador($msg) { $this->msgsubtotalizador = $msg; } |
---|
[6413] | 774 | |
---|
[5307] | 775 | /** |
---|
| 776 | * Funᅵᅵo para Alterar a Mensagem de "Nenhum Resultado Encontrado". |
---|
[6413] | 777 | * |
---|
[5307] | 778 | * @param $msg |
---|
| 779 | */ |
---|
| 780 | public function setMensagemNenhumResultado($msg) { $this->msgnenhumresultado = $msg; } |
---|
| 781 | |
---|
| 782 | /** |
---|
| 783 | * Funᅵᅵo que Indica se a Listagem ᅵ Agrupada Alfabeticamente |
---|
[6413] | 784 | * |
---|
[5307] | 785 | * @param value (true ou false) |
---|
| 786 | */ |
---|
| 787 | public function setAgruparAlfabeticamente($value) { |
---|
| 788 | $this->agruparAlfabeticamente = $value; |
---|
| 789 | } |
---|
[6413] | 790 | |
---|
[5307] | 791 | /** |
---|
| 792 | * Funᅵᅵo para Alterar a Opᅵᅵo de Exibir os Sub-Totais de uma Listagem. |
---|
[6413] | 793 | * |
---|
[5307] | 794 | * @param $value (true ou false) |
---|
| 795 | */ |
---|
| 796 | public function setMostrarSubTotais($value) { |
---|
| 797 | $this->exibesubtotais = $value; |
---|
| 798 | } |
---|
[6413] | 799 | |
---|
[5307] | 800 | public function setMostrarTotal($value) { |
---|
| 801 | $this->_exibetotalizadores = $value; |
---|
| 802 | } |
---|
[6413] | 803 | |
---|
[5307] | 804 | public function setMostrarLegendaTopo($value) { |
---|
| 805 | $this->_mostraLegendaTopo = $value; |
---|
| 806 | } |
---|
[6413] | 807 | |
---|
[5307] | 808 | public function setMostrarLegendaRodape($value) { |
---|
| 809 | $this->_mostraLegendaRodape = $value; |
---|
| 810 | } |
---|
[6413] | 811 | |
---|
| 812 | |
---|
[5307] | 813 | /** |
---|
| 814 | * Funᅵᅵo para Alterar a Opᅵᅵo de Exibir a Quantidade de Registros Retornados da Listagem. |
---|
[6413] | 815 | * |
---|
[5307] | 816 | * @param $exibir (true ou false) |
---|
| 817 | */ |
---|
| 818 | public function setMostrarQuantidadeRegistros($exibir) { |
---|
| 819 | $this->_exibeqtdregistros = $exibir; |
---|
| 820 | } |
---|
| 821 | |
---|
| 822 | /** |
---|
| 823 | * Funᅵᅵo para adicionar uma Coluna na Listagem. |
---|
[6413] | 824 | * |
---|
[5307] | 825 | * @param $idcoluna |
---|
| 826 | * @param $tipo |
---|
| 827 | * @param $titulo |
---|
| 828 | * @param $html |
---|
| 829 | * @param $width |
---|
| 830 | * @param $nowrap |
---|
| 831 | * @param $valign |
---|
| 832 | * @param $visivel |
---|
| 833 | * @return unknown_type |
---|
| 834 | */ |
---|
| 835 | function adicionarColuna($idcoluna,$titulo,$html,$tipo = "text",$align = "",$width = "",$nowrap = false,$visivel = true) { |
---|
| 836 | $erro = false; |
---|
| 837 | if ($this->isColuna($idcoluna)) { |
---|
| 838 | $erro = true; |
---|
| 839 | $this->adicionarErro("addColuna()<br>$idcoluna jᅵ foi adicionada na Listagem."); |
---|
| 840 | } |
---|
| 841 | if (!$erro) { |
---|
| 842 | $coluna = new ListagemColuna($idcoluna,$tipo,$titulo,$html,$width,$nowrap,$align); |
---|
| 843 | $coluna->setVisibilidade($visivel); |
---|
| 844 | $coluna->setIdListagem($this->idlistagem); |
---|
| 845 | array_push($this->colunas,$coluna); |
---|
| 846 | } |
---|
| 847 | } |
---|
[6413] | 848 | |
---|
[5307] | 849 | function adicionarColunaCalculada($idcoluna,$tipo,$html,$condicao_total = "1",$condicao_subtotal = "1") { |
---|
| 850 | $erro = false; |
---|
| 851 | if ($this->isColuna($idcoluna)) { |
---|
| 852 | $erro = true; |
---|
| 853 | $this->adicionarErro("addColuna()<br>$idcoluna jᅵ foi adicionada na Listagem."); |
---|
| 854 | } |
---|
| 855 | if (!$erro) { |
---|
| 856 | $this->adicionarColuna($idcoluna,$tipo,$idcoluna,$html,"",true,"",false); |
---|
| 857 | $this->adicionarTotalizador($idcoluna,$condicao_total,$condicao_subtotal); |
---|
| 858 | } |
---|
| 859 | } |
---|
[6413] | 860 | |
---|
[5307] | 861 | function adicionarLinhaDetalhamento($idlinha,$tipo,$html,$align = "left") { |
---|
| 862 | $width = ""; |
---|
| 863 | $nowrap = false; |
---|
| 864 | $valign = $align; |
---|
| 865 | $coluna = new ListagemColuna($idlinha,$tipo,"",$html,$width,$nowrap,$valign); |
---|
| 866 | array_push($this->linhasdetalhamento,$coluna); |
---|
| 867 | } |
---|
[6413] | 868 | |
---|
[5307] | 869 | /** |
---|
| 870 | * Funᅵᅵo para Adicionar uma Coluna com CheckBoxes. |
---|
[6413] | 871 | * |
---|
[5307] | 872 | * @param $idcoluna |
---|
| 873 | * @param $titulo |
---|
| 874 | * @param $html |
---|
| 875 | * @param $condicao |
---|
| 876 | * @param $width |
---|
| 877 | * @param $nowrap |
---|
| 878 | * @param $valign |
---|
| 879 | * @return unknown_type |
---|
| 880 | */ |
---|
| 881 | function adicionarColunaCheckBox($idcoluna,$titulo,$value,$condicao = "",$width = "1%",$nowrap = false,$valign = "center") { |
---|
| 882 | $tipo = "check"; |
---|
| 883 | $html = "{" . $value . "}"; |
---|
| 884 | $coluna = new ListagemColuna($idcoluna,$tipo,$titulo,$html,$width,$nowrap,$valign); |
---|
| 885 | $coluna->setCondicao($condicao); |
---|
| 886 | $coluna->setIdListagem($this->idlistagem); |
---|
| 887 | array_push($this->colunas,$coluna); |
---|
| 888 | } |
---|
[6413] | 889 | |
---|
[5307] | 890 | /** |
---|
| 891 | * Funᅵᅵo utilizada Internamente para verificar se o idcoluna passado jᅵ foi adicionado a listagem. |
---|
[6413] | 892 | * |
---|
[5307] | 893 | * @param $idcoluna |
---|
| 894 | * @return unknown_type |
---|
| 895 | */ |
---|
| 896 | protected function isColuna($idcoluna) { |
---|
| 897 | $ret = false; |
---|
| 898 | foreach ($this->colunas as $i => $col) { |
---|
| 899 | if ($col->getIdColuna() == $idcoluna) { |
---|
| 900 | $ret = true; |
---|
| 901 | } |
---|
| 902 | } |
---|
| 903 | return $ret; |
---|
| 904 | } |
---|
[6413] | 905 | |
---|
[5307] | 906 | /** |
---|
| 907 | * Adiciona um Link para uma ou mais Colunas. |
---|
[6413] | 908 | * |
---|
[5307] | 909 | * @param $idcolunas (Ids das colunas separados por vï¿œrgula) |
---|
| 910 | * @param $link Link para ser redirecionado. |
---|
| 911 | * @param $target |
---|
| 912 | * @return unknown_type |
---|
| 913 | */ |
---|
| 914 | public function adicionarLink($idcolunas,$link,$condicao = "1",$targetblank = false,$popup = false) { |
---|
| 915 | $colunas = explode(",",$idcolunas); |
---|
| 916 | foreach ($colunas as $idcoluna) { |
---|
| 917 | $erro = false; |
---|
| 918 | if (!$this->isColuna($idcoluna)) { |
---|
| 919 | $this->adicionarErro("addLink()<br>$idcoluna nᅵo ᅵ uma coluna adicionada na Listagem.",false); |
---|
| 920 | $erro = true; |
---|
| 921 | } |
---|
| 922 | if (!$erro) { |
---|
| 923 | foreach ($this->colunas as $i => $col) { |
---|
| 924 | if ($col->getIdColuna() == $idcoluna) { |
---|
| 925 | $this->colunas[$i]->setLink($link,$condicao,$targetblank,$popup); |
---|
| 926 | } |
---|
| 927 | } |
---|
| 928 | } |
---|
| 929 | } |
---|
| 930 | } |
---|
[6413] | 931 | |
---|
[5307] | 932 | public function RemoverColuna($idcolunas){ |
---|
| 933 | $colunas = explode(",",$idcolunas); |
---|
| 934 | foreach ($colunas as $idcoluna) { |
---|
| 935 | $erro = false; |
---|
| 936 | if (!$this->isColuna($idcoluna)) { |
---|
| 937 | $this->adicionarErro("addColunaCor()<br>$idcoluna nᅵo ᅵ uma coluna adicionada na Listagem.",false); |
---|
| 938 | $erro = true; |
---|
| 939 | } |
---|
| 940 | if (!$erro) { |
---|
| 941 | foreach ($this->colunas as $i => $col) { |
---|
| 942 | if ($col->getIdColuna() == $idcoluna) { |
---|
| 943 | unset($this->colunas[$i]); |
---|
| 944 | } |
---|
| 945 | } |
---|
| 946 | } |
---|
| 947 | } |
---|
| 948 | } |
---|
[6413] | 949 | |
---|
| 950 | |
---|
[5307] | 951 | public function adicionarCor($idcolunas,$cor,$condicao = "1") { |
---|
| 952 | $colunas = explode(",",$idcolunas); |
---|
| 953 | $cor = str_replace("#","",$cor); |
---|
| 954 | foreach ($colunas as $idcoluna) { |
---|
| 955 | $erro = false; |
---|
| 956 | if (!$this->isColuna($idcoluna)) { |
---|
| 957 | $this->adicionarErro("addColunaCor()<br>$idcoluna nᅵo ᅵ uma coluna adicionada na Listagem.",false); |
---|
| 958 | $erro = true; |
---|
| 959 | } |
---|
| 960 | if (!$erro) { |
---|
| 961 | foreach ($this->colunas as $i => $col) { |
---|
| 962 | if ($col->getIdColuna() == $idcoluna) { |
---|
| 963 | $this->colunas[$i]->setCor($cor,$condicao); |
---|
| 964 | } |
---|
| 965 | } |
---|
| 966 | } |
---|
| 967 | } |
---|
| 968 | } |
---|
[6413] | 969 | |
---|
[5307] | 970 | /** |
---|
| 971 | * Funᅵᅵo para Adicionar um Indicador (Legenda). |
---|
[6413] | 972 | * |
---|
[5307] | 973 | * @param $idindicador Cᅵdigo Interno de Identificaᅵᅵo do Identificador |
---|
| 974 | * @param $condicao Condiᅵᅵo em PHP para Exibir o Indicador. |
---|
| 975 | * @param $tipo R,Q,T (REDONDO,QUADRADO,TRIANGULO) |
---|
[6413] | 976 | * @param $codigoimagem (1 a 19). |
---|
[5307] | 977 | * @param $legenda Legenda |
---|
| 978 | * @return unknown_type |
---|
| 979 | */ |
---|
| 980 | function adicionarIndicador($idindicador,$condicao,$tipo = "R",$codigoimagem = "1",$legenda = "",$tamanho = "1") { |
---|
| 981 | $Indicador = new ListagemIndicador($idindicador,$condicao,$tipo,$codigoimagem,$legenda,$tamanho); |
---|
| 982 | $Indicador->setUrlBasePath($this->_url_base_path); |
---|
| 983 | if (!isset($this->arrindicadores[$idindicador])) { $this->arrindicadores[$idindicador] = array(); } |
---|
| 984 | array_push($this->arrindicadores[$idindicador],$Indicador); |
---|
| 985 | } |
---|
[6413] | 986 | |
---|
[5307] | 987 | /** |
---|
| 988 | * Funᅵᅵo para Desenhar a Listagem. |
---|
[6413] | 989 | * |
---|
[5307] | 990 | * @return HTML |
---|
| 991 | */ |
---|
| 992 | function desenhar() { |
---|
| 993 | $html = ""; |
---|
| 994 | $this->incluiCssJavaScript($this->_url_base_path); |
---|
| 995 | if ($this->_lstoid != "") { |
---|
| 996 | $this->formataSQLParametros(); |
---|
| 997 | $sql = $this->getSQL(); |
---|
| 998 | $sql = html_entity_decode($sql, ENT_QUOTES); |
---|
| 999 | $this->carregar($sql); |
---|
[6413] | 1000 | |
---|
[5307] | 1001 | } |
---|
[6413] | 1002 | |
---|
[5307] | 1003 | if ($this->_exibearquivocsv) { |
---|
| 1004 | $this->gerarArquivoXLS($this->_colunascsv); |
---|
| 1005 | } |
---|
| 1006 | $this->escreveErros(); |
---|
| 1007 | $this->escreveAbreList(); |
---|
| 1008 | $this->escreveLinhas(); |
---|
| 1009 | $this->escreveFechaList(); |
---|
| 1010 | } |
---|
[6413] | 1011 | |
---|
[5307] | 1012 | function incluiCssJavascript($addpath = "") { |
---|
| 1013 | echo "\n\n<script language=\"Javascript\" type=\"text/javascript\" src=\"$addpath/includes/js/mascaras.js\"></script>\n |
---|
| 1014 | <script language=\"Javascript\" type=\"text/javascript\" src=\"$addpath/includes/js/validacoes.js\"></script>\n |
---|
| 1015 | <script language=\"Javascript\" type=\"text/javascript\" src=\"$addpath/includes/js/auxiliares.js\"></script>\n |
---|
| 1016 | <script language=\"Javascript\" type=\"text/javascript\" src=\"$addpath/includes/js/calendar.js\"></script>\n |
---|
| 1017 | <script language=\"Javascript\" type=\"text/javascript\" src=\"$addpath/includes/js/FormularioUtil.js\"></script>\n |
---|
| 1018 | <link rel=\"stylesheet\" href=\"$addpath/includes/css/base_form.css\" media=\"screen\"></link>\n |
---|
| 1019 | <link rel=\"stylesheet\" href=\"$addpath/includes/css/calendar.css\" media=\"screen\"></link>\n\n"; |
---|
[6413] | 1020 | |
---|
[5307] | 1021 | } |
---|
[6413] | 1022 | |
---|
[5307] | 1023 | protected function escreveLegenda() { |
---|
| 1024 | if ($this->_exiberesultados) { |
---|
| 1025 | if (count($this->arrindicadores)) { |
---|
| 1026 | $colspan=0; |
---|
[6413] | 1027 | |
---|
[5307] | 1028 | echo "\n\t<table width='100%' class='TableMoldura''> |
---|
| 1029 | \n\t\t<tr class='tableSubTitulo'> |
---|
| 1030 | \n\t\t\t<td><h3>Legenda</h3></td> |
---|
| 1031 | \n\t\t</tr>"; |
---|
| 1032 | echo "<tr><td align=left colspan='$colspan'>"; |
---|
| 1033 | foreach ($this->arrindicadores as $idindicador => $indicadores) { |
---|
| 1034 | $exibelinha = false; |
---|
| 1035 | foreach ($indicadores as $indicador) { |
---|
| 1036 | if ($indicador->getLegenda() != "") { |
---|
| 1037 | $exibelinha = true; |
---|
| 1038 | } |
---|
| 1039 | } |
---|
| 1040 | if ($exibelinha) { |
---|
| 1041 | echo "<br> "; |
---|
| 1042 | $addlegenda = ""; |
---|
| 1043 | foreach ($indicadores as $indicador) { |
---|
| 1044 | if ($indicador->getLegenda() != "") { |
---|
| 1045 | $addlegenda .= str_replace("{indicador_substituirpasta}","",$indicador->getHtml()) . " " . $indicador->getLegenda() . " | "; |
---|
| 1046 | } |
---|
| 1047 | } |
---|
| 1048 | $addlegenda = substr($addlegenda,0,strlen($addlegenda) - 3); |
---|
| 1049 | echo $addlegenda; |
---|
| 1050 | echo "<br>"; |
---|
| 1051 | } |
---|
| 1052 | } |
---|
| 1053 | echo "<br></td></tr></table>"; |
---|
| 1054 | } |
---|
| 1055 | } |
---|
| 1056 | } |
---|
[6413] | 1057 | |
---|
[5307] | 1058 | /** |
---|
| 1059 | * Funᅵᅵo que desenha o cabeᅵalho da Listagem. |
---|
[6413] | 1060 | * |
---|
[5307] | 1061 | * @return HTML |
---|
| 1062 | */ |
---|
| 1063 | protected function escreveAbreList() { |
---|
| 1064 | $colspan = count($this->colunas); |
---|
[6413] | 1065 | |
---|
[5307] | 1066 | $htmldivs = ""; |
---|
| 1067 | $html_icone = ""; |
---|
[6413] | 1068 | |
---|
[5307] | 1069 | if (!$this->issublist) { |
---|
| 1070 | if ($this->_mostraLegendaTopo) { |
---|
| 1071 | $this->escreveLegenda(); |
---|
| 1072 | } |
---|
| 1073 | $addclass= " class='TableMoldura'"; |
---|
| 1074 | |
---|
| 1075 | if ($this->_exiberesultados) { |
---|
[6413] | 1076 | |
---|
[5307] | 1077 | if ($this->exibedivcolunas) { |
---|
| 1078 | $html_icone = '<b>[<img id="'. $this->idlistagem . '_img_visivel" src="' . $this->_url_base_path . '/images/icones/maisTransparente.gif" OnClick="ListagemShowHide(event,\''. $this->idlistagem . '\',\''. $this->idlistagem . '_img_visivel\');" OnMouseOver="this.style.cursor=\'pointer\';" OnMouseOut="this.style.cursor=\'default\';">]</b>'; |
---|
| 1079 | $html_icone_2 = '<b>[<img id="'. $this->idlistagem . '_img_visivel_2" src="' . $this->_url_base_path . '/images/icones/menosTransparente.gif" OnClick="ListagemShowHide(event,\''. $this->idlistagem . '\',\''. $this->idlistagem . '_img_visivel\');" OnMouseOver="this.style.cursor=\'pointer\';" OnMouseOut="this.style.cursor=\'default\';">]</b>'; |
---|
| 1080 | |
---|
| 1081 | // $html_icone .= ' <b>[<img id="'. $this->idlistagem . '_img_grafico_visivel" src="images/icones/t1/fileGrafico.jpg" OnClick="ListagemShowHide(event,\''. $this->idlistagem . '\',\''. $this->idlistagem . '_img_grafico_visivel\');" OnMouseOver="this.style.cursor=\'pointer\';" OnMouseOut="this.style.cursor=\'default\';">]</b>'; |
---|
[6413] | 1082 | |
---|
[5307] | 1083 | $cnt = 0; |
---|
| 1084 | $htmlchecks = ""; |
---|
[6413] | 1085 | |
---|
[5307] | 1086 | foreach ($this->colunas as $coluna) { |
---|
| 1087 | $titulo = $coluna->getNome(); |
---|
| 1088 | $idcoluna = $coluna->getIdColuna(); |
---|
| 1089 | $idlistagem = $this->idlistagem; |
---|
| 1090 | $visivel = $coluna->getVisibilidade(); |
---|
| 1091 | $addvisivel = ""; |
---|
| 1092 | if ($visivel) { $addvisivel = "checked"; } |
---|
[6413] | 1093 | |
---|
[5307] | 1094 | $adddisabled = ""; |
---|
| 1095 | if ($cnt == 0) { $adddisabled = " disabled"; $cnt = $cnt + 1; } |
---|
[6413] | 1096 | |
---|
[5307] | 1097 | $htmlchecks .= '<input type="checkbox" class="checkbox" name="' . $idlistagem . '_ck_visivel_' . $idcoluna . '" id="' . $idlistagem . '_ck_visivel_' . $idcoluna . '" OnClick=" document.getElementById(\'' . $idlistagem . '_div_visivel\').style.display = \'none\'; document.getElementById(\'' . $idlistagem . '_div_visivel_load\').style.display = \'\'; alinhaDivDir(\'' .$idlistagem. '_div_visivel_load\'); setTimeout(\'ListagemExibeOcultaColuna(\\\'' . $idlistagem. '\\\',\\\'' .$idcoluna . '\\\');\')" value="' .$idcoluna . '" ' . $addvisivel .$adddisabled . '> ' . $titulo . '<br>'; |
---|
[6413] | 1098 | |
---|
[5307] | 1099 | } |
---|
| 1100 | |
---|
[6413] | 1101 | |
---|
| 1102 | $htmldivs = '<div id="' . $idlistagem. '_div_visivel" class="div_visivel" style="display:none;"> |
---|
| 1103 | <table width="100%"> |
---|
[5307] | 1104 | <tr> |
---|
| 1105 | <td align="right">' .$html_icone_2. '</td> |
---|
| 1106 | </tr> |
---|
| 1107 | <tr> |
---|
| 1108 | <td style="padding-left:5px;">' |
---|
[6413] | 1109 | .$htmlchecks . |
---|
[5307] | 1110 | ' |
---|
| 1111 | |
---|
| 1112 | </td> |
---|
| 1113 | </tr> |
---|
| 1114 | </table> |
---|
| 1115 | </div> |
---|
| 1116 | <div id="' . $idlistagem. '_div_visivel_load" class="div_visivel" style="display:none;"> |
---|
| 1117 | <table width="100%"> |
---|
| 1118 | <tr> |
---|
| 1119 | <td style="padding-left:5px;"> |
---|
| 1120 | <img src="images/progress4.gif"></img> Carregando... |
---|
| 1121 | </td> |
---|
| 1122 | </tr> |
---|
| 1123 | </table> |
---|
| 1124 | </div>'; |
---|
[6413] | 1125 | |
---|
[5307] | 1126 | } |
---|
| 1127 | } |
---|
[6413] | 1128 | |
---|
| 1129 | |
---|
[5307] | 1130 | } |
---|
[6413] | 1131 | |
---|
[5307] | 1132 | echo "\n\t$htmldivs<table id='Listagem_" . $this->getIdListagem() . "' width='100%'$addclass> |
---|
| 1133 | \n\t\t<tr class='tableSubTitulo'> |
---|
| 1134 | \n\t\t\t<td colspan='$colspan'><div style='float: right;'>$html_icone </div><h3>" . $this->titulo . "</h3></td> |
---|
| 1135 | \n\t\t</tr>"; |
---|
| 1136 | } |
---|
[6413] | 1137 | |
---|
[5307] | 1138 | /** |
---|
| 1139 | * Funᅵᅵo que desenha o HTML que fecha a listagem. |
---|
[6413] | 1140 | * |
---|
[5307] | 1141 | * @return HTML |
---|
| 1142 | */ |
---|
| 1143 | protected function escreveFechaList() { |
---|
| 1144 | echo "\n\t</table>"; |
---|
[6413] | 1145 | |
---|
[5307] | 1146 | if (!$this->issublist) { |
---|
| 1147 | if ($this->_mostraLegendaRodape) { |
---|
| 1148 | $this->escreveLegenda(); |
---|
| 1149 | } |
---|
| 1150 | } |
---|
| 1151 | } |
---|
[6413] | 1152 | |
---|
[5307] | 1153 | public function setAgrupamento($idagrupamento,$titulo = "",$repetirtitulo = false) { |
---|
| 1154 | $width = ""; |
---|
| 1155 | $nowrap = false; |
---|
| 1156 | $align = "left"; |
---|
| 1157 | //$html = "{" . $idagrupamento . "}"; |
---|
| 1158 | $html = $idagrupamento; |
---|
[6413] | 1159 | if ($titulo == "") { |
---|
[5307] | 1160 | $titulo = "{" . $idagrupamento . "}"; |
---|
| 1161 | $repetirtitulo = true; |
---|
| 1162 | } |
---|
| 1163 | $this->_repetirtituloagrupamento = $repetirtitulo; |
---|
| 1164 | $tipo = ""; |
---|
| 1165 | $coluna = new ListagemColuna($idagrupamento,$tipo,$titulo,$html,$width,$nowrap,$align); |
---|
| 1166 | $this->linhasagrupamento = array(); |
---|
| 1167 | array_push($this->linhasagrupamento,$coluna); |
---|
| 1168 | } |
---|
[6413] | 1169 | |
---|
[5307] | 1170 | public function setParametro($idparametro,$valor) { |
---|
| 1171 | foreach ($this->arrparametros as $k => $parametro) { |
---|
| 1172 | if ($parametro['idparametro'] == $idparametro) { |
---|
| 1173 | $this->arrparametros[$k]["valor"] = $valor; |
---|
| 1174 | } |
---|
| 1175 | } |
---|
| 1176 | } |
---|
[6413] | 1177 | |
---|
[5307] | 1178 | public function adicionarParametro($idparametro,$tipo,$obrigatorio = false,$valor = "",$valortestes = "") { |
---|
| 1179 | $parametros = array(); |
---|
| 1180 | $parametros["idparametro"] = $idparametro; |
---|
| 1181 | $parametros["tipo"] = $tipo; |
---|
| 1182 | $parametros["valor"] = $valor; |
---|
| 1183 | $parametros["obrigatorio"] = $obrigatorio; |
---|
| 1184 | $parametros["valor_testes"] = $valortestes; |
---|
[6413] | 1185 | |
---|
[5307] | 1186 | if ($this->_debug) { |
---|
| 1187 | if (($tipo != "text") && ($tipo != "int") && ($tipo != "data")) { |
---|
| 1188 | $this->adicionarErro("Parᅵmetro '$idparametro' do tipo '$tipo' nᅵo ᅵ vᅵlido."); |
---|
| 1189 | return false; |
---|
| 1190 | } |
---|
| 1191 | } |
---|
[6413] | 1192 | |
---|
[5307] | 1193 | if (!$this->isParametro($idparametro)) { |
---|
| 1194 | array_push($this->arrparametros,$parametros); |
---|
| 1195 | } else { |
---|
| 1196 | if ($this->_debug) { |
---|
| 1197 | $this->adicionarErro("Parᅵmetro '$idparametro' jᅵ estᅵ adicionado a Listagem."); |
---|
| 1198 | } |
---|
| 1199 | } |
---|
| 1200 | } |
---|
[6413] | 1201 | |
---|
[5307] | 1202 | public function getSQLParametros() { |
---|
| 1203 | $sql = $this->sql; |
---|
| 1204 | $sqlparametros = array(); |
---|
| 1205 | $abre_chaves = explode("{",$sql); |
---|
| 1206 | foreach ($abre_chaves as $chave) { |
---|
| 1207 | $_chaves = array(); |
---|
| 1208 | if (stristr($chave,"}")) { |
---|
| 1209 | $_chaves = explode("}",$chave); |
---|
| 1210 | $sqlparametros[] = $_chaves[0]; |
---|
| 1211 | } |
---|
| 1212 | } |
---|
| 1213 | return $sqlparametros; |
---|
| 1214 | } |
---|
[6413] | 1215 | |
---|
[5307] | 1216 | protected function formataSQLParametros() { |
---|
| 1217 | $sql = $this->sql; |
---|
[6413] | 1218 | |
---|
[5307] | 1219 | $parametrosconsulta = $this->getSQLParametros(); |
---|
[6413] | 1220 | |
---|
[5307] | 1221 | foreach ($parametrosconsulta as $parametro_consulta) { |
---|
| 1222 | $achou = false; |
---|
| 1223 | $achou_consulta = false; |
---|
| 1224 | foreach ($this->arrparametros as $parametro_base) { |
---|
| 1225 | if ($parametro_base["idparametro"] == $parametro_consulta) { |
---|
| 1226 | $achou = true; |
---|
| 1227 | } |
---|
| 1228 | if (in_array($parametro_base["idparametro"],$parametrosconsulta)) { |
---|
| 1229 | $par_base = $parametro_base["idparametro"]; |
---|
| 1230 | $achou_consulta = true; |
---|
| 1231 | } |
---|
| 1232 | } |
---|
| 1233 | if (!$achou) { |
---|
| 1234 | $this->_debug=true; |
---|
| 1235 | $this->adicionarErro("Parï¿œmetro '$parametro_consulta' usado na consulta nï¿œo foi adicionado no cadastro.",true); |
---|
| 1236 | } |
---|
| 1237 | if (!$achou_consulta) { |
---|
| 1238 | $this->_debug=true; |
---|
| 1239 | $this->adicionarErro("Parᅵmetro '$par_base' cadastrado nᅵo ᅵ usado na consulta.",true); |
---|
| 1240 | } |
---|
| 1241 | } |
---|
[6413] | 1242 | |
---|
| 1243 | |
---|
[5307] | 1244 | foreach ($this->arrparametros as $parametro) { |
---|
| 1245 | $idparametro = $parametro["idparametro"]; |
---|
| 1246 | $valor = $parametro["valor"]; |
---|
| 1247 | $obrigatorio = $parametro["obrigatorio"]; |
---|
[6413] | 1248 | if (($obrigatorio == "t") && ($valor == "")) { |
---|
[5307] | 1249 | $this->_debug=true; |
---|
| 1250 | $this->adicionarErro("Parᅵmetro '$idparametro ' ᅵ obrigatᅵrio.",true); |
---|
| 1251 | } |
---|
| 1252 | if (($parametro["tipo"] == "data") || ($parametro["tipo"] == "text")) { |
---|
| 1253 | $valor = "'" . $valor . "'"; |
---|
| 1254 | } |
---|
| 1255 | if (($obrigatorio == "f") && ($parametro["valor"] == "")) { |
---|
| 1256 | $valor = "null"; |
---|
| 1257 | } |
---|
| 1258 | $sql = str_replace("{" . $idparametro. "}",$valor,$sql); |
---|
| 1259 | } |
---|
| 1260 | $this->sql = $sql; |
---|
| 1261 | } |
---|
[6413] | 1262 | |
---|
[5307] | 1263 | protected function isParametro($idparametro) { |
---|
| 1264 | $ret = false; |
---|
| 1265 | foreach ($this->arrparametros as $parametro) { |
---|
| 1266 | if ($parametro['idparametro'] == $idparametro) { |
---|
| 1267 | $ret = true; |
---|
| 1268 | } |
---|
| 1269 | } |
---|
| 1270 | return $ret; |
---|
| 1271 | } |
---|
[6413] | 1272 | |
---|
[5307] | 1273 | protected function isTotalizador($idcoluna) { |
---|
| 1274 | $ret = false; |
---|
| 1275 | foreach ($this->totalizadores as $totalizador) { |
---|
| 1276 | if ($totalizador['idcoluna'] == $idcoluna) { |
---|
| 1277 | $ret = true; |
---|
| 1278 | } |
---|
| 1279 | } |
---|
| 1280 | return $ret; |
---|
| 1281 | } |
---|
[6413] | 1282 | |
---|
[5307] | 1283 | function adicionarTotalizador($idcolunas,$condicaototal = "1",$condicaosubtotal = "1") { |
---|
[6413] | 1284 | |
---|
[5307] | 1285 | $colunas = explode(",",$idcolunas); |
---|
| 1286 | foreach ($colunas as $idcoluna) { |
---|
| 1287 | $erro = false; |
---|
| 1288 | if (!$this->isColuna($idcoluna)) { |
---|
| 1289 | $this->adicionarErro("adicionarTotalizador()<br>$idcoluna nᅵo ᅵ uma coluna adicionada na Listagem.",false); |
---|
| 1290 | $erro = true; |
---|
| 1291 | } |
---|
| 1292 | if (!$erro) { |
---|
[6413] | 1293 | |
---|
[5307] | 1294 | $totalizador = array(); |
---|
| 1295 | $totalizador["idcoluna"] = $idcoluna; |
---|
| 1296 | $totalizador["condicaototal"] = $condicaototal; |
---|
| 1297 | $totalizador["condicaosubtotal"] = $condicaosubtotal; |
---|
| 1298 | $this->totalizadores[$idcoluna] = $totalizador; |
---|
[6413] | 1299 | |
---|
[5307] | 1300 | } |
---|
| 1301 | } |
---|
[6413] | 1302 | |
---|
[5307] | 1303 | } |
---|
[6413] | 1304 | |
---|
[5307] | 1305 | protected function escreveArquivo($arquivo) { |
---|
| 1306 | if ($this->_temarquivocsv) { |
---|
| 1307 | fwrite($arquivo, $this->_txtarquivo); |
---|
| 1308 | $this->_txtarquivo = ""; |
---|
| 1309 | } |
---|
| 1310 | } |
---|
[6413] | 1311 | |
---|
| 1312 | |
---|
[5307] | 1313 | /** |
---|
| 1314 | * Funᅵᅵo para desenhar as Linhas da Listagem. |
---|
[6413] | 1315 | * |
---|
[5307] | 1316 | * @return HTML |
---|
| 1317 | */ |
---|
| 1318 | protected function escreveLinhas() { |
---|
| 1319 | $html = ""; |
---|
| 1320 | $colspan = count($this->colunas); |
---|
| 1321 | $idtd = 0; |
---|
| 1322 | $handle = ""; |
---|
| 1323 | //$nomeform = $this->formpesquisa->getNome(); |
---|
[6413] | 1324 | |
---|
[5307] | 1325 | if ($this->_temarquivocsv) { |
---|
| 1326 | if (!$this->issublist) { |
---|
| 1327 | $tmpfname = $this->_tmp_file_path . "Listagem_" . $this->idlistagem . "_" . time() . ".csv"; |
---|
| 1328 | $handle = fopen($tmpfname, "a+"); |
---|
| 1329 | } |
---|
| 1330 | } |
---|
[6413] | 1331 | |
---|
[5307] | 1332 | if ($this->showthead) { |
---|
| 1333 | if ($this->_exiberesultados) { |
---|
| 1334 | echo "\n\t\t<tr class='tableTituloColunas'>"; |
---|
| 1335 | foreach ($this->colunas as $col) { |
---|
| 1336 | $fwidth = $col->getWidth(true); |
---|
| 1337 | $addvisivel = ""; |
---|
| 1338 | if (!$col->getVisibilidade()) { |
---|
| 1339 | $addvisivel = " style='display: none;' "; |
---|
| 1340 | } |
---|
| 1341 | // if ($col->getVisibilidade()) { |
---|
| 1342 | echo "\n\t\t\t<td id='td_tit_" . $col->getIdColuna() . "' $fwidth align='center'$addvisivel><h3>". $col->getNome() . "</h3></td>"; |
---|
| 1343 | // } |
---|
| 1344 | } |
---|
| 1345 | echo "\n\t\t</tr>"; |
---|
| 1346 | } |
---|
| 1347 | if ($this->_temarquivocsv) { |
---|
| 1348 | foreach ($this->_colunasarquivo as $idcoluna) { |
---|
| 1349 | foreach ($this->colunas as $coluna) { |
---|
| 1350 | if ($coluna->getIdColuna() == $idcoluna) { |
---|
| 1351 | $this->_txtarquivo .= '"' . $coluna->getNome() . '"' . ";"; |
---|
| 1352 | } |
---|
| 1353 | } |
---|
| 1354 | } |
---|
| 1355 | $this->_txtarquivo .= "\n"; |
---|
| 1356 | $this->escreveArquivo($handle); |
---|
[6413] | 1357 | |
---|
[5307] | 1358 | } |
---|
| 1359 | } |
---|
| 1360 | |
---|
| 1361 | if (!$this->issublist) { |
---|
| 1362 | $cnt = 0; |
---|
| 1363 | $this->subListagem->setQuantidadeRegistrosListagemPrincipal($this->getQuantidadeRegistros()); |
---|
| 1364 | } else { |
---|
| 1365 | $cnt = $this->getQuantidadeRegistrosListagemPrincipal(); |
---|
| 1366 | } |
---|
| 1367 | $temcheck = false; |
---|
| 1368 | if (count($this->dados)) { |
---|
| 1369 | |
---|
| 1370 | $arrtotais = array(); |
---|
| 1371 | $arrsubtotais = array(); |
---|
| 1372 | $arrsubtotais_todos = array(); |
---|
| 1373 | $lastagrupamento = ""; |
---|
| 1374 | $cntagrupamentos = 0; |
---|
| 1375 | $arragrupamentos = array(); |
---|
| 1376 | $newagrupamento = ""; |
---|
| 1377 | |
---|
| 1378 | $mostroutituloagrupamento = false; |
---|
| 1379 | |
---|
| 1380 | if (!$this->_isarray) { |
---|
| 1381 | pg_result_seek($this->dados, 0); |
---|
| 1382 | } |
---|
| 1383 | $class= ""; |
---|
[6413] | 1384 | |
---|
[5307] | 1385 | $qtdlinhas = 0; |
---|
[6413] | 1386 | |
---|
[5307] | 1387 | $qtd_registros = $this->getQuantidadeRegistros(); |
---|
| 1388 | |
---|
| 1389 | |
---|
| 1390 | for ($qtd_reg = 1;$qtd_reg <= $qtd_registros; $qtd_reg++) { |
---|
[6413] | 1391 | |
---|
[5307] | 1392 | if ($this->_isarray) { |
---|
| 1393 | if ($qtd_reg == 1) { |
---|
[6413] | 1394 | reset($this->dados); |
---|
[5307] | 1395 | $linha = current($this->dados); |
---|
| 1396 | } else { |
---|
| 1397 | $linha = next($this->dados); |
---|
| 1398 | } |
---|
| 1399 | } else { |
---|
| 1400 | $linha = pg_fetch_array($this->dados); |
---|
| 1401 | } |
---|
[6413] | 1402 | |
---|
[5307] | 1403 | $cnt = $cnt + 1; |
---|
[6413] | 1404 | |
---|
[5307] | 1405 | $qtdlinhas = $qtdlinhas + 1; |
---|
[6413] | 1406 | |
---|
[5307] | 1407 | $class = ( $class == "tdc" ) ? "tde" : "tdc"; |
---|
| 1408 | |
---|
| 1409 | if (count($this->linhasagrupamento)) { |
---|
| 1410 | foreach ($this->linhasagrupamento as $coluna) { |
---|
| 1411 | $fwidth = $coluna->getWidth(true); |
---|
| 1412 | $falign = $coluna->getVAlign(true); |
---|
| 1413 | $addnowrap = ""; |
---|
| 1414 | $align = $coluna->getAlign(); |
---|
| 1415 | if ($coluna->getNowrap()) { $addnowrap = "nowrap"; } |
---|
| 1416 | $htmlcoluna = $coluna->getHtml($linha,$this->arrindicadores,$class,$qtdlinhas - 1); |
---|
| 1417 | if ($coluna->getNome() == "") { |
---|
| 1418 | $tituloagrupamento = $htmlcoluna; |
---|
| 1419 | } else { |
---|
| 1420 | $tituloagrupamento = $coluna->replaceValorLinha($coluna->getNome(),$linha); |
---|
| 1421 | } |
---|
[6413] | 1422 | |
---|
[5307] | 1423 | if ($this->agruparAlfabeticamente) { |
---|
| 1424 | $tituloagrupamento = strtoupper(substr($tituloagrupamento,0,1)); |
---|
| 1425 | $newagrupamento = $tituloagrupamento; |
---|
| 1426 | $align="center"; |
---|
| 1427 | } else { |
---|
| 1428 | $newagrupamento = strtoupper($htmlcoluna); |
---|
| 1429 | } |
---|
[6413] | 1430 | |
---|
| 1431 | |
---|
| 1432 | |
---|
[5307] | 1433 | //AGRUPAMENTO |
---|
| 1434 | $cntcheckspan = 0; |
---|
| 1435 | if ($newagrupamento != $lastagrupamento) { |
---|
| 1436 | $cntagrupamentos = $cntagrupamentos + 1; |
---|
[6413] | 1437 | |
---|
[5307] | 1438 | $arragrupamentos[$cntagrupamentos] = $newagrupamento; |
---|
[6413] | 1439 | |
---|
[5307] | 1440 | //TOTALIZADOR SUB-TOTAL DO AGRUPAMENTO. |
---|
| 1441 | if ($this->exibesubtotais) { |
---|
| 1442 | if (count($this->totalizadores)) { |
---|
| 1443 | if ($cntagrupamentos != 1) { |
---|
| 1444 | if ($this->_exiberesultados) { |
---|
| 1445 | echo "\n\t\t<tr class='tableRodapeModelo2'>"; |
---|
| 1446 | } |
---|
| 1447 | $mostroutotal = false; |
---|
| 1448 | foreach ($this->colunas as $coluna) { |
---|
| 1449 | $idcol = $coluna->getIdColuna(); |
---|
| 1450 | if ($this->isTotalizador($coluna->getIdColuna())) { |
---|
[6413] | 1451 | if (!$mostroutotal) { |
---|
| 1452 | $addtexto = "<h3>" . $this->msgsubtotalizador . "</h3>"; |
---|
| 1453 | $txtarquivotexto = $this->msgsubtotalizador ; |
---|
| 1454 | $mostroutotal = true; |
---|
[5307] | 1455 | } else { |
---|
| 1456 | $addtexto = ""; |
---|
| 1457 | } |
---|
[6413] | 1458 | if ($cntcheckspan) { |
---|
[5307] | 1459 | if ($this->_temarquivocsv) { |
---|
| 1460 | for ($j=1; $j<= $cntcheckspan; $j++) { |
---|
| 1461 | if ($j == $cntcheckspan) { |
---|
| 1462 | $this->_txtarquivo .= $txtarquivotexto; |
---|
| 1463 | } |
---|
| 1464 | $this->_txtarquivo .= ";"; |
---|
| 1465 | } |
---|
[6413] | 1466 | } |
---|
| 1467 | } |
---|
[5307] | 1468 | $cntcheckspan = 0; |
---|
| 1469 | $addvisivel = ""; |
---|
| 1470 | if (!$coluna->getVisibilidade()) { |
---|
| 1471 | $addvisivel = " style='display: none;' "; |
---|
| 1472 | } |
---|
| 1473 | if ($coluna->getTipo() == "hora") { |
---|
| 1474 | $subtotal_valor = $arrsubtotais[$coluna->getIdColuna()]; |
---|
| 1475 | } else { |
---|
| 1476 | if ($this->_totalizadorprecisao != 0) { |
---|
| 1477 | $subtotal_valor = number_format($arrsubtotais[$coluna->getIdColuna()],$this->_totalizadorprecisao,",","."); |
---|
| 1478 | } else { |
---|
| 1479 | $subtotal_valor = $arrsubtotais[$coluna->getIdColuna()]; |
---|
| 1480 | } |
---|
| 1481 | } |
---|
| 1482 | if ($this->_exiberesultados) { |
---|
[6413] | 1483 | echo "<td id='subtotal_" . $idcol . "_$cntagrupamentos' align='right'$addvisivel>$addtexto<h3>" . $subtotal_valor . "</h3></td>"; |
---|
[5307] | 1484 | } |
---|
| 1485 | $this->_txtarquivo .= $subtotal_valor . ";"; |
---|
| 1486 | $arrsubtotais[$coluna->getIdColuna()] = 0; |
---|
| 1487 | $arrsubtotais_todos[$cntagrupamentos][$coluna->getIdColuna()] = 0; |
---|
| 1488 | } else { |
---|
| 1489 | $addvisivel = ""; |
---|
| 1490 | if (!$coluna->getVisibilidade()) { |
---|
| 1491 | $addvisivel = " style='display: none;' "; |
---|
| 1492 | } |
---|
| 1493 | if ($this->_exiberesultados) { |
---|
[6413] | 1494 | echo "<td id='subtotal_$idcol" . "_" . $cntagrupamentos . "' $addvisivel></td>"; |
---|
[5307] | 1495 | } |
---|
| 1496 | } |
---|
| 1497 | } |
---|
| 1498 | // if ($cntcheckspan) { echo "<td colspan='$cntcheckspan'> </td>";} |
---|
| 1499 | if ($this->_exiberesultados) { |
---|
| 1500 | echo "\n\t\t</tr>"; |
---|
| 1501 | } |
---|
| 1502 | if ($this->_temarquivocsv) { |
---|
| 1503 | $this->_txtarquivo .= "\n"; |
---|
| 1504 | $this->escreveArquivo($handle); |
---|
| 1505 | } |
---|
| 1506 | } |
---|
| 1507 | } |
---|
| 1508 | } |
---|
[6413] | 1509 | |
---|
| 1510 | |
---|
| 1511 | |
---|
[5307] | 1512 | if (($this->_repetirtituloagrupamento) || (!$mostroutituloagrupamento)) { |
---|
| 1513 | if ($this->_exiberesultados) { |
---|
| 1514 | echo "\n\t\t<tr>"; |
---|
| 1515 | echo "\n\t\t\t<td class='tableSubTitulo' colspan='$colspan' align='$align'><h3>" . $tituloagrupamento . "</h3></td>"; |
---|
| 1516 | echo "\n\t\t</tr>"; |
---|
| 1517 | $class = "tdc"; |
---|
| 1518 | } |
---|
| 1519 | if ($this->_temarquivocsv) { |
---|
| 1520 | $this->_txtarquivo .= '"' . $tituloagrupamento . '"' . ";\n"; |
---|
| 1521 | } |
---|
| 1522 | $mostroutituloagrupamento = true; |
---|
| 1523 | } |
---|
[6413] | 1524 | |
---|
[5307] | 1525 | } |
---|
[6413] | 1526 | |
---|
[5307] | 1527 | } |
---|
[6413] | 1528 | |
---|
[5307] | 1529 | } |
---|
[6413] | 1530 | |
---|
| 1531 | |
---|
[5307] | 1532 | if (count($this->colunas)) { |
---|
[6413] | 1533 | |
---|
[5307] | 1534 | $addvisivellinha = ""; |
---|
| 1535 | if ($this->_exibelinhasvazias == false) { |
---|
| 1536 | $exibe_linha = false; |
---|
| 1537 | $addvisivellinha = " style='display: none;' "; |
---|
| 1538 | foreach ($this->colunas as $coluna) { |
---|
| 1539 | $htmlcoluna = $coluna->getHtml($linha,$this->arrindicadores,$class,$idtd); |
---|
| 1540 | if (trim($htmlcoluna) != "") { |
---|
| 1541 | $exibe_linha = true; |
---|
| 1542 | $addvisivellinha = ""; |
---|
| 1543 | } |
---|
| 1544 | } |
---|
| 1545 | } |
---|
[6413] | 1546 | |
---|
[5307] | 1547 | //if ($exibe_linha) { |
---|
| 1548 | if ($this->_exiberesultados) { |
---|
| 1549 | echo "\n\t\t<tr class='" . $class . "' onmouseout=\"this.className='" . $class . "'\" onmouseover=\"this.className='" . $class . "Over'\" $addvisivellinha>"; |
---|
| 1550 | } |
---|
| 1551 | foreach ($this->colunas as $coluna) { |
---|
| 1552 | if ($this->_exiberesultados) { |
---|
| 1553 | $fwidth = $coluna->getWidth(true); |
---|
| 1554 | $falign = $coluna->getVAlign(true); |
---|
| 1555 | $addnowrap = ""; |
---|
| 1556 | $align = $coluna->getAlign(); |
---|
| 1557 | if ($coluna->getNowrap()) { $addnowrap = " nowrap"; } |
---|
[6413] | 1558 | |
---|
[5307] | 1559 | if ($this->issublist) { |
---|
| 1560 | $idtd = $cnt -2; |
---|
| 1561 | } else { |
---|
| 1562 | $idtd = $cnt -1; |
---|
| 1563 | } |
---|
| 1564 | $htmlcoluna = $coluna->getHtml($linha,$this->arrindicadores,$class,$idtd); |
---|
[6413] | 1565 | |
---|
[5307] | 1566 | if (($coluna->getTipo() == "check") && ($htmlcoluna != "")) { $temcheck = true; $this->temcheck = true; } |
---|
| 1567 | } |
---|
[6413] | 1568 | if ($this->isTotalizador($coluna->getIdColuna())) { |
---|
[5307] | 1569 | $condicaototal = $this->totalizadores[$coluna->getIdColuna()]["condicaototal"]; |
---|
| 1570 | $condicaosubtotal = $this->totalizadores[$coluna->getIdColuna()]["condicaosubtotal"]; |
---|
| 1571 | $htmlvalorcoluna = $coluna->getValorHTML($linha); |
---|
[6413] | 1572 | if ($condicaototal != "1") { |
---|
[5307] | 1573 | $ret_total = $coluna->validaCondicao($condicaototal,$linha,false); |
---|
| 1574 | } else { |
---|
| 1575 | $ret_total = true; |
---|
| 1576 | } |
---|
[6413] | 1577 | |
---|
[5307] | 1578 | if ($ret_total) { |
---|
| 1579 | $tipo_coluna = $coluna->getTipo(); |
---|
| 1580 | if (isset($arrtotais[$coluna->getIdColuna()])) { |
---|
| 1581 | if ($tipo_coluna != "hora") { |
---|
| 1582 | $arrtotais[$coluna->getIdColuna()] += $htmlvalorcoluna; |
---|
| 1583 | } else { |
---|
| 1584 | $arrhoras = array($arrtotais[$coluna->getIdColuna()],$htmlvalorcoluna); |
---|
| 1585 | $arrtotais[$coluna->getIdColuna()] = $this->somaIntervaloHoras($arrhoras); |
---|
| 1586 | } |
---|
| 1587 | } else { |
---|
| 1588 | if ($tipo_coluna != "hora") { |
---|
| 1589 | $arrtotais[$coluna->getIdColuna()] = 0; |
---|
| 1590 | $arrtotais[$coluna->getIdColuna()] += $htmlvalorcoluna; |
---|
| 1591 | } else { |
---|
| 1592 | $arrtotais[$coluna->getIdColuna()] = "00:00:00"; |
---|
| 1593 | $arrhoras = array($arrtotais[$coluna->getIdColuna()],$htmlvalorcoluna); |
---|
| 1594 | $arrtotais[$coluna->getIdColuna()] = $this->somaIntervaloHoras($arrhoras); |
---|
| 1595 | } |
---|
| 1596 | } |
---|
| 1597 | } |
---|
[6413] | 1598 | if ($condicaosubtotal != "1") { |
---|
[5307] | 1599 | $ret_subtotal = $coluna->validaCondicao($condicaosubtotal,$linha,false); |
---|
| 1600 | } else { |
---|
| 1601 | $ret_subtotal = true; |
---|
| 1602 | } |
---|
| 1603 | if ($ret_subtotal) { |
---|
| 1604 | $tipo_coluna = $coluna->getTipo(); |
---|
| 1605 | if (isset($arrsubtotais[$coluna->getIdColuna()])) { |
---|
| 1606 | if ($tipo_coluna != "hora") { |
---|
| 1607 | $arrsubtotais[$coluna->getIdColuna()] += $htmlvalorcoluna; |
---|
| 1608 | } else { |
---|
| 1609 | $arrhoras = array($arrsubtotais[$coluna->getIdColuna()],$htmlvalorcoluna); |
---|
| 1610 | $arrsubtotais[$coluna->getIdColuna()] = $this->somaIntervaloHoras($arrhoras); |
---|
| 1611 | } |
---|
| 1612 | } else { |
---|
| 1613 | if ($tipo_coluna != "hora") { |
---|
| 1614 | $arrsubtotais[$coluna->getIdColuna()] = 0; |
---|
| 1615 | $arrsubtotais[$coluna->getIdColuna()] += $htmlvalorcoluna; |
---|
| 1616 | } else { |
---|
| 1617 | $arrsubtotais[$coluna->getIdColuna()] = "00:00:00"; |
---|
| 1618 | $arrhoras = array($arrsubtotais[$coluna->getIdColuna()],$htmlvalorcoluna); |
---|
| 1619 | $arrsubtotais[$coluna->getIdColuna()] = $this->somaIntervaloHoras($arrhoras); |
---|
| 1620 | } |
---|
| 1621 | } |
---|
| 1622 | if (isset($arrsubtotais_todos[$cntagrupamentos][$coluna->getIdColuna()])) { |
---|
| 1623 | $arrsubtotais_todos[$cntagrupamentos][$coluna->getIdColuna()] += $htmlvalorcoluna; |
---|
| 1624 | } else { |
---|
| 1625 | if ($tipo_coluna != "hora") { |
---|
| 1626 | $arrsubtotais_todos[$cntagrupamentos][$coluna->getIdColuna()] = 0; |
---|
| 1627 | } else { |
---|
| 1628 | $arrsubtotais_todos[$cntagrupamentos][$coluna->getIdColuna()] = "00:00:00"; |
---|
| 1629 | } |
---|
| 1630 | } |
---|
| 1631 | } |
---|
| 1632 | } |
---|
| 1633 | $addvisivel = ""; |
---|
| 1634 | if (!$coluna->getVisibilidade()) { |
---|
| 1635 | $addvisivel = " style='display: none;' "; |
---|
| 1636 | } |
---|
[6413] | 1637 | |
---|
[5307] | 1638 | if ($this->_exiberesultados) { |
---|
| 1639 | echo "\n\t\t\t<td id='td_" . $coluna->getIdColuna() . "_" . $idtd . "' " . $falign . $fwidth . " align='$align'" . $addnowrap . $addvisivel . ">" . nl2br($htmlcoluna) . "</td>"; |
---|
| 1640 | } |
---|
| 1641 | } |
---|
[6413] | 1642 | |
---|
| 1643 | |
---|
| 1644 | |
---|
[5307] | 1645 | //ARQUIVO CSV |
---|
| 1646 | if ($this->_temarquivocsv) { |
---|
| 1647 | foreach ($this->_colunasarquivo as $colunaarq) { |
---|
| 1648 | foreach ($this->colunas as $coluna) { |
---|
| 1649 | if ($coluna->getIdColuna() == $colunaarq) { |
---|
| 1650 | $htmlarquivo = $coluna->getTextoArquivo($linha,$this->arrindicadores); |
---|
| 1651 | $this->_txtarquivo .= '"' . $htmlarquivo . '"' . ";"; |
---|
| 1652 | } |
---|
| 1653 | } |
---|
| 1654 | } |
---|
| 1655 | } |
---|
| 1656 | if ($this->_exiberesultados) { |
---|
| 1657 | echo "\n\t\t</tr>"; |
---|
| 1658 | } |
---|
| 1659 | // } |
---|
| 1660 | } else { |
---|
| 1661 | $this->adicionarErro("Nenhuma coluna foi adicionada.",true); |
---|
| 1662 | } |
---|
[6413] | 1663 | |
---|
| 1664 | |
---|
[5307] | 1665 | if ($this->_temarquivocsv) { |
---|
| 1666 | $this->_txtarquivo .= "\n"; |
---|
| 1667 | $this->escreveArquivo($handle); |
---|
| 1668 | } |
---|
[6413] | 1669 | |
---|
[5307] | 1670 | //LINHA ADICIONAL DE OBSERVAᅵᅵES, (DETALHAMENTO) |
---|
| 1671 | if (count($this->linhasdetalhamento)) { |
---|
| 1672 | foreach ($this->linhasdetalhamento as $coluna) { |
---|
| 1673 | $fwidth = $coluna->getWidth(true); |
---|
| 1674 | $falign = $coluna->getVAlign(true); |
---|
| 1675 | $addnowrap = ""; |
---|
| 1676 | $align = $coluna->getAlign(); |
---|
| 1677 | if ($coluna->getNowrap()) { $addnowrap = " nowrap"; } |
---|
| 1678 | $htmlcoluna = ""; |
---|
| 1679 | $htmlcoluna = $coluna->getHtml($linha,$this->arrindicadores,$class,$qtdlinhas - 1); |
---|
[6413] | 1680 | |
---|
[5307] | 1681 | if ($this->_exiberesultados) { |
---|
| 1682 | if ($htmlcoluna == "") { |
---|
| 1683 | $addvisivel = " style='display: none;' "; |
---|
| 1684 | } |
---|
| 1685 | echo "\n\t\t<tr id='tr_" . $coluna->getIdColuna() . "_" . $idtd . "' class='" . $class . "' onmouseout=\"this.className='" . $class . "'\" onmouseover=\"this.className='" . $class . "Over'\"" . $addvisivel. ">"; |
---|
| 1686 | echo "\n\t\t\t<td id='td_" . $coluna->getIdColuna() . "_" . $idtd . "' " . $falign . $fwidth . $addnowrap . " align='$align' colspan='" . count($this->colunas) . "'>" . $htmlcoluna . "</td>"; |
---|
| 1687 | echo "\n\t\t</tr>"; |
---|
[6413] | 1688 | |
---|
[5307] | 1689 | } |
---|
| 1690 | if ($this->_temarquivocsv) { |
---|
| 1691 | $htmlarquivo = $coluna->getTextoArquivo($linha,$this->arrindicadores); |
---|
| 1692 | if ($htmlarquivo != "") { |
---|
| 1693 | $this->_txtarquivo .= $htmlarquivo . ";\n"; |
---|
| 1694 | } |
---|
| 1695 | } |
---|
| 1696 | } |
---|
[6413] | 1697 | |
---|
[5307] | 1698 | } |
---|
[6413] | 1699 | |
---|
[5307] | 1700 | $lastagrupamento = $newagrupamento; |
---|
| 1701 | //$lastval = ""; |
---|
| 1702 | } |
---|
| 1703 | } |
---|
[6413] | 1704 | |
---|
[5307] | 1705 | $this->escreveArquivo($handle); |
---|
| 1706 | |
---|
[6413] | 1707 | if (count($this->totalizadores)) { |
---|
[5307] | 1708 | if ($this->exibesubtotais) { |
---|
| 1709 | if ($this->_exiberesultados) { |
---|
| 1710 | echo "\n\t\t<tr class='tableRodapeModelo1'>"; |
---|
| 1711 | } |
---|
| 1712 | $mostrousubtotal = false; |
---|
| 1713 | $cntcheckspan = 0; |
---|
| 1714 | if ($cntagrupamentos != 1) { |
---|
| 1715 | $cntagrupamentos = $cntagrupamentos + 1; |
---|
| 1716 | } |
---|
| 1717 | foreach ($this->colunas as $coluna) { |
---|
| 1718 | $idcol = $coluna->getIdColuna(); |
---|
| 1719 | if ($this->isTotalizador($coluna->getIdColuna())) { |
---|
[6413] | 1720 | |
---|
| 1721 | if (!$mostrousubtotal) { |
---|
| 1722 | $addtexto = "<h3>" . $this->msgsubtotalizador . "</h3>"; |
---|
| 1723 | $mostrousubtotal = true; |
---|
[5307] | 1724 | $txtarquivotexto = $this->msgsubtotalizador; |
---|
| 1725 | } else { |
---|
| 1726 | $addtexto = ""; |
---|
| 1727 | } |
---|
[6413] | 1728 | if ($cntcheckspan) { |
---|
| 1729 | |
---|
[5307] | 1730 | if ($this->_temarquivocsv) { |
---|
| 1731 | for ($j=1; $j<= $cntcheckspan; $j++) { |
---|
| 1732 | if ($j == $cntcheckspan) { |
---|
| 1733 | $this->_txtarquivo .= $txtarquivotexto; |
---|
| 1734 | } |
---|
| 1735 | $this->_txtarquivo .= ";"; |
---|
| 1736 | } |
---|
[6413] | 1737 | } |
---|
| 1738 | } |
---|
[5307] | 1739 | $cntcheckspan = 0; |
---|
| 1740 | $addvisivel = ""; |
---|
| 1741 | if (!$coluna->getVisibilidade()) { |
---|
| 1742 | $addvisivel = " style='display: none;' "; |
---|
| 1743 | } |
---|
| 1744 | if ($coluna->getTipo() == "hora") { |
---|
| 1745 | $subtotal_valor = $arrsubtotais[$coluna->getIdColuna()]; |
---|
| 1746 | } else { |
---|
| 1747 | if ($this->_totalizadorprecisao != 0) { |
---|
| 1748 | $subtotal_valor = number_format($arrsubtotais[$coluna->getIdColuna()],$this->_totalizadorprecisao,",","."); |
---|
| 1749 | } else { |
---|
| 1750 | $subtotal_valor = $arrsubtotais[$coluna->getIdColuna()]; |
---|
| 1751 | } |
---|
| 1752 | } |
---|
| 1753 | if ($this->_exiberesultados) { |
---|
[6413] | 1754 | echo "<td id='subtotal_$idcol" . "_" . $cntagrupamentos . "' align='right'$addvisivel>$addtexto <h3>" . $subtotal_valor . "</h3></td>"; |
---|
[5307] | 1755 | } |
---|
| 1756 | if (in_array($idcol,$this->_colunasarquivo)) { |
---|
| 1757 | $this->_txtarquivo .= $subtotal_valor . ";"; |
---|
| 1758 | } |
---|
| 1759 | } else { |
---|
| 1760 | $addvisivel = ""; |
---|
| 1761 | if (!$coluna->getVisibilidade()) { |
---|
| 1762 | $addvisivel = " style='display: none;' "; |
---|
| 1763 | } |
---|
| 1764 | if ($this->_exiberesultados) { |
---|
[6413] | 1765 | echo "<td id='subtotal_$idcol" . "_" . $cntagrupamentos . "' $addvisivel></td>"; |
---|
[5307] | 1766 | } |
---|
| 1767 | if ($this->_temarquivocsv) { |
---|
| 1768 | if (in_array($idcol,$this->_colunasarquivo)) { |
---|
| 1769 | $this->_txtarquivo .= ";"; |
---|
| 1770 | } |
---|
| 1771 | } |
---|
| 1772 | } |
---|
| 1773 | } |
---|
| 1774 | if ($this->_exiberesultados) { |
---|
| 1775 | echo "\n\t\t</tr>"; |
---|
| 1776 | } |
---|
| 1777 | if ($this->_temarquivocsv) { |
---|
| 1778 | $this->_txtarquivo .= "\n"; |
---|
| 1779 | } |
---|
| 1780 | } |
---|
[6413] | 1781 | |
---|
| 1782 | |
---|
| 1783 | |
---|
[5307] | 1784 | if ($this->_exibetotalizadores) { |
---|
| 1785 | if ($this->_exiberesultados) { |
---|
| 1786 | echo "\n\t\t<tr class='tableRodapeModelo2'>"; |
---|
| 1787 | } |
---|
| 1788 | $mostroutotal = false; |
---|
| 1789 | $cntcheckspan = 0; |
---|
| 1790 | foreach ($this->colunas as $coluna) { |
---|
| 1791 | |
---|
[6413] | 1792 | |
---|
[5307] | 1793 | $idcol = $coluna->getIdColuna(); |
---|
| 1794 | if ($this->isTotalizador($coluna->getIdColuna())) { |
---|
[6413] | 1795 | if (!$mostroutotal) { |
---|
| 1796 | $addtexto = "<h3>" . $this->msgtotalizador . "</h3>"; |
---|
| 1797 | $mostroutotal = true; |
---|
[5307] | 1798 | $txtarquivotexto = $this->msgtotalizador; |
---|
| 1799 | } else { |
---|
| 1800 | $addtexto = ""; |
---|
| 1801 | } |
---|
[6413] | 1802 | |
---|
| 1803 | if ($cntcheckspan) { |
---|
[5307] | 1804 | if ($this->_temarquivocsv) { |
---|
| 1805 | for ($j=1; $j<= $cntcheckspan; $j++) { |
---|
| 1806 | if ($j == $cntcheckspan) { |
---|
| 1807 | $this->_txtarquivo .= $txtarquivotexto; |
---|
| 1808 | } |
---|
| 1809 | $this->_txtarquivo .= ";"; |
---|
| 1810 | } |
---|
[6413] | 1811 | } |
---|
| 1812 | } |
---|
[5307] | 1813 | $cntcheckspan = 0; |
---|
| 1814 | $addvisivel = ""; |
---|
| 1815 | if (!$coluna->getVisibilidade()) { |
---|
| 1816 | $addvisivel = " style='display: none;' "; |
---|
| 1817 | } |
---|
| 1818 | if ($coluna->getTipo() == "hora") { |
---|
| 1819 | $total_valor = $arrtotais[$coluna->getIdColuna()]; |
---|
| 1820 | } else { |
---|
| 1821 | if ($this->_totalizadorprecisao != 0) { |
---|
| 1822 | $total_valor = number_format($arrtotais[$coluna->getIdColuna()],$this->_totalizadorprecisao,",","."); |
---|
| 1823 | } else { |
---|
| 1824 | $total_valor = $arrtotais[$coluna->getIdColuna()]; |
---|
| 1825 | } |
---|
| 1826 | } |
---|
| 1827 | if ($this->_exiberesultados) { |
---|
| 1828 | echo "<td id='total_$idcol' align='right'$addvisivel>$addtexto <h3>" . $total_valor . "</h3></td>"; |
---|
| 1829 | } |
---|
| 1830 | if ($this->_temarquivocsv) { |
---|
| 1831 | if (in_array($idcol,$this->_colunasarquivo)) { |
---|
| 1832 | $this->_txtarquivo .= $total_valor . ";"; |
---|
| 1833 | } |
---|
| 1834 | } |
---|
| 1835 | } else { |
---|
| 1836 | $addvisivel = ""; |
---|
| 1837 | if (!$coluna->getVisibilidade()) { |
---|
| 1838 | $addvisivel = " style='display: none;' "; |
---|
| 1839 | } |
---|
| 1840 | if ($this->_exiberesultados) { |
---|
| 1841 | echo "<td id='total_$idcol' $addvisivel> </td>"; |
---|
| 1842 | } |
---|
| 1843 | if ($this->_temarquivocsv) { |
---|
| 1844 | if (in_array($idcol,$this->_colunasarquivo)) { |
---|
| 1845 | $this->_txtarquivo .= ";"; |
---|
| 1846 | } |
---|
[6413] | 1847 | } |
---|
[5307] | 1848 | } |
---|
| 1849 | } |
---|
| 1850 | if ($this->_exiberesultados) { |
---|
| 1851 | echo "\n\t\t</tr>"; |
---|
| 1852 | } |
---|
| 1853 | if ($this->_temarquivocsv) { |
---|
| 1854 | $this->_txtarquivo .= "\n"; |
---|
[6413] | 1855 | } |
---|
[5307] | 1856 | } |
---|
| 1857 | } |
---|
[6413] | 1858 | |
---|
[5307] | 1859 | $this->escreveArquivo($handle); |
---|
[6413] | 1860 | |
---|
| 1861 | |
---|
[5307] | 1862 | if (!$this->issublist) { |
---|
| 1863 | if (is_object($this->subListagem)) { |
---|
| 1864 | if ($this->subListagem->getQuantidadeRegistros()) { |
---|
[6413] | 1865 | $this->subListagem->gerarArquivoXLS(); |
---|
[5307] | 1866 | ob_start(); |
---|
| 1867 | $this->subListagem->desenhar(); |
---|
| 1868 | $htmllist = ob_get_contents(); |
---|
| 1869 | ob_end_clean(); |
---|
| 1870 | if ($this->_temarquivocsv) { |
---|
| 1871 | $this->_txtarquivo .= $this->subListagem->getTextoArquivoCSV(); |
---|
| 1872 | } |
---|
| 1873 | if ($this->_exiberesultados) { |
---|
| 1874 | echo "<tr><td colspan='$colspan'>"; |
---|
[6413] | 1875 | echo $htmllist; |
---|
[5307] | 1876 | echo "</td></tr>"; |
---|
| 1877 | } |
---|
| 1878 | if ($this->subListagem->getTemCheckBox()) { |
---|
| 1879 | $temcheck = true; |
---|
| 1880 | $this->temcheck = true; |
---|
| 1881 | } |
---|
| 1882 | } |
---|
| 1883 | } |
---|
| 1884 | } |
---|
[6413] | 1885 | |
---|
[5307] | 1886 | $this->escreveArquivo($handle); |
---|
[6413] | 1887 | |
---|
| 1888 | |
---|
| 1889 | /* |
---|
| 1890 | EXIBIR OS BOTï¿œES DE + E - PARA QUANDO POSSUIR COLUNAS COM CHECKBOXES. COMENTADO POR QUE Nï¿œO FUNCIONA SE TIVER MAIS DE UM FORMULï¿œRIO NA MESMA JANELA. */ |
---|
[5307] | 1891 | if (!$this->issublist) { |
---|
| 1892 | if ($temcheck) { |
---|
| 1893 | if (count($this->colunas)) { |
---|
| 1894 | echo "\n\t\t<tr class='tableRodapeModelo3'>"; |
---|
| 1895 | $cntcheckspan = 0; |
---|
| 1896 | $qtd = $this->getQuantidadeRegistros(); |
---|
| 1897 | foreach ($this->colunas as $coluna) { |
---|
| 1898 | if ($coluna->getTipo() == "check") { |
---|
| 1899 | if ($cntcheckspan) { echo "<td colspan='$cntcheckspan'> </td>";} |
---|
| 1900 | $cntcheckspan = 0; |
---|
| 1901 | $idlistagem = $this->getIdListagem(); |
---|
| 1902 | echo "\n\t\t\t<td align=center nowrap> "; |
---|
| 1903 | echo "<input type='button' class='botao' name='btselecionar' onclick=\"ListagemSelecionachecks(1,'" . $qtd. "','" . $coluna->getIdColuna() . "_" . $idlistagem . "_');\" value=' + '> "; |
---|
| 1904 | echo "<input type='button' class='botao' name='btdesselecionar' onclick=\"ListagemSelecionachecks(0,'" . $qtd. "','" . $coluna->getIdColuna() . "_" . $idlistagem . "_');\" value=' - '> "; |
---|
| 1905 | echo "\n\t\t\t</td>"; |
---|
| 1906 | } else { |
---|
| 1907 | $cntcheckspan = $cntcheckspan + 1; |
---|
| 1908 | } |
---|
| 1909 | } |
---|
| 1910 | if ($cntcheckspan) { echo "<td colspan='$cntcheckspan'> </td>";} |
---|
| 1911 | echo "\n\t\t</tr>"; |
---|
| 1912 | } |
---|
| 1913 | } |
---|
| 1914 | } |
---|
| 1915 | |
---|
[6413] | 1916 | |
---|
| 1917 | |
---|
[5307] | 1918 | if ($this->_exibeqtdregistros) { |
---|
| 1919 | if ($this->_exiberesultados) { |
---|
| 1920 | echo "\n\t\t<tr class='tableRodapeModelo3'>\n\t\t\t<td colspan='$colspan' align=center>"; |
---|
| 1921 | } |
---|
| 1922 | $qtd = $this->getQuantidadeRegistros(); |
---|
| 1923 | if ($cnt == 0) { |
---|
| 1924 | if ($this->_exiberesultados) { |
---|
| 1925 | echo $this->msgnenhumresultado; |
---|
| 1926 | } |
---|
| 1927 | } else { |
---|
| 1928 | if ($this->_exiberesultados) { |
---|
| 1929 | echo "<b>$qtd</b> " . $this->msgregistros; |
---|
| 1930 | } |
---|
| 1931 | if ($this->_temarquivocsv) { |
---|
| 1932 | $this->_txtarquivo .= $qtd . " " . $this->msgregistros; |
---|
| 1933 | } |
---|
| 1934 | } |
---|
| 1935 | if ($this->_exiberesultados) { |
---|
| 1936 | echo "</td>\n\t\t</tr>"; |
---|
| 1937 | } |
---|
[6413] | 1938 | |
---|
[5307] | 1939 | } |
---|
[6413] | 1940 | |
---|
[5307] | 1941 | $this->escreveArquivo($handle); |
---|
| 1942 | |
---|
[6413] | 1943 | |
---|
[5307] | 1944 | if ($this->_temarquivocsv) { |
---|
| 1945 | if (!$this->issublist) { |
---|
[6413] | 1946 | |
---|
| 1947 | |
---|
[5307] | 1948 | fclose($handle); |
---|
[6413] | 1949 | |
---|
[5307] | 1950 | $link=$tmpfname; |
---|
[6413] | 1951 | |
---|
[5307] | 1952 | if ($cnt != 0) { |
---|
| 1953 | echo "\n\t\t<tr class='tableRodapeModelo3'>\n\t\t\t<td colspan='$colspan' align=center>"; |
---|
| 1954 | //echo '<input type="button" name="btn_arquivoxls" value="Versï¿œo em XLS" class="botao" onclick="window.open(\'gera_csv_to_excel.php?arquivocsv=/' . $link . '\');" style="width: 90px;">'; |
---|
| 1955 | echo ' <input type="button" name="btn_arquivoxls" value="Download CSV" class="botao" onclick="window.open(\'' . $this->_url_base_path . '/downloads.php?arquivo=' . $link . '\');" style="width:120px;">'; |
---|
| 1956 | echo "</td>\n\t\t</tr>"; |
---|
| 1957 | } else { |
---|
| 1958 | if ($this->_exibeqtdregistros) { |
---|
| 1959 | echo "\n\t\t<tr class='tableRodapeModelo3'>\n\t\t\t<td colspan='$colspan' align=center>"; |
---|
| 1960 | echo $this->msgnenhumresultado; |
---|
| 1961 | echo "</td>\n\t\t</tr>"; |
---|
| 1962 | } |
---|
| 1963 | } |
---|
| 1964 | } |
---|
| 1965 | /* //FORMULï¿œRIO |
---|
| 1966 | $this->form->addButton("btn_arquivo","Arquivo .XLS"); |
---|
| 1967 | $this->form->addCampoAcao("btn_arquivo","onclick","window.open('gera_csv_to_excel.php?arquivocsv=" . $link . "');"); |
---|
| 1968 | $this->form->addQuadro("quadro_arquivo"); |
---|
[6413] | 1969 | $this->form->addQuadroButton("quadro_arquivo","btn_arquivo"); |
---|
[5307] | 1970 | */ |
---|
| 1971 | } |
---|
[6413] | 1972 | |
---|
| 1973 | /* |
---|
| 1974 | FORMULï¿œRIO |
---|
[5307] | 1975 | if (!$this->issublist) { |
---|
| 1976 | if ($cnt != 0) { |
---|
| 1977 | if (($temcheck) || ($this->_temarquivocsv)) { |
---|
| 1978 | echo "\n\t\t<tr>\n\t\t\t<td colspan='$colspan' align=center style='padding: 0px;'>"; |
---|
| 1979 | ob_start(); |
---|
| 1980 | $this->form->desenhaCampos(); |
---|
| 1981 | $this->form->displayErros(); |
---|
| 1982 | $htmlform = ob_get_contents(); |
---|
[6413] | 1983 | |
---|
[5307] | 1984 | ob_end_clean(); |
---|
| 1985 | echo $htmlform; |
---|
| 1986 | } |
---|
| 1987 | } |
---|
| 1988 | echo "</td>\n\t\t</tr>"; |
---|
| 1989 | ob_start(); |
---|
| 1990 | $this->form->fechaForm(); |
---|
| 1991 | $htmlform = ob_get_contents(); |
---|
[6413] | 1992 | ob_end_clean(); |
---|
[5307] | 1993 | } */ |
---|
| 1994 | //echo $htmlform; |
---|
[6413] | 1995 | |
---|
[5307] | 1996 | $this->arrtotais = $arrtotais; |
---|
| 1997 | $this->arrsubtotais = $arrsubtotais_todos; |
---|
| 1998 | $this->arragrupamentos = $arragrupamentos; |
---|
[6413] | 1999 | |
---|
| 2000 | |
---|
[5307] | 2001 | } |
---|
[6413] | 2002 | |
---|
[5307] | 2003 | public function setDebug($value) { |
---|
| 2004 | $this->_debug = $value; |
---|
| 2005 | } |
---|
[6413] | 2006 | |
---|
[5307] | 2007 | /** |
---|
| 2008 | * Funᅵᅵo usada internamente para adicionar um erro ao formulᅵrio. |
---|
| 2009 | * |
---|
| 2010 | * @param string $msgerro Mensagem de Erro |
---|
| 2011 | * @param boolean $fatal Se ᅵ um erro Fatal = true () |
---|
| 2012 | * */ |
---|
| 2013 | protected function adicionarErro($msgerro,$fatal = false) { |
---|
| 2014 | if ($fatal) { $this->_errors = array(); } |
---|
| 2015 | $erro = array("msgerro" => $msgerro,"fatal" => $fatal); |
---|
| 2016 | array_push($this->_errors,$erro); |
---|
[6413] | 2017 | |
---|
[5307] | 2018 | if ($fatal) { |
---|
| 2019 | $this->escreveErros(); |
---|
| 2020 | exit; |
---|
| 2021 | } |
---|
[6413] | 2022 | |
---|
[5307] | 2023 | } |
---|
| 2024 | |
---|
| 2025 | |
---|
| 2026 | /** |
---|
| 2027 | * Funᅵᅵo usada para exibir os erros. |
---|
| 2028 | * |
---|
| 2029 | * */ |
---|
| 2030 | protected function escreveErros() { |
---|
| 2031 | if ($this->_debug) { |
---|
| 2032 | if (count($this->_errors)) { |
---|
| 2033 | echo "<style type='text/css'> |
---|
| 2034 | #erros { background: #BAD0E5; color: #000000; font-size: 12px; Verdana,Arial,Helvetica,sans-serif; font-weight: bold; margin: 15px; padding: 0px; padding-top: 3px; padding-bottom: 3px; text-align: left; } " . |
---|
| 2035 | " .erro { background: #E6EAEE; color: #000000; font-size: 12px; Verdana,Arial,Helvetica,sans-serif; font-weight: bold; margin: 2px; padding: 5px; text-align: left; }" . |
---|
| 2036 | "</style>"; |
---|
| 2037 | echo "<div id='erros'>"; |
---|
| 2038 | foreach ($this->_errors as $erro) { |
---|
| 2039 | echo "<div class=erro>"; |
---|
| 2040 | |
---|
| 2041 | if ($erro["fatal"]) { |
---|
| 2042 | $addmsg = "<span style='color: #990000;'><b>ERRO:</b></span> "; |
---|
| 2043 | } else { |
---|
| 2044 | $addmsg = "ERRO: "; |
---|
| 2045 | } |
---|
| 2046 | echo $addmsg . $erro["msgerro"]; |
---|
| 2047 | echo "</div>"; |
---|
| 2048 | } |
---|
| 2049 | echo "</div>"; |
---|
| 2050 | } |
---|
| 2051 | } else { |
---|
| 2052 | echo "MODO DEBUG ESTᅵ DESATIVADO."; |
---|
| 2053 | } |
---|
| 2054 | } |
---|
[6413] | 2055 | |
---|
[5307] | 2056 | public function gerarArquivoXLS($colunasarquivo = "") { |
---|
| 2057 | if ($colunasarquivo == "") { |
---|
| 2058 | $arcolunas = array(); |
---|
| 2059 | foreach ($this->colunas as $coluna) { |
---|
| 2060 | if ($coluna->getVisibilidade()) { |
---|
| 2061 | $colunasarquivo .= $coluna->getIdColuna() . ","; |
---|
[6413] | 2062 | } |
---|
[5307] | 2063 | } |
---|
| 2064 | $colunasarquivo = substr($colunasarquivo,0,strlen($colunasarquivo)-1); |
---|
| 2065 | } |
---|
| 2066 | $arcolunas = explode(",",$colunasarquivo); |
---|
| 2067 | $txtarquivo = ""; |
---|
| 2068 | $this->_colunasarquivo = $arcolunas; |
---|
[6413] | 2069 | $this->_temarquivocsv = true; |
---|
[5307] | 2070 | } |
---|
[6413] | 2071 | |
---|
[5307] | 2072 | /* |
---|
| 2073 | * Funᅵᅵo utilizada pra somar intervalos de Horas */ |
---|
| 2074 | public function somaIntervaloHoras($arrValores){ |
---|
[6413] | 2075 | |
---|
[5307] | 2076 | // Somando separadamente os valores |
---|
| 2077 | foreach($arrValores as $valor){ |
---|
[6413] | 2078 | |
---|
[5307] | 2079 | $arrTmp = explode(':',$valor); |
---|
[6413] | 2080 | |
---|
[5307] | 2081 | $seg += $arrTmp[2]; |
---|
| 2082 | $min += $arrTmp[1]; |
---|
[6413] | 2083 | $hor += $arrTmp[0]; |
---|
[5307] | 2084 | } |
---|
[6413] | 2085 | |
---|
[5307] | 2086 | // Tratando os segundos |
---|
| 2087 | if( $seg >= 60){ |
---|
[6413] | 2088 | |
---|
[5307] | 2089 | $min += floor($seg / 60) ; |
---|
[6413] | 2090 | |
---|
[5307] | 2091 | while($seg >= 60){ |
---|
[6413] | 2092 | |
---|
[5307] | 2093 | $seg = $seg - 60; |
---|
| 2094 | } |
---|
[6413] | 2095 | |
---|
[5307] | 2096 | } |
---|
| 2097 | // Tratando os minutos |
---|
| 2098 | if( $min >= 60){ |
---|
[6413] | 2099 | |
---|
[5307] | 2100 | $hor += floor($min / 60) ; |
---|
[6413] | 2101 | |
---|
[5307] | 2102 | while($min >= 60){ |
---|
[6413] | 2103 | |
---|
[5307] | 2104 | $min = $min - 60; |
---|
| 2105 | } |
---|
[6413] | 2106 | |
---|
[5307] | 2107 | } |
---|
[6413] | 2108 | |
---|
[5307] | 2109 | return str_pad($hor,2,'0',STR_PAD_LEFT).':'.str_pad($min,2,'0',STR_PAD_LEFT).':'.str_pad($seg,2,'0',STR_PAD_LEFT); |
---|
| 2110 | } |
---|
[6413] | 2111 | |
---|
[5307] | 2112 | /** |
---|
| 2113 | * Funᅵᅵo que Retorna se a listagem Possui um checkBox adicionado. |
---|
| 2114 | */ |
---|
| 2115 | public function getTemCheckBox() { |
---|
| 2116 | return $this->temcheck; |
---|
| 2117 | } |
---|
[6413] | 2118 | |
---|
[5307] | 2119 | /** |
---|
[6413] | 2120 | * Funᅵᅵo que retorna o array com os Totalizadores. |
---|
[5307] | 2121 | */ |
---|
| 2122 | public function getTotais() { |
---|
| 2123 | return $this->arrtotais; |
---|
| 2124 | } |
---|
[6413] | 2125 | |
---|
[5307] | 2126 | /** |
---|
| 2127 | * Funᅵᅵo que Retorna o array com os Sub-Totalizadores. |
---|
| 2128 | */ |
---|
| 2129 | public function getSubTotais() { |
---|
| 2130 | return $this->arrsubtotais; |
---|
| 2131 | } |
---|
[6413] | 2132 | |
---|
[5307] | 2133 | /** |
---|
| 2134 | * Funᅵᅵo que Retorna o array com os Sub-Totalizadores. |
---|
| 2135 | */ |
---|
| 2136 | public function getAgrupamentos() { |
---|
| 2137 | return $this->arragrupamentos; |
---|
| 2138 | } |
---|
[6413] | 2139 | |
---|
[5307] | 2140 | /** |
---|
| 2141 | * Funᅵᅵo Interna Utilizada quando a Listagem possui uma sublistagem para guardar quantos registros a listagem principal tem. |
---|
| 2142 | */ |
---|
| 2143 | protected function setQuantidadeRegistrosListagemPrincipal($value) { |
---|
[6413] | 2144 | $this->_qtdregistroslistagemprincipal = $value; |
---|
[5307] | 2145 | } |
---|
[6413] | 2146 | |
---|
[5307] | 2147 | /** |
---|
| 2148 | * Funᅵᅵo Interna Utilizada quando a Listagem possui uma sublistagem para retornar quantos registros a listagem principal tem. |
---|
| 2149 | */ |
---|
| 2150 | protected function getQuantidadeRegistrosListagemPrincipal() { |
---|
| 2151 | return $this->_qtdregistroslistagemprincipal; |
---|
| 2152 | } |
---|
[6413] | 2153 | |
---|
[5307] | 2154 | protected function getTextoArquivoCSV() { |
---|
| 2155 | return $this->_txtarquivo; |
---|
| 2156 | } |
---|
[6413] | 2157 | |
---|
[5307] | 2158 | public function autoAdicionarColunas() { |
---|
| 2159 | $i = pg_num_fields($this->dados); |
---|
| 2160 | for ($j = 0; $j < $i; $j++) { |
---|
| 2161 | $fieldname = pg_field_name($this->dados, $j); |
---|
| 2162 | $tipo = pg_field_type($this->dados, $j); |
---|
[6413] | 2163 | $this->adicionarColuna("coluna_" .$j,"$fieldname","{" . $fieldname . "}","text","left"); |
---|
[5307] | 2164 | } |
---|
| 2165 | } |
---|
| 2166 | } |
---|
[6413] | 2167 | ?> |
---|