function funcao_gera_formulario()
 {
     echo "<tr>\n";
     echo "<td colspan=\"2\">\n";
     echo "<table align=\"center\" >\n";
     echo "   <tr>\n";
     echo "    <td nowrap title=\"\" > \n";
     echo "      <fieldset><Legend>" . $this->cabecalho . "</legend>\n";
     echo "      <table border=\"0\">\n";
     echo "         <tr>\n";
     echo "           <td nowrap >\n";
     $clrotulocampo = new rotulocampo();
     $clrotulocampo->label($this->codigo);
     $clrotulocampo->label($this->descr);
     $codfilho = "L" . $this->codigo;
     db_ancora($GLOBALS["{$codfilho}"], "js_BuscaDadosArquivo(true);", $this->db_opcao);
     db_input($this->codigo, 8, '', true, 'text', $this->db_opcao, " onchange='js_BuscaDadosArquivo(false);'");
     if ($this->tipo == 1) {
         echo "<br>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp";
     }
     db_input($this->descr, 25, '', true, 'text', 3);
     if ($this->tipo == 1) {
         echo "<br>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp";
     }
     echo "  <input name=\"db_lanca\" type=\"button\" value=\"Lançar\" >\n";
     echo "  </td>\n";
     echo "</tr> \n";
     echo "<tr>  \n ";
     echo "  <td align=\"center\" >\n";
     echo "            <select name=\"" . $this->nomeobjeto . "[]\" id=\"" . $this->nomeobjeto . "\" size=\"" . $this->linhas . "\" style=\"width:" . $this->vwidth . "px\" multiple onDblClick=\"js_excluir_item()\">\n";
     if (!empty($this->sql_exec)) {
         $result = pg_exec($this->sql_exec);
         for ($i = 0; $i < pg_numrows($result); $i++) {
             echo "            <option value='" . pg_result($result, $i, $this->codigo) . "'>" . pg_result($result, $i, $this->descr) . "</option>\n";
         }
     }
     echo "             </select> \n";
     echo "           </td>\n";
     echo "         </tr>\n";
     echo "         </tr>\n";
     echo " \t   <td align=\"center\"><strong>\n";
     echo " \t\t   Dois Clicks sobre o ítem Exclui</strong>\n";
     echo "\t   </td>\n";
     echo "         </tr>\n";
     echo "       </table>\n";
     echo "      </fieldset>\n";
     echo "    </td>\n";
     echo "  </tr>\n";
     echo "</table>\n";
     echo "</td>\n";
     echo "</tr>\t\n";
     echo "<script>\n";
     echo "function js_atualiza_item(){\n";
     echo "  var F = document.getElementById(\"" . $this->nomeobjeto . "\").options;\n";
     echo "  if(F.length==0){\n";
     echo "    alert('Cadastre um ítem para proceguir.');\n";
     echo "    document.form1." . $this->codigo . ".focus();\n";
     echo "    return false;\n";
     echo "  }else{  \n";
     echo "    for(var i = 0;i < F.length;i++) {\n";
     echo "      F[i].selected = true;\n";
     echo "    }\n";
     echo "  }\n";
     echo "  return true;\n";
     echo "}\n";
     echo "function js_excluir_item() {\n";
     echo " var F = document.getElementById(\"" . $this->nomeobjeto . "\");\n";
     echo " if(F.length == 1)\n";
     echo "    F.options[0].selected = true;\n";
     echo " var SI = F.selectedIndex;\n";
     echo " if(F.selectedIndex != -1 && F.length > 0) {\n";
     echo "    F.options[SI] = null;\n";
     echo "    js_trocacordeselect();\n";
     echo "    if(SI <= (F.length - 1))\n";
     echo "      F.options[SI].selected = true;\n";
     echo " }\n";
     echo "}\n";
     echo "function js_insSelect() {\n";
     echo " var texto=document.form1." . $this->descr . ".value;\n";
     echo " var valor=document.form1." . $this->codigo . ".value;\n";
     echo " if(texto != \"\" && valor != \"\"){\n";
     echo "    var F = document.getElementById(\"" . $this->nomeobjeto . "\");\n";
     echo "    var testa = false;\n";
     echo "    for(var x = 0; x < F.length; x++){\n";
     echo "       if(F.options[x].value == valor || F.options[x].text == texto){\n";
     echo "         testa = true;\n";
     echo "         break;\n";
     echo "       }\n";
     echo "    }\n";
     echo "    if(testa == false){\n";
     echo "      F.options[F.length] = new Option(texto,valor);\n";
     echo "      js_trocacordeselect();\n";
     echo "    }\n";
     echo " }\n";
     echo " texto=document.form1." . $this->descr . ".value=\"\";\n";
     echo " valor=document.form1." . $this->codigo . ".value=\"\";\n";
     echo " document.form1.db_lanca.onclick = '';\n";
     echo "}\n";
     echo "function js_BuscaDadosArquivo(chave){\n";
     echo " document.form1.db_lanca.onclick = '';\n";
     echo " if(chave){\n";
     echo "   js_OpenJanelaIframe('{$this->sTarget}','" . $this->nomeiframe . "','" . $this->func_arquivo . "?funcao_js=parent." . $this->funcao_js . "|" . $this->codigo . "|" . $this->descr . "','Pesquisa',true);\n";
     echo " }else{\n";
     echo "   js_OpenJanelaIframe('{$this->sTarget}','db_arquivos_iframe','" . $this->func_arquivo . "?pesquisa_chave='+document.form1." . $this->codigo . ".value+'&funcao_js=parent." . $this->funcao_js_hide . "','Pesquisa',false);\n";
     echo " }\n";
     echo "}\n";
     echo "function " . $this->funcao_js . "(chave,chave1){\n";
     echo " document.form1." . $this->codigo . ".value = chave;\n";
     echo " document.form1." . $this->descr . ".value = chave1;\n";
     echo " " . $this->nomeiframe . ".hide();\n";
     echo " document.form1.db_lanca.onclick = js_insSelect;\n";
     echo "}\n";
     echo "function " . $this->funcao_js_hide . "(chave,chave1){\n";
     echo " document.form1." . $this->descr . ".value = chave;\n";
     echo " if(chave1){\n";
     echo "   document.form1." . $this->codigo . ".select();\n";
     echo "   document.form1." . $this->codigo . ".focus();\n";
     echo " }else{\n";
     echo "   document.form1.db_lanca.onclick = js_insSelect;\n";
     echo " }\n";
     echo " " . $this->nomeiframe . ".hide();\n";
     echo "}\n";
     echo "</script>\n";
 }
	  	<td>
	  	  <?php 
