Alternativa ao TDBSeekButton 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 co...
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:

 
  1. <?php
  2. class FrmMestreReproducao extends TPage
  3. {
  4. protected $form;
  5. public function __construct(){
  6. parent::__construct();
  7. $this->form = new TForm('FrmMestreReproducao');
  8. $this->form->class = 'tform';
  9. parent::include_css('app/resources/custom-frame.css');
  10. $tbl_reproducao = new TTable;
  11. $tbl_matrizes = new TTable;
  12. $tbl_dados_primarios = new TTable;
  13. $tbl_estatisticas = new TTable;
  14. $tbl_matriz2 = new TTable;
  15. $tbl_dados_primarios->styçe='background:whiteSmoke;';
  16. $hbox1 = new THBox;
  17. $hbox2 = new THBox;
  18. $hbox3 = new THBox;
  19. $tbl_reproducao->style='Width:100%;';
  20. $tbl_dados_primarios->style='width:100%';
  21. $tbl_matrizes->style='width:100%';
  22. $tbl_estatisticas->style='width:100%';
  23. $tbl_matriz2->style='width:100%';
  24. $this->form->add($tbl_reproducao);
  25. $tbl_reproducao->addRowSet( new TLabel('Reprodução'), '', '','' )->class = 'tformtitle';
  26. $tbl_reproducao->addRowSet($hbox1);
  27. $tbl_reproducao->addRowSet($hbox2);
  28. $tbl_reproducao->addRowSet($hbox3);
  29. $hbox1->add($tbl_dados_primarios);
  30. $hbox1->add($tbl_estatisticas);
  31. $hbox2->add($tbl_matrizes);
  32. $hbox2->add($tbl_matriz2);
  33. $this->form->add($tbl_reproducao);
  34. $frame_matrizes = new TFrame(NULL, 290);
  35. $frame_matrizes->setLegend('Matrizes');
  36. $frame_matrizes->style .= 'background:whiteSmoke;margin: 4px';
  37. $frame_incubadora = new TFrame(NULL, 290);
  38. $frame_incubadora->setLegend('Incubadora');
  39. $frame_incubadora->style .= ';margin: 4px';
  40. 2249Reproducao = new THidden('idReproducao');
  41. $codigo = new TEntry('codigo');
  42. $dataInicioReproducao = new TDate('dataInicioReproducao');
  43. $temperatura = new TEntry('temperatura');
  44. $equipeReproducao = new TEntry('equipeReproducao');
  45. $climaDia = new TEntry('climaDia');
  46. $pesoTotMatFemea = new TEntry('pesoTotMatFemea');
  47. $pesoTotMatMacho = new TEntry('pesoTotMatMacho');
  48. $qtdeMatFemea = new TEntry('qtdeMatFemea');
  49. $qtdeMatMacho = new TEntry('qtdeMatMacho');
  50. $pesoGeralMatriz = new TEntry('pesoGeralMatriz');
  51. $totalGeralHormonio = new TEntry('totalGeralHormonio');
  52. $dataFinalReproducao = new TDate('dataFinalReproducao');
  53. $reproducao_incubadoras = new TDBRadioGroup('reproducao_incubadoras','dbwf','Incubadora','idIncubadora','descIncubadora');
  54. 2249Matriz = new ">TDBSeekButton('idMatriz','dbwf',$this->form->getName(),'Matriz','numeroChipMatriz','matrizes_id','matrizes_numeroChipMatriz');
  55. //$matriz = new TEntry('matriz');
  56. $numero = new TEntry('numeroChipMatriz');
  57. $pesoMatriz = new TEntry('pesoMatriz');
  58. 2249entMatriz = new TEntry('identMatriz');
  59. $sexoMatriz = new TEntry('sexoMatriz');
  60. $multi_matrizes = new TMultiField('matrizes');
  61. $txEclosao = new TEntry('txEclosao');
  62. $txFecundacao = new TEntry('txFecundacao');
  63. if (!empty(2249Reproducao))
  64. {
  65. 2249Reproducao->setEditable(FALSE);
  66. }
  67. $scroll = new TScroll;
  68. $scroll->setSize(290, 240);
  69. $scroll->add( $reproducao_incubadoras );
  70. $frame_incubadora->add($scroll);
  71. $frame_matrizes->add($multi_matrizes);
  72. //$matriz->setEditable(false);
  73. $codigo->setSize('50%');
  74. $temperatura->setSize('100%');
  75. $equipeReproducao->setSize('100%');
  76. $climaDia->setSize('100%');
  77. $pesoTotMatFemea->setSize('100%');
  78. $pesoTotMatMacho->setSize('100%');
  79. $totalGeralHormonio->setSize('100%');
  80. $qtdeMatFemea->setSize('100%');
  81. $qtdeMatMacho->setSize('100%');
  82. $pesoGeralMatriz->setSize('100%');
  83. $numero->setEditable(false);
  84. $sexoMatriz->setEditable(false);
  85. $dataInicioReproducao->date2br;
  86. $multi_matrizes->setHeight(120);
  87. $multi_matrizes->setClass('Matriz');
  88. $multi_matrizes->addField('id','Matriz', 2249Matriz,60);
  89. $multi_matrizes->addField('numeroChipMatriz','Numero', $numero, 60,'center');
  90. $multi_matrizes->addField('identMatriz','Identificação',2249entMatriz,140);
  91. $multi_matrizes->addField('pesoMatriz','Peso Atual', $pesoMatriz,80);
  92. $matriz1 = new Matriz();
  93. try{
  94. TTransaction::open('dbwf');
  95. $matriz1->load('id');
  96. var_dump($numero->getValue());
  97. TTransaction::close();
  98. }
  99. catch(Exception $e){
  100. new TMessage('error','<b>Erro ao gravar o Registro!</b>'. $e->getMessage());
  101. }
  102. $sexoMatriz->setValue($matriz1->sexoMatriz);
  103. $multi_matrizes->addField('sexoMatriz','Sexo',$sexoMatriz,60);
  104. $multi_matrizes->setOrientation('vertical');
  105. $row = $tbl_dados_primarios->addRow();
  106. $row->addCell(new TLabel('Nº:'))->style='width:150px';
  107. $row->addcell($codigo);
  108. $tbl_dados_primarios->addRowSet(new TLabel('INICIO'.': ' ), $dataInicioReproducao);
  109. $tbl_dados_primarios->addRowSet(new TLabel('TEMPERATURA'.': ' ), $temperatura);
  110. $tbl_dados_primarios->addRowSet(new TLabel('EQUIPE'.': '), $equipeReproducao);
  111. $tbl_dados_primarios->addRowSet(new TLabel('CLIMA DO DIA'.': '), $climaDia);
  112. //$tbl_dados_primarios->addRowSet(new TLabel('FINAL'.': '), $dataFinalReproducao);
  113. $row = $tbl_estatisticas->addRow();
  114. $row->addCell(new TLabel('TAXA DE ECLOSÃO:'))->style='width:150px';
  115. $row->addCell($txEclosao);
  116. $tbl_estatisticas->addRowSet(new TLabel('TAXA DE FECUNDAÇÃO'.': '), $txFecundacao);
  117. $tbl_estatisticas->addRowSet(new TLabel('FINAL'.': '), $dataFinalReproducao);
  118. //$tbl_estatisticas->addRowSet(new TLabel('TOTAL MACHOS'.': '), $qtdeMatMacho);
  119. $row = $tbl_matrizes->addRow();
  120. $row->addCell(new TLabel('TOTAL FÊMEAS: '))->style='width:150px';
  121. $row->addCell($qtdeMatFemea);
  122. $tbl_matrizes->addRowSet(new TLabel('TOTAL MACHOS'.': '), $qtdeMatMacho);
  123. $tbl_matrizes->addRowSet(new TLabel('TOTAL HORMÔNIO'.': '), $totalGeralHormonio);
  124. $row = $tbl_matriz2->addRow();
  125. $row->addCell(new TLabel('PESO FÊMEAS'.': '))->style='width:150px';
  126. $row->addCell($pesoTotMatFemea);
  127. $tbl_matriz2->addRowSet(new TLabel('PESO MACHOS'.': '), $pesoTotMatMacho);
  128. $tbl_matriz2->addRowSet(new TLabel('TOTAL MATRIZES'.': '), $pesoGeralMatriz);
  129. $hbox3->add($frame_matrizes)->style .='vertical-align:top';
  130. $hbox3->add($frame_incubadora)->style .='vertical-align:top';
  131. $save_button=new TButton('save');
  132. $save_button->setAction(new TAction(array($this, 'onSave')), _t('Save'));
  133. $save_button->setImage('fa:floppy-o');
  134. // create an new button (edit with no parameters)
  135. $new_button=new TButton('new');
  136. $new_button->setAction(new TAction(array($this, 'onEdit')), _t('New'));
  137. $new_button->setImage('fa:plus-square green');
  138. $list_button=new TButton('list');
  139. $list_button->setAction(new TAction(array('SystemUserList','onReload')), _t('Back to the listing'));
  140. $list_button->setImage('fa:table blue');
  141. // define the form fields
  142. $this->form->setFields(array(2249Reproducao, $equipeReproducao, $txEclosao, $codigo, $dataInicioReproducao, $dataFinalReproducao, $temperatura, $climaDia, $pesoTotMatFemea, $pesoTotMatMacho,
  143. $qtdeMatFemea, $qtdeMatMacho, $pesoGeralMatriz, $txFecundacao, $totalGeralHormonio, $reproducao_incubadoras, $multi_matrizes, $save_button, $new_button, $list_button));
  144. $buttons = new THBox;
  145. $buttons->add($save_button);
  146. $buttons->add($new_button);
  147. $buttons->add($list_button);
  148. $row=$tbl_reproducao->addRow();
  149. $row->class = 'tformaction';
  150. $row->addCell( $buttons );
  151. $container = new TTable;
  152. $container->style = 'width: 80%';
  153. //$container->addRow()->addCell(new TXMLBreadCrumb('menu.xml', 'SystemUserList'));
  154. $container->addRow()->addCell($this->form);
  155. // add the form to the page
  156. parent::add($container);
  157. }
  158. public function onSave(){
  159. try{
  160. TTransaction::open('dbwf');
  161. TTransaction::setLogger(new TLoggerTXT('C:\\log.txt'));
  162. TTransaction::log('Inserir Reproducao ');
  163. $this->form->validate();
  164. $object = $this->form->getData('Reproducao');
  165. $data = $this->form->getData();
  166. if($data->matrizes)
  167. {
  168. foreach($data->matrizes as $mat)
  169. {
  170. $matriz = new Matriz($mat->id);
  171. $reproducao_matriz = new RepMatriz();
  172. $reproducao_matriz->matriz = $matriz;
  173. $reproducao_matriz->pesoMatriz = $mat->pesoMatriz;
  174. $reproducao_matriz->identMatriz = $mat->identMatriz;
  175. $object->addRepMatriz($reproducao_matriz);
  176. }
  177. }
  178. if($data->reproducao_incubadoras)
  179. {
  180. $incubadora = new Incubadora($data->reproducao_incubadoras);
  181. $object->addIncubadora($incubadora);
  182. }
  183. $data = Reproducao::calcular();
  184. $object->store();
  185. //$object1->store();
  186. $object->clearParts();
  187. TTransaction::close();
  188. new TMessage('info','Registro Gravado com sucesso!');
  189. }
  190. catch(Exception $e){
  191. new TMessage('error','<b>Erro ao gravar o Registro!</b>'. $e->getMessage());
  192. TTransaction::rollback();
  193. }
  194. }
  195. public function onEdit($param)
  196. {
  197. try
  198. {
  199. if(isset($param['key'])){
  200. $key = $param['key'];
  201. TTransaction::open('dbwf');
  202. $incubadoras = array();
  203. $object->matrizes = $object->getRepMatrizes();
  204. $this->form->setData($object);
  205. TTransaction::close();
  206. }
  207. }
  208. catch(Exception $e)
  209. {
  210. new TMessage('Erro '.$e->getMessage());
  211. TTransaction::rollback();
  212. }
  213. }
  214. }
  215. ?>

Curso Dominando o Adianti Framework

O material mais completo de treinamento do Framework.
Curso em vídeo aulas + Livro completo + Códigos fontes do projeto ERPHouse.
Conteúdo Atualizado!


Dominando o Adianti Framework Quero me inscrever agora!

Comentários (3)


AC

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.
TS

Isso mesmo Alexandre, é pq preciso fazer alguns cálculos, mas esses cálculos dependem de quais campos serão preenchidos
PD

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,