function metadata($table = "")
 {
     $count = 0;
     $id = 0;
     $res = array();
     if ($table) {
         $this->connect();
         $id = pg_exec($this->Link_ID, "SELECT * FROM {$table}");
         if ($id < 0) {
             $this->Error = pg_ErrorMessage($id);
             $this->Errno = 1;
             $this->halt("Metadata query failed.");
         }
     } else {
         $id = $this->Query_ID;
         if (!$id) {
             $this->halt("No query specified.");
         }
     }
     $count = pg_NumFields($id);
     for ($i = 0; $i < $count; $i++) {
         $res[$i]["table"] = $table;
         $res[$i]["name"] = pg_FieldName($id, $i);
         $res[$i]["type"] = pg_FieldType($id, $i);
         $res[$i]["len"] = pg_FieldSize($id, $i);
         $res[$i]["flags"] = "";
     }
     if ($table) {
         pg_FreeResult($id);
     }
     return $res;
 }
 function num_fields($query_id)
 {
     return $query_id ? pg_NumFields($query_id) : 0;
 }
Example #3
0
 function metadata($table)
 {
     $count = 0;
     $id = 0;
     $res = array();
     $this->connect();
     $id = pg_exec($this->Link_ID, "select * from {$table} LIMIT 1");
     if ($id < 0) {
         $this->Error = pg_ErrorMessage($id);
         $this->Errno = 1;
         $this->Errors->addError("Metadata query failed: " . $this->Error);
         return 0;
     }
     $count = pg_NumFields($id);
     for ($i = 0; $i < $count; $i++) {
         $res[$i]["table"] = $table;
         $res[$i]["name"] = pg_FieldName($id, $i);
         $res[$i]["type"] = pg_FieldType($id, $i);
         $res[$i]["len"] = pg_FieldSize($id, $i);
         $res[$i]["flags"] = "";
     }
     pg_FreeResult($id);
     return $res;
 }
 function metadata($table = "", $iArr = 0)
 {
     $count = 0;
     $id = 0;
     $res = array();
     if ($table) {
         $this->connect();
         $id = pg_exec($this->conn, "select * from {$table}");
         if ($id < 0) {
             $this->Error = pg_ErrorMessage($id);
             $this->Errno = 1;
             $this->halt("Metadata query failed.");
         }
     } else {
         $id = $this->rs[$iArr];
         if (!$id) {
             $this->halt("No query specified.");
         }
     }
     $count = pg_NumFields($id);
     for ($i = 0; $i < $count; $i++) {
         $res['fields'][$i]["name"] = pg_FieldName($id, $i);
         $res['fields'][$i]["type"] = pg_FieldType($id, $i);
         $res['fields'][$i]["pkey"] = "0";
     }
     $this->query("select a.attname,    t.typname, case when a.attlen = -1 then 0 " . "else a.attlen end + case when a.atttypmod = -1 then 0 " . "else (a.atttypmod - 4) end ," . "case when d.description isnull THEN a.attname else d.description end , " . "a.attnum from pg_class c " . "inner join pg_attribute a ON (c.oid = a.attrelid AND a.attnum > 0) " . "INNER JOIN pg_type t ON (a.atttypid = t.oid) " . "LEFT OUTER JOIN pg_description d ON (c.relfilenode = d.objoid AND a.attnum = d.objsubid) " . "where c.relname = '" . $table . "' order by a.attnum");
     for ($i = 0; $i < $this->numrecords(); $i++) {
         $res['fields'][$i]["size"] = $this->f($i, 2);
         $res['fields'][$i]["desc"] = $this->f($i, 3);
     }
     $j = 0;
     for ($i = 0; $i < $count; $i++) {
         $this->query("SELECT relname, indkey[" . $i . "] " . "FROM pg_catalog.pg_index join pg_catalog.pg_class " . "ON pg_index.indrelid = pg_class.oid " . "WHERE indisprimary=true " . "AND relname = '" . $table . "';", 1);
         if ($this->f(0, 1, 1) != "0") {
             $res['fields'][$this->f(0, 1, 1) - 1]["pkey"] = "1";
             $res['pkey'][$j++] = pg_FieldName($id, $this->f(0, 1, 1) - 1);
         }
     }
     if ($table) {
         pg_FreeResult($id);
     }
     $this->query(' SELECT cl.relname AS table_name, a.attname AS column_name, ' . 'clf.relname AS foreign_table_name, af.attname AS foreign_column_name ' . 'FROM pg_attribute a ' . 'JOIN pg_class cl ON a.attrelid = cl.oid AND cl.relkind = \'r\'::"char" ' . 'JOIN pg_namespace n ON n.oid = cl.relnamespace ' . 'JOIN pg_constraint ct ON a.attrelid = ct.conrelid AND ct.confrelid <> 0::oid ' . 'AND ct.conkey[1] = a.attnum ' . 'JOIN pg_class clf ON ct.confrelid = clf.oid AND clf.relkind = \'r\'::"char" ' . 'JOIN pg_namespace nf ON nf.oid = clf.relnamespace ' . 'JOIN pg_attribute af ON af.attrelid = ct.confrelid AND af.attnum = ct.confkey[1] ' . 'WHERE cl.relname = \'' . $table . '\';');
     for ($i = 0; $i < $this->numrecords(); $i++) {
         $res['foreign'][$i]["idcol"] = $this->f($i, 'column_name');
         $res['foreign'][$i]["foretable"] = $this->f($i, 'foreign_table_name');
         $res['foreign'][$i]["forecol"] = $this->f($i, 'foreign_column_name');
     }
     $this->disconnect();
     return $res;
 }
 function metadata($table)
 {
     $count = 0;
     $id = 0;
     $res = array();
     $this->connect();
     $id = pg_exec($this->Link_ID, "select * from {$table}");
     if ($id < 0) {
         $this->Error = pg_ErrorMessage($id);
         $this->Errno = 1;
         $this->halt('Metadata query failed.');
     }
     $count = pg_NumFields($id);
     for ($i = 0; $i < $count; $i++) {
         $res[$i]['table'] = $table;
         $res[$i]['name'] = pg_FieldName($id, $i);
         $res[$i]['type'] = pg_FieldType($id, $i);
         $res[$i]['len'] = pg_FieldSize($id, $i);
         $res[$i]['flags'] = '';
     }
     pg_FreeResult($id);
     return $res;
 }
