Conheça as melhorias da versão 8.0, 8.1, 8.2!
Clique aqui para saber mais
ajuda com TDropDown Bom dia, alguém pode me ajudar como faço pra colocar esse $dropdown do lado do Botão Novo, imagem em anexo para visualizar melhor o que quero ...
RS
ajuda com TDropDown  
Bom dia, alguém pode me ajudar como faço pra colocar esse $dropdown do lado do Botão Novo, imagem em anexo para visualizar melhor o que quero


 
  1. <?php
  2. class ReceberList extends TPage
  3. {
  4. private $form; // form
  5. private $datagrid; // listing
  6. private $pageNavigation;
  7. private $formgrid;
  8. private $loaded;
  9. private $deleteButton;
  10. /**
  11. * Class constructor
  12. * Creates the page, the form and the listing
  13. */
  14. public function __construct()
  15. {
  16. parent::__construct();
  17. parent::include_css('app/resources/custom-table.css');
  18. // creates the form
  19. $this->form = new TQuickForm('form_search_Receber');
  20. $this->form->class = 'tform'; // change CSS class
  21. $this->form = new BootstrapFormWrapper($this->form);
  22. $this->form->style = 'display: table;width:100%'; // change style
  23. $this->form->setFormTitle('Receber');
  24. // create the form fields
  25. $numero = new TEntry('numero');
  26. $id_cliente = new TDBCombo('id_cliente','scomcomercio','Clientes','cli_codigo','cli_nome');
  27. $emissao = new TDate('emissao');
  28. $vencimento = new TDate('vencimento');
  29. $pagamento = new TDate('pagamento');
  30. $tipo = new TRadioGroup('tipo');
  31. $tipo->addItems(array('A'=>'Abertas', 'L'=>'Liquidadas', 'T'=>'TODAS'));
  32. $tipo->setLayout('horizontal');
  33. $tipo->SetUseButton();
  34. $this->form->setFieldsByRow(2);
  35. // add the fields
  36. $this->form->addQuickField('Numero', $numero, '40%' );
  37. $this->form->addQuickField('Cliente', $id_cliente, '100%' );
  38. $this->form->addQuickField('Emissão', $emissao, '40%' );
  39. $this->form->addQuickField('Vencimento', $vencimento, '40%' );
  40. $this->form->addQuickField('Pagamento', $pagamento, '40%' );
  41. $this->form->addQuickField('Somente', $tipo, '100%' );
  42. // keep the form filled during navigation with session data
  43. $this->form->setData( TSession::getValue('Receber_filter_data') );
  44. // add the search form actions
  45. $btn = $this->form->addQuickAction(_t('Find'), new TAction(array($this, 'onSearch')), 'fa:search');
  46. $btn->class = 'btn btn-sm btn-primary';
  47. $this->form->addQuickAction(_t('New'), new TAction(array('ReceberForm', 'onEdit')), 'bs:plus-sign green');
  48. // $this->form->addQuickAction('Relaório', new TAction(['ViewReceberAbertosReport', 'onClear']), 'bs:print');
  49. //colocar esse TDropDown no formulário
  50. $dropdown = new TDropDown('Dropdown test', 'fa:list');
  51. $dropdown->addAction( 'Show a message', new TAction(array($this, 'onMessage') ));
  52. $dropdown->addAction( 'Customer list', new TAction(array('ReceberList', 'onReload') ));
  53. $this->form->add($dropdown);
  54. // creates a Datagrid
  55. $this->datagrid = new TDataGrid;
  56. //$this->datagrid = new BootstrapDatagridWrapper($this->datagrid);
  57. $this->datagrid->style = 'width: 100%';
  58. $this->datagrid->datatable = 'true';
  59. // $this->datagrid->enablePopover('Popover', 'Hi <b> {name} </b>');
  60. // creates the datagrid columns
  61. $column_numero = new TDataGridColumn('numero', 'Numero', 'left');
  62. $column_id_cliente = new TDataGridColumn('clientes->cli_nome', 'Cliente', 'left');
  63. $column_emissao = new TDataGridColumn('emissao', 'Emissão', 'left');
  64. $column_vencimento = new TDataGridColumn('vencimento', 'Vencimento', 'left');
  65. $column_pagamento = new TDataGridColumn('pagamento', 'Pagamento', 'left');
  66. // $column_referente = new TDataGridColumn('referente', 'Referente', 'left');
  67. $column_id_pedido = new TDataGridColumn('id_pedido', 'Pedido', 'right');
  68. $column_valor = new TDataGridColumn('valor', 'Valor', 'right');
  69. // add the columns to the DataGrid
  70. $this->datagrid->addColumn($column_numero);
  71. $this->datagrid->addColumn($column_id_cliente);
  72. $this->datagrid->addColumn($column_emissao);
  73. $this->datagrid->addColumn($column_vencimento);
  74. $this->datagrid->addColumn($column_pagamento);
  75. // $this->datagrid->addColumn($column_referente);
  76. $this->datagrid->addColumn($column_id_pedido);
  77. $this->datagrid->addColumn($column_valor);
  78. // define the transformer method over image
  79. $column_emissao->setTransformer( function($value, $object, $row) {
  80. $date = new DateTime($value);
  81. return $date->format('d/m/Y');
  82. });
  83. // define the transformer method over image
  84. $column_vencimento->setTransformer( function($value, $object, $row) {
  85. $date = new DateTime($value);
  86. return $date->format('d/m/Y');
  87. });
  88. // define the transformer method over image
  89. $column_pagamento->setTransformer( function($value, $object, $row) {
  90. $date = TDate::date2br($value);
  91. //new DateTime($value);
  92. return $date;
  93. //->format('d/m/Y');
  94. });
  95. // define the transformer method over image
  96. $column_valor->setTransformer( function($value, $object, $row) {
  97. return number_format($value, 2, ',', '.');
  98. });
  99. $column_valor->setTotalFunction( function($values) {
  100. return array_sum((array) $values);
  101. });
  102. /*
  103. $order_Id = new TAction(array($this, 'onReload'));
  104. $order_Id->setParameter('order', 'numero');
  105. $column_Id->setAction($order_Id);
  106. */
  107. // create EDIT action
  108. $action_edit = new TDataGridAction(array('ReceberForm', 'onEdit'));
  109. //$action_edit->setUseButton(TRUE);
  110. //$action_edit->setButtonClass('btn btn-default');
  111. $action_edit->setLabel(_t('Edit'));
  112. $action_edit->setImage('fa:pencil-square-o blue fa-lg');
  113. $action_edit->setField('Id');
  114. $this->datagrid->addAction($action_edit);
  115. // create DELETE action
  116. $action_del = new TDataGridAction(array($this, 'onDelete'));
  117. //$action_del->setUseButton(TRUE);
  118. //$action_del->setButtonClass('btn btn-default');
  119. $action_del->setLabel(_t('Delete'));
  120. $action_del->setImage('fa:trash-o red fa-lg');
  121. $action_del->setField('Id');
  122. $this->datagrid->addAction($action_del);
  123. $action_receber = new TDataGridAction(array('ReceberFormBaixa', 'onEdit'));
  124. $action_receber->setLabel('Baixar');
  125. $action_receber->setImage('baixa.png');
  126. $action_receber->setField('Id');
  127. $this->datagrid->addAction($action_receber);
  128. // create the datagrid model
  129. $this->datagrid->createModel();
  130. // creates the page navigation
  131. $this->pageNavigation = new TPageNavigation;
  132. $this->pageNavigation->setAction(new TAction(array($this, 'onReload')));
  133. $this->pageNavigation->setWidth($this->datagrid->getWidth());
  134. // vertical box container
  135. $container = new TVBox;
  136. $container->style = 'width: 100%';
  137. $container->add(new TXMLBreadCrumb('menu.xml', __CLASS__));
  138. //$container->add($dropdown);
  139. $container->add(TPanelGroup::pack('Contas a Receber', $this->form));
  140. $container->add(TPanelGroup::pack('', $this->datagrid, $this->pageNavigation));
  141. parent::add($container);
  142. }
  143. /**
  144. * Inline record editing
  145. * @param $param Array containing:
  146. * key: object ID value
  147. * field name: object attribute to be updated
  148. * value: new attribute content
  149. */
  150. public function onInlineEdit($param)
  151. {
  152. try
  153. {
  154. // get the parameter $key
  155. $field = $param['field'];
  156. $key = $param['key'];
  157. $value = $param['value'];
  158. TTransaction::open('scomcomercio'); // open a transaction with database
  159. $object = new Receber($key); // instantiates the Active Record
  160. $object->{$field} = $value;
  161. $object->store(); // update the object in the database
  162. TTransaction::close(); // close the transaction
  163. $this->onReload($param); // reload the listing
  164. new TMessage('info', "Record Updated");
  165. }
  166. catch (Exception $e) // in case of exception
  167. {
  168. new TMessage('error', $e->getMessage()); // shows the exception error message
  169. TTransaction::rollback(); // undo all pending operations
  170. }
  171. }
  172. /**
  173. * Register the filter in the session
  174. */
  175. public function onSearch()
  176. {
  177. // get the search form data
  178. $data = $this->form->getData();
  179. // clear session filters
  180. TSession::setValue('ReceberList_filter_numero', NULL);
  181. TSession::setValue('ReceberList_filter_id_cliente', NULL);
  182. TSession::setValue('ReceberList_filter_emissao', NULL);
  183. TSession::setValue('ReceberList_filter_vencimento', NULL);
  184. TSession::setValue('ReceberList_filter_pagamento', NULL);
  185. TSession::setValue('ReceberList_filter_tipo', NULL);
  186. if (isset($data->numero) AND ($data->numero)) {
  187. $filter = new TFilter('numero', '=', "$data->numero"); // create the filter
  188. TSession::setValue('ReceberList_filter_numero', $filter); // stores the filter in the session
  189. }
  190. if (isset($data->id_cliente) AND ($data->id_cliente)) {
  191. $filter = new TFilter('id_cliente', 'like', "%{$data->id_cliente}%"); // create the filter
  192. TSession::setValue('ReceberList_filter_id_cliente', $filter); // stores the filter in the session
  193. }
  194. if (isset($data->emissao) AND ($data->emissao)) {
  195. $filter = new TFilter('emissao', '=', "$data->emissao"); // create the filter
  196. TSession::setValue('ReceberList_filter_emissao', $filter); // stores the filter in the session
  197. }
  198. if (isset($data->vencimento) AND ($data->vencimento)) {
  199. $filter = new TFilter('vencimento', '=', "$data->vencimento"); // create the filter
  200. TSession::setValue('ReceberList_filter_vencimento', $filter); // stores the filter in the session
  201. }
  202. if (isset($data->pagamento) AND ($data->pagamento)) {
  203. $filter = new TFilter('pagamento', '=', "$data->pagamento"); // create the filter
  204. TSession::setValue('ReceberList_filter_pagamento', $filter); // stores the filter in the session
  205. }
  206. if (isset($data->tipo) AND ($data->tipo)) {
  207. if ($data->tipo=='A'){
  208. $filter = new TFilter('pagamento', 'IS', NULL); // create the filter
  209. }
  210. if ($data->tipo=='L'){
  211. $filter = new TFilter('pagamento', 'IS NOT', NULL); // create the filter
  212. }
  213. if ($data->tipo=='T'){
  214. $filter = new TCriteria;
  215. $filter->add(new TFilter('pagamento', 'IS', NULL), TExpression::OR_OPERATOR);
  216. $filter->add(new TFilter('pagamento', 'IS NOT', NULL), TExpression::OR_OPERATOR);
  217. }
  218. TSession::setValue('ReceberList_filter_tipo', $filter); // stores the filter in the session
  219. }
  220. // fill the form with data again
  221. $this->form->setData($data);
  222. // keep the search data in the session
  223. TSession::setValue('Receber_filter_data', $data);
  224. $param=array();
  225. $param['offset'] =0;
  226. $param['first_page']=1;
  227. $this->onReload($param);
  228. }
  229. /**
  230. * Load the datagrid with data
  231. */
  232. public function onReload($param = NULL)
  233. {
  234. try
  235. {
  236. // open a transaction with database 'scomcomercio'
  237. TTransaction::open('scomcomercio');
  238. // creates a repository for Receber
  239. $repository = new TRepository('Receber');
  240. $limit = 10;
  241. // creates a criteria
  242. $criteria = new TCriteria;
  243. // default order
  244. if (empty($param['order']))
  245. {
  246. $param['order'] = 'numero';
  247. $param['direction'] = 'asc';
  248. }
  249. $criteria->setProperties($param); // order, offset
  250. $criteria->setProperty('limit', $limit);
  251. if (TSession::getValue('ReceberList_filter_numero')) {
  252. $criteria->add(TSession::getValue('ReceberList_filter_numero')); // add the session filter
  253. }
  254. if (TSession::getValue('ReceberList_filter_id_cliente')) {
  255. $criteria->add(TSession::getValue('ReceberList_filter_id_cliente')); // add the session filter
  256. }
  257. if (TSession::getValue('ReceberList_filter_emissao')) {
  258. $criteria->add(TSession::getValue('ReceberList_filter_emissao')); // add the session filter
  259. }
  260. if (TSession::getValue('ReceberList_filter_vencimento')) {
  261. $criteria->add(TSession::getValue('ReceberList_filter_vencimento')); // add the session filter
  262. }
  263. if (TSession::getValue('ReceberList_filter_pagamento')) {
  264. $criteria->add(TSession::getValue('ReceberList_filter_pagamento')); // add the session filter
  265. }
  266. if (TSession::getValue('ReceberList_filter_tipo')) {
  267. $criteria->add(TSession::getValue('ReceberList_filter_tipo')); // add the session filter
  268. }
  269. // load the objects according to criteria
  270. $objects = $repository->load($criteria, FALSE);
  271. if (is_callable($this->transformCallback))
  272. {
  273. call_user_func($this->transformCallback, $objects, $param);
  274. }
  275. $this->datagrid->clear();
  276. if ($objects)
  277. {
  278. // iterate the collection of active records
  279. foreach ($objects as $object)
  280. {
  281. // add the object inside the datagrid
  282. $this->datagrid->addItem($object);
  283. }
  284. }
  285. // reset the criteria for record count
  286. $criteria->resetProperties();
  287. $count= $repository->count($criteria);
  288. $this->pageNavigation->setCount($count); // count of records
  289. $this->pageNavigation->setProperties($param); // order, page
  290. $this->pageNavigation->setLimit($limit); // limit
  291. // close the transaction
  292. TTransaction::close();
  293. $this->loaded = true;
  294. }
  295. catch (Exception $e) // in case of exception
  296. {
  297. // shows the exception error message
  298. new TMessage('error', $e->getMessage());
  299. // undo all pending operations
  300. TTransaction::rollback();
  301. }
  302. }
  303. /**
  304. * Ask before deletion
  305. */
  306. public function onDelete($param)
  307. {
  308. // define the delete action
  309. $action = new TAction(array($this, 'onDelCerteza'));
  310. $action->setParameters($param); // pass the key parameter ahead
  311. // shows a dialog to the user
  312. new TQuestion(AdiantiCoreTranslator::translate('Do you really want to delete ?'), $action);
  313. }
  314. /**
  315. * Delete a record
  316. */
  317. public function onDelCerteza($param)
  318. {
  319. // define the delete action
  320. $action = new TAction(array($this, 'Delete'));
  321. $action->setParameters($param); // pass the key parameter ahead
  322. // shows a dialog to the user
  323. new TQuestion('Tem certeza ?', $action);
  324. }
  325. public function Delete($param)
  326. {
  327. try
  328. {
  329. $key=$param['key']; // get the parameter $key
  330. TTransaction::open('scomcomercio'); // open a transaction with database
  331. $object = new Receber($key, FALSE); // instantiates the Active Record
  332. $object->delete(); // deletes the object from the database
  333. TTransaction::close(); // close the transaction
  334. $this->onReload( $param ); // reload the listing
  335. new TMessage('info', AdiantiCoreTranslator::translate('Record deleted')); // success message
  336. }
  337. catch (Exception $e) // in case of exception
  338. {
  339. new TMessage('error', $e->getMessage()); // shows the exception error message
  340. TTransaction::rollback(); // undo all pending operations
  341. }
  342. }
  343. /**
  344. * method show()
  345. * Shows the page
  346. */
  347. public function show()
  348. {
  349. // check if the datagrid is already loaded
  350. if (!$this->loaded AND (!isset($_GET['method']) OR !(in_array($_GET['method'], array('onReload', 'onSearch')))) )
  351. {
  352. if (func_num_args() > 0)
  353. {
  354. $this->onReload( func_get_arg(0) );
  355. }
  356. else
  357. {
  358. $this->onReload();
  359. }
  360. }
  361. parent::show();
  362. }
  363. function onMessage()
  364. {
  365. new TMessage('info','entrei');
  366. }
  367. }
  368. ?>

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


