RS
erro dizendo que não existe a classe TFileldList
Fatal error: Class 'TFieldList' not found in C:wamp64wwwadm_conpusisappcontrolconpusisLoteLancamentosForm.class.php on line 75
- <?php
- /**
- * LoteLancamentoForm Master/Detail
- * @author <your name here>
- */
- class LoteLancamentoForm extends TPage
- {
- protected $form; // form
- protected $fieldlist;
- /**
- * Class constructor
- * Creates the page and the registration form
- */
- function __construct($param)
- {
- parent::__construct($param);
- // creates the form
- $this->form = new TForm('form_LoteLancamento');
- $panel_master = new TPanelGroup( 'LoteLancamento' );
- $vbox = new TVBox;
- $vbox->style = 'width: 100%';
- $this->form->add($panel_master);
- $panel_master->add($vbox);
- $table_general = new TTable;
- $table_general->width = '100%';
- $frame_general = new TFrame;
- $frame_general->class = 'tframe tframe-custom';
- $frame_general->setLegend('LoteLancamento');
- $frame_general->style = 'background:whiteSmoke';
- $frame_general->add($table_general);
- $frame_details = new TFrame;
- $frame_details->class = 'tframe tframe-custom';
- $frame_details->setLegend('CustosLancamentos');
- $vbox->add( $frame_general );
- $vbox->add( $frame_details );
- // master fields
- $Id_lote = new TEntry('Id_lote');
- $lote_competencia = new TEntry('lote_competencia');
- $lote_vencimento = new TDate('lote_vencimento');
- $lote_tipo_custo = new TEntry('lote_tipo_custo');
- // sizes
- $Id_lote->setSize('50%');
- $lote_competencia->setSize('100%');
- $lote_vencimento->setSize('50%');
- $lote_tipo_custo->setSize('50%');
- if (!empty($Id_lote))
- {
- $Id_lote->setEditable(FALSE);
- }
- // add form fields to be handled by form
- $this->form->addField($Id_lote);
- $this->form->addField($lote_competencia);
- $this->form->addField($lote_vencimento);
- $this->form->addField($lote_tipo_custo);
- // add form fields to the screen
- $table_general->addRowSet( new TLabel('Id Lote'), $Id_lote );
- $table_general->addRowSet( new TLabel('Lote Competencia'), $lote_competencia );
- $table_general->addRowSet( new TLabel('Lote Vencimento'), $lote_vencimento );
- $table_general->addRowSet( new TLabel('Lote Tipo Custo'), $lote_tipo_custo );
- // detail fields
- $this->fieldlist = new TFieldList;
- $this->fieldlist->enableSorting();
- $frame_details->add($this->fieldlist);
- $id_custo = new TEntry('list_id_custo[]');
- $valor = new TEntry('list_valor[]');
- $obs = new TText('list_obs[]');
- $id_custo->setSize('50%');
- $valor->setSize('50%');
- $obs->setSize('100%');
- $this->fieldlist->addField( '<b>Id Custo</b>', $id_custo);
- $this->fieldlist->addField( '<b>Valor</b>', $valor);
- $this->fieldlist->addField( '<b>Obs</b>', $obs);
- $this->form->addField($id_custo);
- $this->form->addField($valor);
- $this->form->addField($obs);
- // create an action button (save)
- $save_button = TButton::create('save', array($this, 'onSave'), _t('Save'), 'fa:save blue');
- $new_button = TButton::create('new', array($this, 'onClear'), _t('Clear'), 'fa:eraser red');
- $this->form->addField($save_button);
- $this->form->addField($new_button);
- $panel_master->addFooter( THBox::pack($save_button, $new_button) );
- // create the page container
- $container = new TVBox;
- $container->style = 'width: 100%';
- //$container->add(new TXMLBreadCrumb('menu.xml', __CLASS__));
- $container->add($this->form);
- parent::add($container);
- }
- /**
- * Executed whenever the user clicks at the edit button da datagrid
- */
- function onEdit($param)
- {
- try
- {
- TTransaction::open('conpusis');
- if (isset($param['key']))
- {
- $key = $param['key'];
- $object = new LoteLancamento($key);
- $this->form->setData($object);
- $items = CustosLancamentos::where('id_lote', '=', $key)->load();
- $this->fieldlist->addHeader();
- if ($items)
- {
- foreach($items as $item )
- {
- $detail = new stdClass;
- $detail->list_id_custo = $item->id_custo;
- $detail->list_valor = $item->valor;
- $detail->list_obs = $item->obs;
- $this->fieldlist->addDetail($detail);
- }
- $this->fieldlist->addCloneAction();
- }
- else
- {
- $this->onClear($param);
- }
- TTransaction::close(); // close transaction
- }
- }
- catch (Exception $e) // in case of exception
- {
- new TMessage('error', $e->getMessage());
- TTransaction::rollback();
- }
- }
- /**
- * Clear form
- */
- public function onClear($param)
- {
- $this->fieldlist->addHeader();
- $this->fieldlist->addDetail( new stdClass );
- $this->fieldlist->addCloneAction();
- }
- /**
- * Save the LoteLancamento and the CustosLancamentos's
- */
- public static function onSave($param)
- {
- try
- {
- TTransaction::open('conpusis');
- $id = (int) $param['Id_lote'];
- $master = new LoteLancamento;
- $master->fromArray( $param);
- $master->store(); // save master object
- // delete details
- CustosLancamentos::where('id_lote', '=', $master->Id_lote)->delete();
- if( !empty($param['list_id_custo']) AND is_array($param['list_id_custo']) )
- {
- foreach( $param['list_id_custo'] as $row => $id_custo)
- {
- if (!empty($id_custo))
- {
- $detail = new CustosLancamentos;
- $detail->id_lote = $master->Id_lote;
- $detail->id_custo = $param['list_id_custo'][$row];
- $detail->valor = $param['list_valor'][$row];
- $detail->obs = $param['list_obs'][$row];
- $detail->store();
- }
- }
- }
- $data = new stdClass;
- $data->Id_lote = $master->Id_lote;
- TForm::sendData('form_LoteLancamento', $data);
- TTransaction::close(); // close the transaction
- new TMessage('info', TAdiantiCoreTranslator::translate('Record saved'));
- }
- catch (Exception $e) // in case of exception
- {
- new TMessage('error', $e->getMessage());
- TTransaction::rollback();
- }
- }
- }
- ?>
Qual a versão do seu projeto? O TFieldList só foi acrescentado na versão 5
Obrigado Nataniel, deve ser isso porque este projeto está na versão 4, beleza.