Formulário bootstrap fica com espaços entre os campos ...
GG
Formulário bootstrap fica com espaços entre os campos  
 
  1. <?php
  2. /**
  3. * Pedido_compraForm Master/Detail
  4. * @author <your name here>
  5. */
  6. class Pedido_compraForm extends TPage
  7. {
  8. protected $form; // form
  9. protected $formFields;
  10. protected $detail_list;
  11. /**
  12. * Page constructor
  13. */
  14. public function __construct()
  15. {
  16. parent::__construct();
  17. // creates the form
  18. $this->form = new TForm('form_Pedido_compra');
  19. $this->form->class = 'tform'; // CSS class
  20. $this->form->style = 'max-width:2500px'; // style
  21. $vbox = new TVBox;
  22. $vbox->style = 'width: 100%';
  23. parent::include_css('app/resources/custom-frame.css');
  24. $table_master = new TTable;
  25. $table_master->width = '100%';
  26. $table_master->addRowSet( new TLabel('Pedido de compra'), '', '')->class = 'tformtitle';
  27. // add a table inside form
  28. $table_general = new TTable;
  29. $table_detail = new TTable;
  30. $table_general-> width = '100%';
  31. $table_detail-> width = '100%';
  32. $frame_general = new TFrame;
  33. $frame_general->setLegend('Capa');
  34. $frame_general->style = 'background:whiteSmoke';
  35. $frame_general->add($table_general);
  36. $frame_general-> width = '100%';
  37. $table_master->addRow()->addCell( $frame_general )->colspan=2;
  38. $row = $table_master->addRow();
  39. $row->addCell( $table_detail );
  40. $this->form->add($table_master);
  41. // master fields
  42. $id = new TEntry('id');
  43. $fornecedor_id = new ">TDBSeekButton('fornecedor_id', 'erpweb',$this->form->getName(), 'Fornecedor','pessoa->nome', 'fornecedor_id', 'fornecedor_nome');
  44. $condicao_pagamento_id = new TDBCombo('condicao_pagamento_id', 'erpweb', 'Condicao_pagamento', 'id', 'descricao');
  45. $fornecedor_nome = new TEntry('fornecedor_nome');
  46. $data_compra = new TDate('data_compra');
  47. $observacao = new TText('observacao');
  48. $estoque_interno = new TRadioGroup('estoque_interno');
  49. $situacao = new TRadioGroup('situacao');
  50. $valor_total = new TEntry('valor_total');
  51. $valor_desconto = new TEntry('valor_desconto');
  52. $valor_total_liquido = new TEntry('valor_total_liquido');
  53. $valor_desconto->setExitAction(new TAction(array($this,'onValorDescontoChange')));
  54. $items = array();
  55. $items['1'] ='Sim';
  56. $items['0'] ='Nao';
  57. $estoque_interno->addItems($items);
  58. $situacao->setLayout('horizontal');
  59. $items = array();
  60. $items['0'] ='Em aberto';
  61. $items['1'] ='Em andamento';
  62. $items['2'] ='Atendido';
  63. $items['3'] ='Cancelado';
  64. $situacao->addItems($items);
  65. if (!empty($id))
  66. {
  67. $id->setEditable(FALSE);
  68. }
  69. $id->setSize('5%');
  70. $fornecedor_id->setSize('30%');
  71. $fornecedor_nome->setSize('100%');
  72. $fornecedor_nome->setEditable(false);
  73. $data_compra->setValue(date("Y-m-d"));
  74. $valor_total->setEditable(FALSE);
  75. $valor_total->setSize('30%');
  76. $valor_total_liquido->setEditable(FALSE);
  77. $valor_total_liquido->setSize('30%');
  78. $situacao->setSize('70%');
  79. $valor_total->setNumericMask(2, ',','.',true);
  80. $valor_total_liquido->setNumericMask(2, ',','.',true);
  81. $valor_desconto->setNumericMask(2, ',','.',true);
  82. // detail fields
  83. $detail_id = new THidden('detail_id');
  84. $detail_qtde = new TEntry('detail_qtde');
  85. $detail_qtde_bonificada = new TEntry('detail_qtde_bonificada');
  86. $detail_valor_item = new TEntry('detail_valor_item');
  87. $detail_valor_total_item = new TEntry('detail_valor_total_item');
  88. $detail_produto_id = new ">TDBSeekButton('detail_produto_id', 'erpweb',$this->form->getName(), 'Produto','descricao', 'detail_produto_id', 'detail_produto_nome');
  89. $detail_produto_nome = new TEntry('detail_produto_nome');
  90. $detail_qtde->setNumericMask(3, ',','.',true);
  91. $detail_qtde_bonificada->setNumericMask(3, ',','.',true);
  92. $detail_valor_item->setNumericMask(2, ',','.',true);
  93. $detail_valor_total_item->setNumericMask(2, ',','.',true);
  94. $detail_produto_id->setSize('30%');
  95. $detail_valor_total_item->setEditable(FALSE);
  96. $detail_produto_id->setExitAction(new TAction(array($this,'onProductChange')));
  97. $detail_qtde_bonificada->setExitAction(new TAction(array($this,'onQtdebonificadaChange')));
  98. $detail_produto_nome->setEditable(false);
  99. $detail_produto_nome->setSize('70%');
  100. /** samples
  101. $this->form->addQuickFields('Date', array($date1, new TLabel('to'), $date2)); // side by side fields
  102. $fieldX->addValidation( 'Field X', new TRequiredValidator ); // add validation
  103. $fieldX->setSize( 100, 40 ); // set size
  104. **/
  105. // master
  106. $table_general->addRowSet( new TLabel('Id'), $id );
  107. $table_general->addRowSet( new TLabel('Data de Compra'), $data_compra );
  108. $table_general->addRowSet( $label_fornecedor = new TLabel('Fornecedor (*)'), array( $fornecedor_id, $fornecedor_nome ) );
  109. $table_general->addRowSet( new TLabel('Condicao de Pagamento (*)'), $condicao_pagamento_id );
  110. $table_general->addRowSet( new TLabel('Estoque Interno'), $estoque_interno );
  111. $table_general->addRowSet( new TLabel('Situação'), $situacao );
  112. $table_general->addRowSet( new TLabel('Valor Total'), $valor_total );
  113. $table_general->addRowSet( new TLabel('Valor Desconto'), $valor_desconto );
  114. $table_general->addRowSet( new TLabel('Valor Total Liquido'), $valor_total_liquido );
  115. $table_general->addRowSet( new TLabel('Observação'), $observacao );
  116. // detail
  117. $frame_details = new TFrame();
  118. $frame_details->setLegend('Ítens');
  119. $row = $table_detail->addRow();
  120. $row->addCell($frame_details);
  121. $frame_details-> width = '30%';
  122. $vbox->add( $frame_general );
  123. $vbox->add( $frame_details );
  124. $vbox-> width = '30%';
  125. $btn_save_detail = new TButton('btn_save_detail');
  126. $btn_save_detail->setAction(new TAction(array($this, 'onSaveDetail')), 'Adicionar');
  127. $btn_save_detail->setImage('fa:save');
  128. $table_details = new TTable;
  129. $frame_details->add($table_details);
  130. $table_details-> width = '30%';
  131. $table_details->addRowSet( '', $detail_id );
  132. $table_details->addRowSet( new TLabel('Produto (*)'), array( $detail_produto_id, $detail_produto_nome ) );
  133. $table_details->addRowSet( new TLabel('Qtde'), $detail_qtde );
  134. $table_details->addRowSet( new TLabel('Qtde Bonificada'), $detail_qtde_bonificada );
  135. $table_details->addRowSet( new TLabel('Valor Item'), $detail_valor_item );
  136. $table_details->addRowSet( new TLabel('Valor Total Item'), $detail_valor_total_item );
  137. $table_details->addRowSet( $btn_save_detail );
  138. $this->detail_list = new TQuickGrid;
  139. $this->detail_list->setHeight( 200 );
  140. $this->detail_list->makeScrollable();
  141. $this->detail_list->disableDefaultClick();
  142. $this->detail_list->addQuickColumn('', 'edit', 'left', 60);
  143. $this->detail_list->addQuickColumn('', 'delete', 'left', 60);
  144. // items
  145. $this->detail_list->style = "margin-bottom: 10px";
  146. $this->detail_list->addQuickColumn('Id', 'produto_id', 'center', 50);
  147. $this->detail_list->addQuickColumn('Produto', 'produto_nome', 'left', 200);
  148. $qt = $this->detail_list->addQuickColumn('Qtde', 'qtde', 'left', 200);
  149. $qb = $this->detail_list->addQuickColumn('Qtde Bonificada', 'qtde_bonificada', 'left', 200);
  150. $pr = $this->detail_list->addQuickColumn('Valor Item', 'valor_item', 'left', 200);
  151. $st = $this->detail_list->addQuickColumn('Valor Total Item', 'valor_total_item', 'left', 200);
  152. $this->detail_list->createModel();
  153. $vbox->add( $this->detail_list );
  154. $format_value = function($value) {
  155. if (is_numeric($value)) {
  156. return 'R$ '.number_format($value, 2, ',', '.');
  157. }
  158. return $value;
  159. };
  160. $format_qtde = function($value) {
  161. if (is_numeric($value)) {
  162. return number_format($value, 3, ',', '.');
  163. }
  164. return $value;
  165. };
  166. $pr->setTransformer( $format_value );
  167. $st->setTransformer( $format_value );
  168. $qt->setTransformer( $format_qtde );
  169. $qb->setTransformer( $format_qtde );
  170. $st->setTotalFunction( function($values) {
  171. return array_sum((array) $values);
  172. });
  173. $row = $table_detail->addRow();
  174. $row->addCell($this->detail_list);
  175. // create an action button (save)
  176. $save_button=new TButton('save');
  177. $save_button->setAction(new TAction(array($this, 'onSave')), _t('Save'));
  178. $save_button->setImage('ico_save.png');
  179. // create an new button (edit with no parameters)
  180. $new_button=new TButton('new');
  181. $new_button->setAction(new TAction(array($this, 'onClear')), _t('New'));
  182. $new_button->setImage('ico_new.png');
  183. // define form fields
  184. $this->formFields = array($id,$data_compra,$valor_total,$valor_desconto,$valor_total_liquido,$observacao,$estoque_interno,$situacao,$fornecedor_id,$fornecedor_nome,$condicao_pagamento_id,$detail_qtde,$detail_qtde_bonificada,$detail_valor_item,$detail_valor_total_item,$detail_produto_id,$detail_produto_nome);
  185. $this->formFields[] = $btn_save_detail;
  186. $this->formFields[] = $save_button;
  187. $this->formFields[] = $new_button;
  188. $this->formFields[] = $detail_id;
  189. $this->form->setFields( $this->formFields );
  190. $table_master->addRowSet( array($save_button, $new_button), '', '')->class = 'tformaction'; // CSS class
  191. // create the page container
  192. $container = new TVBox;
  193. $container->style = 'width: 100%';
  194. // $container->add(new TXMLBreadCrumb('menu.xml', __CLASS__));
  195. $container->add($this->form);
  196. parent::add($container);
  197. }
  198. public function onLoad($param)
  199. {
  200. $data = new stdClass;
  201. $data->fornecedor_id = $param['fornecedor_id'];
  202. $data->fornecedor_nome = $param['fornecedor_nome'];
  203. $this->form->setData($data);
  204. }
  205. static function onValorDescontoChange( $params )
  206. {
  207. if( isset($params['valor_total']) && $params['valor_total'] )
  208. {
  209. try
  210. {
  211. TTransaction::open('erpweb');
  212. $fill_data = new StdClass;
  213. $fill_data->valor_total_liquido = number_format((double) str_replace(',', '.',$params['valor_total']) - (double) str_replace(',', '.',$params['valor_desconto']), 2, ',', '.' );
  214. TForm::sendData('form_Pedido_compra', $fill_data);
  215. TTransaction::close();
  216. }
  217. catch (Exception $e) // in case of exception
  218. {
  219. new TMessage('error', '<b>Error</b> ' . $e->getMessage());
  220. TTransaction::rollback();
  221. }
  222. }
  223. else
  224. {
  225. $fill_data = new StdClass;
  226. TForm::sendData('form_Pedido_compra', $fill_data);
  227. TTransaction::close();
  228. }
  229. }
  230. static function onProductChange( $params )
  231. {
  232. if( isset($params['detail_produto_id']) && $params['detail_produto_id'] )
  233. {
  234. try
  235. {
  236. TTransaction::open('erpweb');
  237. $produto = new Produto($params['detail_produto_id']);
  238. $fill_data = new StdClass;
  239. $fill_data->detail_valor_item = number_format($produto->valor_unitario, 2, ',','.');
  240. $fill_data->detail_qtde_bonificada = '';
  241. $fill_data->detail_qtde = '';
  242. $fill_data->detail_valor_total_item = '';
  243. TForm::sendData('form_Pedido_compra', $fill_data);
  244. TTransaction::close();
  245. }
  246. catch (Exception $e) // in case of exception
  247. {
  248. new TMessage('error', '<b>Error</b> ' . $e->getMessage());
  249. TTransaction::rollback();
  250. }
  251. }
  252. else
  253. {
  254. $fill_data = new StdClass;
  255. $fill_data->detail_valor_item = null;
  256. $fill_data->detail_produto_nome = null;
  257. TForm::sendData('form_Pedido_compra', $fill_data);
  258. TTransaction::close();
  259. }
  260. }
  261. static function onQtdebonificadaChange( $params )
  262. {
  263. if( isset($params['detail_produto_id']) && $params['detail_produto_id'] )
  264. {
  265. try
  266. {
  267. TTransaction::open('erpweb');
  268. $produto = new Produto($params['detail_produto_id']);
  269. $fill_data = new StdClass;
  270. $fill_data->detail_valor_total_item = number_format((((double) str_replace(',', '.',$params['detail_qtde']) - (double) str_replace(',', '.',$params['detail_qtde_bonificada']) ) * (double) str_replace(',', '.',$params['detail_valor_item'])), 2, ',', '.');
  271. TForm::sendData('form_Pedido_compra', $fill_data);
  272. TTransaction::close();
  273. }
  274. catch (Exception $e) // in case of exception
  275. {
  276. new TMessage('error', '<b>Error</b> ' . $e->getMessage());
  277. TTransaction::rollback();
  278. }
  279. }
  280. else
  281. {
  282. $fill_data = new StdClass;
  283. $fill_data->detail_valor_item = null;
  284. $fill_data->detail_produto_nome = null;
  285. TForm::sendData('form_Pedido_compra', $fill_data);
  286. TTransaction::close();
  287. }
  288. }
  289. /**
  290. * Clear form
  291. * @param $param URL parameters
  292. */
  293. public function onClear($param)
  294. {
  295. $this->form->clear(TRUE);
  296. TSession::setValue(__CLASS__.'_items', array());
  297. $this->onReload( $param );
  298. }
  299. /**
  300. * Save an item from form to session list
  301. * @param $param URL parameters
  302. */
  303. public function onSaveDetail( $param )
  304. {
  305. try
  306. {
  307. TTransaction::open('erpweb');
  308. $data = $this->form->getData();
  309. /** validation sample
  310. if (! $data->fieldX)
  311. throw new Exception('The field fieldX is required');
  312. **/
  313. $items = TSession::getValue(__CLASS__.'_items');
  314. $key = empty($data->detail_id) ? 'X'.mt_rand(1000000000, 1999999999) : $data->detail_id;
  315. $items[ $key ] = array();
  316. $items[ $key ]['id'] = $key;
  317. $items[ $key ]['qtde'] = $data->detail_qtde;
  318. $items[ $key ]['qtde_bonificada'] = $data->detail_qtde_bonificada;
  319. $items[ $key ]['valor_item'] = $data->detail_valor_item;
  320. $items[ $key ]['valor_total_item'] = $data->detail_valor_total_item;
  321. $items[ $key ]['produto_id'] = $data->detail_produto_id;
  322. $items[ $key ]['produto_nome'] = $data->detail_produto_nome;
  323. TSession::setValue(__CLASS__.'_items', $items);
  324. // clear detail form fields
  325. $data->detail_id = '';
  326. $data->detail_qtde = '';
  327. $data->detail_qtde_bonificada = '';
  328. $data->detail_valor_item = '';
  329. $data->detail_valor_total_item = '';
  330. $data->detail_produto_id = '';
  331. $data->detail_produto_nome = '';
  332. $this->form->setData($data);
  333. TTransaction::close();
  334. $this->onReload( $param ); // reload the items
  335. }
  336. catch (Exception $e)
  337. {
  338. $this->form->setData( $this->form->getData());
  339. new TMessage('error', $e->getMessage());
  340. }
  341. }
  342. /**
  343. * Load an item from session list to detail form
  344. * @param $param URL parameters
  345. */
  346. public function onEditDetail( $param )
  347. {
  348. $data = $this->form->getData();
  349. // read session items
  350. $items = TSession::getValue(__CLASS__.'_items');
  351. // get the session item
  352. $item = $items[ $param['item_key'] ];
  353. $data->detail_id = $item['id'];
  354. $data->detail_qtde = $item['qtde'];
  355. $data->detail_qtde_bonificada = $item['qtde_bonificada'];
  356. $data->detail_valor_item = $item['valor_item'];
  357. $data->detail_valor_total_item = $item['valor_total_item'];
  358. $data->detail_produto_id = $item['produto_id'];
  359. $data->detail_produto_nome = $item['produto_nome'];
  360. // fill detail fields
  361. $this->form->setData( $data );
  362. $this->onReload( $param );
  363. }
  364. /**
  365. * Delete an item from session list
  366. * @param $param URL parameters
  367. */
  368. public function onDeleteDetail( $param )
  369. {
  370. $data = $this->form->getData();
  371. // reset items
  372. $data->detail_qtde = '';
  373. $data->detail_qtde_bonificada = '';
  374. $data->detail_valor_item = '';
  375. $data->detail_valor_total_item = '';
  376. $data->detail_produto_id = '';
  377. $data->detail_produto_nome = '';
  378. $data->valor_total = '';
  379. // clear form data
  380. $this->form->setData( $data );
  381. // read session items
  382. $items = TSession::getValue(__CLASS__.'_items');
  383. // delete the item from session
  384. unset($items[ $param['item_key'] ] );
  385. TSession::setValue(__CLASS__.'_items', $items);
  386. // reload items
  387. $this->onReload( $param );
  388. }
  389. /**
  390. * Load the items list from session
  391. * @param $param URL parameters
  392. */
  393. public function onReload($param)
  394. {
  395. // read session items
  396. $items = TSession::getValue(__CLASS__.'_items');
  397. $this->detail_list->clear(); // clear detail list
  398. $data = $this->form->getData();
  399. $total = 0.00;
  400. if ($items)
  401. {
  402. $cont = 1;
  403. foreach ($items as $list_item_key => $list_item)
  404. {
  405. $item_name = 'prod_' . $cont++;
  406. $item = new StdClass;
  407. // create action buttons
  408. $action_del = new TAction(array($this, 'onDeleteDetail'));
  409. $action_del->setParameter('item_key', $list_item_key);
  410. $action_edi = new TAction(array($this, 'onEditDetail'));
  411. $action_edi->setParameter('item_key', $list_item_key);
  412. $button_del = new TButton('delete_detail'.$cont);
  413. $button_del->class = 'btn btn-default btn-sm';
  414. $button_del->setAction( $action_del, '' );
  415. $button_del->setImage('fa:trash-o red fa-lg');
  416. $button_edi = new TButton('edit_detail'.$cont);
  417. $button_edi->class = 'btn btn-default btn-sm';
  418. $button_edi->setAction( $action_edi, '' );
  419. $button_edi->setImage('fa:edit blue fa-lg');
  420. $item->edit = $button_edi;
  421. $item->delete = $button_del;
  422. $this->formFields[ $item_name.'_edit' ] = $item->edit;
  423. $this->formFields[ $item_name.'_delete' ] = $item->delete;
  424. // items
  425. $item->id = $list_item['id'];
  426. $item->qtde = $list_item['qtde'];
  427. $item->qtde_bonificada = $list_item['qtde_bonificada'];
  428. $item->valor_item = $list_item['valor_item'];
  429. $item->valor_total_item = $list_item['valor_total_item'];
  430. $item->produto_id = $list_item['produto_id'];
  431. $item->produto_nome = $list_item['produto_nome'];
  432. $total += $item->valor_total_item;
  433. $row = $this->detail_list->addItem( $item );
  434. $row->onmouseover='';
  435. $row->onmouseout='';
  436. }
  437. $data = $this->form->getData();
  438. $valor_desconto = number_format(0.00, 2, ',','.');
  439. if ($data->valor_desconto) {
  440. $valor_desconto = number_format($data->valor_desconto, 2, ',','.');
  441. }
  442. $data = new Stdclass();
  443. $data->valor_total = number_format($total, 2, ',','.');
  444. $data->valor_desconto = $valor_desconto;
  445. TForm::sendData('form_Pedido_compra', $data);
  446. $this->form->setFields( $this->formFields );
  447. }
  448. else {
  449. $data = new Stdclass();
  450. $data->valor_total = number_format(0.00, 2, ',','.');
  451. $data->valor_desconto = number_format(0.00, 2, ',','.');
  452. TForm::sendData('form_Pedido_compra', $data);
  453. }
  454. $this->loaded = TRUE;
  455. }
  456. /**
  457. * Load Master/Detail data from database to form/session
  458. */
  459. public function onEdit($param)
  460. {
  461. try
  462. {
  463. TTransaction::open('erpweb');
  464. if (isset($param['key']))
  465. {
  466. $key = $param['key'];
  467. $object = new Pedido_compra($key);
  468. $items = Item_pedido_compra::where('pedido_compra_id', '=', $key)->load();
  469. $session_items = array();
  470. foreach( $items as $item )
  471. {
  472. $item_key = $item->id;
  473. $session_items[$item_key] = $item->toArray();
  474. $session_items[$item_key]['id'] = $item->id;
  475. $session_items[$item_key]['qtde'] = $item->qtde;
  476. $session_items[$item_key]['qtde_bonificada'] = $item->qtde_bonificada;
  477. $session_items[$item_key]['valor_item'] = $item->valor_item;
  478. $session_items[$item_key]['valor_total_item'] = $item->valor_total_item;
  479. $session_items[$item_key]['produto_id'] = $item->produto_id;
  480. $session_items[$item_key]['produto_nome'] = $item->produto->descricao;
  481. }
  482. TSession::setValue(__CLASS__.'_items', $session_items);
  483. $this->form->setData($object); // fill the form with the active record data
  484. $this->onReload( $param ); // reload items list
  485. TTransaction::close(); // close transaction
  486. }
  487. else
  488. {
  489. $this->form->clear(TRUE);
  490. TSession::setValue(__CLASS__.'_items', null);
  491. $this->onReload( $param );
  492. }
  493. }
  494. catch (Exception $e) // in case of exception
  495. {
  496. new TMessage('error', $e->getMessage());
  497. TTransaction::rollback();
  498. }
  499. }
  500. /**
  501. * Save the Master/Detail data from form/session to database
  502. */
  503. public function onSave()
  504. {
  505. try
  506. {
  507. // open a transaction with database
  508. TTransaction::open('erpweb');
  509. $data = $this->form->getData();
  510. $master = new Pedido_compra;
  511. $master->fromArray( (array) $data);
  512. $this->form->validate(); // form validation
  513. $master->store(); // save master object
  514. // delete details
  515. $old_items = Item_pedido_compra::where('pedido_compra_id', '=', $master->id)->load();
  516. $keep_items = array();
  517. // get session items
  518. $items = TSession::getValue(__CLASS__.'_items');
  519. if( $items )
  520. {
  521. foreach( $items as $item )
  522. {
  523. if (substr($item['id'],0,1) == 'X' ) // new record
  524. {
  525. $detail = new Item_pedido_compra;
  526. }
  527. else
  528. {
  529. $detail = Item_pedido_compra::find($item['id']);
  530. }
  531. $detail->qtde = $item['qtde'];
  532. $detail->qtde_bonificada = $item['qtde_bonificada'];
  533. $detail->valor_item = $item['valor_item'];
  534. $detail->valor_total_item = $item['valor_total_item'];
  535. $detail->produto_id = $item['produto_id'];
  536. $detail->pedido_compra_id = $master->id;
  537. $detail->store();
  538. $keep_items[] = $detail->id;
  539. }
  540. }
  541. if ($old_items)
  542. {
  543. foreach ($old_items as $old_item)
  544. {
  545. if (!in_array( $old_item->id, $keep_items))
  546. {
  547. $old_item->delete();
  548. }
  549. }
  550. }
  551. TTransaction::close(); // close the transaction
  552. // reload form and session items
  553. $this->onEdit(array('key'=>$master->id));
  554. new TMessage('info', TAdiantiCoreTranslator::translate('Record saved'));
  555. }
  556. catch (Exception $e) // in case of exception
  557. {
  558. new TMessage('error', $e->getMessage());
  559. $this->form->setData( $this->form->getData() ); // keep form data
  560. TTransaction::rollback();
  561. }
  562. }
  563. /**
  564. * Show the page
  565. */
  566. public function show()
  567. {
  568. // check if the datagrid is already loaded
  569. if (!$this->loaded AND (!isset($_GET['method']) OR $_GET['method'] !== 'onReload') )
  570. {
  571. $this->onReload( func_get_arg(0) );
  572. }
  573. parent::show();
  574. }
  575. }

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


NR

Ao adicionar um array como parâmetro da addRowSet, internamente os componentes do array são adicionados a uma div, e o percentual passado como tamanho corresponde ao tamanho relativo a essa div. O jeito mais simples seria passar um tamanho fixo para o campo:
 
  1. <?php
  2. $fornecedor_id->setSize(80);
  3. ?>

Outra maneira seria atribuir % ao campo e navega pelos containers até o desejado e modificar o seu tamanho:
 
  1. <?php
  2. $fornecedor_id->setSize('85%');
  3. $row = $table_general->addRowSet( $label_fornecedor = new TLabel('Fornecedor (*)'), array( $fornecedor_id, $fornecedor_nome ) );
  4. $row->get(1)->get(0)->get(0)->style = 'width:30%';
  5. ?>
GG

Obrigado Nataniel já melhorei bastante o alinhamento com a sua idéia