Advertisement
Jccosta

Untitled

Mar 12th, 2017
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 23.49 KB | None | 0 0
  1.     <?php
  2.  
  3.  
  4.     class BeneficiarioForm extends TPage
  5.     {
  6.  
  7.         private $form;     // formulario de Beneficiario
  8.  
  9.         /*
  10.          * metodo construtor
  11.          * Cria a pagina do formulario
  12.          */
  13.  
  14.         public function __construct()
  15.         {
  16.  
  17.             parent::__construct();
  18.  
  19.             //TPage::include_css('app/resources/formdecorator.css');    
  20.             //$html = new THtmlRenderer('app/resources/formdecorator.html');    
  21.  
  22.             // instancia um formulario
  23.             $this->form = new TQuickForm('Beneficiario');
  24.             $this->form->class = 'beneficiario';
  25.  
  26.             //$this->form->class = "formwrapper";
  27.  
  28.             // cria um rotulo para o titulo
  29.             $titulo = new TLabel('<div style="position:floatval; width: 200px;"> <b>* Campos Obrigatórios</b></div>');
  30.             $titulo->setFontFace('Arial');
  31.             $titulo->setFontColor('red');
  32.             $titulo->setFontSize(10);
  33.  
  34.             $this->form->setFormTitle("<h4><b> DADOS DO BENEFICIÁRIO");
  35.             $this->form->Style = "display:block;margin-right:auto; width:80%; font-size:14px";
  36.  
  37.  
  38.             //############# cria os campos do formulario ################
  39.  
  40.             //Dados Pessoais
  41.             $id = new THidden('id');
  42.             $nome = new TEntry('nome');
  43.             $municipio = new TEntry('municipio');
  44.             $dtNascimento = new TEntry('dtNascimento');
  45.             $cpf = new TEntry('cpf');
  46.             $matricula = new TEntry('matricula');
  47.             $rg = new TEntry('rg');
  48.             $sexo = new TCombo('sexo');
  49.             $estadoCivil = new TCombo('estadocivil');
  50.             $uniaoEstavel = new TCombo('uniaoestavel');
  51.             $nacionalidade = new TCombo('nacionalidade');
  52.             $naturalidade = new TEntry('naturalidade');
  53.             $rua = new TEntry('rua');
  54.             $numero = new TEntry('numero');
  55.             $complemento = new TEntry('complemento');
  56.             $bairro = new TEntry('bairro');
  57.             $estado = new TCombo('estado');
  58.             $cidade = new TEntry('cidade');
  59.             $cep = new TEntry('cep');        
  60.             $escolaridade = new TCombo('escolaridade');
  61.             $dtEscolaridade = new TEntry('dtescolaridade');
  62.             $dependente = new TCombo('dependente');
  63.             $qtDependente = new TEntry('qtdependente');
  64.             $celular = new TEntry('celular');
  65.             $telefone = new TEntry('telefone');
  66.             $possuiImovel = new TCombo('possuiimovel');
  67.             $tipoImovel = new TCombo('tipoImovel');
  68.             $pne = new TCombo('pne');
  69.  
  70.  
  71.  
  72.             //Dados Cônjuge
  73.             $conj_nome = new TEntry('conj_nome');
  74.             $conj_cpf = new TEntry('conj_cpf');
  75.             $conj_dtNascimento = new TEntry('conj_dtnascimento');
  76.             $conj_sexo = new TCombo('conj_sexo');
  77.             $conj_nacionalidade = new TCombo('conj_nacionalidade');
  78.             $conj_naturalidade = new TEntry('conj_naturalidade');
  79.             $conj_escolaridade = new TCombo('conj_escolaridade');
  80.             $conj_dtEscolaridade = new TEntry('conj_dtescolaridade');
  81.             $conj_email = new TEntry('conj_email');
  82.             $conj_celular = new TEntry('conj_celular');
  83.             $conj_telefone = new TEntry('conj_telefone');
  84.             $conj_pne = new TCombo('conj_pne');
  85.  
  86.             //Dados do Financiamento
  87.             $bancoFinanciamento = new TCombo('bancofinanciamento');      
  88.             $valorFinanciamento = new TEntry('valorfinanciamento');
  89.             $prazoFinanciamento = new TEntry('prazofinanciamento');    
  90.             $fgtsFinanciamento = new TCombo('fgtsfinanciamento');
  91.  
  92.             //Renda
  93.             $ocupacaoPrincipal = new TEntry('ocupacaoprincipal');
  94.             $regimeContratacao = new TEntry('regimecontratacao');
  95.             $dataInicio = new TEntry('datainicio');
  96.             $rendaBruta = new TEntry('rendabruta');
  97.             $nomeOrgao = new TEntry('nomeorgao');
  98.             $lotacao = new TEntry('lotacao');
  99.             $conj_ocupacaoPrincipal = new TEntry('conj_ocupacaoprincipal');
  100.             $conj_regimeContratacao = new TEntry('conj_regimecontratacao');
  101.             $conj_dtInicio = new TEntry('conj_dtinicio');
  102.             $conj_rendaBruta = new TEntry('conj_rendabruta');
  103.             $conj_nomeEmpresa = new TEntry('conj_nomeempresa');
  104.  
  105.  
  106.             //Patrimonio
  107.             $patrimonio = new TEntry('patrimonio');
  108.             $qtPatrimonio = new TEntry('qtpatrimonio');
  109.             $valorPatrimonio = new TEntry('valorpatrimonio');
  110.             $quitado = new TCombo('quitado');
  111.  
  112.  
  113.  
  114.  
  115.             //Dados do Login
  116.             $email = new TEntry('email');
  117.             $password = new TEntry('password');
  118.             $senhaRepete = new TEntry('senharepete');
  119.  
  120.             $situacaoProcesso = new TEntry('situacaoprocesso');
  121.  
  122.  
  123.             //mascara
  124.             $cpf->setMask('999.999.999-99');
  125.             $conj_cpf->setMask('999.999.999-99');
  126.             $celular->setMask('(99)99999-9999');
  127.             $telefone->setMask('(99)9999-9999');
  128.             $conj_celular->setMask('(99)99999-9999');
  129.             $conj_telefone->setMask('(99)9999-9999');
  130.             $valorFinanciamento->setNumericMask(2, ',', '.');
  131.             $rendaBruta->setNumericMask(2, '.', ',');
  132.             $numero->setMask('9999999');
  133.             $cep->setMask('99999-999');
  134.             $rg->setMask('999999999999999');
  135.             $cep->setMask('99999-999');
  136.             $dtNascimento->setMask('99/99/9999');
  137.             $dtEscolaridade->setMask('99/99/9999');
  138.             $conj_dtNascimento->setMask('99/99/9999');
  139.             $conj_dtEscolaridade->setMask('99/99/9999');
  140.             $conj_dtInicio->setMask('99/99/9999');
  141.             $dataInicio->setMask('99/99/9999');
  142.             $matricula->setMask('99999999');
  143.             $prazoFinanciamento->setMask('999');
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.             //############### CRIA UM VETOR COM AS OPÇÕES DO COMBO ###############
  151.  
  152.             //sexo
  153.             $items = array();
  154.             $items['MASCULINO'] = 'MASCULINO';
  155.             $items['FEMININO'] = 'FEMININO';
  156.  
  157.             //estado civil
  158.             $items1 = array();
  159.             $items1['SOLTEIRO'] = 'SOLTEIRO';
  160.             $items1['CASADO(A)'] = 'CASADO(A)';
  161.             $items1['SEPARADO'] = 'SEPARADO';
  162.             $items1['DIVORCIADO'] = 'DIVORCIADO';
  163.             $items1['VIÚVO'] = 'VIÚVO';
  164.  
  165.             //nacionalidade
  166.             $items2 = array();
  167.             $items2['BRASILEIRO'] = 'BRASILEIRO';
  168.             $items2['ESTRANGEIRO'] = 'ESTRANGEIRO';
  169.  
  170.             //sim ou não
  171.             $items3 = array();
  172.             $items3['SIM'] = 'SIM';
  173.             $items3['NÃO'] = 'NÃO';
  174.  
  175.             //tipo imóvel
  176.             $items4 = array();
  177.             $items4['APARTAMENTO'] = 'APARTAMENTO';
  178.             $items4['CASA'] = 'CASA';
  179.  
  180.             //tipo estado
  181.             $items5 = array();
  182.             $items5['AC'] = 'AC';
  183.             $items5['AL'] = 'AL';
  184.             $items5['AM'] = 'AM';
  185.             $items5['AP'] = 'AP';
  186.             $items5['BA'] = 'BA';
  187.             $items5['CE'] = 'CE';
  188.             $items5['DF'] = 'DF';
  189.             $items5['ES'] = 'ES';
  190.             $items5['GO'] = 'GO';
  191.             $items5['MA'] = 'MA';
  192.             $items5['MG'] = 'MG';
  193.             $items5['MS'] = 'MS';
  194.             $items5['MT'] = 'MT';
  195.             $items5['PA'] = 'PA';
  196.             $items5['PB'] = 'PB';
  197.             $items5['PE'] = 'PE';
  198.             $items5['PI'] = 'PI';
  199.             $items5['PR'] = 'PR';
  200.             $items5['RJ'] = 'RJ';
  201.             $items5['RN'] = 'RN';
  202.             $items5['RO'] = 'RO';
  203.             $items5['RR'] = 'RR';
  204.             $items5['RS'] = 'RS';
  205.             $items5['SC'] = 'SC';
  206.             $items5['SE'] = 'SE';
  207.             $items5['SP'] = 'SP';
  208.             $items5['TO'] = 'TO';
  209.  
  210.             //tipo banco
  211.             $items6 = array();
  212.             $items6['BANCO DO BRASIL'] = 'BANCO DO BRASIL';
  213.             $items6['CAIXA ECÔNOMICA FEDERAL'] = 'CAIXA ECONÔMICA FEDERAL';
  214.  
  215.  
  216.             $items7['1'] = '1';
  217.  
  218.  
  219.             $items8['FUNDAMENAL INCOMPLETO'] = 'FUNDAMENAL INCOMPLETO';
  220.             $items8['FUNDAMENAL COMPLETO'] = 'FUNDAMENAL COMPLETO';
  221.             $items8['MÉDIO INCOMPLETO'] = 'MÉDIO INCOMPLETO';
  222.             $items8['MÉDIO COMPLETO'] = 'MÉDIO COMPLETO';
  223.             $items8['SUPERIOR INCOMPLETO'] = 'SUPERIOR INCOMPLETO';
  224.             $items8['SUPERIOR COMPLETO'] = 'SUPERIOR COMPLETO';
  225.  
  226.             // adiciona as opcoes na combo
  227.  
  228.             //coloca o valor padrao no combo
  229.  
  230.  
  231.             //############### SELECIONA VALOR INICIAL DO COMBO ##################
  232.  
  233.             $sexo->setValue('MASCULINO');
  234.             $estadoCivil->setValue('SOLTEIRO');
  235.             $uniaoEstavel->setValue('NÃO');
  236.             $nacionalidade->setValue('BRASILEIRO');
  237.             $pne->setValue('NÃO');
  238.             $dependente->setValue('SIM');
  239.             $possuiImovel->setValue('NÃO');
  240.             $fgtsFinanciamento->setValue('SIM');
  241.             $estado->setValue('RN');
  242.             $estadoCivil->setValue('CASADO(A)');
  243.             $situacaoProcesso->setValue('1');
  244.             $escolaridade->setValue('MÉDIO COMPLETO');
  245.  
  246.  
  247.  
  248.             //############# ADICIONA VALORES AOS COMBOS ###############
  249.  
  250.             // adiciona valores item
  251.             $sexo->addItems($items);
  252.             $conj_sexo->addItems($items);
  253.  
  254.             // adiciona valores items1
  255.             $estadoCivil->addItems($items1);
  256.  
  257.             // adiciona valores items2
  258.             $nacionalidade->addItems($items2);
  259.             $conj_nacionalidade->addItems($items2);
  260.  
  261.             // adiciona items3
  262.             $possuiImovel->addItems($items3);
  263.             $uniaoEstavel->addItems($items3);
  264.             $dependente->addItems($items3);
  265.             $fgtsFinanciamento->addItems($items3);
  266.             $quitado->addItems($items3);
  267.             $pne->addItems($items3);
  268.             $conj_pne->addItems($items3);
  269.  
  270.  
  271.             //adiciona valores items4
  272.  
  273.             $tipoImovel->addItems($items4);
  274.  
  275.             //adiciona valores items5
  276.             $estado->addItems($items5);
  277.  
  278.             //adiciona valores items
  279.             $bancoFinanciamento->addItems($items6);
  280.  
  281.  
  282.             $escolaridade->addItems($items8);
  283.             $conj_escolaridade->addItems($items8);
  284.  
  285.  
  286.             // define os campos
  287.             $this->form->addQuickField(null, $titulo, 250);
  288.             $this->form->addQuickField(null, $id, 10);
  289.             $this->form->addQuickField("<font size='3'><b>Nome Completo:<font color=red><b>*</b></font></b>", $nome, 400);
  290.             $this->form->addQuickField("<font size='3'><b>CPF:<font color=red><b>*</b></font>", $cpf, 150);
  291.             $this->form->addQuickField("<font size='3'><b>Matrícula<font color=red><b>*</b></font>", $matricula, 150);
  292.             $this->form->addQuickField("<font size='3'><b>RG:<font color=red><b>*</b></font>", $rg, 150);
  293.             $this->form->addQuickField("<font size='3'><b>Data de Nascimento:<font color=red><b>*</b></font>", $dtNascimento, 150);
  294.             $this->form->addQuickField("<font size='3'><b>Sexo:<font color=red><b>*</b></font>", $sexo, 150);
  295.             $this->form->addQuickField("<font size='3'><b>Estado Civil:<font color=red><b>*</b></font>", $estadoCivil, 150);
  296.             $this->form->addQuickField("<font size='3'><b>União Estável:<font color=red><b>*</b></font>", $uniaoEstavel, 60);
  297.             $this->form->addQuickField("<font size='3'><b>Nacionalidade:<font color=red><b>*</b></font>", $nacionalidade, 150);
  298.             $this->form->addQuickField("<font size='3'><b>Naturalidade(Cidade/UF):<font color=red><b>*</b></font>", $naturalidade, 250);
  299.             $this->form->addQuickField("<font size='3'><b>Rua:<font color=red><b>*</b></font>", $rua, 300);
  300.             $this->form->addQuickField("<font size='3'><b>Número:<font color=red><b>*</b></font>", $numero, 60);
  301.             $this->form->addQuickField("<font size='3'><b>Complemento:</font>", $complemento, 200);
  302.             $this->form->addQuickField("<font size='3'><b>Bairro:<font color=red><b>*</b></font>", $bairro, 200);
  303.             $this->form->addQuickField("<font size='3'><b>Cidade:<font color=red><b>*</b></font>", $cidade, 200);
  304.             $this->form->addQuickField("<font size='3'><b>Estado:<font color=red><b>*</b></font>", $estado, 60);
  305.             $this->form->addQuickField("<font size='3'><b>CEP:<font color=red><b>*</b></font>", $cep, 200);
  306.             $this->form->addQuickField("<font size='3'><b>Escolaridade:<font color=red><b>*</b></font>", $escolaridade, 230);
  307.             $this->form->addQuickField("<font size='3'><b>Data da Conclusão da formação:<font color=red><b>*</b></font>", $dtEscolaridade, 150);
  308.             $this->form->addQuickField("<font size='3'><b>Município Onde Trabalha:<font color=red><b>*</b></font>", $municipio, 250);
  309.             $this->form->addQuickField("<font size='3'><b>Orgão/Setor:<font color=red><b>*</b></font>", $nomeOrgao, 250);
  310.             $this->form->addQuickField("<font size='3'><b>Possui Dependentes:<font color=red><b>*</b></font>", $dependente, 60);
  311.             $this->form->addQuickField("<font size='3'><b>Se sim, Quantos:<font color=red><b>*</b></font>", $qtDependente, 60);
  312.             $this->form->addQuickField("<font size='3'><b>Telefone Celular:<font color=red><b>*</b></font>", $celular, 150);
  313.             $this->form->addQuickField("<font size='3'><b>Telefone Residêncial:<font color=red><b>*</b></font>", $telefone, 150);
  314.             $this->form->addQuickField("<font size='3'><b>Possui Imóvel:<font color=red><b>*</b></font>", $possuiImovel, 60);
  315.             $this->form->addQuickField("<font size='3'><b>Se Sim, Qual:<font color=red><b>*</b></font>", $tipoImovel, 150);
  316.             $this->form->addQuickField("<font size='3'><b>Portador de Necessidades Especiais:<font color=red><b>*</b></font>", $pne, 60);
  317.  
  318.  
  319.             $this->form->setFormTitle("<br><h4><b> DADOS DO CÔNJUGUE");
  320.             $this->form->addQuickField("<font size='3'><b>Nome Completo do Cônjuge:", $conj_nome, 400);
  321.             $this->form->addQuickField("<font size='3'><b>CPF do Cônjuge:", $conj_cpf, 150);
  322.             $this->form->addQuickField("<font size='3'><b>Data de Nascimento:", $conj_dtNascimento, 150);
  323.             $this->form->addQuickField("<font size='3'><b>Sexo:", $conj_sexo, 150);
  324.             $this->form->addQuickField("<font size='3'><b>Nacionalidade:", $conj_nacionalidade, 150);
  325.             $this->form->addQuickField("<font size='3'><b>Naturalidade(Cidade/UF):", $conj_naturalidade, 250);
  326.             $this->form->addQuickField("<font size='3'><b>Escolaridade:", $conj_escolaridade, 230);        
  327.             $this->form->addQuickField("<font size='3'><b>Conclusão da Formação:", $conj_dtEscolaridade, 150);    
  328.             $this->form->addQuickField("<font size='3'><b>E-mail:", $conj_email, 250);
  329.             $this->form->addQuickField("<font size='3'><b>Celular:", $conj_celular, 150);
  330.             $this->form->addQuickField("<font size='3'><b>Telefone Residêncial:", $conj_telefone, 150);        
  331.             $this->form->addQuickField("<font size='3'><b>Portador de Necessidades Especiais:", $conj_pne, 60);
  332.  
  333.  
  334.             $this->form->setFormTitle("<br><h4><b> DADOS DO FINANCIAMENTO");
  335.             $this->form->addQuickField("<font size='3'><b>Banco:<font color=red><b>*</b></font>", $bancoFinanciamento, 250);
  336.             $this->form->addQuickField("<font size='3'><b>Valor do Financiamento:<font color=red><b>*</b></font>", $valorFinanciamento, 150);        
  337.             $this->form->addQuickField("<font size='3'><b>Prazo Pretendido:<font color=red><b>*</b></font>", $prazoFinanciamento, 60);        
  338.             $this->form->addQuickField("<font size='3'><b>Pretende Utilizar FGTS:<font color=red><b>*</b></font>", $fgtsFinanciamento, 60);
  339.  
  340.  
  341.             $this->form->setFormTitle("<br><h4><b> DADOS DA RENDA");
  342.             $this->form->addQuickField("<font size='3'><b>Ocupação Principal:<font color=red><b>*</b></font>", $ocupacaoPrincipal, 250);
  343.             $this->form->addQuickField("<font size='3'><b>Regime de Contratação:<font color=red><b>*</b></font>", $regimeContratacao, 250);
  344.             $this->form->addQuickField("<font size='3'><b>Data do Início:<font color=red><b>*</b></font>", $dataInicio, 150);
  345.             $this->form->addQuickField("<font size='3'><b>Renda Bruta:<font color=red><b>*</b></font>", $rendaBruta, 150);
  346.             $this->form->addQuickField("<font size='3'><b>Lotação(Cidade/UF):<font color=red><b>*</b></font>", $lotacao, 150);
  347.             $this->form->addQuickField("<font size='3'><b>Ocupação Cônjuge:", $conj_ocupacaoPrincipal, 200);
  348.             $this->form->addQuickField("<font size='3'><b>Regime de Contratação:", $conj_regimeContratacao, 100);
  349.             $this->form->addQuickField("<font size='3'><b>Data Início:", $conj_dtInicio, 150);
  350.             $this->form->addQuickField("<font size='3'><b>Renda Bruta:", $conj_rendaBruta, 100);
  351.             $this->form->addQuickField("<font size='3'><b>Nome da Empresa/Orgão:", $conj_nomeEmpresa, 200);
  352.  
  353.  
  354.             $this->form->setFormTitle("<br><h4><b> DADOS DO PATRIMÔNIO");
  355.             $this->form->addQuickField("<font size='3'><b>Tipo de Patrimônio:", $patrimonio, 150);
  356.             $this->form->addQuickField("<font size='3'><b>Quantidade:", $qtPatrimonio, 60);
  357.             $this->form->addQuickField("<font size='3'><b>Valor Total do Patrimônio:", $valorPatrimonio, 100);
  358.             $this->form->addQuickField("<font size='3'><b>Quitado:", $quitado, 60);
  359.  
  360.  
  361.             $this->form->setFormTitle("<br><h4><b>DADOS PARA LOGIN");
  362.             $this->form->addQuickField("<font size='3'><b>E-mail:<font color=red><b>*</b></font>", $email, 250);
  363.             $this->form->addQuickField("<font size='3'><b>Senha:<font color=red><b>*</b></font>", $password, 150);
  364.             $this->form->addQuickField("<font size='3'><b>Confirme sua Senha:<font color=red><b>*</b></font>", $senhaRepete, 150);
  365.  
  366.  
  367.             $email->addValidation('email', new TEmailValidator);
  368.             $nome->addValidation('nome', new TRequiredValidator);
  369.  
  370.             // cria um botao de acao
  371.             $this->form->addQuickAction("<font size='4'<b> Salvar ", new TAction(array($this, 'onSave')), 'ico_save.png')->class = 'btn btn-info';
  372.  
  373.  
  374.             $this->form->addQuickAction("<font size='4'<b> Voltar", new TAction(array($this, 'onBack')), 'ico_back.png')->class = 'btn btn-info';
  375.  
  376.             //$this->form->addQuickAction('Voltar', new TAction(array($this, 'Login')), 'ico_datagrid.gif');
  377.  
  378.             // adiciona a tabela a pagina
  379.             $conteiner = new TTable();
  380.            
  381.             parent::add($this->form);
  382.  
  383.  
  384.             //Validação de quantidade de caracteres
  385.             //$nome->addValidation('nome', new TMinLengthValidator, array(15));
  386.  
  387.  
  388.         }
  389.  
  390.         /*
  391.          * metodo onSave()
  392.          * Executada quando o usuario clicar no botao salvar do formulario
  393.          */
  394.  
  395.  
  396.         function onSave() {
  397.            
  398.         try {
  399.            
  400.             $o_tag = '<font style="font-size:16px">O campo <font style="color:#FF0000;font-weight:bold">';
  401.             $c_tag = '</font> deve ser preenchido!</font><br/>';
  402.  
  403.             //$this->form->validate();
  404.  
  405.             TTransaction::open('pg_cehab');
  406.            
  407.              $Beneficiario = $this->form->getData('Beneficiario');
  408.             $password = $Beneficiario->password;
  409.             //$senharepete = $Construtora->cos_senha2;
  410.  
  411.            
  412.  
  413.             $msg = '';  
  414.  
  415.  
  416.  
  417.              if ($msg == '') {
  418.                     // armazena o objeto no banco
  419.                     $Beneficiario->store();
  420.                
  421.                     ################################# cria um usuario ######################################
  422.  
  423.                     $repository = new TRepository('SystemUser');
  424.                     $criteria = new TCriteria();
  425.  
  426.                     $criteria->add(new TFilter('beneficiario_id', '=', $Beneficiario->id));
  427.  
  428.  
  429.  
  430.                         $objectSystemUSer = $repository->load($criteria);
  431.  
  432.  
  433.                     foreach ($objectSystemUSer as $obj) {
  434.                         $system_user_id = $obj->id;
  435.                     }
  436.  
  437.                     if ($system_user_id) {
  438.                         $objUser = new SystemUser($system_user_id);
  439.                     } else {
  440.                         $objUser = new SystemUser();
  441.                     }
  442.  
  443.  
  444.                  $objUser->login = $Beneficiario->email;
  445.                  $objUser->password = md5($password);
  446.                  $objUser->beneficiario_id = $Beneficiario->id;
  447.                  $objUser->name = $Beneficiario->nome;
  448.                  $objUser->email = $Beneficiario->email;
  449.                  $objUser->frontpage_id = 21;
  450.  
  451.                  $objUser->store();
  452.  
  453.                     ################################# vincula um gupo ao usuario ######################################        
  454.                    $objUserGroup = new SystemUserGroup();
  455.                     $objUserGroup->system_user_id = $objUser->id;
  456.                     $objUserGroup->system_group_id = 2;
  457.  
  458.  
  459.                     $objUserGroup->store();
  460.                     TApplication::gotoPage('EmpreendimentoList','onReload');
  461.  
  462.                     $msg = 'Dados armazenados com sucesso você receberar um email com todos os passos
  463.                    para acessar seu cadastro e verificar sua situação';
  464.                     $Beneficiario->store();
  465.                     // finaliza a transacao
  466.                     TTransaction::close();
  467.                 } else {
  468.                        $icone = 'error';
  469.                 }
  470.  
  471.                 if ($icone == 'error') {
  472.                     // exibe mensagem de erro
  473.                     new TMessage($icone, $msg);
  474.  
  475.                     $this->form->setData($Beneficiario);   // fill the form with the active record data
  476.                 } else {
  477.                     // exibe um dialogo ao usuario
  478.                     new TMessage("info", $msg);
  479.                 }
  480.             } catch (Exception $e) {
  481.              
  482.                 // em caso de exc
  483.                 // exibe a mensagem gerada pela exce��o
  484.                 new TMessage('error', $e->getMessage());
  485.  
  486.                 // desfaz todas altera��es no banco de dados
  487.                 TTransaction::rollback();
  488.                
  489.             }
  490.            $this->form->setData($Beneficiario);   // fill the form with the active record data
  491.         }
  492.  
  493.  
  494.         /*
  495.          * metodo Login()
  496.          * seta a flag de cadastro para falso e volta para o Logar
  497.          */
  498.  
  499.         function onBack() {
  500.  
  501.             TApplication::gotoPage('Empreend', ''); // Login
  502.         }
  503.  
  504.         function onEdit($param)
  505.         {
  506.  
  507.             try {
  508.  
  509.                 if (isset($param['key'])) {
  510.  
  511.                     // get the parameter $key
  512.                     $key = $param['key'];
  513.                     TTransaction::open('pg_cehab');   // open a transaction with database 'samples'
  514.                     $object = new Beneficiario($key);  // instantiates object City
  515.                     $this->form->setData($object);   // fill the form with the active record data
  516.                     TTransaction::close();           // close the transaction
  517.                 } else {
  518.  
  519.                     $this->form->clear();
  520.                 }
  521.             } catch (Exception $e) {
  522.                 // in case of exception
  523.                 // shows the exception error message
  524.                 new TMessage('error', '<b>Error</b> ' . $e->getMessage());
  525.  
  526.                 // undo all pending operations
  527.                 TTransaction::rollback();
  528.             }
  529.  
  530.     }
  531.  
  532.  
  533.  
  534.  
  535.  
  536.  
  537.  
  538.  
  539.  
  540.  
  541.  
  542.     }
  543.  
  544.  
  545.     ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement