Lançado Adianti Framework 7.6!
Clique aqui para saber mais
Bloqueio de campos Boa tarde... Tenho o formulário de cotação no meu projeto e gostaria que alguns campos ficassem desabilitados (setEditable(false)) conforme o valor dentro do campo Status, por exemplo: Se o registro selecionado tiver com Status = Aprovado, os campos de calculo do frete não podem estar habilitados, pois o usuário poderia alterar o valor de uma cotação que já foi aprovada. Segue anexo tela...
RF
Bloqueio de campos  
Fechado
Boa tarde...
Tenho o formulário de cotação no meu projeto e gostaria que alguns campos ficassem desabilitados (setEditable(false)) conforme o valor dentro do campo Status, por exemplo: Se o registro selecionado tiver com Status = Aprovado, os campos de calculo do frete não podem estar habilitados, pois o usuário poderia alterar o valor de uma cotação que já foi aprovada.
Segue anexo tela e código do formulário:
  1. <?php
  2. class CotacaoForm extends TPage
  3. {
  4.     private $form// form
  5.    
  6.     function __construct()
  7.     {
  8.         parent::__construct();
  9.         
  10.         // creates the form
  11.         $this->form = new TForm('form_cotacao');
  12.         $this->form->class 'tform';
  13.           
  14.         // cria as tabelas
  15.         $table_data     = new TTable;
  16.         $table_destino  = new TTable;
  17.         $table_carga    = new TTable;
  18.         $table_frete    = new TTable;
  19.         $table_diversos = new TTable;
  20.         
  21.         //Tamanho do notebook
  22.         $notebook = new TNotebook(500250);
  23.        
  24.         // adiciona as abas do notebook
  25.         $this->form->add($notebook);
  26.         
  27.         // Adiciona o nome das abas do notebook 
  28.         $notebook->appendPage('Solicitante'$table_data);
  29.         $notebook->appendPage('Destino'$table_destino);
  30.         $notebook->appendPage('Carga',$table_carga);
  31.         $notebook->appendPage('Frete'$table_frete);
  32.         $notebook->appendPage('Diversos',$table_diversos);
  33.         
  34.         // campos do formulário
  35.         2356               = new TEntry('id');
  36.         $customer_cnpj    = new TSeekButton('customer_cnpj');
  37.         $status           = new TCombo('status');
  38.         $observacoes      = new TText('observacoes');
  39.         $solicitante      = new TEntry('solicitante');
  40.         $address          = new TEntry('address');
  41.         $numero           = new TEntry('numero');
  42.         $complemento      = new TEntry('complemento');
  43.         $bairro           = new TEntry('bairro');
  44.         $cep              = new TEntry('cep');
  45.         $uf               = new TEntry('uf');
  46.         $municipio        = new TEntry('municipio');
  47.         $contato          = new TEntry('contato');
  48.         $telefone         = new TEntry('telefone');
  49.         $email            = new TEntry('email');
  50.         $empresa_col      = new TEntry('empresa_col');
  51.         $customercol_cnpj = new TSeekButton('customercol_cnpj');
  52.         $address_col      = new TEntry('address_col');
  53.         $numero_col       = new TEntry('numero_col');
  54.         $complemento_col  = new TEntry('complemento_col');
  55.         $bairro_col       = new TEntry('bairro_col');
  56.         $cep_col          = new TEntry('cep_col');
  57.         $uf_col           = new TEntry('uf_col');
  58.         $municipio_col    = new TEntry('municipio_col');
  59.         $produto_id       = new TDBCombo('produto_id'   'samples''produto'    'id''name');//busca o produto 
  60.         $grnatureza_id    = new TDBCombo('grnatureza_id''samples''Grunatureza''id''name');//busca a natureza
  61.         $embalagem_id     = new TDBCombo('embalagem_id' 'samples''Embalagem'  'id''name');//busca a embalagem
  62.         $distancia        = new TEntry('distancia');
  63.         $prod_quimico     = new TCombo('prod_quimico');
  64.         $onu              = new TEntry('onu');
  65.         $volume           = new TEntry('volume');
  66.         $peso             = new TEntry('peso');
  67.         $comprimento      = new TEntry('comprimento');
  68.         $largura          = new TEntry('largura');    
  69.         $altura           = new TEntry('altura');
  70.         
  71.         //$cubagem          = new TEntry('cubagem');
  72.         //$pesocubado       = new TEntry('pesocubado');
  73.         
  74.         $peso_cubico      = new TEntry('peso_cubico');  
  75.         $peso_cubado      = new TEntry('peso_cubado');  
  76.         
  77.         $valor_nf         = new TEntry('valor_nf');
  78.         $comentarios      = new TText('comentarios');
  79.         $fretepeso        = new TEntry('fretepeso');
  80.         $fretevalor       = new TEntry('fretevalor');
  81.         $coleta           = new TEntry('coleta');
  82.         $entrega          = new TEntry('entrega');
  83.         $data_cotacao     = new TDate('data_cotacao');
  84.         $outros           = new TEntry('outros');
  85.         $cat              = new TEntry('cat');
  86.         $sec_cat          = new TEntry('sec_cat');
  87.         $gris             = new TEntry('gris');
  88.         $txdespacho       = new TEntry('txdespacho');
  89.         $pedagio          = new TEntry('pedagio');
  90.         $perc_icms        = new TEntry('perc_icms');
  91.         $base_icms        = new TEntry('base_icms');
  92.         $valor_icms       = new TEntry('valor_icms');
  93.         $frete_total      = new TEntry('frete_total');
  94.         $alteracao        = new TEntry('alteracao');
  95.                 
  96.         // Tamanho dos campos e desabilitação para editar      
  97.         2356               ->setSize(150);
  98.         2356               ->setEditable(false);
  99.         
  100.         $status           ->setSize(150);
  101.         $data_cotacao     ->setSize(133);
  102.         //Dados do Solicitante  
  103.         $solicitante      ->setSize(220);
  104.         $solicitante      ->style "text-transform: uppercase";
  105.         $customer_cnpj    ->setSize(130);
  106.         $address          ->setSize(220);
  107.         $address          ->style "text-transform: uppercase";
  108.         $municipio        ->setSize(220);
  109.         $municipio        ->style "text-transform: uppercase";
  110.         $numero           ->setSize(75);
  111.         $complemento      ->setSize(220);
  112.         $complemento      ->style "text-transform: uppercase";
  113.         $bairro           ->setSize(173);
  114.         $bairro           ->style "text-transform: uppercase";
  115.         $cep              ->setSize(122);
  116.         $uf               ->setSize(50);
  117.         $uf               ->style "text-transform: uppercase"
  118.         $contato          ->setSize(220);
  119.         $contato          ->style "text-transform: uppercase";
  120.         $telefone         ->setSize(155);
  121.         $email            ->setSize(220);
  122.         $email            ->style "text-transform: lowercase";
  123.         
  124.         //Dados do destino
  125.         $empresa_col      ->setSize(220);
  126.         $customercol_cnpj ->setSize(130);
  127.         $address_col      ->setSize(220);
  128.         $municipio_col    ->setSize(220);
  129.         $numero_col       ->setSize(75);
  130.         $complemento_col  ->setSize(220);
  131.         $bairro_col       ->setSize(173);
  132.         $cep_col          ->setSize(122);
  133.         $uf_col           ->setSize(50);
  134.         //Dados do produto
  135.         $produto_id       ->setSize(350);
  136.         $grnatureza_id    ->setSize(350);
  137.         $embalagem_id     ->setSize(220);
  138.         $distancia        ->setSize(90);
  139.         $prod_quimico     ->setSize(144);
  140.         $onu              ->setSize(145);
  141.         $observacoes      ->setSize(350);
  142.         //Dados da carga
  143.         $volume           ->setSize(144);
  144.         $peso             ->setSize(144);        
  145.         $peso_cubico      ->setSize(144);
  146.         $peso_cubado      ->setSize(100);
  147.         $comprimento      ->setSize(44);
  148.         $largura          ->setSize(44);
  149.         $altura           ->setSize(44);
  150.         $valor_nf         ->setSize(144);
  151.         //Dados do frete
  152.         $fretepeso        ->setSize(150); 
  153.         $fretevalor       ->setSize(150);
  154.         $coleta           ->setSize(150);
  155.         $entrega          ->setSize(150);
  156.         $txdespacho       ->setSize(150);
  157.         $outros           ->setSize(150); 
  158.         $cat              ->setSize(150);
  159.         $sec_cat          ->setSize(150);
  160.         $gris             ->setSize(150);
  161.         $pedagio          ->setSize(150);
  162.         $perc_icms        ->setSize(50);
  163.         $base_icms        ->setSize(145);
  164.         $valor_icms       ->setSize(95);
  165.         $frete_total      ->setSize(150);
  166.         //Demais informações
  167.         $alteracao        ->setSize(150);
  168.         $comentarios      ->setSize(350);
  169.           
  170.         //Mascaras de entrada, campos obrigatórios, validações e campos obrigatórios
  171.         $fretepeso          ->setNumericMask(2',''.',true);
  172.         $fretevalor         ->setNumericMask(2',''.',true);
  173.         $coleta             ->setNumericMask(2',''.',true);
  174.         $entrega            ->setNumericMask(2',''.',true);
  175.         $txdespacho         ->setNumericMask(2',''.',true);
  176.         $outros             ->setNumericMask(2',''.',true);
  177.         $cat                ->setNumericMask(2',''.',true);
  178.         $sec_cat            ->setNumericMask(2',''.',true);
  179.         $gris               ->setNumericMask(2',''.',true);
  180.         $pedagio            ->setNumericMask(2',''.',true);
  181.         $valor_icms         ->setNumericMask(2',''.',true);
  182.         $frete_total        ->setNumericMask(2',''.',true);
  183.         $valor_nf           ->setNumericMask(2',''.',true); 
  184.         $base_icms          ->setNumericMask(2',''.',true); 
  185.         $perc_icms          ->setNumericMask(2',''.',true); 
  186.         $peso_cubico        ->setNumericMask(2',','.' ,true);
  187.         $peso_cubado        ->setNumericMask(2',','.' ,true); 
  188.         $comprimento        ->setNumericMask(2',','.' ,true);
  189.         $largura            ->setNumericMask(2',','.' ,true);
  190.         $altura             ->setNumericMask(2',','.' ,true);  
  191.         $data_cotacao       ->setMask('dd/mm/yyyy');
  192.         $cep                ->setMask('99999-999');
  193.         $telefone           ->setMask('(99)9999-9999');
  194.         $cep_col            ->setMask('99999-999');
  195.         $email              ->addValidation('E-mail',new TEmailValidator);
  196.         
  197.         //Ação dos campos ao perder o foco
  198.         $altura             ->setExitAction(new TAction(array($this'onCubagem'   )));
  199.         $peso_cubico        ->setExitAction(new TAction(array($this'onPesocubado')));
  200.                             
  201.         //Objeto para criar o campo de busca de solicitante e destinatário por cnpj ou rz social
  202.         $obj = new Remetente//
  203.         $customer_cnpj->setAction(new TAction(array($obj'onReload')));
  204.         
  205.         $obj2 = new Destinatario//
  206.         $customercol_cnpj->setAction(new TAction(array($obj2'onReload')));       
  207.                  
  208.         //Itens do Status
  209.         $itemStatus= array();
  210.         $itemStatus['Lançado']      = 'Lançado';
  211.         $itemStatus['Impresso']     = 'Impresso';
  212.         $itemStatus['Aprovado']     = 'Aprovado';
  213.         $itemStatus['Reprovado']    = 'Reprovado';   
  214.         $status->setValue('Lançado');
  215.         $status->addItems($itemStatus);     
  216.         
  217.         //Itens do químico
  218.         $itemQ= array();
  219.         $itemQ['Não']  = 'Não';
  220.         $itemQ['Sim']  = 'Sim';  
  221.         $prod_quimico->setValue('Não');
  222.         $prod_quimico->addItems($itemQ); 
  223.         
  224.         
  225.         
  226.         //Valores padrões para os campos de calculo do frete, isso evita o erro da linha 79
  227.         $fretepeso        ->setValue('0'); 
  228.         $fretevalor       ->setValue('0');
  229.         $coleta           ->setValue('0');
  230.         $entrega          ->setValue('0');
  231.         $txdespacho       ->setValue('0');
  232.         $outros           ->setValue('0'); 
  233.         $cat              ->setValue('0');
  234.         $sec_cat          ->setValue('0');
  235.         $gris             ->setValue('0');
  236.         $pedagio          ->setValue('0');
  237.         $valor_icms       ->setValue('0');
  238.         $frete_total      ->setValue('0');
  239.         $valor_nf         ->setValue('0');
  240.         $base_icms        ->setValue('0');
  241.         $comprimento      ->setValue('0');   
  242.         $largura          ->setValue('0');  
  243.         $altura           ->setValue('0');
  244.         $peso_cubico      ->setValue('0');
  245.         $peso_cubado      ->setValue('0'); 
  246.         $perc_icms        ->setValue('12');
  247.         $status           ->setValue('Lançado');
  248.         $alteracao        ->setValue(date('d-m-Y / H:i'));    
  249.         $alteracao        ->setEditable(FALSE);
  250.         $base_icms        ->setEditable(FALSE);
  251.         $valor_icms       ->setEditable(FALSE);
  252.               
  253.         // Campos da Aba Solicitante
  254.         $table_data->addRowSet(new TLabel(''));
  255.         $table_data->addRowSet(new TLabel('Número:')     ,array(2356,           new TLabel('Data de solicitação :'),$data_cotacao));
  256.         $table_data->addRowSet(new TLabel('CNPJ:')       ,array($customer_cnpj,new TLabel('Rz Social:'),$solicitante));        
  257.         $table_data->addRowSet(new TLabel('Endereço:')   ,array($address,      new TLabel('Número do endereço:'),$numero));
  258.         $table_data->addRowSet(new TLabel('Complemento:'),array($complemento));
  259.         $table_data->addRowSet(new TLabel('Cidade:')     ,array($municipio,    new TLabel('Bairro:'),$bairro));
  260.         $table_data->addRowSet(new TLabel('Estado:')     ,array($uf,           new TLabel('CEP:'),$cep));
  261.         $table_data->addRowSet(new TLabel('Contato:')    ,array($contato,      new TLabel('Telefone :'),$telefone));
  262.         $table_data->addRowSet(new TLabel('E-mail:')     ,$email);
  263.         
  264.         // Campos da Aba Destino
  265.         $table_destino->addRowSet(new TLabel(''));
  266.         $table_destino->addRowSet(new TLabel('CNPJ:')       ,array($customercol_cnpj, new TLabel('Rz Social:'),$empresa_col));        
  267.         $table_destino->addRowSet(new TLabel('Endereço:')   ,array($address_col,      new TLabel('Número do endereço:'),$numero_col));
  268.         $table_destino->addRowSet(new TLabel('Complemento:'),array($complemento_col));
  269.         $table_destino->addRowSet(new TLabel('Cidade:')     ,array($municipio_col,    new TLabel('Bairro:'),$bairro_col));
  270.         $table_destino->addRowSet(new TLabel('Estado:')     ,array($uf_col,           new TLabel('CEP:'),$cep_col));
  271.         // Campos da Aba carga
  272.         $table_carga->addRowSet(new TLabel(''));
  273.         $table_carga->addRowSet(new TLabel('Produto:')  ,array($produto_id));  
  274.         $table_carga->addRowSet(new TLabel('Grupo:')    ,array($grnatureza_id) );
  275.         $table_carga->addRowSet(new TLabel('Embalagem:'),array($embalagem_id,  new TLabel('KM:'),$distancia));          
  276.         $table_carga->addRowSet(new TLabel('Químico?')  ,array($prod_quimico,  new TLabel('O.n.U :'),$onu));  
  277.         $table_carga->addRowSet(new TLabel('Volume:')   ,array($volume,        new TLabel('PESO :') ,$peso));  
  278.         $table_carga->addRowSet(new TLabel('Vlr NF-e:') ,array($valor_nf,      new TLabel('C')      ,$comprimento,new TLabel('L'),$largura,new TLabel('A'),$altura));   
  279.         $table_carga->addRowSet(new TLabel('Cubagem:')  ,array($peso_cubico,   new TLabel('Peso Cubado:') ,$peso_cubado));
  280.         $table_carga->addRowSet(new TLabel('A carga é:'),array($observacoes));
  281.         
  282.         //Campos da Aba Frete
  283.         $table_frete->addRowSet(new TLabel(''));
  284.         $table_frete->addRowSet(new TLabel('Frete Peso:'),array($fretepeso,    new TLabel('Frete Valor :') ,$fretevalor));  
  285.         $table_frete->addRowSet(new TLabel('Entrega:')   ,array($entrega,      new TLabel('T.Despacho:')   ,$txdespacho));
  286.         $table_frete->addRowSet(new TLabel('Coleta:')    ,array($coleta,       new TLabel('Outra taxa .:') ,$outros));
  287.         $table_frete->addRowSet(new TLabel('C.A.T:')     ,array($cat,          new TLabel('Vlr. Pedágio:') ,$pedagio)); 
  288.         $table_frete->addRowSet(new TLabel('GRIS:')      ,array($gris,         new TLabel('S.E.C / CAT.:') ,$sec_cat));         
  289.         $table_frete->addRowSet(new TLabel('')); 
  290.         $table_frete->addRowSet(new TLabel('ICMS %')     ,array($perc_icms,    new TLabel('Base:'),$base_icms, new TLabel('ICMS:'),$valor_icms));  
  291.         $table_frete->addRowSet(new TLabel('Total')      ,array($frete_total) );
  292.           
  293.         // Campos da Aba Diversos
  294.         $table_diversos->addRowSet(new TLabel(''));
  295.         $table_diversos->addRowSet(new TLabel('Status:')      ,array($status));
  296.         $table_diversos->addRowSet(new TLabel('Comentário:')  ,array($comentarios));
  297.         $table_diversos->addRowSet(new TLabel(''));
  298.         $table_diversos->addRowSet(new TLabel('Alterado:')    ,array($alteracao));
  299.          
  300.         //criação das ações dos botões (action button)
  301.         $button1=new TButton('action1');
  302.         $button1->setAction(new TAction(array($this'onSave')), 'Salvar');
  303.         $button1->setImage('fa:floppy-o');
  304.         
  305.         // create an action button (go to list)
  306.         $button2=new TButton('list');
  307.         $button2->setAction(new TAction(array('CotacaoFormView''onReload')), 'Voltar para a listagem');
  308.         $button2->setImage('fa:table blue');
  309.         
  310.         // create an action button (go to list)
  311.         $button3=new TButton('novo');
  312.         $button3->setAction  (new TAction(array($this'onClear')), _t('New'));//onEdit
  313.         $button3->setImage('bs:plus-sign green');
  314.         
  315.         // Vai chamar a função para calcular o frete
  316.         $button4=new TButton('calcFrete');
  317.         $button4->setAction  (new TAction(array($this'onFrete')), ('Calcula o Frete'));
  318.         $button4->setImage('bs:plus-sign green');
  319.         
  320.         // define os campos que são gravados na model e a variável dos botões
  321.         $this->form->setFields(array(2356$status$customer_cnpj,$solicitante,$observacoes,$address,$numero,$complemento,
  322.         $bairro,$cep,$uf,$contato,
  323.         $telefone,$email,$empresa_col,$customercol_cnpj,$address_col,$numero_col,$complemento_col,$bairro_col,$cep_col,
  324.         $uf_col,$produto_id,$municipio_col,$municipio,
  325.         $grnatureza_id,$embalagem_id,$distancia,$prod_quimico,$onu,$volume,$peso,$peso_cubico,$peso_cubado,$valor_nf,
  326.         $comentarios,$fretepeso,$fretevalor,
  327.         $coleta,$entrega,$txdespacho,$outros,$cat,$sec_cat,$gris,$pedagio,$perc_icms,$valor_icms,$frete_total,
  328.         $data_cotacao,$alteracao,
  329.         $button1,$button2,$button3,$button4,$altura,$comprimento,$largura,$base_icms));
  330.         
  331.         // coloca os botões
  332.         $subtable = new TTable;
  333.         $row $subtable->addRow();
  334.         $row->addCell($button1);
  335.         $row->addCell($button3);
  336.         $row->addCell($button2);
  337.         $row->addCell($button4);
  338.         
  339.         // Sub menu bonito
  340.         $vbox = new TVBox;
  341.         $vbox->add(new TXMLBreadCrumb('menu.xml'__CLASS__));
  342.         $vbox->add($this->form);
  343.         $vbox->style 'width: 55%';       
  344.         //$vbox->add($this->datagrid); //pra mostra a grid
  345.         $vbox->add($subtable);
  346.         parent::add($vbox);
  347.     }
  348.    
  349.  //*********************** Funções ******************************
  350.    
  351.     public function onClear$param // botão novo
  352.     {
  353.         $this->form->clear();//Limpa o formulário
  354.         //Informações padrões a serem preenchidas no formulário
  355.         $perc_icms    12;
  356.         $status       'Lançado';
  357.         $alteracao    date('d-m-Y / H:i');
  358.         //Apresentação e  tratamento do campos 
  359.         $obj = new StdClass;
  360.         $obj->perc_icms  number_format($perc_icms 2',''.');
  361.         $obj->status     $status;
  362.         $obj->alteracao  $alteracao;
  363.         TForm::sendData('form_cotacao'$obj);
  364.     }
  365.     
  366.     // Calculo da cubagem    
  367.     static function onCubagem($param)
  368.     {
  369.         $comprimento str_replace(',','.'str_replace('.',''$param['comprimento']));    
  370.         $largura     str_replace(',','.'str_replace('.',''$param['largura'])); 
  371.         $altura      str_replace(',','.'str_replace('.',''$param['altura']));
  372.         $peso_cubico $comprimento $largura $altura;
  373.         
  374.         $obj = new StdClass;
  375.         $obj->peso_cubico number_format($peso_cubico2',''.');
  376.         TForm::sendData('form_cotacao'$obj);   
  377.     }
  378.     
  379.     // Calculo do peso cubado    
  380.     static function onPesocubado($param)
  381.     {
  382.         $peso_cubico str_replace(',','.'str_replace('.',''$param['peso_cubico']));    
  383.         $peso_cubado  $peso_cubico 300;
  384.         $obj = new StdClass;
  385.         $obj->peso_cubado number_format($peso_cubado2',''.');
  386.         TForm::sendData('form_cotacao'$obj);   
  387.     }
  388.     // Calculo do valor do frete   
  389.     static function onFrete($param)
  390.     {
  391.         //Tratamento dos campos
  392.         $fretepeso     str_replace(',','.'str_replace('.',''$param['fretepeso']));    
  393.         $fretevalor    str_replace(',','.'str_replace('.',''$param['fretevalor'])); 
  394.         $coleta        str_replace(',','.'str_replace('.',''$param['coleta']));
  395.         $entrega       str_replace(',','.'str_replace('.',''$param['entrega']));
  396.         $txdespacho    str_replace(',','.'str_replace('.',''$param['txdespacho']));
  397.         $outros        str_replace(',','.'str_replace('.',''$param['outros']));
  398.         $cat           str_replace(',','.'str_replace('.',''$param['cat']));
  399.         $sec_cat       str_replace(',','.'str_replace('.',''$param['sec_cat']));
  400.         $gris          str_replace(',','.'str_replace('.',''$param['gris']));
  401.         $pedagio       str_replace(',','.'str_replace('.',''$param['pedagio']));
  402.         $perc_icms     str_replace(',','.'str_replace('.',''$param['perc_icms']));
  403.         //Calculos
  404.         $base_icms     = ($fretepeso $fretevalor $coleta  $entrega $txdespacho 
  405.                           $outros    $cat        $sec_cat $gris    $pedagio) ;
  406.         $frete_total   $base_icms / ((100 $perc_icms)/100);               
  407.         $valor_icms    $frete_total $base_icms;
  408.         //Apresentação e  tratamento do campos 
  409.         $obj = new StdClass;
  410.         $obj->base_icms   number_format($base_icms  2',''.');
  411.         $obj->frete_total number_format($frete_total2',''.');
  412.         $obj->valor_icms  number_format($valor_icms 2',''.');
  413.         TForm::sendData('form_cotacao'$obj);   
  414.     }
  415.     /**
  416.      * Load object to form data
  417.      * @param $param Request
  418.      */
  419.      public function onEdit$param )
  420.     {
  421.         try
  422.         {
  423.             if (isset($param['key']))
  424.             {
  425.                 $key $param['key'];  // get the parameter $key
  426.                 TTransaction::open('samples'); // open a transaction
  427.                 $object = new Cotacao($key); // instantiates the Active Record
  428.                 $object->data_cotacao TDate::date2br($object->data_cotacao);
  429.                 $this->form->setData($object); // fill the form
  430.                 TTransaction::close(); // close the transaction
  431.             }
  432.             else
  433.             {
  434.                 $this->form->clear();
  435.             }
  436.         }
  437.         catch (Exception $e// in case of exception
  438.         {
  439.             new TMessage('error'$e->getMessage()); // shows the exception error message
  440.             TTransaction::rollback(); // undo all pending operations
  441.         }
  442.     }
  443.        
  444.     /**
  445.      * method onSave()
  446.      * Executed whenever the user clicks at the save button
  447.      */
  448.     function onSave()
  449.     {
  450.        try
  451.        {     
  452.         $alteracao    date('d-m-Y / H:i');
  453.         $obj = new StdClass;
  454.         $obj->alteracao  $alteracao;
  455.         TForm::sendData('form_cotacao'$obj);
  456.        
  457.         TTransaction::open('samples'); // Abre a conexão com o banco
  458.         $this->form->validate(); // validação dos dados
  459.         $object $this->form->getData('Cotacao');//abre a tabela 
  460.         $object->data_cotacao TDate::date2us($object->data_cotacao);//converte para formato US
  461.         $object->store();//grava
  462.         $object->data_cotacao TDate::date2br($object->data_cotacao);
  463.         $this->form->setData($object);//
  464.         new TMessage('info'TAdiantiCoreTranslator::translate('Record saved')); 
  465.         TTransaction::close(); //fecha o banco           
  466.       }
  467.       
  468.         catch (Exception $e// in case of exception
  469.         {
  470.             // shows the exception error message
  471.             new TMessage('error''<b>Error</b> ' $e->getMessage());
  472.             TTransaction::rollback();
  473.         }
  474.         
  475.     }     
  476. }

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)


