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

Pacotão Dominando o Adianti Framework 7
O material mais completo de treinamento do Framework.
Curso em vídeo aulas + Livro completo + Códigos fontes do projeto ERPHouse.
Conteúdo Atualizado! Versão 7.4


Dominando o Adianti 7 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