[5307] | 1 | <?php |
---|
| 2 | |
---|
| 3 | $sql = "select lstidlistagem, lstnome from listagem.listagem where lstoid = $lstoid"; |
---|
| 4 | $res = pg_query($conn,$sql); |
---|
| 5 | $dados= pg_fetch_array($res); |
---|
| 6 | $lstidlistagem = $dados["lstidlistagem"]; |
---|
| 7 | |
---|
| 8 | $form = new Formulario("FrmCadListagem"); |
---|
| 9 | $form->setAction($BASE_URL); |
---|
| 10 | $listagem = new Listagem($idlistagem,"",$conn); |
---|
| 11 | $listagem->setDebug(true); |
---|
| 12 | $listagem->setUrlBasePath($GLOBALS['phpgw_info']['server']['webserver_url'] . "/workflow/inc/report"); |
---|
| 13 | $listagem->carregarIDListagem($lstidlistagem); |
---|
| 14 | |
---|
| 15 | $sql_par = "select |
---|
| 16 | lspoid, |
---|
| 17 | lsplstoid, |
---|
| 18 | lspidparametro, |
---|
| 19 | lsptitulo, |
---|
| 20 | lsptipo, |
---|
| 21 | lspvalor_padrao, |
---|
| 22 | lspobrigatorio |
---|
| 23 | from |
---|
| 24 | listagem.listagem_parametro |
---|
| 25 | where |
---|
| 26 | lsplstoid = $lstoid |
---|
| 27 | order by lspoid "; |
---|
| 28 | $resu_par = pg_query($conn,$sql_par); |
---|
| 29 | |
---|
| 30 | $form->adicionarHidden("lstoid",$lstoid); |
---|
| 31 | $form->adicionarHidden("abaMenu",$abaMenu); |
---|
| 32 | $form->adicionarHidden("acao","editar"); |
---|
| 33 | $exibeform = false; |
---|
| 34 | |
---|
| 35 | while ($parametro = pg_fetch_object($resu_par)) { |
---|
| 36 | $idparametro = $parametro->lspidparametro; |
---|
| 37 | $titulo = $parametro->lsptitulo; |
---|
| 38 | |
---|
| 39 | |
---|
| 40 | if ($titulo == "") { |
---|
| 41 | $titulo = $idparametro; |
---|
| 42 | } |
---|
| 43 | $tipo = $parametro->lsptipo; |
---|
| 44 | $obrigatorio = ($parametro->lspobrigatorio == "t") ? true : false; |
---|
| 45 | $valor_padrao = $parametro->lspvalor_padrao; |
---|
| 46 | |
---|
| 47 | $exibeform = true; |
---|
| 48 | |
---|
| 49 | $valor = $_POST[$idparametro]; |
---|
| 50 | if ($tipo == "data") { |
---|
| 51 | $valor = $_POST[$idparametro . "_inicio"]; |
---|
| 52 | } |
---|
| 53 | if (($valor == "") && ((!isset($_POST[$idparametro])) && (!isset($_POST[$idparametro . "_inicio"])))) { $valor = $valor_padrao; } |
---|
| 54 | |
---|
| 55 | if ($obrigatorio) { $titulo .= " *"; } |
---|
| 56 | |
---|
| 57 | $form->adicionarCampo($idparametro,$tipo,$titulo. ":",$idparametro . ":",$valor,$obrigatorio); |
---|
| 58 | |
---|
| 59 | $listagem->setParametro($idparametro,$valor); |
---|
| 60 | |
---|
| 61 | $addobr = ""; |
---|
| 62 | if ($obrigatorio) { $addobr = " //OBRIGATÓRIO"; } |
---|
| 63 | |
---|
| 64 | $adicionarcodigo .= "\$report->setParam('$idparametro',\$$valor_$idparametro);$addobr<br>"; |
---|
| 65 | } |
---|
| 66 | |
---|
| 67 | if ($exibeform) { |
---|
| 68 | $form->adicionarQuadro("quadro1","Formulário de Pesquisa"); |
---|
| 69 | $form->adicionarSubmit("quadro1","btn_cadastrar","Pesquisar","pesquisar"); |
---|
| 70 | $form->desenhar(); |
---|
| 71 | } |
---|
| 72 | |
---|
| 73 | |
---|
| 74 | |
---|
| 75 | $html = "<center> |
---|
| 76 | <table class='tableMoldura'> |
---|
| 77 | <tr class='tableSubTitulo'><td><h2>CÓDIGO FONTE:</h2></td></tr> |
---|
| 78 | <tr><td> |
---|
| 79 | <br> |
---|
| 80 | <div style='margin: 10px;'> |
---|
| 81 | \$report = Factory::newInstance('wf_report');<br> |
---|
| 82 | \$report->loadReport('$lstidlistagem');<br>$adicionarcodigo |
---|
| 83 | \$html_report = \$report->getHTML();<br> |
---|
| 84 | \$this->addViewVar('report_result', \$html_report); |
---|
| 85 | <br><br> |
---|
| 86 | </div> |
---|
| 87 | </td></tr> |
---|
| 88 | </table> |
---|
| 89 | </center>"; |
---|
| 90 | |
---|
| 91 | echo $html; |
---|
| 92 | |
---|
| 93 | $listagem->desenhar(); |
---|
| 94 | $consulta = $listagem->getSQL(); |
---|
| 95 | |
---|
| 96 | |
---|
| 97 | $res = pg_query($conn,"EXPLAIN " . $consulta); |
---|
| 98 | if (pg_num_rows($res)) { |
---|
| 99 | $tr .= "<table class='tableMoldura'> |
---|
| 100 | <tr class='tableSubTitulo'><td colspan=5><h2>EXPLAIN</h2></td></tr> |
---|
| 101 | <tr class='tableTituloColunas'> |
---|
| 102 | <td><h3>Possíveis problemas encontrados no plano de consulta</h3></td> |
---|
| 103 | </tr>"; |
---|
| 104 | |
---|
| 105 | $qtd = 0; |
---|
| 106 | $qtd1 = 0; |
---|
| 107 | while ($plan = pg_fetch_array($res)) { |
---|
| 108 | $qtd1 = $qtd1+1; |
---|
| 109 | if ((stristr($plan["QUERY PLAN"],"Seq Scan")) || ($qtd1 == 1)) { |
---|
| 110 | $class = ( $class == "tdc" ) ? "tde" : "tdc"; |
---|
| 111 | $tr .= "<tr class='$class'>"; |
---|
| 112 | $tr .= "<td>" .$plan["QUERY PLAN"]. "</td>"; |
---|
| 113 | $tr .= "</tr>"; |
---|
| 114 | $qtd = $qtd + 1; |
---|
| 115 | } |
---|
| 116 | } |
---|
| 117 | if ($qtd == 0) { $msgres = "Nenhum Resultado Encontrado."; } else { $msgres = "$qtd resultado(s) encontrado(s)."; } |
---|
| 118 | $tr .= "<tr class='tableRodapeModelo1'><td colspan=5 align='center'><h3>$msgres</h3></td></tr>"; |
---|
| 119 | $tr .= "</table>"; |
---|
| 120 | } |
---|
| 121 | |
---|
| 122 | echo "<center><table class='tableMoldura'> |
---|
| 123 | <tr class='tableSubTitulo'><td><h2>CONSULTA EXECUTADA:</h2></td></tr> |
---|
| 124 | <tr><td> |
---|
| 125 | <br> |
---|
| 126 | <div style='margin: 10px;'> |
---|
| 127 | $consulta |
---|
| 128 | </div> |
---|
| 129 | <br><center>$tr</center> |
---|
| 130 | </td></tr> |
---|
| 131 | </table></center>"; |
---|
| 132 | |
---|
| 133 | ?> |
---|