Lançado Adianti Framework 7.6!
Clique aqui para saber mais
Fieldlist e datagrid não carregam!!! Pessoal do forum...boa noite... Estou convertendo um erp gigante para o adianti framework, por meios auto-ditada aprendendo e fazendo, tentativa e erro rsrs, consegui gerar a aplicação do zero até o estado que esta, super funcional e dentro do previsto, porem tem um problema que me aflige à algum tempo, optei por montar o Mestre/Detalhe com os detalhes em formulários independentes, mas o f...
AT
Fieldlist e datagrid não carregam!!!  
Pessoal do forum...boa noite...

Estou convertendo um erp gigante para o adianti framework, por meios auto-ditada aprendendo e fazendo, tentativa e erro rsrs, consegui gerar a aplicação do zero até o estado que esta, super funcional e dentro do previsto, porem tem um problema que me aflige à algum tempo, optei por montar o Mestre/Detalhe com os detalhes em formulários independentes, mas o fieldlist ou datagrid nos detalhes não carregam, quando faço a carga direto na url eles funcionam, mas quando a carga é feita do onEdit do Mestre não funcionam, notem a imagem anexo, dados pessoais normal e dados de endereço e os outros não funcionam, acionados igualmente no form principal, estou enviando as telas e os fontes, por favor se alguém puder me ajudar fico muito grato

[] obrigado

Augusto

Pacotão Dominando o Adianti Framework 7
O material mais completo de treinamento do Framework.
Curso em vídeo aulas + Livro completo + Códigos fontes do projeto ERPHouse.
Conteúdo Atualizado! Versão 7.4


Dominando o Adianti 7 Quero me inscrever agora!

Comentários (5)


