Forma de Chamar Seek Boa Tarde, consegui criar meus 2 primeiros formularios SEEk, enquanto tinha um só tudo bem, ao criar o segundo e criar a action dele, os forms com seek nao abrem mais como modal, ele abrem abaixo do form que chama eles, ja revisei o codigo e ambos estão iguais, segue abaixo a forma como chamo eles, alguem poderia me ajudar com alguma dica? desde ja agradeço. ...
AB
Forma de Chamar Seek  
Boa Tarde, consegui criar meus 2 primeiros formularios SEEk, enquanto tinha um só tudo bem, ao criar o segundo e criar a action dele, os forms com seek nao abrem mais como modal, ele abrem abaixo do form que chama eles, ja revisei o codigo e ambos estão iguais, segue abaixo a forma como chamo eles, alguem poderia me ajudar com alguma dica? desde ja agradeço.

 
  1. <?php
  2. // define the action for lance_id
  3. $obj_lance = new ConsultaLance();
  4. $obj_lance->set_formulario('form_arrematacao');
  5. $action_lance = new TAction(array($obj_lance, 'onReload'));
  6. $lance_id->setAction($action_lance);
  7. // define the action for lance_id
  8. $obj_leilao = new ConsultaLeilao();
  9. $obj_leilao->set_formulario('form_arrematacao');
  10. $action_leilao = new TAction(array($obj_leilao, 'onReload'));
  11. $leilao_id->setAction($action_leilao);
  12. ?>



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


NR

Fiz o mesmo teste aqui com 2 seeks e funcionou certinho.

Se possível poste o código no pastebin
AB

Obrigado pelo retorno Nataniel, hoje fui entrar e ver novamente, o primeiro seek esta OK, funcionando, o segundo ele da permissão negada, verifiquei nas permissoes e estaão OK, vou rever mais uma vez para ver e caso persista posto o código, caso encontre algo, posto aqui tambem para futura referencia.
AB