IF

Olá Robson. Tenta com JQuery:

  1. <?php
  2.   //Defina um ID para os campos que vc vai manipular
  3.   $frete_total->setId('frete_total');
  4.   $status->setChangeAction(new TAction(array($this ,'onChangeStatus')));
  5.   //Crie a function onChangeStatus
  6.   static function onChangeStatus($param)
  7.     {
  8.          $status $param['status'];
  9.          if ($status == 'Aprovado')
  10.          {
  11.              TScript::create('$("#frete_total").addClass("tfield_disabled");');
  12.          }
  13.          else
  14.          {
  15.              TScript::create('$("#frete_total").removeClass("tfield_disabled");');   
  16.          }
  17.     }
  18. ?>


Não sei se é a melhor forma de fazer isso, mas eu uso assim e funciona!
RF

Boa noite Ivan, quase funcionou do modo como desejado, na verdade ao abrir o formulário de lançamento (CotacaoForm) o campo continua sendo exibido, ou seja, só funciona quando altero o status.
Na verdade eu queria: Ao selecionar um registro do formulário CotacaoFormView, e o Status fosse "Aprovado" ao abrir CotacaoForm alguns campos (por exemplo frete_total) aparecesse desabilitado.

  1. <?php
  2. /**
  3.  * CotacaoFormView Listing
  4.  * @author  <your name here>
  5.  */
  6. class CotacaoFormView extends TPage
  7. {
  8.     private $form// form
  9.     private $datagrid// listing
  10.     private $pageNavigation;
  11.     private $formgrid;
  12.     private $loaded;
  13.     private $deleteButton;
  14.     
  15.     /**
  16.      * Class constructor
  17.      * Creates the page, the form and the listing
  18.      */
  19.     public function __construct()
  20.     {
  21.         parent::__construct();
  22.         
  23.         // creates the form
  24.         $this->form = new TQuickForm('form_search_Cotacao');
  25.         $this->form->class 'tform'// change CSS class 
  26.         $this->form->style 'display: table;width:100%'// change style
  27.        
  28.         // create the form fields
  29.         $id            = new TEntry('id');
  30.         $status        = new TCombo('status');
  31.         $data_cotacao  = new TDate('data_cotacao');
  32.         //filtro que busca dentro da propria tabela os dados
  33.         //campo        combo de busca  campo que recebe  banco    tabela     chave de busca    campo encontrado    
  34.         $solicitante   = new TDBCombo('solicitante'   'samples''Cotacao''solicitante'  'solicitante');
  35.         $empresa_col   = new TDBCombo('empresa_col'   'samples''Cotacao''empresa_col'  'empresa_col');
  36.         $municipio_col = new TDBCombo('municipio_col' 'samples''Cotacao''municipio_col''municipio_col');
  37.         $uf_col        = new TCombo('uf_col');
  38.         
  39.         //Itens do Status
  40.         $itemStatus= array();
  41.         $itemStatus['Lançado']     = 'Lançado';
  42.         $itemStatus['Emitido']     = 'Emitido';
  43.         $itemStatus['Aprovado']    = 'Aprovado';  
  44.         $status->setValue('Lançado');
  45.         $status->addItems($itemStatus);   
  46.         //Lista de UFs
  47.         $itemUf       = array();
  48.         $itemUf['AC'] = 'AC';
  49.         $itemUf['AL'] = 'AL';
  50.         $itemUf['AM'] = 'AM';
  51.         $itemUf['AP'] = 'AP';
  52.         $itemUf['BA'] = 'BA';
  53.         $itemUf['CE'] = 'CE';
  54.         $itemUf['DF'] = 'DF';
  55.         $itemUf['ES'] = 'ES';
  56.         $itemUf['EX'] = 'EX';
  57.         $itemUf['GO'] = 'GO';
  58.         $itemUf['MA'] = 'MA';
  59.         $itemUf['MG'] = 'MG';
  60.         $itemUf['MS'] = 'MS';
  61.         $itemUf['MT'] = 'MT';
  62.         $itemUf['PA'] = 'PA';
  63.         $itemUf['PB'] = 'PB';
  64.         $itemUf['PE'] = 'PE';
  65.         $itemUf['PI'] = 'PI';
  66.         $itemUf['PR'] = 'PR';
  67.         $itemUf['RJ'] = 'RJ';
  68.         $itemUf['RN'] = 'RN';
  69.         $itemUf['RO'] = 'RO';
  70.         $itemUf['RR'] = 'RR';
  71.         $itemUf['RS'] = 'RS';
  72.         $itemUf['SC'] = 'SC';
  73.         $itemUf['SE'] = 'SE';
  74.         $itemUf['SP'] = 'SP';
  75.         $itemUf['TO'] = 'TO';      
  76.         $uf_col->addItems($itemUf);
  77.         //Mascara da data
  78.         $data_cotacao -> setMask('dd/mm/yyyy');
  79.         // add the fields
  80.         $this->form->addQuickField('Número'$id,  200 );
  81.         $this->form->addQuickField('Status'$status,  200 );
  82.         $this->form->addQuickField('Solicitante'$solicitante,  200 );
  83.         $this->form->addQuickField('Empresa de Coleta'$empresa_col,  200 );
  84.         $this->form->addQuickField('UF de Coleta'$uf_col,  200 );
  85.         $this->form->addQuickField('Cidade de Coleta'$municipio_col,  200 );
  86.         $this->form->addQuickField('Data de Cotação'$data_cotacao,  180 );
  87.         
  88.         // keep the form filled during navigation with session data
  89.         $this->form->setDataTSession::getValue('Cotacao_filter_data') );
  90.         
  91.         // add the search form actions
  92.         $this->form->addQuickAction(_t('Find'), new TAction(array($this'onSearch')), 'fa:search');
  93.         $this->form->addQuickAction(_t('New'),  new TAction(array('CotacaoForm''onEdit')), 'bs:plus-sign green');
  94.         
  95.         // creates a Datagrid
  96.         $this->datagrid = new TDataGrid;
  97.         
  98.         $this->datagrid->style 'width: 100%';
  99.         $this->datagrid->setHeight(320);
  100.         // $this->datagrid->datatable = 'true';
  101.         // $this->datagrid->enablePopover('Popover', 'Hi <b> {name} </b>');
  102.         
  103.         // creates the datagrid columns
  104.         $column_id               = new TDataGridColumn('id''Número''right');
  105.         $column_status           = new TDataGridColumn('status''Status''left');
  106.         $column_data_cotacao     = new TDataGridColumn('data_cotacao''Data''left');
  107.         $column_solicitante      = new TDataGridColumn('solicitante''Solicitante''left');
  108.         $column_customer_cnpj    = new TDataGridColumn('customer_cnpj''C.N.P.J''left');
  109.         $column_contato          = new TDataGridColumn('contato''Contato''left');
  110.         $column_telefone         = new TDataGridColumn('telefone''Telefone''left');
  111.         $column_email            = new TDataGridColumn('email''Email''left');
  112.         $column_observacoes      = new TDataGridColumn('observacoes''Observações''left');
  113.         $column_empresa_col      = new TDataGridColumn('empresa_col''Empresa de Coleta''left');
  114.         $column_uf_col           = new TDataGridColumn('uf_col''UF de Coleta''left');
  115.         $column_municipio_col    = new TDataGridColumn('municipio_col''Cidade de Coleta''left');
  116.         $column_produto_id       = new TDataGridColumn('produto_id''Produto''right');
  117.         $column_grnatureza_id    = new TDataGridColumn('grnatureza_id''Grupo de Natureza''right');
  118.         $column_embalagem_id     = new TDataGridColumn('embalagem_id''Embalagem''right');
  119.         $column_distancia        = new TDataGridColumn('distancia''Distância''right');
  120.         $column_prod_quimico     = new TDataGridColumn('prod_quimico''Químico''left');
  121.         $column_onu              = new TDataGridColumn('onu''Onu''left');
  122.         $column_volume           = new TDataGridColumn('volume''Volume''right');
  123.         $column_peso             = new TDataGridColumn('peso''Peso''right');
  124.         $column_cubagem          = new TDataGridColumn('cubagem''Cubagem''right');
  125.         $column_pesocubado       = new TDataGridColumn('pesocubado''Peso Cubado''right');
  126.         $column_valor_nf         = new TDataGridColumn('valor_nf''Valor da NF-e''right');
  127.         $column_comentarios      = new TDataGridColumn('comentarios''Comentários''left');
  128.         $column_frete_total      = new TDataGridColumn('frete_total''Frete Total''right');
  129.         // Columas do DataGrid
  130.         $this->datagrid->addColumn($column_id);
  131.         $this->datagrid->addColumn($column_status);
  132.         $this->datagrid->addColumn($column_data_cotacao);
  133.         $this->datagrid->addColumn($column_solicitante);
  134.         $this->datagrid->addColumn($column_empresa_col);
  135.         $this->datagrid->addColumn($column_contato);
  136.         $this->datagrid->addColumn($column_telefone);
  137.         $this->datagrid->addColumn($column_prod_quimico);
  138.         $this->datagrid->addColumn($column_frete_total);
  139.         //$this->datagrid->addColumn($column_email);
  140.         //$this->datagrid->addColumn($column_observacoes);
  141.         //$this->datagrid->addColumn($column_uf_col);
  142.         //$this->datagrid->addColumn($column_municipio_col);
  143.         //$this->datagrid->addColumn($column_produto_id);
  144.         //$this->datagrid->addColumn($column_grnatureza_id);
  145.         //$this->datagrid->addColumn($column_embalagem_id);
  146.         //$this->datagrid->addColumn($column_distancia);
  147.         //$this->datagrid->addColumn($column_onu);
  148.         //$this->datagrid->addColumn($column_volume);
  149.         //$this->datagrid->addColumn($column_peso);
  150.         //$this->datagrid->addColumn($column_cubagem);
  151.         //$this->datagrid->addColumn($column_pesocubado);
  152.         //$this->datagrid->addColumn($column_valor_nf);
  153.         //$this->datagrid->addColumn($column_comentarios);
  154.         //$this->datagrid->addColumn($column_customer_cnpj);
  155.         
  156.         // create EDIT action
  157.         $action_edit = new TDataGridAction(array('CotacaoForm''onEdit'));
  158.         $action_edit->setUseButton(TRUE);
  159.         $action_edit->setButtonClass('btn btn-default');
  160.         //$action_edit->setLabel(_t('Edit'));
  161.         $action_edit->setImage('fa:pencil-square-o blue fa-lg');
  162.         $action_edit->setField('id');
  163.         $this->datagrid->addAction($action_edit);
  164.         
  165.         /*
  166.         // create DELETE action
  167.         $action_del = new TDataGridAction(array($this, 'onDelete'));
  168.         $action_del->setUseButton(TRUE);
  169.         $action_del->setButtonClass('btn btn-default');
  170.         //$action_del->setLabel(_t('Delete'));
  171.         $action_del->setImage('fa:trash-o red fa-lg');
  172.         $action_del->setField('id');
  173.         $this->datagrid->addAction($action_del);
  174.         */
  175.         
  176.         // create the datagrid model
  177.         $this->datagrid->createModel();
  178.         
  179.         // creates the page navigation
  180.         $this->pageNavigation = new TPageNavigation;
  181.         $this->pageNavigation->setAction(new TAction(array($this'onReload')));
  182.         $this->pageNavigation->setWidth($this->datagrid->getWidth());
  183.         
  184.         // Sub menu bonito
  185.         $vbox = new TVBox;
  186.         $vbox->add(new TXMLBreadCrumb('menu.xml'__CLASS__));
  187.         $vbox->add($this->form);
  188.         $vbox->style 'width: 100%';       
  189.         $vbox->add($this->datagrid);
  190.         $vbox->add($this->pageNavigation);
  191.         parent::add($vbox);  
  192.     }
  193.     
  194.     /**
  195.      * Inline record editing
  196.      * @param $param Array containing:
  197.      *              key: object ID value
  198.      *              field name: object attribute to be updated
  199.      *              value: new attribute content 
  200.      */
  201.     public function onInlineEdit($param)
  202.     {
  203.         try
  204.         {
  205.             // get the parameter $key
  206.             $field $param['field'];
  207.             $key   $param['key'];
  208.             $value $param['value'];
  209.             
  210.             TTransaction::open('samples'); // open a transaction with database
  211.             $object = new Cotacao($key); // instantiates the Active Record
  212.             $object->data_cotacao TDate::date2br($object->data_cotacao);
  213.             $object->{$field} = $value;
  214.             $object->store(); // update the object in the database
  215.             TTransaction::close(); // close the transaction
  216.             
  217.             $this->onReload($param); // reload the listing
  218.             new TMessage('info'"Record Updated");
  219.         }
  220.         catch (Exception $e// in case of exception
  221.         {
  222.             new TMessage('error''<b>Error</b> ' $e->getMessage()); // shows the exception error message
  223.             TTransaction::rollback(); // undo all pending operations
  224.         }
  225.     }
  226.     
  227.     /**
  228.      * Register the filter in the session
  229.      */
  230.     public function onSearch()
  231.     {
  232.         // get the search form data
  233.         $data $this->form->getData();
  234.         
  235.         // clear session filters
  236.         TSession::setValue('CotacaoFormView_filter_id',   NULL);
  237.         TSession::setValue('CotacaoFormView_filter_status',   NULL);
  238.         TSession::setValue('CotacaoFormView_filter_data_cotacao',   NULL);
  239.         TSession::setValue('CotacaoFormView_filter_solicitante',   NULL);
  240.         TSession::setValue('CotacaoFormView_filter_empresa_col',   NULL);
  241.         TSession::setValue('CotacaoFormView_filter_uf_col',   NULL);
  242.         TSession::setValue('CotacaoFormView_filter_municipio_col',   NULL);
  243.         if (isset($data->id) AND ($data->id)) {
  244.             $filter = new TFilter('id''like'"%{$data->id}%"); // create the filter
  245.             TSession::setValue('CotacaoFormView_filter_id',   $filter); // stores the filter in the session
  246.         }
  247.         if (isset($data->status) AND ($data->status)) {
  248.             $filter = new TFilter('status''like'"%{$data->status}%"); // create the filter
  249.             TSession::setValue('CotacaoFormView_filter_status',   $filter); // stores the filter in the session
  250.         }
  251.         if (isset($data->data_cotacao) AND ($data->data_cotacao)) {
  252.             $data->data_cotacao TDate::date2us($data->data_cotacao);//Muda para o formato USA
  253.             $filter = new TFilter('data_cotacao''like'"%{$data->data_cotacao}%"); // create the filter
  254.             $data->data_cotacao TDate::date2br($data->data_cotacao);//Volta para o formato BRA
  255.             TSession::setValue('CotacaoFormView_filter_data_cotacao',   $filter); // stores the filter in the session
  256.         }
  257.         if (isset($data->solicitante) AND ($data->solicitante)) {
  258.             $filter = new TFilter('solicitante''like'"%{$data->solicitante}%"); // create the filter
  259.             TSession::setValue('CotacaoFormView_filter_solicitante',   $filter); // stores the filter in the session
  260.         }
  261.         if (isset($data->empresa_col) AND ($data->empresa_col)) {
  262.             $filter = new TFilter('empresa_col''like'"%{$data->empresa_col}%"); // create the filter
  263.             TSession::setValue('CotacaoFormView_filter_empresa_col',   $filter); // stores the filter in the session
  264.         }
  265.         if (isset($data->uf_col) AND ($data->uf_col)) {
  266.             $filter = new TFilter('uf_col''like'"%{$data->uf_col}%"); // create the filter
  267.             TSession::setValue('CotacaoFormView_filter_uf_col',   $filter); // stores the filter in the session
  268.         }
  269.         if (isset($data->municipio_col) AND ($data->municipio_col)) {
  270.             $filter = new TFilter('municipio_col''like'"%{$data->municipio_col}%"); // create the filter
  271.             TSession::setValue('CotacaoFormView_filter_municipio_col',   $filter); // stores the filter in the session
  272.         }
  273.         
  274.         // fill the form with data again
  275.         $this->form->setData($data);
  276.         
  277.         // keep the search data in the session
  278.         TSession::setValue('Cotacao_filter_data'$data);
  279.         
  280.         $param=array();
  281.         $param['offset']    =0;
  282.         $param['first_page']=1;
  283.         $this->onReload($param);
  284.     }
  285.     
  286.     /**
  287.      * Load the datagrid with data
  288.      */
  289.     public function onReload($param NULL)
  290.     {
  291.         try
  292.         {
  293.             // open a transaction with database 'samples'
  294.             TTransaction::open('samples');
  295.             
  296.             // creates a repository for Cotacao
  297.             $repository = new TRepository('Cotacao');
  298.             $limit 10;
  299.             // creates a criteria
  300.             
  301.             $criteria = new TCriteria;    
  302.             
  303.             // default order
  304.             if (empty($param['order']))
  305.             {
  306.                 $param['order'] = 'id';
  307.                 $param['direction'] = 'asc';
  308.             }
  309.             $criteria->setProperties($param); // order, offset
  310.             $criteria->setProperty('limit'$limit);
  311.             
  312.             if (TSession::getValue('CotacaoFormView_filter_id')) {
  313.                 $criteria->add(TSession::getValue('CotacaoFormView_filter_id')); // add the session filter
  314.             }
  315.             if (TSession::getValue('CotacaoFormView_filter_status')) {
  316.                 $criteria->add(TSession::getValue('CotacaoFormView_filter_status')); // add the session filter
  317.             }
  318.             if (TSession::getValue('CotacaoFormView_filter_data_cotacao')) {
  319.                 $criteria->add(TSession::getValue('CotacaoFormView_filter_data_cotacao')); // add the session filter
  320.             }
  321.             if (TSession::getValue('CotacaoFormView_filter_solicitante')) {
  322.                 $criteria->add(TSession::getValue('CotacaoFormView_filter_solicitante')); // add the session filter
  323.             }
  324.             if (TSession::getValue('CotacaoFormView_filter_empresa_col')) {
  325.                 $criteria->add(TSession::getValue('CotacaoFormView_filter_empresa_col')); // add the session filter
  326.             }
  327.             if (TSession::getValue('CotacaoFormView_filter_uf_col')) {
  328.                 $criteria->add(TSession::getValue('CotacaoFormView_filter_uf_col')); // add the session filter
  329.             }
  330.             if (TSession::getValue('CotacaoFormView_filter_municipio_col')) {
  331.                 $criteria->add(TSession::getValue('CotacaoFormView_filter_municipio_col')); // add the session filter
  332.             }
  333.             
  334.             // load the objects according to criteria
  335.             $objects $repository->load($criteriaFALSE);
  336.             
  337.             if (is_callable($this->transformCallback))
  338.             {
  339.                 call_user_func($this->transformCallback$objects$param);
  340.             }
  341.             
  342.             $this->datagrid->clear();
  343.             if ($objects)
  344.             {
  345.                 // iterate the collection of active records
  346.                 foreach ($objects as $object)
  347.                 {
  348.                     // add the object inside the datagrid // converta a data para dd/mm/yyyy e exibe
  349.                     $object->data_cotacao TDate::date2br($object->data_cotacao);
  350.                     $this->datagrid->addItem($object);
  351.                 }
  352.             }
  353.             
  354.             // reset the criteria for record count
  355.             $criteria->resetProperties();
  356.             $count$repository->count($criteria);
  357.             
  358.             $this->pageNavigation->setCount($count); // count of records
  359.             $this->pageNavigation->setProperties($param); // order, page
  360.             $this->pageNavigation->setLimit($limit); // limit
  361.             
  362.             // close the transaction
  363.             TTransaction::close();
  364.             $this->loaded true;
  365.         }
  366.         catch (Exception $e// in case of exception
  367.         {
  368.             // shows the exception error message
  369.             new TMessage('error'$e->getMessage());
  370.             // undo all pending operations
  371.             TTransaction::rollback();
  372.         }
  373.     }
  374.     
  375.     /**
  376.      * Ask before deletion
  377.      */
  378.     public function onDelete($param)
  379.     {
  380.         // define the delete action
  381.         $action = new TAction(array($this'Delete'));
  382.         $action->setParameters($param); // pass the key parameter ahead
  383.         
  384.         // shows a dialog to the user
  385.         new TQuestion(AdiantiCoreTranslator::translate('Do you really want to delete ?'), $action);
  386.     }
  387.     
  388.     /**
  389.      * Delete a record
  390.      */
  391.     public function Delete($param)
  392.     {
  393.         try
  394.         {
  395.             $key=$param['key']; // get the parameter $key
  396.             TTransaction::open('samples'); // open a transaction with database
  397.             $object = new Cotacao($keyFALSE); // instantiates the Active Record
  398.             $object->delete(); // deletes the object from the database
  399.             TTransaction::close(); // close the transaction
  400.             $this->onReload$param ); // reload the listing
  401.             new TMessage('info'AdiantiCoreTranslator::translate('Record deleted')); // success message
  402.         }
  403.         catch (Exception $e// in case of exception
  404.         {
  405.             new TMessage('error'$e->getMessage()); // shows the exception error message
  406.             TTransaction::rollback(); // undo all pending operations
  407.         }
  408.     }
  409.     
  410.     
  411.     /**
  412.      * method show()
  413.      * Shows the page
  414.      */
  415.     public function show()
  416.     {
  417.         // check if the datagrid is already loaded
  418.         if (!$this->loaded AND (!isset($_GET['method']) OR !(in_array($_GET['method'],  array('onReload''onSearch')))) )
  419.         {
  420.             if (func_num_args() > 0)
  421.             {
  422.                 $this->onReloadfunc_get_arg(0) );
  423.             }
  424.             else
  425.             {
  426.                 $this->onReload();
  427.             }
  428.         }
  429.         parent::show();
  430.     }
  431. }
  432.  </your>
