TS
Alternativa ao TDBSeekButton
Fechado
Senhores,
boa noite, estou com um problema referente ao componente TDBSeekButton. É o seguinte, tenho um formulário que captura dados de uma determinada classe para preencher outra classe que faz associação com minha classe principal, a qual dá origem ao formulário. O problema é que o TDBSeekButton tem uma limitação de parâmetros de busca e na hora de inserir no multifield ele não consegue capturar alguns dados que são necessários para a funcionalidade do formulário. A dúvida é a seguinte, existe algum componente que posso utilizar como alternativa ao TDBSeekButton, para capturar todos os dados necessários?
Fico no aguardo, desde já grato.
Segue abaixo o código do formulário:
boa noite, estou com um problema referente ao componente TDBSeekButton. É o seguinte, tenho um formulário que captura dados de uma determinada classe para preencher outra classe que faz associação com minha classe principal, a qual dá origem ao formulário. O problema é que o TDBSeekButton tem uma limitação de parâmetros de busca e na hora de inserir no multifield ele não consegue capturar alguns dados que são necessários para a funcionalidade do formulário. A dúvida é a seguinte, existe algum componente que posso utilizar como alternativa ao TDBSeekButton, para capturar todos os dados necessários?
Fico no aguardo, desde já grato.
Segue abaixo o código do formulário:
- <?php
- class FrmMestreReproducao extends TPage
- {
- protected $form;
- public function __construct(){
- parent::__construct();
- $this->form = new TForm('FrmMestreReproducao');
- $this->form->class = 'tform';
- parent::include_css('app/resources/custom-frame.css');
- $tbl_reproducao = new TTable;
- $tbl_matrizes = new TTable;
- $tbl_dados_primarios = new TTable;
- $tbl_estatisticas = new TTable;
- $tbl_matriz2 = new TTable;
- $tbl_dados_primarios->styçe='background:whiteSmoke;';
- $hbox1 = new THBox;
- $hbox2 = new THBox;
- $hbox3 = new THBox;
- $tbl_reproducao->style='Width:100%;';
- $tbl_dados_primarios->style='width:100%';
- $tbl_matrizes->style='width:100%';
- $tbl_estatisticas->style='width:100%';
- $tbl_matriz2->style='width:100%';
- $this->form->add($tbl_reproducao);
- $tbl_reproducao->addRowSet( new TLabel('Reprodução'), '', '','' )->class = 'tformtitle';
- $tbl_reproducao->addRowSet($hbox1);
- $tbl_reproducao->addRowSet($hbox2);
- $tbl_reproducao->addRowSet($hbox3);
- $hbox1->add($tbl_dados_primarios);
- $hbox1->add($tbl_estatisticas);
- $hbox2->add($tbl_matrizes);
- $hbox2->add($tbl_matriz2);
- $this->form->add($tbl_reproducao);
- $frame_matrizes = new TFrame(NULL, 290);
- $frame_matrizes->setLegend('Matrizes');
- $frame_matrizes->style .= 'background:whiteSmoke;margin: 4px';
- $frame_incubadora = new TFrame(NULL, 290);
- $frame_incubadora->setLegend('Incubadora');
- $frame_incubadora->style .= ';margin: 4px';
- 2249Reproducao = new THidden('idReproducao');
- $codigo = new TEntry('codigo');
- $dataInicioReproducao = new TDate('dataInicioReproducao');
- $temperatura = new TEntry('temperatura');
- $equipeReproducao = new TEntry('equipeReproducao');
- $climaDia = new TEntry('climaDia');
- $pesoTotMatFemea = new TEntry('pesoTotMatFemea');
- $pesoTotMatMacho = new TEntry('pesoTotMatMacho');
- $qtdeMatFemea = new TEntry('qtdeMatFemea');
- $qtdeMatMacho = new TEntry('qtdeMatMacho');
- $pesoGeralMatriz = new TEntry('pesoGeralMatriz');
- $totalGeralHormonio = new TEntry('totalGeralHormonio');
- $dataFinalReproducao = new TDate('dataFinalReproducao');
- $reproducao_incubadoras = new TDBRadioGroup('reproducao_incubadoras','dbwf','Incubadora','idIncubadora','descIncubadora');
- 2249Matriz = new ">TDBSeekButton('idMatriz','dbwf',$this->form->getName(),'Matriz','numeroChipMatriz','matrizes_id','matrizes_numeroChipMatriz');
- //$matriz = new TEntry('matriz');
- $numero = new TEntry('numeroChipMatriz');
- $pesoMatriz = new TEntry('pesoMatriz');
- 2249entMatriz = new TEntry('identMatriz');
- $sexoMatriz = new TEntry('sexoMatriz');
- $multi_matrizes = new TMultiField('matrizes');
- $txEclosao = new TEntry('txEclosao');
- $txFecundacao = new TEntry('txFecundacao');
- if (!empty(2249Reproducao))
- {
- 2249Reproducao->setEditable(FALSE);
- }
- $scroll = new TScroll;
- $scroll->setSize(290, 240);
- $scroll->add( $reproducao_incubadoras );
- $frame_incubadora->add($scroll);
- $frame_matrizes->add($multi_matrizes);
- //$matriz->setEditable(false);
- $codigo->setSize('50%');
- $temperatura->setSize('100%');
- $equipeReproducao->setSize('100%');
- $climaDia->setSize('100%');
- $pesoTotMatFemea->setSize('100%');
- $pesoTotMatMacho->setSize('100%');
- $totalGeralHormonio->setSize('100%');
- $qtdeMatFemea->setSize('100%');
- $qtdeMatMacho->setSize('100%');
- $pesoGeralMatriz->setSize('100%');
- $numero->setEditable(false);
- $sexoMatriz->setEditable(false);
- $dataInicioReproducao->date2br;
- $multi_matrizes->setHeight(120);
- $multi_matrizes->setClass('Matriz');
- $multi_matrizes->addField('id','Matriz', 2249Matriz,60);
- $multi_matrizes->addField('numeroChipMatriz','Numero', $numero, 60,'center');
- $multi_matrizes->addField('identMatriz','Identificação',2249entMatriz,140);
- $multi_matrizes->addField('pesoMatriz','Peso Atual', $pesoMatriz,80);
- $matriz1 = new Matriz();
- try{
- TTransaction::open('dbwf');
- $matriz1->load('id');
- var_dump($numero->getValue());
- TTransaction::close();
- }
- catch(Exception $e){
- new TMessage('error','<b>Erro ao gravar o Registro!</b>'. $e->getMessage());
- }
- $sexoMatriz->setValue($matriz1->sexoMatriz);
- $multi_matrizes->addField('sexoMatriz','Sexo',$sexoMatriz,60);
- $multi_matrizes->setOrientation('vertical');
- $row = $tbl_dados_primarios->addRow();
- $row->addCell(new TLabel('Nº:'))->style='width:150px';
- $row->addcell($codigo);
- $tbl_dados_primarios->addRowSet(new TLabel('INICIO'.': ' ), $dataInicioReproducao);
- $tbl_dados_primarios->addRowSet(new TLabel('TEMPERATURA'.': ' ), $temperatura);
- $tbl_dados_primarios->addRowSet(new TLabel('EQUIPE'.': '), $equipeReproducao);
- $tbl_dados_primarios->addRowSet(new TLabel('CLIMA DO DIA'.': '), $climaDia);
- //$tbl_dados_primarios->addRowSet(new TLabel('FINAL'.': '), $dataFinalReproducao);
- $row = $tbl_estatisticas->addRow();
- $row->addCell(new TLabel('TAXA DE ECLOSÃO:'))->style='width:150px';
- $row->addCell($txEclosao);
- $tbl_estatisticas->addRowSet(new TLabel('TAXA DE FECUNDAÇÃO'.': '), $txFecundacao);
- $tbl_estatisticas->addRowSet(new TLabel('FINAL'.': '), $dataFinalReproducao);
- //$tbl_estatisticas->addRowSet(new TLabel('TOTAL MACHOS'.': '), $qtdeMatMacho);
- $row = $tbl_matrizes->addRow();
- $row->addCell(new TLabel('TOTAL FÊMEAS: '))->style='width:150px';
- $row->addCell($qtdeMatFemea);
- $tbl_matrizes->addRowSet(new TLabel('TOTAL MACHOS'.': '), $qtdeMatMacho);
- $tbl_matrizes->addRowSet(new TLabel('TOTAL HORMÔNIO'.': '), $totalGeralHormonio);
- $row = $tbl_matriz2->addRow();
- $row->addCell(new TLabel('PESO FÊMEAS'.': '))->style='width:150px';
- $row->addCell($pesoTotMatFemea);
- $tbl_matriz2->addRowSet(new TLabel('PESO MACHOS'.': '), $pesoTotMatMacho);
- $tbl_matriz2->addRowSet(new TLabel('TOTAL MATRIZES'.': '), $pesoGeralMatriz);
- $hbox3->add($frame_matrizes)->style .='vertical-align:top';
- $hbox3->add($frame_incubadora)->style .='vertical-align:top';
- $save_button=new TButton('save');
- $save_button->setAction(new TAction(array($this, 'onSave')), _t('Save'));
- $save_button->setImage('fa:floppy-o');
- // create an new button (edit with no parameters)
- $new_button=new TButton('new');
- $new_button->setAction(new TAction(array($this, 'onEdit')), _t('New'));
- $new_button->setImage('fa:plus-square green');
- $list_button=new TButton('list');
- $list_button->setAction(new TAction(array('SystemUserList','onReload')), _t('Back to the listing'));
- $list_button->setImage('fa:table blue');
- // define the form fields
- $this->form->setFields(array(2249Reproducao, $equipeReproducao, $txEclosao, $codigo, $dataInicioReproducao, $dataFinalReproducao, $temperatura, $climaDia, $pesoTotMatFemea, $pesoTotMatMacho,
- $qtdeMatFemea, $qtdeMatMacho, $pesoGeralMatriz, $txFecundacao, $totalGeralHormonio, $reproducao_incubadoras, $multi_matrizes, $save_button, $new_button, $list_button));
- $buttons = new THBox;
- $buttons->add($save_button);
- $buttons->add($new_button);
- $buttons->add($list_button);
- $row=$tbl_reproducao->addRow();
- $row->class = 'tformaction';
- $row->addCell( $buttons );
- $container = new TTable;
- $container->style = 'width: 80%';
- //$container->addRow()->addCell(new TXMLBreadCrumb('menu.xml', 'SystemUserList'));
- $container->addRow()->addCell($this->form);
- // add the form to the page
- parent::add($container);
- }
- public function onSave(){
- try{
- TTransaction::open('dbwf');
- TTransaction::setLogger(new TLoggerTXT('C:\\log.txt'));
- TTransaction::log('Inserir Reproducao ');
- $this->form->validate();
- $object = $this->form->getData('Reproducao');
- $data = $this->form->getData();
- if($data->matrizes)
- {
- foreach($data->matrizes as $mat)
- {
- $matriz = new Matriz($mat->id);
- $reproducao_matriz = new RepMatriz();
- $reproducao_matriz->matriz = $matriz;
- $reproducao_matriz->pesoMatriz = $mat->pesoMatriz;
- $reproducao_matriz->identMatriz = $mat->identMatriz;
- $object->addRepMatriz($reproducao_matriz);
- }
- }
- if($data->reproducao_incubadoras)
- {
- $incubadora = new Incubadora($data->reproducao_incubadoras);
- $object->addIncubadora($incubadora);
- }
- $data = Reproducao::calcular();
- $object->store();
- //$object1->store();
- $object->clearParts();
- TTransaction::close();
- new TMessage('info','Registro Gravado com sucesso!');
- }
- catch(Exception $e){
- new TMessage('error','<b>Erro ao gravar o Registro!</b>'. $e->getMessage());
- TTransaction::rollback();
- }
- }
- public function onEdit($param)
- {
- try
- {
- if(isset($param['key'])){
- $key = $param['key'];
- TTransaction::open('dbwf');
- $incubadoras = array();
- $object->matrizes = $object->getRepMatrizes();
- $this->form->setData($object);
- TTransaction::close();
- }
- }
- catch(Exception $e)
- {
- new TMessage('Erro '.$e->getMessage());
- TTransaction::rollback();
- }
- }
- }
- ?>
Thiago, se entendi bem o que você quer, é algo como isso:
www.adianti.com.br/framework_files/tutor/index.php?class=POSFormView
Tu seleciona o produto e ele preenche vários campos do formulário.
Isso mesmo Alexandre, é pq preciso fazer alguns cálculos, mas esses cálculos dependem de quais campos serão preenchidos
Nesse exemplo é usada datagrid no lugar de multifield. Se você usar o setExitAction() do seek e pegar o ID do objeto selecionado, com base no Id, você instancia o objeto e pega o resto...
Abs,