Desculpe a demora Nataniel, tive que passar outras coisas na frente, segue abaixo o código do form principal

 
  1. <?php
 
  1. <?php
  2. /**
  3. * arrematacaoForm Form
  4. * @author <your name here>
  5. */
  6. class arrematacaoForm extends TPage
  7. {
  8. protected $form; // form
  9. /**
  10. * Form constructor
  11. * @param $param Request
  12. */
  13. public function __construct( $param )
  14. {
  15. parent::__construct();
  16. // creates the form
  17. $this->form = new TQuickForm('form_arrematacao');
  18. $this->form->class = 'tform'; // change CSS class
  19. //$this->form = new BootstrapFormWrapper($this->form);
  20. $this->form->style = 'display: table;width:100%'; // change style
  21. // define the form title
  22. $this->form->setFormTitle('Arrematação');
  23. $id = new TEntry('id');
  24. $lote_id = new TEntry('lote_id');
  25. $numero_lote = new TEntry('numero_lote');
  26. $dados_leilao = new TEntry('dados_leilao');
  27. $codicional = new TCombo('codicional');
  28. $recibo_nr = new TEntry('recibo_nr');
  29. $tipo_adjudicacao = new TEntry('tipo_adjudicacao');
  30. $valor = new TEntry('valor');
  31. $numero_nota_fiscal = new TEntry('numero_nota_fiscal');
  32. $comprador = new ">TDBSeekButton('comprador','banco', 'form_arrematacao', 'cliente', 'nome', 'comprador', 'nome_cliente');
  33. $senha = new TEntry('senha');
  34. $venda_parcial = new TCombo('venda_parcial');
  35. $venda_percentual = new TEntry('venda_percentual');
  36. $venda_prazo = new TCombo('venda_prazo');
  37. $bem_removido = new TCombo('bem_removido');
  38. $alienacao_fiduciaria = new TCombo('alienacao_fiduciaria');
  39. $leilao_id = new TSeekButton('leilao_id');
  40. $status_id = new TDBCombo('status_id','banco', 'arrematacao_status', 'id', 'nome', 'nome');
  41. $tipo_venda = new TDBCombo('tipo_venda','banco', 'tipos_venda', 'id', 'nome', 'nome');
  42. $data_hora = new TDate('data_hora');
  43. $data_arremate = new TEntry('data_arremate');
  44. $hora_arremate = new TEntry('hora_arremate');
  45. $criteria_lance = new TCriteria;
  46. $criteria_lance->add(new TFilter('leilao_id', '=', $leilao_id));
  47. $criteria_lance->add(new TFilter('lote_id', '=', $lote_id));
  48. $criteria_lance->setProperty('order', 'nome');
  49. $lance_id = new TSeekButton('lance_id');
  50. $valor_produtos = new TEntry('valor_produtos');
  51. $situacao_arrematacao = new TCombo('situacao_arrematacao');
  52. $email_enviado = new TCombo('email_enviado');
  53. $observacoes = new TText('observacoes');
  54. $nome_cliente = new TEntry('nome_cliente');
  55. // define the action for lance_id
  56. $obj_lance = new ConsultaLance();
  57. $obj_lance->set_formulario('form_arrematacao');
  58. $action_lance = new TAction(array($obj_lance, 'onReload'));
  59. $lance_id->setAction($action_lance);
  60. // define the action for leilao_id
  61. $obj_leilao = new ConsultaLeilao();
  62. $obj_leilao->set_formulario('form_arrematacao');
  63. $action_leilao = new TAction(array($obj_leilao, 'onReload'));
  64. $leilao_id->setAction($action_leilao);
  65. $action_lote = new TAction(array($this, 'onPesquisaLote'));
  66. $numero_lote->setExitAction($action_lote);
  67. $sim_nao = array();
  68. $sim_nao[1] = 'Sim';
  69. $sim_nao[0] = 'Não';
  70. $codicional->addItems($sim_nao);
  71. $venda_parcial->addItems($sim_nao);
  72. $venda_prazo->addItems($sim_nao);
  73. $bem_removido->addItems($sim_nao);
  74. $alienacao_fiduciaria->addItems($sim_nao);
  75. $email_enviado->addItems($sim_nao);
  76. $sit_arremate = array();
  77. $sit_arremate['C'] = 'Concluso';
  78. $sit_arremate['D'] = 'Deferido';
  79. $sit_arremate['I'] = 'Indeferido';
  80. $situacao_arrematacao->addItems($sit_arremate);
  81. $valor->setNumericMask(2,',','.', TRUE);
  82. $valor_produtos->setNumericMask(2,',','.', TRUE);
  83. $id->setEditable(FALSE);
  84. $data_arremate->setEditable(FALSE);
  85. $hora_arremate->setEditable(FALSE);
  86. $dados_leilao->setEditable(FALSE);
  87. $nome_cliente->setEditable(FALSE);
  88. $lote_id->setEditable(FALSE);
  89. $codicional->addValidation('Condicional', new TRequiredValidator);
  90. $comprador->addValidation('Arrematante', new TRequiredValidator);
  91. $id->setSize(100);
  92. $lote_id->setSize(100);
  93. $numero_lote->setSize(80);
  94. $codicional->setSize(80);
  95. $recibo_nr->setSize(100);
  96. $tipo_adjudicacao->setSize(200);
  97. $valor->setSize(100);
  98. $numero_nota_fiscal->setSize(100);
  99. $comprador->setSize(100);
  100. $senha->setSize(100);
  101. $venda_parcial->setSize(80);
  102. $venda_percentual->setSize(100);
  103. $venda_prazo->setSize(80);
  104. $bem_removido->setSize(100);
  105. $alienacao_fiduciaria->setSize(80);
  106. $leilao_id->setSize(100);
  107. $status_id->setSize(120);
  108. $tipo_venda->setSize(200);
  109. $data_arremate->setSize(100);
  110. $hora_arremate->setSize(100);
  111. $lance_id->setSize(100);
  112. $valor_produtos->setSize(100);
  113. $situacao_arrematacao->setSize(100);
  114. $email_enviado->setSize(100,30);
  115. $observacoes->setSize(1000, 40);
  116. $nome_cliente->setSize(500);
  117. $dados_leilao->setSize(500);
  118. $id->style = ('text-align:center;color:#ff0000;font-weight:bold;font-size:14px;');
  119. $lote_id->style = ('text-align:center;color:#ff0000;font-weight:bold;font-size:14px;display:none');
  120. $data_hora->style = ('text-align:center;color:#ff0000;font-weight:bold;font-size:14px;display:none');
  121. $recibo_nr->style = ('text-align:center;color:#ff0000;font-weight:bold;font-size:14px;');
  122. $numero_nota_fiscal->style = ('text-align:center;color:#ff0000;font-weight:bold;font-size:14px;');
  123. $senha->style = ('text-align:center;color:#ff0000;font-weight:bold;font-size:14px;');
  124. $data_arremate->style = ('text-align:center;color:#ff0000;font-weight:bold;font-size:14px;');
  125. $hora_arremate->style = ('text-align:center;color:#ff0000;font-weight:bold;font-size:14px;');
  126. $lance_id->style = ('text-align:center;color:#ff0000;font-weight:bold;font-size:14px;');
  127. $numero_lote->style = ('text-align:center;color:#ff0000;font-weight:bold;font-size:14px;');
  128. $linha1 = array(new TLabel('Leilão: '), $leilao_id);
  129. $linha2 = array($dados_leilao);
  130. $linha = array_merge($linha1, $linha2);
  131. $this->form->addQuickFields('',$linha);
  132. $linha1 = array(new TLabel('Código: '), $id);
  133. $linha2 = array(new TLabel('Lote: '), $numero_lote, $lote_id);
  134. $linha3 = array(new TLabel('Lance: '), $lance_id);;
  135. $linha = array_merge($linha1, $linha2, $linha3);
  136. $this->form->addQuickFields('',$linha);
  137. $linha1 = array(new TLabel('Condicional: '), $codicional);
  138. $linha2 = array(new TLabel('Nº. Recibo: '), $recibo_nr);
  139. $linha3 = array(new TLabel('Tipo Adjudicação: '), $tipo_adjudicacao);
  140. $linha4 = array(new TLabel('Nº. Senha: '), $senha);
  141. $linha = array_merge($linha1, $linha2, $linha3, $linha4);
  142. $this->form->addQuickFields('',$linha);
  143. $linha1 = array(new TLabel('Valor Arremate: '), $valor);
  144. $linha2 = array(new TLabel('Valor Produto: '), $valor_produtos);
  145. $linha3 = array(new TLabel('% Venda: '), $venda_percentual);
  146. $linha4 = array(new TLabel('Tipo Venda: '), $tipo_venda);
  147. $linha = array_merge($linha1, $linha2, $linha3, $linha4);
  148. $this->form->addQuickFields('',$linha);
  149. $linha1 = array(new TLabel('Venda Parcial: '), $venda_parcial);
  150. $linha2 = array(new TLabel('Venda Prazo: '), $venda_prazo);
  151. $linha3 = array(new TLabel('Alienação Fiduciária: '), $alienacao_fiduciaria);
  152. $linha4 = array(new TLabel('Status: '), $status_id);
  153. $linha = array_merge($linha1, $linha2, $linha3, $linha4);
  154. $this->form->addQuickFields('',$linha);
  155. $linha1 = array(new TLabel('Arrematante: '), $comprador);
  156. $linha2 = array($nome_cliente);
  157. $linha3 = array(new TLabel('Nº. Nota Venda: '), $numero_nota_fiscal);
  158. $linha = array_merge($linha1, $linha2, $linha3);
  159. $this->form->addQuickFields('',$linha);
  160. $linha1 = array(new TLabel('Situação da Arrematação: '), $situacao_arrematacao);
  161. $linha2 = array(new TLabel('Data: '), $data_arremate, $data_hora);
  162. $linha3 = array(new TLabel('Hora: '), $hora_arremate);
  163. $linha4 = array(new TLabel('Bem Removido: '), $bem_removido);
  164. $linha5 = array(new TLabel('Email Enviado: '), $email_enviado);
  165. $linha = array_merge($linha1, $linha2, $linha3, $linha4, $linha5);
  166. $this->form->addQuickFields('',$linha);
  167. // add the fields
  168. $linha1 = array(new TLabel('Observação: '), $observacoes);
  169. $linha = array_merge($linha1);
  170. $this->form->addQuickFields('',$linha);
  171. // create the form actions
  172. $this->form->addQuickAction(_t('Save'), new TAction(array($this, 'onSave')), 'fa:floppy-o');
  173. $this->form->addQuickAction(_t('New'), new TAction(array($this, 'onClear')), 'bs:plus-sign green');
  174. // vertical box container
  175. $container = new TVBox;
  176. $container->style = 'width: 90%';
  177. $container->add($this->form);
  178. parent::add($container);
  179. }
  180. /**
  181. * Save form data
  182. * @param $param Request
  183. */
  184. public function onSave( $param )
  185. {
  186. try
  187. {
  188. TTransaction::open('banco'); // open a transaction
  189. /**
  190. // Enable Debug logger for SQL operations inside the transaction
  191. TTransaction::setLogger(new TLoggerSTD); // standard output
  192. TTransaction::setLogger(new TLoggerTXT('log.txt')); // file
  193. **/
  194. $this->form->validate(); // validate form data
  195. $object = new arrematacao; // create an empty object
  196. $data = $this->form->getData(); // get form data as array
  197. $object->fromArray( (array) $data); // load the object with data
  198. $object->store(); // save the object
  199. // get the generated id
  200. $data->id = $object->id;
  201. $this->form->setData($data); // fill form data
  202. TTransaction::close(); // close the transaction
  203. new TMessage('info', TAdiantiCoreTranslator::translate('Record saved'));
  204. }
  205. catch (Exception $e) // in case of exception
  206. {
  207. new TMessage('error', $e->getMessage()); // shows the exception error message
  208. $this->form->setData( $this->form->getData() ); // keep form data
  209. TTransaction::rollback(); // undo all pending operations
  210. }
  211. }
  212. public static function onPesquisaLote( $param )
  213. {
  214. TSession::setValue('numeroLote', $param['numero_lote']);
  215. }
  216. /**
  217. * Clear form data
  218. * @param $param Request
  219. */
  220. public function onClear( $param )
  221. {
  222. $this->form->clear();
  223. }
  224. /**
  225. * Load object to form data
  226. * @param $param Request
  227. */
  228. public function onEdit( $param )
  229. {
  230. try
  231. {
  232. if (isset($param['key']))
  233. {
  234. $key = $param['key']; // get the parameter $key
  235. TTransaction::open('anco'); // open a transaction
  236. $object = new arrematacao($key); // instantiates the Active Record
  237. $this->form->setData($object); // fill the form
  238. TTransaction::close(); // close the transaction
  239. }
  240. else
  241. {
  242. $this->form->clear();
  243. }
  244. }
  245. catch (Exception $e) // in case of exception
  246. {
  247. new TMessage('error', $e->getMessage()); // shows the exception error message
  248. TTransaction::rollback(); // undo all pending operations
  249. }
  250. }
  251. }
  252. ?>
</your>
AB

Form da consulta


 
  1. <?php
  2. /**
  3. * Formulario de Consulta de Lances
  4. *
  5. * @version 1.0
  6. * @package
  7. * @subpackage
  8. * @author Agostinho Francisco Barbosa
  9. */
  10. class ConsultaLeilao extends TWindow
  11. {
  12. private $form; // form
  13. private $datagrid; // datagrid
  14. private $pageNavigation;
  15. private $loaded;
  16. /**
  17. * Class constructor
  18. * Creates the page, the search form and the listing
  19. */
  20. public function __construct()
  21. {
  22. parent::__construct();
  23. parent::setSize(700, 600);
  24. parent::setTitle('Consulta Leilão');
  25. new TSession;
  26. // creates the form
  27. $this->form = new TQuickForm('form_consulta_leilao');
  28. $this->form->class = 'tform';
  29. // create the form fields
  30. $data_leilao = new TDate('data_leilao');
  31. $data_leilao->setMask('99/99/9999');
  32. // add the form fields
  33. $this->form->addQuickField('Data Leilão', $data_leilao, 100);
  34. // define the form action
  35. $this->form->addQuickAction('Find', new TAction(array($this, 'onSearch')), 'ico_find.png');
  36. // creates a DataGrid
  37. $this->datagrid = new TQuickGrid;
  38. $this->datagrid->style = 'width: 100%';
  39. $this->datagrid->setHeight(230);
  40. // creates the datagrid columns
  41. $column_id = $this->datagrid->addQuickColumn('Id', 'id', 'center', 40);
  42. $column_realizacao = $this->datagrid->addQuickColumn('Data Realização', 'data_realizacao', 'center', 100);
  43. $column_nome = $this->datagrid->addQuickColumn('Descrição', 'nome', 'left', 100);
  44. $column_leiloeiro = $this->datagrid->addQuickColumn('Leiloeiro', 'nome_leiloeiro', 'left', 200);
  45. $column_realizacao->setTransformer( function($value, $object, $row) {
  46. return TDate::date2br($value);
  47. });
  48. // creates two datagrid actions
  49. $this->datagrid->addQuickAction('Select', new TDataGridAction(array($this, 'onSelect')), 'id', 'ico_apply.png');
  50. // create the datagrid model
  51. $this->datagrid->createModel();
  52. // creates the page navigation
  53. $this->pageNavigation = new TPageNavigation;
  54. $this->pageNavigation->setAction(new TAction(array($this, 'onReload')));
  55. $this->pageNavigation->setWidth($this->datagrid->getWidth());
  56. // creates a container
  57. $container = new TVBox;
  58. $container->style = 'width: 100%';
  59. $container->add($this->form);
  60. $container->add($this->datagrid);
  61. $container->add($this->pageNavigation);
  62. // add the container inside the page
  63. parent::add($container);
  64. }
  65. /**
  66. * method onSearch()
  67. * Register the filter in the session when the user performs a search
  68. */
  69. function onSearch()
  70. {
  71. // get the search form data
  72. $data = $this->form->getData();
  73. // check if the user has filled the form
  74. if (isset($data->data_leilao))
  75. {
  76. $data->data_leilao = TDate::date2us($data->data_leilao);
  77. // creates a filter using what the user has typed
  78. $filtro_data_leilao = new TFilter('data_realizacao', '=', "{$data->data_leilao}");
  79. // stores the filter in the session
  80. TSession::setValue('data_leilao_filtro', $filtro_data_leilao);
  81. $data->data_leilao = TDate::date2br($data->data_leilao);
  82. $this->form->setData($data);
  83. }
  84. // redefine the parameters for reload method
  85. $param = array();
  86. $param['offset'] = 0;
  87. $param['first_page'] = 1;
  88. $this->onReload($param);
  89. }
  90. /**
  91. * Load the datagrid with the database objects
  92. */
  93. function onReload($param = NULL)
  94. {
  95. try
  96. {
  97. // open a transaction with database 'samples'
  98. TTransaction::open('brldb');
  99. // creates a repository for City
  100. $repository = new TRepository('interativo_leilao');
  101. $limit = 10;
  102. $criteria = new TCriteria;
  103. // default order
  104. if (!isset($param['order']))
  105. {
  106. $param['order'] = 'data_realizacao';
  107. $param['direction'] = 'desc';
  108. }
  109. $criteria->setProperties($param); // order, offset
  110. $criteria->setProperty('limit', $limit);
  111. if (TSession::getValue('data_leilao_filtro'))
  112. {
  113. // add the filter stored in the session to the criteria
  114. $criteria->add(TSession::getValue('data_leilao_filtro'));
  115. }
  116. // load the objects according to the criteria
  117. $lista_leilao = $repository->load($criteria);
  118. $this->datagrid->clear();
  119. if ($lista_leilao)
  120. {
  121. foreach ($lista_leilao as $leilao)
  122. {
  123. // add the object inside the datagrid
  124. $this->datagrid->addItem($leilao);
  125. }
  126. }
  127. // reset the criteria for record count
  128. $criteria->resetProperties();
  129. $count = $repository->count($criteria);
  130. $this->pageNavigation->setCount($count); // count of records
  131. $this->pageNavigation->setProperties($param); // order, page
  132. $this->pageNavigation->setLimit($limit); // limit
  133. // close the transaction
  134. TTransaction::close();
  135. $this->loaded = true;
  136. }
  137. catch (Exception $e) // in case of exception
  138. {
  139. // shows the exception error message
  140. new TMessage('error', $e->getMessage());
  141. // undo all pending operations
  142. TTransaction::rollback();
  143. }
  144. }
  145. /**
  146. * Executed when the user chooses the record
  147. */
  148. public function onSelect($param)
  149. {
  150. try
  151. {
  152. $key = $param['key'];
  153. TTransaction::open('brldb');
  154. // load the active record
  155. $leilao = new interativo_leilao($key);
  156. $object = new StdClass;
  157. $object->leilao_id = $leilao->id;
  158. $object->dados_leilao = $leilao->dados_leilao;
  159. TForm::sendData(TSession::getValue('form_chamador_leilao'), $object);
  160. // closes the transaction
  161. TTransaction::close();
  162. parent::closeWindow(); // close the window
  163. }
  164. catch (Exception $e) // em caso de exceção
  165. {
  166. // clear fields
  167. $object = new StdClass;
  168. $object->leilao_id = '';
  169. $object->dados_leilao = '';
  170. TForm::sendData($this->form_chamador, $object);
  171. // undo pending operations
  172. TTransaction::rollback();
  173. }
  174. }
  175. /**
  176. * Shows the page
  177. */
  178. function show()
  179. {
  180. // if the datagrid was not loaded yet
  181. if (!$this->loaded)
  182. {
  183. $this->onReload();
  184. }
  185. parent::show();
  186. }
  187. function set_formulario($formulario)
  188. {
  189. TSession::setValue('form_chamador_leilao', $formulario);
  190. }
  191. function get_formulario()
  192. {
  193. return TSession::getValue('form_chamador_leilao');
  194. }
  195. }
  196. ?>
AB

Descobri uma coisa, no form de consulta o campo $data_leilao é um campo de data, se passo para input normal não ocorre, ou seja

assim ele coloca o formulario de consulta abaixo no form
 
  1. <?php
  2. $data_leilao = new TDate('data_leilao');
  3. $data_leilao->setMask('99/99/9999');
  4. ?>

Assim ele faz certo, ou seja abre em uma Janela
 
  1. <?php
  2. $data_leilao = new TInput('data_leilao');
  3. $data_leilao->setMask('99/99/9999');
  4. ?>

AB

new TInput não, desculpem, new TEntry

 
  1. <?php
  2. $data_leilao = new TEntry('data_leilao');
  3. $data_leilao->setMask('99/99/9999');
  4. ?>
NR

Agostinho, o formato da máscara da data está incorreto. Isso está gerando um erro javascript. Deixe no formato abaixo que vai funcionar:
 
  1. <?php
  2. $data_leilao->setMask('dd/mm/yyyy');
  3. ?>
AB

Bom Dia Nataniel, era isso mesmo, coisas pequenas que não prestamos atenção. funcionou 100%.

Obrigado