MC

Boas;

Vou deixar na Aba Contribuição a Alteração que fiz, para quem sabe numa próxima versão sege implementada.

Depois volto aqui para deixar o link

Abraços
MC

Boas;

Links da Contribuicao, espero ter ajudado:

Update Compenente
www.adianti.com.br/forum/pt/view_4044?tbootstrapformbuilder-add-tdro


Imagem de Uso
www.adianti.com.br/forum/pt/view_4045?tdropdown-apenas-imagem-de-uso
RS

Obrigado
RS

boa tarde, eu estou usando o BootstrapFormWrapper daria pra fazer estas mudanças nele?
MC

Robson, boas

Até onde eu vi e sei (posso estar enganado), vc pegou um form comum e o transformou em
Bootstrap, neste caso acredito que sim, é só fazendo o teste para saber.

Agora, pq você não usa o Bootstrap direto.

As mudanças seriam minimas e iria direto ao assunto.

Abaixo algumas mudanças (ou todas) no seu codigo.


 
  1. <?php
  2. de...
  3. // creates the form
  4. $this->form = new TQuickForm('form_search_Receber');
  5. $this->form->class = 'tform'; // change CSS class
  6. $this->form = new BootstrapFormWrapper($this->form);
  7. $this->form->style = 'display: table;width:100%'; // change style
  8. $this->form->setFormTitle('Receber');
  9. para....
  10. // Form Principal
  11. $this->form = new BootstrapFormBuilder( 'form_'.__CLASS__ );
  12. $this->form->setFormTitle('Receber' );
  13. de....
  14. // add the fields
  15. $this->form->addQuickField('Numero', $numero, '40%' );
  16. $this->form->addQuickField('Cliente', $id_cliente, '100%' );
  17. $this->form->addQuickField('Emissão', $emissao, '40%' );
  18. $this->form->addQuickField('Vencimento', $vencimento, '40%' );
  19. $this->form->addQuickField('Pagamento', $pagamento, '40%' );
  20. $this->form->addQuickField('Somente', $tipo, '100%' );
  21. para.....
  22. // add the fields
  23. $this->form->addFields(['Numero'], [$numero] );
  24. $this->form->addFields(['Cliente'], [$id_cliente] );
  25. $this->form->addFields(['Emissão'], [$emissao] );
  26. $this->form->addFields(['Vencimento'], [$vencimento] );
  27. $this->form->addFields(['Pagamento'], [$pagamento] );
  28. $this->form->addFields(['Somente'], [$tipo] );
  29. $numero->setSize('40%');
  30. ...........etc....................
  31. ?>
RS

Obrigado Marco, vou fazer conforme me indicou...valeu