Lançado Adianti Framework 7.6!
Clique aqui para saber mais
Erro: Classe Item não encontrada em Adianti\Widget\Form\TForm:: Criei um relatório de digitação de coletas, tenho uma aba onde uma grid lista as diversas NF-es que serão coletadas. Porém não consigo gravar os dados, segue a tela com o erro (Classe Item não encontrada em Adianti\Widget\Form\TForm::getData) e o código do formulário. ...
WF
Erro: Classe Item não encontrada em Adianti\Widget\Form\TForm::  
Fechado
Criei um relatório de digitação de coletas, tenho uma aba onde uma grid lista as diversas NF-es que serão coletadas. Porém não consigo gravar os dados, segue a tela com o erro (Classe Item não encontrada em Adianti\Widget\Form\TForm::getData) e o código do formulário.

  1. <?php
  2. class ColetaForm extends TPage
  3. {
  4.     private    $form// form
  5.     private    $frete_total;
  6.     private    $detail_list;
  7.     
  8.     function __construct()
  9.     {
  10.         parent::__construct();
  11.         
  12.         // creates the form
  13.         $this->form = new TForm('form_coleta');
  14.         $this->form->class 'tform';
  15.                    
  16.         // cria as tabelas
  17.         $table_data     = new TTable;
  18.         $table_destino  = new TTable;
  19.         $table_carga    = new TTable;
  20.         $table_frete    = new TTable;
  21.         $table_diversos = new TTable;
  22.         $table_nfe      = new TTable;
  23.         
  24.         //Tamanho do notebook
  25.         $notebook = new TNotebook(500250);
  26.        
  27.         // adiciona as abas do notebook
  28.         $this->form->add($notebook);
  29.         
  30.         // Adiciona o nome das abas do notebook 
  31.         $notebook->appendPage('Solicitante'$table_data);
  32.         $notebook->appendPage('Destino'$table_destino);
  33.         $notebook->appendPage('Carga',$table_carga);
  34.         $notebook->appendPage('NF-es',$table_nfe);
  35.         $notebook->appendPage('Frete'$table_frete);
  36.         $notebook->appendPage('Diversos',$table_diversos);
  37.         
  38.         // campos do formulário
  39.         2425               = new TEntry('id');
  40.         $customer_cnpj    = new TSeekButton('customer_cnpj');
  41.         $status           = new TEntry('status');
  42.         $observacoes      = new TText('observacoes');
  43.         $solicitante      = new TEntry('solicitante');
  44.         $address          = new TEntry('address');
  45.         $numero           = new TEntry('numero');
  46.         $complemento      = new TEntry('complemento');
  47.         $bairro           = new TEntry('bairro');
  48.         $cep              = new TEntry('cep');
  49.         $uf               = new TCombo('uf');
  50.         $municipio        = new TEntry('municipio');
  51.         $contato          = new TEntry('contato');
  52.         $telefone         = new TEntry('telefone');
  53.         $email            = new TEntry('email');
  54.         $empresa_col      = new TEntry('empresa_col');
  55.         $customercol_cnpj = new TSeekButton('customercol_cnpj');
  56.         $address_col      = new TEntry('address_col');
  57.         $numero_col       = new TEntry('numero_col');
  58.         $complemento_col  = new TEntry('complemento_col');
  59.         $bairro_col       = new TEntry('bairro_col');
  60.         $cep_col          = new TEntry('cep_col');
  61.         $uf_col           = new TCombo('uf_col');
  62.         $municipio_col    = new TEntry('municipio_col');
  63.         $produto_id       = new TDBCombo('produto_id'   'samples''produto'    'id''name');//busca o produto 
  64.         $grnatureza_id    = new TDBCombo('grnatureza_id''samples''Grunatureza''id''name');//busca a natureza
  65.         $embalagem_id     = new TDBCombo('embalagem_id' 'samples''Embalagem'  'id''name');//busca a embalagem
  66.         $distancia        = new TEntry('distancia');
  67.         $prod_quimico     = new TCombo('prod_quimico');
  68.         $onu              = new TEntry('onu');
  69.         //dados da nfe
  70.         $nfe              = new TEntry('nfe');
  71.         $serie            = new TEntry('serie');
  72.         $data_nfe         = new TDate('data_nfe');
  73.         $volume           = new TEntry('volume');
  74.         $peso             = new TEntry('peso');
  75.         $comprimento      = new TEntry('comprimento');
  76.         $largura          = new TEntry('largura');    
  77.         $altura           = new TEntry('altura');
  78.         $peso_cubico      = new TEntry('peso_cubico');  
  79.         $peso_cubado      = new TEntry('peso_cubado');  
  80.         $valor_nf         = new TEntry('valor_nf');
  81.         //frete a cobrar
  82.         $comentarios      = new TText('comentarios');
  83.         $fretepeso        = new TEntry('fretepeso');
  84.         $fretevalor       = new TEntry('fretevalor');
  85.         $coleta           = new TEntry('coleta');
  86.         $entrega          = new TEntry('entrega');
  87.         $data_coleta     = new TDate('data_coleta');
  88.         $outros           = new TEntry('outros');
  89.         $cat              = new TEntry('cat');
  90.         $sec_cat          = new TEntry('sec_cat');
  91.         $gris             = new TEntry('gris');
  92.         $txdespacho       = new TEntry('txdespacho');
  93.         $pedagio          = new TEntry('pedagio');
  94.         $perc_icms        = new TEntry('perc_icms');
  95.         $base_icms        = new TEntry('base_icms');
  96.         $valor_icms       = new TEntry('valor_icms');
  97.         //OBS: Diferente para validar
  98.         $this->frete_total= new TEntry('frete_total');
  99.         $alteracao        = new TEntry('alteracao');
  100.                 
  101.         // Tamanho dos campos e desabilitação para editar      
  102.         2425               ->setSize(150);
  103.         2425               ->setEditable(false);
  104.         
  105.         $status           ->setSize(150);
  106.         $data_coleta     ->setSize(133);
  107.         //Dados do Solicitante  
  108.         $solicitante      ->setSize(220);
  109.         $solicitante      ->style "text-transform: uppercase";
  110.         $customer_cnpj    ->setSize(130);
  111.         $address          ->setSize(220);
  112.         $address          ->style "text-transform: uppercase";
  113.         $municipio        ->setSize(220);
  114.         $municipio        ->style "text-transform: uppercase";
  115.         $numero           ->setSize(75);
  116.         $complemento      ->setSize(220);
  117.         $complemento      ->style "text-transform: uppercase";
  118.         $bairro           ->setSize(173);
  119.         $bairro           ->style "text-transform: uppercase";
  120.         $cep              ->setSize(122);
  121.         $uf               ->setSize(50);
  122.         $uf               ->style "text-transform: uppercase"
  123.         $contato          ->setSize(220);
  124.         $contato          ->style "text-transform: uppercase";
  125.         $telefone         ->setSize(155);
  126.         $email            ->setSize(220);
  127.         $email            ->style "text-transform: lowercase";
  128.         //Dados do destino
  129.         $empresa_col      ->setSize(220);
  130.         $empresa_col      ->style "text-transform: uppercase"
  131.         $customercol_cnpj ->setSize(130);
  132.         $address_col      ->setSize(220);
  133.         $address_col      ->style "text-transform: uppercase";
  134.         $municipio_col    ->setSize(220);
  135.         $municipio_col    ->style "text-transform: uppercase";
  136.         $numero_col       ->setSize(75);
  137.         $complemento_col  ->setSize(220);
  138.         $complemento_col  ->style "text-transform: uppercase";
  139.         $bairro_col       ->setSize(173);
  140.         $bairro_col       ->style "text-transform: uppercase";
  141.         $cep_col          ->setSize(122);
  142.         $uf_col           ->setSize(50);
  143.         $uf_col           ->style "text-transform: uppercase";
  144.         //Dados do produto
  145.         $produto_id       ->setSize(350);
  146.         $grnatureza_id    ->setSize(350);
  147.         $embalagem_id     ->setSize(220);
  148.         $distancia        ->setSize(90);
  149.         $prod_quimico     ->setSize(144);
  150.         $onu              ->setSize(145);
  151.         $observacoes      ->setSize(350);
  152.         //Dados da NF-e
  153.         $nfe              ->setSize(100);//colocar  
  154.         $serie            ->setSize(44); //colocar
  155.         $data_nfe         ->setSize(124);//colocar
  156.         $volume           ->setSize(144);
  157.         $peso             ->setSize(146); 
  158.         $peso_cubico      ->setSize(144);
  159.         $peso_cubado      ->setSize(146);
  160.         $comprimento      ->setSize(44);
  161.         $largura          ->setSize(44);
  162.         $altura           ->setSize(44);
  163.         $valor_nf         ->setSize(146);
  164.         //Dados do frete
  165.         $fretepeso        ->setSize(150); 
  166.         $fretevalor       ->setSize(150);
  167.         $coleta           ->setSize(150);
  168.         $entrega          ->setSize(150);
  169.         $txdespacho       ->setSize(150);
  170.         $outros           ->setSize(150); 
  171.         $cat              ->setSize(150);
  172.         $sec_cat          ->setSize(150);
  173.         $gris             ->setSize(150);
  174.         $pedagio          ->setSize(150);
  175.         $perc_icms        ->setSize(150);
  176.         $base_icms        ->setSize(150);
  177.         $valor_icms       ->setSize(150);
  178.         //OBS: Diferente para validar
  179.         $this->frete_total ->setSize(150);
  180.         //Demais informações
  181.         $alteracao        ->setSize(150);
  182.         $comentarios      ->setSize(350);
  183.                 
  184.         //Lista de UFs
  185.         $itemUf       = array();
  186.         $itemUf['AC'] = 'AC';
  187.         $itemUf['AL'] = 'AL';
  188.         $itemUf['AM'] = 'AM';
  189.         $itemUf['AP'] = 'AP';
  190.         $itemUf['BA'] = 'BA';
  191.         $itemUf['CE'] = 'CE';
  192.         $itemUf['DF'] = 'DF';
  193.         $itemUf['ES'] = 'ES';
  194.         $itemUf['EX'] = 'EX';
  195.         $itemUf['GO'] = 'GO';
  196.         $itemUf['MA'] = 'MA';
  197.         $itemUf['MG'] = 'MG';
  198.         $itemUf['MS'] = 'MS';
  199.         $itemUf['MT'] = 'MT';
  200.         $itemUf['PA'] = 'PA';
  201.         $itemUf['PB'] = 'PB';
  202.         $itemUf['PE'] = 'PE';
  203.         $itemUf['PI'] = 'PI';
  204.         $itemUf['PR'] = 'PR';
  205.         $itemUf['RJ'] = 'RJ';
  206.         $itemUf['RN'] = 'RN';
  207.         $itemUf['RO'] = 'RO';
  208.         $itemUf['RR'] = 'RR';
  209.         $itemUf['RS'] = 'RS';
  210.         $itemUf['SC'] = 'SC';
  211.         $itemUf['SE'] = 'SE';
  212.         $itemUf['SP'] = 'SP';
  213.         $itemUf['TO'] = 'TO';      
  214.         $uf    ->addItems($itemUf);//Estado do solicitante
  215.         $uf_col->addItems($itemUf);//Estado do destinatário
  216.         //Mascaras de entrada, campos obrigatórios, validações
  217.         $fretepeso          ->setNumericMask(2',''.',true);
  218.         $fretevalor         ->setNumericMask(2',''.',true);
  219.         $coleta             ->setNumericMask(2',''.',true);
  220.         $entrega            ->setNumericMask(2',''.',true);
  221.         $txdespacho         ->setNumericMask(2',''.',true);
  222.         $outros             ->setNumericMask(2',''.',true);
  223.         $cat                ->setNumericMask(2',''.',true);
  224.         $sec_cat            ->setNumericMask(2',''.',true);
  225.         $gris               ->setNumericMask(2',''.',true);
  226.         $pedagio            ->setNumericMask(2',''.',true);
  227.         $valor_icms         ->setNumericMask(2',''.',true);
  228.         //Obs: Diferente para validar
  229.         $this->frete_total  ->setNumericMask(2',''.',true);
  230.         $valor_nf           ->setNumericMask(2',''.',true); 
  231.         $base_icms          ->setNumericMask(2',''.',true); 
  232.         $perc_icms          ->setNumericMask(2',''.',true); 
  233.         $peso_cubico        ->setNumericMask(2',','.' ,true);
  234.         $peso_cubado        ->setNumericMask(2',','.' ,true); 
  235.         $comprimento        ->setNumericMask(2',','.' ,true);
  236.         $largura            ->setNumericMask(2',','.' ,true);
  237.         $altura             ->setNumericMask(2',','.' ,true);  
  238.         $status             ->setValue('Lançado');
  239.         $data_coleta       ->setMask('dd/mm/yyyy');
  240.         $cep                ->setMask('99999-999');
  241.         $telefone           ->setMask('(99)9999-9999');
  242.         $cep_col            ->setMask('99999-999');
  243.         //Validação dos campos
  244.         $email              ->addValidation('E-mail',new TEmailValidator);
  245.         $data_coleta       ->addValidation('Data de solicitação', new TRequiredValidator);
  246.         $solicitante        ->addValidation('R.Z Social', new TRequiredValidator);
  247.         $address            ->addValidation('Endereço', new TRequiredValidator);
  248.         $municipio          ->addValidation('Cidade', new TRequiredValidator);
  249.         $numero             ->addValidation('Número', new TRequiredValidator);
  250.         $bairro             ->addValidation('Bairro', new TRequiredValidator);
  251.         $cep                ->addValidation('C.E.P', new TRequiredValidator);
  252.         $uf                 ->addValidation('UF', new TRequiredValidator);
  253.         $contato            ->addValidation('Contato', new TRequiredValidator);
  254.         $telefone           ->addValidation('Telefone', new TRequiredValidator);
  255.         $empresa_col        ->addValidation('R.Z Social do Destinatário', new TRequiredValidator);
  256.         $address_col        ->addValidation('Endereço do Destinatário', new TRequiredValidator);
  257.         $municipio_col      ->addValidation('Cidade do Destinatário', new TRequiredValidator);
  258.         $numero_col         ->addValidation('Número do Destinatário', new TRequiredValidator);
  259.         $bairro_col         ->addValidation('Bairro do Destinatário', new TRequiredValidator);
  260.         $cep_col            ->addValidation('C.E.P do Destinatário', new TRequiredValidator);
  261.         $uf_col             ->addValidation('UF do Destinatário', new TRequiredValidator);
  262.         $produto_id         ->addValidation('Produto', new TRequiredValidator);
  263.         $grnatureza_id      ->addValidation('Grupo', new TRequiredValidator);
  264.         $embalagem_id       ->addValidation('Embalagem', new TRequiredValidator);
  265.         $prod_quimico       ->addValidation('Químico', new TRequiredValidator);
  266.         $volume             ->addValidation('Volume', new TRequiredValidator);
  267.         $peso               ->addValidation('Peso', new TRequiredValidator);
  268.         $valor_nf           ->addValidation('Valor da NF-e', new TRequiredValidator); 
  269.         //Ação dos campos ao perder o foco
  270.         $altura             ->setExitAction(new TAction(array($this'onCubagem'   )));
  271.         $peso_cubico        ->setExitAction(new TAction(array($this'onPesocubado')));
  272.         
  273.         //Objeto para criar o campo de busca de solicitante e destinatário por cnpj ou rz social
  274.         $obj = new SolicitanteCol//
  275.         $customer_cnpj->setAction(new TAction(array($obj'onReload')));
  276.         
  277.         $obj2 = new Destinatario//
  278.         $customercol_cnpj->setAction(new TAction(array($obj2'onReload')));       
  279.         
  280.         //Botão da Grid - Aba NF-e
  281.         $btn_inclui_nfe = new TButton('btn_inclui_nfe');
  282.         $btn_inclui_nfe->setAction(new TAction(array($this'onIncluiNFe')), 'Incluir');
  283.         $btn_inclui_nfe->setImage('fa:save');
  284.         
  285.         //Itens do químico
  286.         $itemQ= array();
  287.         $itemQ['Não']  = 'Não';
  288.         $itemQ['Sim']  = 'Sim';  
  289.         $prod_quimico->setValue('Não');
  290.         $prod_quimico->addItems($itemQ); 
  291.             
  292.         //Valores padrões para os campos de calculo do frete, isso evita o erro da linha 79
  293.         $fretepeso        ->setValue('0'); 
  294.         $fretevalor       ->setValue('0');
  295.         $coleta           ->setValue('0');
  296.         $entrega          ->setValue('0');
  297.         $txdespacho       ->setValue('0');
  298.         $outros           ->setValue('0'); 
  299.         $cat              ->setValue('0');
  300.         $sec_cat          ->setValue('0');
  301.         $gris             ->setValue('0');
  302.         $pedagio          ->setValue('0');
  303.         $valor_icms       ->setValue('0');
  304.         $this->frete_total->setValue('0');
  305.         $valor_nf         ->setValue('0');
  306.         $base_icms        ->setValue('0');
  307.         $comprimento      ->setValue('0');   
  308.         $largura          ->setValue('0');  
  309.         $altura           ->setValue('0');
  310.         $peso_cubico      ->setValue('0');
  311.         $peso_cubado      ->setValue('0'); 
  312.         $perc_icms        ->setValue('12');
  313.         $status           ->setValue('Lançado');
  314.         $alteracao        ->setValue(date('d-m-Y / H:i'));    
  315.         $alteracao        ->setEditable(FALSE);
  316.         $base_icms        ->setEditable(FALSE);
  317.         $valor_icms       ->setEditable(FALSE);
  318.         $comentarios      ->setEditable(FALSE);
  319.         $status           ->setEditable(FALSE);
  320.               
  321.         // Campos da Aba Solicitante
  322.         $table_data->addRowSet(new TLabel(''));
  323.         $table_data->addRowSet(new TLabel('Número:')     ,array(2425,           new TLabel('Data de solicitação :'),$data_coleta));
  324.         $table_data->addRowSet(new TLabel('CNPJ:')       ,array($customer_cnpj,new TLabel('Rz Social:'),$solicitante));        
  325.         $table_data->addRowSet(new TLabel('Endereço:')   ,array($address,      new TLabel('Número do endereço:'),$numero));
  326.         $table_data->addRowSet(new TLabel('Complemento:'),array($complemento));
  327.         $table_data->addRowSet(new TLabel('Cidade:')     ,array($municipio,    new TLabel('Bairro:'),$bairro));
  328.         $table_data->addRowSet(new TLabel('Estado:')     ,array($uf,           new TLabel('CEP:'),$cep));
  329.         $table_data->addRowSet(new TLabel('Contato:')    ,array($contato,      new TLabel('Telefone :'),$telefone));
  330.         $table_data->addRowSet(new TLabel('E-mail:')     ,$email);
  331.         
  332.         // Campos da Aba Destino
  333.         $table_destino->addRowSet(new TLabel(''));
  334.         $table_destino->addRowSet(new TLabel('CNPJ:')       ,array($customercol_cnpj, new TLabel('Rz Social:'),$empresa_col));        
  335.         $table_destino->addRowSet(new TLabel('Endereço:')   ,array($address_col,      new TLabel('Número do endereço:'),$numero_col));
  336.         $table_destino->addRowSet(new TLabel('Complemento:'),array($complemento_col));
  337.         $table_destino->addRowSet(new TLabel('Cidade:')     ,array($municipio_col,    new TLabel('Bairro:'),$bairro_col));
  338.         $table_destino->addRowSet(new TLabel('Estado:')     ,array($uf_col,           new TLabel('CEP:'),$cep_col));
  339.         // Campos da Aba carga
  340.         $table_carga->addRowSet(new TLabel(''));
  341.         $table_carga->addRowSet(new TLabel('Produto:')  ,array($produto_id));  
  342.         $table_carga->addRowSet(new TLabel('Grupo:')    ,array($grnatureza_id) );
  343.         $table_carga->addRowSet(new TLabel('Embalagem:'),array($embalagem_id,  new TLabel('KM:'),$distancia));          
  344.         $table_carga->addRowSet(new TLabel('Químico?')  ,array($prod_quimico,  new TLabel('O.n.U :'),$onu));  
  345.         $table_carga->addRowSet(new TLabel('A carga é:'),array($observacoes));
  346.         // Campos da NF-e  
  347.         $table_nfe->addRowSet(new TLabel(''));        
  348.         $table_nfe->addRowSet(new TLabel('NF-e:')      ,array($nfe         ,new TLabel('Série:'),$serie, new TLabel('Data.:'),$data_nfe));   
  349.         $table_nfe->addRowSet(new TLabel('Volume:')    ,array($volume     ,new TLabel('Peso:') ,$peso));
  350.         $table_nfe->addRowSet(new TLabel('Comp.:')     ,array($comprimento ,new TLabel('Lar.:') , $largura ,new TLabel('Alt.:'), $altura, new TLabel('Valor:'),$valor_nf)); 
  351.         $table_nfe->addRowSet(new TLabel('Cubagem:')   ,array($peso_cubico,new TLabel('Peso cubado.:') ,$peso_cubado));
  352.         $table_nfe->addRowSet(new TLabel('')           ,array($btn_inclui_nfe));
  353.         
  354.         //Cria a Grid da NF-e
  355.         $this->detail_list = new TQuickGrid;
  356.         $this->detail_list->setHeight175 );
  357.         $this->detail_list->makeScrollable();
  358.         $this->detail_list->disableDefaultClick();
  359.         $this->detail_list->addQuickColumn('''edit''left'50);
  360.         $this->detail_list->addQuickColumn('''delete''left'50);
  361.         
  362.         //Itens da Grid da NF-e
  363.         $this->detail_list->addQuickColumn('NF-e''nfe''left'100); 
  364.         $this->detail_list->addQuickColumn('Série''serie''left'30);
  365.         $this->detail_list->addQuickColumn('Valor NF-e''valor_nf''left'100);
  366.         $this->detail_list->addQuickColumn('Data''data_nfe''left'100); 
  367.         $this->detail_list->addQuickColumn('Volume''volume''left'50);
  368.         $this->detail_list->addQuickColumn('Peso''peso''left'50);
  369.         $this->detail_list->addQuickColumn('C''comprimento''left'100);
  370.         $this->detail_list->addQuickColumn('L''largura''left'100);
  371.         $this->detail_list->addQuickColumn('A''altura''left'100);
  372.         $this->detail_list->addQuickColumn('Metro 3''metro_cubico''left'50);
  373.         $this->detail_list->addQuickColumn('Peso 3''peso_cubado''left'100);
  374.        
  375.         $this->detail_list->createModel();
  376.         
  377.         //Adiciona a Grid na Aba NF-e
  378.         $linha=$table_nfe->addRowSet(new TLabel(''));
  379.         $linha->addCell($this->detail_list);
  380.         
  381.         //Campos da Aba Frete
  382.         $table_frete->addRowSet(new TLabel(''));
  383.         $table_frete->addRowSet(new TLabel('Frete Peso:'),array($fretepeso),new TLabel('Frete Valor:') ,array($fretevalor));    //new TLabel('Frete Valor :') ,$fretevalor));  
  384.         $table_frete->addRowSet(new TLabel('Entrega:')   ,array($entrega)  ,new TLabel('T.Despacho:')  ,array($txdespacho));      //);
  385.         $table_frete->addRowSet(new TLabel('Coleta:')    ,array($coleta)   ,new TLabel('Outra taxa:')  ,array($outros));       //);
  386.         $table_frete->addRowSet(new TLabel('C.A.T:')     ,array($cat)      ,new TLabel('Vlr. Pedágio:'),array($pedagio));          //); 
  387.         $table_frete->addRowSet(new TLabel('GRIS:')      ,array($gris)     ,new TLabel('SEC / CAT:')   ,array($sec_cat));         //);         
  388.         $table_frete->addRowSet(new TLabel('')); 
  389.         $table_frete->addRowSet(new TLabel('ICMS (%):')     ,array($perc_icms),new TLabel('ICMS (R$):'),array($valor_icms));  
  390.         $table_frete->addRowSet(new TLabel('Base:')       ,array($base_icms),new TLabel('Total:'),array($this->frete_total));
  391.         $table_frete->addRowSet(new TLabel(''));
  392.         
  393.         // Campos da Aba Diversos
  394.         $table_diversos->addRowSet(new TLabel(''));
  395.         $table_diversos->addRowSet(new TLabel('Status:')      ,array($status));
  396.         $table_diversos->addRowSet(new TLabel('Comentário:')  ,array($comentarios));
  397.         $table_diversos->addRowSet(new TLabel(''));
  398.         $table_diversos->addRowSet(new TLabel('Alterado:')    ,array($alteracao));
  399.          
  400.         //criação das ações dos botões (action button)
  401.         $button1=new TButton('action1');
  402.         $button1->setAction(new TAction(array($this'onSave')), 'Salvar');
  403.         $button1->setImage('fa:floppy-o');
  404.         
  405.         // create an action button (go to list)
  406.         $button2=new TButton('list');
  407.         $button2->setAction(new TAction(array('ConsultaDeColeta''onReload')), 'Consulta de coleta');
  408.         $button2->setImage('fa:table blue');
  409.         
  410.         // create an action button (go to list)
  411.         $button3=new TButton('novo');
  412.         $button3->setAction  (new TAction(array($this'onClear')), _t('New'));//onEdit
  413.         $button3->setImage('bs:plus-sign green');
  414.         
  415.         // Vai chamar a função para calcular o frete
  416.         $button4=new TButton('calcFrete');
  417.         $button4->setAction  (new TAction(array($this'onFrete')), ('Calcula o Frete'));
  418.         $button4->setImage('bs:plus-sign green');
  419.         
  420.         // define os campos que são gravados na model e a variável dos botões
  421.         $this->form->setFields(array(2425$status$customer_cnpj,$solicitante,$observacoes,$address,$numero,$complemento,
  422.         $bairro,$cep,$uf,$contato,
  423.         $telefone,$email,$empresa_col,$customercol_cnpj,$address_col,$numero_col,$complemento_col,$bairro_col,$cep_col,
  424.         $uf_col,$produto_id,$municipio_col,$municipio,
  425.         $grnatureza_id,$embalagem_id,$distancia,$prod_quimico,$onu,$volume,$peso,$peso_cubico,$peso_cubado,$valor_nf,
  426.         $comentarios,$fretepeso,$fretevalor,
  427.         $coleta,$entrega,$txdespacho,$outros,$cat,$sec_cat,$gris,$pedagio,$perc_icms,$valor_icms,$this->frete_total,
  428.         $data_coleta,$alteracao,$btn_inclui_nfe,
  429.         $button1,$button2,$button3,$button4,$altura,$comprimento,$largura,$base_icms));
  430.         
  431.         // coloca os botões
  432.         $subtable = new TTable;
  433.         $row $subtable->addRow();
  434.         $row->addCell($button1);
  435.         $row->addCell($button3);
  436.         $row->addCell($button2);
  437.         $row->addCell($button4);
  438.         
  439.         // Sub menu bonito
  440.         $vbox = new TVBox;
  441.         $vbox->add(new TXMLBreadCrumb('menu.xml'__CLASS__));
  442.         $vbox->add($this->form);
  443.         $vbox->style 'width: 55%';       
  444.         //$vbox->add($this->datagrid); //pra mostra a grid
  445.         $vbox->add($subtable);
  446.         parent::add($vbox);
  447.     }
  448.    
  449.  //*********************** Funções ******************************
  450.     public function onIncluiNFe()
  451.     {
  452.         // obtém os dados do formulário
  453.         $item $this->form->getData('Item');
  454.         // lê variável $list da seção
  455.         $list TSession::getValue('list');
  456.         // acrescenta produto na variável $list
  457.         $list[$item->id_produto]= $item;
  458.         // grava variável $list de volta à seção
  459.         TSession::setValue('list'$list);
  460.         // recarrega a listagem
  461.         $this->onReload();
  462.     }
  463.     
  464.     
  465.     
  466.        
  467.     public function onClear$param // botão novo
  468.     {
  469.         $this->form->clear();//Limpa o formulário
  470.         //Informações padrões a serem preenchidas no formulário
  471.         $perc_icms    12;
  472.         $status       'Lançado';
  473.         $alteracao    date('d-m-Y / H:i');
  474.         //Apresentação e  tratamento do campos 
  475.         $obj = new StdClass;
  476.         $obj->perc_icms  number_format($perc_icms 2',''.');
  477.         $obj->status     $status;
  478.         $obj->alteracao  $alteracao;
  479.         TForm::sendData('form_coleta'$obj);
  480.     }
  481.     
  482.     // Calculo da cubagem    
  483.     static function onCubagem($param)
  484.     {
  485.         $comprimento str_replace(',','.'str_replace('.',''$param['comprimento']));    
  486.         $largura     str_replace(',','.'str_replace('.',''$param['largura'])); 
  487.         $altura      str_replace(',','.'str_replace('.',''$param['altura']));
  488.         $peso_cubico $comprimento $largura $altura;
  489.         
  490.         $obj = new StdClass;
  491.         $obj->peso_cubico number_format($peso_cubico2',''.');
  492.         TForm::sendData('form_coleta'$obj);   
  493.     }
  494.     
  495.     // Calculo do peso cubado    
  496.     static function onPesocubado($param)
  497.     {
  498.         $peso_cubico str_replace(',','.'str_replace('.',''$param['peso_cubico']));    
  499.         $peso_cubado  $peso_cubico 300;
  500.         $obj = new StdClass;
  501.         $obj->peso_cubado number_format($peso_cubado2',''.');
  502.         TForm::sendData('form_coleta'$obj);   
  503.     }
  504.     // Calculo do valor do frete   
  505.     static function onFrete($param)
  506.     {
  507.         //Tratamento dos campos
  508.         $fretepeso     str_replace(',','.'str_replace('.',''$param['fretepeso']));    
  509.         $fretevalor    str_replace(',','.'str_replace('.',''$param['fretevalor'])); 
  510.         $coleta        str_replace(',','.'str_replace('.',''$param['coleta']));
  511.         $entrega       str_replace(',','.'str_replace('.',''$param['entrega']));
  512.         $txdespacho    str_replace(',','.'str_replace('.',''$param['txdespacho']));
  513.         $outros        str_replace(',','.'str_replace('.',''$param['outros']));
  514.         $cat           str_replace(',','.'str_replace('.',''$param['cat']));
  515.         $sec_cat       str_replace(',','.'str_replace('.',''$param['sec_cat']));
  516.         $gris          str_replace(',','.'str_replace('.',''$param['gris']));
  517.         $pedagio       str_replace(',','.'str_replace('.',''$param['pedagio']));
  518.         $perc_icms     str_replace(',','.'str_replace('.',''$param['perc_icms']));
  519.         //Calculos
  520.         if ($perc_icms==0)
  521.         {
  522.             new TMessage('danger','Digite a alíquota em ICMS (%).');
  523.         }
  524.             else
  525.             {
  526.                 $base_icms     = ($fretepeso $fretevalor $coleta  $entrega $txdespacho 
  527.                                   $outros    $cat        $sec_cat $gris    $pedagio) ;
  528.                 $frete_total   $base_icms / ((100 $perc_icms)/100);               
  529.                 $valor_icms    $frete_total $base_icms;
  530.                 //Apresentação e  tratamento do campos 
  531.                 $obj = new StdClass;
  532.                 $obj->base_icms   number_format($base_icms  2',''.');
  533.                 $obj->frete_total number_format($frete_total2',''.');
  534.                 $obj->valor_icms  number_format($valor_icms 2',''.');
  535.                 TForm::sendData('form_coleta'$obj);
  536.             }  
  537.     }
  538.     /**
  539.      * Load object to form data
  540.      * @param $param Request
  541.      */
  542.      public function onEdit$param )
  543.     {
  544.         try
  545.         {
  546.             if (isset($param['key']))
  547.             {
  548.                 $key $param['key'];  // get the parameter $key
  549.                 TTransaction::open('samples'); // open a transaction
  550.                 $object = new Coleta($key); // instantiates the Active Record
  551.                 $object->data_coleta TDate::date2br($object->data_coleta);
  552.                 //Desabilita os campos do formulário
  553.                 if ($object->status=='Aprovado')
  554.                   {
  555.                     $this->frete_total->setEditable(FALSE);
  556.                   }
  557.                 $this->form->setData($object); // fill the form
  558.                 TTransaction::close(); // close the transaction           
  559.             }
  560.             else
  561.             {
  562.                 $this->form->clear();
  563.             }
  564.         }
  565.         catch (Exception $e// in case of exception
  566.         {
  567.             new TMessage('error'$e->getMessage()); // shows the exception error message
  568.             TTransaction::rollback(); // undo all pending operations
  569.         }
  570.     }
  571.        
  572.     /**
  573.      * method onSave()
  574.      * Executed whenever the user clicks at the save button
  575.      */
  576.     function onSave()
  577.     {
  578.        try
  579.        {           //grava a data e hora da última alteração     
  580.         $alteracao date('d-m-Y / H:i');
  581.         $obj       = new StdClass;
  582.         $obj       ->alteracao  $alteracao;
  583.         TForm::sendData('form_coleta'$obj);
  584.        
  585.         TTransaction::open('samples'); // Abre a conexão com o banco
  586.         $this->form->validate(); // validação dos dados       
  587.         $object $this->form->getData('Coleta');//abre a tabela
  588.         //Lê o Status do documento e só grava se for igual a lançado
  589.         if ($object->status=='Lançado')
  590.           {
  591.             $object->data_coleta TDate::date2us($object->data_coleta);//converte para formato US
  592.             $object->store();//grava
  593.             $object->data_coleta TDate::date2br($object->data_coleta);
  594.             $this->form->setData($object);//
  595.             new TMessage('info'TAdiantiCoreTranslator::translate('Record saved')); 
  596.           }
  597.         else 
  598.             {
  599.                 if ($object->status=='')//Correção do campo Status que vem vazio das consultas
  600.                 {
  601.                     $status       'Lançado';
  602.                     $alteracao    date('d-m-Y / H:i');
  603.                     //Apresentação e  tratamento do campos 
  604.                     $obj = new StdClass;
  605.                     $obj->status     $status;
  606.                     $obj->alteracao  $alteracao;
  607.                     TForm::sendData('form_coleta'$obj);
  608.                     //Salva o registro
  609.                     $object->data_coleta TDate::date2us($object->data_coleta);//converte para formato US
  610.                     $object->store();//grava
  611.                     $object->data_coleta TDate::date2br($object->data_coleta);
  612.                     $this->form->setData($object);//
  613.                     new TMessage('info'TAdiantiCoreTranslator::translate('Record saved'));
  614.                 }
  615.                 else 
  616.                 {
  617.                     new TMessage('danger','Não é permitido a gravação de documentos impressos ou finalizados.'); 
  618.                 }
  619.             }
  620.         TTransaction::close(); //fecha o banco           
  621.       }
  622.       
  623.         catch (Exception $e// in case of exception
  624.         {
  625.             // shows the exception error message
  626.             new TMessage('error''<b>Error</b> ' $e->getMessage());
  627.             TTransaction::rollback();
  628.         }
  629.         
  630.     }     

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 (1)


NR

Wempar, esse erro ocorre quando o modelo não foi encontrado pelo método getData.

Você já criou o modelo Item?