db_inputdata('data_inicio', @$data_inicio_dia, @$data_inicio_mes, @$data_inicio_ano, true, 'text', 1);
?>
	  	</td>
	  </tr>
	</table>
</fieldset>

<fieldset>
	<legend><strong>Atividades:</strong></legend>
	<table>
	  <tr>
	  	<td title="Atividades">
	  		<?php 
db_ancora('<strong>Atividade:</strong>', 'js_pesquisaAtividade()', 1);
?>
	  	</td>
	  	<td nowrap="nowrap">
	  		<?php 
db_input('q03_ativ', 10, $Ij50_zona, true, 'hidden', 1);
db_input('q03_descr', 44, $Ij50_descr, true, 'text', 3);
?>
	  		<input type="button" value="Lançar" name="lancar" id="lancar" onclick="js_lancar()" />
	  	</td>
	  </tr>


	  <tr>
	  	<td colspan="2">
	  	  <fieldset id="fieldsetAtividades" style="display: none;">
function db_foto($numcgm, $db_opcao = 3, $javascript = "", $width = "95", $height = "120")
{
    global $oid;
    if (trim($numcgm) != "" && $numcgm != null) {
        $result_foto = pg_exec("select rh50_oid as oid from rhfotos where rh50_numcgm = {$numcgm}");
        if (pg_numrows($result_foto) > 0) {
            db_fieldsmemory($result_foto, 0);
        }
    }
    $mostrarimagem = "imagens/none1.jpeg";
    if (isset($oid)) {
        $mostrarimagem = "func_mostrarimagem.php?oid=" . $oid;
    }
    $href = "<img src='" . $mostrarimagem . "' border=0 width='" . $width . "' height='" . $height . "'>";
    db_ancora("{$href}", "{$javascript}", "{$db_opcao}");
}
">
      Complemento:
    </td>
    <td>
<?php 
    db_input('w11_compl', 20, $Iw11_compl, true, 'text', "", "");
    ?>
    </td>
  </tr>
  <tr>
    <td nowrap title="<?php 
    echo @$Tw11_bairro;
    ?>
">
       <?php 
    db_ancora("<b>Bairro:</b>", "js_pesquisaw11_bairro(true);", $db_opcao);
    ?>
    </td>
    <td>
<?php 
    db_input('w11_bairro', 30, $Iw11_bairro, true, 'text', "", '');
    ?>
    </td>
  </tr>
  <tr>
    <td nowrap title="<?php 
    echo @$Tw11_munic;
    ?>
">
      Municipio:
    </td>