function db_lovrot($query, $numlinhas, $arquivo = "", $filtro = "%", $aonde = "_self", $campos_layer = "", $NomeForm = "NoMe", $variaveis_repassa = array(), $automatico = true, $totalizacao = array())
{
    //Observação : Quando utilizar o parametro automatico, coloque no parametro NomeForm o seguinte "NoMe" e em variaveis_repassa array().
    //#00#//db_lovrot
    //#10#//Esta funcao é utilizada para mostrar registros na tela, podendo páginar os dados
    //#15#//db_lovrot($query,$numlinhas,$arquivo="",$filtro="%",$aonde="_self",$campos_layer="",$NomeForm="NoMe",$variaveis_repassa=array());
    //#20#//$query               Select que será executado
    //#20#//$numlinhas           Número de linhas a serem mostradas
    //#20#//$arquivo             Arquivo que será executado quando der um click em uma linha
    //#20#//                     Na versão com iframe deverá ser colocado "()"
    //#20#//$filtro              Filtro que será gerado, normamente ""
    //#20#//$aonde               Nome da função que será executada quando der um click
    //#20#//$campos_layer        Campos que serão colocados na layer quando passar o mouse ( não esta implementado )
    //#20#//$NomeForm            Nome do formulário para colocar variáveis complementares Padrão = "NoMe"
    //#20#//$variaveis_repassa   Array com as variáveis a serem reoassadas para o programa
    //#99#//Exemplo:
    //#99#//$js_funcao = "";
    //#99#//db_lovrot("select z01_nome from cgm limit 1","()","",$js_funcao);
    //#99#//
    //#99#//O cabeçalho da tabela o sistema pega pelo nome do campo e busca na documentação, colcando o label
    //#99#//Quando não desejar colocar o label da documentacao, o nome do campo deverá ser iniciado com dl_ e o sistema retirará
    //#99#//estes caracteres e colocará o primeiro caracter em maiusculo
    //#99#//Criado parametro novo, $totalizacao = array() que devere fornecer os campos que desejar fazer somatorio, conforme
    //#99#//exemplo abaixo:
    //#99#//
    //#99#//$totalizacao["e60_vlremp"] = "e60_vlremp"; totaliza o campo
    //#99#//$totalizacao["e60_vlranu"] = "e60_vlranu"; totaliza o campo
    //#99#//$totalizacao["e60_vlrpag"] = "e60_vlrpag"; totaliza o campo
    //#99#//$totalizacao["e60_vlrliq"] = "e60_vlrliq"; totaliza o campo
    //#99#//$totalizacao["dl_saldo"] = "dl_saldo";     totaliza o campo ( neste caso, o campo é um alias no sql)
    //#99#//$totalizacao["totalgeral"] = "z01_nome";   indica qual o campo sera colocado o total
    global $BrowSe;
    //cor do cabecalho
    global $db_corcabec;
    $db_corcabec = $db_corcabec == "" ? "#CDCDFF" : $db_corcabec;
    //cor de fundo de cada registro
    global $cor1;
    global $cor2;
    $cor1 = $GLOBALS['w01_corfundomenu'];
    $cor2 = $GLOBALS['w01_corfundomenuativo'];
    $mensagem = "Clique Aqui";
    $cor1 = $cor1 == "" ? "#97B5E6" : $cor1;
    $cor2 = $cor2 == "" ? "#E796A4" : $cor2;
    global $HTTP_POST_VARS;
    $tot_registros = "tot_registros" . $NomeForm;
    $offset = "offset" . $NomeForm;
    //recebe os valores do campo hidden
    if (isset($HTTP_POST_VARS["totreg" . $NomeForm])) {
        ${$tot_registros} = $HTTP_POST_VARS["totreg" . $NomeForm];
    } else {
        ${$tot_registros} = 0;
    }
    if (isset($HTTP_POST_VARS["offset" . $NomeForm])) {
        ${$offset} = $HTTP_POST_VARS["offset" . $NomeForm];
    } else {
        ${$offset} = 0;
    }
    if (isset($HTTP_POST_VARS["recomecar"])) {
        $recomecar = $HTTP_POST_VARS["recomecar"];
    }
    // se for a primeira vez que é rodado, pega o total de registros e guarda no campo hidden
    if (empty(${$tot_registros}) && !empty($query) || isset($recomecar)) {
        if (isset($recomecar)) {
            $query = db_getsession("dblov_query_inicial");
        }
        $Dd1 = "disabled";
        if (count($totalizacao) > 0 || isset($totalizacao_rep)) {
            $total_campos = "";
            $sep_total_campos = "";
            reset($totalizacao);
            for ($j = 0; $j < count($totalizacao); $j++) {
                if (key($totalizacao) == $totalizacao[key($totalizacao)]) {
                    $total_campos .= $sep_total_campos . "sum(" . $totalizacao[key($totalizacao)] . ") as " . $totalizacao[key($totalizacao)];
                    $sep_total_campos = ",";
                }
                next($totalizacao);
            }
            reset($totalizacao);
            $tot = db_query("select count(*),{$total_campos}\n\tfrom ({$query}) as temp");
        } else {
            $tot = db_query("select count(*) from ({$query}) as temp");
        }
        //$tot = 0;
        db_putsession("dblov_query_inicial", $query);
        ${$tot_registros} = pg_result($tot, 0, 0);
        if (${$tot_registros} == 0) {
            $Dd2 = "disabled";
        }
    }
    if (isset($HTTP_POST_VARS["nova_quantidade_linhas"]) && $HTTP_POST_VARS["nova_quantidade_linhas"] != '') {
        $HTTP_POST_VARS["nova_quantidade_linhas"] = $HTTP_POST_VARS["nova_quantidade_linhas"] + 0;
        $numlinhas = $HTTP_POST_VARS["nova_quantidade_linhas"];
    }
    // testa qual botao foi pressionado
    if (isset($HTTP_POST_VARS["pri" . $NomeForm])) {
        ${$offset} = 0;
        $Dd1 = "disabled";
        $query = str_replace("\\", "", $HTTP_POST_VARS["filtroquery"]);
    } else {
        if (isset($HTTP_POST_VARS["ant" . $NomeForm])) {
            // if(isset("filtroquery"]);
            $query = str_replace("\\", "", @$HTTP_POST_VARS["filtroquery"]);
            if (${$offset} <= $numlinhas) {
                ${$offset} = 0;
                $Dd1 = "disabled";
            } else {
                ${$offset} = ${$offset} - $numlinhas;
            }
        } else {
            if (isset($HTTP_POST_VARS["prox" . $NomeForm])) {
                $query = str_replace("\\", "", $HTTP_POST_VARS["filtroquery"]);
                //    if($numlinhas >= ($$tot_registros - $$offset - $numlinhas)) {
                if (${$offset} + $numlinhas * 2 >= ${$tot_registros}) {
                    $Dd2 = "disabled";
                }
                if ($numlinhas >= ${$tot_registros} - ${$offset}) {
                    //$$offset = $$tot_registros - $numlinhas;
                    if (${$tot_registros} - ${$offset} - $numlinhas >= $numlinhas) {
                        ${$offset} = $numlinhas;
                    } else {
                        ${$offset} = ${$offset} + $numlinhas;
                    }
                    if (${$offset} > ${$tot_registros}) {
                        ${$offset} = 0;
                    }
                    $Dd2 = "disabled";
                } else {
                    ${$offset} = ${$offset} + $numlinhas;
                }
            } else {
                if (isset($HTTP_POST_VARS["ult" . $NomeForm])) {
                    $query = str_replace("\\", "", $HTTP_POST_VARS["filtroquery"]);
                    ${$offset} = ${$tot_registros} - $numlinhas;
                    if (${$offset} < 0) {
                        ${$offset} = 0;
                    }
                    $Dd2 = "disabled";
                } else {
                    reset($HTTP_POST_VARS);
                    for ($i = 0; $i < sizeof($HTTP_POST_VARS); $i++) {
                        $ordem_lov = substr(key($HTTP_POST_VARS), 0, 11);
                        if ($ordem_lov == 'ordem_dblov') {
                            $query = str_replace("\\", "", $HTTP_POST_VARS["filtroquery"]);
                            $campo = substr(key($HTTP_POST_VARS), 11);
                            $ordem_ordenacao = '';
                            if (isset($HTTP_POST_VARS['ordem_lov_anterior'])) {
                                if ($HTTP_POST_VARS['ordem_lov_anterior'] == $HTTP_POST_VARS[key($HTTP_POST_VARS)]) {
                                    $ordem_ordenacao = 'desc';
                                }
                            }
                            if ($HTTP_POST_VARS["codigo_pesquisa"] != '') {
                                $query_anterior = $query;
                                $query_novo_filtro = "select * from (" . $query . ") as x where " . $campo . " ILIKE '" . $HTTP_POST_VARS["codigo_pesquisa"] . "%' order by " . $campo . ' ' . $ordem_ordenacao;
                                $query = $query_novo_filtro;
                            } else {
                                if ($HTTP_POST_VARS["distinct_pesquisa"] == '1') {
                                    $query_anterior = $query;
                                    $query = "select distinct on (" . $campo . ") * from (" . $query . ") as x order by " . $campo . " " . $ordem_ordenacao;
                                    $query_novo_filtro = $query;
                                } else {
                                    $query = "select * from (" . $query . ") as x order by " . $campo . " " . $ordem_ordenacao;
                                }
                            }
                            ${$offset} = 0;
                            break;
                        }
                        next($HTTP_POST_VARS);
                    }
                }
            }
        }
    }
    $filtroquery = $query;
    // executa a query e cria a tabela
    if ($query == "") {
        exit;
    }
    $query .= " limit {$numlinhas} offset " . ${$offset};
    $result = db_query($query);
    $NumRows = pg_numrows($result);
    if ($NumRows == 0) {
        if (isset($query_anterior)) {
            echo "<script>alert('Não existem dados para este filtro');</script>";
            if (count($totalizacao) > 0 || isset($totalizacao_rep)) {
                $total_campos = "";
                $sep_total_campos = "";
                reset($totalizacao);
                for ($j = 0; $j < count($totalizacao); $j++) {
                    if (key($totalizacao) == $totalizacao[key($totalizacao)]) {
                        $total_campos .= $sep_total_campos . "sum(" . $totalizacao[key($totalizacao)] . ") as " . $totalizacao[key($totalizacao)];
                        $sep_total_campos = ",";
                    }
                    next($totalizacao);
                }
                reset($totalizacao);
                $tot = db_query("select count(*),{$total_campos}\n                            from ({$query_anterior}) as temp");
            } else {
                $tot = db_query("select count(*) from ({$query_anterior}) as temp");
            }
            //$tot = 0;
            ${$tot_registros} = pg_result($tot, 0, 0);
            ${$tot_registros} = pg_result($tot, 0, 0);
            $query = $query_anterior . " limit {$numlinhas} offset " . ${$offset};
            $result = db_query($query);
            $NumRows = pg_numrows($result);
            $filtroquery = $query_anterior;
        }
    } else {
        if (isset($query_anterior)) {
            $Dd1 = "disabled";
            if (count($totalizacao) > 0 || isset($totalizacao_rep)) {
                $total_campos = "";
                $sep_total_campos = "";
                reset($totalizacao);
                for ($j = 0; $j < count($totalizacao); $j++) {
                    if (key($totalizacao) == $totalizacao[key($totalizacao)]) {
                        $total_campos .= $sep_total_campos . "sum(" . $totalizacao[key($totalizacao)] . ") as " . $totalizacao[key($totalizacao)];
                        $sep_total_campos = ",";
                    }
                    next($totalizacao);
                }
                reset($totalizacao);
                $tot = db_query("select count(*),{$total_campos}\n\t\t\t\t\tfrom ({$query_novo_filtro}) as temp");
            } else {
                $tot = db_query("select count(*) from ({$query_novo_filtro}) as temp");
            }
            //$tot = 0;
            ${$tot_registros} = pg_result($tot, 0, 0);
            if (${$tot_registros} == 0) {
                $Dd2 = "disabled";
            }
        }
    }
    // echo "<script>alert('$NumRows')</script>";
    $NumFields = pg_numfields($result);
    if ($NumRows < $numlinhas && $numlinhas < ${$tot_registros} - ${$offset} - $numlinhas) {
        $Dd1 = @($Dd2 = "disabled");
    }
    echo "<script>\n\t\tfunction js_mostra_text(liga,nomediv,evt){\n\n\t\t\tevt = (evt)?evt:(window.event)?window.event:'';\n\t\t\tif(liga==true){\n\n\t\t\tdocument.getElementById(nomediv).style.top = 0; //evt.clientY;\n\t\t\tdocument.getElementById(nomediv).style.left = 0; //(evt.clientX+20);\n\t\t\tdocument.getElementById(nomediv).style.visibility = 'visible';\n\t\t\t}else\n                    document.getElementById(nomediv).style.visibility = 'hidden';\n\t\t\t}\n\t\t\tfunction js_troca_ordem(nomeform,campo,valor){\n\t\t\tobj=document.createElement('input');\n\t\t\t\tobj.setAttribute('name',campo);\n\t\t\t\tobj.setAttribute('type','submit');\n\t\t\t\tobj.setAttribute('value',valor);\n\t\t\t\tobj.setAttribute('style','color:#FCA;background-color:transparent;border-style:none');\n\t\t\t\t\teval('document.'+nomeform+'.appendChild(obj)');\n\t\t\t\teval('document.'+nomeform+'.'+campo+'.click()');\n\t\t\t}\n\t\t\t\tfunction js_lanca_codigo_pesquisa(valor_recebido){\n\t\t\t\tdocument.navega_lov" . $NomeForm . ".codigo_pesquisa.value = valor_recebido;\n\t\t\t}\n\t\t\tfunction js_lanca_distinct_pesquisa(){\n\t\t\tdocument.navega_lov" . $NomeForm . ".distinct_pesquisa.value = 1;\n\t\t\t}\n\t\t\tfunction js_nova_quantidade_linhas(valor_recebido){\n\t\t\tvalor_recebe = Number(valor_recebido);\n          if(!valor_recebe){\n\t\t\talert('Valor Inválido!');\n\t\t\tdocument.navega_lov" . $NomeForm . ".nova_quantidade_linhas.value = '';\n                document.getElementById('quant_lista').value = '';\n\t\t}else{\n\t\tif(valor_recebe > 100){\n\t\t\tdocument.navega_lov" . $NomeForm . ".nova_quantidade_linhas.value = '100';\n\t\t\tdocument.getElementById('quant_lista').value = 100;\n\t\t}else{\n\t\t\tdocument.navega_lov" . $NomeForm . ".nova_quantidade_linhas.value = valor_recebido;\n\t\t}\n\t\t}\n\t\t}\n\t\t</script>";
    echo "<table id=\"TabDbLov\" border=\"1\" cellspacing=\"1\" cellpadding=\"0\" class=\"lov\">\n";
    /**** botoes de navegacao ********/
    echo "<tr><td colspan=\"" . ($NumFields + 1) . "\" nowrap> <form name=\"navega_lov" . $NomeForm . "\" method=\"post\">\n\t    <input type=\"submit\" name=\"pri" . $NomeForm . "\" value=\"Início\" " . @$Dd1 . " class=\"botao\">\n\t    <input type=\"submit\" name=\"ant" . $NomeForm . "\" value=\"Anterior\" " . @$Dd1 . " class=\"botao\">\n\t    <input type=\"submit\" name=\"prox" . $NomeForm . "\" value=\"Próximo\" " . @$Dd2 . " class=\"botao\">\n\t    <input type=\"submit\" name=\"ult" . $NomeForm . "\" value=\"Último\" " . @$Dd2 . " class=\"botao\">\n\t\t\t<input type=\"hidden\" name=\"offset" . $NomeForm . "\" value=\"" . @${$offset} . "\">\n\t\t\t<input type=\"hidden\" name=\"totreg" . $NomeForm . "\" value=\"" . @${$tot_registros} . "\">\n\t\t\t<input type=\"hidden\" name=\"codigo_pesquisa\" value=\"\">\n\n\t\t\t<input type=\"hidden\" name=\"distinct_pesquisa\" value=\"\">\n\n\t\t\t<input type=\"hidden\" name=\"filtro\" value=\"{$filtro}\">\n";
    reset($variaveis_repassa);
    if (sizeof($variaveis_repassa) > 0) {
        for ($varrep = 0; $varrep < sizeof($variaveis_repassa); $varrep++) {
            echo "<input type=\"hidden\" name=\"" . key($variaveis_repassa) . "\" value=\"" . $variaveis_repassa[key($variaveis_repassa)] . "\">\n";
            next($variaveis_repassa);
        }
    }
    if (isset($ordem_lov) && (isset($ordem_ordenacao) && $ordem_ordenacao == '')) {
        echo "<input type=\"hidden\" name=\"ordem_lov_anterior\" value=\"" . $HTTP_POST_VARS[key($HTTP_POST_VARS)] . "\">\n";
    }
    if (isset($HTTP_POST_VARS['nova_quantidade_linhas']) && $HTTP_POST_VARS['nova_quantidade_linhas'] == '') {
        $numlinhas = $HTTP_POST_VARS['nova_quantidade_linhas'];
    }
    echo "<input type=\"hidden\" name=\"nova_quantidade_linhas\" value=\"{$numlinhas}\" >\n";
    if (isset($totalizacao) && isset($tot)) {
        if (count($totalizacao) > 0) {
            $totNumfields = pg_numfields($tot);
            for ($totrep = 1; $totrep < $totNumfields; $totrep++) {
                echo "<input type=\"hidden\" name=\"totrep_" . pg_fieldname($tot, $totrep) . "\" value=\"" . db_formatar(pg_result($tot, 0, $totrep), 'f') . "\">";
            }
            reset($totalizacao);
            $totrepreg = "";
            $totregsep = "";
            for ($totrep = 0; $totrep < count($totalizacao); $totrep++) {
                $totrepreg .= $totregsep . key($totalizacao) . "=" . $totalizacao[key($totalizacao)];
                $totregsep = "|";
                next($totalizacao);
            }
            reset($totalizacao);
            echo "<input type=\"hidden\" name=\"totalizacao_repas\" value=\"" . $totrepreg . "\">";
        }
    } else {
        if (isset($HTTP_POST_VARS["totalizacao_repas"])) {
            $totalizacao_split = split("\\|", $HTTP_POST_VARS["totalizacao_repas"]);
            for ($totrep = 0; $totrep < count($totalizacao_split); $totrep++) {
                $totalizacao_sep = split("\\=", $totalizacao_split[$totrep]);
                $totalizacao[$totalizacao_sep[0]] = $totalizacao_sep[1];
                if (isset($HTTP_POST_VARS["totrep_" . $totalizacao_sep[0]])) {
                    echo "<input type=\"hidden\" name=\"totrep_" . $totalizacao_sep[0] . "\" value=\"" . $HTTP_POST_VARS["totrep_" . $totalizacao_sep[0]] . "\">";
                }
            }
            echo "<input type=\"hidden\" name=\"totalizacao_repas\" value=\"" . $HTTP_POST_VARS["totalizacao_repas"] . "\">";
        }
    }
    echo "<input type=\"hidden\" name=\"filtroquery\" value=\"" . str_replace("\n", "", @$filtroquery) . "\">\n          " . ($NumRows > 0 ? "\n          Foram retornados <font color=\"red\"><strong>" . ${$tot_registros} . "</strong></font> registros.\n\t\tMostrando de <font color=\"red\"><strong>" . (@${$offset} + 1) . "</strong></font> até\n          <font color=\"red\"><strong>" . (${$tot_registros} < @${$offset} + $numlinhas ? $NumRows <= $numlinhas ? ${$tot_registros} : $NumRows : ${$offset} + $numlinhas) . "</strong></font>." : "Nenhum Registro\n\t\tRetornado") . "</form>\n          </td></tr>\n";
    /*********************************/
    /***** Escreve o cabecalho *******/
    if ($NumRows > 0) {
        echo "<tr>\n";
        // implamentacao de informacoes complementares
        //    echo "<td title='Outras Informações'>OI</td>\n";
        //se foi passado funcao
        if ($campos_layer != "") {
            $campo_layerexe = split("\\|", $campos_layer);
            echo "<td nowrap bgcolor=\"{$db_corcabec}\" title=\"Executa Procedimento Específico.\" align=\"center\">Clique</td>\n";
        }
        $clrotulocab = new rotulolov();
        for ($i = 0; $i < $NumFields; $i++) {
            if (strlen(strstr(pg_fieldname($result, $i), "db_")) == 0) {
                $clrotulocab->label(pg_fieldname($result, $i));
                //echo "<td nowrap bgcolor=\"$db_corcabec\" title=\"".$clrotulocab->title."\" align=\"center\"><b><u>".$clrotulocab->titulo."</u></b></td>\n";
                echo "<td nowrap bgcolor=\"{$db_corcabec}\" title=\"" . $clrotulocab->title . "\" align=\"center\"><input name=\"" . pg_fieldname($result, $i) . "\" value=\"" . ucfirst($clrotulocab->titulo) . "\" type=\"button\" onclick=\"js_troca_ordem('navega_lov" . $NomeForm . "','ordem_dblov" . pg_fieldname($result, $i) . "','" . pg_fieldname($result, $i) . "');\" style=\"text-decoration:underline;background-color:transparent;border-style:none\"> </td>\n";
            } else {
                if (strlen(strstr(pg_fieldname($result, $i), "db_m_")) != 0) {
                    echo "<td nowrap bgcolor=\"{$db_corcabec}\" title=\"" . substr(pg_fieldname($result, $i), 5) . "\" align=\"center\"><b><u>" . substr(pg_fieldname($result, $i), 5) . "</u></b></td>\n";
                }
            }
        }
        echo "</tr>\n";
    }
    //cria nome da funcao com parametros
    if ($arquivo == "()") {
        $arrayFuncao = split("\\|", $aonde);
        $quantidadeItemsArrayFuncao = sizeof($arrayFuncao);
    }
    /********************************/
    /****** escreve o corpo *******/
    for ($i = 0; $i < $NumRows; $i++) {
        echo '<tr >' . "\n";
        // implamentacao de informacoes complementares
        //          echo '<td onMouseOver="document.getElementById(\'div'.$i.'\').style.visibility=\'visible\';" onMouseOut="document.getElementById(\'div'.$i.'\').style.visibility=\'hidden\';" >-></td>'."\n";
        if ($arquivo == "()") {
            $loop = "";
            $caracter = "";
            if ($quantidadeItemsArrayFuncao > 1) {
                for ($cont = 1; $cont < $quantidadeItemsArrayFuncao; $cont++) {
                    if (strlen($arrayFuncao[$cont]) > 3) {
                        for ($luup = 0; $luup < pg_NumFields($result); $luup++) {
                            if (pg_FieldName($result, $luup) == "db_" . $arrayFuncao[$cont]) {
                                $arrayFuncao[$cont] = "db_" . $arrayFuncao[$cont];
                            }
                        }
                    }
                    $loop .= $caracter . "'" . addslashes(str_replace('"', '', @pg_result($result, $i, strlen($arrayFuncao[$cont]) < 4 ? (int) $arrayFuncao[$cont] : $arrayFuncao[$cont]))) . "'";
                    //$loop .= $caracter."'".pg_result($result,$i,(int)$arrayFuncao[$cont])."'";
                    $caracter = ",";
                }
                $resultadoRetorno = $arrayFuncao[0] . "(" . $loop . ")";
            } else {
                $resultadoRetorno = $arrayFuncao[0] . "()";
            }
        }
        /*
        	if($NumRows==1){
        if($arquivo!=""){
        echo "<td>$resultadoRetorno<td>";
        exit;
        }else{
        echo "<script>JanBrowse = window.open('".$arquivo."?".base64_encode("retorno=".($BrowSe==1?0:trim(pg_result($result,0,0))))."','$aonde','width=800,height=600');</script>";
        exit;
        }
        }
        */
        if (isset($cor)) {
            $cor = $cor == $cor1 ? $cor2 : $cor1;
        } else {
            $cor = $cor1;
        }
        // implamentacao de informacoes complementares
        //    $mostradiv="";
        if ($campos_layer != "") {
            $campo_layerexe = split("\\|", $campos_layer);
            echo "<td id=\"funcao_aux" . $i . "\" style=\"text-decoration:none;color:#000000;\" bgcolor=\"{$cor}\" nowrap><a href=\"\" onclick=\"" . $campo_layerexe[1] . "({$loop});return false\" ><strong>" . $campo_layerexe[0] . "&nbsp;</strong></a></td>\n";
        }
        for ($j = 0; $j < $NumFields; $j++) {
            if (strlen(strstr(pg_fieldname($result, $j), "db_")) == 0 || strlen(strstr(pg_fieldname($result, $j), "db_m_")) != 0) {
                if (pg_fieldtype($result, $j) == "date") {
                    if (pg_result($result, $i, $j) != "") {
                        $matriz_data = split("-", pg_result($result, $i, $j));
                        $var_data = $matriz_data[2] . "/" . $matriz_data[1] . "/" . $matriz_data[0];
                    } else {
                        $var_data = "//";
                    }
                    echo "<td id=\"I" . $i . $j . "\" style=\"text-decoration:none;color:#000000;\" bgcolor=\"{$cor}\" nowrap>" . ($arquivo != "" ? "<a title=\"{$mensagem}\" style=\"text-decoration:none;color:#000000;\" href=\"\" " . ($arquivo == "()" ? "OnClick=\"" . $resultadoRetorno . ";return false\">" : "onclick=\"JanBrowse = window.open('" . $arquivo . "?" . base64_encode("retorno=" . ($BrowSe == 1 ? $i : trim(pg_result($result, $i, 0)))) . "','{$aonde}','width=800,height=600');return false\">") . trim($var_data) . "</a>" : trim($var_data)) . "&nbsp;</td>\n";
                } else {
                    if (pg_fieldtype($result, $j) == "float8" || pg_fieldtype($result, $j) == "float4") {
                        $var_data = db_formatar(pg_result($result, $i, $j), 'f', ' ');
                        echo "<td id=\"I" . $i . $j . "\" style=\"text-decoration:none;color:#000000\" bgcolor=\"{$cor}\" align=right nowrap>" . ($arquivo != "" ? "<a title=\"{$mensagem}\" style=\"text-decoration:none;color:#000000;\" href=\"\" " . ($arquivo == "()" ? "OnClick=\"" . $resultadoRetorno . ";return false\">" : "onclick=\"JanBrowse = window.open('" . $arquivo . "?" . base64_encode("retorno=" . ($BrowSe == 1 ? $i : trim(pg_result($result, $i, 0)))) . "','{$aonde}','width=800,height=600');return false\">") . trim($var_data) . "</a>" : trim($var_data)) . "&nbsp;</td>\n";
                    } else {
                        if (pg_fieldtype($result, $j) == "bool") {
                            $var_data = pg_result($result, $i, $j) == 'f' || pg_result($result, $i, $j) == '' ? 'Não' : 'Sim';
                            echo "<td id=\"I" . $i . $j . "\" style=\"text-decoration:none;color:#000000;align:right\" bgcolor=\"{$cor}\" nowrap>" . ($arquivo != "" ? "<a title=\"{$mensagem}\" style=\"text-decoration:none;color:#000000;\" href=\"\" " . ($arquivo == "()" ? "OnClick=\"" . $resultadoRetorno . ";return false\">" : "onclick=\"JanBrowse = window.open('" . $arquivo . "?" . base64_encode("retorno=" . ($BrowSe == 1 ? $i : trim(pg_result($result, $i, 0)))) . "','{$aonde}','width=800,height=600');return false\">") . trim($var_data) . "</a>" : trim($var_data)) . "&nbsp;</td>\n";
                        } else {
                            if (pg_fieldtype($result, $j) == "text") {
                                $var_data = substr(pg_result($result, $i, $j), 0, 10) . "...";
                                echo "<td onMouseOver=\"js_mostra_text(true,'div_text_" . $i . "_" . $j . "',event);\" onMouseOut=\"js_mostra_text(false,'div_text_" . $i . "_" . $j . "',event)\" id=\"I" . $i . $j . "\" style=\"text-decoration:none;color:#000000;align:right\" bgcolor=\"{$cor}\" nowrap>" . ($arquivo != "" ? "<a title=\"{$mensagem}\" style=\"text-decoration:none;color:#000000;\" href=\"\" " . ($arquivo == "()" ? "OnClick=\"" . $resultadoRetorno . ";return false\">" : "onclick=\"JanBrowse = window.open('" . $arquivo . "?" . base64_encode("retorno=" . ($BrowSe == 1 ? $i : trim(pg_result($result, $i, 0)))) . "','{$aonde}','width=800,height=600');return false\">") . trim($var_data) . "</a>" : trim($var_data)) . "&nbsp;</td>\n";
                            } else {
                                if (pg_fieldname($result, $j) == 'j01_matric') {
                                    echo "<td id=\"I" . $i . $j . "\" style=\"text-decoration:none;color:#000000;\" bgcolor=\"{$cor}\" nowrap><a title='Informações Imóvel' onclick=\"js_JanelaAutomatica('iptubase','" . trim(pg_result($result, $i, $j)) . "');return false;\">&nbsp;Inf->&nbsp;</a>" . ($arquivo != "" ? "<a title=\"{$mensagem}\" style=\"text-decoration:none;color:#000000;\" href=\"\" " . ($arquivo == "()" ? "OnClick=\"" . $resultadoRetorno . ";return false\">" : "onclick=\"JanBrowse = window.open('" . $arquivo . "?" . base64_encode("retorno=" . ($BrowSe == 1 ? $i : trim(pg_result($result, $i, 0)))) . "','{$aonde}','width=800,height=600');return false\">") . trim(pg_result($result, $i, $j)) . "</a>" : trim(pg_result($result, $i, $j))) . "&nbsp;</td>\n";
                                } else {
                                    if (pg_fieldname($result, $j) == 'm80_codigo') {
                                        echo "<td id=\"I" . $i . $j . "\" style=\"text-decoration:none;color:#000000;\" bgcolor=\"{$cor}\" nowrap><a title='Informações Lançamento' onclick=\"js_JanelaAutomatica('matestoqueini','" . trim(pg_result($result, $i, $j)) . "');return false;\">&nbsp;Inf->&nbsp;</a>" . ($arquivo != "" ? "<a title=\"{$mensagem}\" style=\"text-decoration:none;color:#000000;\" href=\"\" " . ($arquivo == "()" ? "OnClick=\"" . $resultadoRetorno . ";return false\">" : "onclick=\"JanBrowse = window.open('" . $arquivo . "?" . base64_encode("retorno=" . ($BrowSe == 1 ? $i : trim(pg_result($result, $i, 0)))) . "','{$aonde}','width=800,height=600');return false\">") . trim(pg_result($result, $i, $j)) . "</a>" : trim(pg_result($result, $i, $j))) . "&nbsp;</td>\n";
                                    } else {
                                        if (pg_fieldname($result, $j) == 'm40_codigo') {
                                            echo "<td id=\"I" . $i . $j . "\" style=\"text-decoration:none;color:#000000;\" bgcolor=\"{$cor}\" nowrap><a title='Informações Requisição' onclick=\"js_JanelaAutomatica('matrequi','" . trim(pg_result($result, $i, $j)) . "');return false;\">&nbsp;Inf->&nbsp;</a>" . ($arquivo != "" ? "<a title=\"{$mensagem}\" style=\"text-decoration:none;color:#000000;\" href=\"\" " . ($arquivo == "()" ? "OnClick=\"" . $resultadoRetorno . ";return false\">" : "onclick=\"JanBrowse = window.open('" . $arquivo . "?" . base64_encode("retorno=" . ($BrowSe == 1 ? $i : trim(pg_result($result, $i, 0)))) . "','{$aonde}','width=800,height=600');return false\">") . trim(pg_result($result, $i, $j)) . "</a>" : trim(pg_result($result, $i, $j))) . "&nbsp;</td>\n";
                                        } else {
                                            if (pg_fieldname($result, $j) == 'm42_codigo') {
                                                echo "<td id=\"I" . $i . $j . "\" style=\"text-decoration:none;color:#000000;\" bgcolor=\"{$cor}\" nowrap><a title='Informações Atendimento' onclick=\"js_JanelaAutomatica('atendrequi','" . trim(pg_result($result, $i, $j)) . "');return false;\">&nbsp;Inf->&nbsp;</a>" . ($arquivo != "" ? "<a title=\"{$mensagem}\" style=\"text-decoration:none;color:#000000;\" href=\"\" " . ($arquivo == "()" ? "OnClick=\"" . $resultadoRetorno . ";return false\">" : "onclick=\"JanBrowse = window.open('" . $arquivo . "?" . base64_encode("retorno=" . ($BrowSe == 1 ? $i : trim(pg_result($result, $i, 0)))) . "','{$aonde}','width=800,height=600');return false\">") . trim(pg_result($result, $i, $j)) . "</a>" : trim(pg_result($result, $i, $j))) . "&nbsp;</td>\n";
                                            } else {
                                                if (pg_fieldname($result, $j) == 'm45_codigo') {
                                                    echo "<td id=\"I" . $i . $j . "\" style=\"text-decoration:none;color:#000000;\" bgcolor=\"{$cor}\" nowrap><a title='Informações Devolução' onclick=\"js_JanelaAutomatica('matestoquedev','" . trim(pg_result($result, $i, $j)) . "');return false;\">&nbsp;Inf->&nbsp;</a>" . ($arquivo != "" ? "<a title=\"{$mensagem}\" style=\"text-decoration:none;color:#000000;\" href=\"\" " . ($arquivo == "()" ? "OnClick=\"" . $resultadoRetorno . ";return false\">" : "onclick=\"JanBrowse = window.open('" . $arquivo . "?" . base64_encode("retorno=" . ($BrowSe == 1 ? $i : trim(pg_result($result, $i, 0)))) . "','{$aonde}','width=800,height=600');return false\">") . trim(pg_result($result, $i, $j)) . "</a>" : trim(pg_result($result, $i, $j))) . "&nbsp;</td>\n";
                                                } else {
                                                    if (pg_fieldname($result, $j) == 't52_bem') {
                                                        echo "<td id=\"I" . $i . $j . "\" style=\"text-decoration:none;color:#000000;\" bgcolor=\"{$cor}\" nowrap><a title='Informações Bem' onclick=\"js_JanelaAutomatica('bem','" . trim(pg_result($result, $i, $j)) . "');return false;\">&nbsp;Inf->&nbsp;</a>" . ($arquivo != "" ? "<a title=\"{$mensagem}\" style=\"text-decoration:none;color:#000000;\" href=\"\" " . ($arquivo == "()" ? "OnClick=\"" . $resultadoRetorno . ";return false\">" : "onclick=\"JanBrowse = window.open('" . $arquivo . "?" . base64_encode("retorno=" . ($BrowSe == 1 ? $i : trim(pg_result($result, $i, 0)))) . "','{$aonde}','width=800,height=600');return false\">") . trim(pg_result($result, $i, $j)) . "</a>" : trim(pg_result($result, $i, $j))) . "&nbsp;</td>\n";
                                                    } else {
                                                        if (pg_fieldname($result, $j) == 'q02_inscr') {
                                                            echo "<td id=\"I" . $i . $j . "\" style=\"text-decoration:none;color:#000000;\" bgcolor=\"{$cor}\" nowrap><a title='Informações Issqn' onclick=\"js_JanelaAutomatica('issbase','" . trim(pg_result($result, $i, $j)) . "');return false;\">&nbsp;Inf->&nbsp;</a>" . ($arquivo != "" ? "<a title=\"{$mensagem}\" style=\"text-decoration:none;color:#000000;\" href=\"\" " . ($arquivo == "()" ? "OnClick=\"" . $resultadoRetorno . ";return false\">" : "onclick=\"JanBrowse = window.open('" . $arquivo . "?" . base64_encode("retorno=" . ($BrowSe == 1 ? $i : trim(pg_result($result, $i, 0)))) . "','{$aonde}','width=800,height=600');return false\">") . trim(pg_result($result, $i, $j)) . "</a>" : trim(pg_result($result, $i, $j))) . "&nbsp;</td>\n";
                                                        } else {
                                                            if (pg_fieldname($result, $j) == 'z01_numcgm') {
                                                                echo "<td id=\"I" . $i . $j . "\" style=\"text-decoration:none;color:#000000;\" bgcolor=\"{$cor}\" nowrap><a title='Informações Contribuinte/Empresa' onclick=\"js_JanelaAutomatica('cgm','" . trim(pg_result($result, $i, $j)) . "');return false;\">&nbsp;Inf->&nbsp;</a>" . ($arquivo != "" ? "<a title=\"{$mensagem}\" style=\"text-decoration:none;color:#000000;\" href=\"\" " . ($arquivo == "()" ? "OnClick=\"" . $resultadoRetorno . ";return false\">" : "onclick=\"JanBrowse = window.open('" . $arquivo . "?" . base64_encode("retorno=" . ($BrowSe == 1 ? $i : trim(pg_result($result, $i, 0)))) . "','{$aonde}','width=800,height=600');return false\">") . trim(pg_result($result, $i, $j)) . "</a>" : trim(pg_result($result, $i, $j))) . "&nbsp;</td>\n";
                                                            } else {
                                                                if (pg_fieldname($result, $j) == 'e60_numemp' || pg_fieldname($result, $j) == 'e61_numemp' || pg_fieldname($result, $j) == 'e62_numemp') {
                                                                    echo "<td id=\"I" . $i . $j . "\" style=\"text-decoration:none;color:#000000;\" bgcolor=\"{$cor}\" nowrap><a title='Informações do Empenho' onclick=\"js_JanelaAutomatica('empempenho','" . trim(pg_result($result, $i, $j)) . "');return false;\">&nbsp;Inf->&nbsp;</a>" . ($arquivo != "" ? "<a title=\"{$mensagem}\" style=\"text-decoration:none;color:#000000;\" href=\"\" " . ($arquivo == "()" ? "OnClick=\"" . $resultadoRetorno . ";return false\">" : "onclick=\"JanBrowse = window.open('" . $arquivo . "?" . base64_encode("retorno=" . ($BrowSe == 1 ? $i : trim(pg_result($result, $i, 0)))) . "','{$aonde}','width=800,height=600');return false\">") . trim(pg_result($result, $i, $j)) . "</a>" : trim(pg_result($result, $i, $j))) . "&nbsp;</td>\n";
                                                                } else {
                                                                    if (pg_fieldname($result, $j) == 'e54_autori' || pg_fieldname($result, $j) == 'e55_autori' || pg_fieldname($result, $j) == 'e56_autori') {
                                                                        echo "<td id=\"I" . $i . $j . "\" style=\"text-decoration:none;color:#000000;\" bgcolor=\"{$cor}\" nowrap><a title='Informações da Autorização de Empenho' onclick=\"js_JanelaAutomatica('empautoriza','" . trim(pg_result($result, $i, $j)) . "');return false;\">&nbsp;Inf->&nbsp;</a>" . ($arquivo != "" ? "<a title=\"{$mensagem}\" style=\"text-decoration:none;color:#000000;\" href=\"\" " . ($arquivo == "()" ? "OnClick=\"" . $resultadoRetorno . ";return false\">" : "onclick=\"JanBrowse = window.open('" . $arquivo . "?" . base64_encode("retorno=" . ($BrowSe == 1 ? $i : trim(pg_result($result, $i, 0)))) . "','{$aonde}','width=800,height=600');return false\">") . trim(pg_result($result, $i, $j)) . "</a>" : trim(pg_result($result, $i, $j))) . "&nbsp;</td>\n";
                                                                    } else {
                                                                        if (pg_fieldname($result, $j) == "pc10_numero") {
                                                                            echo "<td id=\"I" . $i . $j . "\" style=\"text-decoration:none;color:#000000;\" bgcolor=\"{$cor}\" nowrap><a title='Informações da Solicitação' onclick=\"js_JanelaAutomatica('empsolicita','" . trim(pg_result($result, $i, $j)) . "');return false;\">&nbsp;Inf->&nbsp;</a>" . ($arquivo != "" ? "<a title=\"{$mensagem}\" style=\"text-decoration:none;color:#000000;\" href=\"\" " . ($arquivo == "()" ? "OnClick=\"" . $resultadoRetorno . ";return false\">" : "onclick=\"JanBrowse = window.open('" . $arquivo . "?" . base64_encode("retorno=" . ($BrowSe == 1 ? $i : trim(pg_result($result, $i, 0)))) . "','{$aonde}','width=800,height=600');return false\">") . trim(pg_result($result, $i, $j)) . "</a>" : trim(pg_result($result, $i, $j))) . "&nbsp;</td>\n";
                                                                        } else {
                                                                            echo "<td id=\"I" . $i . $j . "\" style=\"text-decoration:none;color:#000000;\" bgcolor=\"{$cor}\" nowrap>" . ($arquivo != "" ? "<a title=\"{$mensagem}\" style=\"text-decoration:none;color:#000000;\" href=\"\" " . ($arquivo == "()" ? "OnClick=\"" . $resultadoRetorno . ";return false\">" : "onclick=\"JanBrowse = window.open('" . $arquivo . "?" . base64_encode("retorno=" . ($BrowSe == 1 ? $i : trim(pg_result($result, $i, 0)))) . "','{$aonde}','width=800,height=600');return false\">") . trim(pg_result($result, $i, $j)) . "</a>" : trim(pg_result($result, $i, $j))) . "&nbsp;</td>\n";
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        echo "</tr>\n";
        // implamentacao de informacoes complementares
        //    $divmostra .= "</table>";
        //    $divmostra .= '<div id="div'.$i.'" name="div'.$i.'" style="position:absolute; left:30px; top:40px; z-index:1; visibility: hidden; border: 1px none #000000; background-color: #CCCCCC; layer-background-color: #CCCCCC;">';
        //    $divmostra .= '<table  border=\"1\"  align=\"center\" cellspacing=\"1\">';
        //    $divmostra .= '<tr>';
        //    $divmostra .= '<td> '.$mostradiv;
        //    $divmostra .= '</td> ';
        //    $divmostra .= '</tr> ';
        //    $divmostra .= '</table>';
        //    $divmostra .= '</div>';
    }
    //  echo $divmostra;
    /******************************/
    if (count($totalizacao) > 0) {
        echo "<tr>";
        for ($j = 0; $j < $NumFields; $j++) {
            $key_elemento = array_search(pg_fieldname($result, $j), $totalizacao);
            if ($key_elemento == true && pg_fieldname($result, $j) == $key_elemento && strlen(strstr(pg_fieldname($result, $j), "db_")) == 0) {
                @($vertotrep = $HTTP_POST_VARS['totrep_' . $key_elemento]);
                if (@$vertotrep != "" && !isset($tot)) {
                    echo "<td style=\"text-decoration:none;color:#000000\" bgcolor=\"white\" align=right nowrap> " . $vertotrep . "&nbsp;</td>\n";
                } else {
                    if (isset($tot)) {
                        echo "<td style=\"text-decoration:none;color:#000000\" bgcolor=\"white\" align=right nowrap> " . db_formatar(pg_result($tot, 0, $key_elemento), 'f') . "&nbsp;</td>\n";
                    } else {
                        echo "<td style=\"text-decoration:none;color:#000000\" bgcolor=\"white\" align=right nowrap> &nbsp;</td>\n";
                    }
                }
            } else {
                if ($key_elemento == 'totalgeral') {
                    echo "<td align='right'><strong>Total Geral : </strong></td>";
                } else {
                    if (strlen(strstr(pg_fieldname($result, $j), "db_")) == 0) {
                        echo "<td></td>";
                    }
                }
            }
        }
        echo "</tr>";
    }
    if ($NumRows > 0) {
        echo "<tr><td colspan={$NumFields} >\n              <input name='recomecar' type='button' value='Recomeçar' onclick=\"js_troca_ordem('navega_lov" . $NomeForm . "','recomecar','0');\" class=\"botao\">\n\t\t\t\t\t\t<strong>Indique o Conteúdo:</strong><input title='Digite o valor a pesquisar e clique sobre o campo (cabeçalho) a pesquisar' name=indica_codigo type=text onchange='js_lanca_codigo_pesquisa(this.value)' style='background-color:#E6E4F1'>\n\t\t\t\t\t\t<strong>Quantidade a Listar:</strong><input id=quant_lista name=quant_lista type=text onchange='js_nova_quantidade_linhas(this.value)' style='background-color:#E6E4F1' value='{$numlinhas}' size='5'>\n\t\t\t\t\t\t<strong>Mostra Diferentes:</strong><input title='Mostra os valores diferentes clicando no cabeçalho a pesquisar' name=mostra_diferentes type=checkbox onchange='js_lanca_distinct_pesquisa()' style='background-color:#E6E4F1'>\n\t\t\t\t\t\t</td>";
        echo "</tr>\n";
    }
    echo "</table>";
    for ($i = 0; $i < $NumRows; $i++) {
        for ($j = 0; $j < $NumFields; $j++) {
            if (pg_fieldtype($result, $j) == "text") {
                $clrotulocab->label(pg_fieldname($result, $j));
                echo "<div id='div_text_" . $i . "_" . $j . "' style='position:absolute;left:10px; top:10px; visibility:hidden ; background-color:#6699CC ; border:2px outset #cccccc; align:left'>\n\t\t\t\t\t\t<table>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td align='left'>\n\t\t\t\t\t\t<font color='black' face='arial' size='2'><strong>" . $clrotulocab->titulo . "</strong>:</font><br>\n\t\t\t\t\t\t<font color='black' face='arial' size='1'>" . str_replace("\n", "<br>", pg_result($result, $i, $j)) . "</font>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t</table>\n\t\t\t\t\t\t</div>";
            }
        }
    }
    if ($automatico == true) {
        if (pg_numrows($result) == 1 && ${$offset} == 0) {
            echo "<script>" . @$resultadoRetorno . "</script>";
        }
    }
    return $result;
}
 function NumFields()
 {
     if ($this->res) {
         return pg_NumFields($this->res);
     } else {
         return -1;
     }
 }
Example #8
0
 function metadata($table)
 {
     $count = 0;
     $id = 0;
     $res = array();
     $this->connect();
     $id = pg_exec($this->Link_ID, "select * from {$table}");
     if ($id < 0) {
         $this->Error = pg_ErrorMessage($id);
         $this->Errno = 1;
         $this->halt("Metadata query failed.");
     }
     $count = pg_NumFields($id);
     for ($i = 0; $i < $count; $i++) {
         $res[$i]["table"] = $table;
         $name = pg_FieldName($id, $i);
         $res[$i]["name"] = $name;
         $res[$i]["type"] = pg_FieldType($id, $i);
         //zot:  phplib is wrong, $name in field size should be $i
         //Mike got the line above corrected.
         $res[$i]["len"] = pg_FieldSize($id, $i);
         $res[$i]["flags"] = "";
     }
     pg_FreeResult($id);
     return $res;
 }