IF

Entendi, então faça assim:

No início do programa declare os campos que vc vai querer manipular como private:

  1. <?php
  2.   class CotacaoForm extends TPage
  3.   {
  4.       private $form// form
  5.       private $frete_total;
  6. ?>


Depois declare as variáveis dos campos com o this:

  1. <?php
  2.   $this->frete_valor = new TEntry('frete_valor');
  3. ?>


Na function onEdit(), vc faz a verificação do status e altera o atributo dos campos:

  1. <?php
  2.    ...
  3.    if (isset($param['key']))
  4.             {
  5.                 $key $param['key'];  // get the parameter $key
  6.                 TTransaction::open('samples'); // open a transaction
  7.                 $object = new Cotacao($key); // instantiates the Active Record
  8.                 $object->data_cotacao TDate::date2br($object->data_cotacao);
  9.                //Aqui vc faz a verificação
  10.                if ($object->status=='Aprovado')
  11.               {
  12.                    $this->frete_valor->setEditable(FALSE);
  13.                   ...
  14.               }
  15.                 $this->form->setData($object); // fill the form
  16.                 TTransaction::close(); // close the transaction
  17.             }
  18.             ...
  19. ?>


Acho que é isso
RF

Boa noite Ivan, muito obrigado mais uma vez. Deu certo, aprendi mais algumas coisas.
Na verdade para esse momento vou fazer algo diferente. Só não vou permitir que o registro seja gravado se o Status for igual a Lançado, para a próxima tela (Ordens de coleta e Romaneio) vou usar esse conceito que entendi.
Amanhã publico a versão corrigida, se desejar dar uma olhada no meu trabalho entre em transpalog.esy.es usuário convidado, senha convidado.
Até a próxima dúvida... rssss
IF

Ok Robson, vou dar uma olhada. Abraço