Commit 8838ea615546a4f862ce124821aafce00a6424b0

Authored by Eriksen Costa Paixão
1 parent 6a3710d8
Exists in master

Refactoring para coding standards

Showing 1 changed file with 2826 additions and 2522 deletions   Show diff stats
ieducar/intranet/include/clsCampos.inc.php
Changes suppressed. Click to show
1 1 <?php
2   -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
3   -* *
4   -* @author Prefeitura Municipal de Itajaí *
5   -* @updated 29/03/2007 *
6   -* Pacote: i-PLB Software Público Livre e Brasileiro *
7   -* *
8   -* Copyright (C) 2006 PMI - Prefeitura Municipal de Itajaí *
9   -* ctima@itajai.sc.gov.br *
10   -* *
11   -* Este programa é software livre, você pode redistribuí-lo e/ou *
12   -* modificá-lo sob os termos da Licença Pública Geral GNU, conforme *
13   -* publicada pela Free Software Foundation, tanto a versão 2 da *
14   -* Licença como (a seu critério) qualquer versão mais nova. *
15   -* *
16   -* Este programa é distribuído na expectativa de ser útil, mas SEM *
17   -* QUALQUER GARANTIA. Sem mesmo a garantia implícita de COMERCIALI- *
18   -* ZAÇÃO ou de ADEQUAÇÃO A QUALQUER PROPÓSITO EM PARTICULAR. Con- *
19   -* sulte a Licença Pública Geral GNU para obter mais detalhes. *
20   -* *
21   -* Você deve ter recebido uma cópia da Licença Pública Geral GNU *
22   -* junto com este programa. Se não, escreva para a Free Software *
23   -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA *
24   -* 02111-1307, USA. *
25   -* *
26   -* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  2 +
  3 +/**
  4 + * i-Educar - Sistema de gestão escolar
  5 + *
  6 + * Copyright (C) 2006 Prefeitura Municipal de Itajaí
  7 + * <ctima@itajai.sc.gov.br>
  8 + *
  9 + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo
  10 + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free
  11 + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério)
  12 + * qualquer versão posterior.
  13 + *
  14 + * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM
  15 + * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU
  16 + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral
  17 + * do GNU para mais detalhes.
  18 + *
  19 + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto
  20 + * com este programa; se não, escreva para a Free Software Foundation, Inc., no
  21 + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA.
  22 + *
  23 + * @author Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br>
  24 + * @license http://creativecommons.org/licenses/GPL/2.0/legalcode.pt CC GNU GPL
  25 + * @package Core
  26 + * @since Classe disponível desde a versão 1.0.0
  27 + * @version $Id$
  28 + */
  29 +
  30 +/**
  31 + * clsCampos class.
  32 + *
  33 + * Implementa toda a lógica necessária para criar elementos de formulário e os
  34 + * códigos HTML e Javascript necessários para o funcionamento no i-Educar.
  35 + *
  36 + * @author Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br>
  37 + * @license http://creativecommons.org/licenses/GPL/2.0/legalcode.pt CC GNU GPL
  38 + * @package Core
  39 + * @since Classe disponível desde a versão 1.0.0
  40 + * @version $Id$
  41 + */
