From 8838ea615546a4f862ce124821aafce00a6424b0 Mon Sep 17 00:00:00 2001 From: Eriksen Costa Paixão Date: Thu, 3 Sep 2009 06:16:43 +0000 Subject: [PATCH] Refactoring para coding standards --- ieducar/intranet/include/clsCampos.inc.php | 5348 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 1 file changed, 2826 insertions(+), 2522 deletions(-) diff --git a/ieducar/intranet/include/clsCampos.inc.php b/ieducar/intranet/include/clsCampos.inc.php index 0d0f718..7641b53 100755 --- a/ieducar/intranet/include/clsCampos.inc.php +++ b/ieducar/intranet/include/clsCampos.inc.php @@ -1,2623 +1,2927 @@ + * + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) + * qualquer versão posterior. + * + * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM + * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral + * do GNU para mais detalhes. + * + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto + * com este programa; se não, escreva para a Free Software Foundation, Inc., no + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. + * + * @author Prefeitura Municipal de Itajaí + * @license http://creativecommons.org/licenses/GPL/2.0/legalcode.pt CC GNU GPL + * @package Core + * @since Classe disponível desde a versão 1.0.0 + * @version $Id$ + */ + +/** + * clsCampos class. + * + * Implementa toda a lógica necessária para criar elementos de formulário e os + * códigos HTML e Javascript necessários para o funcionamento no i-Educar. + * + * @author Prefeitura Municipal de Itajaí + * @license http://creativecommons.org/licenses/GPL/2.0/legalcode.pt CC GNU GPL + * @package Core + * @since Classe disponível desde a versão 1.0.0 + * @version $Id$ + */ class clsCampos { - var $campos = array(); - var $num_espaco = 1; - var $__nome = "formcadastro"; - var $__adicionando = false; - var $__adicionador_inline = false; - var $__blocos = 0; - var $__bloco_bt_add = false; - var $campoFoco = false; - - var $__adicionando_tabela = false; - var $__id_tabela = 1; - var $__campos_tabela = array(); - var $__cabecalho_tabela = array(); - var $__nm_tabela; - var $__titulo_tabela; - var $__largura_tabela; - var $__valores_tabela = array(array()); - var $__valores_listas_tabela = array(array()); - - var $__adicionando_tab = false; - var $__id_tab; - var $__nm_tab; - var $__tabs = array(); - var $__campos_tab = array(); - var $__id_tabbed = 1; - var $__cabecalho_tab = array(); - var $__desabilitado_tab = array(); - var $__segue_fluxo = false; - var $__sequencia_fluxo = false; - var $__sequencia_default = true; - var $__acao_enviar_abas = "acao()"; - - var $has_tiny = false; - - //var $__campo_obrigatorio = array(); - - function campoTabInicio($nome ,$largura = "", $segue_fluxo = false, $array_sequencia = null) - { - $this->__id_tab = 1; - $this->__nm_tab = $nome; - $this->__segue_fluxo = $segue_fluxo; - if(is_array($array_sequencia)) - { - $this->__sequencia_fluxo = serialize($array_sequencia); - $this->__sequencia_default = false; - } - $this->campos['tabbed_add_'.$this->__id_tabbed] = $this->__id_tabbed; - } - - function campoTabFim() - { - $this->campos['fim_tab'] = 1; - $this->campos['cabecalho_tab'] = $this->__cabecalho_tab; - $this->campos['desabilitado_tab'] = $this->__desabilitado_tab; - $this->__cabecalho_tab = array(); - $this->__id_tabbed++; - } - - function campoAdicionaTab($nome_tab, $desabilitado_tab = false) - { - if($this->__sequencia_default) - { - $this->__sequencia_fluxo = unserialize($this->__sequencia_fluxo); - $this->__sequencia_fluxo[] = $this->__id_tab; - $this->__sequencia_fluxo = serialize($this->__sequencia_fluxo); - } - $this->campos['tab_name_'.$this->__id_tab] = array('nome' => $nome_tab,'id'=>$this->__id_tab); - $this->__cabecalho_tab[] = $nome_tab; - $this->__desabilitado_tab[] = $desabilitado_tab == true ? 1 : 0; - $this->__id_tab++; - } - - - function campoTabelaInicio($nome , $titulo = "",$arr_campos = array()/*, $arr_obrigatorio = array()*/, $arr_valores = array(array()),$largura = "",$array_valores_lista = array(array())) - { - $this->__adicionando_tabela = true; - unset($this->__campos_tabela); - $this->__campos_tabela = array(); - $this->__cabecalho_tabela = $arr_campos; - $this->__nm_tabela = $nome; - $this->__valores_tabela = $arr_valores; - $this->__titulo_tabela = $titulo; - $this->__largura_tabela = $largura; - $this->__valores_listas_tabela = $array_valores_lista; - } - - function campoTabelaFim() - { - if(count($this->__campos_tabela) && is_array($this->__campos_tabela)) - { - $this->campos['tab_add_'.$this->__id_tabela][] = $this->__campos_tabela; - $this->campos['tab_add_'.$this->__id_tabela]['cabecalho'] = $this->__cabecalho_tabela; - $this->campos['tab_add_'.$this->__id_tabela]['nome'] = $this->__nm_tabela; - $this->campos['tab_add_'.$this->__id_tabela]['valores'] = $this->__valores_tabela; - $this->campos['tab_add_'.$this->__id_tabela]['titulo'] = $this->__titulo_tabela; - $this->campos['tab_add_'.$this->__id_tabela]['largura'] = $this->__largura_tabela; - $this->campos['tab_add_'.$this->__id_tabela]['valores_lista'] = $this->__valores_listas_tabela; - } - - unset($this->__cabecalho_tabela); - $this->__cabecalho_tabela = array(); - $this->__adicionando_tabela = false; - $this->__id_tabela++; - } - - - - function blocoAdicionadorBegin( $precadastrados_inline = true ) - { - $this->campos["bloco_beg_" . $this->__blocos] = array( "bloco_adicionador", "begin" ); - $this->campos["teste1"] = array( "rotulo", "teste1", "teste1", "teste1" ); - $this->campos["teste2"] = array( "rotulo", "teste2", "teste2", "teste2" ); - $this->campos["teste3"] = array( "rotulo", "teste3", "teste3", "teste3" ); - $this->campos["teste4"] = array( "rotulo", "teste4", "teste4", "teste4" ); - $this->campos["teste5"] = array( "rotulo", "teste5", "teste5", "teste5" ); - $this->__adicionador_inline = $precadastrados_inline; - } - - function blocoAdicionadorEnd() - { - $this->campos["bloco_end_" . $this->__blocos] = array( "bloco_adicionador", "end" ); - $this->__blocos++; - } - - function campoAnexarLista( $nome, $campo, $valor, $default, $valores_ja_incluidos = false, $caminho="", $acao = "", $duplo=false, $descricao="", $descricao2="" ) - { - $this->campos[$nome] = array( "anexarListaPesquisa", $campo, "", $valor, $default, $acao, $descricao, $caminho, $descricao2, $valores_ja_incluidos ); - } - - function campoAddCampos($nome, $arr_campos = array(), $arr_valores = array()) - { - $this->campos[$nome] = array("addCampos", $nome, false, $arr_campos, $arr_valores ); - } - - function campoBoolLista( $nome, $campo, $default, $val_true = "Sim", $val_false = "Não", $val_undefined = null ) - { - $valor = array(); - $valor["f"] = $val_false; - $valor["t"] = $val_true; - - if( ! is_null( $val_undefined ) ) - { - $valor[''] = $val_undefined; - } - $this->campoLista( $nome, $campo, $valor, $default ); - } - -// function campoBoolRadio( $nome, $arr_campos = array(), $arr_valores = array() ) -// { -// $this->campos[$nome] = array("addCampos", $nome, false, $arr_campos, $arr_valores ); -// } - - function campoAddForm($nome, $arr_campos = array()) - { - $this->campos["linha_{$nome}"] = array("addForm", $nome, $arr_campos ); - } - - function campoAdicionar( $nome, $campo, $valor, $default, $acao = "" , $duplo=false, $descricao="", $link, $url_janela, $largura_j, $altura_j, $obrigatorio = false, $redirecionamento="") - { - $this->campos[$nome] = array( "adicionar", $campo, $obrigatorio ? "/[^ ]/" : "", $valor, $default, $acao, $descricao, $link, $url_janela, $largura_j, $altura_j, $redirecionamento ); - } - - function campoArquivo( $nome, $campo, $valor, $tamanho, $descricao="", $tr_invisivel = false ) - { - $this->campos[$nome] = array( "arquivo", $campo, "", $valor, $tamanho, $descricao, "tr_invisivel"=>$tr_invisivel); - $this->form_enctype = " enctype='multipart/form-data'"; - } - - function campoCep( $nome, $campo, $valor, $obrigatorio = false, $hifen = "-", $descricao = false, $disable = false) - { - $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" : ""); - - if(!$this->__adicionando_tabela) - $this->campos[$nome] = $arr_componente; - else - $this->__campos_tabela[] = $arr_componente; - } - - function campoCheck( $nome, $campo, $valor, $desc = "", $duplo=false, $script = false, $disable = false) - { - $arr_componente = array( $duplo ? "checkDuplo": "check", $this->__adicionando_tabela ? $nome : $campo, false, $valor, $desc, $script, ($disable) ? "disabled" : "" ); - - if(!$this->__adicionando_tabela) - $this->campos[$nome] = $arr_componente; - else - $this->__campos_tabela[] = $arr_componente; - - } - - function campoCnpj( $nome, $campo, $valor, $obrigatorio = false) - { - $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" ); - - if(!$this->__adicionando_tabela) - $this->campos[$nome] = $arr_componente; - else - $this->__campos_tabela[] = $arr_componente; - } - - function campoCnpjPesq( $nome, $campo, $valor, $arquivo_pesquisa, $parametros_serializados = false, $obrigatorio = false ) - { - $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 ); - } - - function campoCor( $nome, $campo, $valor, $obrigatorio = false, $descricao="") - { - $this->campos[$nome] = array( "cor", $campo, $obrigatorio ? "/[^ ]/" : "", $valor, "cor", "cor", $descricao ); - } - - function campoCpf( $nome, $campo, $valor, $obrigatorio = false, $descricao = false, $disabled = false) - { - - $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); - - if(!$this->__adicionando_tabela) - $this->campos[$nome] = $arr_componente; - else - $this->__campos_tabela[] = $arr_componente; - } - - function campoIdFederal( $nome, $campo, $valor, $obrigatorio=false, $invisivel=false, $descricao=false) - { - $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); - - if(!$this->__adicionando_tabela) - $this->campos[$nome] = $arr_componente; - else - $this->__campos_tabela[] = $arr_componente; - } - - function campoData( $nome, $campo, $valor, $obrigatorio = false, $descricao="", $duplo=false, $acao="",$disabled = false ) - { - $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); - - if(!$this->__adicionando_tabela) - $this->campos[$nome] = $arr_componente; - else - $this->__campos_tabela[] = $arr_componente; - } - - function campoDetalhe( $nome, $campo, $valor, $default, $acao = "" , $duplo=false, $descricao="", $link, $url_janela, $largura_j, $altura_j, $obrigatorio = false) - { - $this->campos[$nome] = array( "detalhe", $campo, $obrigatorio ? "/[^ ]/" : "", $valor, $default, $acao, $descricao, $link, $url_janela, $largura_j, $altura_j ); - } - - function campoExterno( $nome, $campo, $valor, $tamanhovisivel, $tamanhomaximo, $caminho, $nome_caminho, $obrigatorio = false, $duplo=false, $descricao="") - { - $this->campos[$nome] = array( "textoExterno", $campo, ($obrigatorio ? "/[^ ]/" : ""), $valor, $tamanhovisivel, $tamanhomaximo, $descricao, $caminho, $nome_caminho ); - } - - function campoProcurarAdicionar( $nome, $campo, $valor, $tamanhovisivel, $tamanhomaximo, $caminho, $nome_caminho, $caminho_dest, $nome_caminho_dest ,$obrigatorio = false, $duplo=false, $descricao="") - { - $this->campos[$nome] = array( "adicionarProcurar", $campo, ($obrigatorio ? "/[^ ]/" : ""), $valor, $tamanhovisivel, $tamanhomaximo, $descricao, $caminho, $nome_caminho,$caminho_dest, $nome_caminho_dest ); - } - - function campoFone( $nome, $campo, $valor, $obrigatorio = false) - { - $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" ); - } - - function campoHora( $nome, $campo, $valor, $obrigatorio = false, $descricao="", $acao="" ) - { - $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 ); - - if(!$this->__adicionando_tabela) - $this->campos[$nome] = $arr_componente; - else - $this->__campos_tabela[] = $arr_componente; - } - - function campoLista( $nome, $campo, $valor, $default, $acao = "" , $duplo=false, $descricao="", $complemento="", $desabilitado = false, $obrigatorio = true,$multiple = false ) - { - $filtro = ""; - if( $obrigatorio ) - { - $filtro = "/[^ ]/"; - } - - $arr_componente = array( $duplo?"listaDupla":"lista", ($this->__adicionando_tabela === true? $nome : $campo), $filtro, $valor, $default, $acao, $descricao, $complemento, $desabilitado ? "disabled='disabled'" : "",$multiple ); - - if(!$this->__adicionando_tabela) - $this->campos[$nome] = $arr_componente; - else - $this->__campos_tabela[] = $arr_componente; - - } - - function campoListaDin( $nome, $campo, $valor, $default, $acao = "" , $arquivo, $campo_destino, $_GET_campos = array(), $complemento="", $desabilitado = false, $obrigatorio = true, $function_extra = "", $duplo=false ) - { - $filtro = ( $obrigatorio ) ? "/[^ ]/": ""; - $this->campos[$nome] = array( "listaDin", $campo, $filtro, $valor, $default, $acao, "", $campo_destino, $complemento, $desabilitado ? "disabled" : "", $arquivo, $nome, $_GET_campos, $function_extra, $duplo ); - } - - function campoListaAtivarPeso( $nome, $campo, $valor, $default="0", $ativado=false, $colunas="10", $tamanho="10", $default1="") - { - $this->campos[$nome] = array( "listaativarpeso", $campo, "/[^ ]/", $valor, $default, $ativado, "", $colunas, $tamanho, $default1 ); - } - - function campoListaAtivarPesoSelect( $nome, $campo, $valor, $default="0", $ativado=false,$valor2) - { - $this->campos[$nome] = array( "listaativarpesoselect", $campo, "/[^ ]/", $valor, $default, $ativado, $valor2); - } - - function campoListaPesq( $nome, $campo, $valor, $default, $caminho="", $acao = "" , $duplo=false, $descricao="", $descricao2="", $flag=null, $pag_cadastro = null, $disabled = "", $div = false, $serializedcampos = false, $obrigatorio = false ) - { - $this->campos[$nome] = array( "listapesquisa", $campo, $obrigatorio ? "/[^ ]/": "", $valor, $default, $acao, $descricao, $caminho, $descricao2, $flag, $pag_cadastro, $disabled, $div, $serializedcampos, $obrigatorio ); - } - - function campoMemo( $nome, $campo, $valor, $colunas, $linhas, $obrigatorio = false, $descricao="", $conta="", $duplo = false, $script = false, $evento = "onclick", $disabled = false ) - { - $this->campos[$nome] = array( "memo", $campo, $obrigatorio ? "/[^ ]/" : "", $valor, $colunas, $linhas, $descricao, $conta, $duplo, $evento, $script, $disabled ); - } - - function campoNumero( $nome, $campo, $valor, $tamanhovisivel, $tamanhomaximo, $obrigatorio = false, $descricao="", $descricao2 = "", $script = false, $evento = false, $duplo = false, $disabled = false ) - { - $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 ); - - if(!$this->__adicionando_tabela) - $this->campos[$nome] = $arr_componente; - else - $this->__campos_tabela[] = $arr_componente; - } - function campoMonetario( $nome, $campo, $valor, $tamanhovisivel, $tamanhomaximo, $obrigatorio = false, $descricao="", $script = "", $evento = "onChange", $disabled=false, $show_sub = true,$descricao2="", $duplo = false ) - { - $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); - - if(!$this->__adicionando_tabela) - $this->campos[$nome] = $arr_componente; - else - $this->__campos_tabela[] = $arr_componente; - - } - - function campoOculto( $nome, $valor ) - { - $arr_componente = array( "oculto", $nome, "", $valor ); - - if(!$this->__adicionando_tabela) - $this->campos[$nome] = $arr_componente; - else - $this->__campos_tabela['oculto'][] = $arr_componente; - } - - function campoRadio( $nome, $campo, $valor, $default, $acao = "", $descricao="" ) - { - $this->campos[$nome] = array( "radio", $campo, "", $valor, $default, $acao, $descricao ); - } - - function campoRotulo( $nome, $campo, $valor, $duplo = false, $descricao="", $separador = ":" ) - { - $arr_componente = array( $duplo ? "rotuloDuplo":"rotulo", $this->__adicionando_tabela ? $nome : $campo, "", $valor, 6=>$descricao, "separador"=>$separador ); - - if(!$this->__adicionando_tabela) - $this->campos[$nome] = $arr_componente; - else - $this->__campos_tabela[] = $arr_componente; - } - - function campoSenha( $nome, $campo, $valor, $obrigatorio = false, $descricao="" ) - { - $this->campos[$nome] = array( "senha", $campo, $obrigatorio ? "/[^ ]/" : "", $valor, 10, 100, $descricao ); - } - - function campoTexto( $nome, $campo, $valor, $tamanhovisivel, $tamanhomaximo, $obrigatorio = false, $expressao = false, $duplo=false, $descricao="", $descricao2 = "", $script="", $evento = "onKeyUp", $disabled=false ) - { - - $arr_componente = array( $duplo ? "textoDuplo":"texto", $this->__adicionando_tabela ? $nome : $campo, $expressao ? $expressao :( $obrigatorio ? "/[^ ]/" : ""), $valor, $tamanhovisivel, $tamanhomaximo, $descricao, $descricao2, $script, $evento, $disabled ); - - if(!$this->__adicionando_tabela) - $this->campos[$nome] = $arr_componente; - else - $this->__campos_tabela[] = $arr_componente; - } - - function campoEmail( $nome, $campo, $valor, $tamanhovisivel, $tamanhomaximo, $obrigatorio = false, $expressao = false, $duplo=false, $descricao="", $descricao2 = "", $script="") - { - $this->campos[$nome] = array( $duplo ? "emailDuplo":"email", $campo, $expressao ? $expressao :( $obrigatorio ? "/^[a-z_\-\.0-9]+$/" : ""), $valor, $tamanhovisivel, $tamanhomaximo, $descricao, $descricao2, $script ); - } - - function campoSuggest( $nome, $campo, $valor, $obrigatorio = false, $expressao = false, $duplo=false, $descricao="", $arquivo = "xml_pessoas.php" ) - { - $this->campos[$nome] = array( "suggest", $campo, $expressao ? $expressao :( $obrigatorio ? "/[^ ]/" : ""), $valor, $descricao, $descricao2 ); - } - - function campoTextoPesquisa( $nome, $campo, $valor, $tamanhovisivel, $tamanhomaximo, $obrigatorio = false, $caminho = "", $expressao = false, $duplo=false, $descricao="", $descricao2 = "", $serializedcampos = null, $disabled = false, $script="", $evento = "onChange") - { - $arr_componente = array( $duplo ? "textoPesquisaDuplo":"textoPesquisa", $this->__adicionando_tabela ? $nome : $campo, $expressao ? $expressao :( $obrigatorio ? "/[^ ]/" : ""), $valor, $tamanhovisivel, $tamanhomaximo, $descricao, $descricao2, $caminho, $serializedcampos, $disabled, $script, $evento ); - - if(!$this->__adicionando_tabela) - $this->campos[$nome] = $arr_componente; - else - $this->__campos_tabela[] = $arr_componente; - } - - function campoTextoInv( $nome, $campo, $valor, $tamanhovisivel, $tamanhomaximo, $obrigatorio = false, $expressao = false, $duplo=false, $descricao="",$descricao2="", $script = "", $evento = "onKeyUp",$name = "") - { - $name = $name ? $name : $nome; - $this->campos[$nome] = array( $duplo ? "textoDuploInv":"textoInv", $campo, $expressao ? $expressao :( $obrigatorio ? "/[^ ]/" : ""), $valor, $tamanhovisivel, $tamanhomaximo, $descricao,$descricao2, $script, $evento,$name ); - } - - function campoTheEditor ( $nome, $campo, $valor, $largura, $altura ) - { - $this->campos[$nome] = array( "theEditor", $campo, $valor, $largura, $altura ); - } - - function campoQuebra() - { - $this->campos["espaco".$this->num_espaco] = array( "espaco", "", "", "", "", "", "", "" ); - $this->num_espaco++; - } - - function campoQuebra2($cor = "#000000", $altura = 2) - { - $this->campos["linha_preta".$this->num_espaco] = array( "linha_preta", "cor"=>$cor, "altura"=>$altura, "", "", "", "", "" ); - $this->num_espaco++; - } - - function setFocus($campo) - { - $this->campoFoco = $campo; - } - - function campoTiny( $id, $valor, $obrigatorio = false) - { - - $this->campos['0'] = array( "tiny","",false, $valor,$obrigatorio); - } - - function MakeCampos( $array_campos = null, $adicionador_indice = null, $todos_inline = false, $todos_disabled = false, $junta_linhas = false, $start_md = null ) - { - - $retorno = ""; - $gerou_script = false; - - if( ! $arr_campos ) - { - $arr_campos = $this->campos; - } - reset( $arr_campos ); - $campo_anterior = ""; - $md = true; - if( ! is_null( $start_md ) && is_bool( $start_md ) ) - { - $md = $start_md; - } - $foiDuplo = $junta_linhas; - $adicionador_total_valores = 5; // marca quantos valores foram passados para o prenchimento das repeticoes - - $javascript .= " - function tabela(name,counter) - { - //seta variavel para nao reordenar id dos campos - this.setReordena = function(reordenar) - { - this.reordenar = reordenar; - } - - this.constructor = function(){ - - var This = this; - - this.id = counter; - this.afterAddRow = function(){}; - this.afterRemoveRow = function(){}; - this.isIE = (navigator.appName.indexOf('Microsoft')!= -1) ? 1:0 - this.nome = name; - this.campos = new Array(); - this.reordenar = true; - - this.getId = function(){ return this.id;} - - - var numColumns = document.getElementById(This.nome).rows[1].childNodes.length; - - var row = document.getElementById(This.nome).insertRow(document.getElementById(This.nome).rows.length-1); - - for(var ct=0;ct__id_tab = 1; + $this->__nm_tab = $nome; + $this->__segue_fluxo = $segue_fluxo; + + if (is_array($array_sequencia)) { + $this->__sequencia_fluxo = serialize($array_sequencia); + $this->__sequencia_default = FALSE; + } + + $this->campos['tabbed_add_' . $this->__id_tabbed] = $this->__id_tabbed; + } + + function campoTabFim() + { + $this->campos['fim_tab'] = 1; + $this->campos['cabecalho_tab'] = $this->__cabecalho_tab; + $this->campos['desabilitado_tab'] = $this->__desabilitado_tab; + $this->__cabecalho_tab = array(); + $this->__id_tabbed++; + } + + function campoAdicionaTab($nome_tab, $desabilitado_tab = FALSE) + { + if($this->__sequencia_default) { + $this->__sequencia_fluxo = unserialize($this->__sequencia_fluxo); + $this->__sequencia_fluxo[] = $this->__id_tab; + $this->__sequencia_fluxo = serialize($this->__sequencia_fluxo); + } + + $this->campos['tab_name_' . $this->__id_tab] = array( + 'nome' => $nome_tab, + 'id' => $this->__id_tab + ); + + $this->__cabecalho_tab[] = $nome_tab; + $this->__desabilitado_tab[] = $desabilitado_tab == TRUE ? 1 : 0; + $this->__id_tab++; + } + + function campoTabelaInicio($nome , $titulo = '', $arr_campos = array(), + $arr_valores = array(array()), $largura = '', $array_valores_lista = array(array())) + { + $this->__adicionando_tabela = TRUE; + + unset($this->__campos_tabela); + + $this->__campos_tabela = array(); + $this->__cabecalho_tabela = $arr_campos; + $this->__nm_tabela = $nome; + $this->__valores_tabela = $arr_valores; + $this->__titulo_tabela = $titulo; + $this->__largura_tabela = $largura; + $this->__valores_listas_tabela = $array_valores_lista; + } + + function campoTabelaFim() + { + if (count($this->__campos_tabela) && is_array($this->__campos_tabela)) + { + $this->campos['tab_add_' . $this->__id_tabela][] = $this->__campos_tabela; + $this->campos['tab_add_' . $this->__id_tabela]['cabecalho'] = $this->__cabecalho_tabela; + $this->campos['tab_add_' . $this->__id_tabela]['nome'] = $this->__nm_tabela; + $this->campos['tab_add_' . $this->__id_tabela]['valores'] = $this->__valores_tabela; + $this->campos['tab_add_' . $this->__id_tabela]['titulo'] = $this->__titulo_tabela; + $this->campos['tab_add_' . $this->__id_tabela]['largura'] = $this->__largura_tabela; + $this->campos['tab_add_' . $this->__id_tabela]['valores_lista'] = $this->__valores_listas_tabela; + } + + unset($this->__cabecalho_tabela); + $this->__cabecalho_tabela = array(); + $this->__adicionando_tabela = FALSE; + $this->__id_tabela++; + } + + function blocoAdicionadorBegin($precadastrados_inline = TRUE) + { + $this->campos['bloco_beg_' . $this->__blocos] = array('bloco_adicionador', 'begin'); + + $this->campos['teste1'] = array('rotulo', 'teste1', 'teste1', 'teste1'); + $this->campos['teste2'] = array('rotulo', 'teste2', 'teste2', 'teste2'); + $this->campos['teste3'] = array('rotulo', 'teste3', 'teste3', 'teste3'); + $this->campos['teste4'] = array('rotulo', 'teste4', 'teste4', 'teste4'); + $this->campos['teste5'] = array('rotulo', 'teste5', 'teste5', 'teste5'); + + $this->__adicionador_inline = $precadastrados_inline; + } + + function blocoAdicionadorEnd() + { + $this->campos['bloco_end_' . $this->__blocos] = array('bloco_adicionador', 'end'); + $this->__blocos++; + } + + function campoAnexarLista($nome, $campo, $valor, $default, + $valores_ja_incluidos = FALSE, $caminho = '', $acao = '', $duplo = FALSE, + $descricao = '', $descricao2 = '') + { + $this->campos[$nome] = array('anexarListaPesquisa', $campo, '', $valor, + $default, $acao, $descricao, $caminho, $descricao2, $valores_ja_incluidos); + } + + function campoAddCampos($nome, $arr_campos = array(), $arr_valores = array()) + { + $this->campos[$nome] = array('addCampos', $nome, FALSE, $arr_campos, $arr_valores); + } + + function campoBoolLista($nome, $campo, $default, $val_true = 'Sim', + $val_false = 'Não', $val_undefined = NULL) + { + $valor = array(); + $valor['f'] = $val_false; + $valor['t'] = $val_true; + + if (! is_null($val_undefined)) { + $valor[''] = $val_undefined; + } + $this->campoLista( $nome, $campo, $valor, $default ); + } + + function campoAddForm($nome, $arr_campos = array()) + { + $this->campos['linha_' . $nome] = array('addForm', $nome, $arr_campos); + } + + function campoAdicionar($nome, $campo, $valor, $default, $acao = '' , + $duplo = FALSE, $descricao = '', $link, $url_janela, $largura_j, + $altura_j, $obrigatorio = FALSE, $redirecionamento = '') + { + $this->campos[$nome] = array('adicionar', $campo, + $obrigatorio ? "/[^ ]/" : '', + $valor, $default, $acao, $descricao, $link, $url_janela, + $largura_j, $altura_j, $redirecionamento); + } + + function campoArquivo($nome, $campo, $valor, $tamanho, + $descricao = '', $tr_invisivel = FALSE) + { + $this->campos[$nome] = array('arquivo', $campo, '', $valor, $tamanho, + $descricao, 'tr_invisivel' => $tr_invisivel); + + $this->form_enctype = " enctype='multipart/form-data'"; + } + + function campoCep($nome, $campo, $valor, $obrigatorio = FALSE, + $hifen = '-', $descricao = FALSE, $disable = FALSE) + { + $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' : '' + ); + + if (! $this->__adicionando_tabela) { + $this->campos[$nome] = $arr_componente; + } + else { + $this->__campos_tabela[] = $arr_componente; + } + } + + function campoCheck($nome, $campo, $valor, $desc = '', $duplo = FALSE, + $script = FALSE, $disable = FALSE) + { + $arr_componente = array( + $duplo ? 'checkDuplo' : 'check', + $this->__adicionando_tabela ? $nome : $campo, + FALSE, + $valor, + $desc, + $script, + ($disable) ? 'disabled' : '' + ); + + if (! $this->__adicionando_tabela) { + $this->campos[$nome] = $arr_componente; + } + else { + $this->__campos_tabela[] = $arr_componente; + } + } + + function campoCnpj($nome, $campo, $valor, $obrigatorio = FALSE) + { + $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' + ); + + if (! $this->__adicionando_tabela) { + $this->campos[$nome] = $arr_componente; + } + else { + $this->__campos_tabela[] = $arr_componente; + } + } + + function campoCnpjPesq($nome, $campo, $valor, $arquivo_pesquisa, + $parametros_serializados = FALSE, $obrigatorio = FALSE) + { + $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 + ); + } + + function campoCor($nome, $campo, $valor, $obrigatorio = FALSE, $descricao = '') + { + $this->campos[$nome] = array( + 'cor', + $campo, + $obrigatorio ? "/[^ ]/" : '', + $valor, + 'cor', + 'cor', + $descricao + ); + } + + function campoCpf($nome, $campo, $valor, $obrigatorio = FALSE, $descricao = FALSE, $disabled = FALSE) + { + $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 + ); + + if (! $this->__adicionando_tabela) { + $this->campos[$nome] = $arr_componente; + } + else { + $this->__campos_tabela[] = $arr_componente; + } + } + + function campoIdFederal($nome, $campo, $valor, $obrigatorio = FALSE, + $invisivel = FALSE, $descricao = FALSE) + { + $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 + ); + + if (! $this->__adicionando_tabela) { + $this->campos[$nome] = $arr_componente; + } + else { + $this->__campos_tabela[] = $arr_componente; + } + } + + function campoData($nome, $campo, $valor, $obrigatorio = FALSE, $descricao = '', + $duplo = FALSE, $acao = '', $disabled = FALSE) + { + $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 + ); + + if (! $this->__adicionando_tabela) { + $this->campos[$nome] = $arr_componente; + } + else { + $this->__campos_tabela[] = $arr_componente; + } + } + + function campoDetalhe($nome, $campo, $valor, $default, $acao = '', $duplo = FALSE, + $descricao = '', $link, $url_janela, $largura_j, $altura_j, $obrigatorio = FALSE) + { + $this->campos[$nome] = array( + 'detalhe', + $campo, + $obrigatorio ? "/[^ ]/" : '', + $valor, + $default, + $acao, + $descricao, + $link, + $url_janela, + $largura_j, + $altura_j + ); + } + + function campoExterno($nome, $campo, $valor, $tamanhovisivel, $tamanhomaximo, + $caminho, $nome_caminho, $obrigatorio = FALSE, $duplo = FALSE, $descricao = '') + { + $this->campos[$nome] = array( + 'textoExterno', + $campo, + $obrigatorio ? "/[^ ]/" : '', + $valor, + $tamanhovisivel, + $tamanhomaximo, + $descricao, + $caminho, + $nome_caminho + ); + } + + function campoProcurarAdicionar($nome, $campo, $valor, $tamanhovisivel, + $tamanhomaximo, $caminho, $nome_caminho, $caminho_dest, $nome_caminho_dest, + $obrigatorio = FALSE, $duplo = FALSE, $descricao = '') + { + $this->campos[$nome] = array( + 'adicionarProcurar', + $campo, + $obrigatorio ? "/[^ ]/" : '', + $valor, + $tamanhovisivel, + $tamanhomaximo, + $descricao, + $caminho, + $nome_caminho, + $caminho_dest, + $nome_caminho_dest + ); + } + + function campoFone($nome, $campo, $valor, $obrigatorio = FALSE) + { + $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' + ); + } + + function campoHora($nome, $campo, $valor, $obrigatorio = FALSE, $descricao = '', $acao = '') + { + $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 + ); + + if (! $this->__adicionando_tabela) { + $this->campos[$nome] = $arr_componente; + } + else { + $this->__campos_tabela[] = $arr_componente; + } + } + + function campoLista($nome, $campo, $valor, $default, $acao = '', $duplo = FALSE, + $descricao = '', $complemento = '', $desabilitado = FALSE, $obrigatorio = TRUE, + $multiple = FALSE) + { + $filtro = ''; + + if ($obrigatorio) { + $filtro = "/[^ ]/"; + } + + $arr_componente = array( + $duplo ? 'listaDupla' : 'lista', + ($this->__adicionando_tabela === TRUE ? $nome : $campo), + $filtro, + $valor, + $default, + $acao, + $descricao, + $complemento, + $desabilitado ? "disabled='disabled'" : '', + $multiple + ); + + if (! $this->__adicionando_tabela) { + $this->campos[$nome] = $arr_componente; + } + else { + $this->__campos_tabela[] = $arr_componente; + } + } + + function campoListaDin($nome, $campo, $valor, $default, $acao = '', + $arquivo, $campo_destino, $_GET_campos = array(), $complemento = '', + $desabilitado = FALSE, $obrigatorio = TRUE, $function_extra = '', $duplo = FALSE) + { + $filtro = ($obrigatorio) ? "/[^ ]/": ''; + + $this->campos[$nome] = array( + 'listaDin', + $campo, + $filtro, + $valor, + $default, + $acao, + '', + $campo_destino, + $complemento, + $desabilitado ? 'disabled' : '', + $arquivo, + $nome, + $_GET_campos, + $function_extra, + $duplo + ); + } + + function campoListaAtivarPeso($nome, $campo, $valor, $default = '0', + $ativado = FALSE, $colunas = '10', $tamanho = '10', $default1 = '') + { + $this->campos[$nome] = array( + 'listaativarpeso', + $campo, + "/[^ ]/", + $valor, + $default, + $ativado, + '', + $colunas, + $tamanho, + $default1 + ); + } + + function campoListaAtivarPesoSelect($nome, $campo, $valor, $default = '0', + $ativado = FALSE, $valor2) + { + $this->campos[$nome] = array( + 'listaativarpesoselect', + $campo, + "/[^ ]/", + $valor, + $default, + $ativado, + $valor2 + ); + } + + function campoListaPesq($nome, $campo, $valor, $default, $caminho = '', $acao = '', + $duplo = FALSE, $descricao = '', $descricao2 = '', $flag = NULL, $pag_cadastro = NULL, + $disabled = '', $div = FALSE, $serializedcampos = FALSE, $obrigatorio = FALSE) + { + $this->campos[$nome] = array( + 'listapesquisa', + $campo, + $obrigatorio ? "/[^ ]/": '', + $valor, + $default, + $acao, + $descricao, + $caminho, + $descricao2, + $flag, + $pag_cadastro, + $disabled, + $div, + $serializedcampos, + $obrigatorio + ); + } + + function campoMemo($nome, $campo, $valor, $colunas, $linhas, $obrigatorio = FALSE, + $descricao = '', $conta = '', $duplo = FALSE, $script = FALSE, $evento = 'onclick', $disabled = FALSE) + { + $this->campos[$nome] = array( + 'memo', + $campo, + $obrigatorio ? "/[^ ]/" : '', + $valor, + $colunas, + $linhas, + $descricao, + $conta, + $duplo, + $evento, + $script, + $disabled + ); + } + + function campoNumero($nome, $campo, $valor, $tamanhovisivel, $tamanhomaximo, + $obrigatorio = FALSE, $descricao = '', $descricao2 = '', $script = FALSE, + $evento = FALSE, $duplo = FALSE, $disabled = FALSE) + { + $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 + ); + + if (! $this->__adicionando_tabela) { + $this->campos[$nome] = $arr_componente; + } + else { + $this->__campos_tabela[] = $arr_componente; + } + } + + function campoMonetario($nome, $campo, $valor, $tamanhovisivel, $tamanhomaximo, + $obrigatorio = FALSE, $descricao = '', $script = '', $evento = 'onChange', + $disabled = FALSE, $show_sub = TRUE, $descricao2 = '', $duplo = FALSE) + { + $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 + ); + + if (! $this->__adicionando_tabela) { + $this->campos[$nome] = $arr_componente; + } + else { + $this->__campos_tabela[] = $arr_componente; + } + } + + function campoOculto($nome, $valor) + { + $arr_componente = array( + 'oculto', + $nome, + '', + $valor + ); + + if (! $this->__adicionando_tabela) { + $this->campos[$nome] = $arr_componente; + } + else { + $this->__campos_tabela['oculto'][] = $arr_componente; + } + } + + function campoRadio($nome, $campo, $valor, $default, $acao = '', $descricao = '') + { + $this->campos[$nome] = array( + 'radio', + $campo, + '', + $valor, + $default, + $acao, + $descricao + ); + } + + function campoRotulo($nome, $campo, $valor, $duplo = FALSE, $descricao = '', $separador = ':') + { + $arr_componente = array( + $duplo ? 'rotuloDuplo' : 'rotulo', + $this->__adicionando_tabela ? $nome : $campo, + '', + $valor, + 6 => $descricao, + 'separador' => $separador + ); + + if (! $this->__adicionando_tabela) { + $this->campos[$nome] = $arr_componente; + } + else { + $this->__campos_tabela[] = $arr_componente; + } + } + + function campoSenha($nome, $campo, $valor, $obrigatorio = FALSE, $descricao = '') + { + $this->campos[$nome] = array( + 'senha', + $campo, + $obrigatorio ? "/[^ ]/" : '', + $valor, + 10, + 100, + $descricao + ); + } + + function campoTexto($nome, $campo, $valor, $tamanhovisivel, $tamanhomaximo, + $obrigatorio = FALSE, $expressao = FALSE, $duplo = FALSE, $descricao = '', + $descricao2 = '', $script = '', $evento = 'onKeyUp', $disabled = FALSE) + { + $arr_componente = array( + $duplo ? 'textoDuplo' : 'texto', + $this->__adicionando_tabela ? $nome : $campo, + $expressao ? $expressao : ($obrigatorio ? "/[^ ]/" : ''), + $valor, + $tamanhovisivel, + $tamanhomaximo, + $descricao, + $descricao2, + $script, + $evento, + $disabled + ); + + if (! $this->__adicionando_tabela) { + $this->campos[$nome] = $arr_componente; + } + else { + $this->__campos_tabela[] = $arr_componente; + } + } + + function campoEmail($nome, $campo, $valor, $tamanhovisivel, $tamanhomaximo, + $obrigatorio = FALSE, $expressao = FALSE, $duplo = FALSE, $descricao = '', + $descricao2 = '', $script = '') + { + $this->campos[$nome] = array( + $duplo ? 'emailDuplo' : 'email', + $campo, + $expressao ? $expressao : ($obrigatorio ? "/^[a-z_\-\.0-9]+$/" : ''), + $valor, + $tamanhovisivel, + $tamanhomaximo, + $descricao, + $descricao2, + $script + ); + } + + function campoSuggest($nome, $campo, $valor, $obrigatorio = FALSE, $expressao = FALSE, + $duplo = FALSE, $descricao = '', $arquivo = 'xml_pessoas.php') + { + $this->campos[$nome] = array( + 'suggest', + $campo, + $expressao ? $expressao : ($obrigatorio ? "/[^ ]/" : ''), + $valor, + $descricao, + $descricao2 + ); + } + + function campoTextoPesquisa($nome, $campo, $valor, $tamanhovisivel, $tamanhomaximo, + $obrigatorio = FALSE, $caminho = '', $expressao = FALSE, $duplo = FALSE, + $descricao = '', $descricao2 = '', $serializedcampos = NULL, $disabled = FALSE, + $script = '', $evento = 'onChange') + { + $arr_componente = array( + $duplo ? 'textoPesquisaDuplo' : 'textoPesquisa', + $this->__adicionando_tabela ? $nome : $campo, + $expressao ? $expressao : ($obrigatorio ? "/[^ ]/" : ''), + $valor, + $tamanhovisivel, + $tamanhomaximo, + $descricao, + $descricao2, + $caminho, + $serializedcampos, + $disabled, + $script, + $evento + ); + + if (! $this->__adicionando_tabela) { + $this->campos[$nome] = $arr_componente; + } + else { + $this->__campos_tabela[] = $arr_componente; + } + } + + function campoTextoInv($nome, $campo, $valor, $tamanhovisivel, $tamanhomaximo, + $obrigatorio = FALSE, $expressao = FALSE, $duplo = FALSE, $descricao = '', + $descricao2 = '', $script = '', $evento = 'onKeyUp', $name = '') + { + $name = $name ? $name : $nome; + $this->campos[$nome] = array( + $duplo ? 'textoDuploInv' : 'textoInv', + $campo, + $expressao ? $expressao : ($obrigatorio ? "/[^ ]/" : ''), + $valor, + $tamanhovisivel, + $tamanhomaximo, + $descricao, + $descricao2, + $script, + $evento, + $name + ); + } + + function campoTheEditor ($nome, $campo, $valor, $largura, $altura) + { + $this->campos[$nome] = array( + 'theEditor', + $campo, + $valor, + $largura, + $altura + ); + } + + function campoQuebra() + { + $this->campos['espaco' . $this->num_espaco] = array('espaco', '', '', '', '', '', '', ''); + $this->num_espaco++; + } + + function campoQuebra2($cor = '#000000', $altura = 2) + { + $this->campos['linha_preta' . $this->num_espaco] = array( + 'linha_preta', + 'cor' => $cor, + 'altura' => $altura, + '', + '', + '', + '', + '' + ); + + $this->num_espaco++; + } + + function setFocus($campo) + { + $this->campoFoco = $campo; + } + + function campoTiny($id, $valor, $obrigatorio = FALSE) + { + $this->campos['0'] = array('tiny', '', FALSE, $valor, $obrigatorio); + } + + function MakeCampos($array_campos = NULL, $adicionador_indice = NULL, $todos_inline = FALSE, + $todos_disabled = FALSE, $junta_linhas = FALSE, $start_md = NULL) + { + $retorno = ''; + $gerou_script = FALSE; + + if (! $arr_campos) { + $arr_campos = $this->campos; + } + + reset($arr_campos); + $campo_anterior = ''; + $md = TRUE; + + if (! is_null($start_md) && is_bool($start_md)) { + $md = $start_md; + } + + $foiDuplo = $junta_linhas; + + // Marca quantos valores foram passados para o prenchimento das repetições + $adicionador_total_valores = 5; + + $javascript .= " + function tabela(name, counter) + { + // Seta variavel para não reordenar id dos campos + this.setReordena = function(reordenar) + { + this.reordenar = reordenar; + } + + // Construtor + this.constructor = function() { + + // Contém uma referência ao objeto + var This = this; + + this.id = counter; + + this.afterAddRow = function(){}; + this.afterRemoveRow = function(){}; + + this.isIE = (navigator.appName.indexOf('Microsoft') != -1) ? 1 : 0; + this.nome = name; + this.campos = new Array(); + this.reordenar = true; + + this.getId = function() { return this.id; } + + var numColumns = document.getElementById(This.nome).rows[1].childNodes.length; + + var row = document.getElementById(This.nome).insertRow(document.getElementById(This.nome).rows.length-1); + + for (var ct = 0; ct < numColumns - 1; ct++) { + var campo = document.getElementById(This.nome).rows[2].childNodes[ct].cloneNode(true); + + if (This.isIE) { + if(campo.childNodes[0].type == 'text') + campo.childNodes[0].value = ''; + else if(campo.childNodes[0].type == 'select-one') + campo.childNodes[0].value = ''; + else if(campo.childNodes[0].type == 'checkbox') + campo.childNodes[0].checked = false; + } + else { + if (campo.childNodes[1].type == 'text') + campo.childNodes[1].value = ''; + else if(campo.childNodes[1].type == 'select-one') + campo.childNodes[1].value = ''; + else if(campo.childNodes[1].type == 'checkbox') + campo.childNodes[1].checked = false; + } - var campo = document.getElementById(This.nome).rows[2].childNodes[ct].cloneNode(true); + This.campos.push(campo); + } + var campo = document.getElementById(This.nome).rows[2].childNodes[ct].cloneNode(true); + var campos_oculto = campo.getElementsByTagName('INPUT'); - if(This.isIE) - { - if(campo.childNodes[0].type == 'text') - campo.childNodes[0].value = ''; - else if(campo.childNodes[0].type == 'select-one') - campo.childNodes[0].value = ''; - else if(campo.childNodes[0].type == 'checkbox') - campo.childNodes[0].checked = false; - } - else - { - if(campo.childNodes[1].type == 'text') - campo.childNodes[1].value = ''; - else if(campo.childNodes[1].type == 'select-one') - campo.childNodes[1].value = ''; - else if(campo.childNodes[1].type == 'checkbox') - campo.childNodes[1].checked = false; - } + for (var co = 0; co < campos_oculto.length; co++) { + campos_oculto[co].id = /[a-zA-Z_-]*/.exec(campos_oculto[co].id) + '[' + This.id +']'; + campos_oculto[co].value = ''; + } - This.campos.push(campo); + This.campos.push(campo); + } - } + // Call the constructor + this.constructor(); - var campo = document.getElementById(This.nome).rows[2].childNodes[ct].cloneNode(true); + this.classe = (this.id % 2 == 0 )? 'formlttd' : 'formmdtd'; + this.addRow = function() + { + var This = this; - var campos_oculto = campo.getElementsByTagName('INPUT'); + This.classe = (This.id % 2 == 0 )? 'formmdtd' : 'formlttd'; + var numColumns = This.campos.length - for(var co=0;co + + + + + + + "; + $retorno .= ' +   + + + + + "; + $colspan = 1; + } + if ($sequencia[$index] != 0) { + $prox_id = $sequencia[$index++]*2; + $retorno .= ""; + } + else { + $retorno .= ""; + } + } + + $retorno .= "
'; + + $existe_tab_iniciada = TRUE; + continue; + } + + if (ereg("^(tab_name_[0-9]+)", $nome) === 1) { + if ($existe_tab_aberta) { + if ($this->__segue_fluxo) { + $colspan = 2; + $sequencia = unserialize($this->__sequencia_fluxo); + + if (isset($sequencia[$index - 1])) { + $prox_id = array_flip($sequencia); + $prox_id = $prox_id[$index] * 2; + + $retorno .= "
"; + } + + $existe_tab_aberta = TRUE; + $retorno .= "
"; + $retorno .= ""; + + continue; + } + + if ($nome === 'fim_tab') { + if ($existe_tab_aberta) { + if ($this->__segue_fluxo) { + $colspan = 2; + $sequencia = unserialize($this->__sequencia_fluxo); + + if (isset($sequencia[$index - 1])) { + $prox_id = array_flip($sequencia); + $prox_id = $prox_id[$index] * 2; + + $retorno .= ""; + $colspan = 1; + } + + if (! $this->__sequencia_default) { + if($sequencia[$index] != 0) { + $prox_id = $sequencia[$index] * 2; + $retorno .= ""; + } + else { + $retorno .= ""; + } + } + else { + $retorno .= ""; + } + } + + $retorno .= "
"; + } + + $retorno .= " + + + + + + "; + $retorno .= '
'; + + continue; + } + + if (ereg("^(tab_add_[0-9]+)",$nome) === 1) { + $campo_tabela = TRUE; + $javascript = ''; + + $cabecalho = $componente['cabecalho']; + $nome_tabela = $componente['nome']; + $valores = $componente['valores']; + $titulo = $componente['titulo']; + $largura = $componente['largura'] ? " width=\"{$componente['largura']}\" " : ""; + $valores_lista_tabela = $componente['valores_lista']; + $componente = array_shift($componente); + + $campos_oculto = $componente['oculto']; + unset($componente['oculto']); + + $classe = $md ? 'formlttd' : 'formmdtd'; + $md = $md ? FALSE : TRUE; + + $retorno .= ""; + $retorno .= "\n"; + + $total_campos = count($cabecalho); + $span = $total_campos + 1; + + if ($titulo) { + $retorno.= ""; + } + else { + $retorno.= ""; + } + + $retorno.= ""; + + foreach ($cabecalho as $key => $cab) { + $expressao_regular = $componente[$key][2]; + + if ($expressao_regular && substr( $expressao_regular, 0, 1 ) != "*") { + $obrigatorio = "*"; + } + else { + $obrigatorio = ''; + } + + $retorno.= ""; + } + + $retorno.= ""; + $retorno.= ""; + + $click = "$nome_add.removeRow(this);"; + + $img = "\"excluir\""; + $md2 = FALSE; + + if (! count($valores)) { + $valores[0] = ''; + } + + foreach ($valores as $key2 => $valor) { + $classe2 = $md2 ? 'formlttd' : 'formmdtd'; + $md2 = $md2 ? FALSE : TRUE; + + $retorno .= ""; + $array_valores_lista = $valores_lista_tabela[$key2]; + + foreach ($componente as $key => $campo_) { + $nome = $campo_[1]; + + if ($campo_[10]) { + $disabled = 'disabled'; + } + else { + $disabled = ''; + } + + if ($campo_[9] && $campo_[8]) { + $evento = " {$campo_[9]}=\"{$campo_[8]}\""; + } + else { + $evento = ''; + } - var trs = tab.getElementsByTagName('TR'); + $expressao_regular = $campo_[2]; - var linha = 0; + if ($expressao_regular && substr( $expressao_regular, 0, 1 ) != "*") { + $class = 'obrigatorio'; + } + else { + $class = 'geral'; + } - for(var ct=2;ctgetCampoTexto("{$nome}[{$key2}]","{$nome}[{$key2}]",$valor[$key],$campo_[4],$campo_[5],$evento,$campo_[10],"",$class,$campo_[7]); + break; - classe = (classe == 'formmdtd')? 'formlttd' : 'formmdtd'; - }*/ - } + case 'monetario': + $retorno .= $this->getCampoMonetario("{$nome}[{$key2}]","{$nome}[{$key2}]",$valor[$key],$campo_[4],$campo_[5],$campo_[9],$campo_[6],$campo_[11],$class,$campo_[8],$campo_[7]); + break; + + case 'hora': + $retorno .= $this->getCampoHora("{$nome}[{$key2}]","{$nome}[{$key2}]",$valor[$key],$class,$campo_[4],$campo_[5],"",""); + break; - //trs = tab.getElementsByTagName('TR'); - trs = document.getElementsByName('tr_'+This.nome + '[]'); - var classe = 'formmdtd'; + case 'lista': + $lista = NULL; - for(var ct=0;ctgetCampoLista("{$nome}[{$key2}]","{$nome}[$key2]",$campo_[5],$lista,$valor[$key],$campo_[7],$campo_[8],$class,$campo_[9]); + break; + + case 'rotulo': + $retorno .= $this->getCampoRotulo($campo_[3]?$campo_[3] : $valor[$key]); + break; + + case 'check' : + $retorno .= $this->getCampoCheck("{$nome}[{$key2}]","{$nome}[{$key2}]",$campo_[3]?$campo_[3] : $valor[$key],$campo_[4],$campo_[5],$campo_[6]); + break; + + case 'cnpj': + $retorno .= $this->getCampoCNPJ("{$nome}[{$key2}]","{$nome}[{$key2}]",$valor[$key],$class,$campo_[4],$campo_[5]); + break; + + case 'cpf': + $retorno .= $this->getCampoCPF("{$nome}[{$key2}]","{$nome}[{$key2}]",$valor[$key],$class,$campo_[4],$campo_[5],$campo_[8]); + break; + + case 'idfederal': + $retorno .= $this->getCampoIdFederal("{$nome}[{$key2}]","{$nome}[{$key2}]",$valor[$key],$class,$campo_[4],$campo_[5],$campo_[8]); + break; + + case 'data': + $retorno .= $this->getCampoData("{$nome}[{$key2}]","{$nome}[{$key2}]",$valor[$key],$class,$campo_[4],$campo_[5],$campo_[9]); + break; + + case 'textopesquisa': + $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]); + break; + + case 'cep': + $retorno .= $this->getCampoCep("{$nome}[{$key2}]","{$nome}[{$key2}]",$valor[$key],$class,$campo_[4],$campo_[5],$campo_[8],$campo_[7]); + break; + } + + $retorno .= ''; + $evento = ''; + } + + $retorno_oculto = ''; + + if (is_array($campos_oculto)) { + foreach ($campos_oculto as $key_oculto => $campo_oculto) { + $key_oculto = $key_oculto + sizeof($cabecalho); + + $campo_oculto[3] = $campo_oculto[3] ? + $campo_oculto[3] : $valor[$key_oculto]; + + $retorno_oculto .= $this->getCampoOculto("{$campo_oculto[1]}[{$key2}]",$campo_oculto[3],"{$campo_oculto[1]}[{$key2}]"); + } + } + + $retorno .= ""; + $img = "\"excluir\""; + $id = count($valores); + + $javascript .= " + var $nome_add = new tabela('{$nome_tabela}','{$id}');\n"; + } // endforeach. + + $retorno .= ''; + + $click = "$nome_add.addRow();"; + $img = "\"incluir\""; + $retorno .= ""; + $tt = $total_campos + 1; + $retorno .= ""; + $retorno .= ""; + + $retorno .= "
$titulo
$cab{$obrigatorio}Ação
$img$retorno_oculto
$img
"; + $retorno .= ""; + + $retorno .= ""; + continue; + } + + if ($this->__adicionando && FALSE) { + // Adiciona o campo no bloco de repetição + $adicionador_campos_repeticao[$nome] = $componente; + $adicionador_complemento_campo = "[{$adicionador_indice}]"; + $campo_valor = $componente[3][$adicionador_indice]; + } + else { + $adicionador_complemento_campo = ''; + $campo_valor = $componente[3]; + } + + $nome .= $adicionador_complemento_campo; + $expressao_regular = $componente[2]; + + if ($expressao_regular && substr($expressao_regular, 0, 1) != "*") { + $class = 'obrigatorio'; + $obrigatorio = "*"; + } + else { + $class = 'geral'; + $obrigatorio = ''; + } + + // Separador: insere uma linha preta + if ($componente[0] == 'linha_preta') { + $retorno .= ""; + continue; + } + elseif ($componente[0] == 'espaco') { + $retorno .= "
"; + continue; + } + elseif ($componente[0] == 'bloco_adicionador') { + if ($componente[1] == 'begin') { + // Flag de que estamos no meio de um bloco de adiçã + $this->__adicionando = TRUE; + + // Se for a primeira vez que cai aqui define o índice como zero, + // nas vezes subsequentes (chamadas por recursividade) o índice será + // passado na chamada da função + if (is_null($adicionador_indice)) { + $adicionador_indice = 0; + } + + // Cria um array para armazenar os campos a serem repetidos + $adicionador_campos_repeticao = array(); + + // Adiciona o campo begin no ínicio do bloco de repetição + $adicionador_campos_repeticao[$nome] = $componente; + } + else { + // Desmarca a flag de bloco de adiçã + $this->__adicionando = FALSE; + + // Adiciona o campo end no fim do bloco de repetição + $adicionador_campos_repeticao[$nome] = $componente; + + // Ainda não repetiu o bloco por tempo suficiente + $adicionador_indice++; + if ($adicionador_indice < $adicionador_total_valores) { + $retorno .= $this->MakeCampos($adicionador_campos_repeticao, + $adicionador_indice, FALSE, TRUE, TRUE, ! $md); + } + } + } + elseif ($componente[0] != 'oculto') { + $tipo = $componente[0]; + + if (! ($componente['separador'])) { + $campo = $componente[1]; + } + else { + $campo = $componente[1] . "{$componente['separador']}"; + } + + $validador = $componente[2]; + + if (($campo == $campo_anterior) && ($campo != '-:')) { + $campo = ''; + } + else { + $campo_anterior = $campo; + $tipo_anterior = $tipo; + + if (! $foiDuplo) { + $md = ! $md; + } + } + + $classe = $md ? 'formmdtd' : 'formlttd'; + + if ($campo_tabela && FALSE) { + if($componente[10] && ($componente[0] == 'textoDuploInv' + || $componente[0] =="textoInv" )) + { + $name = " name='tr_{$componente[10]}' "; + } + else { + $name = ''; + } + + $retorno .= "$campo{$obrigatorio}{$explicacao}\n"; + } + elseif (! $foiDuplo) { + if ($campo == '-:') { + if (empty($componente[3])) { + $componente[3] = renderpixel(); + } + + $explicacao = ($componente[6]) ? + "
{$componente[6]}" : ""; + + $retorno .= "$componente[3]{$explicacao}\n"; + } + else { + if ($componente[10] && ($componente[0] == "textoDuploInv" + || $componente[0] =="textoInv" )) + { + $name = " name='tr_{$componente[10]}' "; + } + else { + $name = ''; + } + + $style = ($componente['tr_invisivel']) ? + "style='visibility:collapse'" : ''; + + $explicacao = ($componente[6]) ? + "
{$componente[6]}" : ''; + + $retorno .= "$campo{$obrigatorio}{$explicacao}\n"; + } + } + elseif ($tipo) { + if ($componente[10] == TRUE) { + $explicacao = ($componente[6]) ? + "
{$componente[6]}" : ''; + + $retorno .= "$campo{$explicacao}\n"; + } + else { + $retorno .= "$campo\n"; + } + + $foiDuplo = FALSE; + } + + switch ($tipo) { + case 'tiny': + $retorno .= "
{$componente[3]}
"; + $this->has_tiny = TRUE; + break; + + case 'anexarListaPesquisa': + $inicio = 0; + $javascript = ''; + $inclusos = array(); + + $retorno .= ""; + + if (is_array($componente[9])) { + // Existem itens já incluídos, monta a lista com eles (com o botão remover ao lado) + foreach ($componente[9] as $ja_incluido) { + list($cod, $label) = $ja_incluido; + + $retorno .= ""; + $inclusos[] = $inicio; + + $inicio++; + } + } + + $inclusos[] = $inicio; + $javascript .= "\nitens_{$nome} = [" . implode( ",", $inclusos ) . "];"; + + $retorno .= "
"; + break; + + case 'rotuloDuplo': + $foiDuplo = TRUE; + case 'rotulo': + if ($campo != '-:') { + $retorno .= $componente[3]; + } + break; + + case 'cep': + $retorno .= "$componente[7]\n"; + break; + + case 'fone': + $retorno .= " \n"; + break; + + case 'data': + $retorno .= " $componente[7]\n"; + break; + + case 'dataDupla': + $retorno .= " $componente[7]"; + break; + + case 'hora': + $componente[3] = strlen( $componente[3] ) < 6 ? $componente[3]: substr($componente[3],0,5); + $retorno .= "{$componente[7]}"; + break; + + case 'cor': + $cor = empty($componente[3]) ? "ffffff" : $componente[3]; + $retorno .= " * + Alterar cor + "; + break; + + case 'mapa': + $cor = empty($componente[3]) ? "ffffff" : $componente[3]; + $retorno .= " * + Seleciona Coordenada"; + break; + + case 'adicionar': + $retorno .= " 0) CarregaDetalhe( '{$nome}_div','".$componente[8]."'+this.value); $componente[5]\" class='{$class}' name='{$nome}' id='{$nome}' >"; + reset($componente[3]); + + while (list($chave, $texto) = each($componente[3])) { + $retorno .= "