AT

  1. <?php
  2.     
  3. /**
  4. * EntidadeForm
  5. *
  6. * @version    1.0
  7. * @package    setcia
  8. * @author     Antonio Augusto Tavares
  9. * @copyright  Copyright (c) 2018 Setsoft - Consultoria e Informática Ltda
  10. */
  11. class EntidadeForm extends TPage
  12. {
  13.     private   $form
  14.     private   $entidade;    
  15.     private   $notebook;
  16.    
  17.     function __construct()
  18.     {
  19.         parent::__construct();
  20.         
  21.         TSession::setValue('id_ent'0);
  22.         
  23.         // cria o form
  24.  
  25.         $this->form = new BootstrapFormBuilder('form_entidade');
  26.         $this->form->style 'width: 100%';
  27.         $this->form->setFieldSizes('100%');
  28.         
  29.         // declara campos de pesquisa
  30.             
  31.         $id_find = new TDBCombo('id_find''setcis''Entidade''id''id');
  32.         $id_find->setSize('100%');
  33.     
  34.         $nome_find = new TDBUniqueSearch('nome_find''setcis''entidade''id''nome''nome asc');
  35.         $nome_find->setMinLength(1);
  36.         $nome_find->setSize('100%');
  37.         $nome_find->setMask('{nome}');
  38.            
  39.         $programatico_find = new TDBUniqueSearch('programatico_find''setcis''entidade''id''programatico''programatico asc');
  40.         $programatico_find->setMinLength(1);
  41.         $programatico_find->setSize('100%');
  42.         $programatico_find->setMask('{programatico} ');
  43.         
  44.         // defina ações de pesquisa
  45.         
  46.         $id_change = new TAction(array($this'onFiltro'));
  47.         $id_find->setChangeAction($id_change);
  48.         
  49.         $nome_change = new TAction(array($this'onFiltro'));
  50.         $nome_find->setChangeAction($nome_change);
  51.             
  52.         $programatico_change = new TAction(array($this'onFiltro'));
  53.         $programatico_find->setChangeAction($programatico_change);
  54.            
  55.         $gru_ini parse_ini_file('app\config\entidades.ini'true);
  56.         
  57.         $opcaoMenu $gru_ini['grupo']['Fornecedores'];
  58.             
  59.         $criteria = new TCriteria();
  60.         $criteria->add(new TFilter('grupo','=',$opcaoMenu));
  61.         
  62.         $id             = new TEntry('id');
  63.         $nome           = new TEntry('nome');
  64.         $pessoas_id     = new TDBCombo('pessoas_id''setcis''pessoas''id''descricao');
  65.         $entidades_id   = new TDBCombo('entidades_id''setcis''entidades''id''descricao''descricao asc');
  66.         $programatico   = new TEntry('programatico');
  67.         
  68.         //$entidades_id_change = new TAction(array($this, 'onSetMask'));
  69.         //$entidades_id->setChangeAction($entidades_id_change);        
  70.         
  71.         // validações
  72.         
  73.         $nome->addValidation('Nome', new TRequiredValidator); 
  74.         $pessoas_id->addValidation('Pessoa', new TRequiredValidator); 
  75.         $entidades_id->addValidation('Categoria', new TRequiredValidator); 
  76.         $programatico->addValidation('Código/Alternatibo', new TRequiredValidator); 
  77.             
  78.         $id->setEditable(FALSE);
  79.          
  80.         // posiciona elementos no form
  81.         $row $this->form->addFields([ $id_find ],
  82.                                       [ $nome_find ],
  83.                                       [ $programatico_find ],
  84.                                       [ TButton::create('clear', array($this'onClear'), 'Novo''fa:eraser green')]);
  85.         $row->layout = ['col-sm-1''col-sm-8''col-sm-2''col-sm-1'];       
  86.             
  87.         $row $this->form->addFields([ new TLabel('<b>Codigo</b>') ], //'<b>Id</b>'
  88.                                       [ new TLabel('<b>Nome</b>') ],
  89.                                       [ new TLabel('<b>Pessoa</b>') ],
  90.                                       [ new TLabel('<b>Categoria</b>') ],
  91.                                       [ new TLabel('<b>Código/Alternativo</b>') ],
  92.                                       [TButton::create('delete', array($this'onDelete'), 'Excluir''fa:eraser red')]);
  93.         $row->layout = ['col-sm-1''col-sm-4''col-sm-2''col-sm-2''col-sm-2''col-sm-1' ];     
  94.                         
  95.         $row $this->form->addFields([ $id ],
  96.                                       [ $nome ],
  97.                                       [ $pessoas_id ],
  98.                                       [ $entidades_id ],
  99.                                       [ $programatico ],
  100.                                       [ TButton::create('save',  array($this'onSave'), 'Salvar''fa:save blue')]);
  101.         $row->layout = ['col-sm-1''col-sm-4''col-sm-2''col-sm-2''col-sm-2''col-sm-1' ];
  102.         
  103.         // prepara notebook de detalhes
  104.             
  105.         $pessoal        = new TFrame;
  106.         $pessoal->class 'tframe tframe-custom';
  107.         $pessoal->style 'background:whiteSmoke;margin:0px;width:100%;height:350px';
  108.  
  109.         $endereco        = new TFrame;
  110.         $endereco->class 'tframe tframe-custom';
  111.         $endereco->style 'background:whiteSmoke';
  112.         
  113.         $inscricao        = new TFrame;
  114.         $inscricao->class 'tframe tframe-custom';
  115.         $inscricao->style 'background:whiteSmoke';
  116.         
  117.         $eletronico        = new TFrame;
  118.         $eletronico->class 'tframe tframe-custom';
  119.         $eletronico->style 'background:whiteSmoke';   
  120.              
  121.         $contrato        = new TFrame;
  122.         $contrato->class 'tframe tframe-custom';
  123.         $contrato->style 'background:whiteSmoke';        
  124.         
  125.         $carteira    = new TFrame;
  126.         $carteira->class 'tframe tframe-custom';
  127.         $carteira->style 'background:whiteSmoke';   
  128.         
  129.         $vinculado   = new TFrame;
  130.         $vinculado->class 'tframe tframe-custom';
  131.         $vinculado->style 'background:whiteSmoke';           
  132.         
  133.         $conta       = new TFrame;
  134.         $conta->class 'tframe tframe-custom';
  135.         $conta->style 'background:whiteSmoke';              
  136.         
  137.         $boleto      = new TFrame;
  138.         $boleto->class 'tframe tframe-custom';
  139.         $boleto->style 'background:whiteSmoke';      
  140.                 
  141.         $mandato     = new TFrame;
  142.         $mandato->class 'tframe tframe-custom';
  143.         $mandato->style 'background:whiteSmoke';              
  144.         
  145.         $atendimento = new TFrame;
  146.         $atendimento->class 'tframe tframe-custom';
  147.         $atendimento->style 'background:whiteSmoke';           
  148.         
  149.         $ocorrencias = new TFrame;
  150.         $ocorrencias->class 'tframe tframe-custom';
  151.         $ocorrencias->style 'background:whiteSmoke';      
  152.         
  153.         $Imagem       = new TFrame;     
  154.         $Imagem->class 'tframe tframe-custom';
  155.         $Imagem->style 'background:whiteSmoke';   
  156.         
  157.         // cria notebook detalhes 
  158.         $notebook = new BootstrapNotebookWrapper( new TNotebook() );
  159.         //$notebook->setTabAction( new TAction(array($this, 'onTabClick')));
  160.         $notebook->style 'background:white';  
  161.    
  162.         TTransaction::open('setcis'); 
  163.         
  164.         $tabEntidades = new Entidades(2);
  165.         
  166.         TTransaction::close(); 
  167.         
  168.         $items str_split(str_replace(','''$tabEntidades->paginas), 3);  
  169.         
  170.         foreach ($items as $key
  171.         {
  172. //            if ($key == 'PES') 
  173. //            {
  174.                 $notebook->appendPage('Pessoais',   $pessoal); 
  175.                 $form_pessoais = new PessoaisForm(0);
  176.                 $pessoal->add($form_pessoais);                
  177. //            }
  178. //            if ($key == 'END')
  179. //            {
  180.                 $notebook->appendPage('Endereços',   $endereco);
  181.                 $form_endereco = new EnderecoForm(0);
  182.                 $endereco->add($form_endereco);
  183. //            }
  184. //            if ($key == 'INS')
  185. //            {
  186.                 $notebook->appendPage('Inscrições',  $inscricao);
  187.                 $form_inscricao = new InscricaoForm(0);
  188.                 $inscricao->add($form_inscricao);  
  189. //            }
  190.             if ($key == 'ELE')
  191.             {
  192.                 $notebook->appendPage('Eletrônicos'$eletronico); 
  193.                 $form_eletronico = new EletronicoForm(0);
  194.                 $eletronico->add($form_Eletronico);                                
  195.             }    
  196.             if ($key == 'CON')
  197.             {
  198.                 $notebook->appendPage('Contratos',   $contrato); 
  199.             }
  200.             if ($key == 'CTA')
  201.             {
  202.                 $notebook->appendPage('Contas',      $conta);    
  203.             }            
  204.             if ($key == 'BOL')
  205.             {
  206.                 $notebook->appendPage('Boletos',      $boleto); 
  207.             }            
  208.             if ($key == 'VIN')
  209.             {
  210.                 $notebook->appendPage('Vínculos',    $vinculado);  
  211.             }
  212.             if ($key == 'CAR')
  213.             {
  214.                 $notebook->appendPage('Carteiras',    $carteira); 
  215.             }     
  216.             if ($key == 'MAN')
  217.             {
  218.                 $notebook->appendPage('Mandatos',    $mandato);
  219.             }
  220.             if ($key == 'ATE')
  221.             {
  222.                 $notebook->appendPage('Atendimentos'$atendimento);
  223.             }
  224.             if ($key == 'OCO')
  225.             {                
  226.                 $notebook->appendPage('Ocorrências'$ocorrencias);   
  227.             } 
  228.             if ($key == 'IMA')
  229.             {
  230.                 $notebook->appendPage('Imagem',      $Imagem); 
  231.                 $form_imagem = new ImagemForm(0);
  232.                 $Imagem->add($form_imagem);
  233.             }        
  234.         }
  235.         // monta pagina
  236.         
  237.         $vbox = new TVBox;
  238.         $vbox->style 'width: 100%';
  239.         $vbox->add(new TXMLBreadCrumb('menu.xml'__CLASS__));
  240.         $vbox->add($this->form);
  241.         $vbox->add($notebook);
  242.         parent::add($vbox);
  243.         
  244.     }
  245.         
  246.     // define mascara programatico
  247.         
  248.     public function show()
  249.     {
  250.         if (!$this->loaded AND (!isset($_GET['method']) OR $_GET['method'] !== 'onClear') )
  251.         {
  252.            $this->onClear(0);
  253.            $this->onEdit(1);
  254.         }
  255.         parent::show();
  256.     }    
  257.     // limpa o form
  258.     public function onClear($param)
  259.     {
  260.         $objeto = new stdClass;    
  261.         $objeto->id_find           '';
  262.         $objeto->nome_find         '';
  263.         $objeto->programatico_find '';   
  264.         $objeto->id '';
  265.         $objeto->nome '';
  266.         $objeto->pessoas_id '';
  267.         $objeto->entidades_id '';
  268.         $objeto->programatico '';
  269.         
  270.         TSession::setValue('id_ent'0);
  271.         
  272.         $this->form->setData($objeto); 
  273.     }
  274.     
  275.     // method onFiltro
  276.     
  277.     public static function onFiltro($param)
  278.     {
  279.         AdiantiCoreApplication::loadPage(__CLASS__'onEdit'$param);
  280.     }    
  281.     // apresenta dados no form
  282.         
  283.     public function onEdit$param )
  284.     {
  285.         try
  286.         {
  287.             if (isset($param['key']))
  288.             {
  289.                 TTransaction::open('setcis'); 
  290.                 
  291.                 $id_ent = (int) $param['key']; 
  292.                 
  293.                 TSession::setValue('id_ent'$id_ent);           
  294.                 $form_pessoais   = new PessoaisForm($id_ent);
  295.                 $form_endereco   = new EnderecoForm($id_ent);
  296.                 $form_inscricao  = new InscricaoForm($id_ent);
  297.                 $form_eletronico = new EletronicoForm($id_ent);                
  298.                
  299.                 $objetoEntidade = new entidade($id_ent);
  300.                 
  301.                 $objetoForm = new stdClass;
  302.                 
  303.                 if ($objetoEntidade)
  304.                 {
  305.                    $objetoForm->id           $objetoEntidade->id;
  306.                    $objetoForm->nome         $objetoEntidade->nome;
  307.                    $objetoForm->pessoas_id   $objetoEntidade->pessoas_id;
  308.                    $objetoForm->entidades_id $objetoEntidade->entidades_id;
  309.                    $objetoForm->programatico $objetoEntidade->programatico;
  310.                 }  
  311.                 
  312.                 TForm::sendData('form_entidade'$objetoForm);
  313.                 
  314.                 TTransaction::close(); 
  315.             }
  316.         }
  317.         catch (Exception $e
  318.         {
  319.             new TMessage('error'$e->getMessage()); 
  320.             TTransaction::rollback(); 
  321.         }
  322.     }        
  323.     
  324.     // method onSave
  325.     public function onSave($param)
  326.     {
  327.         try
  328.         {
  329.             TTransaction::open('setcis');
  330.                 
  331.             $this->form->validate(); 
  332.             
  333.             $data $this->form->getData(); 
  334.             if (!$param['id'])
  335.             {
  336.                 $entidades = new entidade;
  337.             }
  338.             else
  339.             {
  340.                 $entidades = new entidade($data->id);
  341.             }
  342.                 
  343.             $entidades->fromArray( (array) $data); 
  344.             $entidades->store();
  345.             
  346.             $data->id $entidades->id;
  347.             
  348.             $this->form->setData($data); 
  349.                 
  350.             new TMessage('info''Record saved');
  351.                 
  352.             TTransaction::close(); 
  353.         }
  354.         catch (Exception $e
  355.         {
  356.             new TMessage('error'$e->getMessage());
  357.             TTransaction::rollback();
  358.         }
  359.     }
  360.     
  361.     // confirma antes da exclusão
  362.     
  363.     public static function onDelete($param)
  364.     {
  365.         $action = new TAction([__CLASS__'Delete']);
  366.         $action->setParameters($param);
  367.         
  368.         new TQuestion(TAdiantiCoreTranslator::translate('Do you really want to delete ?'), $action);
  369.     }        
  370.     // method delete
  371.  
  372.     public function Delete($param)
  373.     {   
  374.         try
  375.         {
  376.             TTransaction::open('setcis'); 
  377.                 
  378.             $id $param['id'];
  379.               
  380.             $entidades = new entidade($id);
  381.             $entidades->delete();
  382.             
  383.             TTransaction::close(); 
  384.                 
  385.             $pos_action = new TAction([__CLASS__'onClear']);
  386.                 
  387.             new TMessage('info'TAdiantiCoreTranslator::translate('Record deleted'), $pos_action); 
  388.         }
  389.         catch (Exception $e
  390.         {
  391.             new TMessage('error'$e->getMessage());
  392.                 
  393.             TTransaction::rollback();
  394.         }    
  395.     }     
  396.     
  397.     // method onTabClick
  398.         
  399.     public function onTabClick($param)
  400.     {
  401.          try
  402.         {
  403.             $id_ent TSession::getValue('id_ent');
  404.             
  405.             $page = (int) $param['current_page'];   
  406.             
  407.             if ($page == 2)   // load sub-form  endereços
  408.             {
  409.                 $form_Endereco = new EnderecoForm($id_ent);
  410.                 var_dump($id_ent);
  411.             }
  412.             elseif ($page == 3// load sub-form  inscrições
  413.             {
  414.                 $form_Inscricao = new InscricaoForm($id_ent);
  415.             }           
  416.             elseif ($page == 4// load sub-form Eletrônicos
  417.             {
  418.                 $form_Eletronico = new EletronicoForm($id_ent); 
  419.             }                       
  420.         }
  421.         catch (Exception $e)
  422.         {
  423.             new TMessage('error'$e->getMessage()); 
  424.             TTransaction::rollback(); 
  425.         }        
  426.     }        
  427. }         
AT

  1. <?php
  2. /*
  3. * EnderecoForm 
  4. * @version    1.0
  5. * @package    setcis
  6. * @author     Antonio Augusto Tavares
  7. * @copyright  Copyright (c) 2018 Setsoft - Consultoria e Informática Ltda
  8. */
  9. class EnderecoForm extends TPage
  10. {
  11.     protected $form// form
  12.     protected $formfdl;
  13.     protected $detail_row;
  14.     protected $fieldlist;
  15.     static    $id_ent;
  16.     static    $actEnd;
  17.     static    $arrLogra;
  18.     
  19.     // Creates the page and the registration form
  20.     function __construct($param)
  21.     {
  22.         parent::__construct();
  23.         
  24.         $this->form = new TForm('form_endereco');
  25.         
  26.         // cria fieldlist
  27.         
  28.         $this->fieldlist = new TFieldList;
  29.         $this->fieldlist->width '100%';
  30.         $this->fieldlist->name  'fdlEndereco';
  31.         $this->form->add($this->fieldlist);
  32.         // define campos
  33.         
  34.         $id             = new TEntry('list_id[]');
  35.         $enderecos_id   = new TDBCombo('list_enderecos_id[]''setcis''Enderecos''id''descricao''descricao asc');
  36.         $cep            = new TEntry('list_cep[]');
  37.         $logradouros_id = new TDBCombo('list_logradouros_id[]''setcis''Logradouros''id''descricao''descricao asc');
  38.         $endereco       = new TEntry('list_endereco[]');
  39.         $numero         = new TEntry('list_numero[]');
  40.         $complemento    = new TEntry('list_complemento[]');
  41.         $bairro         = new TDBEntry('list_bairro[]''setcis''CepBairro''bairro');
  42.         $cidade_id      = new TDBCombo('list_cidade_id[]''setcis''Municipio''id''nome''nome asc');
  43.         $estado_id      = new TDBCombo('list_estado_id[]''setcis''Estado''id''sigla''sigla asc');
  44.         $actEnd = new TCombo('list_action');
  45.         $entidade_id = new THidden('list_entidade_id[]');
  46.         
  47.         // Tamanhos
  48.         
  49.         $id->setSize('100%'); 
  50.         $enderecos_id->setSize('100%');
  51.         $cep->setSize('100%');
  52.         $logradouros_id->setSize('100%');
  53.         $endereco->setSize('100%');
  54.         $numero->setSize('100%');
  55.         $complemento->setSize('100%');
  56.         $bairro->setSize('100%');
  57.         $cidade_id->setSize('100%');
  58.         $estado_id->setSize('100%');
  59.         $actEnd->setSize('100%');   
  60.         
  61.         // styles
  62.         
  63.         $cep->style="background-color: #ffff99; text-align: left";        
  64.         $numero->style="text-align: center"
  65.         $complemento->style 'text-transform: uppercase';
  66.         
  67.         // define ações
  68.         
  69.         $items = ['1'=>'SALVAR''2'=>'EXCLUIR''3'=>'SUCESSO''4'=>'MAPA'];  
  70.         $actEnd->addItems($items);
  71.         $actEnd->setValue('1');        
  72.         
  73.         $id->setEditable(FALSE); 
  74.         $cep->setExitAction(new TAction(array($this'onCep')));
  75.         $change_action = new TAction(array($this'onDefine'));
  76.         $actEnd->setChangeAction($change_action);
  77.         
  78.         //$change_cidade_id = new TAction(array($this, 'onDetalhes'));
  79.         //$cidade_id->setChangeAction($change_cidade_id);        
  80.  
  81.         // monta fieldlist    
  82.  
  83.         $this->fieldlist->addField'ID'$id, ['width' => '4%']);
  84.         $this->fieldlist->addField'Tipo'$enderecos_id, ['width' => '6%']);
  85.         $this->fieldlist->addField'Cep'$cep, ['width' => '6%']);
  86.         $this->fieldlist->addField'Logradouro'$logradouros_id, ['width' => '6%']);
  87.         $this->fieldlist->addField'Endereco'$endereco, ['width' => '18%']);
  88.         $this->fieldlist->addField'Número'$numero, ['width' => '5%']);
  89.         $this->fieldlist->addField'Complemento'$complemento, ['width' => '10%']);
  90.         $this->fieldlist->addField'Bairro'$bairro, ['width' => '10%']);
  91.         $this->fieldlist->addField'Cidade'$cidade_id, ['width' => '10%']);
  92.         $this->fieldlist->addField'Estado'$estado_id, ['width' => '4%']);
  93.         $this->fieldlist->addField'Salvar/Excluir'$actEnd, ['width' => '2%']);
  94.         $this->fieldlist->addField''$entidade_id);
  95.         $this->fieldlist->width '100%';
  96.          
  97.         // adiciona campos no form
  98.         
  99.         $this->form->addField($id);
  100.         $this->form->addField($enderecos_id);
  101.         $this->form->addField($cep);
  102.         $this->form->addField($logradouros_id);
  103.         $this->form->addField($endereco);
  104.         $this->form->addField($numero);
  105.         $this->form->addField($complemento);
  106.         $this->form->addField($bairro);
  107.         $this->form->addField($cidade_id);
  108.         $this->form->addField($estado_id);
  109.         $this->form->addField($actEnd);
  110.         $this->form->addField($entidade_id);
  111.         
  112.         // create the page container
  113.         
  114.         $vbox = new TVBox;
  115.         $vbox->style 'width: 100%';
  116.         $vbox->add($this->form);
  117.         
  118.         parent::add($vbox);
  119.         
  120.         if ((int) $param != 0)
  121.         {
  122.             $this->onLoad((int) $param);
  123.         }   
  124.     }
  125.     // metodo show
  126.      
  127.     public function show()
  128.     {
  129.         if (!$this->loaded AND (!isset($_GET['method']) OR $_GET['method'] !== 'onLoad') )
  130.         {
  131.             $this->onLoad(0);
  132.         }
  133.         parent::show();
  134.     }    
  135.     // metodo carga do fieldlist
  136.     
  137.     function onLoad($param)
  138.     {
  139.         try
  140.         {
  141.             TTransaction::open('setcis');
  142.             
  143.             $id_ent TSession::getValue('id_ent'); 
  144.             
  145.             //$id_ent++;
  146.             
  147.             //var_dump($param);
  148.             
  149.             //var_dump($id_ent++);
  150.             
  151.             $criteria = new TCriteria();
  152.             $criteria->add(new TFilter('entidade_id''='$id_ent));
  153.             $repository = new TRepository('EntidadeEndereco');
  154.   
  155.             $objEndereco $repository->load($criteria); 
  156.             
  157.             $this->fieldlist->addHeader();
  158.                     
  159.             if ($objEndereco)
  160.             {
  161.                 foreach ($objEndereco as $end)
  162.                 {
  163.                     $objForm                      = new stdClass;
  164.                     $objForm->list_id             $end->id;
  165.                     $objForm->list_enderecos_id   $end->enderecos_id;
  166.                     $objForm->list_cep            $end->cep;
  167.                     $objForm->list_logradouros_id $end->logradouros_id;
  168.                     $objForm->list_endereco       $end->endereco;
  169.                     $objForm->list_numero         $end->numero;
  170.                     $objForm->list_complemento    $end->complemento;
  171.                     $objForm->list_bairro         $end->bairro;
  172.                     $objForm->list_cidade_id      $end->cidade_id;
  173.                     $objForm->list_estado_id      $end->estado_id;
  174.                     
  175.                     $row $this->fieldlist->addDetail($objForm);
  176.                     $row->del($row->get(count($row->getChildren())-1));
  177.                 }          
  178.                 $row $this->fieldlist->addDetail( new stdClass );
  179.                 $row->del($row->get(count($row->getChildren())-1)); 
  180.             }   
  181.             else
  182.             {
  183.                 $row $this->fieldlist->addDetail( new stdClass );
  184.                 $row->del($row->get(count($row->getChildren())-1)); 
  185.             }          
  186.             TTransaction::close();
  187.             
  188.             TScript::create(' $( "#list_enderecos_id" ).focus(); '); 
  189.         
  190.         }
  191.         catch (Exception $e
  192.         {
  193.             new TMessage('error'$e->getMessage());
  194.               
  195.             TTransaction::rollback();
  196.         }
  197.     }        
  198.     
  199.     // method onDefine
  200.     
  201.     public static function onDefine($param)
  202.     {
  203.         $opcao $param['key'];
  204.         
  205.         if($opcao == '1')
  206.         {
  207.             AdiantiCoreApplication::loadPage(__CLASS__'onSave'$param);
  208.         }
  209.         elseif ($opcao == '2')
  210.         {        
  211.             $action = new TAction([__CLASS__'onDelete']);
  212.             $action->setParameters($param); 
  213.             new TQuestion(TAdiantiCoreTranslator::translate('Do you really want to delete ?'), $action);
  214.         }
  215.         elseif ($opcao == '4')
  216.         {
  217.             AdiantiCoreApplication::loadPage(__CLASS__'onMapa'$param); 
  218.         }
  219.     }
  220.     
  221.     // method onSave
  222.    
  223.     function onSave($param)
  224.     {
  225.         try
  226.         {
  227.             // captura o indice e id
  228.             
  229.             parse_str($param['_field_data'], $field_data);
  230.             $indice $field_data['row'];      
  231.             $id_end = (int) $param['list_id'][$indice];
  232.             
  233.             $input_id $param['_field_id'];
  234.             $input_pieces explode('_'$input_id);
  235.             $unique_id end($input_pieces);  
  236.             
  237.             TTransaction::open('setcis'); 
  238.             
  239.             $this->onValidate($param);
  240.             
  241.             $objEndereco = new StdClass;
  242.             $objEndereco->enderecos_id   $param['list_enderecos_id'][$indice];
  243.             $objEndereco->cep            $param['list_cep'][$indice];
  244.             $objEndereco->logradouros_id $param['list_logradouros_id'][$indice];
  245.             $objEndereco->endereco       $param['list_endereco'][$indice];
  246.             $objEndereco->numero         $param['list_numero'][$indice];
  247.             $objEndereco->complemento    $param['list_complemento'][$indice];
  248.             $objEndereco->bairro         $param['list_bairro'][$indice];
  249.             $objEndereco->cidade_id      $param['list_cidade_id'][$indice];
  250.             $objEndereco->estado_id      $param['list_estado_id'][$indice];
  251.             $tabEndereco->entidade_id    TSession::getValue('id_ent');
  252.             
  253.             $tabEndereco = new EntidadeEndereco($id_end);
  254.             
  255.             $tabEndereco->fromArray( (array) $objEndereco);
  256.             $tabEndereco->store();
  257.             
  258.             $objForm = new StdClass;
  259.             $objForm->{'list_id_'.$unique_id}     = $tabEndereco->id;
  260.             $objForm->{'list_action_'.$unique_id} = '3';
  261.             
  262.             TForm::sendData('form_endereco'$objForm);
  263.             if (end($param['list_cep']))
  264.             {
  265.                 TFieldList::addRows('fdlEndereco',1);
  266.             }
  267.             
  268.             $hifem  strpos($param['list_cep'][$indice], '-');
  269.             $cepNum substr($objEndereco->cep,0,$hifem) . substr($objEndereco->cep,$hifem 1,3);
  270.             $tabCep Cep::where('cep''='$cepNum)->load();
  271.             
  272.             if (!$tabCep)
  273.             {
  274.                 $objCep             = new stdClass
  275.                 $objCep->cep        $cepNum;
  276.                 $objCep->logradouro TSession::getValue('arrLogra')[$param['list_logradouros_id'][$indice]];
  277.                 $objCep->endereco   $objEndereco->endereco;
  278.                 $objCep->bairro     $objEndereco->bairro;
  279.                 $objCep->cidade     TSession::getValue('arrCidade')[$param['list_cidade_id'][$indice]]; 
  280.                 $objCep->estado     TSession::getValue('arrEstado')[$param['list_estado_id'][$indice]];  
  281.                 
  282.                 $tabCep = new Cep;
  283.                 $tabCep->fromArray( (array) $objCep);
  284.                 $tabCep->store();
  285.             }
  286.             
  287.             TTransaction::close(); 
  288.         }
  289.         catch (Exception $e
  290.         {
  291.             new TMessage('error'$e->getMessage());
  292.             TTransaction::rollback();
  293.         }
  294.     }    
  295.     
  296.     // method validador
  297.    
  298.     public function onValidate($param)
  299.     {
  300.         parse_str($param['_field_data'], $field_data);
  301.         $indice $field_data['row']; 
  302.    
  303.         if ((!$param['list_enderecos_id'][$indice])) throw new Exception('O campo <b>Tipo</b> é obrigatório');
  304.         if ((!$param['list_cep'][$indice])) throw new Exception('O campo <b>Cep</b> é obrigatório');
  305.         if ((!$param['list_logradouros_id'][$indice])) throw new Exception('O campo <b>Logradouro</b> é obrigatório');
  306.         if ((!$param['list_enderecos_id'][$indice])) throw new Exception('O campo <b>Endereco</b> é obrigatório');
  307.         if ((!$param['list_numero'][$indice])) throw new Exception('O campo <b>Numero</b> é obrigatório');
  308.         if ((!$param['list_bairro'][$indice])) throw new Exception('O campo <b>Bairro</b> é obrigatório');
  309.         if ((!$param['list_cidade_id'][$indice])) throw new Exception('O campo <b>Cidade</b> é obrigatório');
  310.         if ((!$param['list_estado_id'][$indice])) throw new Exception('O campo <b>Estado</b> é obrigatório');
  311.     }            
  312.   
  313.     // method delete endereço
  314.     
  315.     function onDelete($param)
  316.     {
  317.         try
  318.         {
  319.             // captura o indice e id
  320.   
  321.             parse_str($param['_field_data'], $field_data);
  322.             $indice $field_data['row'];      
  323.             $id_end = (int) $param['list_id'][$indice];        
  324.             
  325.             TTransaction::open('setcis'); 
  326.             
  327.             $tabEndereco = new EntidadeEndereco($id_end);
  328.             $tabEndereco->delete();
  329.              
  330.             TTransaction::close();
  331.             
  332.             AdiantiCoreApplication::loadPage(__CLASS__'onLoad'); 
  333.         }
  334.         catch (Exception $e
  335.         {
  336.             new TMessage('error'$e->getMessage());
  337.                 
  338.             TTransaction::rollback();
  339.         }        
  340.     }    
  341.     
  342.     // method busca cep
  343.     
  344.     public static function onCep($param
  345.     {
  346.         try 
  347.         {
  348.             //Monta parametros
  349.             parse_str($param['_field_data'], $field_data);
  350.             $indice $field_data['row'];      
  351.             $id_end = (int) $param['list_id'][$indice];
  352.         
  353.             $input_id $param['_field_id'];
  354.             $input_pieces explode('_'$input_id);
  355.             $unique_id end($input_pieces);    
  356.             
  357.             $cepKey trim($param['key']);
  358.             $hifem strpos($cepKey'-');
  359.             $cepNum = ($hifem) ? substr($cepKey,0,$hifem) . substr($cepKey,$hifem 1,3) : $cepKey;
  360.             $cepTam strlen($cepNum);
  361.             
  362.             $from 'àáãâéêíóõôúüç';
  363.             $to   'ÀÁÃÂÉÊÍÓÕÔÚÜÇ';
  364.             $key  "AIzaSyCN3Csd1bMMcHBCjQZ-w6Jv1bGHP9NjxWY";
  365.             $correio 'http://www.buscacep.correios.com.br/sistemas/buscacep/resultadoBuscaCepEndereco.cfm';
  366.   
  367.             if ($cepTam == 0)
  368.             {
  369.                 TScript::create("var win = window.open('{$correio}', '_blank'); win.focus();");
  370.             }
  371.             elseif ($cepTam != 8)
  372.             {
  373.                 new TMessage('info''Cep inválido...(tem que ter 8 digitos)');
  374.                 TScript::create('setTimeout(function() { $("input[name=\'cep\']").focus() }, 500);');        
  375.             }
  376.             else
  377.             {
  378.                 TTransaction::open('setcis');
  379.                 
  380.                 $tabCep Cep::where('cep''='$cepNum)->load();
  381.                 
  382.                 if ($tabCep)
  383.                 {
  384.                     foreach ($tabCep as $tab
  385.                     {
  386.                         $objCep = new StdClass
  387.                         $objCep->{'list_enderecos_id_'.$unique_id} = $param['list_enderecos_id'][$indice];
  388.                         $objCep->{'list_cep_'.$unique_id} = substr($tab->cep,0,5) . '-'substr($tab->cep,5,3);
  389.                         $objCep->{'list_logradouros_id_'.$unique_id} = array_search($tab->logradouroLogradouros::getIndexedArray('id''descricao')); 
  390.                         $objCep->{'list_endereco_'.$unique_id} = $tab->endereco;
  391.                         $objCep->{'list_bairro_'.$unique_id} = $tab->bairro;
  392.                         $objCep->{'list_cidade_id_'.$unique_id} = array_search($tab->cidadeMunicipio::getIndexedArray('id''nome'));
  393.                         $objCep->{'list_estado_id_'.$unique_id} = array_search($tab->estadoEstado::getIndexedArray('id''sigla'));
  394.                                  
  395.                         TForm::sendData('form_endereco'$objCep); 
  396.                         
  397.                         //TScript::create('setTimeout(function() { $("input[name='list_numero']").focus() }, 100);');
  398.                         
  399.                         //TScript::create('setTimeout(function() { $("input[name=\'list_numero\']").focus() }, 200);'); 
  400.                     }    
  401.                 }
  402.                 else
  403.                 {      
  404.                     TScript::create("var win = window.open('{$correio}', '_blank'); win.focus();");
  405.                     //new TMessage('info', 'Cep: '.$cepNum.' não existe na base de dados!');
  406.                     //$objCep->{'ibge_'.$unique_id} = $retorno->ibge;                
  407.                 }                
  408.                 
  409.                 TTransaction::close(); 
  410.             }
  411.         }
  412.         catch (Exception $e
  413.         {
  414.             new TMessage('error'$e->getMessage());    
  415.         }
  416.     }
  417.     
  418.     // pesquisa coordenas lat e lng
  419.     
  420.     public static function onMapa($param)
  421.     {
  422.         parse_str($param['_field_data'], $field_data);
  423.         $indice $field_data['row'];  
  424.         
  425.         $input_id $param['_field_id'];
  426.         $input_pieces explode('_'$input_id);
  427.         $unique_id end($input_pieces);    
  428.          
  429.         $from 'àáãâéêíóõôúüç';
  430.         $to   'ÀÁÃÂÉÊÍÓÕÔÚÜÇ';
  431.         TTransaction::open('setcis');
  432.             
  433.         $desLogra  Logradouros::getIndexedArray('id''descricao')[$param['list_logradouros_id'][$indice]];
  434.         $desCidade Municipio::getIndexedArray('id''nome')[$param['list_cidade_id'][$indice]];   
  435.         $desEstado Estado::getIndexedArray('id''sigla')[$param['list_estado_id'][$indice]];
  436.             
  437.         TTransaction::close(); 
  438.         $urlEnd $desLogra.' '.$param['list_endereco'][$indice].' '.$param['list_numero'][$indice].' '.$param['list_bairro'][$indice].' '.$desCidade.' '.$desEstado;
  439.         $address str_replace(' ','+',strtr(strtolower($urlEnd), $to$from)); 
  440.         $geocode = new TGeoCode($address);
  441.         $geocode->request();
  442.         $status $geocode->getStatus();
  443.         if ($status == 'OK'
  444.         {
  445.             $link 'http://maps.google.com/?q='.$geocode->getLat().','.$geocode->getLng(); 
  446.             TScript::create("var win = window.open('{$link}', '_blank'); win.focus();");                 
  447.         }  
  448.         else
  449.         {
  450.             new TMessage('info''Não foi possível abrir o mapa, motivo: '.$status);
  451.         }            
  452.         
  453.     }        
  454.     
  455.     //edite cidade
  456.     
  457.     public static function onDetalhes($param)
  458.     {
  459.        //$MunicipioForm = 'app\control\tabelas\MunicipioForm';
  460.        //$link = new TElement('a');
  461.        //$link->target = 'newwindow';
  462.        //$link->class = 'MunicipioForm';
  463.        //$link->href = 'index.php?class=MunicipioForm';
  464.        //$link->add('Cidades');
  465.               
  466.        AdiantiCoreApplication::loadPage('MunicipioForm');   
  467.        
  468.        //$link = 'app/control/tabelas/MunicipioForm';         
  469.               
  470.        //if($param) TApplication::loadPage('C:\wamp64\www\setcis\app\control\tabelas\MunicipioForm'); 
  471.        //TScript::create("var win = window.open('{$link}', '_blank'); win.focus();");
  472.     }        
  473. }
  474. ?>

AT

Carga do form dentro da aba do notebook na linha 183, com os dados no onEdit linha 304 do princincipal, por favor me ajudem!!!

[] obrigado

Augusto
MM

Bom dia Antonio Augusto, podemos nos falar por telefone para trocar-mos uma experiência a respeito da situação? O meu e-mail é milton@rsys.com.br
AT

Boa noite Milton, enviei um email com o numero do meu telefone: TIM (31) 986843101, se puder me liga ok?

[] obrigado

Augusto