27 42 class clsCampos
28 43 {
29   - var $campos = array();
30   - var $num_espaco = 1;
31   - var $__nome = "formcadastro";
32   - var $__adicionando = false;
33   - var $__adicionador_inline = false;
34   - var $__blocos = 0;
35   - var $__bloco_bt_add = false;
36   - var $campoFoco = false;
37   -
38   - var $__adicionando_tabela = false;
39   - var $__id_tabela = 1;
40   - var $__campos_tabela = array();
41   - var $__cabecalho_tabela = array();
42   - var $__nm_tabela;
43   - var $__titulo_tabela;
44   - var $__largura_tabela;
45   - var $__valores_tabela = array(array());
46   - var $__valores_listas_tabela = array(array());
47   -
48   - var $__adicionando_tab = false;
49   - var $__id_tab;
50   - var $__nm_tab;
51   - var $__tabs = array();
52   - var $__campos_tab = array();
53   - var $__id_tabbed = 1;
54   - var $__cabecalho_tab = array();
55   - var $__desabilitado_tab = array();
56   - var $__segue_fluxo = false;
57   - var $__sequencia_fluxo = false;
58   - var $__sequencia_default = true;
59   - var $__acao_enviar_abas = "acao()";
60   -
61   - var $has_tiny = false;
62   -
63   - //var $__campo_obrigatorio = array();
64   -
65   - function campoTabInicio($nome ,$largura = "", $segue_fluxo = false, $array_sequencia = null)
66   - {
67   - $this->__id_tab = 1;
68   - $this->__nm_tab = $nome;
69   - $this->__segue_fluxo = $segue_fluxo;
70   - if(is_array($array_sequencia))
71   - {
72   - $this->__sequencia_fluxo = serialize($array_sequencia);
73   - $this->__sequencia_default = false;
74   - }
75   - $this->campos['tabbed_add_'.$this->__id_tabbed] = $this->__id_tabbed;
76   - }
77   -
78   - function campoTabFim()
79   - {
80   - $this->campos['fim_tab'] = 1;
81   - $this->campos['cabecalho_tab'] = $this->__cabecalho_tab;
82   - $this->campos['desabilitado_tab'] = $this->__desabilitado_tab;
83   - $this->__cabecalho_tab = array();
84   - $this->__id_tabbed++;
85   - }
86   -
87   - function campoAdicionaTab($nome_tab, $desabilitado_tab = false)
88   - {
89   - if($this->__sequencia_default)
90   - {
91   - $this->__sequencia_fluxo = unserialize($this->__sequencia_fluxo);
92   - $this->__sequencia_fluxo[] = $this->__id_tab;
93   - $this->__sequencia_fluxo = serialize($this->__sequencia_fluxo);
94   - }
95   - $this->campos['tab_name_'.$this->__id_tab] = array('nome' => $nome_tab,'id'=>$this->__id_tab);
96   - $this->__cabecalho_tab[] = $nome_tab;
97   - $this->__desabilitado_tab[] = $desabilitado_tab == true ? 1 : 0;
98   - $this->__id_tab++;
99   - }
100   -
101   -
102   - function campoTabelaInicio($nome , $titulo = "",$arr_campos = array()/*, $arr_obrigatorio = array()*/, $arr_valores = array(array()),$largura = "",$array_valores_lista = array(array()))
103   - {
104   - $this->__adicionando_tabela = true;
105   - unset($this->__campos_tabela);
106   - $this->__campos_tabela = array();
107   - $this->__cabecalho_tabela = $arr_campos;
108   - $this->__nm_tabela = $nome;
109   - $this->__valores_tabela = $arr_valores;
110   - $this->__titulo_tabela = $titulo;
111   - $this->__largura_tabela = $largura;
112   - $this->__valores_listas_tabela = $array_valores_lista;
113   - }
114   -
115   - function campoTabelaFim()
116   - {
117   - if(count($this->__campos_tabela) && is_array($this->__campos_tabela))
118   - {
119   - $this->campos['tab_add_'.$this->__id_tabela][] = $this->__campos_tabela;
120   - $this->campos['tab_add_'.$this->__id_tabela]['cabecalho'] = $this->__cabecalho_tabela;
121   - $this->campos['tab_add_'.$this->__id_tabela]['nome'] = $this->__nm_tabela;
122   - $this->campos['tab_add_'.$this->__id_tabela]['valores'] = $this->__valores_tabela;
123   - $this->campos['tab_add_'.$this->__id_tabela]['titulo'] = $this->__titulo_tabela;
124   - $this->campos['tab_add_'.$this->__id_tabela]['largura'] = $this->__largura_tabela;
125   - $this->campos['tab_add_'.$this->__id_tabela]['valores_lista'] = $this->__valores_listas_tabela;
126   - }
127   -
128   - unset($this->__cabecalho_tabela);
129   - $this->__cabecalho_tabela = array();
130   - $this->__adicionando_tabela = false;
131   - $this->__id_tabela++;
132   - }
133   -
134   -
135   -
136   - function blocoAdicionadorBegin( $precadastrados_inline = true )
137   - {
138   - $this->campos["bloco_beg_" . $this->__blocos] = array( "bloco_adicionador", "begin" );
139   - $this->campos["teste1"] = array( "rotulo", "teste1", "teste1", "teste1" );
140   - $this->campos["teste2"] = array( "rotulo", "teste2", "teste2", "teste2" );
141   - $this->campos["teste3"] = array( "rotulo", "teste3", "teste3", "teste3" );
142   - $this->campos["teste4"] = array( "rotulo", "teste4", "teste4", "teste4" );
143   - $this->campos["teste5"] = array( "rotulo", "teste5", "teste5", "teste5" );
144   - $this->__adicionador_inline = $precadastrados_inline;
145   - }
146   -
147   - function blocoAdicionadorEnd()
148   - {
149   - $this->campos["bloco_end_" . $this->__blocos] = array( "bloco_adicionador", "end" );
150   - $this->__blocos++;
151   - }
152   -
153   - function campoAnexarLista( $nome, $campo, $valor, $default, $valores_ja_incluidos = false, $caminho="", $acao = "", $duplo=false, $descricao="", $descricao2="" )
154   - {
155   - $this->campos[$nome] = array( "anexarListaPesquisa", $campo, "", $valor, $default, $acao, $descricao, $caminho, $descricao2, $valores_ja_incluidos );
156   - }
157   -
158   - function campoAddCampos($nome, $arr_campos = array(), $arr_valores = array())
159   - {
160   - $this->campos[$nome] = array("addCampos", $nome, false, $arr_campos, $arr_valores );
161   - }
162   -
163   - function campoBoolLista( $nome, $campo, $default, $val_true = "Sim", $val_false = "Não", $val_undefined = null )
164   - {
165   - $valor = array();
166   - $valor["f"] = $val_false;
167   - $valor["t"] = $val_true;
168   -
169   - if( ! is_null( $val_undefined ) )
170   - {
171   - $valor[''] = $val_undefined;
172   - }
173   - $this->campoLista( $nome, $campo, $valor, $default );
174   - }
175   -
176   -// function campoBoolRadio( $nome, $arr_campos = array(), $arr_valores = array() )
177   -// {
178   -// $this->campos[$nome] = array("addCampos", $nome, false, $arr_campos, $arr_valores );
179   -// }
180   -
181   - function campoAddForm($nome, $arr_campos = array())
182   - {
183   - $this->campos["linha_{$nome}"] = array("addForm", $nome, $arr_campos );
184   - }
185   -
186   - function campoAdicionar( $nome, $campo, $valor, $default, $acao = "" , $duplo=false, $descricao="", $link, $url_janela, $largura_j, $altura_j, $obrigatorio = false, $redirecionamento="")
187   - {
188   - $this->campos[$nome] = array( "adicionar", $campo, $obrigatorio ? "/[^ ]/" : "", $valor, $default, $acao, $descricao, $link, $url_janela, $largura_j, $altura_j, $redirecionamento );
189   - }
190   -
191   - function campoArquivo( $nome, $campo, $valor, $tamanho, $descricao="", $tr_invisivel = false )
192   - {
193   - $this->campos[$nome] = array( "arquivo", $campo, "", $valor, $tamanho, $descricao, "tr_invisivel"=>$tr_invisivel);
194   - $this->form_enctype = " enctype='multipart/form-data'";
195   - }
196   -
197   - function campoCep( $nome, $campo, $valor, $obrigatorio = false, $hifen = "-", $descricao = false, $disable = false)
198   - {
199   - $arr_componente = array( "cep", $this->__adicionando_tabela ? $nome : $campo, $obrigatorio ? "/([0-9]{5})$hifen([0-9]{3})/" : "*(/([0-9]{5})$hifen([0-9]{3})/)", $valor, 10, (8+@strlen($hifen)), "nnnnn-nnn" , $descricao, ($disable) ? "disabled" : "");
200   -
201   - if(!$this->__adicionando_tabela)
202   - $this->campos[$nome] = $arr_componente;
203   - else
204   - $this->__campos_tabela[] = $arr_componente;
205   - }
206   -
207   - function campoCheck( $nome, $campo, $valor, $desc = "", $duplo=false, $script = false, $disable = false)
208   - {
209   - $arr_componente = array( $duplo ? "checkDuplo": "check", $this->__adicionando_tabela ? $nome : $campo, false, $valor, $desc, $script, ($disable) ? "disabled" : "" );
210   -
211   - if(!$this->__adicionando_tabela)
212   - $this->campos[$nome] = $arr_componente;
213   - else
214   - $this->__campos_tabela[] = $arr_componente;
215   -
216   - }
217   -
218   - function campoCnpj( $nome, $campo, $valor, $obrigatorio = false)
219   - {
220   - $arr_componente = array( "cnpj",$this->__adicionando_tabela ? $nome : $campo, $obrigatorio ? "/[0-9]{2}\.[0-9]{3}\.[0-9]{3}\/[0-9]{4}\-[0-9]{2}/" : "*(/[0-9]{2}\.[0-9]{3}\.[0-9]{3}\/[0-9]{4}\-[0-9]{2}/)", $valor, 20, 18, "nn.nnn.nnn/nnnn-nn" );
221   -
222   - if(!$this->__adicionando_tabela)
223   - $this->campos[$nome] = $arr_componente;
224   - else
225   - $this->__campos_tabela[] = $arr_componente;
226   - }
227   -
228   - function campoCnpjPesq( $nome, $campo, $valor, $arquivo_pesquisa, $parametros_serializados = false, $obrigatorio = false )
229   - {
230   - $this->campos[$nome] = array( "cnpj_pesq", $campo, $obrigatorio ? "/[0-9]{2}\.[0-9]{3}\.[0-9]{3}\/[0-9]{4}\-[0-9]{2}/" : "*(/[0-9]{2}\.[0-9]{3}\.[0-9]{3}\/[0-9]{4}\-[0-9]{2}/)", $valor, 20, 18, "nn.nnn.nnn/nnnn-nn", $arquivo_pesquisa, $parametros_serializados );
231   - }
232   -
233   - function campoCor( $nome, $campo, $valor, $obrigatorio = false, $descricao="")
234   - {
235   - $this->campos[$nome] = array( "cor", $campo, $obrigatorio ? "/[^ ]/" : "", $valor, "cor", "cor", $descricao );
236   - }
237   -
238   - function campoCpf( $nome, $campo, $valor, $obrigatorio = false, $descricao = false, $disabled = false)
239   - {
240   -
241   - $arr_componente = array( "cpf", $this->__adicionando_tabela ? $nome : $campo, $obrigatorio ? "/[0-9]{3}\.[0-9]{3}\.[0-9]{3}-[0-9]{2}/" : "", $valor, 16, 14, "nnn.nnn.nnn-nn",$descricao,$disabled);
242   -
243   - if(!$this->__adicionando_tabela)
244   - $this->campos[$nome] = $arr_componente;
245   - else
246   - $this->__campos_tabela[] = $arr_componente;
247   - }
248   -
249   - function campoIdFederal( $nome, $campo, $valor, $obrigatorio=false, $invisivel=false, $descricao=false)
250   - {
251   - $arr_componente= array( "idFederal", $this->__adicionando_tabela ? $nome : $campo, $obrigatorio ?"/[0-9]{3}\.[0-9]{3}\.[0-9]{3}-[0-9]{2}/+/[0-9]{2}\.[0-9]{3}\.[0-9]{3}\/[0-9]{4}\-[0-9]{2}/" :"", $valor, 20, 18, "nnn.nnn.nnn-nn ou nn.nnn.nnn/nnnn-nn", $invisivel ? "disabled" : "" , $descricao);
252   -
253   - if(!$this->__adicionando_tabela)
254   - $this->campos[$nome] = $arr_componente;
255   - else
256   - $this->__campos_tabela[] = $arr_componente;
257   - }
258   -
259   - function campoData( $nome, $campo, $valor, $obrigatorio = false, $descricao="", $duplo=false, $acao="",$disabled = false )
260   - {
261   - $arr_componente = array( $duplo?"dataDupla":"data", $this->__adicionando_tabela ? $nome : $campo, $obrigatorio ? "/(((0[1-9]|[12][0-9])\/(02))|((0[1-9]|[12][0-9]|(30))\/(0[4689]|(11)))|((0[1-9]|[12][0-9]|3[01])\/(0[13578]|(10)|(12))))\/[1-2][0-9]{3}/" : "*/(((0[1-9]|[12][0-9])\/(02))|((0[1-9]|[12][0-9]|(30))\/(0[4689]|(11)))|((0[1-9]|[12][0-9]|3[01])\/(0[13578]|(10)|(12))))\/[1-2][0-9]{3}/", $valor, 9, 10, "dd/mm/aaaa", $descricao, $acao,$disabled);
262   -
263   - if(!$this->__adicionando_tabela)
264   - $this->campos[$nome] = $arr_componente;
265   - else
266   - $this->__campos_tabela[] = $arr_componente;
267   - }
268   -
269   - function campoDetalhe( $nome, $campo, $valor, $default, $acao = "" , $duplo=false, $descricao="", $link, $url_janela, $largura_j, $altura_j, $obrigatorio = false)
270   - {
271   - $this->campos[$nome] = array( "detalhe", $campo, $obrigatorio ? "/[^ ]/" : "", $valor, $default, $acao, $descricao, $link, $url_janela, $largura_j, $altura_j );
272   - }
273   -
274   - function campoExterno( $nome, $campo, $valor, $tamanhovisivel, $tamanhomaximo, $caminho, $nome_caminho, $obrigatorio = false, $duplo=false, $descricao="")
275   - {
276   - $this->campos[$nome] = array( "textoExterno", $campo, ($obrigatorio ? "/[^ ]/" : ""), $valor, $tamanhovisivel, $tamanhomaximo, $descricao, $caminho, $nome_caminho );
277   - }
278   -
279   - function campoProcurarAdicionar( $nome, $campo, $valor, $tamanhovisivel, $tamanhomaximo, $caminho, $nome_caminho, $caminho_dest, $nome_caminho_dest ,$obrigatorio = false, $duplo=false, $descricao="")
280   - {
281   - $this->campos[$nome] = array( "adicionarProcurar", $campo, ($obrigatorio ? "/[^ ]/" : ""), $valor, $tamanhovisivel, $tamanhomaximo, $descricao, $caminho, $nome_caminho,$caminho_dest, $nome_caminho_dest );
282   - }
283   -
284   - function campoFone( $nome, $campo, $valor, $obrigatorio = false)
285   - {
286   - $this->campos[$nome] = array( "fone", $campo, $obrigatorio ? "/^\([0-9]{2}\)[0-9]{3}[0-9]?\-[0-9]{4}$/" : "*(/^\([0-9]{2}\)[0-9]{3}[0-9]?\-[0-9]{4}$/)", $valor, 20, 13, "(nn)nnnn-nnnn ou (nn)nnn-nnnn" );
287   - }
288   -
289   - function campoHora( $nome, $campo, $valor, $obrigatorio = false, $descricao="", $acao="" )
290   - {
291   - $arr_componente = array( "hora", $this->__adicionando_tabela ? $nome : $campo, $obrigatorio ? "/[0-9]{2}:[0-9]{2}/" : "*(/[0-9]{2}:[0-9]{2}/)", $valor, 6, 5, "hh:mm", $descricao, $acao );
292   -
293   - if(!$this->__adicionando_tabela)
294   - $this->campos[$nome] = $arr_componente;
295   - else
296   - $this->__campos_tabela[] = $arr_componente;
297   - }
298   -
299   - function campoLista( $nome, $campo, $valor, $default, $acao = "" , $duplo=false, $descricao="", $complemento="", $desabilitado = false, $obrigatorio = true,$multiple = false )
300   - {
301   - $filtro = "";
302   - if( $obrigatorio )
303   - {
304   - $filtro = "/[^ ]/";
305   - }
306   -
307   - $arr_componente = array( $duplo?"listaDupla":"lista", ($this->__adicionando_tabela === true? $nome : $campo), $filtro, $valor, $default, $acao, $descricao, $complemento, $desabilitado ? "disabled='disabled'" : "",$multiple );
308   -
309   - if(!$this->__adicionando_tabela)
310   - $this->campos[$nome] = $arr_componente;
311   - else
312   - $this->__campos_tabela[] = $arr_componente;
313   -
314   - }
315   -
316   - function campoListaDin( $nome, $campo, $valor, $default, $acao = "" , $arquivo, $campo_destino, $_GET_campos = array(), $complemento="", $desabilitado = false, $obrigatorio = true, $function_extra = "", $duplo=false )
317   - {
318   - $filtro = ( $obrigatorio ) ? "/[^ ]/": "";
319   - $this->campos[$nome] = array( "listaDin", $campo, $filtro, $valor, $default, $acao, "", $campo_destino, $complemento, $desabilitado ? "disabled" : "", $arquivo, $nome, $_GET_campos, $function_extra, $duplo );
320   - }
321   -
322   - function campoListaAtivarPeso( $nome, $campo, $valor, $default="0", $ativado=false, $colunas="10", $tamanho="10", $default1="")
323   - {
324   - $this->campos[$nome] = array( "listaativarpeso", $campo, "/[^ ]/", $valor, $default, $ativado, "", $colunas, $tamanho, $default1 );
325   - }
326   -
327   - function campoListaAtivarPesoSelect( $nome, $campo, $valor, $default="0", $ativado=false,$valor2)
328   - {
329   - $this->campos[$nome] = array( "listaativarpesoselect", $campo, "/[^ ]/", $valor, $default, $ativado, $valor2);
330   - }
331   -
332   - function campoListaPesq( $nome, $campo, $valor, $default, $caminho="", $acao = "" , $duplo=false, $descricao="", $descricao2="", $flag=null, $pag_cadastro = null, $disabled = "", $div = false, $serializedcampos = false, $obrigatorio = false )
333   - {
334   - $this->campos[$nome] = array( "listapesquisa", $campo, $obrigatorio ? "/[^ ]/": "", $valor, $default, $acao, $descricao, $caminho, $descricao2, $flag, $pag_cadastro, $disabled, $div, $serializedcampos, $obrigatorio );
335   - }
336   -
337   - function campoMemo( $nome, $campo, $valor, $colunas, $linhas, $obrigatorio = false, $descricao="", $conta="", $duplo = false, $script = false, $evento = "onclick", $disabled = false )
338   - {
339   - $this->campos[$nome] = array( "memo", $campo, $obrigatorio ? "/[^ ]/" : "", $valor, $colunas, $linhas, $descricao, $conta, $duplo, $evento, $script, $disabled );
340   - }
341   -
342   - function campoNumero( $nome, $campo, $valor, $tamanhovisivel, $tamanhomaximo, $obrigatorio = false, $descricao="", $descricao2 = "", $script = false, $evento = false, $duplo = false, $disabled = false )
343   - {
344   - $arr_componente = array( $duplo ? "textoDuplo" : "texto", $this->__adicionando_tabela ? $nome : $campo, $obrigatorio ? "/^[0-9]+$/" : "*(/^[0-9]+$/)", $valor, $tamanhovisivel, $tamanhomaximo, $descricao ? $descricao : "somente números", $descricao2, $script, $evento, $disabled );
345   -
346   - if(!$this->__adicionando_tabela)
347   - $this->campos[$nome] = $arr_componente;
348   - else
349   - $this->__campos_tabela[] = $arr_componente;
350   - }
351   - function campoMonetario( $nome, $campo, $valor, $tamanhovisivel, $tamanhomaximo, $obrigatorio = false, $descricao="", $script = "", $evento = "onChange", $disabled=false, $show_sub = true,$descricao2="", $duplo = false )
352   - {
353   - $arr_componente = array($duplo ? "monetarioDuplo" : "monetario", $this->__adicionando_tabela ? $nome : $campo, $obrigatorio ? "/^[0-9.,]+$/" : "*(/^[0-9.,]+$/)", $valor, $tamanhovisivel, $tamanhomaximo, $descricao, $script, $evento, $disabled , $show_sub,$descricao2);
354   -
355   - if(!$this->__adicionando_tabela)
356   - $this->campos[$nome] = $arr_componente;
357   - else
358   - $this->__campos_tabela[] = $arr_componente;
359   -
360   - }
361   -
362   - function campoOculto( $nome, $valor )
363   - {
364   - $arr_componente = array( "oculto", $nome, "", $valor );
365   -
366   - if(!$this->__adicionando_tabela)
367   - $this->campos[$nome] = $arr_componente;
368   - else
369   - $this->__campos_tabela['oculto'][] = $arr_componente;
370   - }
371   -
372   - function campoRadio( $nome, $campo, $valor, $default, $acao = "", $descricao="" )
373   - {
374   - $this->campos[$nome] = array( "radio", $campo, "", $valor, $default, $acao, $descricao );
375   - }
376   -
377   - function campoRotulo( $nome, $campo, $valor, $duplo = false, $descricao="", $separador = ":" )
378   - {
379   - $arr_componente = array( $duplo ? "rotuloDuplo":"rotulo", $this->__adicionando_tabela ? $nome : $campo, "", $valor, 6=>$descricao, "separador"=>$separador );
380   -
381   - if(!$this->__adicionando_tabela)
382   - $this->campos[$nome] = $arr_componente;
383   - else
384   - $this->__campos_tabela[] = $arr_componente;
385   - }
386   -
387   - function campoSenha( $nome, $campo, $valor, $obrigatorio = false, $descricao="" )
388   - {
389   - $this->campos[$nome] = array( "senha", $campo, $obrigatorio ? "/[^ ]/" : "", $valor, 10, 100, $descricao );
390   - }
391   -
392   - function campoTexto( $nome, $campo, $valor, $tamanhovisivel, $tamanhomaximo, $obrigatorio = false, $expressao = false, $duplo=false, $descricao="", $descricao2 = "", $script="", $evento = "onKeyUp", $disabled=false )
393   - {
394   -
395   - $arr_componente = array( $duplo ? "textoDuplo":"texto", $this->__adicionando_tabela ? $nome : $campo, $expressao ? $expressao :( $obrigatorio ? "/[^ ]/" : ""), $valor, $tamanhovisivel, $tamanhomaximo, $descricao, $descricao2, $script, $evento, $disabled );
396   -
397   - if(!$this->__adicionando_tabela)
398   - $this->campos[$nome] = $arr_componente;
399   - else
400   - $this->__campos_tabela[] = $arr_componente;
401   - }
402   -
403   - function campoEmail( $nome, $campo, $valor, $tamanhovisivel, $tamanhomaximo, $obrigatorio = false, $expressao = false, $duplo=false, $descricao="", $descricao2 = "", $script="")
404   - {
405   - $this->campos[$nome] = array( $duplo ? "emailDuplo":"email", $campo, $expressao ? $expressao :( $obrigatorio ? "/^[a-z_\-\.0-9]+$/" : ""), $valor, $tamanhovisivel, $tamanhomaximo, $descricao, $descricao2, $script );
406   - }
407   -
408   - function campoSuggest( $nome, $campo, $valor, $obrigatorio = false, $expressao = false, $duplo=false, $descricao="", $arquivo = "xml_pessoas.php" )
409   - {
410   - $this->campos[$nome] = array( "suggest", $campo, $expressao ? $expressao :( $obrigatorio ? "/[^ ]/" : ""), $valor, $descricao, $descricao2 );
411   - }
412   -
413   - function campoTextoPesquisa( $nome, $campo, $valor, $tamanhovisivel, $tamanhomaximo, $obrigatorio = false, $caminho = "", $expressao = false, $duplo=false, $descricao="", $descricao2 = "", $serializedcampos = null, $disabled = false, $script="", $evento = "onChange")
414   - {
415   - $arr_componente = array( $duplo ? "textoPesquisaDuplo":"textoPesquisa", $this->__adicionando_tabela ? $nome : $campo, $expressao ? $expressao :( $obrigatorio ? "/[^ ]/" : ""), $valor, $tamanhovisivel, $tamanhomaximo, $descricao, $descricao2, $caminho, $serializedcampos, $disabled, $script, $evento );
416   -
417   - if(!$this->__adicionando_tabela)
418   - $this->campos[$nome] = $arr_componente;
419   - else
420   - $this->__campos_tabela[] = $arr_componente;
421   - }
422   -
423   - function campoTextoInv( $nome, $campo, $valor, $tamanhovisivel, $tamanhomaximo, $obrigatorio = false, $expressao = false, $duplo=false, $descricao="",$descricao2="", $script = "", $evento = "onKeyUp",$name = "")
424   - {
425   - $name = $name ? $name : $nome;
426   - $this->campos[$nome] = array( $duplo ? "textoDuploInv":"textoInv", $campo, $expressao ? $expressao :( $obrigatorio ? "/[^ ]/" : ""), $valor, $tamanhovisivel, $tamanhomaximo, $descricao,$descricao2, $script, $evento,$name );
427   - }
428   -
429   - function campoTheEditor ( $nome, $campo, $valor, $largura, $altura )
430   - {
431   - $this->campos[$nome] = array( "theEditor", $campo, $valor, $largura, $altura );
432   - }
433   -
434   - function campoQuebra()
435   - {
436   - $this->campos["espaco".$this->num_espaco] = array( "espaco", "", "", "", "", "", "", "" );
437   - $this->num_espaco++;
438   - }
439   -
440   - function campoQuebra2($cor = "#000000", $altura = 2)
441   - {
442   - $this->campos["linha_preta".$this->num_espaco] = array( "linha_preta", "cor"=>$cor, "altura"=>$altura, "", "", "", "", "" );
443   - $this->num_espaco++;
444   - }
445   -
446   - function setFocus($campo)
447   - {
448   - $this->campoFoco = $campo;
449   - }
450   -
451   - function campoTiny( $id, $valor, $obrigatorio = false)
452   - {
453   -
454   - $this->campos['0'] = array( "tiny","",false, $valor,$obrigatorio);
455   - }
456   -
457   - function MakeCampos( $array_campos = null, $adicionador_indice = null, $todos_inline = false, $todos_disabled = false, $junta_linhas = false, $start_md = null )
458   - {
459   -
460   - $retorno = "";
461   - $gerou_script = false;
462   -
463   - if( ! $arr_campos )
464   - {
465   - $arr_campos = $this->campos;
466   - }
467   - reset( $arr_campos );
468   - $campo_anterior = "";
469   - $md = true;
470   - if( ! is_null( $start_md ) && is_bool( $start_md ) )
471   - {
472   - $md = $start_md;
473   - }
474   - $foiDuplo = $junta_linhas;
475   - $adicionador_total_valores = 5; // marca quantos valores foram passados para o prenchimento das repeticoes
476   -
477   - $javascript .= "
478   - function tabela(name,counter)
479   - {
480   - //seta variavel para nao reordenar id dos campos
481   - this.setReordena = function(reordenar)
482   - {
483   - this.reordenar = reordenar;
484   - }
485   -
486   - this.constructor = function(){
487   -
488   - var This = this;
489   -
490   - this.id = counter;
491   - this.afterAddRow = function(){};
492   - this.afterRemoveRow = function(){};
493   - this.isIE = (navigator.appName.indexOf('Microsoft')!= -1) ? 1:0
494   - this.nome = name;
495   - this.campos = new Array();
496   - this.reordenar = true;
497   -
498   - this.getId = function(){ return this.id;}
499   -
500   -
501   - var numColumns = document.getElementById(This.nome).rows[1].childNodes.length;
502   -
503   - var row = document.getElementById(This.nome).insertRow(document.getElementById(This.nome).rows.length-1);
504   -
505   - for(var ct=0;ct<numColumns-1;ct++)
506   - {
  44 + var $campos = array();
  45 + var $num_espaco = 1;
  46 + var $__nome = "formcadastro";
  47 + var $__adicionando = FALSE;
  48 + var $__adicionador_inline = FALSE;
  49 + var $__blocos = 0;
  50 + var $__bloco_bt_add = FALSE;
  51 + var $campoFoco = FALSE;
  52 +
  53 + var $__adicionando_tabela = FALSE;
  54 + var $__id_tabela = 1;
  55 + var $__campos_tabela = array();
  56 + var $__cabecalho_tabela = array();
  57 + var $__nm_tabela;
  58 + var $__titulo_tabela;
  59 + var $__largura_tabela;
  60 + var $__valores_tabela = array(array());
  61 + var $__valores_listas_tabela = array(array());
  62 +
  63 + var $__adicionando_tab = FALSE;
  64 + var $__id_tab;
  65 + var $__nm_tab;
  66 + var $__tabs = array();
  67 + var $__campos_tab = array();
  68 + var $__id_tabbed = 1;
  69 + var $__cabecalho_tab = array();
  70 + var $__desabilitado_tab = array();
  71 + var $__segue_fluxo = FALSE;
  72 + var $__sequencia_fluxo = FALSE;
  73 + var $__sequencia_default = TRUE;
  74 + var $__acao_enviar_abas = 'acao()';
  75 +
  76 + var $has_tiny = FALSE;
  77 +
  78 + function campoTabInicio($nome ,$largura = '', $segue_fluxo = FALSE, $array_sequencia = NULL)
  79 + {
  80 + $this->__id_tab = 1;
  81 + $this->__nm_tab = $nome;
  82 + $this->__segue_fluxo = $segue_fluxo;
  83 +
  84 + if (is_array($array_sequencia)) {
  85 + $this->__sequencia_fluxo = serialize($array_sequencia);
  86 + $this->__sequencia_default = FALSE;
  87 + }
  88 +
  89 + $this->campos['tabbed_add_' . $this->__id_tabbed] = $this->__id_tabbed;
  90 + }
  91 +
  92 + function campoTabFim()
  93 + {
  94 + $this->campos['fim_tab'] = 1;
  95 + $this->campos['cabecalho_tab'] = $this->__cabecalho_tab;
  96 + $this->campos['desabilitado_tab'] = $this->__desabilitado_tab;
  97 + $this->__cabecalho_tab = array();
  98 + $this->__id_tabbed++;
  99 + }
  100 +
  101 + function campoAdicionaTab($nome_tab, $desabilitado_tab = FALSE)
  102 + {
  103 + if($this->__sequencia_default) {
  104 + $this->__sequencia_fluxo = unserialize($this->__sequencia_fluxo);
  105 + $this->__sequencia_fluxo[] = $this->__id_tab;
  106 + $this->__sequencia_fluxo = serialize($this->__sequencia_fluxo);
  107 + }
  108 +
  109 + $this->campos['tab_name_' . $this->__id_tab] = array(
  110 + 'nome' => $nome_tab,
  111 + 'id' => $this->__id_tab
  112 + );
  113 +
  114 + $this->__cabecalho_tab[] = $nome_tab;
  115 + $this->__desabilitado_tab[] = $desabilitado_tab == TRUE ? 1 : 0;
  116 + $this->__id_tab++;
  117 + }
  118 +
  119 + function campoTabelaInicio($nome , $titulo = '', $arr_campos = array(),
  120 + $arr_valores = array(array()), $largura = '', $array_valores_lista = array(array()))
  121 + {
  122 + $this->__adicionando_tabela = TRUE;
  123 +
  124 + unset($this->__campos_tabela);
  125 +
  126 + $this->__campos_tabela = array();
  127 + $this->__cabecalho_tabela = $arr_campos;
  128 + $this->__nm_tabela = $nome;
  129 + $this->__valores_tabela = $arr_valores;
  130 + $this->__titulo_tabela = $titulo;
  131 + $this->__largura_tabela = $largura;
  132 + $this->__valores_listas_tabela = $array_valores_lista;
  133 + }
  134 +
  135 + function campoTabelaFim()
  136 + {
  137 + if (count($this->__campos_tabela) && is_array($this->__campos_tabela))
  138 + {
  139 + $this->campos['tab_add_' . $this->__id_tabela][] = $this->__campos_tabela;
  140 + $this->campos['tab_add_' . $this->__id_tabela]['cabecalho'] = $this->__cabecalho_tabela;
  141 + $this->campos['tab_add_' . $this->__id_tabela]['nome'] = $this->__nm_tabela;
  142 + $this->campos['tab_add_' . $this->__id_tabela]['valores'] = $this->__valores_tabela;
  143 + $this->campos['tab_add_' . $this->__id_tabela]['titulo'] = $this->__titulo_tabela;
  144 + $this->campos['tab_add_' . $this->__id_tabela]['largura'] = $this->__largura_tabela;
  145 + $this->campos['tab_add_' . $this->__id_tabela]['valores_lista'] = $this->__valores_listas_tabela;
  146 + }
  147 +
  148 + unset($this->__cabecalho_tabela);
  149 + $this->__cabecalho_tabela = array();
  150 + $this->__adicionando_tabela = FALSE;
  151 + $this->__id_tabela++;
  152 + }
  153 +
  154 + function blocoAdicionadorBegin($precadastrados_inline = TRUE)
  155 + {
  156 + $this->campos['bloco_beg_' . $this->__blocos] = array('bloco_adicionador', 'begin');
  157 +
  158 + $this->campos['teste1'] = array('rotulo', 'teste1', 'teste1', 'teste1');
  159 + $this->campos['teste2'] = array('rotulo', 'teste2', 'teste2', 'teste2');
  160 + $this->campos['teste3'] = array('rotulo', 'teste3', 'teste3', 'teste3');
  161 + $this->campos['teste4'] = array('rotulo', 'teste4', 'teste4', 'teste4');
  162 + $this->campos['teste5'] = array('rotulo', 'teste5', 'teste5', 'teste5');
  163 +
  164 + $this->__adicionador_inline = $precadastrados_inline;
  165 + }
  166 +
  167 + function blocoAdicionadorEnd()
  168 + {
  169 + $this->campos['bloco_end_' . $this->__blocos] = array('bloco_adicionador', 'end');
  170 + $this->__blocos++;
  171 + }
  172 +
  173 + function campoAnexarLista($nome, $campo, $valor, $default,
  174 + $valores_ja_incluidos = FALSE, $caminho = '', $acao = '', $duplo = FALSE,
  175 + $descricao = '', $descricao2 = '')
  176 + {
  177 + $this->campos[$nome] = array('anexarListaPesquisa', $campo, '', $valor,
  178 + $default, $acao, $descricao, $caminho, $descricao2, $valores_ja_incluidos);
  179 + }
  180 +
  181 + function campoAddCampos($nome, $arr_campos = array(), $arr_valores = array())
  182 + {
  183 + $this->campos[$nome] = array('addCampos', $nome, FALSE, $arr_campos, $arr_valores);
  184 + }
  185 +
  186 + function campoBoolLista($nome, $campo, $default, $val_true = 'Sim',
  187 + $val_false = 'Não', $val_undefined = NULL)
  188 + {
  189 + $valor = array();
  190 + $valor['f'] = $val_false;
  191 + $valor['t'] = $val_true;
  192 +
  193 + if (! is_null($val_undefined)) {
  194 + $valor[''] = $val_undefined;
  195 + }
  196 + $this->campoLista( $nome, $campo, $valor, $default );
  197 + }
  198 +
  199 + function campoAddForm($nome, $arr_campos = array())
  200 + {
  201 + $this->campos['linha_' . $nome] = array('addForm', $nome, $arr_campos);
  202 + }
  203 +
  204 + function campoAdicionar($nome, $campo, $valor, $default, $acao = '' ,
  205 + $duplo = FALSE, $descricao = '', $link, $url_janela, $largura_j,
  206 + $altura_j, $obrigatorio = FALSE, $redirecionamento = '')
  207 + {
  208 + $this->campos[$nome] = array('adicionar', $campo,
  209 + $obrigatorio ? "/[^ ]/" : '',
  210 + $valor, $default, $acao, $descricao, $link, $url_janela,
  211 + $largura_j, $altura_j, $redirecionamento);
  212 + }
  213 +
  214 + function campoArquivo($nome, $campo, $valor, $tamanho,
  215 + $descricao = '', $tr_invisivel = FALSE)
  216 + {
  217 + $this->campos[$nome] = array('arquivo', $campo, '', $valor, $tamanho,
  218 + $descricao, 'tr_invisivel' => $tr_invisivel);
  219 +
  220 + $this->form_enctype = " enctype='multipart/form-data'";
  221 + }
  222 +
  223 + function campoCep($nome, $campo, $valor, $obrigatorio = FALSE,
  224 + $hifen = '-', $descricao = FALSE, $disable = FALSE)
  225 + {
  226 + $arr_componente = array(
  227 + 'cep',
  228 + $this->__adicionando_tabela ? $nome : $campo,
  229 + $obrigatorio ? "/([0-9]{5})$hifen([0-9]{3})/" : "*(/([0-9]{5})$hifen([0-9]{3})/)",
  230 + $valor,
  231 + 10,
  232 + (8 + @strlen($hifen)),
  233 + 'nnnnn-nnn',
  234 + $descricao,
  235 + ($disable) ? 'disabled' : ''
  236 + );
  237 +
  238 + if (! $this->__adicionando_tabela) {
  239 + $this->campos[$nome] = $arr_componente;
  240 + }
  241 + else {
  242 + $this->__campos_tabela[] = $arr_componente;
  243 + }
  244 + }
  245 +
  246 + function campoCheck($nome, $campo, $valor, $desc = '', $duplo = FALSE,
  247 + $script = FALSE, $disable = FALSE)
  248 + {
  249 + $arr_componente = array(
  250 + $duplo ? 'checkDuplo' : 'check',
  251 + $this->__adicionando_tabela ? $nome : $campo,
  252 + FALSE,
  253 + $valor,
  254 + $desc,
  255 + $script,
  256 + ($disable) ? 'disabled' : ''
  257 + );
  258 +
  259 + if (! $this->__adicionando_tabela) {
  260 + $this->campos[$nome] = $arr_componente;
  261 + }
  262 + else {
  263 + $this->__campos_tabela[] = $arr_componente;
  264 + }
  265 + }
  266 +
  267 + function campoCnpj($nome, $campo, $valor, $obrigatorio = FALSE)
  268 + {
  269 + $arr_componente = array(
  270 + "cnpj",
  271 + $this->__adicionando_tabela ? $nome : $campo,
  272 + $obrigatorio ? "/[0-9]{2}\.[0-9]{3}\.[0-9]{3}\/[0-9]{4}\-[0-9]{2}/" : "*(/[0-9]{2}\.[0-9]{3}\.[0-9]{3}\/[0-9]{4}\-[0-9]{2}/)",
  273 + $valor,
  274 + 20,
  275 + 18,
  276 + 'nn.nnn.nnn/nnnn-nn'
  277 + );
  278 +
  279 + if (! $this->__adicionando_tabela) {
  280 + $this->campos[$nome] = $arr_componente;
  281 + }
  282 + else {
  283 + $this->__campos_tabela[] = $arr_componente;
  284 + }
  285 + }
  286 +
  287 + function campoCnpjPesq($nome, $campo, $valor, $arquivo_pesquisa,
  288 + $parametros_serializados = FALSE, $obrigatorio = FALSE)
  289 + {
  290 + $this->campos[$nome] = array(
  291 + 'cnpj_pesq',
  292 + $campo,
  293 + $obrigatorio ? "/[0-9]{2}\.[0-9]{3}\.[0-9]{3}\/[0-9]{4}\-[0-9]{2}/" : "*(/[0-9]{2}\.[0-9]{3}\.[0-9]{3}\/[0-9]{4}\-[0-9]{2}/)",
  294 + $valor,
  295 + 20,
  296 + 18,
  297 + 'nn.nnn.nnn/nnnn-nn',
  298 + $arquivo_pesquisa,
  299 + $parametros_serializados
  300 + );
  301 + }
  302 +
  303 + function campoCor($nome, $campo, $valor, $obrigatorio = FALSE, $descricao = '')
  304 + {
  305 + $this->campos[$nome] = array(
  306 + 'cor',
  307 + $campo,
  308 + $obrigatorio ? "/[^ ]/" : '',
  309 + $valor,
  310 + 'cor',
  311 + 'cor',
  312 + $descricao
  313 + );
  314 + }
  315 +
  316 + function campoCpf($nome, $campo, $valor, $obrigatorio = FALSE, $descricao = FALSE, $disabled = FALSE)
  317 + {
  318 + $arr_componente = array(
  319 + 'cpf',
  320 + $this->__adicionando_tabela ? $nome : $campo,
  321 + $obrigatorio ? "/[0-9]{3}\.[0-9]{3}\.[0-9]{3}-[0-9]{2}/" : '',
  322 + $valor,
  323 + 16,
  324 + 14,
  325 + 'nnn.nnn.nnn-nn',
  326 + $descricao,
  327 + $disabled
  328 + );
  329 +
  330 + if (! $this->__adicionando_tabela) {
  331 + $this->campos[$nome] = $arr_componente;
  332 + }
  333 + else {
  334 + $this->__campos_tabela[] = $arr_componente;
  335 + }
  336 + }
  337 +
  338 + function campoIdFederal($nome, $campo, $valor, $obrigatorio = FALSE,
  339 + $invisivel = FALSE, $descricao = FALSE)
  340 + {
  341 + $arr_componente = array(
  342 + 'idFederal',
  343 + $this->__adicionando_tabela ? $nome : $campo,
  344 + $obrigatorio ?"/[0-9]{3}\.[0-9]{3}\.[0-9]{3}-[0-9]{2}/+/[0-9]{2}\.[0-9]{3}\.[0-9]{3}\/[0-9]{4}\-[0-9]{2}/" : '',
  345 + $valor,
  346 + 20,
  347 + 18,
  348 + 'nnn.nnn.nnn-nn ou nn.nnn.nnn/nnnn-nn',
  349 + $invisivel ? 'disabled' : '', $descricao
  350 + );
  351 +
  352 + if (! $this->__adicionando_tabela) {
  353 + $this->campos[$nome] = $arr_componente;
  354 + }
  355 + else {
  356 + $this->__campos_tabela[] = $arr_componente;
  357 + }
  358 + }
  359 +
  360 + function campoData($nome, $campo, $valor, $obrigatorio = FALSE, $descricao = '',
  361 + $duplo = FALSE, $acao = '', $disabled = FALSE)
  362 + {
  363 + $arr_componente = array(
  364 + $duplo ? 'dataDupla' : 'data',
  365 + $this->__adicionando_tabela ? $nome : $campo,
  366 + $obrigatorio ? "/(((0[1-9]|[12][0-9])\/(02))|((0[1-9]|[12][0-9]|(30))\/(0[4689]|(11)))|((0[1-9]|[12][0-9]|3[01])\/(0[13578]|(10)|(12))))\/[1-2][0-9]{3}/" : "*/(((0[1-9]|[12][0-9])\/(02))|((0[1-9]|[12][0-9]|(30))\/(0[4689]|(11)))|((0[1-9]|[12][0-9]|3[01])\/(0[13578]|(10)|(12))))\/[1-2][0-9]{3}/",
  367 + $valor,
  368 + 9,
  369 + 10,
  370 + 'dd/mm/aaaa',
  371 + $descricao,
  372 + $acao,
  373 + $disabled
  374 + );
  375 +
  376 + if (! $this->__adicionando_tabela) {
  377 + $this->campos[$nome] = $arr_componente;
  378 + }
  379 + else {
  380 + $this->__campos_tabela[] = $arr_componente;
  381 + }
  382 + }
  383 +
  384 + function campoDetalhe($nome, $campo, $valor, $default, $acao = '', $duplo = FALSE,
  385 + $descricao = '', $link, $url_janela, $largura_j, $altura_j, $obrigatorio = FALSE)
  386 + {
  387 + $this->campos[$nome] = array(
  388 + 'detalhe',
  389 + $campo,
  390 + $obrigatorio ? "/[^ ]/" : '',
  391 + $valor,
  392 + $default,
  393 + $acao,
  394 + $descricao,
  395 + $link,
  396 + $url_janela,
  397 + $largura_j,
  398 + $altura_j
  399 + );
  400 + }
  401 +
  402 + function campoExterno($nome, $campo, $valor, $tamanhovisivel, $tamanhomaximo,
  403 + $caminho, $nome_caminho, $obrigatorio = FALSE, $duplo = FALSE, $descricao = '')
  404 + {
  405 + $this->campos[$nome] = array(
  406 + 'textoExterno',
  407 + $campo,
  408 + $obrigatorio ? "/[^ ]/" : '',
  409 + $valor,
  410 + $tamanhovisivel,
  411 + $tamanhomaximo,
  412 + $descricao,
  413 + $caminho,
  414 + $nome_caminho
  415 + );
  416 + }
  417 +
  418 + function campoProcurarAdicionar($nome, $campo, $valor, $tamanhovisivel,
  419 + $tamanhomaximo, $caminho, $nome_caminho, $caminho_dest, $nome_caminho_dest,
  420 + $obrigatorio = FALSE, $duplo = FALSE, $descricao = '')
  421 + {
  422 + $this->campos[$nome] = array(
  423 + 'adicionarProcurar',
  424 + $campo,
  425 + $obrigatorio ? "/[^ ]/" : '',
  426 + $valor,
  427 + $tamanhovisivel,
  428 + $tamanhomaximo,
  429 + $descricao,
  430 + $caminho,
  431 + $nome_caminho,
  432 + $caminho_dest,
  433 + $nome_caminho_dest
  434 + );
  435 + }
  436 +
  437 + function campoFone($nome, $campo, $valor, $obrigatorio = FALSE)
  438 + {
  439 + $this->campos[$nome] = array(
  440 + 'fone',
  441 + $campo,
  442 + $obrigatorio ? "/^\([0-9]{2}\)[0-9]{3}[0-9]?\-[0-9]{4}$/" : "*(/^\([0-9]{2}\)[0-9]{3}[0-9]?\-[0-9]{4}$/)",
  443 + $valor,
  444 + 20,
  445 + 13,
  446 + '(nn)nnnn-nnnn ou (nn)nnn-nnnn'
  447 + );
  448 + }
  449 +
  450 + function campoHora($nome, $campo, $valor, $obrigatorio = FALSE, $descricao = '', $acao = '')
  451 + {
  452 + $arr_componente = array(
  453 + 'hora',
  454 + $this->__adicionando_tabela ? $nome : $campo,
  455 + $obrigatorio ? "/[0-9]{2}:[0-9]{2}/" : "*(/[0-9]{2}:[0-9]{2}/)",
  456 + $valor,
  457 + 6,
  458 + 5,
  459 + 'hh:mm',
  460 + $descricao,
  461 + $acao
  462 + );
  463 +
  464 + if (! $this->__adicionando_tabela) {
  465 + $this->campos[$nome] = $arr_componente;
  466 + }
  467 + else {
  468 + $this->__campos_tabela[] = $arr_componente;
  469 + }
  470 + }
  471 +
  472 + function campoLista($nome, $campo, $valor, $default, $acao = '', $duplo = FALSE,
  473 + $descricao = '', $complemento = '', $desabilitado = FALSE, $obrigatorio = TRUE,
  474 + $multiple = FALSE)
  475 + {
  476 + $filtro = '';
  477 +
  478 + if ($obrigatorio) {
  479 + $filtro = "/[^ ]/";
  480 + }
  481 +
  482 + $arr_componente = array(
  483 + $duplo ? 'listaDupla' : 'lista',
  484 + ($this->__adicionando_tabela === TRUE ? $nome : $campo),
  485 + $filtro,
  486 + $valor,
  487 + $default,
  488 + $acao,
  489 + $descricao,
  490 + $complemento,
  491 + $desabilitado ? "disabled='disabled'" : '',
  492 + $multiple
  493 + );
  494 +
  495 + if (! $this->__adicionando_tabela) {
  496 + $this->campos[$nome] = $arr_componente;
  497 + }
  498 + else {
  499 + $this->__campos_tabela[] = $arr_componente;
  500 + }
  501 + }
  502 +
  503 + function campoListaDin($nome, $campo, $valor, $default, $acao = '',
  504 + $arquivo, $campo_destino, $_GET_campos = array(), $complemento = '',
  505 + $desabilitado = FALSE, $obrigatorio = TRUE, $function_extra = '', $duplo = FALSE)
  506 + {
  507 + $filtro = ($obrigatorio) ? "/[^ ]/": '';
  508 +
  509 + $this->campos[$nome] = array(
  510 + 'listaDin',
  511 + $campo,
  512 + $filtro,
  513 + $valor,
  514 + $default,
  515 + $acao,
  516 + '',
  517 + $campo_destino,
  518 + $complemento,
  519 + $desabilitado ? 'disabled' : '',
  520 + $arquivo,
  521 + $nome,
  522 + $_GET_campos,
  523 + $function_extra,
  524 + $duplo
  525 + );
  526 + }
  527 +
  528 + function campoListaAtivarPeso($nome, $campo, $valor, $default = '0',
  529 + $ativado = FALSE, $colunas = '10', $tamanho = '10', $default1 = '')
  530 + {
  531 + $this->campos[$nome] = array(
  532 + 'listaativarpeso',
  533 + $campo,
  534 + "/[^ ]/",
  535 + $valor,
  536 + $default,
  537 + $ativado,
  538 + '',
  539 + $colunas,
  540 + $tamanho,
  541 + $default1
  542 + );
  543 + }
  544 +
  545 + function campoListaAtivarPesoSelect($nome, $campo, $valor, $default = '0',
  546 + $ativado = FALSE, $valor2)
  547 + {
  548 + $this->campos[$nome] = array(
  549 + 'listaativarpesoselect',
  550 + $campo,
  551 + "/[^ ]/",
  552 + $valor,
  553 + $default,
  554 + $ativado,
  555 + $valor2
  556 + );
  557 + }
  558 +
  559 + function campoListaPesq($nome, $campo, $valor, $default, $caminho = '', $acao = '',
  560 + $duplo = FALSE, $descricao = '', $descricao2 = '', $flag = NULL, $pag_cadastro = NULL,
  561 + $disabled = '', $div = FALSE, $serializedcampos = FALSE, $obrigatorio = FALSE)
  562 + {
  563 + $this->campos[$nome] = array(
  564 + 'listapesquisa',
  565 + $campo,
  566 + $obrigatorio ? "/[^ ]/": '',
  567 + $valor,
  568 + $default,
  569 + $acao,
  570 + $descricao,
  571 + $caminho,
  572 + $descricao2,
  573 + $flag,
  574 + $pag_cadastro,
  575 + $disabled,
  576 + $div,
  577 + $serializedcampos,
  578 + $obrigatorio
  579 + );
  580 + }
  581 +
  582 + function campoMemo($nome, $campo, $valor, $colunas, $linhas, $obrigatorio = FALSE,
  583 + $descricao = '', $conta = '', $duplo = FALSE, $script = FALSE, $evento = 'onclick', $disabled = FALSE)
  584 + {
  585 + $this->campos[$nome] = array(
  586 + 'memo',
  587 + $campo,
  588 + $obrigatorio ? "/[^ ]/" : '',
  589 + $valor,
  590 + $colunas,
  591 + $linhas,
  592 + $descricao,
  593 + $conta,
  594 + $duplo,
  595 + $evento,
  596 + $script,
  597 + $disabled
  598 + );
  599 + }
  600 +
  601 + function campoNumero($nome, $campo, $valor, $tamanhovisivel, $tamanhomaximo,
  602 + $obrigatorio = FALSE, $descricao = '', $descricao2 = '', $script = FALSE,
  603 + $evento = FALSE, $duplo = FALSE, $disabled = FALSE)
  604 + {
  605 + $arr_componente = array(
  606 + $duplo ? 'textoDuplo' : 'texto',
  607 + $this->__adicionando_tabela ? $nome : $campo,
  608 + $obrigatorio ? "/^[0-9]+$/" : "*(/^[0-9]+$/)",
  609 + $valor,
  610 + $tamanhovisivel,
  611 + $tamanhomaximo,
  612 + $descricao ? $descricao : 'somente números',
  613 + $descricao2,
  614 + $script,
  615 + $evento,
  616 + $disabled
  617 + );
  618 +
  619 + if (! $this->__adicionando_tabela) {
  620 + $this->campos[$nome] = $arr_componente;
  621 + }
  622 + else {
  623 + $this->__campos_tabela[] = $arr_componente;
  624 + }
  625 + }
  626 +
  627 + function campoMonetario($nome, $campo, $valor, $tamanhovisivel, $tamanhomaximo,
  628 + $obrigatorio = FALSE, $descricao = '', $script = '', $evento = 'onChange',
  629 + $disabled = FALSE, $show_sub = TRUE, $descricao2 = '', $duplo = FALSE)
  630 + {
  631 + $arr_componente = array(
  632 + $duplo ? 'monetarioDuplo' : 'monetario',
  633 + $this->__adicionando_tabela ? $nome : $campo,
  634 + $obrigatorio ? "/^[0-9.,]+$/" : "*(/^[0-9.,]+$/)",
  635 + $valor,
  636 + $tamanhovisivel,
  637 + $tamanhomaximo,
  638 + $descricao,
  639 + $script,
  640 + $evento,
  641 + $disabled,
  642 + $show_sub,
  643 + $descricao2
  644 + );
  645 +
  646 + if (! $this->__adicionando_tabela) {
  647 + $this->campos[$nome] = $arr_componente;
  648 + }
  649 + else {
  650 + $this->__campos_tabela[] = $arr_componente;
  651 + }
  652 + }
  653 +
  654 + function campoOculto($nome, $valor)
  655 + {
  656 + $arr_componente = array(
  657 + 'oculto',
  658 + $nome,
  659 + '',
  660 + $valor
  661 + );
  662 +
  663 + if (! $this->__adicionando_tabela) {
  664 + $this->campos[$nome] = $arr_componente;
  665 + }
  666 + else {
  667 + $this->__campos_tabela['oculto'][] = $arr_componente;
  668 + }
  669 + }
  670 +
  671 + function campoRadio($nome, $campo, $valor, $default, $acao = '', $descricao = '')
  672 + {
  673 + $this->campos[$nome] = array(
  674 + 'radio',
  675 + $campo,
  676 + '',
  677 + $valor,
  678 + $default,
  679 + $acao,
  680 + $descricao
  681 + );
  682 + }
  683 +
  684 + function campoRotulo($nome, $campo, $valor, $duplo = FALSE, $descricao = '', $separador = ':')
  685 + {
  686 + $arr_componente = array(
  687 + $duplo ? 'rotuloDuplo' : 'rotulo',
  688 + $this->__adicionando_tabela ? $nome : $campo,
  689 + '',
  690 + $valor,
  691 + 6 => $descricao,
  692 + 'separador' => $separador
  693 + );
  694 +
  695 + if (! $this->__adicionando_tabela) {
  696 + $this->campos[$nome] = $arr_componente;
  697 + }
  698 + else {
  699 + $this->__campos_tabela[] = $arr_componente;
  700 + }
  701 + }
  702 +
  703 + function campoSenha($nome, $campo, $valor, $obrigatorio = FALSE, $descricao = '')
  704 + {
  705 + $this->campos[$nome] = array(
  706 + 'senha',
  707 + $campo,
  708 + $obrigatorio ? "/[^ ]/" : '',
  709 + $valor,
  710 + 10,
  711 + 100,
  712 + $descricao
  713 + );
  714 + }
  715 +
  716 + function campoTexto($nome, $campo, $valor, $tamanhovisivel, $tamanhomaximo,
  717 + $obrigatorio = FALSE, $expressao = FALSE, $duplo = FALSE, $descricao = '',
  718 + $descricao2 = '', $script = '', $evento = 'onKeyUp', $disabled = FALSE)
  719 + {
  720 + $arr_componente = array(
  721 + $duplo ? 'textoDuplo' : 'texto',
  722 + $this->__adicionando_tabela ? $nome : $campo,
  723 + $expressao ? $expressao : ($obrigatorio ? "/[^ ]/" : ''),
  724 + $valor,
  725 + $tamanhovisivel,
  726 + $tamanhomaximo,
  727 + $descricao,
  728 + $descricao2,
  729 + $script,
  730 + $evento,
  731 + $disabled
  732 + );
  733 +
  734 + if (! $this->__adicionando_tabela) {
  735 + $this->campos[$nome] = $arr_componente;
  736 + }
  737 + else {
  738 + $this->__campos_tabela[] = $arr_componente;
  739 + }
  740 + }
  741 +
  742 + function campoEmail($nome, $campo, $valor, $tamanhovisivel, $tamanhomaximo,
  743 + $obrigatorio = FALSE, $expressao = FALSE, $duplo = FALSE, $descricao = '',
  744 + $descricao2 = '', $script = '')
  745 + {
  746 + $this->campos[$nome] = array(
  747 + $duplo ? 'emailDuplo' : 'email',
  748 + $campo,
  749 + $expressao ? $expressao : ($obrigatorio ? "/^[a-z_\-\.0-9]+$/" : ''),
  750 + $valor,
  751 + $tamanhovisivel,
  752 + $tamanhomaximo,
  753 + $descricao,
  754 + $descricao2,
  755 + $script
  756 + );
  757 + }
  758 +
  759 + function campoSuggest($nome, $campo, $valor, $obrigatorio = FALSE, $expressao = FALSE,
  760 + $duplo = FALSE, $descricao = '', $arquivo = 'xml_pessoas.php')
  761 + {
  762 + $this->campos[$nome] = array(
  763 + 'suggest',
  764 + $campo,
  765 + $expressao ? $expressao : ($obrigatorio ? "/[^ ]/" : ''),
  766 + $valor,
  767 + $descricao,
  768 + $descricao2
  769 + );
  770 + }
  771 +
  772 + function campoTextoPesquisa($nome, $campo, $valor, $tamanhovisivel, $tamanhomaximo,
  773 + $obrigatorio = FALSE, $caminho = '', $expressao = FALSE, $duplo = FALSE,
  774 + $descricao = '', $descricao2 = '', $serializedcampos = NULL, $disabled = FALSE,
  775 + $script = '', $evento = 'onChange')
  776 + {
  777 + $arr_componente = array(
  778 + $duplo ? 'textoPesquisaDuplo' : 'textoPesquisa',
  779 + $this->__adicionando_tabela ? $nome : $campo,
  780 + $expressao ? $expressao : ($obrigatorio ? "/[^ ]/" : ''),
  781 + $valor,
  782 + $tamanhovisivel,
  783 + $tamanhomaximo,
  784 + $descricao,
  785 + $descricao2,
  786 + $caminho,
  787 + $serializedcampos,
  788 + $disabled,
  789 + $script,
  790 + $evento
  791 + );
  792 +
  793 + if (! $this->__adicionando_tabela) {
  794 + $this->campos[$nome] = $arr_componente;
  795 + }
  796 + else {
  797 + $this->__campos_tabela[] = $arr_componente;
  798 + }
  799 + }
  800 +
  801 + function campoTextoInv($nome, $campo, $valor, $tamanhovisivel, $tamanhomaximo,
  802 + $obrigatorio = FALSE, $expressao = FALSE, $duplo = FALSE, $descricao = '',
  803 + $descricao2 = '', $script = '', $evento = 'onKeyUp', $name = '')
  804 + {
  805 + $name = $name ? $name : $nome;
  806 + $this->campos[$nome] = array(
  807 + $duplo ? 'textoDuploInv' : 'textoInv',
  808 + $campo,
  809 + $expressao ? $expressao : ($obrigatorio ? "/[^ ]/" : ''),
  810 + $valor,
  811 + $tamanhovisivel,
  812 + $tamanhomaximo,
  813 + $descricao,
  814 + $descricao2,
  815 + $script,
  816 + $evento,
  817 + $name
  818 + );
  819 + }
  820 +
  821 + function campoTheEditor ($nome, $campo, $valor, $largura, $altura)
  822 + {
  823 + $this->campos[$nome] = array(
  824 + 'theEditor',
  825 + $campo,
  826 + $valor,
  827 + $largura,
  828 + $altura
  829 + );
  830 + }
  831 +
  832 + function campoQuebra()
  833 + {
  834 + $this->campos['espaco' . $this->num_espaco] = array('espaco', '', '', '', '', '', '', '');
  835 + $this->num_espaco++;
  836 + }
  837 +
  838 + function campoQuebra2($cor = '#000000', $altura = 2)
  839 + {
  840 + $this->campos['linha_preta' . $this->num_espaco] = array(
  841 + 'linha_preta',
  842 + 'cor' => $cor,
  843 + 'altura' => $altura,
  844 + '',
  845 + '',
  846 + '',
  847 + '',
  848 + ''
  849 + );
  850 +
  851 + $this->num_espaco++;
  852 + }
  853 +
  854 + function setFocus($campo)
  855 + {
  856 + $this->campoFoco = $campo;
  857 + }
  858 +
  859 + function campoTiny($id, $valor, $obrigatorio = FALSE)
  860 + {
  861 + $this->campos['0'] = array('tiny', '', FALSE, $valor, $obrigatorio);
  862 + }
  863 +
  864 + function MakeCampos($array_campos = NULL, $adicionador_indice = NULL, $todos_inline = FALSE,
  865 + $todos_disabled = FALSE, $junta_linhas = FALSE, $start_md = NULL)
  866 + {
  867 + $retorno = '';
  868 + $gerou_script = FALSE;
  869 +
  870 + if (! $arr_campos) {
  871 + $arr_campos = $this->campos;
  872 + }
  873 +
  874 + reset($arr_campos);
  875 + $campo_anterior = '';
  876 + $md = TRUE;
  877 +
  878 + if (! is_null($start_md) && is_bool($start_md)) {
  879 + $md = $start_md;
  880 + }
  881 +
  882 + $foiDuplo = $junta_linhas;
  883 +
  884 + // Marca quantos valores foram passados para o prenchimento das repetições
  885 + $adicionador_total_valores = 5;
  886 +
  887 + $javascript .= "
  888 + function tabela(name, counter)
  889 + {
  890 + // Seta variavel para não reordenar id dos campos
  891 + this.setReordena = function(reordenar)
  892 + {
  893 + this.reordenar = reordenar;
  894 + }
  895 +
  896 + // Construtor
  897 + this.constructor = function() {
  898 +
  899 + // Contém uma referência ao objeto
  900 + var This = this;
  901 +
  902 + this.id = counter;
  903 +
  904 + this.afterAddRow = function(){};
  905 + this.afterRemoveRow = function(){};
  906 +
  907 + this.isIE = (navigator.appName.indexOf('Microsoft') != -1) ? 1 : 0;
  908 + this.nome = name;
  909 + this.campos = new Array();
  910 + this.reordenar = true;
  911 +
  912 + this.getId = function() { return this.id; }
  913 +
  914 + var numColumns = document.getElementById(This.nome).rows[1].childNodes.length;
  915 +
  916 + var row = document.getElementById(This.nome).insertRow(document.getElementById(This.nome).rows.length-1);
  917 +
  918 + for (var ct = 0; ct < numColumns - 1; ct++) {
  919 + var campo = document.getElementById(This.nome).rows[2].childNodes[ct].cloneNode(true);
  920 +
  921 + if (This.isIE) {
  922 + if(campo.childNodes[0].type == 'text')
  923 + campo.childNodes[0].value = '';
  924 + else if(campo.childNodes[0].type == 'select-one')
  925 + campo.childNodes[0].value = '';
  926 + else if(campo.childNodes[0].type == 'checkbox')
  927 + campo.childNodes[0].checked = false;
  928 + }
  929 + else {
  930 + if (campo.childNodes[1].type == 'text')
  931 + campo.childNodes[1].value = '';
  932 + else if(campo.childNodes[1].type == 'select-one')
  933 + campo.childNodes[1].value = '';
  934 + else if(campo.childNodes[1].type == 'checkbox')
  935 + campo.childNodes[1].checked = false;
  936 + }
507 937  
508   - var campo = document.getElementById(This.nome).rows[2].childNodes[ct].cloneNode(true);
  938 + This.campos.push(campo);
  939 + }
509 940  
  941 + var campo = document.getElementById(This.nome).rows[2].childNodes[ct].cloneNode(true);
  942 + var campos_oculto = campo.getElementsByTagName('INPUT');
510 943  
511   - if(This.isIE)
512   - {
513   - if(campo.childNodes[0].type == 'text')
514   - campo.childNodes[0].value = '';
515   - else if(campo.childNodes[0].type == 'select-one')
516   - campo.childNodes[0].value = '';
517   - else if(campo.childNodes[0].type == 'checkbox')
518   - campo.childNodes[0].checked = false;
519   - }
520   - else
521   - {
522   - if(campo.childNodes[1].type == 'text')
523   - campo.childNodes[1].value = '';
524   - else if(campo.childNodes[1].type == 'select-one')
525   - campo.childNodes[1].value = '';
526   - else if(campo.childNodes[1].type == 'checkbox')
527   - campo.childNodes[1].checked = false;
528   - }
  944 + for (var co = 0; co < campos_oculto.length; co++) {
  945 + campos_oculto[co].id = /[a-zA-Z_-]*/.exec(campos_oculto[co].id) + '[' + This.id +']';
  946 + campos_oculto[co].value = '';
  947 + }
529 948  
530   - This.campos.push(campo);
  949 + This.campos.push(campo);
  950 + }
531 951  
532   - }
  952 + // Call the constructor
  953 + this.constructor();
533 954  
534   - var campo = document.getElementById(This.nome).rows[2].childNodes[ct].cloneNode(true);
  955 + this.classe = (this.id % 2 == 0 )? 'formlttd' : 'formmdtd';
  956 + this.addRow = function()
  957 + {
  958 + var This = this;
535 959  
536   - var campos_oculto = campo.getElementsByTagName('INPUT');
  960 + This.classe = (This.id % 2 == 0 )? 'formmdtd' : 'formlttd';
  961 + var numColumns = This.campos.length
537 962  
538   - for(var co=0;co<campos_oculto.length;co++)
539   - {
540   - campos_oculto[co].id = /[a-zA-Z_-]*/.exec(campos_oculto[co].id) + '[' + This.id +']';
541   - campos_oculto[co].value = '';
542   - }
  963 + var row = document.getElementById(This.nome).insertRow(document.getElementById(This.nome).rows.length-2);
543 964  
544   - This.campos.push(campo);
  965 + row.setAttribute(\"id\", \"tr_\"+This.nome+\"[\"+This.id+\"]\");
  966 + row.setAttribute(\"name\", \"tr_\"+This.nome+\"[]\");
545 967  
546   - }
  968 + row.className = This.classe;
547 969  
548   - /*
549   - call the constructor
550   - */
551   - this.constructor();
  970 + for (var ct = 0; ct < numColumns - 1; ct++) {
  971 + var campo = This.campos[ct].cloneNode(true);
  972 + campo.className = This.classe;
  973 + campo.setAttribute(\"id\", /[a-zA-Z_-]*/.exec(campo.id)+\"[\"+This.id+\"]\");
552 974  
  975 + if (This.isIE) {
  976 + campo.childNodes[0].id = /[a-zA-Z_-]*/.exec(campo.childNodes[0].id) + '[' + This.id +']';
  977 + campo.childNodes[0].name = /[a-zA-Z_-]*/.exec(campo.childNodes[0].name) + '[' + This.id +']';
553 978  
554   - this.classe = (this.id % 2 == 0 )? 'formlttd' : 'formmdtd';
555   - this.addRow = function ()
556   - {
  979 + if (campo.childNodes[0].type == 'select-one')
  980 + campo.childNodes[0].selectedIndex = '';
  981 + }
  982 + else {
  983 + campo.childNodes[1].id = /[a-zA-Z_-]*/.exec(campo.childNodes[1].id) + '[' + This.id +']';
  984 + campo.childNodes[1].name = /[a-zA-Z_-]*/.exec(campo.childNodes[1].name) + '[' + This.id +']';
557 985  
558   - var This = this;
559   - //if(This.id == 0)
560   - //setVisibility(document.getElementById('tr_' + This.nome + '_cab'),true);
  986 + if (campo.childNodes[1].type == 'select-one')
  987 + campo.childNodes[1].selectedIndex = '';
  988 + }
561 989  
562   - This.classe = (This.id % 2 == 0 )? 'formmdtd' : 'formlttd';
563   - var numColumns = This.campos.length
  990 + row.appendChild(campo);
  991 + }
564 992  
565   - var row = document.getElementById(This.nome).insertRow(document.getElementById(This.nome).rows.length-2);
  993 + This.classe = (This.classe == 'formmdtd') ? 'formlttd' : 'formmdtd';
566 994  
567   - row.setAttribute( \"id\", \"tr_\"+This.nome+\"[\"+This.id+\"]\");
568   - row.setAttribute( \"name\", \"tr_\"+This.nome+\"[]\");
  995 + var campo = this.campos[This.campos.length-1].cloneNode(true);
569 996  
570   - row.className = This.classe;
  997 + row.appendChild(campo);
571 998  
572   - for(var ct=0;ct<numColumns-1;ct++)
573   - {
  999 + var campos_oculto = campo.getElementsByTagName('INPUT');
574 1000  
575   - var campo = This.campos[ct].cloneNode(true);
  1001 + for (var co = 0; co < campos_oculto.length; co++) {
  1002 + campos_oculto[co].id = /[a-zA-Z_-]*/.exec(campos_oculto[co].id) + '[' + This.id +']';
  1003 + campos_oculto[co].name = /[a-zA-Z_-]*/.exec(campos_oculto[co].name) + '[' + This.id +']';
  1004 + }
576 1005  
577   - campo.className = This.classe;
578   -
579   - campo.setAttribute( \"id\", /[a-zA-Z_-]*/.exec(campo.id)+\"[\"+This.id+\"]\");
  1006 + var link_deletar = campo.getElementsByTagName('A');
580 1007  
581   - if(This.isIE)
582   - {
583   - campo.childNodes[0].id = /[a-zA-Z_-]*/.exec(campo.childNodes[0].id) + '[' + This.id +']';
584   - campo.childNodes[0].name = /[a-zA-Z_-]*/.exec(campo.childNodes[0].name) + '[' + This.id +']';
  1008 + link_deletar[0].id = /[a-zA-Z_-]*/.exec(link_deletar[0].id) + '[' + This.id +']';
585 1009  
586   - if(campo.childNodes[0].type == 'select-one')
587   - campo.childNodes[0].selectedIndex = '';
588   - }
589   - else
590   - {
591   - campo.childNodes[1].id = /[a-zA-Z_-]*/.exec(campo.childNodes[1].id) + '[' + This.id +']';
592   - campo.childNodes[1].name = /[a-zA-Z_-]*/.exec(campo.childNodes[1].name) + '[' + This.id +']';
  1010 + This.id++;
  1011 + this.afterAddRow();
  1012 + }
593 1013  
594   - if(campo.childNodes[1].type == 'select-one')
595   - campo.childNodes[1].selectedIndex = '';
596   - }
  1014 + this.removeRow = function(row)
  1015 + {
  1016 + var This = this;
597 1017  
  1018 + var tab = row;
  1019 + var tr;
  1020 + while (tab.nodeName != 'TABLE') {
  1021 + if(tab.nodeName == 'TR')
  1022 + tr = tab;
598 1023  
  1024 + tab = tab.parentNode;
  1025 + }
599 1026  
600   - row.appendChild(campo);
  1027 + var trs = tab.getElementsByTagName('TR');
601 1028  
602   - }
  1029 + var linha = 0;
603 1030  
604   - This.classe = (This.classe == 'formmdtd')? 'formlttd' : 'formmdtd';
  1031 + for (var ct = 2; ct < trs.length - 1; ct++) {
  1032 + if (trs[ct] == tr) {
  1033 + tab.deleteRow(ct);
  1034 + }
  1035 + }
605 1036  
606   - var campo = this.campos[This.campos.length-1].cloneNode(true);
607   - //var img = campo.getElementsByTagName('IMG')[0];
608   - //var link = campo.getElementsByTagName('A')[0];
  1037 + trs = document.getElementsByName('tr_'+This.nome + '[]');
  1038 + var classe = 'formmdtd';
609 1039  
610   - row.appendChild(campo);
  1040 + for (var ct = 0; ct < trs.length; ct++) {
  1041 + if (trs[ct] && trs[ct].id != 'adicionar_linha') {
  1042 + trs[ct].className = classe;
611 1043  
612   - var campos_oculto = campo.getElementsByTagName('INPUT');
  1044 + for (var c = 0; c < trs[ct].cells.length; c++)
  1045 + trs[ct].cells[c].className = classe;
613 1046  
614   - for(var co=0;co<campos_oculto.length;co++)
615   - {
616   - campos_oculto[co].id = /[a-zA-Z_-]*/.exec(campos_oculto[co].id) + '[' + This.id +']';
617   - campos_oculto[co].name = /[a-zA-Z_-]*/.exec(campos_oculto[co].name) + '[' + This.id +']';
618   - //campos_oculto[co].name = /[a-zA-Z_-]*/.exec(campos_oculto[co].name) + '[]';
  1047 + classe = (classe == 'formmdtd')? 'formlttd' : 'formmdtd';
  1048 + }
  1049 + }
619 1050  
620   - }
  1051 + if (This.reordenar) {
  1052 + This.setId(tab);
  1053 + This.id--;
  1054 + }
621 1055  
622   - var link_deletar = campo.getElementsByTagName('A');
  1056 + if (This.id == 0)
  1057 + This.addRow();
623 1058  
624   - link_deletar[0].id = /[a-zA-Z_-]*/.exec(link_deletar[0].id) + '[' + This.id +']';
  1059 + this.afterRemoveRow();
  1060 + }
625 1061  
626   - This.id++;
627   - this.afterAddRow();
628   - }
  1062 + this.setId = function setId(tab)
  1063 + {
  1064 + var trs = tab.getElementsByTagName('TR');
  1065 + var cod_ini = 0;
629 1066  
  1067 + for (var ct = 2; ct < trs.length; ct++) {
  1068 + var nome_tr = /[a-zA-Z-_]*/.exec(trs[ct].id);
630 1069  
631   - this.removeRow = function(row)
632   - {
633   - var This = this;
  1070 + if (!nome_tr)
  1071 + continue;
634 1072  
  1073 + trs[ct].setAttribute( \"id\",nome_tr + '[' + cod_ini + ']');
635 1074  
636   - var tab = row;
637   - var tr;
638   - while (tab.nodeName != 'TABLE'){
  1075 + for (var c = 0; c < trs[ct].cells.length; c++) {
  1076 + var nome_td = /[a-zA-Z-_]*/.exec(trs[ct].cells[c].id);
  1077 + trs[ct].cells[c].setAttribute( \"id\",nome_td + '[' + cod_ini + ']');
639 1078  
640   - if(tab.nodeName == 'TR')
641   - tr = tab;
  1079 + var campos = trs[ct].cells[c].childNodes;
  1080 +
  1081 + for (var inp = 0 ; inp < campos.length; inp++) {
  1082 + if (!campos[inp].id)
  1083 + continue;
642 1084  
643   - tab = tab.parentNode;
  1085 + var nome_inp = /[a-zA-Z-_]*/.exec(campos[inp].id);
644 1086  
645   - }
  1087 + campos[inp].setAttribute(\"id\",nome_inp + '[' + cod_ini + ']');
  1088 + campos[inp].setAttribute(\"name\",nome_inp + '[' + cod_ini + ']');
  1089 + }
  1090 + }
  1091 +
  1092 + cod_ini++;
  1093 + }
  1094 + }
  1095 + }
  1096 + ";
  1097 +
  1098 + $retorno .= "<script>$javascript</script>";
  1099 + $classe = $md ? 'formlttd' : 'formmdtd';
  1100 + $md = $md ? FALSE : TRUE;
  1101 + $index = 0;
  1102 +
  1103 + while (list($nome, $componente) = each($arr_campos)) {
  1104 + $nome_add = $nome;
  1105 + $campo_tabela = FALSE;
  1106 +
  1107 + // Cria nova tab
  1108 + if (ereg("^(tabbed_add_[0-9]+)", $nome) === 1) {
  1109 + $nomes_tab = urlencode(serialize($arr_campos['cabecalho_tab']));
  1110 + unset($arr_campos['cabecalho_tab']);
  1111 +
  1112 + // $arr_campos
  1113 + $desabilitado_tab = urlencode(serialize($arr_campos['desabilitado_tab']));
  1114 + unset($arr_campos['desabilitado_tab']);
  1115 +
  1116 + $retorno .= "<tr id='tr_tab'>
  1117 + <td valign='top' colspan='2' width='100%' align='center'>";
  1118 +
  1119 + $rand = rand();
  1120 +
  1121 + $retorno .= "<!-- INICIO TABELA 1 --><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" id=\"tabela_principal\" align=center width='100%'>
  1122 + <tr>
  1123 + <td valign=top height=30>
  1124 + <link href=\"styles/styles_tab.css?$rand\" rel=\"stylesheet\" type=\"text/css\" />
  1125 + <script type=\"text/javascript\" language=\"JavaScript1.2\" src=\"scripts/dtabs.js?$rand\"></script>
  1126 + <script type=\"text/javascript\" src=\"scripts/tabs_cab.php?nomes_tab={$nomes_tab}&desabilitado_tab=$desabilitado_tab\"></script>
  1127 + </td>
  1128 + </tr>";
  1129 + $retorno .= '<tr>
  1130 + <td valign=top height=auto class="pageTabb">&nbsp;
  1131 + <!-- INICIO TABELA 2 -->
  1132 + <table cellpadding="0" cellspacing="0" border="0" height=auto>
  1133 + <tr>
  1134 + <td valign=top width=1><img src="imagens/img/blank.gif" width=1 height=1></td>
  1135 + <td valign=top width=100% class="tabPage" height="auto">';
  1136 +
  1137 + $existe_tab_iniciada = TRUE;
  1138 + continue;
  1139 + }
  1140 +
  1141 + if (ereg("^(tab_name_[0-9]+)", $nome) === 1) {
  1142 + if ($existe_tab_aberta) {
  1143 + if ($this->__segue_fluxo) {
  1144 + $colspan = 2;
  1145 + $sequencia = unserialize($this->__sequencia_fluxo);
  1146 +
  1147 + if (isset($sequencia[$index - 1])) {
  1148 + $prox_id = array_flip($sequencia);
  1149 + $prox_id = $prox_id[$index] * 2;
  1150 +
  1151 + $retorno .= "<tr><td align=left><img onclick='LTb0(\"0\", \"$prox_id\")' style='cursor:pointer' src='imagens/bot_anterior.gif' border='0' /></td>";
  1152 + $colspan = 1;
  1153 + }
  1154 + if ($sequencia[$index] != 0) {
  1155 + $prox_id = $sequencia[$index++]*2;
  1156 + $retorno .= "<td colspan=$colspan align=right><img onclick='validaTab(".($componente['id']-1).");LTb0(\"0\", \"$prox_id\")' style='cursor:pointer' src='imagens/bot_proximo.gif' border='0' /></td></tr>";
  1157 + }
  1158 + else {
  1159 + $retorno .= "<td colspan=$colspan align=right><img onclick='{$this->__acao_enviar_abas}' style='cursor:pointer' src='imagens/bot_salvar.gif' border='0' /></td></tr>";
  1160 + }
  1161 + }
  1162 +
  1163 + $retorno .= "<!-- FIM TABELA 3 --></table></div>";
  1164 + }
  1165 +
  1166 + $existe_tab_aberta = TRUE;
  1167 + $retorno .= "<div id=\"content{$componente['id']}\" style=\"visibility: hidden;\" class=\"tabPage\">";
  1168 + $retorno .= "<!-- INICIO TABELA 3 --><table cellpadding=\"2\" cellspacing=\"0\" border=\"0\" width=100% align=center>";
  1169 +
  1170 + continue;
  1171 + }
  1172 +
  1173 + if ($nome === 'fim_tab') {
  1174 + if ($existe_tab_aberta) {
  1175 + if ($this->__segue_fluxo) {
  1176 + $colspan = 2;
  1177 + $sequencia = unserialize($this->__sequencia_fluxo);
  1178 +
  1179 + if (isset($sequencia[$index - 1])) {
  1180 + $prox_id = array_flip($sequencia);
  1181 + $prox_id = $prox_id[$index] * 2;
  1182 +
  1183 + $retorno .= "<tr><td align=left><img onclick='LTb0(\"0\", \"$prox_id\")' style='cursor:pointer' src='imagens/bot_anterior.gif' border='0' /></td>";
  1184 + $colspan = 1;
  1185 + }
  1186 +
  1187 + if (! $this->__sequencia_default) {
  1188 + if($sequencia[$index] != 0) {
  1189 + $prox_id = $sequencia[$index] * 2;
  1190 + $retorno .= "<td colspan=$colspan align=right><img onclick='validaTab(".($componente['id']-1).");LTb0(\"0\", \"$prox_id\")' style='cursor:pointer' src='imagens/bot_proximo.gif' border='0' /></td></tr>";
  1191 + }
  1192 + else {
  1193 + $retorno .= "<td colspan=$colspan align=right><img onclick='{$this->__acao_enviar_abas}' style='cursor:pointer' src='imagens/bot_salvar.gif' border='0' /></td></tr>";
  1194 + }
  1195 + }
  1196 + else {
  1197 + $retorno .= "<td colspan=$colspan align=right><img onclick='{$this->__acao_enviar_abas}' style='cursor:pointer' src='imagens/bot_salvar.gif' border='0' /></td></tr>";
  1198 + }
  1199 + }
  1200 +
  1201 + $retorno .= "<!-- FIM TABELA 3 --></table></div>";
  1202 + }
  1203 +
  1204 + $retorno .= " </td>
  1205 + <td valign=top width=1><img src='imagens/img/blank.gif' width=1 height=1></td>
  1206 + </tr>
  1207 + </table><!-- FIM TABELA 2 -->
  1208 + </td>
  1209 + </tr>
  1210 + </table><!-- FIM TABELA 1 -->";
  1211 + $retorno .= '<br></td></tr>';
  1212 +
  1213 + continue;
  1214 + }
  1215 +
  1216 + if (ereg("^(tab_add_[0-9]+)",$nome) === 1) {
  1217 + $campo_tabela = TRUE;
  1218 + $javascript = '';
  1219 +
  1220 + $cabecalho = $componente['cabecalho'];
  1221 + $nome_tabela = $componente['nome'];
  1222 + $valores = $componente['valores'];
  1223 + $titulo = $componente['titulo'];
  1224 + $largura = $componente['largura'] ? " width=\"{$componente['largura']}\" " : "";
  1225 + $valores_lista_tabela = $componente['valores_lista'];
  1226 + $componente = array_shift($componente);
  1227 +
  1228 + $campos_oculto = $componente['oculto'];
  1229 + unset($componente['oculto']);
  1230 +
  1231 + $classe = $md ? 'formlttd' : 'formmdtd';
  1232 + $md = $md ? FALSE : TRUE;
  1233 +
  1234 + $retorno .= "<tr id='tr_$nome_tabela' class='$classe'><td valign='top' align='center' colspan='2'>";
  1235 + $retorno .= "\n<table cellspacing='0' $largura id='$nome_tabela' cellpadding='2' style='border-width:1px 1px 1px 1px;border-color:#000000;border-style:solid;margin:10px 0px 10px 0px;' >";
  1236 +
  1237 + $total_campos = count($cabecalho);
  1238 + $span = $total_campos + 1;
  1239 +
  1240 + if ($titulo) {
  1241 + $retorno.= "<tr align='center' id='tr_{$nome_tabela}_tit' style='font-weight:bold' class='formdktd'><td colspan='$span'>$titulo</td></tr>";
  1242 + }
  1243 + else {
  1244 + $retorno.= "<tr align='center' id='tr_{$nome_tabela}_tit' style='font-weight:bold;display:none;visibility:hidden;' ><td colspan='$span'>&nbsp;</td></tr>";
  1245 + }
  1246 +
  1247 + $retorno.= "<tr align='center' style='font-weight:bold' id='tr_{$nome_tabela}_cab'>";
  1248 +
  1249 + foreach ($cabecalho as $key => $cab) {
  1250 + $expressao_regular = $componente[$key][2];
  1251 +
  1252 + if ($expressao_regular && substr( $expressao_regular, 0, 1 ) != "*") {
  1253 + $obrigatorio = "<span class=\"campo_obrigatorio\">*</span>";
  1254 + }
  1255 + else {
  1256 + $obrigatorio = '';
  1257 + }
  1258 +
  1259 + $retorno.= "<td class='formmdtd' id='td_$cab' align='center'><span class='form'>$cab</span>{$obrigatorio}</td>";
  1260 + }
  1261 +
  1262 + $retorno.= "<td class='formmdtd' id='td_acao' align='center'><span class='form'>A&ccedil;&atilde;o</span></td>";
  1263 + $retorno.= "</tr>";
  1264 +
  1265 + $click = "$nome_add.removeRow(this);";
  1266 +
  1267 + $img = "<img src=\"imagens/banco_imagens/excluirrr.gif\" border=\"0\" alt=\"excluir\" />";
  1268 + $md2 = FALSE;
  1269 +
  1270 + if (! count($valores)) {
  1271 + $valores[0] = '';
  1272 + }
  1273 +
  1274 + foreach ($valores as $key2 => $valor) {
  1275 + $classe2 = $md2 ? 'formlttd' : 'formmdtd';
  1276 + $md2 = $md2 ? FALSE : TRUE;
  1277 +
  1278 + $retorno .= "<tr id='tr_{$nome_tabela}[$key2]' name='tr_{$nome_tabela}[]' $style class='$classe2'>";
  1279 + $array_valores_lista = $valores_lista_tabela[$key2];
  1280 +
  1281 + foreach ($componente as $key => $campo_) {
  1282 + $nome = $campo_[1];
  1283 +
  1284 + if ($campo_[10]) {
  1285 + $disabled = 'disabled';
  1286 + }
  1287 + else {
  1288 + $disabled = '';
  1289 + }
  1290 +
  1291 + if ($campo_[9] && $campo_[8]) {
  1292 + $evento = " {$campo_[9]}=\"{$campo_[8]}\"";
  1293 + }
  1294 + else {
  1295 + $evento = '';
  1296 + }
646 1297  
647   - var trs = tab.getElementsByTagName('TR');
  1298 + $expressao_regular = $campo_[2];
648 1299  
649   - var linha = 0;
  1300 + if ($expressao_regular && substr( $expressao_regular, 0, 1 ) != "*") {
  1301 + $class = 'obrigatorio';
  1302 + }
  1303 + else {
  1304 + $class = 'geral';
  1305 + }
650 1306  
651   - for(var ct=2;ct<trs.length-1;ct++)
652   - {
653   - if(trs[ct] == tr){
654   - tab.deleteRow(ct);
655   - //ct=1;
656   - //classe = 'formmdtd'
657   - //var trs = tab.getElementsByTagName('TR');
658   - //continue;
659   - }
  1307 + $center = (strtolower($campo_[0]) == 'rotulo' || strtolower($campo_[0]) == 'check' || $largura) ?
  1308 + 'align="center"' : '';
660 1309  
661   - /*if(trs[ct] && trs[ct].id != 'adicionar_linha')
662   - {
663   - trs[ct].className = classe;
  1310 + $retorno .= "<td class='$classe2' $center id='td_{$nome}[{$key2}]' valign='top'>\n";
664 1311  
665   - for(var c=0;c<trs[ct].cells.length;c++)
666   - trs[ct].cells[c].className = classe;
  1312 + switch (strtolower($campo_[0])) {
  1313 + case 'texto':
  1314 + $retorno .= $this->getCampoTexto("{$nome}[{$key2}]","{$nome}[{$key2}]",$valor[$key],$campo_[4],$campo_[5],$evento,$campo_[10],"",$class,$campo_[7]);
  1315 + break;
667 1316  
668   - classe = (classe == 'formmdtd')? 'formlttd' : 'formmdtd';
669   - }*/
670   - }
  1317 + case 'monetario':
  1318 + $retorno .= $this->getCampoMonetario("{$nome}[{$key2}]","{$nome}[{$key2}]",$valor[$key],$campo_[4],$campo_[5],$campo_[9],$campo_[6],$campo_[11],$class,$campo_[8],$campo_[7]);
  1319 + break;
  1320 +
  1321 + case 'hora':
  1322 + $retorno .= $this->getCampoHora("{$nome}[{$key2}]","{$nome}[{$key2}]",$valor[$key],$class,$campo_[4],$campo_[5],"","");
  1323 + break;
671 1324  
672   - //trs = tab.getElementsByTagName('TR');
673   - trs = document.getElementsByName('tr_'+This.nome + '[]');
674   - var classe = 'formmdtd';
  1325 + case 'lista':
  1326 + $lista = NULL;
675 1327  
676   - for(var ct=0;ct<trs.length;ct++)
677   - {
678   - if(trs[ct] && trs[ct].id != 'adicionar_linha')
679   - {
680   - trs[ct].className = classe;
  1328 + if (is_array($array_valores_lista)) {
  1329 + $lista = array_shift($array_valores_lista);
  1330 + }
  1331 +
  1332 + $lista = (sizeof($lista)) ?
  1333 + $lista : $campo_[3];
  1334 +
  1335 + $retorno .= $this->getCampoLista("{$nome}[{$key2}]","{$nome}[$key2]",$campo_[5],$lista,$valor[$key],$campo_[7],$campo_[8],$class,$campo_[9]);
  1336 + break;
  1337 +
  1338 + case 'rotulo':
  1339 + $retorno .= $this->getCampoRotulo($campo_[3]?$campo_[3] : $valor[$key]);
  1340 + break;
  1341 +
  1342 + case 'check' :
  1343 + $retorno .= $this->getCampoCheck("{$nome}[{$key2}]","{$nome}[{$key2}]",$campo_[3]?$campo_[3] : $valor[$key],$campo_[4],$campo_[5],$campo_[6]);
  1344 + break;
  1345 +
  1346 + case 'cnpj':
  1347 + $retorno .= $this->getCampoCNPJ("{$nome}[{$key2}]","{$nome}[{$key2}]",$valor[$key],$class,$campo_[4],$campo_[5]);
  1348 + break;
  1349 +
  1350 + case 'cpf':
  1351 + $retorno .= $this->getCampoCPF("{$nome}[{$key2}]","{$nome}[{$key2}]",$valor[$key],$class,$campo_[4],$campo_[5],$campo_[8]);
  1352 + break;
  1353 +
  1354 + case 'idfederal':
  1355 + $retorno .= $this->getCampoIdFederal("{$nome}[{$key2}]","{$nome}[{$key2}]",$valor[$key],$class,$campo_[4],$campo_[5],$campo_[8]);
  1356 + break;
  1357 +
  1358 + case 'data':
  1359 + $retorno .= $this->getCampoData("{$nome}[{$key2}]","{$nome}[{$key2}]",$valor[$key],$class,$campo_[4],$campo_[5],$campo_[9]);
  1360 + break;
  1361 +
  1362 + case 'textopesquisa':
  1363 + $retorno .= $this->getCampoTextoPesquisa("{$nome}[{$key2}]","{$nome}[{$key2}]",$valor[$key],$class,$campo_[4],$campo_[5],$campo_[10],$campo_[8],$campo_[9],$campo_[7], $campo_[12], $campo_[11]);
  1364 + break;
  1365 +
  1366 + case 'cep':
  1367 + $retorno .= $this->getCampoCep("{$nome}[{$key2}]","{$nome}[{$key2}]",$valor[$key],$class,$campo_[4],$campo_[5],$campo_[8],$campo_[7]);
  1368 + break;
  1369 + }
  1370 +
  1371 + $retorno .= '</td>';
  1372 + $evento = '';
  1373 + }
  1374 +
  1375 + $retorno_oculto = '';
  1376 +
  1377 + if (is_array($campos_oculto)) {
  1378 + foreach ($campos_oculto as $key_oculto => $campo_oculto) {
  1379 + $key_oculto = $key_oculto + sizeof($cabecalho);
  1380 +
  1381 + $campo_oculto[3] = $campo_oculto[3] ?
  1382 + $campo_oculto[3] : $valor[$key_oculto];
  1383 +
  1384 + $retorno_oculto .= $this->getCampoOculto("{$campo_oculto[1]}[{$key2}]",$campo_oculto[3],"{$campo_oculto[1]}[{$key2}]");
  1385 + }
  1386 + }
  1387 +
  1388 + $retorno .= "<td align='center'><a href='javascript:void(0)' onclick='$click' id='link_remove[$key2]' style='outline: none;'>$img</a>$retorno_oculto</td>";
  1389 + $img = "<img src=\"imagens/banco_imagens/excluirrr.gif\" border=\"0\" alt=\"excluir\" />";
  1390 + $id = count($valores);
  1391 +
  1392 + $javascript .= "
  1393 + var $nome_add = new tabela('{$nome_tabela}','{$id}');\n";
  1394 + } // endforeach.
  1395 +
  1396 + $retorno .= '</tr>';
  1397 +
  1398 + $click = "$nome_add.addRow();";
  1399 + $img = "<img src=\"imagens/nvp_bot_novo.png\" border=\"0\" alt=\"incluir\" />";
  1400 + $retorno .= "<tr id='adicionar_linha'>";
  1401 + $tt = $total_campos + 1;
  1402 + $retorno .= "<td colspan='$tt' align='left' style='border-width:1px 0px 0px 0px;border-style:dotted;border-color:#000000;'><a href='javascript:void(0)' id='btn_add_$nome_add' onclick='$click' style='outline: none;'>$img</a></td>";
  1403 + $retorno .= "</tr>";
  1404 +
  1405 + $retorno .= "</table>";
  1406 + $retorno .= "</td></tr>";
  1407 +
  1408 + $retorno .= "<script type='text/javascript'>$javascript</script>";
  1409 + continue;
  1410 + }
  1411 +
  1412 + if ($this->__adicionando && FALSE) {
  1413 + // Adiciona o campo no bloco de repetição
  1414 + $adicionador_campos_repeticao[$nome] = $componente;
  1415 + $adicionador_complemento_campo = "[{$adicionador_indice}]";
  1416 + $campo_valor = $componente[3][$adicionador_indice];
  1417 + }
  1418 + else {
  1419 + $adicionador_complemento_campo = '';
  1420 + $campo_valor = $componente[3];
  1421 + }
  1422 +
  1423 + $nome .= $adicionador_complemento_campo;
  1424 + $expressao_regular = $componente[2];
  1425 +
  1426 + if ($expressao_regular && substr($expressao_regular, 0, 1) != "*") {
  1427 + $class = 'obrigatorio';
  1428 + $obrigatorio = "<span class=\"campo_obrigatorio\">*</span>";
  1429 + }
  1430 + else {
  1431 + $class = 'geral';
  1432 + $obrigatorio = '';
  1433 + }
  1434 +
  1435 + // Separador: insere uma linha preta
  1436 + if ($componente[0] == 'linha_preta') {
  1437 + $retorno .= "<tr><td style='padding:0px;background-color:{$componente["cor"]};' colspan='2' height='{$componente["altura"]}'></td></tr>";
  1438 + continue;
  1439 + }
  1440 + elseif ($componente[0] == 'espaco') {
  1441 + $retorno .= "<tr><td colspan='2'><hr></td></tr>";
  1442 + continue;
  1443 + }
  1444 + elseif ($componente[0] == 'bloco_adicionador') {
  1445 + if ($componente[1] == 'begin') {
  1446 + // Flag de que estamos no meio de um bloco de adiçã
  1447 + $this->__adicionando = TRUE;
  1448 +
  1449 + // Se for a primeira vez que cai aqui define o índice como zero,
  1450 + // nas vezes subsequentes (chamadas por recursividade) o índice será
  1451 + // passado na chamada da função
  1452 + if (is_null($adicionador_indice)) {
  1453 + $adicionador_indice = 0;
  1454 + }
  1455 +
  1456 + // Cria um array para armazenar os campos a serem repetidos
  1457 + $adicionador_campos_repeticao = array();
  1458 +
  1459 + // Adiciona o campo begin no ínicio do bloco de repetição
  1460 + $adicionador_campos_repeticao[$nome] = $componente;
  1461 + }
  1462 + else {
  1463 + // Desmarca a flag de bloco de adiçã
  1464 + $this->__adicionando = FALSE;
  1465 +
  1466 + // Adiciona o campo end no fim do bloco de repetição
  1467 + $adicionador_campos_repeticao[$nome] = $componente;
  1468 +
  1469 + // Ainda não repetiu o bloco por tempo suficiente
  1470 + $adicionador_indice++;
  1471 + if ($adicionador_indice < $adicionador_total_valores) {
  1472 + $retorno .= $this->MakeCampos($adicionador_campos_repeticao,
  1473 + $adicionador_indice, FALSE, TRUE, TRUE, ! $md);
  1474 + }
  1475 + }
  1476 + }
  1477 + elseif ($componente[0] != 'oculto') {
  1478 + $tipo = $componente[0];
  1479 +
  1480 + if (! ($componente['separador'])) {
  1481 + $campo = $componente[1];
  1482 + }
  1483 + else {
  1484 + $campo = $componente[1] . "{$componente['separador']}";
  1485 + }
  1486 +
  1487 + $validador = $componente[2];
  1488 +
  1489 + if (($campo == $campo_anterior) && ($campo != '-:')) {
  1490 + $campo = '';
  1491 + }
  1492 + else {
  1493 + $campo_anterior = $campo;
  1494 + $tipo_anterior = $tipo;
  1495 +
  1496 + if (! $foiDuplo) {
  1497 + $md = ! $md;
  1498 + }
  1499 + }
  1500 +
  1501 + $classe = $md ? 'formmdtd' : 'formlttd';
  1502 +
  1503 + if ($campo_tabela && FALSE) {
  1504 + if($componente[10] && ($componente[0] == 'textoDuploInv'
  1505 + || $componente[0] =="textoInv" ))
  1506 + {
  1507 + $name = " name='tr_{$componente[10]}' ";
  1508 + }
  1509 + else {
  1510 + $name = '';
  1511 + }
  1512 +
  1513 + $retorno .= "<tr id='tr_$nome' {$name} $style><td class='$classe' valign='top'><span class='form'>$campo</span>{$obrigatorio}{$explicacao}</td><td class='$classe' valign='top'><span class='form'>\n";
  1514 + }
  1515 + elseif (! $foiDuplo) {
  1516 + if ($campo == '-:') {
  1517 + if (empty($componente[3])) {
  1518 + $componente[3] = renderpixel();
  1519 + }
  1520 +
  1521 + $explicacao = ($componente[6]) ?
  1522 + "<br><sub style='vertical-align:top;'>{$componente[6]}</sub>" : "";
  1523 +
  1524 + $retorno .= "<tr><td colspan='2' class='$classe'><span class='form'><b>$componente[3]</b></span>{$explicacao}</td></tr>\n";
  1525 + }
  1526 + else {
  1527 + if ($componente[10] && ($componente[0] == "textoDuploInv"
  1528 + || $componente[0] =="textoInv" ))
  1529 + {
  1530 + $name = " name='tr_{$componente[10]}' ";
  1531 + }
  1532 + else {
  1533 + $name = '';
  1534 + }
  1535 +
  1536 + $style = ($componente['tr_invisivel']) ?
  1537 + "style='visibility:collapse'" : '';
  1538 +
  1539 + $explicacao = ($componente[6]) ?
  1540 + "<br><sub style='vertical-align:top;'>{$componente[6]}</sub>" : '';
  1541 +
  1542 + $retorno .= "<tr id='tr_$nome' {$name} $style><td class='$classe' valign='top'><span class='form'>$campo</span>{$obrigatorio}{$explicacao}</td><td class='$classe' valign='top'><span class='form'>\n";
  1543 + }
  1544 + }
  1545 + elseif ($tipo) {
  1546 + if ($componente[10] == TRUE) {
  1547 + $explicacao = ($componente[6]) ?
  1548 + "<br><sub style='vertical-align:top;'>{$componente[6]}</sub>" : '';
  1549 +
  1550 + $retorno .= "<span class='form'>$campo</span>{$explicacao}\n";
  1551 + }
  1552 + else {
  1553 + $retorno .= "<span class='form'>$campo</span>\n";
  1554 + }
  1555 +
  1556 + $foiDuplo = FALSE;
  1557 + }
  1558 +
  1559 + switch ($tipo) {
  1560 + case 'tiny':
  1561 + $retorno .= "<div id='elm1' style='width:450px; height:250px'>{$componente[3]}</div>";
  1562 + $this->has_tiny = TRUE;
  1563 + break;
  1564 +
  1565 + case 'anexarListaPesquisa':
  1566 + $inicio = 0;
  1567 + $javascript = '';
  1568 + $inclusos = array();
  1569 +
  1570 + $retorno .= "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" id=\"anexador_{$nome}\">";
  1571 +
  1572 + if (is_array($componente[9])) {
  1573 + // Existem itens já incluídos, monta a lista com eles (com o botão remover ao lado)
  1574 + foreach ($componente[9] as $ja_incluido) {
  1575 + list($cod, $label) = $ja_incluido;
  1576 +
  1577 + $retorno .= "<tr><td><select onchange=\"{$componente[5]}\" class='{$class}' name='{$nome}[]' id='{$nome}_{$inicio}'>";
  1578 +
  1579 + $opcoes = $componente[3];
  1580 +
  1581 + if ($componente[7]) {
  1582 + // É um adicionador, então vamos inserir os já incluídos na lista padrão
  1583 + $opcoes[$cod] = $label;
  1584 + }
  1585 +
  1586 + reset($opcoes);
  1587 +
  1588 + while (list($chave, $texto) = each($opcoes)) {
  1589 + $retorno .= "<option id=\"{$nome}_{$inicio}_".urlencode($chave)."\" value=\"".urlencode($chave)."\"";
  1590 +
  1591 + if ($chave == $cod) {
  1592 + $retorno .= ' selected';
  1593 + }
  1594 +
  1595 + $retorno .= ">$texto</option>";
  1596 + }
  1597 +
  1598 + $retorno .= '</select>';
  1599 +
  1600 + if ($componente[7]) {
  1601 + $retorno .= "<img src=\"imagens/lupa.png\" alt=\"Pesquisa\" border=\"0\" onclick=\"pesquisa_valores_popless('{$componente[7]}', '{$nome}_{$inicio}')\">";
  1602 + }
  1603 +
  1604 + $retorno .= " {$componente[8]}</td><td id=\"td_adicionador_{$nome}_{$inicio}\" style=\"padding-left:30px;\"><img name=\"adicionador_{$nome}_{$inicio}\" id=\"adicionador_{$nome}_{$inicio}\" onclick=\"remove_{$nome}('{$inicio}');\" src=\"imagens/banco_imagens/excluirrr.gif\" title=\"Excluir\" border=0></td></tr>";
  1605 + $inclusos[] = $inicio;
  1606 +
  1607 + $inicio++;
  1608 + }
  1609 + }
  1610 +
  1611 + $inclusos[] = $inicio;
  1612 + $javascript .= "\nitens_{$nome} = [" . implode( ",", $inclusos ) . "];";
  1613 +
  1614 + $retorno .= "<tr><td><select onchange=\"{$componente[5]}\" class='{$class}' name='{$nome}[]' id='{$nome}_{$inicio}'>";
  1615 + $javascript .= "
  1616 + function remove_{$nome}(id)
  1617 + {
  1618 + posicao = 0;
  1619 + tabela = document.getElementById( 'anexador_{$nome}' );
  1620 +
  1621 + for (i = 0; i < id; i++) {
  1622 + if (itens_{$nome}[i] >= id) {
  1623 + break;
  1624 + }
  1625 +
  1626 + if (itens_{$nome}[i] != null) {
  1627 + posicao++;
  1628 + }
  1629 + }
681 1630  
682   - for(var c=0;c<trs[ct].cells.length;c++)
683   - trs[ct].cells[c].className = classe;
  1631 + itens_{$nome}[id] = null;
  1632 + tabela.deleteRow( posicao );
  1633 + }
684 1634  
685   - classe = (classe == 'formmdtd')? 'formlttd' : 'formmdtd';
686   - }
687   - }
  1635 + function duplica_{$nome}()
  1636 + {
  1637 + id = itens_{$nome}.length;
  1638 + id = itens_{$nome}.length;
  1639 +
  1640 + tabela = document.getElementById( 'anexador_{$nome}' );
  1641 +
  1642 + linha = tabela.insertRow( tabela.rows.length );
  1643 +
  1644 + col1 = linha.insertCell( 0 );
  1645 + col2 = linha.insertCell( 1 );
  1646 + col2.style.paddingLeft = '30px';
  1647 +
  1648 + sel = document.createElement('select');
  1649 + novoIndice = 0;
  1650 + ";
688 1651  
  1652 + reset($componente[3]);
689 1653  
690   - if(This.reordenar)
691   - {
692   - This.setId(tab);
  1654 + while (list($chave, $texto) = each($componente[3])) {
  1655 + $retorno .= "<option id=\"{$nome}_{$inicio}_".urlencode($chave)."\" value=\"".urlencode($chave)."\"";
693 1656  
694   - This.id--;
695   - }
  1657 + $javascript .= "
  1658 + sel.options[novoIndice] = new Option( '{$texto}' );
  1659 + sel.options[novoIndice].value = '" . urlencode($chave) . "';
  1660 + ";
696 1661  
697   - if(This.id == 0)
698   - This.addRow();
699   - //setVisibility(document.getElementById('tr_' + This.nome + '_cab'),false);
  1662 + if ($chave == $componente[4]) {
  1663 + $retorno .= ' selected';
  1664 + $javascript .= '
  1665 + sel.options[novoIndice].selected = true;
  1666 + ';
  1667 + }
700 1668  
701   - this.afterRemoveRow();
702   - }
  1669 + $retorno .= ">$texto</option>";
  1670 + $javascript .= "
  1671 + novoIndice++;
  1672 + ";
  1673 + }
  1674 +
  1675 + $retorno .= '</select>';
  1676 + $javascript .= "
  1677 + sel.className = '{$class}';
  1678 + col1.appendChild(sel);
  1679 +
  1680 + img = document.createElement('img');
  1681 + img.src = 'imagens/banco_imagens/entrada2.gif';
  1682 + img.title = 'Incluir';
  1683 + img.id = 'adicionador_{$nome}_' + id;
  1684 + img.name = 'adicionador_{$nome}_' + id;
  1685 + img.onclick = function() { duplica_{$nome}(); };
  1686 +
  1687 + col2.appendChild(img);
  1688 +
  1689 + id_antecessor = id - 1;
  1690 +
  1691 + img_ant = document.getElementById('adicionador_{$nome}_' + id_antecessor);
  1692 + img_ant.src = 'imagens/banco_imagens/excluirrr.gif';
  1693 +
  1694 + document.getElementById('adicionador_{$nome}_' + id_antecessor).onclick = function() { onclick=remove_{$nome}(this.name.substr(this.name.lastIndexOf( '_' ) + 1)); };
  1695 +
  1696 + itens_{$nome}[id] = id;
  1697 + }
  1698 + ";
  1699 +
  1700 + if ($componente[7]) {
  1701 + $retorno .= "<img src=\"imagens/lupa.png\" alt=\"Pesquisa\" border=\"0\" onclick=\"pesquisa_valores_popless('{$componente[7]}', '{$nome}_{$inicio}')\">";
  1702 + }
  1703 +
  1704 + $retorno .= " {$componente[8]}</td><td id=\"td_adicionador_{$nome}_{$inicio}\" style=\"padding-left:30px;\"><img name=\"adicionador_{$nome}_{$inicio}\" id=\"adicionador_{$nome}_{$inicio}\" onclick=\"duplica_{$nome}();\" src=\"imagens/banco_imagens/entrada2.gif\" title=\"Incluir\" border=0></td></tr></table><script type=\"text/javascript\">$javascript</script>";
  1705 + break;
  1706 +
  1707 + case 'rotuloDuplo':
  1708 + $foiDuplo = TRUE;
  1709 + case 'rotulo':
  1710 + if ($campo != '-:') {
  1711 + $retorno .= $componente[3];
  1712 + }
  1713 + break;
  1714 +
  1715 + case 'cep':
  1716 + $retorno .= "<input onKeyPress=\"formataCEP(this, event);\" class='{$class}' type='text' name=\"{$nome}\" id=\"{$nome}\" value=\"{$campo_valor}\" size=\"{$componente[4]}\" maxlength=\"{$componente[5]}\" $componente[8]>$componente[7]\n";
  1717 + break;
  1718 +
  1719 + case 'fone':
  1720 + $retorno .= "<input class='{$class}' type='text' name=\"ddd_{$nome}\" id=\"ddd_{$nome}\" value=\"{$componente[3]}\" size=\"3\" maxlength=\"2\"> <input onKeyPress=\"formataFone(this,event);\" class='{$class}' type='text' name=\"fone_{$nome}\" id=\"fone_{$nome}\" value=\"{$componente[3]}\" size=\"{$componente[4]}\" maxlength=\"{$componente[5]}\">\n";
  1721 + break;
  1722 +
  1723 + case 'data':
  1724 + $retorno .= "<input onKeyPress=\"formataData(this, event);\" class='{$class}' type='text' name=\"{$nome}\" id=\"{$nome}\" value=\"{$componente[3]}\" size=\"{$componente[4]}\" maxlength=\"{$componente[5]}\" {$componente[8]}> $componente[7]\n";
  1725 + break;
  1726 +
  1727 + case 'dataDupla':
  1728 + $retorno .= "<input onKeyPress=\"formataData(this, event);\" class='{$class}' type='text' name=\"{$nome}\" id=\"{$nome}\" value=\"{$componente[3]}\" size=\"{$componente[4]}\" maxlength=\"{$componente[5]}\"> $componente[7]";
  1729 + break;
  1730 +
  1731 + case 'hora':
  1732 + $componente[3] = strlen( $componente[3] ) < 6 ? $componente[3]: substr($componente[3],0,5);
  1733 + $retorno .= "<input onKeyPress=\"formataHora(this, event);\" class='{$class}' type='text' name=\"{$nome}\" id=\"{$nome}\" value=\"{$componente[3]}\" size=\"{$componente[4]}\" maxlength=\"{$componente[5]}\" {$componente[8]}>{$componente[7]}";
  1734 + break;
  1735 +
  1736 + case 'cor':
  1737 + $cor = empty($componente[3]) ? "ffffff" : $componente[3];
  1738 + $retorno .= "<input type='text' name='{$nome}' value='$componente[3]' size='6' maxlength='6' onBlur='setColor();' class='{$class}' /> *
  1739 + <a href='#' class='link' onClick=\"newwin=window.open('./cores.html', 'cores', 'width=320, height=260, scollbars=false');\">Alterar cor</a>
  1740 + <span id=\"{$nome}1\" style=\" background:#$cor;\"><a href=\"#\" onClick=\"newwin=window.open('./cores.html', 'cores', 'width=320, height=260, scollbars=false');\"><img src=\"./imagens/shim.gif\" border=\"1\" width=\"40\" style=\"border-color:#000000;\" height=\"18\"></a></span>";
  1741 + break;
  1742 +
  1743 + case 'mapa':
  1744 + $cor = empty($componente[3]) ? "ffffff" : $componente[3];
  1745 + $retorno .= "<input disabled type='text' name='{$nome}' value='$componente[3]' size='6' maxlength='6' onBlur='setColor();' class='{$class}' /> *
  1746 + <a href='#' class='link' onClick=\"newwin=window.open('./escolhe_coordenada.php', 'escolhe_coordenada', 'width=400, height=430, scollbars=false');\">Seleciona Coordenada</a>";
  1747 + break;
  1748 +
  1749 + case 'adicionar':
  1750 + $retorno .= "<select onchange=\"{$componente[5]}\" class='{$class}' name='{$nome}' id='{$nome}' >";
  1751 +
  1752 + reset($componente[3]);
  1753 +
  1754 + while (list($chave, $texto) = each($componente[3])) {
  1755 + $retorno .= "<option value=\"".urlencode($chave)."\"";
  1756 +
  1757 + if ($chave == $componente[4]) {
  1758 + $retorno .= " selected";
  1759 + }
  1760 +
  1761 + $retorno .= ">$texto</option>";
  1762 + }
  1763 +
  1764 + $retorno .= "</select>";
  1765 + $retorno .= "<a href='#' class='imagem' onClick=\"receptor=document.formcadastro.{$nome};newwin=window.open('".$componente[8]."', '{$nome}_link', 'width=".$componente[9].", height=".$componente[10].", scollbars=false');\"> <img src='imagens/nvp_bot_novo.png' border=0 alt='".$componente[7]."'></a>";
  1766 + $retorno .= "
  1767 + <script type=\"text/javascript\">
  1768 + var receptor;
  1769 + document.formcadastro.{$nome}.muda = function(valor, texto)
  1770 + {
  1771 + novoIndice = this.options.length;
  1772 + this.options[novoIndice] = new Option(texto);
  1773 + opcao = this.options[novoIndice];
  1774 + opcao.value = valor;
  1775 + opcao.selected = true;
  1776 + {$componente[11]}
  1777 + }
  1778 + </script>
  1779 + ";
  1780 +
  1781 + break;
  1782 +
  1783 + case 'detalhe':
  1784 + $retorno .= "<select onchange=\"if(this.value > 0) CarregaDetalhe( '{$nome}_div','".$componente[8]."'+this.value); $componente[5]\" class='{$class}' name='{$nome}' id='{$nome}' >";
  1785 + reset($componente[3]);
  1786 +
  1787 + while (list($chave, $texto) = each($componente[3])) {
  1788 + $retorno .= "<option value=\"".urlencode($chave)."\"";
  1789 +
  1790 + if ($chave == $componente[4]) {
  1791 + $retorno .= " selected";
  1792 + }
  1793 +
  1794 + $retorno .= ">$texto</option>";
  1795 + }
  1796 +
  1797 + $retorno .= "</select>";
  1798 +
  1799 + if ($componente[4]) {
  1800 + $carrega ="CarregaDetalhe('{$nome}_div','".$componente[8].$componente[4]."');";
  1801 + }
  1802 +
  1803 + $onClick = "AbreFecha('{$nome}_div', '{$nome}_img');";
  1804 + $retorno .= "<a href='#' class='imagem' onClick=\"$carrega $onClick\"> <img src='imagens/log-info.gif' border=0 alt='".$componente[7]."' id='{$nome}_img'></a>";
  1805 + $retorno .= "<div style='overflow: hidden;height: 1px;position: relative;width:100%;' name='{$nome}_div' id='{$nome}_div'></div>";
  1806 +
  1807 + $classe = ($classe == 'formmdtd') ?
  1808 + 'formlttd' : 'formmdtd';
  1809 +
  1810 + break;
  1811 +
  1812 + case 'cpf':
  1813 + $retorno .= "<input onKeyPress=\"formataCPF(this, event);\" class='{$class}' type='text' name=\"{$nome}\" id=\"{$nome}\" value=\"{$componente[3]}\" size=\"{$componente[4]}\" maxlength=\"{$componente[5]}\">$componente[7]";
  1814 + break;
  1815 +
  1816 + case 'idFederal':
  1817 + $retorno .= "<input onkeyPress=\"formataIdFederal(this,event);\" class='{$class}' type='text' name=\"{$nome}\" id=\"{$nome}\" value=\"{$componente[3]}\" size=\"{$componente[4]}\" maxlength=\"{$componente[5]}\" {$componente[7]}> {$componente[8]}";
  1818 + break;
  1819 +
  1820 + case 'cnpj':
  1821 + $retorno .= "<input onKeyPress=\"formataCNPJ(this, event);\" class='{$class}' type='text' name=\"{$nome}\" id=\"{$nome}\" value=\"{$componente[3]}\" size=\"{$componente[4]}\" maxlength=\"{$componente[5]}\">";
  1822 + break;
  1823 +
  1824 + case 'cnpj_pesq':
  1825 + $retorno .= "<input onKeyPress=\"formataCNPJ(this, event);\" class='{$class}' type='text' name=\"{$nome}\" id=\"{$nome}\" value=\"{$componente[3]}\" size=\"{$componente[4]}\" maxlength=\"{$componente[5]}\">";
  1826 + $retorno .= "<img src=\"imagens/lupa.png\" alt=\"Pesquisa\" border=\"0\" onclick=\"pesquisa_valores_popless('{$componente[7]}?campos={$componente[8]}', '{$nome}')\"> {$componente[9]}";
  1827 + break;
  1828 +
  1829 + case 'check':
  1830 + $onClick = '';
  1831 + if ($componente[5]) {
  1832 + $onClick = "onclick=\"{$componente[5]}\"";
  1833 + }
  1834 +
  1835 + $retorno .= "<input type='checkbox' name=\"{$nome}\" id=\"{$nome}\" {$onClick}";
  1836 +
  1837 + if ($componente[3]) {
  1838 + $retorno .= ' checked';
  1839 + }
  1840 +
  1841 + $retorno .= " {$componente[6]}> {$componente[4]}";
  1842 + break;
  1843 +
  1844 + case 'checkDuplo':
  1845 + $retorno .= "<input type='checkbox' name=\"{$nome}\"";
  1846 +
  1847 + if ($componente[3]) {
  1848 + $retorno .= ' checked';
  1849 + }
  1850 +
  1851 + $retorno .= "> {$componente[4]} ";
  1852 + $foiDuplo = TRUE;
  1853 + break;
  1854 +
  1855 + case 'latitude':
  1856 + $retorno .= "<input onBlur=\"colocaMenos(this);\" class='{$class}' type='text' name=\"{$nome}_graus\" value=\"{$componente[3]}\" size=\"3\" maxlength=\"3\"><sup style='vertical-align:top;'>o</sup><input class='{$class}' type='text' name=\"{$nome}_min\" value=\"{$componente[7]}\" size=\"2\" maxlength=\"2\"><sup style='vertical-align:top;'>'</sup><input class='{$class}' type='text' name=\"{$nome}_seg\" value=\"{$componente[8]}\" size=\"2\" maxlength=\"2\"><sup style='vertical-align:top;'>\"</sup>";
  1857 + break;
  1858 +
  1859 + case 'longitude':
  1860 + $retorno .= "<input onBlur=\"colocaMenos(this);\" class='{$class}' type='text' name=\"{$nome}_graus\" value=\"{$componente[3]}\" size=\"3\" maxlength=\"3\"><sup style='vertical-align:top;'>o</sup><input class='{$class}' type='text' name=\"{$nome}_min\" value=\"{$componente[7]}\" size=\"2\" maxlength=\"2\"><sup style='vertical-align:top;'>'</sup><input class='{$class}' type='text' name=\"{$nome}_seg\" value=\"{$componente[8]}\" size=\"2\" maxlength=\"2\"><sup style='vertical-align:top;'>\"</sup>";
  1861 + break;
  1862 +
  1863 + case 'texto':
  1864 + if ($componente[10]) {
  1865 + $disabled = 'disabled';
  1866 + }
  1867 + else {
  1868 + $disabled = '';
  1869 + }
  1870 +
  1871 + if ($componente[9] && $componente[8]) {
  1872 + $evento = " {$componente[9]}=\"{$componente[8]}\"";
  1873 + }
  1874 + else {
  1875 + $evento = '';
  1876 + }
  1877 +
  1878 + $retorno .= "<input class='{$class}' type='text' name=\"{$nome}\" id=\"{$nome}\" value=\"{$campo_valor}\" size=\"{$componente[4]}\" maxlength=\"{$componente[5]}\" {$evento} {$disabled}> {$componente[7]}";
  1879 + break;
  1880 +
  1881 + case 'monetario':
  1882 + if ($componente[9]) {
  1883 + $disabled = 'disabled';
  1884 + }
  1885 + else {
  1886 + $disabled = '';
  1887 + }
  1888 +
  1889 + if (! $componente[6]) {
  1890 + $componente[6] = $componente[11];
  1891 + }
  1892 +
  1893 + $retorno .= "<input style='text-align:right' onKeyup=\"formataMonetario(this, event);\" $componente[8] = \"{$componente[7]}\" class='{$class}' type='text' name=\"{$nome}\" id=\"{$nome}\" value=\"{$componente[3]}\" size=\"{$componente[4]}\" maxlength=\"{$componente[5]}\" {$disabled}> {$componente[6]}";
  1894 + break;
  1895 +
  1896 + case 'monetarioDuplo':
  1897 + if ($componente[9]) {
  1898 + $disabled = 'disabled';
  1899 + }
  1900 + else {
  1901 + $disabled = '';
  1902 + }
  1903 +
  1904 + if (! $componente[6]) {
  1905 + $componente[6] = $componente[11];
  1906 + }
  1907 +
  1908 + $retorno .= "<input style='text-align:right' onKeyup=\"formataMonetario(this, event);\" $componente[8] = \"{$componente[7]}\" class='{$class}' type='text' name=\"{$nome}\" id=\"{$nome}\" value=\"{$componente[3]}\" size=\"{$componente[4]}\" maxlength=\"{$componente[5]}\" {$disabled}> {$componente[6]}";
  1909 + $foiDuplo = TRUE;
  1910 + break;
  1911 +
  1912 + case 'email':
  1913 + $retorno .= "<input class='{$class}' style='text-align: left;' type='text' name=\"{$nome}\" id=\"{$nome}\" value=\"{$componente[3]}\" size=\"{$componente[4]}\" maxlength=\"{$componente[5]}\" onKeyUp=\"{$componente[8]}\"> $componente[7]";
  1914 + break;
  1915 +
  1916 + case 'suggest':
  1917 + $retorno .= "<input class='{$class}' type='text' name=\"{$nome}\" id=\"{$nome}\" value=\"{$componente[3]}\" onfocus=\"DOM_focusIn();\" onblur=\"DOM_focusOut();\" class=\"DOM_suggest\" style=\"width:250px;\">";
  1918 + $retorno .= "<script type=\"text/javascript\">";
  1919 + $retorno .= "DOM_atual = new Object();";
  1920 + $retorno .= "DOM_atual.objectId = \"{$nome}\";";
  1921 + $retorno .= "DOM_atual.arquivo = \"{$componente[7]}\";";
  1922 + $retorno .= "document.getElementById(\"{$nome}\").onkeyup=function(e){ DOM_atual.objectId=\"{$nome}\"; DOM_navegaUpDown(e); };";
  1923 + $retorno .= "</script>";
  1924 + break;
  1925 +
  1926 + case 'textoPesquisa':
  1927 + if ($componente[10]) {
  1928 + $disabled = 'disabled';
  1929 + }
  1930 + else {
  1931 + $disabled = '';
  1932 + }
  1933 +
  1934 + $retorno .= "<input class='{$class}' type='text' name=\"{$nome}\" id=\"{$nome}\" value=\"{$componente[3]}\" size=\"{$componente[4]}\" maxlength=\"{$componente[5]}\" {$componente[12]}='{$componente[11]}' {$disabled}> ";
  1935 +
  1936 + if ($componente[9]) {
  1937 + // tem serialized campos
  1938 + $retorno .= "<img src=\"imagens/lupa.png\" alt=\"Pesquisa\" border=\"0\" name='{$nome}_lupa' id='{$nome}_lupa' onclick=\"pesquisa_valores_popless('{$componente[8]}?campos={$componente[9]}', '{$nome}')\"> {$componente[7]}";
  1939 + }
  1940 + else {
  1941 + $retorno .= "<img src=\"imagens/lupa.png\" alt=\"Pesquisa\" border=\"0\" name='{$nome}_lupa' id='{$nome}_lupa' onclick=\"pesquisa_valores_popless('{$componente[8]}', '{$nome}')\"> {$componente[7]}";
  1942 + }
  1943 +
  1944 + break;
  1945 +
  1946 + case 'textoInv':
  1947 + $retorno .= "<input class='{$class}' type='text' name=\"{$componente[10]}\" id=\"{$nome}\" value=\"{$componente[3]}\" size=\"{$componente[4]}\" maxlength=\"{$componente[5]}\" disabled=true {$componente[9]}=\"{$componente[8]}\">&nbsp;$componente[7]";
  1948 + break;
  1949 +
  1950 + case 'textoDuploInv':
  1951 + $retorno .= "<input class='{$class}' type='text' name=\"{$componente[10]}\" id=\"{$nome}\" value=\"{$componente[3]}\" size=\"{$componente[4]}\" maxlength=\"{$componente[5]}\" disabled=true>";
  1952 + $foiDuplo = TRUE;
  1953 + break;
  1954 +
  1955 + case 'textoExterno':
  1956 + $retorno .= "<input class='{$class}' type='text' name=\"{$nome}\" id=\"{$nome}\" value=\"{$componente[3]}\" size=\"{$componente[4]}\" maxlength=\"{$componente[5]}\" disabled=true> <a href='#' onclick=\"javascript:$componente[7]\">$componente[8]</a>";
  1957 + break;
  1958 +
  1959 + case 'adicionarProcurar':
  1960 + $retorno .= "<input class='{$class}' type='text' name=\"{$nome}\" id=\"{$nome}\" value=\"{$componente[3]}\" size=\"{$componente[4]}\" maxlength=\"{$componente[5]}\" disabled=true> <a href='#' onclick=\"javascript:$componente[7]\">$componente[8]</a>&nbsp;&nbsp;<a href='#' onclick=\"javascript:$componente[9]\">$componente[10]</a>";
  1961 + break;
  1962 +
  1963 + case 'senha':
  1964 + $retorno .= "<input class='{$class}' type='password' name=\"{$nome}\" id=\"{$nome}\" value=\"{$campo_valor}\" size=\"{$componente[4]}\" maxlength=\"{$componente[5]}\">";
  1965 + break;
  1966 +
  1967 + case 'textoDuplo':
  1968 + if ($componente[10]) {
  1969 + $disabled = 'disabled';
  1970 + }
  1971 + else {
  1972 + $disabled = '';
  1973 + }
  1974 +
  1975 + $retorno .= "<input class='{$class}' type='text' name=\"{$nome}\" id=\"{$nome}\" value=\"{$campo_valor}\" size=\"{$componente[4]}\" maxlength=\"{$componente[5]}\" onKeyUp=\"{$componente[8]}\" {$disabled}>";
  1976 + $foiDuplo = TRUE;
  1977 + break;
  1978 +
  1979 + case 'memo':
  1980 + if ($componente[11]) {
  1981 + $retorno .= "<textarea class='{$class}' name=\"{$nome}\" id=\"{$nome}\" cols=\"{$componente[4]}\" rows=\"{$componente[5]}\" style='wrap:virtual' {$evento} disabled ";
  1982 + }
  1983 + else {
  1984 + $retorno .= "<textarea class='{$class}' name=\"{$nome}\" id=\"{$nome}\" cols=\"{$componente[4]}\" rows=\"{$componente[5]}\" style='wrap:virtual' {$evento} ";
  1985 + }
  1986 +
  1987 + if ($componente[9] && $componente[10]) {
  1988 + $evento = "{$componente[9]}=\"{$componente[10]}\"";
  1989 + }
  1990 + else {
  1991 + $evento = "";
  1992 + }
  1993 +
  1994 + if ($componente[7] > 0) {
  1995 + $retorno .= "ONKEYDOWN='this.form.{$nome}.value=this.form.{$nome}.value.length >= {$componente[7]} ? this.form.{$nome}.value.substring(0,{$componente[7]}-1) : this.form.{$nome}.value;'";
  1996 + }
  1997 +
  1998 + $retorno .= ">{$campo_valor}</textarea>\n";
  1999 + $foiDuplo = $componente[8];
  2000 + break;
  2001 +
  2002 + case 'lista':
  2003 + if (is_numeric($componente[9])) {
  2004 + $multiple = " multiple='multiple' SIZE='{$componente[9]}' ";
  2005 + }
  2006 + else {
  2007 + $multiple = '';
  2008 + }
  2009 +
  2010 + $retorno .= "<select onchange=\"{$componente[5]}\" class='{$class}' name='{$nome}' id='{$nome}' {$componente[8]} {$multiple}>";
  2011 + $opt_open = FALSE;
  2012 +
  2013 + reset($componente[3]);
  2014 +
  2015 + while (list($chave, $texto) = each($componente[3])) {
  2016 + if (substr($texto, 0, 9) == 'optgroup:') {
  2017 + $opt_open = TRUE;
  2018 + $retorno .= "<optgroup label=\"" . substr( $texto, 9 ) . "\">";
  2019 + }
  2020 + elseif (substr($texto, 0, 8) == 'optgroup') {
  2021 + // optgroup
  2022 + if ($opt_open) {
  2023 + $opt_open = FALSE;
  2024 + $retorno .= '</optgroup>';
  2025 + }
  2026 + }
  2027 + else {
  2028 + // option normal
  2029 + $retorno .= "<option id=\"{$nome}_".urlencode($chave)."\" value=\"".urlencode($chave)."\"";
  2030 + if (is_array($componente[4])) {
  2031 + if ($chave == $componente[4][$adicionador_indice]) {
  2032 + $retorno .= " selected";
  2033 + }
  2034 + }
  2035 + elseif ($chave == $componente[4]) {
  2036 + $retorno .= " selected";
  2037 + }
  2038 +
  2039 + $retorno .= ">$texto</option>";
  2040 + }
  2041 + }
  2042 +
  2043 + if ($opt_open) {
  2044 + $retorno .= '</optgroup>';
  2045 + }
  2046 +
  2047 + $retorno .= "</select> {$componente[7]}";
  2048 + break;
  2049 +
  2050 + case 'AddForm':
  2051 + $arr_campos["linha_{$nome}"] = array('addForm', $nome, $arr_campos);
  2052 +
  2053 + $span = '';
  2054 + $input = '';
  2055 + $cont = 0;
  2056 +
  2057 + if ($arr_campos) {
  2058 + foreach ($arr_campos as $campo => $atributo) {
  2059 + $span .= "var span$cont = document.createElement( \"span{$cont}\" );";
  2060 + $cont++;
  2061 + }
  2062 + }
  2063 +
  2064 + $retorno = "
  2065 + function adiciona (obj)
  2066 + {
  2067 + tabela = document.getElementById( 'table_fotos' );
  2068 + linha = tabela.insertRow( tabela.rows.length );
  2069 +
  2070 + var td = document.createElement( \"td\" );
  2071 + var input = document.createElement( \"input\" );
  2072 + var botao = document.createElement( \"input\" );
  2073 +
  2074 + botao.setAttribute( \"type\", \"button\");
  2075 + botao.setAttribute( \"id\", \"foto_[]\" );
  2076 + botao.setAttribute( \"name\", \"foto_[]\" );
  2077 + botao.setAttribute( \"onclick\", \"adiciona(this);\" );
  2078 + botao.setAttribute( \"value\", \"Adicionar[+]\" );
  2079 +
  2080 + input.setAttribute( \"type\", \"text\" );
  2081 + input.setAttribute( \"id\", \"foto[]\" );
  2082 + input.setAttribute( \"name\", \"foto[]\" );
  2083 + input.setAttribute( \"maxlength\", \"50\" );
  2084 + input.setAttribute( \"size\", \"50\" );
  2085 +
  2086 + obj.setAttribute( \"onclick\", \"this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode);\" );
  2087 + obj.setAttribute( \"value\", \"Remover[-]\" );
  2088 +
  2089 + linha.appendChild(td);
  2090 + td.appendChild(input);
  2091 + td.appendChild(botao);
  2092 + }
  2093 + ";
  2094 +
  2095 + case 'addCampos':
  2096 + $nome = $componente[1];
  2097 + $nome = str_replace(' ', '_', $nome);
  2098 +
  2099 + $arr_campos = $componente[3];
  2100 + $arr_valores = $componente[4];
  2101 + $arr_tipos = array();
  2102 +
  2103 + $input = '';
  2104 + $strCampos = '';
  2105 + $setAtributos = '';
  2106 + $addCampo = '';
  2107 + $valores = '';
  2108 + $br = '';
  2109 + $ValEditar = '';
  2110 +
  2111 + $quebra = '';
  2112 + $inicio = "<div id=\"div{$nome}0\">";
  2113 +
  2114 + $cont = 0;
  2115 +
  2116 + if ($arr_campos) {
  2117 + foreach ($arr_campos as $campo => $atributo) {
  2118 + $atributo['quebra'] = ! isset($atributo['quebra']) ?
  2119 + TRUE : $atributo['quebra'];
  2120 +
  2121 + $arr_tipos[$campo] = $atributo['type'];
  2122 +
  2123 + if (! empty($atributo['campo'])) {
  2124 + $atributo['campo'] = "<br>{$atributo['campo']}:<br>";
  2125 + }
  2126 + else {
  2127 + $atributo['campo'] = '';
  2128 + }
  2129 +
  2130 + $disabled = ! empty($atributo['disabled']) ?
  2131 + ' disabled = true ' : '';
  2132 +
  2133 + $inicio .= "$quebra<span >{$atributo['campo']}</span>
  2134 + <input id='{$atributo['id']}0' name='{$atributo['name']}[]' ";
  2135 +
  2136 + $input .= "var input_$campo = document.createElement( \"input\" );\n";
  2137 + $input .= "var span_$campo = document.createElement( \"span\" );\n";
  2138 + $input .= "span_$campo.setAttribute( \"id\", \"span_$campo\"+cont{$nome} );\n";
  2139 +
  2140 + $id = $atributo['id'];
  2141 +
  2142 + if ($atributo) {
  2143 + foreach ($atributo as $formId => $valor) {
  2144 + if ($formId == 'id') {
  2145 + $setAtributos .= "input_{$campo}.setAttribute( \"$formId\", \"{$valor}\"+cont{$nome} );\n";
  2146 + }
  2147 + elseif ($formId == 'name') {
  2148 + $valores .= "document.getElementById( \"{$id}\"+cont{$nome} ).name = \"{$valor}[]\"; \n ";
  2149 + }
  2150 + elseif ($formId != 'quebra' || $formId == 'campo') {
  2151 + $valor = $formId == "disabled" ? "TRUE" : $valor;
  2152 + $setAtributos .= "input_{$campo}.setAttribute( '$formId', '$valor' );\n";
  2153 + $inicio .= "$formId = '$valor'" ;
  2154 + }
  2155 + }
  2156 + }
  2157 +
  2158 + $inicio .= "{$disabled} >";
  2159 + $quebra = $atributo['quebra'] == TRUE || !isset($atributo['quebra']) ?
  2160 + '<br>' : '';
  2161 +
  2162 + $addCampo .= "\n div_{$nome}.appendChild(span_{$campo}); \n document.getElementById(\"span_$campo\"+cont{$nome}).innerHTML = '$quebra{$atributo['campo']} ';\n div_{$nome}.appendChild(input_{$campo});\n";
  2163 +
  2164 + $atributo['campo'] = '';
  2165 + }
  2166 + }
  2167 +
  2168 + if ($arr_valores) {
  2169 + if (array_key_exists('options', $arr_valores)) {
  2170 + $opcoes = array_pop($arr_campos);
  2171 + print_r($opcoes);
  2172 + }
  2173 +
  2174 + foreach ($arr_valores as $val) {
  2175 + $ValEditar .= "<div>";
  2176 +
  2177 + if ($val) {
  2178 + $chave = key($arr_valores);
  2179 +
  2180 + $valor_chave = reset($val);
  2181 + $disabled = substr($valor_chave, -2);
  2182 + $valor_chave = substr($valor_chave, 0, -2);
  2183 +
  2184 + $disabled = $disabled == '_1' ?
  2185 + 'disabled' : '';
  2186 +
  2187 + foreach ($arr_tipos as $id => $type) {
  2188 + if ($type == 'file') {
  2189 + $ValEditar .= "{$valor_chave}<br>";
  2190 + }
  2191 + elseif ($type != 'button') {
  2192 + if ($type == 'hidden') {
  2193 + $valor_chave = (!$valor_chave) ?
  2194 + $chave : $valor_chave;
  2195 +
  2196 + $disabled = '';
  2197 + }
  2198 + elseif(strstr($id, 'data') != FALSE) {
  2199 + $keypress = " onKeyPress=\"formataData(this, event);\" maxlength=\"10\"";
  2200 + }
  2201 + else {
  2202 + $keypress = '';
  2203 + }
  2204 +
  2205 + $ValEditar .= "<input type='{$type}' $keypress class='geral' value='{$valor_chave}' name='edit_{$id}[{$chave}]' $disabled><br>";
  2206 + }
  2207 +
  2208 + $valor_chave = next($val);
  2209 + }
  2210 +
  2211 + $chave = next($arr_valores);
  2212 + $chave = key($arr_valores);
  2213 + }
  2214 + $ValEditar .= "<img vspace='4' src='imagens/banco_imagens/excluir.gif' onclick='this.parentNode.parentNode.removeChild(this.parentNode);'><hr></div>";
  2215 + }
  2216 + }
  2217 +
  2218 + $inicio .= "<img hspace='5' src='imagens/banco_imagens/incluir.gif' onclick='adiciona_{$nome}();'><br><br>";
  2219 + $retorno .= "
  2220 + <script type=\"text/javascript\">
  2221 + var cont{$nome} = 1;
  2222 +
  2223 + function adiciona_{$nome}()
  2224 + {
  2225 + principal = document.getElementById('{$nome}');
  2226 +
  2227 + var div_{$nome} = document.createElement(\"div\");\n;
  2228 + var div_linha = document.createElement(\"hr\");\n;
  2229 +
  2230 + $input
  2231 + principal.appendChild(div_{$nome});
  2232 + div_{$nome}.appendChild(div_linha);
  2233 + add_new = '<img hspace=\'5\' src=\'imagens/banco_imagens/incluir.gif\' onclick=\'adiciona_{$nome}();\'>';
  2234 + del = '<img hspace=\'5\' src=\'imagens/banco_imagens/excluir.gif\' onclick=\'this.parentNode.parentNode.removeChild(this.parentNode);\'><br><br>';
  2235 +
  2236 + div_{$nome}.setAttribute(\"id\", \"div{$nome}\"+cont{$nome});\n
  2237 + $setAtributos
  2238 +
  2239 + $addCampo
  2240 +
  2241 + document.getElementById('div{$nome}'+cont{$nome}).innerHTML += add_new;
  2242 + document.getElementById('div{$nome}'+cont{$nome}).innerHTML += del;
  2243 +
  2244 + $valores
  2245 +
  2246 + cont{$nome}++;
  2247 + }
  2248 + </script>
  2249 +
  2250 + <div =\"valores{$nome}\">
  2251 + $ValEditar
  2252 + </div>
  2253 +
  2254 + <div id=\"{$nome}\">
  2255 + $inicio
  2256 + </div>
  2257 + ";
  2258 + break;
  2259 +
  2260 + case 'listaDin':
  2261 + $url = 'var campos = [];';
  2262 +
  2263 + if ($componente[12]) {
  2264 + foreach ($componente[12] as $key => $campo) {
  2265 + $url .= "campos[$key] = '$campo';";
  2266 + }
  2267 + }
  2268 +
  2269 + $rand = rand(1, 10000);
  2270 + $script = "
  2271 + <script type=\"text/javascript\">
  2272 + function get_{$componente[11]}()
  2273 + {
  2274 + $url
  2275 + url = '?';
  2276 + junta = '';
  2277 + for (i = 0; i < campos.length; i++) {
  2278 + url += junta+campos[i]+'='+document.getElementById(campos[i]).value;
  2279 + junta = '&';
  2280 + }
  2281 +
  2282 + // define qual a funcao que devera ser executada quando o xml for carregado
  2283 + DOM_execute_when_xmlhttpChange = function() { get_{$componente[11]}Done(); };
  2284 + strURL = \"{$componente[10]}\"+url+'&rand='+\"{$url}\";
  2285 + DOM_loadXMLDoc(strURL);
  2286 + }
  2287 +
  2288 + function get_{$componente[11]}Done()
  2289 + {
  2290 + var valores = [];
  2291 + var campos = [];
  2292 + ObjSelect = document.getElementById(\"{$componente[7]}\");
  2293 + ObjSelect.options.length =0;
  2294 + ObjSelect.options[ObjSelect.options.length] = new Option ('Selecione', '0', true, true);
703 2295  
704   - this.setId = function setId(tab){
  2296 + for (i = 0; i < DOM_itensArray.length; i = i + 2) {
  2297 + objXML = DOM_itensArray[i].firstChild;
  2298 + valores[i] = objXML.data;
705 2299  
  2300 + objXML = DOM_itensArray[i+1].firstChild;
  2301 + campos[i] = objXML.data;
706 2302  
707   - var trs = tab.getElementsByTagName('TR');
708   - var cod_ini = 0;
709   - for(var ct=2;ct<trs.length;ct++)
710   - {
711   -
712   -
713   - var nome_tr = /[a-zA-Z-_]*/.exec(trs[ct].id);
714   - if(!nome_tr)
715   - continue;
716   - trs[ct].setAttribute( \"id\",nome_tr + '[' + cod_ini + ']');
717   -
718   - for(var c=0;c<trs[ct].cells.length;c++)
719   - {
720   -
721   - var nome_td = /[a-zA-Z-_]*/.exec(trs[ct].cells[c].id);
722   -
723   -
724   - trs[ct].cells[c].setAttribute( \"id\",nome_td + '[' + cod_ini + ']');
725   -
726   - var campos = trs[ct].cells[c].childNodes;
727   -
728   - for(var inp = 0 ;inp<campos.length;inp++)
729   - {
730   - if(!campos[inp].id)
731   - continue;
732   -
733   - var nome_inp = /[a-zA-Z-_]*/.exec(campos[inp].id);
734   -
735   - campos[inp].setAttribute( \"id\",nome_inp + '[' + cod_ini + ']');
736   - campos[inp].setAttribute( \"name\",nome_inp + '[' + cod_ini + ']');
737   - //campos[inp].setAttribute( \"name\",nome_inp + '[]');
738   -
739   - }
740   -
741   - }
742   -
743   - cod_ini++;
744   - }
745   -
746   - }
747   - }";
748   - $retorno .= "<script>$javascript</script>";
749   - $classe = $md ? 'formlttd' : 'formmdtd';
750   - $md = $md ? false : true;
751   - $index = 0;
752   - while (list( $nome, $componente ) = each( $arr_campos ))
753   - {
754   - $nome_add = $nome;
755   - $campo_tabela = false;
756   -
757   -
758   - /**
759   - * cria nova tab
760   - */
761   -
762   - if(ereg("^(tabbed_add_[0-9]+)",$nome) === 1)
763   - {
764   - $nomes_tab = urlencode(serialize($arr_campos['cabecalho_tab']));
765   - unset($arr_campos['cabecalho_tab']);
766   - // $arr_campos
767   - $desabilitado_tab = urlencode(serialize($arr_campos['desabilitado_tab']));
768   - unset($arr_campos['desabilitado_tab']);
769   -
770   - $retorno .= "<tr id='tr_tab'>
771   - <td valign='top' colspan='2' width='100%' align='center'>";
772   - $rand = rand();
773   - // $retorno .= "<!-- INICIO TABELA 1 --><div style='width: 300'><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"350\" height=\"250\" id=\"tabela_principal\" align=center>
774   - $retorno .= "<!-- INICIO TABELA 1 --><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" id=\"tabela_principal\" align=center width='100%'>
775   - <tr>
776   - <td valign=top height=30>
777   - <link href=\"styles/styles_tab.css?$rand\" rel=\"stylesheet\" type=\"text/css\" />
778   - <script type=\"text/javascript\" language=\"JavaScript1.2\" src=\"scripts/dtabs.js?$rand\"></script>
779   - <script type=\"text/javascript\" src=\"scripts/tabs_cab.php?nomes_tab={$nomes_tab}&desabilitado_tab=$desabilitado_tab\"></script>
780   - </td>
781   - </tr>";
782   - $retorno .= '<tr>
783   - <td valign=top height=auto class="pageTabb">&nbsp;
784   - <!-- INICIO TABELA 2 -->
785   - <table cellpadding="0" cellspacing="0" border="0" height=auto>
786   - <tr>
787   - <td valign=top width=1><img src="imagens/img/blank.gif" width=1 height=1></td>
788   - <td valign=top width=100% class="tabPage" height="auto">';
789   -
790   - $existe_tab_iniciada = true;
791   - continue;
792   - }
793   -
794   - if(ereg("^(tab_name_[0-9]+)",$nome) === 1)
795   - {
796   - if($existe_tab_aberta)
797   - {
798   - if($this->__segue_fluxo)
799   - {
800   - $colspan = 2;
801   - $sequencia = unserialize($this->__sequencia_fluxo);
802   - if(isset($sequencia[$index-1]))
803   - {
804   - $prox_id = array_flip($sequencia);
805   - $prox_id = $prox_id[$index]*2;
806   -
807   - $retorno .= "<tr><td align=left><img onclick='LTb0(\"0\", \"$prox_id\")' style='cursor:pointer' src='imagens/bot_anterior.gif' border='0' /></td>";
808   - $colspan = 1;
809   - }
810   - if($sequencia[$index] != 0)
811   - {
812   - $prox_id = $sequencia[$index++]*2;
813   - $retorno .= "<td colspan=$colspan align=right><img onclick='validaTab(".($componente['id']-1).");LTb0(\"0\", \"$prox_id\")' style='cursor:pointer' src='imagens/bot_proximo.gif' border='0' /></td></tr>";
814   - }
815   - else
816   - {
817   - $retorno .= "<td colspan=$colspan align=right><img onclick='{$this->__acao_enviar_abas}' style='cursor:pointer' src='imagens/bot_salvar.gif' border='0' /></td></tr>";
818   - }
819   - }
820   - $retorno .= "<!-- FIM TABELA 3 --></table></div>";
821   - }
822   - $existe_tab_aberta = true;
823   - $retorno .= "<div id=\"content{$componente['id']}\" style=\"visibility: hidden;\" class=\"tabPage\">";
824   - $retorno .= "<!-- INICIO TABELA 3 --><table cellpadding=\"2\" cellspacing=\"0\" border=\"0\" width=100% align=center>";
825   - continue;
826   - }
827   -
828   -
829   - if($nome === 'fim_tab')
830   - {
831   - if($existe_tab_aberta)
832   - {
833   - if($this->__segue_fluxo)
834   - {
835   - $colspan = 2;
836   - $sequencia = unserialize($this->__sequencia_fluxo);
837   - if(isset($sequencia[$index-1]))
838   - {
839   - $prox_id = array_flip($sequencia);
840   - $prox_id = $prox_id[$index]*2;
841   -
842   - $retorno .= "<tr><td align=left><img onclick='LTb0(\"0\", \"$prox_id\")' style='cursor:pointer' src='imagens/bot_anterior.gif' border='0' /></td>";
843   - $colspan = 1;
844   - }
845   - if(!$this->__sequencia_default)
846   - {
847   - if($sequencia[$index] != 0)
848   - {
849   - $prox_id = $sequencia[$index]*2;
850   - $retorno .= "<td colspan=$colspan align=right><img onclick='validaTab(".($componente['id']-1).");LTb0(\"0\", \"$prox_id\")' style='cursor:pointer' src='imagens/bot_proximo.gif' border='0' /></td></tr>";
851   - }
852   - else
853   - {
854   - $retorno .= "<td colspan=$colspan align=right><img onclick='{$this->__acao_enviar_abas}' style='cursor:pointer' src='imagens/bot_salvar.gif' border='0' /></td></tr>";
855   - }
856   - }
857   - else
858   - {
859   - $retorno .= "<td colspan=$colspan align=right><img onclick='{$this->__acao_enviar_abas}' style='cursor:pointer' src='imagens/bot_salvar.gif' border='0' /></td></tr>";
860   - }
861   - }
862   - $retorno .= "<!-- FIM TABELA 3 --></table></div>";
863   - }
864   -
865   - $retorno .= " </td>
866   - <td valign=top width=1><img src='imagens/img/blank.gif' width=1 height=1></td>
867   - </tr>
868   - </table><!-- FIM TABELA 2 -->
869   - </td>
870   - </tr>
871   - </table><!-- FIM TABELA 1 -->";
872   - $retorno .= '<br></td></tr>';
873   -
874   - continue;
875   - }
876   -
877   -
878   - /**
879   - *
880   - */
881   -
882   -
883   - if(ereg("^(tab_add_[0-9]+)",$nome) === 1)
884   - {
885   -
886   - $campo_tabela = true;
887   - $javascript = "";
888   -
889   -
890   - $cabecalho = $componente['cabecalho'];
891   - $nome_tabela = $componente['nome'];
892   - $valores = $componente['valores'];
893   - $titulo = $componente['titulo'];
894   - $largura = $componente['largura'] ? " width=\"{$componente['largura']}\" " : "";
895   - $valores_lista_tabela = $componente['valores_lista'];
896   - $componente = array_shift($componente);
897   -
898   -
899   - $campos_oculto = $componente['oculto'];
900   - unset($componente['oculto']);
901   - //echo '<pre>';print_r($campos_oculto);die;
902   - $classe = $md ? 'formlttd' : 'formmdtd';
903   - $md = $md ? false : true;
904   -
905   - $retorno .= "<tr id='tr_$nome_tabela' class='$classe'><td valign='top' align='center' colspan='2'>";
906   - $retorno .= "\n<table cellspacing='0' $largura id='$nome_tabela' cellpadding='2' style='border-width:1px 1px 1px 1px;border-color:#000000;border-style:solid;margin:10px 0px 10px 0px;' >";
907   -
908   - $total_campos = count($cabecalho);
909   - $span = $total_campos+1;
910   -
911   - if($titulo)
912   - $retorno.= "<tr align='center' id='tr_{$nome_tabela}_tit' style='font-weight:bold' class='formdktd'><td colspan='$span'>$titulo</td></tr>";
913   - else
914   - $retorno.= "<tr align='center' id='tr_{$nome_tabela}_tit' style='font-weight:bold;display:none;visibility:hidden;' ><td colspan='$span'>&nbsp;</td></tr>";
915   -
916   - $retorno.= "<tr align='center' style='font-weight:bold' id='tr_{$nome_tabela}_cab'>";
917   - //echo '<pre>';print_r($componente);die;
918   - foreach ($cabecalho as $key => $cab)
919   - {
920   - $expressao_regular = $componente[$key][2];
921   -
922   - if( $expressao_regular && substr( $expressao_regular, 0, 1 ) != "*" )
923   -
924   - $obrigatorio = "<span class=\"campo_obrigatorio\">*</span>";
925   -
926   - else
927   -
928   - $obrigatorio = "";
929   -
930   - //$retorno.= "<td class='formmdtd' id='td_$cab' align='center'><span class='form'>$cab</span>{$obrigatorio}{$explicacao}</td>";
931   - $retorno.= "<td class='formmdtd' id='td_$cab' align='center'><span class='form'>$cab</span>{$obrigatorio}</td>";
932   - }
933   -
934   - $retorno.= "<td class='formmdtd' id='td_acao' align='center'><span class='form'>A&ccedil;&atilde;o</span></td>";
935   - $retorno.= "</tr>";
936   -
937   -
938   -// link.onclick = function() {This.removeRow(this);};
939   -// img.setAttribute( \"border\",\"0\");
940   -// img.src = 'imagens/banco_imagens/excluirrr.gif';
941   -
942   - //$click = "$nome_add.addRow();";
943   - $click = "$nome_add.removeRow(this);";
944   -
945   - //$img = "<img src=\"imagens/banco_imagens/incluir.gif\" border=\"0\" alt=\"incluir\" />";
946   - $img = "<img src=\"imagens/banco_imagens/excluirrr.gif\" border=\"0\" alt=\"excluir\" />";
947   - $md2 = false;
948   -
949   - if( ! count( $valores ) )
950   - {
951   - $valores[0] = "";
952   - }
953   - foreach ($valores as $key2 => $valor)
954   - {
955   - $classe2 = $md2 ? 'formlttd' : 'formmdtd';
956   - $md2 = $md2 ? false : true;
  2303 + ObjSelect.options[ObjSelect.options.length] = new Option (campos[i], valores[i], true, true);
  2304 + }
957 2305  
958   - $retorno .= "<tr id='tr_{$nome_tabela}[$key2]' name='tr_{$nome_tabela}[]' $style class='$classe2'>";
959   - $array_valores_lista = $valores_lista_tabela[$key2];
  2306 + ObjSelect.value = 0;
  2307 + {$componente[13]}
  2308 + }
  2309 + </script>
  2310 + ";
960 2311  
961   - foreach ($componente as $key => $campo_)
962   - {
  2312 + $retorno .= "$script<select onchange=\"{$componente[5]} get_{$componente[11]}();\" class='{$class}' name='{$nome}' id='{$nome}' {$componente[8]}>";
963 2313  
964   - $nome = $campo_[1];
965   - if($campo_[10])
966   - {
967   - $disabled = "disabled";
968   - }
969   - else
970   - {
971   - $disabled = "";
972   - }
  2314 + reset($componente[3]);
973 2315  
974   - if( $campo_[9] && $campo_[8] )
975   - {
976   - $evento = " {$campo_[9]}=\"{$campo_[8]}\"";
977   - }
978   - else
979   - {
980   - $evento = "";
981   - }
  2316 + while (list($chave, $texto) = each($componente[3])) {
  2317 + $retorno .= "<option id=\"{$nome}_".urlencode($chave)."\" value=\"".urlencode($chave)."\"";
982 2318  
983   - $expressao_regular = $campo_[2];
984   - if( $expressao_regular && substr( $expressao_regular, 0, 1 ) != "*" )
985   - {
  2319 + if ($chave == $componente[4]) {
  2320 + $retorno .= " selected";
  2321 + }
986 2322  
987   - $class = "obrigatorio";
  2323 + $retorno .= ">$texto</option>";
  2324 + }
988 2325  
989   - }
990   - else
991   - {
  2326 + $retorno .= "</select>";
992 2327  
993   - $class = "geral";
  2328 + if ($componente[14]) {
  2329 + $foiDuplo = TRUE;
  2330 + }
994 2331  
995   - }
996   - $center = (strtolower($campo_[0]) == 'rotulo' || strtolower($campo_[0]) == 'check' || $largura) ? 'align="center"' : "";
997   - $retorno .= "<td class='$classe2' $center id='td_{$nome}[{$key2}]' valign='top'>\n";
  2332 + break;
998 2333  
999   - switch (strtolower($campo_[0]))
1000   - {
1001   - case 'texto':
1002   - $retorno .= $this->getCampoTexto("{$nome}[{$key2}]","{$nome}[{$key2}]",$valor[$key],$campo_[4],$campo_[5],$evento,$campo_[10],"",$class,$campo_[7]);
1003   - break;
  2334 + case "listaativarpeso" :
  2335 + $retorno .= "<input type='checkbox' ";
  2336 + $retorno .= ($componente[5]) ? "checked" : "";
  2337 + $retorno .= " name='{$nome_chk}' onclick='ativaCampo(\"{$nome}\")'>&nbsp;&nbsp;<select ";
  2338 + $retorno .= ($componente[5]) ? "" : "disabled";
  2339 + $retorno .= " class='{$class}' name='{$nome}_lst' id='{$nome}_lst'>";
1004 2340  
1005   - case 'monetario':
1006   - $retorno .= $this->getCampoMonetario("{$nome}[{$key2}]","{$nome}[{$key2}]",$valor[$key],$campo_[4],$campo_[5],$campo_[9],$campo_[6],$campo_[11],$class,$campo_[8],$campo_[7]);
1007   - break;
1008   - case 'hora':
1009   - $retorno .= $this->getCampoHora("{$nome}[{$key2}]","{$nome}[{$key2}]",$valor[$key],$class,$campo_[4],$campo_[5],"","");
1010   - break;
1011   - case 'lista':
1012   - $lista = null;
1013   - if(is_array($array_valores_lista))
1014   - $lista = array_shift($array_valores_lista);
1015   - $lista = (sizeof($lista)) ? $lista : $campo_[3];
1016   -
1017   - $retorno .= $this->getCampoLista("{$nome}[{$key2}]","{$nome}[$key2]",$campo_[5],$lista,$valor[$key],$campo_[7],$campo_[8],$class,$campo_[9]);
1018   - break;
1019   -
1020   - case 'rotulo':
1021   -
1022   - $retorno .= $this->getCampoRotulo($campo_[3]?$campo_[3] : $valor[$key]);
1023   - break;
1024   -
1025   - case 'check' :
1026   -
1027   - $retorno .= $this->getCampoCheck("{$nome}[{$key2}]","{$nome}[{$key2}]",$campo_[3]?$campo_[3] : $valor[$key],$campo_[4],$campo_[5],$campo_[6]);
1028   - break;
1029   -
1030   - case 'cnpj':
1031   -
1032   - $retorno .= $this->getCampoCNPJ("{$nome}[{$key2}]","{$nome}[{$key2}]",$valor[$key],$class,$campo_[4],$campo_[5]);
1033   - break;
1034   -
1035   -
1036   - case 'cpf':
1037   -
1038   - $retorno .= $this->getCampoCPF("{$nome}[{$key2}]","{$nome}[{$key2}]",$valor[$key],$class,$campo_[4],$campo_[5],$campo_[8]);
1039   - break;
1040   -
1041   - case 'idfederal':
1042   -
1043   - $retorno .= $this->getCampoIdFederal("{$nome}[{$key2}]","{$nome}[{$key2}]",$valor[$key],$class,$campo_[4],$campo_[5],$campo_[8]);
1044   - break;
1045   -
1046   - case 'data':
1047   - $retorno .= $this->getCampoData("{$nome}[{$key2}]","{$nome}[{$key2}]",$valor[$key],$class,$campo_[4],$campo_[5],$campo_[9]);
1048   - break;
1049   -
1050   - case 'textopesquisa':
1051   - $retorno .= $this->getCampoTextoPesquisa("{$nome}[{$key2}]","{$nome}[{$key2}]",$valor[$key],$class,$campo_[4],$campo_[5],$campo_[10],$campo_[8],$campo_[9],$campo_[7], $campo_[12], $campo_[11]);
1052   - break;
1053   -
1054   - case 'cep':
1055   - $retorno .= $this->getCampoCep("{$nome}[{$key2}]","{$nome}[{$key2}]",$valor[$key],$class,$campo_[4],$campo_[5],$campo_[8],$campo_[7]);
1056   - break;
1057   - }
1058   - $retorno .= "</td>";
1059   -
1060   - $evento = "";
1061   -
1062   - }
1063   - $retorno_oculto = "";
1064   - if(is_array($campos_oculto))
1065   - {
1066   - foreach ($campos_oculto as $key_oculto => $campo_oculto)
1067   - {
1068   - $key_oculto = $key_oculto + sizeof($cabecalho);
1069   -
1070   - $campo_oculto[3] = $campo_oculto[3] ? $campo_oculto[3] : $valor[$key_oculto];
1071   - $retorno_oculto .= $this->getCampoOculto("{$campo_oculto[1]}[{$key2}]",$campo_oculto[3],"{$campo_oculto[1]}[{$key2}]");
1072   - }
1073   - }
1074   -
1075   - $retorno .= "<td align='center'><a href='javascript:void(0)' onclick='$click' id='link_remove[$key2]' style='outline: none;'>$img</a>$retorno_oculto</td>";
1076   - //$click = "$nome_add.removeRow(this);";
1077   - $img = "<img src=\"imagens/banco_imagens/excluirrr.gif\" border=\"0\" alt=\"excluir\" />";
1078   - $id = count($valores);
1079   - $javascript .= "
1080   -
1081   - var $nome_add = new tabela('{$nome_tabela}','{$id}');\n";
1082   -
1083   - }
1084   - $retorno .= "</tr>";
1085   -
1086   - $click = "$nome_add.addRow();";
1087   - //$img = "<img src=\"imagens/nvp_bot_adiciona.gif\" border=\"0\" alt=\"incluir\" />";
1088   - $img = "<img src=\"imagens/nvp_bot_novo.png\" border=\"0\" alt=\"incluir\" />";
1089   - $retorno .= "<tr id='adicionar_linha'>";
1090   - $tt = $total_campos +1;
1091   - $retorno .= "<td colspan='$tt' align='left' style='border-width:1px 0px 0px 0px;border-style:dotted;border-color:#000000;'><a href='javascript:void(0)' id='btn_add_$nome_add' onclick='$click' style='outline: none;'>$img</a></td>";
1092   - $retorno .= "</tr>";
1093   -
1094   - $retorno .= "</table>";
1095   - $retorno .= "</td></tr>";
1096   -
1097   - $retorno .= "<script type='text/javascript'>$javascript</script>";
1098   - continue;
1099   - }
1100   -
1101   -
1102   - if( $this->__adicionando && false )
1103   - {
1104   - // adiciona o campo no bloco de repeticao
1105   - $adicionador_campos_repeticao[$nome] = $componente;
1106   - $adicionador_complemento_campo = "[{$adicionador_indice}]";
1107   - $campo_valor = $componente[3][$adicionador_indice];
1108   - }
1109   - else
1110   - {
1111   - $adicionador_complemento_campo = "";
1112   - $campo_valor = $componente[3];
1113   - }
1114   - $nome .= $adicionador_complemento_campo;
1115   - $expressao_regular = $componente[2];
1116   - if( $expressao_regular && substr( $expressao_regular, 0, 1 ) != "*" )
1117   - {
1118   - $class = "obrigatorio";
1119   - $obrigatorio = "<span class=\"campo_obrigatorio\">*</span>";
1120   - }
1121   - else
1122   - {
1123   - $class = "geral";
1124   - $obrigatorio = "";
1125   - }
1126   -
1127   -
1128   - //separador: insere uma linha preta !
1129   - if ($componente[0] == "linha_preta")
1130   - {
1131   -// $retorno .= "<tr><td height='1' colspan='2'></td></tr>";
1132   - $retorno .= "<tr><td style='padding:0px;background-color:{$componente["cor"]};' colspan='2' height='{$componente["altura"]}'></td></tr>";
1133   -// $retorno .= "<tr><td height='1'></td></tr>";
1134   - continue;
1135   - }
1136   - else if ($componente[0] == "espaco")
1137   - {
1138   -
1139   - $retorno .= "<tr><td colspan='2'><hr></td></tr>";
1140   - continue;
1141   - }
1142   - else if ( $componente[0] == "bloco_adicionador" )
1143   - {
1144   - if( $componente[1] == "begin" )
1145   - {
1146   - // flag de que estamos no meio de um bloco de adicao
1147   - $this->__adicionando = true;
1148   - // se for a primeira vez que cai aqui define o indice como zero,
1149   - // nas vezes subsequentes (chamadas por recursividade) o indice será
1150   - // passado na chamada da funcao
1151   - if( is_null($adicionador_indice) )
1152   - $adicionador_indice = 0;
1153   - // cria um array para armazenar os campos a serem repetidos
1154   - $adicionador_campos_repeticao = array();
1155   - // adiciona o campo begin no inicio do bloco de repeticao
1156   - $adicionador_campos_repeticao[$nome] = $componente;
1157   - }
1158   - else
1159   - {
1160   - // desmarca da flag de bloco de adicao
1161   - $this->__adicionando = false;
1162   - // adiciona o campo end no fim do bloco de repeticao
1163   - $adicionador_campos_repeticao[$nome] = $componente;
1164   - // ainda nao repetiu o bloco por tempo suficiente
1165   - $adicionador_indice++;
1166   - if( $adicionador_indice < $adicionador_total_valores )
1167   - {
1168   - $retorno .= $this->MakeCampos( $adicionador_campos_repeticao, $adicionador_indice, false, true, true, ! $md );
1169   - }
1170   - }
1171   - }
1172   - else if ( $componente[0] != "oculto" )
1173   - {
1174   -
1175   - $tipo = $componente[0];
1176   - if( ! ( $componente['separador'] ) )
1177   - {
1178   - $campo = $componente[1];
1179   - }
1180   - else
1181   - {
1182   - $campo = $componente[1]."{$componente['separador']}";
1183   - }
1184   -
1185   - $validador = $componente[2];
1186   - if (($campo == $campo_anterior) && ($campo != "-:"))
1187   - $campo = "";
1188   - else
1189   - {
1190   - $campo_anterior = $campo;
1191   - $tipo_anterior = $tipo;
1192   - if (!$foiDuplo)
1193   - $md = !$md;
1194   - }
1195   - $classe = $md ? 'formmdtd' : 'formlttd';
1196   -
1197   -
1198   - if($campo_tabela && false)
1199   - {
1200   - if($componente[10] && ($componente[0] == "textoDuploInv" || $componente[0] =="textoInv" ))
1201   - $name = " name='tr_{$componente[10]}' ";
1202   - else
1203   - $name = "";
1204   - $retorno .= "<tr id='tr_$nome' {$name} $style><td class='$classe' valign='top'><span class='form'>$campo</span>{$obrigatorio}{$explicacao}</td><td class='$classe' valign='top'><span class='form'>\n";
1205   - }
1206   - elseif (!$foiDuplo )
1207   - {
1208   - if ($campo == "-:")
1209   - {
1210   - if (empty( $componente[3] )) $componente[3] = renderpixel();
1211   - $explicacao = ( $componente[6] ) ? "<br><sub style='vertical-align:top;'>{$componente[6]}</sub>": "";
1212   - $retorno .= "<tr><td colspan='2' class='$classe'><span class='form'><b>$componente[3]</b></span>{$explicacao}</td></tr>\n";
1213   - }
1214   - else
1215   - { if($componente[10] && ($componente[0] == "textoDuploInv" || $componente[0] =="textoInv" ))
1216   - $name = " name='tr_{$componente[10]}' ";
1217   - else
1218   - $name = "";
1219   -
1220   - $style = ($componente["tr_invisivel"]) ? "style='visibility:collapse'" : "";
1221   - $explicacao = ( $componente[6] ) ? "<br><sub style='vertical-align:top;'>{$componente[6]}</sub>": "";
1222   - $retorno .= "<tr id='tr_$nome' {$name} $style><td class='$classe' valign='top'><span class='form'>$campo</span>{$obrigatorio}{$explicacao}</td><td class='$classe' valign='top'><span class='form'>\n";
1223   - }
1224   - }
1225   - elseif($tipo)
1226   - {
1227   - if($componente[10] == true)
1228   - {
1229   - $explicacao = ( $componente[6] ) ? "<br><sub style='vertical-align:top;'>{$componente[6]}</sub>": "";
1230   - $retorno .= "<span class='form'>$campo</span>{$explicacao}\n";
1231   - }
1232   - else
1233   - {
1234   - $retorno .= "<span class='form'>$campo</span>\n";
1235   - }
1236   - $foiDuplo = false;
1237   - }
1238   -
1239   -
1240   -
1241   - switch ( $tipo )
1242   - {
1243   - case "tiny":
1244   - $retorno .= "<div id='elm1' style='width:450px; height:250px'>{$componente[3]}</div>";
1245   - $this->has_tiny = true;
1246   - break;
1247   -
1248   - case "anexarListaPesquisa":
1249   - {
1250   - $inicio = 0;
1251   - $javascript = "";
1252   - $inclusos = array();
1253   -
1254   - $retorno .= "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" id=\"anexador_{$nome}\">";
1255   - if( is_array( $componente[9] ) )
1256   - {
1257   - // existem itens ja incluidos, monta a lista com eles (com o botao remover ao lado)
1258   - foreach ( $componente[9] AS $ja_incluido )
1259   - {
1260   - list( $cod, $label ) = $ja_incluido;
1261   - $retorno .= "<tr><td><select onchange=\"{$componente[5]}\" class='{$class}' name='{$nome}[]' id='{$nome}_{$inicio}'>";
1262   -
1263   - $opcoes = $componente[3];
1264   - if( $componente[7] )
1265   - {
1266   - // eh um adicionador, entao vamos inserir os ja incluidos na lista padrao
1267   - $opcoes[$cod] = $label;
1268   - }
1269   - reset( $opcoes );
1270   - while (list( $chave, $texto ) = each( $opcoes ))
1271   - {
1272   - $retorno .= "<option id=\"{$nome}_{$inicio}_".urlencode($chave)."\" value=\"".urlencode($chave)."\"";
1273   - if ($chave == $cod) { $retorno .= " selected"; }
1274   - $retorno .= ">$texto</option>";
1275   - }
1276   - $retorno .= "</select>";
1277   - if( $componente[7] )
1278   - {
1279   - $retorno .= "<img src=\"imagens/lupa.png\" alt=\"Pesquisa\" border=\"0\" onclick=\"pesquisa_valores_popless('{$componente[7]}', '{$nome}_{$inicio}')\">";
1280   - }
1281   - $retorno .= " {$componente[8]}</td><td id=\"td_adicionador_{$nome}_{$inicio}\" style=\"padding-left:30px;\"><img name=\"adicionador_{$nome}_{$inicio}\" id=\"adicionador_{$nome}_{$inicio}\" onclick=\"remove_{$nome}('{$inicio}');\" src=\"imagens/banco_imagens/excluirrr.gif\" title=\"Excluir\" border=0></td></tr>";
1282   - $inclusos[] = $inicio;
1283   - $inicio++;
1284   - }
1285   - }
1286   - $inclusos[] = $inicio;
1287   - $javascript .= "\nitens_{$nome} = [" . implode( ",", $inclusos ) . "];";
1288   -
1289   - // array( "anexarListaPesquisa", $campo, "/[^ ]/", $valor, $default, $acao, $descricao, $caminho, $descricao2 );
1290   - $retorno .= "<tr><td><select onchange=\"{$componente[5]}\" class='{$class}' name='{$nome}[]' id='{$nome}_{$inicio}'>";
1291   - $javascript .= "
1292   - function remove_{$nome}( id )
1293   - {
1294   - posicao = 0;
1295   - tabela = document.getElementById( 'anexador_{$nome}' );
1296   - for( i = 0; i < id; i++ )
1297   - {
1298   - if( itens_{$nome}[i] >= id ){break;}
1299   - if( itens_{$nome}[i] != null ){posicao++;}
1300   - }
1301   - itens_{$nome}[id] = null;
1302   - tabela.deleteRow( posicao );
1303   - }
1304   -
1305   - function duplica_{$nome}()
1306   - {
1307   - id = itens_{$nome}.length;
1308   - id = itens_{$nome}.length;
1309   - tabela = document.getElementById( 'anexador_{$nome}' );
1310   - linha = tabela.insertRow( tabela.rows.length );
1311   - col1 = linha.insertCell( 0 );
1312   - col2 = linha.insertCell( 1 );
1313   - col2.style.paddingLeft = '30px';
1314   - sel = document.createElement('select');
1315   - novoIndice = 0;
1316   - ";
1317   -
1318   - reset( $componente[3] );
1319   -
1320   - while (list( $chave, $texto ) = each( $componente[3] ))
1321   - {
1322   - $retorno .= "<option id=\"{$nome}_{$inicio}_".urlencode($chave)."\" value=\"".urlencode($chave)."\"";
1323   - //$javascript .= "strConteudo += '<option id=\"{$nome}_' + id + '_".urlencode($chave)."\" value=\"".urlencode($chave)."\"";
1324   -
1325   - $javascript .= "
1326   - sel.options[novoIndice] = new Option( '{$texto}' );
1327   - sel.options[novoIndice].value = '" . urlencode($chave) . "';
1328   - ";
1329   -
1330   - if ($chave == $componente[4])
1331   - {
1332   - $retorno .= " selected";
1333   - $javascript .= "sel.options[novoIndice].selected = true;";
1334   - }
1335   - $retorno .= ">$texto</option>";
1336   - $javascript .= "
1337   - novoIndice++;
1338   - ";
1339   - }
1340   - $retorno .= "</select>";
1341   - $javascript .= "
1342   - sel.className = '{$class}';
1343   - col1.appendChild( sel );
1344   -
1345   - img = document.createElement('img');
1346   - img.src = 'imagens/banco_imagens/entrada2.gif';
1347   - img.title = 'Incluir';
1348   - img.id = 'adicionador_{$nome}_' + id;
1349   - img.name = 'adicionador_{$nome}_' + id;
1350   - img.onclick = function(){duplica_{$nome}();};
1351   - col2.appendChild( img );
1352   -
1353   - id_antecessor = id - 1;
1354   -
1355   - img_ant = document.getElementById( 'adicionador_{$nome}_' + id_antecessor );
1356   - img_ant.src = 'imagens/banco_imagens/excluirrr.gif';
1357   - document.getElementById( 'adicionador_{$nome}_' + id_antecessor ).onclick = function(){ onclick=remove_{$nome}(this.name.substr( this.name.lastIndexOf( '_' ) + 1 )); };
1358   -
1359   - itens_{$nome}[id] = id;
1360   - }
1361   - ";
1362   - if( $componente[7] )
1363   - {
1364   - $retorno .= "<img src=\"imagens/lupa.png\" alt=\"Pesquisa\" border=\"0\" onclick=\"pesquisa_valores_popless('{$componente[7]}', '{$nome}_{$inicio}')\">";
1365   - //$javascript .= "strConteudo += '<img src=\"imagens/lupa.png\" alt=\"Pesquisa\" border=\"0\" onclick=\"pesquisa_valores_popless( \'{$componente[7]}\', \'{$nome}_' + id + '\' )\">';\n";
1366   - }
1367   -// $javascript .= "strConteudo += '</td><td id=\"td_adicionador_{$nome}_' + id + '\" style=\"padding-left:30px;\"><input type=\"button\" name=\"adicionador_{$nome}_' + id + '\" id=\"adicionador_{$nome}_' + id + '\" value=\"[+] Adicionar teste 2\" onclick=\"duplica_{$nome}();\" class=\"botaolistagem\"></td>';\n";
1368   -// $javascript .= "strConteudo += '</td><td id=\"td_adicionador_{$nome}_' + id + '\" style=\"padding-left:30px;\"><img name=\"adicionador_{$nome}_' + id + '\" id=\"adicionador_{$nome}_' + id + '\" onclick=\"duplica_{$nome}();\" src=\"imagens/banco_imagens/entrada2.gif\" title=\"Incluir\" border=0></td>';\n";
1369   -// $javascript .= "tabela = document.getElementById( 'anexador_{$nome}' );\nlinha = tabela.insertRow( tabela.rows.length );\ntrocaConteudo( linha, strConteudo );\nfor( i = id - 1; i > -1; i-- ){\nantecessor = document.getElementById( 'td_adicionador_{$nome}_' + itens_{$nome}[i] );\nbotaoRemover = '<input type=\"button\" name=\"adicionador_{$nome}_' + i + '\" id=\"adicionador_{$nome}_' + i + '\" value=\"[-] Remover removteste\" onclick=\"remove_{$nome}(' + i + ');\" class=\"botaolistagem\">';\nif( typeof antecessor == 'object' ){\ntrocaConteudo( antecessor, botaoRemover );\nbreak;\n}\n}\nitens_{$nome}[id] = id;\n}";
1370   -// $javascript .= "tabela = document.getElementById( 'anexador_{$nome}' );\nlinha = tabela.insertRow( tabela.rows.length );\ntrocaConteudo( linha, strConteudo );\nfor( i = id - 1; i > -1; i-- ){\nantecessor = document.getElementById( 'td_adicionador_{$nome}_' + itens_{$nome}[i] );\nbotaoRemover = '<img name=\"adicionador_{$nome}_' + i + '\" id=\"adicionador_{$nome}_' + i + '\" onclick=\"remove_{$nome}(' + i + ');\" src=\"imagens/banco_imagens/excluirrr.gif\" title=\"Excluir\" border=0>';\nif( typeof antecessor == 'object' ){\ntrocaConteudo( antecessor, botaoRemover );\nbreak;\n}\n}\nitens_{$nome}[id] = id;\n}";
1371   -// $retorno .= " {$componente[8]}</td><td id=\"td_adicionador_{$nome}_{$inicio}\" style=\"padding-left:30px;\"><input type=\"button\" name=\"adicionador_{$nome}_{$inicio}\" id=\"adicionador_{$nome}_{$inicio}\" value=\"[+] Adicionar teste\" onclick=\"duplica_{$nome}();\" class=\"botaolistagem\"></td></tr></table><script type=\"text/javascript\">$javascript</script>";
1372   - $retorno .= " {$componente[8]}</td><td id=\"td_adicionador_{$nome}_{$inicio}\" style=\"padding-left:30px;\"><img name=\"adicionador_{$nome}_{$inicio}\" id=\"adicionador_{$nome}_{$inicio}\" onclick=\"duplica_{$nome}();\" src=\"imagens/banco_imagens/entrada2.gif\" title=\"Incluir\" border=0></td></tr></table><script type=\"text/javascript\">$javascript</script>";
1373   - break;
1374   - }
1375   - case "rotuloDuplo":
1376   - $foiDuplo = true;
1377   - case "rotulo":
1378   - {
1379   - if ($campo != "-:")
1380   - $retorno .= $componente[3];
1381   - break;
1382   - }
1383   - case "cep":
1384   - {
1385   - $retorno .= "<input onKeyPress=\"formataCEP(this, event);\" class='{$class}' type='text' name=\"{$nome}\" id=\"{$nome}\" value=\"{$campo_valor}\" size=\"{$componente[4]}\" maxlength=\"{$componente[5]}\" $componente[8]>$componente[7]\n";
1386   - break;
1387   - }
1388   - case "fone":
1389   - {
1390   - $retorno .= "<input class='{$class}' type='text' name=\"ddd_{$nome}\" id=\"ddd_{$nome}\" value=\"{$componente[3]}\" size=\"3\" maxlength=\"2\"> <input onKeyPress=\"formataFone(this,event);\" class='{$class}' type='text' name=\"fone_{$nome}\" id=\"fone_{$nome}\" value=\"{$componente[3]}\" size=\"{$componente[4]}\" maxlength=\"{$componente[5]}\">\n";
1391   - break;
1392   - }
1393   - case "data":
1394   - {
1395   - $retorno .= "<input onKeyPress=\"formataData(this, event);\" class='{$class}' type='text' name=\"{$nome}\" id=\"{$nome}\" value=\"{$componente[3]}\" size=\"{$componente[4]}\" maxlength=\"{$componente[5]}\" {$componente[8]}> $componente[7]\n";
1396   - break;
1397   - }
1398   - case "dataDupla":
1399   - {
1400   -
1401   - $retorno .= "<input onKeyPress=\"formataData(this, event);\" class='{$class}' type='text' name=\"{$nome}\" id=\"{$nome}\" value=\"{$componente[3]}\" size=\"{$componente[4]}\" maxlength=\"{$componente[5]}\"> $componente[7]";
1402   - break;
1403   - }
1404   - case "hora":
1405   - {
1406   - $componente[3] = strlen( $componente[3] ) < 6 ? $componente[3]: substr($componente[3],0,5);
1407   - $retorno .= "<input onKeyPress=\"formataHora(this, event);\" class='{$class}' type='text' name=\"{$nome}\" id=\"{$nome}\" value=\"{$componente[3]}\" size=\"{$componente[4]}\" maxlength=\"{$componente[5]}\" {$componente[8]}>{$componente[7]}";
1408   - break;
1409   - }
1410   - case "cor":
1411   - {
1412   - $cor = empty($componente[3]) ? "ffffff" : $componente[3];
1413   - $retorno .= "<input type='text' name='{$nome}' value='$componente[3]' size='6' maxlength='6' onBlur='setColor();' class='{$class}' /> *
1414   - <a href='#' class='link' onClick=\"newwin=window.open('./cores.html', 'cores', 'width=320, height=260, scollbars=false');\">Alterar cor</a>
1415   - <span id=\"{$nome}1\" style=\" background:#$cor;\"><a href=\"#\" onClick=\"newwin=window.open('./cores.html', 'cores', 'width=320, height=260, scollbars=false');\"><img src=\"./imagens/shim.gif\" border=\"1\" width=\"40\" style=\"border-color:#000000;\" height=\"18\"></a></span>";
1416   - break;
1417   - }
1418   - case "mapa":
1419   - {
1420   - $cor = empty($componente[3]) ? "ffffff" : $componente[3];
1421   - $retorno .= "<input disabled type='text' name='{$nome}' value='$componente[3]' size='6' maxlength='6' onBlur='setColor();' class='{$class}' /> *
1422   - <a href='#' class='link' onClick=\"newwin=window.open('./escolhe_coordenada.php', 'escolhe_coordenada', 'width=400, height=430, scollbars=false');\">Seleciona Coordenada</a>";
1423   - break;
1424   - }
1425   - case "adicionar":
1426   - {
1427   - $retorno .= "<select onchange=\"{$componente[5]}\" class='{$class}' name='{$nome}' id='{$nome}' >";
1428   - reset( $componente[3] );
1429   - while (list( $chave, $texto ) = each( $componente[3] ))
1430   - {
1431   - $retorno .= "<option value=\"".urlencode($chave)."\"";
1432   - if ($chave == $componente[4])
1433   - $retorno .= " selected";
1434   - $retorno .= ">$texto</option>";
1435   - }
1436   - $retorno .= "</select>";
1437   - $retorno .= "<a href='#' class='imagem' onClick=\"receptor=document.formcadastro.{$nome};newwin=window.open('".$componente[8]."', '{$nome}_link', 'width=".$componente[9].", height=".$componente[10].", scollbars=false');\"> <img src='imagens/nvp_bot_novo.png' border=0 alt='".$componente[7]."'></a>";
1438   - $retorno .= "
1439   - <script type=\"text/javascript\">
1440   - var receptor;
1441   - document.formcadastro.{$nome}.muda = function( valor, texto )
1442   - {
1443   - novoIndice = this.options.length;
1444   - this.options[novoIndice] = new Option( texto );
1445   - opcao = this.options[novoIndice];
1446   - opcao.value = valor;
1447   - opcao.selected = true;
1448   - {$componente[11]}
1449   - }
1450   - </script>
1451   - ";
1452   - break;
1453   - }
1454   - case "detalhe":
1455   - {
1456   - $retorno .= "<select onchange=\"if(this.value > 0) CarregaDetalhe( '{$nome}_div','".$componente[8]."'+this.value); $componente[5]\" class='{$class}' name='{$nome}' id='{$nome}' >";
1457   - reset( $componente[3] );
1458   - while (list( $chave, $texto ) = each( $componente[3] ))
1459   - {
1460   - $retorno .= "<option value=\"".urlencode($chave)."\"";
1461   - if ($chave == $componente[4])
1462   - $retorno .= " selected";
1463   - $retorno .= ">$texto</option>";
1464   - }
1465   - $retorno .= "</select>";
1466   - if($componente[4])
1467   - $carrega ="CarregaDetalhe('{$nome}_div','".$componente[8].$componente[4]."');";
1468   - $onClick = "AbreFecha('{$nome}_div', '{$nome}_img');";
1469   - $retorno .= "<a href='#' class='imagem' onClick=\"$carrega $onClick\"> <img src='imagens/log-info.gif' border=0 alt='".$componente[7]."' id='{$nome}_img'></a>";
1470   - $retorno .= "<div style='overflow: hidden;height: 1px;position: relative;width:100%;' name='{$nome}_div' id='{$nome}_div'></div>";
1471   - $classe = ($classe == 'formmdtd') ? 'formlttd' : 'formmdtd' ;
1472   - break;
1473   - }
1474   - case "cpf":
1475   - {
1476   - $retorno .= "<input onKeyPress=\"formataCPF(this, event);\" class='{$class}' type='text' name=\"{$nome}\" id=\"{$nome}\" value=\"{$componente[3]}\" size=\"{$componente[4]}\" maxlength=\"{$componente[5]}\">$componente[7]";
1477   - break;
1478   - }
1479   -
1480   - case "idFederal":
1481   - {
1482   - $retorno .= "<input onkeyPress=\"formataIdFederal(this,event);\" class='{$class}' type='text' name=\"{$nome}\" id=\"{$nome}\" value=\"{$componente[3]}\" size=\"{$componente[4]}\" maxlength=\"{$componente[5]}\" {$componente[7]}> {$componente[8]}";
1483   - break;
1484   - }
1485   -
1486   - case "cnpj":
1487   - {
1488   - $retorno .= "<input onKeyPress=\"formataCNPJ(this, event);\" class='{$class}' type='text' name=\"{$nome}\" id=\"{$nome}\" value=\"{$componente[3]}\" size=\"{$componente[4]}\" maxlength=\"{$componente[5]}\">";
1489   - break;
1490   - }
1491   -
1492   - case "cnpj_pesq":
1493   - {
1494   - $retorno .= "<input onKeyPress=\"formataCNPJ(this, event);\" class='{$class}' type='text' name=\"{$nome}\" id=\"{$nome}\" value=\"{$componente[3]}\" size=\"{$componente[4]}\" maxlength=\"{$componente[5]}\">";
1495   - $retorno .= "<img src=\"imagens/lupa.png\" alt=\"Pesquisa\" border=\"0\" onclick=\"pesquisa_valores_popless('{$componente[7]}?campos={$componente[8]}', '{$nome}')\"> {$componente[9]}";
1496   - break;
1497   - }
1498   -
1499   - case "check":
1500   - {
1501   - $onClick = "";
1502   - if( $componente[5] )
1503   - {
1504   - $onClick = "onclick=\"{$componente[5]}\"";
1505   - }
1506   -
1507   - // "check", $campo, $valor
1508   - $retorno .= "<input type='checkbox' name=\"{$nome}\" id=\"{$nome}\" {$onClick}";
1509   - if ($componente[3])
1510   - {
1511   - $retorno .= " checked";
1512   - }
1513   - $retorno .= " {$componente[6]}> {$componente[4]}";
1514   -
1515   - break;
1516   - }
1517   -
1518   - case "checkDuplo":
1519   - {
1520   - // "check", $campo, $valor
1521   - $retorno .= "<input type='checkbox' name=\"{$nome}\"";
1522   - if ($componente[3])
1523   - {
1524   - $retorno .= " checked";
1525   - }
1526   - $retorno .= "> {$componente[4]} ";
1527   - $foiDuplo = true;
1528   - break;
1529   - }
1530   - case "latitude":
1531   - {
1532   - $retorno .= "<input onBlur=\"colocaMenos(this);\" class='{$class}' type='text' name=\"{$nome}_graus\" value=\"{$componente[3]}\" size=\"3\" maxlength=\"3\"><sup style='vertical-align:top;'>o</sup><input class='{$class}' type='text' name=\"{$nome}_min\" value=\"{$componente[7]}\" size=\"2\" maxlength=\"2\"><sup style='vertical-align:top;'>'</sup><input class='{$class}' type='text' name=\"{$nome}_seg\" value=\"{$componente[8]}\" size=\"2\" maxlength=\"2\"><sup style='vertical-align:top;'>\"</sup>";
1533   - break;
1534   - }
1535   - case "longitude":
1536   - {
1537   - $retorno .= "<input onBlur=\"colocaMenos(this);\" class='{$class}' type='text' name=\"{$nome}_graus\" value=\"{$componente[3]}\" size=\"3\" maxlength=\"3\"><sup style='vertical-align:top;'>o</sup><input class='{$class}' type='text' name=\"{$nome}_min\" value=\"{$componente[7]}\" size=\"2\" maxlength=\"2\"><sup style='vertical-align:top;'>'</sup><input class='{$class}' type='text' name=\"{$nome}_seg\" value=\"{$componente[8]}\" size=\"2\" maxlength=\"2\"><sup style='vertical-align:top;'>\"</sup>";
1538   - break;
1539   - }
1540   - case "texto" :
1541   - {
1542   -
1543   - if($componente[10])
1544   - {
1545   - $disabled = "disabled";
1546   - }
1547   - else
1548   - {
1549   - $disabled = "";
1550   - }
1551   -
1552   - if( $componente[9] && $componente[8] )
1553   - {
1554   - $evento = " {$componente[9]}=\"{$componente[8]}\"";
1555   - }
1556   - else
1557   - {
1558   - $evento = "";
1559   - }
1560   - $retorno .= "<input class='{$class}' type='text' name=\"{$nome}\" id=\"{$nome}\" value=\"{$campo_valor}\" size=\"{$componente[4]}\" maxlength=\"{$componente[5]}\" {$evento} {$disabled}> {$componente[7]}";
1561   -
1562   - break;
1563   - }
1564   - case "monetario" :
1565   - {
1566   - if($componente[9])
1567   - $disabled = "disabled";
1568   - else
1569   - $disabled = "";
1570   -
1571   - if(!$componente[6])
1572   - $componente[6] = $componente[11];
1573   -
1574   - $retorno .= "<input style='text-align:right' onKeyup=\"formataMonetario(this, event);\" $componente[8] = \"{$componente[7]}\" class='{$class}' type='text' name=\"{$nome}\" id=\"{$nome}\" value=\"{$componente[3]}\" size=\"{$componente[4]}\" maxlength=\"{$componente[5]}\" {$disabled}> {$componente[6]}";
1575   - break;
1576   - }
1577   - case "monetarioDuplo" :
1578   - {
1579   - if($componente[9])
1580   - $disabled = "disabled";
1581   - else
1582   - $disabled = "";
1583   -
1584   - if(!$componente[6])
1585   - $componente[6] = $componente[11];
1586   -
1587   - $retorno .= "<input style='text-align:right' onKeyup=\"formataMonetario(this, event);\" $componente[8] = \"{$componente[7]}\" class='{$class}' type='text' name=\"{$nome}\" id=\"{$nome}\" value=\"{$componente[3]}\" size=\"{$componente[4]}\" maxlength=\"{$componente[5]}\" {$disabled}> {$componente[6]}";
1588   - $foiDuplo = true;
1589   - break;
1590   -
1591   - }
1592   - case "email" :
1593   - {
1594   - $retorno .= "<input class='{$class}' style='text-align: left;' type='text' name=\"{$nome}\" id=\"{$nome}\" value=\"{$componente[3]}\" size=\"{$componente[4]}\" maxlength=\"{$componente[5]}\" onKeyUp=\"{$componente[8]}\"> $componente[7]";
1595   - break;
1596   - }
1597   - case "suggest" :
1598   - {
1599   - $retorno .= "<input class='{$class}' type='text' name=\"{$nome}\" id=\"{$nome}\" value=\"{$componente[3]}\" onfocus=\"DOM_focusIn();\" onblur=\"DOM_focusOut();\" class=\"DOM_suggest\" style=\"width:250px;\">";
1600   - $retorno .= "<script type=\"text/javascript\">";
1601   - $retorno .= "DOM_atual = new Object();";
1602   - $retorno .= "DOM_atual.objectId = \"{$nome}\";";
1603   - $retorno .= "DOM_atual.arquivo = \"{$componente[7]}\";";
1604   - $retorno .= "document.getElementById(\"{$nome}\").onkeyup=function(e){ DOM_atual.objectId=\"{$nome}\"; DOM_navegaUpDown(e); };";
1605   - $retorno .= "</script>";
1606   - break;
1607   - }
1608   - case "textoPesquisa" :
1609   - {
1610   - if( $componente[10] )
1611   - {
1612   - $disabled = "disabled";
1613   - }
1614   - else
1615   - {
1616   - $disabled = "";
1617   - }
1618   - $retorno .= "<input class='{$class}' type='text' name=\"{$nome}\" id=\"{$nome}\" value=\"{$componente[3]}\" size=\"{$componente[4]}\" maxlength=\"{$componente[5]}\" {$componente[12]}='{$componente[11]}' {$disabled}> ";
1619   - if ( $componente[9] )
1620   - { // tem serialized campos
1621   - $retorno .= "<img src=\"imagens/lupa.png\" alt=\"Pesquisa\" border=\"0\" name='{$nome}_lupa' id='{$nome}_lupa' onclick=\"pesquisa_valores_popless('{$componente[8]}?campos={$componente[9]}', '{$nome}')\"> {$componente[7]}";
1622   - }else {
1623   - $retorno .= "<img src=\"imagens/lupa.png\" alt=\"Pesquisa\" border=\"0\" name='{$nome}_lupa' id='{$nome}_lupa' onclick=\"pesquisa_valores_popless('{$componente[8]}', '{$nome}')\"> {$componente[7]}";
1624   -// $retorno .= "<img src=\"imagens/lupa.png\" alt=\"Pesquisa\" border=\"0\" onclick=\"pesquisa_valores_f('{$componente[8]}', '{$nome}')\"> $componente[7]";
1625   - }
1626   - break;
1627   - }
1628   - case "textoInv" :
1629   - {
1630   - $retorno .= "<input class='{$class}' type='text' name=\"{$componente[10]}\" id=\"{$nome}\" value=\"{$componente[3]}\" size=\"{$componente[4]}\" maxlength=\"{$componente[5]}\" disabled=true {$componente[9]}=\"{$componente[8]}\">&nbsp;$componente[7]";
1631   - break;
1632   - }
1633   - case "textoDuploInv" :
1634   - {
1635   - $retorno .= "<input class='{$class}' type='text' name=\"{$componente[10]}\" id=\"{$nome}\" value=\"{$componente[3]}\" size=\"{$componente[4]}\" maxlength=\"{$componente[5]}\" disabled=true>";
1636   - $foiDuplo = true;
1637   - break;
1638   - }
1639   - case "textoExterno" :
1640   - {
1641   - //"textoExterno", $campo, $obrigatorio, $valor, $tamanhovisivel, $tamanhomaximo, $descricao, $caminho, $nome_caminho
1642   - $retorno .= "<input class='{$class}' type='text' name=\"{$nome}\" id=\"{$nome}\" value=\"{$componente[3]}\" size=\"{$componente[4]}\" maxlength=\"{$componente[5]}\" disabled=true> <a href='#' onclick=\"javascript:$componente[7]\">$componente[8]</a>";
1643   - break;
1644   - }
1645   - case "adicionarProcurar" :
1646   - {
1647   - //"textoExterno", $campo, $obrigatorio, $valor, $tamanhovisivel, $tamanhomaximo, $descricao, $caminho, $nome_caminho
1648   - $retorno .= "<input class='{$class}' type='text' name=\"{$nome}\" id=\"{$nome}\" value=\"{$componente[3]}\" size=\"{$componente[4]}\" maxlength=\"{$componente[5]}\" disabled=true> <a href='#' onclick=\"javascript:$componente[7]\">$componente[8]</a>&nbsp;&nbsp;<a href='#' onclick=\"javascript:$componente[9]\">$componente[10]</a>";
1649   - break;
1650   - }
1651   - case "senha" :
1652   - {
1653   - $retorno .= "<input class='{$class}' type='password' name=\"{$nome}\" id=\"{$nome}\" value=\"{$campo_valor}\" size=\"{$componente[4]}\" maxlength=\"{$componente[5]}\">";
1654   - break;
1655   - }
1656   - case "textoDuplo" :
1657   - {
1658   - if($componente[10])
1659   - $disabled = "disabled";
1660   - else
1661   - $disabled = "";
1662   -
1663   - $retorno .= "<input class='{$class}' type='text' name=\"{$nome}\" id=\"{$nome}\" value=\"{$campo_valor}\" size=\"{$componente[4]}\" maxlength=\"{$componente[5]}\" onKeyUp=\"{$componente[8]}\" {$disabled}>";
1664   - $foiDuplo = true;
1665   - break;
1666   - }
1667   - case "memo" :
1668   - {
1669   -
1670   - if ( $componente[11] )
1671   - {
1672   - $retorno .= "<textarea class='{$class}' name=\"{$nome}\" id=\"{$nome}\" cols=\"{$componente[4]}\" rows=\"{$componente[5]}\" style='wrap:virtual' {$evento} disabled ";
1673   - }
1674   - else
1675   - {
1676   - $retorno .= "<textarea class='{$class}' name=\"{$nome}\" id=\"{$nome}\" cols=\"{$componente[4]}\" rows=\"{$componente[5]}\" style='wrap:virtual' {$evento} ";
1677   - }
1678   -
1679   - if( $componente[9] && $componente[10] )
1680   - {
1681   - $evento = "{$componente[9]}=\"{$componente[10]}\"";
1682   - }
1683   - else
1684   - {
1685   - $evento = "";
1686   - }
1687   -
1688   - if ($componente[7] > 0)
1689   - $retorno .= "ONKEYDOWN='this.form.{$nome}.value=this.form.{$nome}.value.length >= {$componente[7]} ? this.form.{$nome}.value.substring(0,{$componente[7]}-1) : this.form.{$nome}.value;'";
1690   - $retorno .= ">{$campo_valor}</textarea>\n";
1691   - $foiDuplo = $componente[8];
1692   - break;
1693   - }
1694   - case "lista" :
1695   - {
1696   -
1697   - if(is_numeric($componente[9]))
1698   - $multiple = " multiple='multiple' SIZE='{$componente[9]}' ";
1699   - else
1700   - $multiple = "";
1701   -
1702   - $retorno .= "<select onchange=\"{$componente[5]}\" class='{$class}' name='{$nome}' id='{$nome}' {$componente[8]} {$multiple}>";
1703   - $opt_open = false;
1704   - reset( $componente[3] );
1705   - while (list( $chave, $texto ) = each( $componente[3] ))
1706   - {
1707   - if( substr( $texto, 0, 9 ) == "optgroup:" )
1708   - {
1709   - // optgroup
1710   - /*if( $opt_open )
1711   - {
1712   - $retorno .= "</optgroup>";
1713   - }*/
1714   - $opt_open = true;
1715   - $retorno .= "<optgroup label=\"" . substr( $texto, 9 ) . "\">";
1716   - }
1717   - elseif( substr( $texto, 0, 8 ) == "optgroup" )
1718   - {
1719   - // optgroup
1720   - if( $opt_open )
1721   - {
1722   - $opt_open = false;
1723   - $retorno .= "</optgroup>";
1724   - }
1725   - //$retorno .= "<optgroup label=\"" . substr( $texto, 9 ) . "\">";
1726   - }
1727   - else
1728   - {
1729   - // option normal
1730   - $retorno .= "<option id=\"{$nome}_".urlencode($chave)."\" value=\"".urlencode($chave)."\"";
1731   - if( is_array( $componente[4] ) )
1732   - {
1733   - if( $chave==$componente[4][$adicionador_indice])
1734   - {
1735   - $retorno .= " selected";
1736   - }
1737   - }
1738   - else if ($chave == $componente[4])
1739   - {
1740   - $retorno .= " selected";
1741   - }
1742   - $retorno .= ">$texto</option>";
1743   - }
1744   - }
1745   - if( $opt_open )
1746   - {
1747   - $retorno .= "</optgroup>";
1748   - }
1749   - $retorno .= "</select> {$componente[7]}";
1750   - break;
1751   - }
1752   -
1753   - case "AddForm":
1754   - {
1755   - $arr_campos["linha_{$nome}"] = array("addForm", $nome, $arr_campos );
1756   -
1757   - $span = "";
1758   - $input = "";
1759   - $cont=0;
1760   - if($arr_campos)
1761   - {
1762   - foreach ($arr_campos as $campo => $atributo)
1763   - {
1764   - $span .= "var span$cont = document.createElement( \"span{$cont}\" );";
1765   - $cont++;
1766   - }
1767   - }
1768   -
1769   - $retorno = "function adiciona (obj)
1770   - {
1771   - tabela = document.getElementById( 'table_fotos' );
1772   - linha = tabela.insertRow( tabela.rows.length );
1773   -
1774   - var td = document.createElement( \"td\" );
1775   - var input = document.createElement( \"input\" );
1776   - var botao = document.createElement( \"input\" );
1777   -
1778   - botao.setAttribute( \"type\", \"button\");
1779   - botao.setAttribute( \"id\", \"foto_[]\" );
1780   - botao.setAttribute( \"name\", \"foto_[]\" );
1781   - botao.setAttribute( \"onclick\", \"adiciona(this);\" );
1782   - botao.setAttribute( \"value\", \"Adicionar[+]\" );
1783   -
1784   - input.setAttribute( \"type\", \"text\" );
1785   - input.setAttribute( \"id\", \"foto[]\" );
1786   - input.setAttribute( \"name\", \"foto[]\" );
1787   - input.setAttribute( \"maxlength\", \"50\" );
1788   - input.setAttribute( \"size\", \"50\" );
1789   -
1790   - obj.setAttribute( \"onclick\", \"this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode);\" );
1791   - obj.setAttribute( \"value\", \"Remover[-]\" );
1792   -
1793   - linha.appendChild( td );
1794   - td.appendChild(input);
1795   - td.appendChild(botao);
1796   -
1797   - }
1798   - ";
1799   - }
1800   - case "addCampos":
1801   - {
1802   -// $arr_campos["linha_{$nome}"] = array("addForm", $nome, $arr_campos );
1803   -
1804   -
1805   -
1806   - $nome = $componente[1];
1807   - $nome = str_replace(" ", "_" , $nome);
1808   -
1809   - $arr_campos = $componente[3];
1810   - $arr_valores = $componente[4];
1811   - $arr_tipos = array();
1812   -
1813   - $input = "";
1814   - $strCampos = "";
1815   - $setAtributos = "";
1816   - $addCampo = "";
1817   - $valores = "";
1818   - $br = "";
1819   - $ValEditar = "";
1820   -
1821   - $quebra = "";
1822   - $inicio = "<div id=\"div{$nome}0\">";
1823   -
1824   - $cont = 0;
1825   -
1826   - if($arr_campos)
1827   - {
1828   - foreach ($arr_campos as $campo => $atributo)
1829   - {
1830   - $atributo["quebra"] = !isset($atributo["quebra"])? true : $atributo["quebra"];
1831   - //echo $atributo["quebra"];
1832   - $arr_tipos[$campo] = $atributo['type'];
1833   - //$quebra = "<br>";//$atributo["quebra"] == true ? "<br>" : "";
1834   - if( !empty($atributo['campo']) )
1835   - $atributo['campo'] = "<br>{$atributo['campo']}:<br>";
1836   - else
1837   - $atributo['campo'] = "";
1838   -
1839   - $disabled = !empty($atributo['disabled']) ? " disabled = true " : "";
1840   -
1841   -// $atributo['campo'] = !empty($atributo['campo']) ? "{$atributo['campo']}:<br>" : " ";
1842   - //$inicio .= "$quebra<span >{$atributo['campo']}</span>"
1843   - $inicio .= "$quebra<span >{$atributo['campo']}</span>
1844   - <input id='{$atributo['id']}0' name='{$atributo['name']}[]' ";
1845   - $input .= "var input_$campo = document.createElement( \"input\" );\n";
1846   - $input .= "var span_$campo = document.createElement( \"span\" );\n";
1847   - $input .= "span_$campo.setAttribute( \"id\", \"span_$campo\"+cont{$nome} );\n";
1848   - $id = $atributo['id'];
1849   - if($atributo)
1850   - {
1851   - foreach ($atributo as $formId => $valor)
1852   - {
1853   - if ($formId == 'id')
1854   - {
1855   - $setAtributos .= "input_{$campo}.setAttribute( \"$formId\", \"{$valor}\"+cont{$nome} );\n";
1856   - }
1857   - elseif($formId == 'name')
1858   - {
1859   - $valores .= "document.getElementById( \"{$id}\"+cont{$nome} ).name = \"{$valor}[]\"; \n ";
1860   - }
1861   - elseif($formId != 'quebra' || $formId == 'campo')
1862   - {
1863   - $valor = $formId == "disabled" ? "true" : $valor;
1864   - $setAtributos .= "input_{$campo}.setAttribute( '$formId', '$valor' );\n";
1865   - $inicio .= "$formId = '$valor'" ;
1866   - }
1867   - //$valores .= "document.getElementById( \"{$id}\"+cont{$nome} ).disabled = \"true\"; \n ";
1868   - }
1869   -
1870   - }
1871   - $inicio .= "{$disabled} >";
1872   - $quebra = $atributo["quebra"] == true || !isset($atributo["quebra"]) ? "<br>" : "";
1873   - $addCampo .= "\n div_{$nome}.appendChild(span_{$campo}); \n document.getElementById(\"span_$campo\"+cont{$nome}).innerHTML = '$quebra{$atributo['campo']} ';\n div_{$nome}.appendChild(input_{$campo});\n";
1874   -
1875   - $atributo['campo'] = "";
1876   - }
1877   - }
1878   -
1879   - if($arr_valores)
1880   - {
1881   -
1882   - if(array_key_exists("options",$arr_valores)){
1883   - $opcoes = array_pop($arr_campos);
1884   - print_r($opcoes);
1885   - //die;
1886   - }
1887   - //print_r($arr_valores);
1888   - foreach ($arr_valores as $val)
1889   - {
1890   - $ValEditar .= "<div>";
1891   -
1892   - if($val)
1893   - {
1894   -
1895   -// $chave = reset($val);
1896   - $chave = key($arr_valores);
1897   -
1898   -
1899   - $valor_chave = reset($val);
1900   - $disabled = substr($valor_chave, -2);
1901   - $valor_chave = substr($valor_chave, 0, -2);
1902   -
1903   - // echo "<b>$valor_chave , $disabled</b><br>";
1904   - $disabled = $disabled=="_1" ? "disabled" : "";
1905   - foreach ($arr_tipos as $id => $type)
1906   - {
1907   - if($type == 'file')
1908   - {
1909   - $ValEditar .= "{$valor_chave}<br>";
1910   - }
1911   - elseif($type != 'button')
1912   - {
1913   - if($type == "hidden")
1914   - {
1915   - $valor_chave = (!$valor_chave) ? $chave : $valor_chave;
1916   - $disabled = "";
1917   - }
1918   - elseif(strstr($id,"data") != false)
1919   - {
1920   - $keypress = " onKeyPress=\"formataData(this, event);\" maxlength=\"10\"";
1921   - }
1922   - else
1923   - {
1924   - $keypress = "";
1925   - }
1926   -
1927   - $ValEditar .= "<input type='{$type}' $keypress class='geral' value='{$valor_chave}' name='edit_{$id}[{$chave}]' $disabled><br>";
1928   - }
1929   -
1930   - $valor_chave = next($val);
1931   -
1932   - }
1933   - $chave = next($arr_valores);
1934   - $chave = key($arr_valores);
1935   - }
1936   - $ValEditar .= "<img vspace='4' src='imagens/banco_imagens/excluir.gif' onclick='this.parentNode.parentNode.removeChild(this.parentNode);'><hr></div>";
1937   - }
1938   - }
1939   - $inicio .= "<img hspace='5' src='imagens/banco_imagens/incluir.gif' onclick='adiciona_{$nome}();'><br>
1940   - <br>
1941   - " ;
1942   - $retorno .= "<script type=\"text/javascript\">var cont{$nome}=1;
1943   - function adiciona_{$nome}()
1944   - {
1945   - principal = document.getElementById( '{$nome}' );
1946   -
1947   - var div_{$nome} = document.createElement( \"div\" );\n;
1948   - var div_linha = document.createElement( \"hr\" );\n;
1949   -
1950   -
1951   - $input
1952   - principal.appendChild(div_{$nome});
1953   - div_{$nome}.appendChild(div_linha);
1954   - add_new = '<img hspace=\'5\' src=\'imagens/banco_imagens/incluir.gif\' onclick=\'adiciona_{$nome}();\'>';
1955   - del = '<img hspace=\'5\' src=\'imagens/banco_imagens/excluir.gif\' onclick=\'this.parentNode.parentNode.removeChild(this.parentNode);\'><br><br>';
1956   -
1957   - div_{$nome}.setAttribute( \"id\", \"div{$nome}\"+cont{$nome} );\n
1958   -
1959   - $setAtributos
1960   -
1961   -
1962   - $addCampo
1963   -
1964   - document.getElementById( 'div{$nome}'+cont{$nome} ).innerHTML += add_new;
1965   - document.getElementById( 'div{$nome}'+cont{$nome} ).innerHTML += del;
1966   -
1967   - $valores
1968   -
1969   - cont{$nome}++;
1970   - }
1971   - </script>
1972   - <div =\"valores{$nome}\">
1973   - $ValEditar
1974   - </div>
1975   - <div id=\"{$nome}\">
1976   - $inicio
1977   - </div>
1978   -
1979   - ";
1980   - break;
1981   - }
1982   - case "listaDin" :
1983   - {
1984   - $url = "var campos = [];";
1985   - if($componente[12])
1986   - {
1987   - foreach ($componente[12] as $key=>$campo)
1988   - {
1989   - $url .= "campos[$key] = '$campo';";
1990   - }
1991   - }
1992   - $rand = rand(1,10000);
1993   - $script = "
1994   - <script type=\"text/javascript\">
1995   - function get_{$componente[11]}()
1996   - {
1997   - $url
1998   - url = '?';
1999   - junta = '';
2000   - for( i = 0; i < campos.length; i++ )
2001   - {
2002   - url += junta+campos[i]+'='+document.getElementById(campos[i]).value;
2003   - junta = '&';
2004   - }
2005   -
2006   - // define qual a funcao que devera ser executada quando o xml for carregado
2007   - DOM_execute_when_xmlhttpChange = function() { get_{$componente[11]}Done(); };
2008   - strURL = \"{$componente[10]}\"+url+'&rand='+\"{$url}\";
2009   - DOM_loadXMLDoc( strURL );
2010   - }
2011   -
2012   - function get_{$componente[11]}Done()
2013   - {
2014   - var valores = [];
2015   - var campos = [];
2016   - ObjSelect = document.getElementById(\"{$componente[7]}\");
2017   - ObjSelect.options.length =0;
2018   - ObjSelect.options[ObjSelect.options.length] = new Option ( 'Selecione','0', true, true);
2019   - for( i = 0; i < DOM_itensArray.length; i=i+2 )
2020   - {
2021   -
2022   - objXML = DOM_itensArray[i].firstChild;
2023   - valores[i] = objXML.data;
2024   - objXML = DOM_itensArray[i+1].firstChild;
2025   - campos[i] = objXML.data;
2026   - ObjSelect.options[ObjSelect.options.length] = new Option (campos[i], valores[i], true, true);
2027   -
2028   - }
2029   - ObjSelect.value = 0;
2030   - {$componente[13]}
2031   - }
2032   -
2033   - </script>
2034   - ";
2035   -
2036   - $retorno .= "$script<select onchange=\"{$componente[5]} get_{$componente[11]}();\" class='{$class}' name='{$nome}' id='{$nome}' {$componente[8]}>";
2037   - // die($componente[3]);
2038   - reset( $componente[3] );
2039   - while (list( $chave, $texto ) = each( $componente[3] ))
2040   - {
2041   - $retorno .= "<option id=\"{$nome}_".urlencode($chave)."\" value=\"".urlencode($chave)."\"";
2042   - if ($chave == $componente[4])
2043   - $retorno .= " selected";
2044   - $retorno .= ">$texto</option>";
2045   - }
2046   - $retorno .= "</select>";
2047   - if($componente[14])
2048   - $foiDuplo = true;
2049   -
2050   - break;
2051   - }
2052   - //$arr_campos[$nome] = array( "listaativarpeso", $campo, "/[^ ]/", $valor, $default, $ativado, "", $colunas, $tamanho );
2053   - case "listaativarpeso" :
2054   - {
2055   - $retorno .= "<input type='checkbox' ";
2056   - $retorno .= ($componente[5]) ? "checked" : "";
2057   - $retorno .= " name='{$nome_chk}' onclick='ativaCampo(\"{$nome}\")'>&nbsp;&nbsp;<select ";
2058   - $retorno .= ($componente[5]) ? "" : "disabled";
2059   - $retorno .= " class='{$class}' name='{$nome}_lst' id='{$nome}_lst'>";
2060   - reset( $componente[3] );
2061   -
2062   - while (list( $chave, $texto ) = each( $componente[3] ))
2063   - {
2064   - $retorno .= "<option id=\"{$nome}_".urlencode($chave)."\" value=\"".urlencode($chave)."\"";
2065   - if ($chave == $componente[4])
2066   - $retorno .= " selected";
2067   - $retorno .= ">$texto</option>";
2068   - }
2069   - $retorno .= "</select> &nbsp;&nbsp; <input ";
2070   - $retorno .= ($componente[5]) ? "" : "disabled";
2071   - $retorno .= " name='{$nome}_val' id='{$nome}_val' type='text' size='{$componente[7]}' maxlength='{$componente[8]}' value={$componente[9]}>";
2072   - break;
2073   - }
2074   - case "listaativarpesoselect" :
2075   - {
2076   - //
2077   - $retorno .= "<input type='checkbox' ";
2078   - $retorno .= ($componente[5]) ? "checked" : "";
2079   - $retorno .= " name='{$nome_chk}' onclick='ativaCampo(\"{$nome}\")'>&nbsp;&nbsp;<select ";
2080   - $retorno .= ($componente[5]) ? "" : "disabled";
2081   - $retorno .= " class='{$class}' name='{$nome}_lst' id='{$nome}_lst'>";
2082   - reset( $componente[3] );
2083   -
2084   - while (list( $chave, $texto ) = each( $componente[3] ))
2085   - {
2086   - $retorno .= "<option id=\"{$nome}_".urlencode($chave)."\" value=\"".urlencode($chave)."\"";
2087   - if ($chave == $componente[4])
2088   - $retorno .= " selected";
2089   - $retorno .= ">$texto</option>";
2090   - }
2091   - $retorno .= "</select> &nbsp;&nbsp;";
2092   -
2093   - $retorno .= "<select ";
2094   - $retorno .= ($componente[5]) ? "" : "disabled";
2095   - $retorno .= " class='{$class}' name='{$nome}_val' id='{$nome}_val'>";
2096   - reset( $componente[6] );
2097   -
2098   - while (list( $chave, $texto ) = each( $componente[6] ))
2099   - {
2100   - $retorno .= "<option id=\"{$nome}_".urlencode($chave)."\" value=\"".urlencode($chave)."\"";
2101   - if ($chave == $componente[9])
2102   - $retorno .= " selected";
2103   - $retorno .= ">$texto</option>";
2104   - }
2105   - $retorno .= "</select>";
2106   - break;
2107   - }
2108   - case "listapesquisa" :
2109   - {
2110   - ////( "listapesquisa", $campo, "/[^ ]/", $valor, $default, $acao, $descricao, $caminho )
2111   - $class = ($componente[14])?"obrigatorio":"geral";
2112   - $retorno .= "<select onchange=\"{$componente[5]}\" class='{$class}' name='{$nome}' id='{$nome}' {$componente[11]}>";
2113   - reset( $componente[3] );
2114   - while (list( $chave, $texto ) = each( $componente[3] ))
2115   - {
2116   - $retorno .= "<option id=\"{$nome}_".urlencode($chave)."\" value=\"".urlencode($chave)."\"";
2117   - if ($chave == $componente[4])
2118   - $retorno .= " selected";
2119   - $retorno .= ">$texto</option>";
2120   - }
2121   - $retorno .= "</select> ";
2122   - if ( $componente[13] )
2123   - { // tem serialized campos
2124   - $retorno .= "<img src=\"imagens/lupa.png\" alt=\"Pesquisa\" border=\"0\" name='{$nome}_lupa' id='{$nome}_lupa' onclick=\"pesquisa_valores_popless('{$componente[7]}?campos={$componente[13]}', '{$nome}')\"> {$componente[8]}";
2125   - }
2126   - else
2127   - {
2128   - if($componente[12])
2129   - { // vai abrir em um div
2130   - $retorno .= "<img src=\"imagens/lupa.png\" alt=\"Pesquisa\" border=\"0\" name='{$nome}_lupa' id='{$nome}_lupa' onclick=\"pesquisa_valores_popless('{$componente[7]}', '{$nome}')\"> {$componente[8]}";
2131   - }
2132   - else
2133   - { // abre num pop-up
2134   - $retorno .= "<img id='lupa' src=\"imagens/lupa.png\" alt=\"Pesquisa\" name='{$nome}_lupa' id='{$nome}_lupa' border=\"0\" onclick=\"pesquisa_valores_f('{$componente[7]}', '{$nome}', '{$componente[9]}', '{$componente[10]}')\"> {$componente[8]}";
2135   - }
2136   - }
2137   - break;
2138   - }
2139   - case "listaDupla" :
2140   - {
2141   - $retorno .= "<select onchange=\"{$componente[5]}\" class='{$class}' name='{$nome}' id='{$nome}' {$componente[8]}>";
2142   - reset( $componente[3] );
2143   - while (list( $chave, $texto ) = each( $componente[3] ))
2144   - {
2145   - $retorno .= "<option value=\"".urlencode($chave)."\"";
2146   - if ($chave == $componente[4])
2147   - $retorno .= " selected";
2148   - $retorno .= ">$texto</option>";
2149   - }
2150   - $retorno .= "</select>";
2151   - $foiDuplo = true;
2152   - break;
2153   - }
2154   - case "arquivo":
2155   - {
2156   - $retorno .= "<input class='{$class}' name=\"{$nome}\" id=\"{$nome}\" type='file' size=\"{$componente[4]}\" value=\"{$componente[3]}\">";
2157   - if(!empty($componente[5]))
2158   - $retorno.= "&nbsp;$componente[5]";
2159   - break;
2160   - }
2161   - case "email":
2162   - {
2163   -
2164   - $retorno .= "<a href='www.google.com.br' class='linkBory'>Enviar Por Email</a>";
2165   - break;
2166   - }
2167   - case "emailDuplo" :
2168   - {
2169   - $retorno .= "<input class='{$class}' type='text' name=\"{$nome}\" id=\"{$nome}\" value=\"{$componente[3]}\" size=\"{$componente[4]}\" maxlength=\"{$componente[5]}\" onKeyUp=\"{$componente[8]}\">";
2170   - $foiDuplo = true;
2171   - break;
2172   - }
2173   -
2174   - case "radio" :
2175   - {
2176   - $primeiro = true;
2177   - reset( $componente[3] );
2178   - $retorno .= "<span onclick=\"{$componente[5]}\" >";
2179   - while (list( $chave, $texto ) = each( $componente[3] ))
2180   - {
2181   - if ($primeiro)
2182   - {
2183   - $primeiro = false;
2184   - $id = "id=\"{$nome}\"";
2185   - }
2186   - else
2187   - {
2188   - $id = "";
2189   - $retorno .= "<br>";
2190   - }
2191   - $retorno .= "<input type='radio' class='{$class}' name=\"{$nome}\" {$id} value=\"".urlencode($chave)."\"";
2192   - if ($chave == $componente[4])
2193   - {
2194   - $retorno .= " checked";
2195   - }
2196   - $retorno .= ">$texto";
2197   - }
2198   - $retorno .= "</span>";
2199   - break;
2200   - }
2201   - case "theEditor":
2202   - {
2203   - $theEditorCampo = $nome;
2204   - $theEditorForm = $this->__nome;
2205   - $theEditorValue = $componente[2];
2206   - $theEditorHeight = $componente[3];
2207   - $theEditorWidth = $componente[4];
2208   - require_once ( "include/clsEditor.inc.php" );
2209   - }
2210   - }
2211   - if ($this->erros[$nome])
2212   - $retorno .= "<br><font color=red>".$this->erros[$nome]."</font>";
2213   - if ( ! $foiDuplo )
2214   - {
2215   - $retorno .= "</span></td></tr>";
2216   - }
2217   - }
2218   - if ( $todos_inline )
2219   - {
2220   - $foiDuplo = true;
2221   - }
2222   - }
2223   -
2224   - if($this->has_tiny)
2225   - {
2226   - $retorno .= '<script language="javascript" type="text/javascript">
2227   - /* tinyMCE.init({
2228   - theme : "advanced",
2229   - width:500,
2230   - mode : "exact",
2231   - file_browser_callback : "fileBrowserCallBack",
2232   - apply_source_formatting : true,
2233   - elements : "elm1"});*/
2234   -
2235   - tinyMCE.init({
2236   - mode : "exact",
2237   - theme : "advanced",
2238   -width:500,
2239   - elements : "elm1",
2240   - plugins : "spellchecker,style,layer,table,advhr,advimage,advlink,zoom,contextmenu,paste,directionality,noneditable,visualchars,nonbreaking,xhtmlxtras,template",
2241   - theme_advanced_buttons1_add_before : "save,separator",
2242   - theme_advanced_disable : "formatselect,styleselect,date,timehelp",
2243   - theme_advanced_buttons1_add : "fontselect,fontsizeselect",
2244   - theme_advanced_buttons2_add : "separator,insertdate,inserttime,preview,separator,forecolor,backcolor",
2245   - theme_advanced_buttons2_add_before: "cut,copy,paste,pastetext,pasteword,separator,search,replace,separator",
2246   - theme_advanced_buttons3_add_before : "tablecontrols,separator",
2247   - theme_advanced_buttons3_add : "emotions,iespell,media,advhr,separator,print,separator,ltr,rtl,separator,fullscreen",
2248   - theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,spellchecker,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template",
2249   - theme_advanced_toolbar_location : "top",
2250   - theme_advanced_toolbar_align : "left",
2251   - theme_advanced_path_location : "bottom",
2252   - content_css : "/example_data/example_full.css",
2253   -
2254   - extended_valid_elements : "hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style],p[lang]",
2255   - file_browser_callback : "fileBrowserCallBack",
2256   - theme_advanced_resize_horizontal : false,
2257   - theme_advanced_resizing : true,
2258   - apply_source_formatting : true
2259   - });
2260   -
2261   -
2262   - function fileBrowserCallBack(field_name, url, type, win) {
2263   - var connector = "../../filemanager/browser.html?Connector=connectors/php/connector.php";
2264   - var enableAutoTypeSelection = false;
2265   -
2266   - var cType;
2267   - tinyfck_field = field_name;
2268   - tinyfck = win;
2269   -
2270   - switch (type) {
2271   - case "image":
2272   - cType = "Image";
2273   - break;
2274   - case "flash":
2275   - cType = "Flash";
2276   - break;
2277   - case "file":
2278   - cType = "File";
2279   - break;
2280   - }
2281   -
2282   - /*if (enableAutoTypeSelection && cType) {
2283   - connector += "&Type=" + cType;
2284   - }*/
2285   - connector += "&Type=Image";
2286   -
2287   - window.open(connector, "tinyfck", "modal,width=600,height=400");
2288   - }
2289   - </script>';
2290   - }
2291   -
2292   - return $retorno;
2293   - }
2294   -
2295   -
2296   - function MakeFormat()
2297   - {
2298   - ///*******setar foco do campo
2299   - //$onload = ($this->campoFoco != false) ? "if(document.body.onload)document.body.onload=setFocus(\"{$this->campoFoco}\");" : "if(document.body.onload)document.body.onload=setFocus();" ;
2300   -
2301   - //*******
2302   -
2303   - $ret = " \n{$onload} \n
2304   - function CarregaDetalhe(id_div, endereco)
2305   - {
2306   - var elemento_div = document.getElementById(id_div);
2307   - if(endereco != '')
2308   - {
2309   - xmlhttp.open(\"GET\", endereco, true);
2310   - xmlhttp.onreadystatechange = function()
2311   - {
2312   - if (xmlhttp.readyState==4)
2313   - {
2314   - elemento_div.innerHTML = xmlhttp.responseText;
2315   - }
2316   - }
2317   - xmlhttp.send(null);
2318   - }
2319   - }
2320   -
2321   - function AbreFecha(id_div, id_img)
2322   - {
2323   - var elemento_div = document.getElementById(id_div);
2324   - var elemento_img = document.getElementById(id_img);
2325   - if(!aberto)
2326   - {
2327   - elemento_div.style.overflow = 'visible';
2328   - if(goodIE)
2329   - {
2330   - elemento_div.style.height = '0px';
2331   - elemento_img.src = '".$config['urlImagens']."excluir_1.gif';
2332   - elemento_img.alt = 'Fechar';
2333   - }
2334   - else
2335   - {
2336   - elemento_div.style.height = '100%';
2337   - elemento_img.src = '".$config['urlImagens']."excluir_1.gif';
2338   - elemento_img.alt = 'Fechar';
2339   - }
2340   - }
2341   - else
2342   - {
2343   - elemento_img.src = '".$config['urlImagens']."log-info.gif';
2344   - elemento_div.style.overflow = 'hidden';
2345   - elemento_div.style.height = '1px';
2346   - elemento_img.alt = 'Visualizar detalhes';
2347   - }
2348   -
2349   - aberto = !aberto;
2350   - }
2351   -
2352   - function AdicionaItem(chave, item, nome_pai, submete)
2353   - {
2354   - var x = document.getElementById(nome_pai);
2355   - opt = document.createElement('OPTION');
2356   - opt.value = chave;
2357   - opt.selected = true;
2358   - opt.appendChild(document.createTextNode(item));
2359   - x.appendChild(opt);
2360   - if(submete)
2361   - {";
2362   - if($this->executa_submete)
2363   - $ret .= "document.".$this->__nome.".".$this->executa_submete;
2364   - $ret .= "document.$this->__nome.submit();
2365   - }
2366   - }
2367   -
2368   - function go( url )
2369   - {
2370   - document.location = url;
2371   - }
2372   -
2373   - function excluir()
2374   - {
2375   - document.$this->__nome.reset();
2376   - if (confirm('Excluir registro?'))
2377   - {
2378   - document.$this->__nome.tipoacao.value = 'Excluir';
2379   - document.$this->__nome.submit();
2380   - }
2381   - }
2382   -
2383   - function ExcluirImg()
2384   - {
2385   - document.$this->__nome.reset();
2386   - if (confirm('Excluir imagem?'))
2387   - {
2388   - document.$this->__nome.tipoacao.value = 'ExcluirImg';
2389   - document.$this->__nome.submit();
2390   - }
2391   - }
2392   - ";
2393   -
2394   - return $ret;
2395   - }
2396   -
2397   - function getCampoTexto($nome,$id = "",$valor = "",$tamanhovisivel = "",$tamanhomaximo = "",$evento = "",$disabled = "",$descricao = "",$class ="",$descricao = "")
2398   - {
2399   - $id = $id ? $id : $nome;
2400   -
2401   - if($disabled)
2402   - $disabled = "disabled='disabled'";
2403   - else
2404   - $disabled = "";
2405   -
2406   - $tamanhomaximo = $tamanhomaximo ? "maxlength=\"{$tamanhomaximo}\"" : "";
2407   -
2408   - $tamanhovisivel = $tamanhovisivel ? "size=\"{$tamanhovisivel}\"" : "";
2409   -
2410   - $class = $class ? "class=\"{$class}\"" : "";
2411   -
2412   - return "<input {$class} type='text' name=\"{$nome}\" id=\"{$id}\" value=\"{$valor}\" {$tamanhovisivel} {$tamanhomaximo} {$evento} {$disabled}> {$descricao}";
2413   - }
2414   -
2415   - function getCampoLista($nome,$id = "",$acao = "",$valor,$default,$complemento = "",$desabilitado = false,$class,$multiple = false)
2416   - {
2417   - $id = $id ? $id : $nome;
2418   -
2419   - if(is_numeric($multiple))
2420   - $multiple = " multiple='multiple' SIZE='$multiple' ";
2421   - else
2422   - $multiple = "";
2423   -
2424   - $retorno = "<select onchange=\"{$acao}\" class='{$class}' name='{$nome}' id='{$id}' {$desabilitado} $multiple>";
2425   - $opt_open = false;
2426   -
2427   - reset( $valor );
2428   -
2429   - while (list( $chave, $texto ) = each( $valor))
2430   - {
2431   - if( substr( $texto, 0, 9 ) == "optgroup:" )
2432   - {
2433   - // optgroup
2434   - if( $opt_open )
2435   - {
2436   - $retorno .= "</optgroup>";
2437   - }
2438   - $retorno .= "<optgroup label=\"" . substr( $texto, 9 ) . "\">";
2439   - }
2440   - else
2441   - {
2442   - // option normal
2443   - $retorno .= "<option id=\"{$nome}_".urlencode($chave)."\" value=\"".urlencode($chave)."\"";
2444   - if( is_array( $default ) )
2445   - {
2446   - if( $chave==$default[$adicionador_indice])
2447   - {
2448   - $retorno .= " selected";
2449   - }
2450   - }
2451   - else if ($chave == $default)
2452   - {
2453   -
2454   - $retorno .= " selected";
2455   - }
2456   - $retorno .= ">$texto</option>";
2457   - }
2458   - }
2459   - if( $opt_open )
2460   - {
2461   - $retorno .= "</optgroup>";
2462   - }
2463   - $retorno .= "</select> {$complemento}";
2464   - return $retorno;
2465   - }
2466   -
2467   - function getCampoMonetario($nome,$id="", $valor = "",$tamanhovisivel,$tamanhomaximo,$disabled = false, $descricao = "", $descricao2 = "", $class, $evento = "onChange",$script = "")
2468   - {
2469   - $id = $id ? $id : $nome;
2470   -
2471   - if($disabled)
2472   - $disabled = "disabled='disabled'";
2473   - else
2474   - $disabled = "";
2475   -
2476   - if(!$descricao)
2477   - $descricao = $descricao2;
2478   -
2479   - return "<input style='text-align:right' onKeyup=\"formataMonetario(this, event);\" $evento = \"{$script}\" class='{$class}' type='text' name=\"{$nome}\" id=\"{$id}\" value=\"{$valor}\" size=\"{$tamanhovisivel}\" maxlength=\"{$tamanhomaximo}\" {$disabled}> {$descricao}";
2480   -
2481   - }
2482   -
2483   - function getCampoHora($nome,$id="",$valor="",$class,$tamanhovisivel,$tamanhomaximo,$acao="",$descricao="")
2484   - {
2485   - $id = $id ? $id : $nome;
2486   - $valor = strlen( $valor ) < 6 ? $valor : substr($valor,0,5);
2487   - return "<input onKeyPress=\"formataHora(this, event);\" class='{$class}' type='text' name=\"{$nome}\" id=\"{$id}\" value=\"{$valor}\" size=\"{$tamanhovisivel}\" maxlength=\"{$tamanhomaximo}\" $acao>{$descricao}";
2488   - }
2489   -
2490   - function getCampoRotulo($valor)
2491   - {
2492   -
2493   - return "<span class=\"form\"> $valor</span>";
2494   -
2495   - }
2496   -
2497   - function getCampoCheck($nome,$id = "", $valor, $desc = "", $script = false, $disable = false)
2498   - {
2499   - $id = $id ? $id : $nome;
2500   -
2501   - $onClick = "";
2502   - if( $script )
2503   - {
2504   - $onClick = "onclick=\"{$script}\"";
2505   - }
2506   - if($disabled)
2507   - $disabled = "disabled='disabled'";
2508   - else
2509   - $disabled = "";
2510   -
2511   - $retorno = "<input type='checkbox' name=\"{$nome}\" id=\"{$id}\" {$onClick}";
2512   - if ($valor)
2513   - {
2514   - $retorno .= " checked";
2515   - }
2516   - $retorno .= " {$disabled}> {$desc}";
2517   -
2518   - return $retorno;
2519   - }
2520   -
2521   - function getCampoCNPJ($nome,$id = "", $valor, $class,$tamanhovisivel,$tamanhomaximo)
2522   - {
2523   - $id = $id ? $id : $nome;
2524   -
2525   - return "<input onKeyPress=\"formataCNPJ(this, event);\" class='{$class}' type='text' name=\"{$nome}\" id=\"{$id}\" value=\"{$valor}\" size=\"{$tamanhovisivel}\" maxlength=\"{$tamanhomaximo}\">";
2526   -
2527   - }
2528   -
2529   - function getCampoCPF($nome,$id = "", $valor, $class,$tamanhovisivel,$tamanhomaximo, $disabled = false)
2530   - {
2531   - $id = $id ? $id : $nome;
2532   -
2533   - if($disabled)
2534   - $disabled = "disabled='disabled'";
2535   - else
2536   - $disabled = "";
2537   -
2538   - return "<input onKeyPress=\"formataCPF(this, event);\" class='{$class}' type='text' name=\"{$nome}\" id=\"{$id}\" value=\"{$valor}\" size=\"{$tamanhovisivel}\" maxlength=\"{$tamanhomaximo}\" $disabled>";
2539   -
2540   - }
2541   -
2542   - function getCampoIdFederal($nome,$id = "", $valor, $class,$tamanhovisivel,$tamanhomaximo,$disabled = false)
2543   - {
2544   - $id = $id ? $id : $nome;
  2341 + reset($componente[3]);
2545 2342  
2546   - if($disabled)
2547   - $disabled = "disabled='disabled'";
2548   - else
2549   - $disabled = "";
  2343 + while (list($chave, $texto) = each($componente[3])) {
  2344 + $retorno .= "<option id=\"{$nome}_".urlencode($chave)."\" value=\"".urlencode($chave)."\"";
  2345 +
  2346 + if ($chave == $componente[4]) {
  2347 + $retorno .= " selected";
  2348 + }
2550 2349  
2551   - return "<input onkeyPress=\"formataIdFederal(this,event);\" class='{$class}' type='text' name=\"{$nome}\" id=\"{$id}\" value=\"{$valor}\" size=\"{$tamanhovisivel}\" maxlength=\"{$tamanhomaximo}\" {$disabled}>";
  2350 + $retorno .= ">$texto</option>";
  2351 + }
  2352 +
  2353 + $retorno .= "</select> &nbsp;&nbsp; <input ";
  2354 +
  2355 + $retorno .= ($componente[5]) ?
  2356 + '' : 'disabled';
2552 2357  
2553   - }
  2358 + $retorno .= " name='{$nome}_val' id='{$nome}_val' type='text' size='{$componente[7]}' maxlength='{$componente[8]}' value={$componente[9]}>";
  2359 + break;
2554 2360  
2555   - function getCampoOculto($nome,$valor,$id = "")
2556   - {
2557   - $id = $id ? $id : $nome;
2558   - if($valor)
2559   - $valor = urlencode($valor);
2560   - return "<input name='$nome' id='$id' type='hidden' value='{$valor}'>\n";
  2361 + case "listaativarpesoselect" :
  2362 + $retorno .= "<input type='checkbox' ";
  2363 + $retorno .= ($componente[5]) ? "checked" : "";
  2364 + $retorno .= " name='{$nome_chk}' onclick='ativaCampo(\"{$nome}\")'>&nbsp;&nbsp;<select ";
  2365 + $retorno .= ($componente[5]) ? "" : "disabled";
  2366 + $retorno .= " class='{$class}' name='{$nome}_lst' id='{$nome}_lst'>";
2561 2367  
2562   - }
  2368 + reset($componente[3]);
2563 2369  
2564   - function getCampoData($nome,$id = "", $valor, $class,$tamanhovisivel,$tamanhomaximo,$disabled = false)
2565   - {
  2370 + while (list($chave, $texto) = each($componente[3])) {
  2371 + $retorno .= "<option id=\"{$nome}_".urlencode($chave)."\" value=\"".urlencode($chave)."\"";
2566 2372  
2567   - if($disabled)
2568   - $disabled = "disabled='disabled'";
2569   - else
2570   - $disabled = "";
2571   - $id = $id ? $id : $nome;
  2373 + if ($chave == $componente[4]) {
  2374 + $retorno .= " selected";
  2375 + }
2572 2376  
2573   - return "<input onKeyPress=\"formataData(this, event);\" class='{$class}' type='text' name=\"{$nome}\" id=\"{$id}\" value=\"{$valor}\" size=\"{$tamanhovisivel}\" maxlength=\"{$tamanhomaximo}\" {$disabled}> \n";
  2377 + $retorno .= ">$texto</option>";
  2378 + }
2574 2379  
2575   - }
  2380 + $retorno .= "</select> &nbsp;&nbsp;";
  2381 + $retorno .= "<select ";
2576 2382  
2577   - function getCampoCep($nome,$id = "", $valor, $class,$tamanhovisivel,$tamanhomaximo,$disabled = false,$descricao = '')
2578   - {
  2383 + $retorno .= ($componente[5]) ?
  2384 + '' : 'disabled';
2579 2385  
2580   - if($disabled)
2581   - $disabled = "disabled='disabled'";
2582   - else
2583   - $disabled = "";
2584   - $id = $id ? $id : $nome;
  2386 + $retorno .= " class='{$class}' name='{$nome}_val' id='{$nome}_val'>";
  2387 + reset($componente[6]);
2585 2388  
2586   - return $retorno .= "<input onKeyPress=\"formataCEP(this, event);\" class='{$class}' type='text' name=\"{$nome}\" id=\"{$nome}\" value=\"{$valor}\" size=\"{$tamanhovisivel}\" maxlength=\"{$tamanhomaximo}\" {$disabled}>$descricao\n";
  2389 + while (list( $chave, $texto) = each($componente[6])) {
  2390 + $retorno .= "<option id=\"{$nome}_".urlencode($chave)."\" value=\"".urlencode($chave)."\"";
2587 2391  
2588   - }
  2392 + if ($chave == $componente[9]) {
  2393 + $retorno .= ' selected';
  2394 + }
2589 2395  
2590   - function getCampoTextoPesquisa($nome,$id = "", $valor, $class,$tamanhovisivel,$tamanhomaximo,$disabled = false,$caminho,$campos_serializados = null,$descricao = null, $script = null, $evento = null)
2591   - {
  2396 + $retorno .= ">$texto</option>";
  2397 + }
  2398 + $retorno .= "</select>";
  2399 + break;
2592 2400  
2593   - if( $disabled )
2594   - {
2595   - $disabled = "disabled";
2596   - }
2597   - else
2598   - {
2599   - $disabled = "";
2600   - }
  2401 + case "listapesquisa" :
  2402 + $class = ($componente[14]) ?
  2403 + 'obrigatorio' : 'geral';
2601 2404  
2602   - $id = $id ? $id : $nome;
  2405 + $retorno .= "<select onchange=\"{$componente[5]}\" class='{$class}' name='{$nome}' id='{$nome}' {$componente[11]}>";
  2406 + reset($componente[3]);
2603 2407  
2604   - $retorno = "<input class='{$class}' type='text' name=\"{$nome}\" id=\"{$id}\" value=\"{$valor}\" size=\"{$tamanhovisivel}\" maxlength=\"{$tamanhomaximo}\" {$evento}='{$script}' {$disabled}> ";
  2408 + while (list($chave, $texto) = each($componente[3])) {
  2409 + $retorno .= "<option id=\"{$nome}_".urlencode($chave)."\" value=\"".urlencode($chave)."\"";
2605 2410  
2606   - if ( $campos_serializados )
2607   - { // tem serialized campos
2608   - $retorno .= "<img src=\"imagens/lupa.png\" alt=\"Pesquisa\" border=\"0\" name='{$nome}_lupa' id='{$id}_lupa' onclick=\"pesquisa_valores_popless('{$caminho}?campos={$campos_serializados}', '{$nome}')\">$descricao";
2609   - }else {
2610   - $retorno .= "<img src=\"imagens/lupa.png\" alt=\"Pesquisa\" border=\"0\" onclick=\"pesquisa_valores_f('{$caminho}', '{$nome}')\"> $descricao";
2611   - }
  2411 + if ($chave == $componente[4]) {
  2412 + $retorno .= ' selected';
  2413 + }
2612 2414  
2613   - return $retorno;
2614   - }
  2415 + $retorno .= ">$texto</option>";
  2416 + }
2615 2417  
  2418 + $retorno .= '</select> ';
2616 2419  
  2420 + if ($componente[13]) {
  2421 + // Tem serialized campos
  2422 + $retorno .= "<img src=\"imagens/lupa.png\" alt=\"Pesquisa\" border=\"0\" name='{$nome}_lupa' id='{$nome}_lupa' onclick=\"pesquisa_valores_popless('{$componente[7]}?campos={$componente[13]}', '{$nome}')\"> {$componente[8]}";
  2423 + }
  2424 + else {
  2425 + if ($componente[12]) {
  2426 + // Vai abrir em um div
  2427 + $retorno .= "<img src=\"imagens/lupa.png\" alt=\"Pesquisa\" border=\"0\" name='{$nome}_lupa' id='{$nome}_lupa' onclick=\"pesquisa_valores_popless('{$componente[7]}', '{$nome}')\"> {$componente[8]}";
  2428 + }
  2429 + else {
  2430 + // Abre num pop-up
  2431 + $retorno .= "<img id='lupa' src=\"imagens/lupa.png\" alt=\"Pesquisa\" name='{$nome}_lupa' id='{$nome}_lupa' border=\"0\" onclick=\"pesquisa_valores_f('{$componente[7]}', '{$nome}', '{$componente[9]}', '{$componente[10]}')\"> {$componente[8]}";
  2432 + }
  2433 + }
  2434 + break;
  2435 +
  2436 + case 'listaDupla':
  2437 + $retorno .= "<select onchange=\"{$componente[5]}\" class='{$class}' name='{$nome}' id='{$nome}' {$componente[8]}>";
  2438 + reset($componente[3]);
  2439 +
  2440 + while (list($chave, $texto) = each($componente[3])) {
  2441 + $retorno .= "<option value=\"".urlencode($chave)."\"";
  2442 +
  2443 + if ($chave == $componente[4]) {
  2444 + $retorno .= " selected";
  2445 + }
  2446 +
  2447 + $retorno .= ">$texto</option>";
  2448 + }
  2449 +
  2450 + $retorno .= "</select>";
  2451 + $foiDuplo = TRUE;
  2452 + break;
  2453 +
  2454 + case 'arquivo':
  2455 + $retorno .= "<input class='{$class}' name=\"{$nome}\" id=\"{$nome}\" type='file' size=\"{$componente[4]}\" value=\"{$componente[3]}\">";
  2456 +
  2457 + if (! empty($componente[5])) {
  2458 + $retorno.= "&nbsp;$componente[5]";
  2459 + }
  2460 +
  2461 + break;
  2462 +
  2463 + case 'email':
  2464 + $retorno .= "<a href='www.google.com.br' class='linkBory'>Enviar Por Email</a>";
  2465 + break;
  2466 +
  2467 + case 'emailDuplo':
  2468 + $retorno .= "<input class='{$class}' type='text' name=\"{$nome}\" id=\"{$nome}\" value=\"{$componente[3]}\" size=\"{$componente[4]}\" maxlength=\"{$componente[5]}\" onKeyUp=\"{$componente[8]}\">";
  2469 + $foiDuplo = TRUE;
  2470 + break;
  2471 +
  2472 + case 'radio':
  2473 + $primeiro = TRUE;
  2474 +
  2475 + reset($componente[3]);
  2476 +
  2477 + $retorno .= "<span onclick=\"{$componente[5]}\" >";
  2478 +
  2479 + while (list($chave, $texto) = each($componente[3])) {
  2480 + if ($primeiro) {
  2481 + $primeiro = FALSE;
  2482 + $id = "id=\"{$nome}\"";
  2483 + }
  2484 + else {
  2485 + $id = '';
  2486 + $retorno .= '<br>';
  2487 + }
  2488 +
  2489 + $retorno .= "<input type='radio' class='{$class}' name=\"{$nome}\" {$id} value=\"".urlencode($chave)."\"";
  2490 + if ($chave == $componente[4]) {
  2491 + $retorno .= " checked";
  2492 + }
  2493 +
  2494 + $retorno .= ">$texto";
  2495 + }
  2496 +
  2497 + $retorno .= "</span>";
  2498 + break;
  2499 +
  2500 + case 'theEditor':
  2501 + $theEditorCampo = $nome;
  2502 + $theEditorForm = $this->__nome;
  2503 + $theEditorValue = $componente[2];
  2504 + $theEditorHeight = $componente[3];
  2505 + $theEditorWidth = $componente[4];
  2506 + require_once 'include/clsEditor.inc.php';
  2507 + break;
  2508 + } // endswitch
  2509 +
  2510 + if ($this->erros[$nome]) {
  2511 + $retorno .= "<br><font color=red>".$this->erros[$nome]."</font>";
  2512 + }
  2513 +
  2514 + if (! $foiDuplo) {
  2515 + $retorno .= "</span></td></tr>";
  2516 + }
  2517 + }
  2518 +
  2519 + if ($todos_inline) {
  2520 + $foiDuplo = TRUE;
  2521 + }
  2522 + }
  2523 +
  2524 + if ($this->has_tiny) {
  2525 + $retorno .= '
  2526 + <script language="javascript" type="text/javascript">
  2527 + tinyMCE.init({
  2528 + mode : "exact",
  2529 + theme : "advanced",
  2530 + width : 500,
  2531 + elements : "elm1",
  2532 + plugins : "spellchecker,style,layer,table,advhr,advimage,advlink,zoom,contextmenu,paste,directionality,noneditable,visualchars,nonbreaking,xhtmlxtras,template",
  2533 + theme_advanced_buttons1_add_before : "save,separator",
  2534 + theme_advanced_disable : "formatselect,styleselect,date,timehelp",
  2535 + theme_advanced_buttons1_add : "fontselect,fontsizeselect",
  2536 + theme_advanced_buttons2_add : "separator,insertdate,inserttime,preview,separator,forecolor,backcolor",
  2537 + theme_advanced_buttons2_add_before: "cut,copy,paste,pastetext,pasteword,separator,search,replace,separator",
  2538 + theme_advanced_buttons3_add_before : "tablecontrols,separator",
  2539 + theme_advanced_buttons3_add : "emotions,iespell,media,advhr,separator,print,separator,ltr,rtl,separator,fullscreen",
  2540 + theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,spellchecker,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template",
  2541 + theme_advanced_toolbar_location : "top",
  2542 + theme_advanced_toolbar_align : "left",
  2543 + theme_advanced_path_location : "bottom",
  2544 + content_css : "/example_data/example_full.css",
  2545 +
  2546 + extended_valid_elements : "hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style],p[lang]",
  2547 + file_browser_callback : "fileBrowserCallBack",
  2548 + theme_advanced_resize_horizontal : false,
  2549 + theme_advanced_resizing : true,
  2550 + apply_source_formatting : true
  2551 + });
  2552 +
  2553 + function fileBrowserCallBack(field_name, url, type, win)
  2554 + {
  2555 + var connector = "../../filemanager/browser.html?Connector=connectors/php/connector.php";
  2556 + var enableAutoTypeSelection = false;
  2557 +
  2558 + var cType;
  2559 + tinyfck_field = field_name;
  2560 + tinyfck = win;
  2561 +
  2562 + switch (type) {
  2563 + case "image":
  2564 + cType = "Image";
  2565 + break;
  2566 + case "flash":
  2567 + cType = "Flash";
  2568 + break;
  2569 + case "file":
  2570 + cType = "File";
  2571 + break;
  2572 + }
  2573 +
  2574 + connector += "&Type=Image";
  2575 +
  2576 + window.open(connector, "tinyfck", "modal,width=600,height=400");
  2577 + }
  2578 + </script>
  2579 + ';
  2580 + }
  2581 +
  2582 + return $retorno;
  2583 + }
  2584 +
  2585 + function MakeFormat()
  2586 + {
  2587 + $ret = " \n{$onload} \n
  2588 + function CarregaDetalhe(id_div, endereco)
  2589 + {
  2590 + var elemento_div = document.getElementById(id_div);
  2591 + if (endereco != '') {
  2592 + xmlhttp.open(\"GET\", endereco, true);
  2593 + xmlhttp.onreadystatechange = function()
  2594 + {
  2595 + if (xmlhttp.readyState==4) {
  2596 + elemento_div.innerHTML = xmlhttp.responseText;
  2597 + }
  2598 + }
  2599 +
  2600 + xmlhttp.send(null);
  2601 + }
  2602 + }
  2603 +
  2604 + function AbreFecha(id_div, id_img)
  2605 + {
  2606 + var elemento_div = document.getElementById(id_div);
  2607 + var elemento_img = document.getElementById(id_img);
  2608 +
  2609 + if (!aberto) {
  2610 + elemento_div.style.overflow = 'visible';
  2611 + if (goodIE) {
  2612 + elemento_div.style.height = '0px';
  2613 + elemento_img.src = '".$config['urlImagens']."excluir_1.gif';
  2614 + elemento_img.alt = 'Fechar';
  2615 + }
  2616 + else {
  2617 + elemento_div.style.height = '100%';
  2618 + elemento_img.src = '".$config['urlImagens']."excluir_1.gif';
  2619 + elemento_img.alt = 'Fechar';
  2620 + }
  2621 + }
  2622 + else {
  2623 + elemento_img.src = '".$config['urlImagens']."log-info.gif';
  2624 + elemento_div.style.overflow = 'hidden';
  2625 + elemento_div.style.height = '1px';
  2626 + elemento_img.alt = 'Visualizar detalhes';
  2627 + }
  2628 +
  2629 + aberto = !aberto;
  2630 + }
  2631 +
  2632 + function AdicionaItem(chave, item, nome_pai, submete)
  2633 + {
  2634 + var x = document.getElementById(nome_pai);
  2635 +
  2636 + opt = document.createElement('OPTION');
  2637 + opt.value = chave;
  2638 + opt.selected = true;
  2639 + opt.appendChild(document.createTextNode(item));
  2640 +
  2641 + x.appendChild(opt);
  2642 + if (submete) {
  2643 + ";
  2644 +
  2645 + if ($this->executa_submete) {
  2646 + $ret .= "
  2647 + document.".$this->__nome.".".$this->executa_submete;
  2648 + }
  2649 +
  2650 + $ret .= "
  2651 + document.$this->__nome.submit();
  2652 + }
  2653 + }
  2654 +
  2655 + function go(url)
  2656 + {
  2657 + document.location = url;
  2658 + }
  2659 +
  2660 + function excluir()
  2661 + {
  2662 + document.$this->__nome.reset();
  2663 +
  2664 + if (confirm('Excluir registro?')) {
  2665 + document.$this->__nome.tipoacao.value = 'Excluir';
  2666 + document.$this->__nome.submit();
  2667 + }
  2668 + }
  2669 +
  2670 + function ExcluirImg()
  2671 + {
  2672 + document.$this->__nome.reset();
  2673 + if (confirm('Excluir imagem?')) {
  2674 + document.$this->__nome.tipoacao.value = 'ExcluirImg';
  2675 + document.$this->__nome.submit();
  2676 + }
  2677 + }
  2678 + ";
  2679 +
  2680 + return $ret;
  2681 + }
  2682 +
  2683 + function getCampoTexto($nome, $id = '', $valor = '', $tamanhovisivel = '',
  2684 + $tamanhomaximo = '', $evento = '', $disabled = '', $descricao = '',
  2685 + $class = '', $descricao = '')
  2686 + {
  2687 + $id = $id ? $id : $nome;
  2688 +
  2689 + if ($disabled) {
  2690 + $disabled = "disabled='disabled'";
  2691 + }
  2692 + else {
  2693 + $disabled = '';
  2694 + }
  2695 +
  2696 + $tamanhomaximo = $tamanhomaximo ?
  2697 + "maxlength=\"{$tamanhomaximo}\"" : '';
  2698 +
  2699 + $tamanhovisivel = $tamanhovisivel ?
  2700 + "size=\"{$tamanhovisivel}\"" : '';
  2701 +
  2702 + $class = $class ?
  2703 + "class=\"{$class}\"" : '';
  2704 +
  2705 + return "<input {$class} type='text' name=\"{$nome}\" id=\"{$id}\" value=\"{$valor}\" {$tamanhovisivel} {$tamanhomaximo} {$evento} {$disabled}> {$descricao}";
  2706 + }
  2707 +
  2708 + function getCampoLista($nome, $id = '', $acao = '', $valor, $default,
  2709 + $complemento = '', $desabilitado = FALSE, $class, $multiple = FALSE)
  2710 + {
  2711 + $id = $id ? $id : $nome;
  2712 +
  2713 + if (is_numeric($multiple)) {
  2714 + $multiple = " multiple='multiple' SIZE='$multiple' ";
  2715 + }
  2716 + else {
  2717 + $multiple = '';
  2718 + }
  2719 +
  2720 + $retorno = "<select onchange=\"{$acao}\" class='{$class}' name='{$nome}' id='{$id}' {$desabilitado} $multiple>";
  2721 + $opt_open = FALSE;
  2722 +
  2723 + reset($valor);
  2724 +
  2725 + while (list($chave, $texto) = each($valor)) {
  2726 + if (substr($texto, 0, 9) == 'optgroup:') {
  2727 + // optgroup
  2728 + if ($opt_open) {
  2729 + $retorno .= "</optgroup>";
  2730 + }
  2731 +
  2732 + $retorno .= "<optgroup label=\"" . substr( $texto, 9 ) . "\">";
  2733 + }
  2734 + else {
  2735 + // option normal
  2736 + $retorno .= "<option id=\"{$nome}_".urlencode($chave)."\" value=\"".urlencode($chave)."\"";
  2737 +
  2738 + if (is_array($default)) {
  2739 + if ($chave == $default[$adicionador_indice]) {
  2740 + $retorno .= " selected";
  2741 + }
  2742 + }
  2743 + elseif ($chave == $default) {
  2744 + $retorno .= " selected";
  2745 + }
  2746 +
  2747 + $retorno .= ">$texto</option>";
  2748 + }
  2749 + }
  2750 +
  2751 + if ($opt_open) {
  2752 + $retorno .= '</optgroup>';
  2753 + }
  2754 +
  2755 + $retorno .= "</select> {$complemento}";
  2756 + return $retorno;
  2757 + }
  2758 +
  2759 + function getCampoMonetario($nome, $id = '', $valor = '', $tamanhovisivel,
  2760 + $tamanhomaximo, $disabled = FALSE, $descricao = '', $descricao2 = '',
  2761 + $class, $evento = 'onChange', $script = '')
  2762 + {
  2763 + $id = $id ? $id : $nome;
  2764 +
  2765 + if ($disabled) {
  2766 + $disabled = "disabled='disabled'";
  2767 + }
  2768 + else {
  2769 + $disabled = '';
  2770 + }
  2771 +
  2772 + if (! $descricao) {
  2773 + $descricao = $descricao2;
  2774 + }
  2775 +
  2776 + return "<input style='text-align:right' onKeyup=\"formataMonetario(this, event);\" $evento = \"{$script}\" class='{$class}' type='text' name=\"{$nome}\" id=\"{$id}\" value=\"{$valor}\" size=\"{$tamanhovisivel}\" maxlength=\"{$tamanhomaximo}\" {$disabled}> {$descricao}";
  2777 + }
  2778 +
  2779 + function getCampoHora($nome, $id = '', $valor = '', $class, $tamanhovisivel,
  2780 + $tamanhomaximo, $acao = '', $descricao = '')
  2781 + {
  2782 + $id = $id ? $id : $nome;
  2783 +
  2784 + $valor = strlen($valor) < 6 ? $valor : substr($valor, 0, 5);
  2785 +
  2786 + return "<input onKeyPress=\"formataHora(this, event);\" class='{$class}' type='text' name=\"{$nome}\" id=\"{$id}\" value=\"{$valor}\" size=\"{$tamanhovisivel}\" maxlength=\"{$tamanhomaximo}\" $acao>{$descricao}";
  2787 + }
  2788 +
  2789 + function getCampoRotulo($valor)
  2790 + {
  2791 + return "<span class=\"form\"> $valor</span>";
  2792 + }
  2793 +
  2794 + function getCampoCheck($nome, $id = '', $valor, $desc = '', $script = FALSE, $disable = FALSE)
  2795 + {
  2796 + $id = $id ? $id : $nome;
  2797 +
  2798 + $onClick = '';
  2799 +
  2800 + if ($script) {
  2801 + $onClick = "onclick=\"{$script}\"";
  2802 + }
  2803 +
  2804 + if ($disabled) {
  2805 + $disabled = "disabled='disabled'";
  2806 + }
  2807 + else {
  2808 + $disabled = '';
  2809 + }
  2810 +
  2811 + $retorno = "<input type='checkbox' name=\"{$nome}\" id=\"{$id}\" {$onClick}";
  2812 +
  2813 + if ($valor) {
  2814 + $retorno .= ' checked';
  2815 + }
  2816 +
  2817 + $retorno .= " {$disabled}> {$desc}";
  2818 +
  2819 + return $retorno;
  2820 + }
  2821 +
  2822 + function getCampoCNPJ($nome, $id = '', $valor, $class, $tamanhovisivel, $tamanhomaximo)
  2823 + {
  2824 + $id = $id ? $id : $nome;
  2825 +
  2826 + return "<input onKeyPress=\"formataCNPJ(this, event);\" class='{$class}' type='text' name=\"{$nome}\" id=\"{$id}\" value=\"{$valor}\" size=\"{$tamanhovisivel}\" maxlength=\"{$tamanhomaximo}\">";
  2827 + }
  2828 +
  2829 + function getCampoCPF($nome, $id = '', $valor, $class, $tamanhovisivel, $tamanhomaximo, $disabled = FALSE)
  2830 + {
  2831 + $id = $id ? $id : $nome;
  2832 +
  2833 + if ($disabled) {
  2834 + $disabled = "disabled='disabled'";
  2835 + }
  2836 + else {
  2837 + $disabled = '';
  2838 + }
  2839 +
  2840 + return "<input onKeyPress=\"formataCPF(this, event);\" class='{$class}' type='text' name=\"{$nome}\" id=\"{$id}\" value=\"{$valor}\" size=\"{$tamanhovisivel}\" maxlength=\"{$tamanhomaximo}\" $disabled>";
  2841 + }
  2842 +
  2843 + function getCampoIdFederal($nome, $id = '', $valor, $class, $tamanhovisivel,
  2844 + $tamanhomaximo, $disabled = FALSE)
  2845 + {
  2846 + $id = $id ? $id : $nome;
  2847 +
  2848 + if ($disabled) {
  2849 + $disabled = "disabled='disabled'";
  2850 + }
  2851 + else {
  2852 + $disabled = '';
  2853 + }
  2854 +
  2855 + return "<input onkeyPress=\"formataIdFederal(this,event);\" class='{$class}' type='text' name=\"{$nome}\" id=\"{$id}\" value=\"{$valor}\" size=\"{$tamanhovisivel}\" maxlength=\"{$tamanhomaximo}\" {$disabled}>";
  2856 + }
  2857 +
  2858 + function getCampoOculto($nome, $valor, $id = '')
  2859 + {
  2860 + $id = $id ? $id : $nome;
  2861 +
  2862 + if ($valor) {
  2863 + $valor = urlencode($valor);
  2864 + }
  2865 +
  2866 + return "<input name='$nome' id='$id' type='hidden' value='{$valor}'>\n";
  2867 + }
  2868 +
  2869 + function getCampoData($nome, $id = '', $valor, $class, $tamanhovisivel, $tamanhomaximo, $disabled = FALSE)
  2870 + {
  2871 + if ($disabled) {
  2872 + $disabled = "disabled='disabled'";
  2873 + }
  2874 + else {
  2875 + $disabled = '';
  2876 + }
  2877 +
  2878 + $id = $id ? $id : $nome;
  2879 +
  2880 + return "<input onKeyPress=\"formataData(this, event);\" class='{$class}' type='text' name=\"{$nome}\" id=\"{$id}\" value=\"{$valor}\" size=\"{$tamanhovisivel}\" maxlength=\"{$tamanhomaximo}\" {$disabled}> \n";
  2881 + }
  2882 +
  2883 + function getCampoCep($nome, $id = '', $valor, $class, $tamanhovisivel, $tamanhomaximo,
  2884 + $disabled = FALSE, $descricao = '')
  2885 + {
  2886 + if ($disabled) {
  2887 + $disabled = "disabled='disabled'";
  2888 + }
  2889 + else {
  2890 + $disabled = '';
  2891 + }
  2892 +
  2893 + $id = $id ? $id : $nome;
  2894 +
  2895 + return $retorno .= "<input onKeyPress=\"formataCEP(this, event);\" class='{$class}' type='text' name=\"{$nome}\" id=\"{$nome}\" value=\"{$valor}\" size=\"{$tamanhovisivel}\" maxlength=\"{$tamanhomaximo}\" {$disabled}>$descricao\n";
  2896 + }
  2897 +
  2898 + function getCampoTextoPesquisa($nome, $id = '', $valor, $class, $tamanhovisivel,
  2899 + $tamanhomaximo, $disabled = FALSE, $caminho, $campos_serializados = NULL,
  2900 + $descricao = NULL, $script = NULL, $evento = NULL)
  2901 + {
  2902 + if ($disabled) {
  2903 + $disabled = 'disabled';
  2904 + }
  2905 + else {
  2906 + $disabled = '';
  2907 + }
  2908 +
  2909 + $id = $id ? $id : $nome;
  2910 +
  2911 + $retorno = "<input class='{$class}' type='text' name=\"{$nome}\" id=\"{$id}\" value=\"{$valor}\" size=\"{$tamanhovisivel}\" maxlength=\"{$tamanhomaximo}\" {$evento}='{$script}' {$disabled}> ";
  2912 +
  2913 + if ($campos_serializados) {
  2914 + // Tem serialized campos
  2915 + $retorno .= "<img src=\"imagens/lupa.png\" alt=\"Pesquisa\" border=\"0\" name='{$nome}_lupa' id='{$id}_lupa' onclick=\"pesquisa_valores_popless('{$caminho}?campos={$campos_serializados}', '{$nome}')\">$descricao";
  2916 + }
  2917 + else {
  2918 + $retorno .= "<img src=\"imagens/lupa.png\" alt=\"Pesquisa\" border=\"0\" onclick=\"pesquisa_valores_f('{$caminho}', '{$nome}')\"> $descricao";
  2919 + }
  2920 +
  2921 + return $retorno;
  2922 + }
2617 2923 }
2618 2924  
2619 2925 class clsCampo
2620 2926 {
2621   -
2622   -}
2623   -?>
  2927 +}
2624 2928 \ No newline at end of file
... ...