Lançado Adianti Framework 7.6!
Clique aqui para saber mais
Erro botão TSeekButton Bom dia, Sou iniciante no Framework, e estou implementando um cadastro de nota fiscal (mestre / detalhe). Preciso implementar o botão "Seek" semelhante ao do exemplo Tutor. Porém ao instanciar a Classe que abre a window para selecionar o registro que eu quero, ocorre o erro "Fatal error: Class 'RemetenteDestinatarioSeek' not found in C:wampwwwnotafiscalappcontrolNotaFiscalForm.cla...
CG
Erro botão TSeekButton  
Fechado
Bom dia,

Sou iniciante no Framework, e estou implementando um cadastro de nota fiscal (mestre / detalhe).

Preciso implementar o botão "Seek" semelhante ao do exemplo Tutor.

Porém ao instanciar a Classe que abre a window para selecionar o registro que eu quero, ocorre o erro "Fatal error: Class 'RemetenteDestinatarioSeek' not found in C:wampwwwnotafiscalappcontrolNotaFiscalForm.class.php on line 34".

Porém no código estou instanciando a Classe corretamente, conforme código abaixo:

function __construct(){ parent::__construct(); //FORM MESTRE //NOTA FISCAL $this->form = new TQuickForm('form_nota_fiscal'); parent::setDatabase('livraria'); parent::setActiveRecord('NotaFiscal'); $notafiscal_id = new TEntry('notafiscal_id'); $notafiscal_id->setEditable(FALSE); $numero = new TEntry('numero'); $emissao = new TDate('emissao'); //$emissao->setMask('dd/mm/yyyy'); $remetente_id = new TEntry('remdest_nome1'); $destinatario_id = new TEntry('destinatario_id'); $remdest_id1 = new TSeekButton('remdest_id1'); //$remdest_id2 = new TSeekButton('city_id1'); $remetente_id->setEditable(FALSE); <b> $obj = new RemetenteDestinatarioSeek; </b> /* $action = new TAction(array($obj, 'onReload')); $remdest_id1->setAction($action); */ $this->form->addQuickField('Id', $notafiscal_id, 100); $this->form->addQuickField('Número', $numero, 200); $this->form->addQuickField('Emissão', $emissao, 80); $this->form->addQuickField('Remetente', $remetente_id, 80); $this->form->addQuickField('Nome do Remetente', $remdest_id1, 80); $this->form->addQuickField('Destinatário', $destinatario_id, 80); [....]


Código da window:

class RemententeDestinatarioSeek extends TWindow { private $form; // form private $datagrid; // datagrid private $pageNavigation; private $parentForm; private $loaded; /** * constructor method */ public function __construct() { parent::__construct(); new TSession; // creates the form $this->form = new TForm('form_rem_dest_seek'); // creates the table $table = new TTable; // add the table inside the form $this->form->add($table); // create the form fields $name= new TEntry('nome'); // keep the session value $name->setValue(TSession::getValue('nome')); // add the field inside the table $row=$table->addRow(); $row->addCell(new TLabel('Nome:')); $row->addCell($name); // create a find button $find_button = new TButton('Buscar'); // define the button action $find_button->setAction(new TAction(array($this, 'onSearch')), 'Search'); $find_button->setImage('ico_find.png'); // add a row for the find button $row=$table->addRow(); $row->addCell($find_button); // define wich are the form fields $this->form->setFields(array($name, $find_button)); // create the datagrid $this->datagrid = new TDataGrid; // create the datagrid columns 778 = new TDataGridColumn('id', 'Id', 'right', 70); $name = new TDataGridColumn('Nome', 'nome', 'left', 220); $state = new TDataGridColumn('CNPJ', 'cnpj', 'left', 80); $order1= new TAction(array($this, 'onReload')); $order2= new TAction(array($this, 'onReload')); $order1->setParameter('order', 'id'); $order2->setParameter('order', 'nome'); // define the column actions 778->setAction($order1); $name->setAction($order2); // add the columns inside the datagrid $this->datagrid->addColumn(778); $this->datagrid->addColumn($name); $this->datagrid->addColumn($state); // create one datagrid action $action1 = new TDataGridAction(array($this, 'onSelect')); $action1->setLabel('Selecionar'); $action1->setImage('ico_apply.png'); $action1->setField('id'); // add the action to the datagrid $this->datagrid->addAction($action1); // create the datagrid model $this->datagrid->createModel(); // create the page navigator $this->pageNavigation = new TPageNavigation; $this->pageNavigation->setAction(new TAction(array($this, 'onReload'))); $this->pageNavigation->setWidth($this->datagrid->getWidth()); // create a table for layout $table = new TTable; // create a row for the form $row = $table->addRow(); $row->addCell($this->form); // create a row for the datagrid $row = $table->addRow(); $row->addCell($this->datagrid); // create a row for the page navigator $row = $table->addRow(); $row->addCell($this->pageNavigation); // add the table inside the page parent::add($table); } /** * Register a filter in the session */ function onSearch() { // get the form data $data = $this->form->getData(); // check if the user has filled the fields if (isset($data->name)) { // cria um filtro pelo conteúdo digitado $filter = new TFilter('nome', 'like', "%{$data->nome}%"); // armazena o filtro na seção TSession::setValue('test_remdest_filter', $filter); TSession::setValue('test_remdest_name', $data->nome); // put the data back to the form $this->form->setData($data); } // redefine the parameters for reload method $param=array(); $param['offset'] =0; $param['first_page']=1; $this->onReload($param); } /** * Load the datagrid with the database objects */ function onReload($param = NULL) { try { // start database transaction TTransaction::open('livraria'); // create a repository for RemententeDestinatário table $repository = new TRepository('RemententeDestinatario'); $limit = 10; // creates a criteria $criteria = new TCriteria; $criteria->setProperties($param); // order, offset $criteria->setProperty('limit', $limit); if (TSession::getValue('test_remdest_filter')) { // filter by remetente destinatário nome $criteria->add(TSession::getValue('test_remdest_filter')); } // load the objects according to the criteria $pessoas = $repository->load($criteria); $this->datagrid->clear(); if ($cities) { foreach ($pessoas as $pessoa) { // add the objects inside the datagrid $this->datagrid->addItem($pessoa); } } // clear the criteria $criteria->resetProperties(); $count= $repository->count($criteria); $this->pageNavigation->setCount($count); // count of records $this->pageNavigation->setProperties($param); // order, page $this->pageNavigation->setLimit($limit); // limit // commit and closes the database transaction TTransaction::close(); $this->loaded = true; } catch (Exception $e) // exceptions { // show the error message new TMessage('error', '<b>Erro</b> ' . $e->getMessage()); // undo all pending operations TTransaction::rollback(); } } /** * Executed when the user chooses the record */ function onSelect($param) { try { $key = $param['key']; TTransaction::open('livraria'); // load the active record $remdest = new RemententeDestinatario($key); // closes the transaction TTransaction::close(); $object = new StdClass; $object->remdest_id1 = $remdest->id; $object->remdest_nome1 = $remdest->nome; TForm::sendData('form_seek_sample', $object); parent::closeWindow(); // closes the window } catch (Exception $e) // em caso de exceção { // clear fields $object = new StdClass; $object->remdest_id1 = ''; $object->remdest_nome1 = ''; TForm::sendData('form_seek_sample', $object); // undo pending operations TTransaction::rollback(); } } /** * Shows the page */ function show() { // if the datagrid was not loaded yet if (!$this->loaded) { $this->onReload(); } parent::show(); } }

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)


PD

a class RemententeDestinatarioSeek esta salva na pasta control como

RemententeDestinatarioSeek.class.php?
PD

da uma olhada nesse componente

https://github.com/ale-php/TComponetes/blob/master/PForm/PStandartSeek.class.php

muito facil de usar

  1. <?php
  2. // campo onde sera retornado o id
  3. $seek = new TSeekButton('categoria_id');
  4.   
  5. // class PStandartSeek
  6.   $obj = new PStandartSeek();
  7. //prefix usado nos campos 
  8. //ex categoria_id
  9.   $obj->setPrefix('categoria');
  10. // mode a ser usada
  11.   $obj->setModel('Categoria');
  12. //primary key da model
  13.   $obj->setKey('id');
  14. //formulario de retorno
  15.   $obj->setParentForm('frmCategoria');
  16. //banco a ser usado
  17.   $obj->setBanco('sample');
  18. //capos a serem mostrados na gris
  19. //campo=>label
  20. // estes campos seram retornados al selecionar um registro
  21. //mas o campo deve ter o prefixo
  22. //ex categoria_nome
  23.   $obj->setCampos(array('id'=>'Codigo','nome'=>'Nome'));
  24. //campo a ser usado para filtro
  25.   $obj->setFiltro('nome');
  26. //altura da janela
  27.   $obj->setHeight(300);
  28. //largura da janela
  29.   $obj->setWidth(500);
  30. //titulo da janela
  31.   $obj->setTitulo('Categorias');
  32.   
  33. //cria a action
  34.   $action = new TAction(array($obj,'onReload'));
  35.   // iseri a action no TStandartSeek
  36.   $seek->setAction($action);
  37. ?>
CG

Opa,

Beleza meu caro.

Vou testar seu código, e qualquer coisa eu te falo.


Valeu!!
CG

Progs Desenvolvimento,

Ficou show de bola!!

Parabéns!
PD

é sempre bom ajudar, em breve farei masi componetes, uteis aceito sugestoes