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
- <?php
- class ReceberList extends TPage
- {
- private $form; // form
- private $datagrid; // listing
- private $pageNavigation;
- private $formgrid;
- private $loaded;
- private $deleteButton;
- /**
- * Class constructor
- * Creates the page, the form and the listing
- */
- public function __construct()
- {
- parent::__construct();
- parent::include_css('app/resources/custom-table.css');
- // creates the form
- $this->form = new TQuickForm('form_search_Receber');
- $this->form->class = 'tform'; // change CSS class
- $this->form = new BootstrapFormWrapper($this->form);
- $this->form->style = 'display: table;width:100%'; // change style
- $this->form->setFormTitle('Receber');
- // create the form fields
- $numero = new TEntry('numero');
- $id_cliente = new TDBCombo('id_cliente','scomcomercio','Clientes','cli_codigo','cli_nome');
- $emissao = new TDate('emissao');
- $vencimento = new TDate('vencimento');
- $pagamento = new TDate('pagamento');
- $tipo = new TRadioGroup('tipo');
- $tipo->addItems(array('A'=>'Abertas', 'L'=>'Liquidadas', 'T'=>'TODAS'));
- $tipo->setLayout('horizontal');
- $tipo->SetUseButton();
- $this->form->setFieldsByRow(2);
- // add the fields
- $this->form->addQuickField('Numero', $numero, '40%' );
- $this->form->addQuickField('Cliente', $id_cliente, '100%' );
- $this->form->addQuickField('Emissão', $emissao, '40%' );
- $this->form->addQuickField('Vencimento', $vencimento, '40%' );
- $this->form->addQuickField('Pagamento', $pagamento, '40%' );
- $this->form->addQuickField('Somente', $tipo, '100%' );
- // keep the form filled during navigation with session data
- $this->form->setData( TSession::getValue('Receber_filter_data') );
- // add the search form actions
- $btn = $this->form->addQuickAction(_t('Find'), new TAction(array($this, 'onSearch')), 'fa:search');
- $btn->class = 'btn btn-sm btn-primary';
- $this->form->addQuickAction(_t('New'), new TAction(array('ReceberForm', 'onEdit')), 'bs:plus-sign green');
- // $this->form->addQuickAction('Relaório', new TAction(['ViewReceberAbertosReport', 'onClear']), 'bs:print');
- //colocar esse TDropDown no formulário
- $dropdown = new TDropDown('Dropdown test', 'fa:list');
- $dropdown->addAction( 'Show a message', new TAction(array($this, 'onMessage') ));
- $dropdown->addAction( 'Customer list', new TAction(array('ReceberList', 'onReload') ));
- $this->form->add($dropdown);
- // creates a Datagrid
- $this->datagrid = new TDataGrid;
- //$this->datagrid = new BootstrapDatagridWrapper($this->datagrid);
- $this->datagrid->style = 'width: 100%';
- $this->datagrid->datatable = 'true';
- // $this->datagrid->enablePopover('Popover', 'Hi <b> {name} </b>');
- // creates the datagrid columns
- $column_numero = new TDataGridColumn('numero', 'Numero', 'left');
- $column_id_cliente = new TDataGridColumn('clientes->cli_nome', 'Cliente', 'left');
- $column_emissao = new TDataGridColumn('emissao', 'Emissão', 'left');
- $column_vencimento = new TDataGridColumn('vencimento', 'Vencimento', 'left');
- $column_pagamento = new TDataGridColumn('pagamento', 'Pagamento', 'left');
- // $column_referente = new TDataGridColumn('referente', 'Referente', 'left');
- $column_id_pedido = new TDataGridColumn('id_pedido', 'Pedido', 'right');
- $column_valor = new TDataGridColumn('valor', 'Valor', 'right');
- // add the columns to the DataGrid
- $this->datagrid->addColumn($column_numero);
- $this->datagrid->addColumn($column_id_cliente);
- $this->datagrid->addColumn($column_emissao);
- $this->datagrid->addColumn($column_vencimento);
- $this->datagrid->addColumn($column_pagamento);
- // $this->datagrid->addColumn($column_referente);
- $this->datagrid->addColumn($column_id_pedido);
- $this->datagrid->addColumn($column_valor);
- // define the transformer method over image
- $column_emissao->setTransformer( function($value, $object, $row) {
- $date = new DateTime($value);
- return $date->format('d/m/Y');
- });
- // define the transformer method over image
- $column_vencimento->setTransformer( function($value, $object, $row) {
- $date = new DateTime($value);
- return $date->format('d/m/Y');
- });
- // define the transformer method over image
- $column_pagamento->setTransformer( function($value, $object, $row) {
- $date = TDate::date2br($value);
- //new DateTime($value);
- return $date;
- //->format('d/m/Y');
- });
- // define the transformer method over image
- $column_valor->setTransformer( function($value, $object, $row) {
- return number_format($value, 2, ',', '.');
- });
- $column_valor->setTotalFunction( function($values) {
- return array_sum((array) $values);
- });
- /*
- $order_Id = new TAction(array($this, 'onReload'));
- $order_Id->setParameter('order', 'numero');
- $column_Id->setAction($order_Id);
- */
- // create EDIT action
- $action_edit = new TDataGridAction(array('ReceberForm', 'onEdit'));
- //$action_edit->setUseButton(TRUE);
- //$action_edit->setButtonClass('btn btn-default');
- $action_edit->setLabel(_t('Edit'));
- $action_edit->setImage('fa:pencil-square-o blue fa-lg');
- $action_edit->setField('Id');
- $this->datagrid->addAction($action_edit);
- // create DELETE action
- $action_del = new TDataGridAction(array($this, 'onDelete'));
- //$action_del->setUseButton(TRUE);
- //$action_del->setButtonClass('btn btn-default');
- $action_del->setLabel(_t('Delete'));
- $action_del->setImage('fa:trash-o red fa-lg');
- $action_del->setField('Id');
- $this->datagrid->addAction($action_del);
- $action_receber = new TDataGridAction(array('ReceberFormBaixa', 'onEdit'));
- $action_receber->setLabel('Baixar');
- $action_receber->setImage('baixa.png');
- $action_receber->setField('Id');
- $this->datagrid->addAction($action_receber);
- // create the datagrid model
- $this->datagrid->createModel();
- // creates the page navigation
- $this->pageNavigation = new TPageNavigation;
- $this->pageNavigation->setAction(new TAction(array($this, 'onReload')));
- $this->pageNavigation->setWidth($this->datagrid->getWidth());
- // vertical box container
- $container = new TVBox;
- $container->style = 'width: 100%';
- $container->add(new TXMLBreadCrumb('menu.xml', __CLASS__));
- //$container->add($dropdown);
- $container->add(TPanelGroup::pack('Contas a Receber', $this->form));
- $container->add(TPanelGroup::pack('', $this->datagrid, $this->pageNavigation));
- parent::add($container);
- }
- /**
- * Inline record editing
- * @param $param Array containing:
- * key: object ID value
- * field name: object attribute to be updated
- * value: new attribute content
- */
- public function onInlineEdit($param)
- {
- try
- {
- // get the parameter $key
- $field = $param['field'];
- $key = $param['key'];
- $value = $param['value'];
- TTransaction::open('scomcomercio'); // open a transaction with database
- $object = new Receber($key); // instantiates the Active Record
- $object->{$field} = $value;
- $object->store(); // update the object in the database
- TTransaction::close(); // close the transaction
- $this->onReload($param); // reload the listing
- new TMessage('info', "Record Updated");
- }
- catch (Exception $e) // in case of exception
- {
- new TMessage('error', $e->getMessage()); // shows the exception error message
- TTransaction::rollback(); // undo all pending operations
- }
- }
- /**
- * Register the filter in the session
- */
- public function onSearch()
- {
- // get the search form data
- $data = $this->form->getData();
- // clear session filters
- TSession::setValue('ReceberList_filter_numero', NULL);
- TSession::setValue('ReceberList_filter_id_cliente', NULL);
- TSession::setValue('ReceberList_filter_emissao', NULL);
- TSession::setValue('ReceberList_filter_vencimento', NULL);
- TSession::setValue('ReceberList_filter_pagamento', NULL);
- TSession::setValue('ReceberList_filter_tipo', NULL);
- if (isset($data->numero) AND ($data->numero)) {
- $filter = new TFilter('numero', '=', "$data->numero"); // create the filter
- TSession::setValue('ReceberList_filter_numero', $filter); // stores the filter in the session
- }
- if (isset($data->id_cliente) AND ($data->id_cliente)) {
- $filter = new TFilter('id_cliente', 'like', "%{$data->id_cliente}%"); // create the filter
- TSession::setValue('ReceberList_filter_id_cliente', $filter); // stores the filter in the session
- }
- if (isset($data->emissao) AND ($data->emissao)) {
- $filter = new TFilter('emissao', '=', "$data->emissao"); // create the filter
- TSession::setValue('ReceberList_filter_emissao', $filter); // stores the filter in the session
- }
- if (isset($data->vencimento) AND ($data->vencimento)) {
- $filter = new TFilter('vencimento', '=', "$data->vencimento"); // create the filter
- TSession::setValue('ReceberList_filter_vencimento', $filter); // stores the filter in the session
- }
- if (isset($data->pagamento) AND ($data->pagamento)) {
- $filter = new TFilter('pagamento', '=', "$data->pagamento"); // create the filter
- TSession::setValue('ReceberList_filter_pagamento', $filter); // stores the filter in the session
- }
- if (isset($data->tipo) AND ($data->tipo)) {
- if ($data->tipo=='A'){
- $filter = new TFilter('pagamento', 'IS', NULL); // create the filter
- }
- if ($data->tipo=='L'){
- $filter = new TFilter('pagamento', 'IS NOT', NULL); // create the filter
- }
- if ($data->tipo=='T'){
- $filter = new TCriteria;
- $filter->add(new TFilter('pagamento', 'IS', NULL), TExpression::OR_OPERATOR);
- $filter->add(new TFilter('pagamento', 'IS NOT', NULL), TExpression::OR_OPERATOR);
- }
- TSession::setValue('ReceberList_filter_tipo', $filter); // stores the filter in the session
- }
- // fill the form with data again
- $this->form->setData($data);
- // keep the search data in the session
- TSession::setValue('Receber_filter_data', $data);
- $param=array();
- $param['offset'] =0;
- $param['first_page']=1;
- $this->onReload($param);
- }
- /**
- * Load the datagrid with data
- */
- public function onReload($param = NULL)
- {
- try
- {
- // open a transaction with database 'scomcomercio'
- TTransaction::open('scomcomercio');
- // creates a repository for Receber
- $repository = new TRepository('Receber');
- $limit = 10;
- // creates a criteria
- $criteria = new TCriteria;
- // default order
- if (empty($param['order']))
- {
- $param['order'] = 'numero';
- $param['direction'] = 'asc';
- }
- $criteria->setProperties($param); // order, offset
- $criteria->setProperty('limit', $limit);
- if (TSession::getValue('ReceberList_filter_numero')) {
- $criteria->add(TSession::getValue('ReceberList_filter_numero')); // add the session filter
- }
- if (TSession::getValue('ReceberList_filter_id_cliente')) {
- $criteria->add(TSession::getValue('ReceberList_filter_id_cliente')); // add the session filter
- }
- if (TSession::getValue('ReceberList_filter_emissao')) {
- $criteria->add(TSession::getValue('ReceberList_filter_emissao')); // add the session filter
- }
- if (TSession::getValue('ReceberList_filter_vencimento')) {
- $criteria->add(TSession::getValue('ReceberList_filter_vencimento')); // add the session filter
- }
- if (TSession::getValue('ReceberList_filter_pagamento')) {
- $criteria->add(TSession::getValue('ReceberList_filter_pagamento')); // add the session filter
- }
- if (TSession::getValue('ReceberList_filter_tipo')) {
- $criteria->add(TSession::getValue('ReceberList_filter_tipo')); // add the session filter
- }
- // load the objects according to criteria
- $objects = $repository->load($criteria, FALSE);
- if (is_callable($this->transformCallback))
- {
- call_user_func($this->transformCallback, $objects, $param);
- }
- $this->datagrid->clear();
- if ($objects)
- {
- // iterate the collection of active records
- foreach ($objects as $object)
- {
- // add the object inside the datagrid
- $this->datagrid->addItem($object);
- }
- }
- // reset the criteria for record count
- $criteria->resetProperties();
- $count= $repository->count($criteria);
- $this->pageNavigation->setCount($count); // count of records
- $this->pageNavigation->setProperties($param); // order, page
- $this->pageNavigation->setLimit($limit); // limit
- // close the transaction
- TTransaction::close();
- $this->loaded = true;
- }
- catch (Exception $e) // in case of exception
- {
- // shows the exception error message
- new TMessage('error', $e->getMessage());
- // undo all pending operations
- TTransaction::rollback();
- }
- }
- /**
- * Ask before deletion
- */
- public function onDelete($param)
- {
- // define the delete action
- $action = new TAction(array($this, 'onDelCerteza'));
- $action->setParameters($param); // pass the key parameter ahead
- // shows a dialog to the user
- new TQuestion(AdiantiCoreTranslator::translate('Do you really want to delete ?'), $action);
- }
- /**
- * Delete a record
- */
- public function onDelCerteza($param)
- {
- // define the delete action
- $action = new TAction(array($this, 'Delete'));
- $action->setParameters($param); // pass the key parameter ahead
- // shows a dialog to the user
- new TQuestion('Tem certeza ?', $action);
- }
- public function Delete($param)
- {
- try
- {
- $key=$param['key']; // get the parameter $key
- TTransaction::open('scomcomercio'); // open a transaction with database
- $object = new Receber($key, FALSE); // instantiates the Active Record
- $object->delete(); // deletes the object from the database
- TTransaction::close(); // close the transaction
- $this->onReload( $param ); // reload the listing
- new TMessage('info', AdiantiCoreTranslator::translate('Record deleted')); // success message
- }
- catch (Exception $e) // in case of exception
- {
- new TMessage('error', $e->getMessage()); // shows the exception error message
- TTransaction::rollback(); // undo all pending operations
- }
- }
- /**
- * method show()
- * Shows the page
- */
- public function show()
- {
- // check if the datagrid is already loaded
- if (!$this->loaded AND (!isset($_GET['method']) OR !(in_array($_GET['method'], array('onReload', 'onSearch')))) )
- {
- if (func_num_args() > 0)
- {
- $this->onReload( func_get_arg(0) );
- }
- else
- {
- $this->onReload();
- }
- }
- parent::show();
- }
- function onMessage()
- {
- new TMessage('info','entrei');
- }
- }
- ?>
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
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
Obrigado
boa tarde, eu estou usando o BootstrapFormWrapper daria pra fazer estas mudanças nele?
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.
Obrigado Marco, vou fazer conforme me indicou...valeu