Gravar valor numérico na Grid - comportamento "estranho" Boa tarde... Tenho um formulário de digitação de solicitações, esse foi criado com o formulário mestre detalhe, do Studio. Com base no micro erp, fiz algumas adaptações para que ao digitar nos campos: volumes, peso e valor, tivesse a formatação com ponto e virgula. O comportamento estranho está acontecendo na grid, onde ao salvar pela primeira vez ele grava o número "com a formata...
RF
Gravar valor numérico na Grid - comportamento "estranho"  
Boa tarde...

Tenho um formulário de digitação de solicitações, esse foi criado com o formulário mestre detalhe, do Studio.
Com base no micro erp, fiz algumas adaptações para que ao digitar nos campos: volumes, peso e valor, tivesse a formatação com ponto e virgula.
O comportamento estranho está acontecendo na grid, onde ao salvar pela primeira vez ele grava o número "com a formatação" (aparece com xx,xx - mas até esse momento tudo bem, no exemplo do cicro erp isso também acontece, dá pra conviver, rsss).
Ao clicar na grid e trazer para os TEntry, os valores, a coisa fica estranha, ele perde a formatação e ao salvar novamente para a Grid, o sistema "elimina" o ponto e grava um número maior.
Em anexo há um exemplo passo-a-passo desse comportamento.

Nesse exemplo o campo peso informado (45,55), quando vai para a grid passa para 4555, e esse ciclo se repete para os demais campos.

Onde deve ser corrigido esse problema?

Segue abaixo o código completo do formulário:

 
  1. <?php
  2. /**
  3. * solicitacao_de_carga_form Master/Detail
  4. * @author <your name here>
  5. */
  6. class solicitacao_de_carga_form extends TPage
  7. {
  8. protected $form; // form
  9. protected $detail_list;
  10. /**
  11. * Page constructor
  12. */
  13. public function __construct()
  14. {
  15. parent::__construct();
  16. // creates the form
  17. $this->form = new BootstrapFormBuilder('form_solicitacao_de_carga');
  18. $this->form->setFormTitle('solicitacao_de_carga');
  19. // master fields
  20. $id = new TEntry('id');
  21. $status_carga = new TEntry('status_carga');
  22. $data_cadastro = new TEntry('data_cadastro');
  23. $unidade_id = new TEntry('unidade_id');
  24. $cliente_id = new TEntry('cliente_id');
  25. $servico = new TEntry('servico');
  26. $loja_id = new TEntry('loja_id');
  27. $remetente_cnpj = new TEntry('remetente_cnpj');
  28. $remetente_ie = new TEntry('remetente_ie');
  29. $remetente_rz_social = new TEntry('remetente_rz_social');
  30. $remetente_nome_fantasia = new TEntry('remetente_nome_fantasia');
  31. $remetente_cep = new TEntry('remetente_cep');
  32. $remetente_uf = new TEntry('remetente_uf');
  33. $remetente_cidade = new TEntry('remetente_cidade');
  34. $remetente_endereco = new TEntry('remetente_endereco');
  35. $remetente_numero = new TEntry('remetente_numero');
  36. $remetente_bairro = new TEntry('remetente_bairro');
  37. $remetente_complemento = new TEntry('remetente_complemento');
  38. $remetente_telefone = new TEntry('remetente_telefone');
  39. $remetente_email = new TEntry('remetente_email');
  40. $destinatario_cnpj = new TEntry('destinatario_cnpj');
  41. $destinatario_ie = new TEntry('destinatario_ie');
  42. $destinatario_rz_social = new TEntry('destinatario_rz_social');
  43. $destinatario_cep = new TEntry('destinatario_cep');
  44. $destinatario_uf = new TEntry('destinatario_uf');
  45. $destinatario_cidade = new TEntry('destinatario_cidade');
  46. $destinatario_endereco = new TEntry('destinatario_endereco');
  47. $destinatario_numero = new TEntry('destinatario_numero');
  48. $destinatario_id = new TEntry('destinatario_id');
  49. $destinatario_bairro = new TEntry('destinatario_bairro');
  50. $destinatario_completo = new TEntry('destinatario_completo');
  51. $destinatario_telefone = new TEntry('destinatario_telefone');
  52. $valor_rs_total = new TEntry('valor_rs_total');
  53. $volume_total = new TEntry('volume_total');
  54. $peso_total = new TEntry('peso_total');
  55. $cubagem_total = new TEntry('cubagem_total');
  56. $peso_cubado_total = new TEntry('peso_cubado_total');
  57. $tipo_de_documento = new TEntry('tipo_de_documento');
  58. // detail fields
  59. $detail_id = new THidden('detail_id');
  60. $detail_nota_fiscal = new TEntry('detail_nota_fiscal');
  61. $detail_serie_nota_fiscal = new TEntry('detail_serie_nota_fiscal');
  62. $detail_danfe = new TEntry('detail_danfe');
  63. $detail_emissao = new TDate('detail_emissao');
  64. $detail_valor = new TNumeric('detail_valor', '2', ',', '.' );//new TEntry('detail_valor');
  65. $detail_pedido = new TEntry('detail_pedido');
  66. $detail_entrega = new TEntry('detail_entrega');
  67. $detail_carga = new TEntry('detail_carga');
  68. $detail_volumes = new TNumeric('detail_volumes', '0', ',', '.' ); //new TEntry('detail_volumes');
  69. $detail_peso_informado = new TNumeric('detail_peso_informado', '2', ',', '.' );// new TEntry('detail_peso_informado');
  70. $detail_peso_medido = new TNumeric('detail_peso_medido', '2', ',', '.' );//TEntry('detail_peso_medido');
  71. $detail_comprimento = new TNumeric('detail_comprimento', '2', ',', '.' );//TEntry('detail_comprimento');
  72. $detail_largura = new TNumeric('detail_largura', '2', ',', '.' );//TEntry('detail_largura');
  73. $detail_altura = new TNumeric('detail_altura', '2', ',', '.' );//TEntry('detail_altura');
  74. $detail_cubagem = new TNumeric('detail_cubagem', '2', ',', '.' );//TEntry('detail_cubagem');
  75. if (!empty($id))
  76. {
  77. $id->setEditable(FALSE);
  78. }
  79. // master fields
  80. $this->form->addFields( [new TLabel('Número')], [$id] );
  81. $this->form->addFields( [new TLabel('Status')], [$status_carga] );
  82. $this->form->addFields( [new TLabel('Data Cadastro')], [$data_cadastro] );
  83. $this->form->addFields( [new TLabel('Unidade atual')], [$unidade_id] );
  84. $this->form->addFields( [new TLabel('Cliente')], [$cliente_id] );
  85. $this->form->addFields( [new TLabel('Tipo de serviço')], [$servico] );
  86. $this->form->addFields( [new TLabel('Cliente embarcador')], [$loja_id] );
  87. $this->form->addFields( [new TLabel('Remetente Cnpj')], [$remetente_cnpj] );
  88. $this->form->addFields( [new TLabel('Remetente Ie')], [$remetente_ie] );
  89. $this->form->addFields( [new TLabel('Remetente Rz Social')], [$remetente_rz_social] );
  90. $this->form->addFields( [new TLabel('Remetente Nome Fantasia')], [$remetente_nome_fantasia] );
  91. $this->form->addFields( [new TLabel('Remetente Cep')], [$remetente_cep] );
  92. $this->form->addFields( [new TLabel('Remetente Uf')], [$remetente_uf] );
  93. $this->form->addFields( [new TLabel('Remetente Cidade')], [$remetente_cidade] );
  94. $this->form->addFields( [new TLabel('Remetente Endereco')], [$remetente_endereco] );
  95. $this->form->addFields( [new TLabel('Remetente Numero')], [$remetente_numero] );
  96. $this->form->addFields( [new TLabel('Remetente Bairro')], [$remetente_bairro] );
  97. $this->form->addFields( [new TLabel('Remetente Complemento')], [$remetente_complemento] );
  98. $this->form->addFields( [new TLabel('Remetente Telefone')], [$remetente_telefone] );
  99. $this->form->addFields( [new TLabel('Remetente Email')], [$remetente_email] );
  100. $this->form->addFields( [new TLabel('Destinatario Cnpj')], [$destinatario_cnpj] );
  101. $this->form->addFields( [new TLabel('Destinatario Ie')], [$destinatario_ie] );
  102. $this->form->addFields( [new TLabel('Destinatario Rz Social')], [$destinatario_rz_social] );
  103. $this->form->addFields( [new TLabel('Destinatario Cep')], [$destinatario_cep] );
  104. $this->form->addFields( [new TLabel('Destinatario Uf')], [$destinatario_uf] );
  105. $this->form->addFields( [new TLabel('Destinatario Cidade')], [$destinatario_cidade] );
  106. $this->form->addFields( [new TLabel('Destinatario Endereco')], [$destinatario_endereco] );
  107. $this->form->addFields( [new TLabel('Destinatario Numero')], [$destinatario_numero] );
  108. $this->form->addFields( [new TLabel('Destinatario Id')], [$destinatario_id] );
  109. $this->form->addFields( [new TLabel('Destinatario Bairro')], [$destinatario_bairro] );
  110. $this->form->addFields( [new TLabel('Destinatario Completo')], [$destinatario_completo] );
  111. $this->form->addFields( [new TLabel('Destinatario Telefone')], [$destinatario_telefone] );
  112. $this->form->addFields( [new TLabel('Valor Rs Total')], [$valor_rs_total] );
  113. $this->form->addFields( [new TLabel('Volume Total')], [$volume_total] );
  114. $this->form->addFields( [new TLabel('Peso Total')], [$peso_total] );
  115. $this->form->addFields( [new TLabel('Cubagem Total')], [$cubagem_total] );
  116. $this->form->addFields( [new TLabel('Peso Cubado Total')], [$peso_cubado_total] );
  117. $this->form->addFields( [new TLabel('Tipo De Documento')], [$tipo_de_documento] );
  118. // detail fields
  119. $this->form->addContent( ['<h4>Details</h4><hr>'] );
  120. $this->form->addFields( [$detail_id] );
  121. $this->form->addFields( [new TLabel('Nota Fiscal')], [$detail_nota_fiscal] );
  122. $this->form->addFields( [new TLabel('Serie Nota Fiscal')], [$detail_serie_nota_fiscal] );
  123. $this->form->addFields( [new TLabel('Danfe')], [$detail_danfe] );
  124. $this->form->addFields( [new TLabel('Emissao')], [$detail_emissao] );
  125. $this->form->addFields( [new TLabel('Valor')], [$detail_valor] );
  126. $this->form->addFields( [new TLabel('Pedido')], [$detail_pedido] );
  127. $this->form->addFields( [new TLabel('Entrega')], [$detail_entrega] );
  128. $this->form->addFields( [new TLabel('Carga')], [$detail_carga] );
  129. $this->form->addFields( [new TLabel('Volumes')], [$detail_volumes] );
  130. $this->form->addFields( [new TLabel('Peso Informado')], [$detail_peso_informado] );
  131. $this->form->addFields( [new TLabel('Peso Medido')], [$detail_peso_medido] );
  132. $this->form->addFields( [new TLabel('Comprimento')], [$detail_comprimento] );
  133. $this->form->addFields( [new TLabel('Largura')], [$detail_largura] );
  134. $this->form->addFields( [new TLabel('Altura')], [$detail_altura] );
  135. $this->form->addFields( [new TLabel('Cubagem')], [$detail_cubagem] );
  136. $add = TButton::create('add', [$this, 'onSaveDetail'], 'Register', 'fa:save');
  137. $this->form->addFields( [], [$add] )->style = 'background: whitesmoke; padding: 5px; margin: 1px;';
  138. $this->detail_list = new BootstrapDatagridWrapper(new TQuickGrid);
  139. $this->detail_list->style = "min-width: 700px; width:100%;margin-bottom: 10px";
  140. $this->detail_list->setId('solicitacao_de_carga_list');
  141. // items
  142. $col_nota_fiscal = $this->detail_list->addQuickColumn('Documento', 'nota_fiscal', 'left', 100);
  143. $col_serie_nota_fiscal = $this->detail_list->addQuickColumn('Serie', 'serie_nota_fiscal', 'left', 100);
  144. //$col_danfe = $this->detail_list->addQuickColumn('Danfe', 'danfe', 'left', 100);
  145. //$col_emissao = $this->detail_list->addQuickColumn('Emissão', 'emissao', 'left', 100);
  146. $col_volumes = $this->detail_list->addQuickColumn('Volumes', 'volumes', 'left', 100);
  147. $col_peso_informado = $this->detail_list->addQuickColumn('Peso Inf.', 'peso_informado', 'left', 100);
  148. $col_peso_medido = $this->detail_list->addQuickColumn('Peso Med.', 'peso_medido', 'left', 100);
  149. $col_valor = $this->detail_list->addQuickColumn('Valor', 'valor', 'left', 100);
  150. //$col_pedido = $this->detail_list->addQuickColumn('Pedido', 'pedido', 'left', 100);
  151. //$col_entrega = $this->detail_list->addQuickColumn('Entrega', 'entrega', 'left', 100);
  152. //$col_carga = $this->detail_list->addQuickColumn('Carga', 'carga', 'left', 100);
  153. //$col_comprimento = $this->detail_list->addQuickColumn('Comprimento', 'comprimento', 'left', 100);
  154. //$col_largura = $this->detail_list->addQuickColumn('Largura', 'largura', 'left', 100);
  155. //$col_altura = $this->detail_list->addQuickColumn('Altura', 'altura', 'left', 100);
  156. //$col_cubagem = $this->detail_list->addQuickColumn('Cubagem', 'cubagem', 'left', 100);
  157. $col_volumes->setTotalFunction( function($values) {
  158. return array_sum((array) $values);
  159. });
  160. $col_peso_informado->setTotalFunction( function($values) {
  161. return array_sum((array) $values);
  162. });
  163. $col_peso_medido->setTotalFunction( function($values) {
  164. return array_sum((array) $values);
  165. });
  166. $col_valor->setTotalFunction( function($values) {
  167. return array_sum((array) $values);
  168. });
  169. //$this->item_pedido_list->createModel();
  170. $col_valor->setTransformer(function($value, $object, $row) {
  171. if (!$value)
  172. {
  173. $value = 0;
  174. }
  175. return number_format($value, 2, ",", ".");
  176. });
  177. // detail actions
  178. $this->detail_list->addQuickAction( 'Edit', new TDataGridAction([$this, 'onEditDetail']), 'id', 'fa:edit blue');
  179. $this->detail_list->addQuickAction( 'Delete', new TDataGridAction([$this, 'onDeleteDetail']), 'id', 'fa:trash red');
  180. $this->detail_list->createModel();
  181. $panel = new TPanelGroup;
  182. $panel->add($this->detail_list);
  183. $panel->getBody()->style = 'overflow-x:auto';
  184. $this->form->addContent( [$panel] );
  185. $btn = $this->form->addAction( _t('Save'), new TAction([$this, 'onSave']), 'fa:save');
  186. $btn->class = 'btn btn-sm btn-primary';
  187. $this->form->addAction( _t('Clear'), new TAction([$this, 'onClear']), 'fa:eraser red');
  188. // create the page container
  189. $container = new TVBox;
  190. $container->style = 'width: 90%';
  191. $container->add(new TXMLBreadCrumb('menu.xml','lista_de_solicitacoes'));
  192. $container->add($this->form);
  193. parent::add($container);
  194. }
  195. /**
  196. * Clear form
  197. * @param $param URL parameters
  198. */
  199. public function onClear($param)
  200. {
  201. $this->form->clear(TRUE);
  202. TSession::setValue(__CLASS__.'_items', array());
  203. $this->onReload( $param );
  204. }
  205. /**
  206. * Save an item from form to session list
  207. * @param $param URL parameters
  208. */
  209. public function onSaveDetail( $param )
  210. {
  211. try
  212. {
  213. TTransaction::open('banco');
  214. $data = $this->form->getData();
  215. /** validation sample
  216. if (empty($data->fieldX))
  217. {
  218. throw new Exception('The field fieldX is required');
  219. }
  220. **/
  221. $items = TSession::getValue(__CLASS__.'_items');
  222. $key = empty($data->detail_id) ? 'X'.mt_rand(1000000000, 1999999999) : $data->detail_id;
  223. $items[ $key ] = array();
  224. $items[ $key ]['id'] = $key;
  225. $items[ $key ]['nota_fiscal'] = $data->detail_nota_fiscal;
  226. $items[ $key ]['serie_nota_fiscal'] = $data->detail_serie_nota_fiscal;
  227. $items[ $key ]['danfe'] = $data->detail_danfe;
  228. $items[ $key ]['emissao'] = $data->detail_emissao;
  229. $items[ $key ]['valor'] = $data->detail_valor;
  230. $items[ $key ]['pedido'] = $data->detail_pedido;
  231. $items[ $key ]['entrega'] = $data->detail_entrega;
  232. $items[ $key ]['carga'] = $data->detail_carga;
  233. $items[ $key ]['volumes'] = $data->detail_volumes;
  234. $items[ $key ]['peso_informado'] = $data->detail_peso_informado;
  235. $items[ $key ]['peso_medido'] = $data->detail_peso_medido;
  236. $items[ $key ]['comprimento'] = $data->detail_comprimento;
  237. $items[ $key ]['largura'] = $data->detail_largura;
  238. $items[ $key ]['altura'] = $data->detail_altura;
  239. $items[ $key ]['cubagem'] = $data->detail_cubagem;
  240. TSession::setValue(__CLASS__.'_items', $items);
  241. // clear detail form fields
  242. $data->detail_id = '';
  243. $data->detail_nota_fiscal = '';
  244. $data->detail_serie_nota_fiscal = '';
  245. $data->detail_danfe = '';
  246. $data->detail_emissao = '';
  247. $data->detail_valor = '';
  248. $data->detail_pedido = '';
  249. $data->detail_entrega = '';
  250. $data->detail_carga = '';
  251. $data->detail_volumes = '';
  252. $data->detail_peso_informado = '';
  253. $data->detail_peso_medido = '';
  254. $data->detail_comprimento = '';
  255. $data->detail_largura = '';
  256. $data->detail_altura = '';
  257. $data->detail_cubagem = '';
  258. TTransaction::close();
  259. $this->form->setData($data);
  260. $this->onReload( $param ); // reload the items
  261. }
  262. catch (Exception $e)
  263. {
  264. $this->form->setData( $this->form->getData());
  265. new TMessage('error', $e->getMessage());
  266. }
  267. }
  268. /**
  269. * Load an item from session list to detail form
  270. * @param $param URL parameters
  271. */
  272. public static function onEditDetail( $param )
  273. {
  274. // read session items
  275. $items = TSession::getValue(__CLASS__.'_items');
  276. // get the session item
  277. $item = $items[ $param['key'] ];
  278. $data = new stdClass;
  279. $data->detail_id = $item['id'];
  280. $data->detail_nota_fiscal = $item['nota_fiscal'];
  281. $data->detail_serie_nota_fiscal = $item['serie_nota_fiscal'];
  282. $data->detail_danfe = $item['danfe'];
  283. $data->detail_emissao = $item['emissao'];
  284. $data->detail_valor = $item['valor'];
  285. $data->detail_pedido = $item['pedido'];
  286. $data->detail_entrega = $item['entrega'];
  287. $data->detail_carga = $item['carga'];
  288. $data->detail_volumes = $item['volumes'];
  289. $data->detail_peso_informado = $item['peso_informado'];
  290. $data->detail_peso_medido = $item['peso_medido'];
  291. $data->detail_comprimento = $item['comprimento'];
  292. $data->detail_largura = $item['largura'];
  293. $data->detail_altura = $item['altura'];
  294. $data->detail_cubagem = $item['cubagem'];
  295. // fill detail fields
  296. TForm::sendData( 'form_solicitacao_de_carga', $data );
  297. }
  298. /**
  299. * Delete an item from session list
  300. * @param $param URL parameters
  301. */
  302. public static function onDeleteDetail( $param )
  303. {
  304. // reset items
  305. $data = new stdClass;
  306. $data->detail_nota_fiscal = '';
  307. $data->detail_serie_nota_fiscal = '';
  308. $data->detail_danfe = '';
  309. $data->detail_emissao = '';
  310. $data->detail_valor = '';
  311. $data->detail_pedido = '';
  312. $data->detail_entrega = '';
  313. $data->detail_carga = '';
  314. $data->detail_volumes = '';
  315. $data->detail_peso_informado = '';
  316. $data->detail_peso_medido = '';
  317. $data->detail_comprimento = '';
  318. $data->detail_largura = '';
  319. $data->detail_altura = '';
  320. $data->detail_cubagem = '';
  321. // clear form data
  322. TForm::sendData('form_solicitacao_de_carga', $data );
  323. // read session items
  324. $items = TSession::getValue(__CLASS__.'_items');
  325. // get detail id
  326. $detail_id = $param['key'];
  327. // delete the item from session
  328. unset($items[ $detail_id ] );
  329. // rewrite session items
  330. TSession::setValue(__CLASS__.'_items', $items);
  331. // delete item from screen
  332. TScript::create("ttable_remove_row_by_id('solicitacao_de_carga_list', '{$detail_id}')");
  333. }
  334. /**
  335. * Load the items list from session
  336. * @param $param URL parameters
  337. */
  338. public function onReload($param)
  339. {
  340. // read session items
  341. $items = TSession::getValue(__CLASS__.'_items');
  342. $this->detail_list->clear(); // clear detail list
  343. if ($items)
  344. {
  345. foreach ($items as $list_item)
  346. {
  347. $item = (object) $list_item;
  348. $row = $this->detail_list->addItem( $item );
  349. $row->id = $list_item['id'];
  350. }
  351. }
  352. $this->loaded = TRUE;
  353. }
  354. /**
  355. * Load Master/Detail data from database to form/session
  356. */
  357. public function onEdit($param)
  358. {
  359. try
  360. {
  361. TTransaction::open('banco');
  362. if (isset($param['key']))
  363. {
  364. $key = $param['key'];
  365. $object = new solicitacao_de_carga($key);
  366. $items = notas_fiscais_carga::where('solicitacao_de_carga_id', '=', $key)->load();
  367. $session_items = array();
  368. foreach( $items as $item )
  369. {
  370. $item_key = $item->id;
  371. $session_items[$item_key] = $item->toArray();
  372. $session_items[$item_key]['id'] = $item->id;
  373. $session_items[$item_key]['nota_fiscal'] = $item->nota_fiscal;
  374. $session_items[$item_key]['serie_nota_fiscal'] = $item->serie_nota_fiscal;
  375. $session_items[$item_key]['danfe'] = $item->danfe;
  376. $session_items[$item_key]['emissao'] = $item->emissao;
  377. $session_items[$item_key]['valor'] = $item->valor;
  378. $session_items[$item_key]['pedido'] = $item->pedido;
  379. $session_items[$item_key]['entrega'] = $item->entrega;
  380. $session_items[$item_key]['carga'] = $item->carga;
  381. $session_items[$item_key]['volumes'] = $item->volumes;
  382. $session_items[$item_key]['peso_informado'] = $item->peso_informado;
  383. $session_items[$item_key]['peso_medido'] = $item->peso_medido;
  384. $session_items[$item_key]['comprimento'] = $item->comprimento;
  385. $session_items[$item_key]['largura'] = $item->largura;
  386. $session_items[$item_key]['altura'] = $item->altura;
  387. $session_items[$item_key]['cubagem'] = $item->cubagem;
  388. }
  389. TSession::setValue(__CLASS__.'_items', $session_items);
  390. $this->form->setData($object); // fill the form with the active record data
  391. $this->onReload( $param ); // reload items list
  392. TTransaction::close(); // close transaction
  393. }
  394. else
  395. {
  396. $this->form->clear(TRUE);
  397. TSession::setValue(__CLASS__.'_items', null);
  398. $this->onReload( $param );
  399. }
  400. }
  401. catch (Exception $e) // in case of exception
  402. {
  403. new TMessage('error', $e->getMessage());
  404. TTransaction::rollback();
  405. }
  406. }
  407. /**
  408. * Save the Master/Detail data from form/session to database
  409. */
  410. public function onSave()
  411. {
  412. try
  413. {
  414. // open a transaction with database
  415. TTransaction::open('banco');
  416. $data = $this->form->getData();
  417. $master = new solicitacao_de_carga;
  418. $master->fromArray( (array) $data);
  419. $this->form->validate(); // form validation
  420. $master->store(); // save master object
  421. // delete details
  422. $old_items = notas_fiscais_carga::where('solicitacao_de_carga_id', '=', $master->id)->load();
  423. $keep_items = array();
  424. // get session items
  425. $items = TSession::getValue(__CLASS__.'_items');
  426. if( $items )
  427. {
  428. foreach( $items as $item )
  429. {
  430. if (substr($item['id'],0,1) == 'X' ) // new record
  431. {
  432. $detail = new notas_fiscais_carga;
  433. }
  434. else
  435. {
  436. $detail = notas_fiscais_carga::find($item['id']);
  437. }
  438. $detail->nota_fiscal = $item['nota_fiscal'];
  439. $detail->serie_nota_fiscal = $item['serie_nota_fiscal'];
  440. $detail->danfe = $item['danfe'];
  441. $detail->emissao = $item['emissao'];
  442. $detail->valor = $item['valor'];
  443. $detail->pedido = $item['pedido'];
  444. $detail->entrega = $item['entrega'];
  445. $detail->carga = $item['carga'];
  446. $detail->volumes = $item['volumes'];
  447. $detail->peso_informado = $item['peso_informado'];
  448. $detail->peso_medido = $item['peso_medido'];
  449. $detail->comprimento = $item['comprimento'];
  450. $detail->largura = $item['largura'];
  451. $detail->altura = $item['altura'];
  452. $detail->cubagem = $item['cubagem'];
  453. $detail->solicitacao_de_carga_id = $master->id;
  454. $detail->store();
  455. $keep_items[] = $detail->id;
  456. }
  457. }
  458. if ($old_items)
  459. {
  460. foreach ($old_items as $old_item)
  461. {
  462. if (!in_array( $old_item->id, $keep_items))
  463. {
  464. $old_item->delete();
  465. }
  466. }
  467. }
  468. TTransaction::close(); // close the transaction
  469. // reload form and session items
  470. $this->onEdit(array('key'=>$master->id));
  471. new TMessage('info', TAdiantiCoreTranslator::translate('Record saved'));
  472. }
  473. catch (Exception $e) // in case of exception
  474. {
  475. new TMessage('error', $e->getMessage());
  476. $this->form->setData( $this->form->getData() ); // keep form data
  477. TTransaction::rollback();
  478. }
  479. }
  480. /**
  481. * Show the page
  482. */
  483. public function show()
  484. {
  485. // check if the datagrid is already loaded
  486. if (!$this->loaded AND (!isset($_GET['method']) OR $_GET['method'] !== 'onReload') )
  487. {
  488. $this->onReload( func_get_arg(0) );
  489. }
  490. parent::show();
  491. }
  492. }

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


NR

Como a função onEditDetail é estática a máscara do campo definida no construtor não é utilizada.

Faça o ajuste manual antes de enviar as informações:
 
  1. <?php
  2. // funcao onEditDetail
  3. $data->detail_peso_informado = number_format($item['peso_informado'],2,',','.');
  4. ?>
AR

Comigo acontece algo semelhante,
Quando insiro ítem do detalhe, os campos do mestre com formatação numérica perdem a formatação.
.
RJ

O problema com o TNumeric formatado para o padrão Brasil continua acontecendo no onDetailAdd no Adianti FrameWork 7.4.1