erros Undefined Index e Undefined Variable Tenho um formulário que começou a apresentar erros: Notice: Undefined index: Oferta_list_dt_oferta on line 563 Notice: Undefined variable: total on line 581 Não estou conseguindo identificar o que está ocorrendo. está salvando e também somando e enviando a soma dos detalhes normalmente más apresentam o erros na tela após o salvamento. ...
AR
erros Undefined Index e Undefined Variable  
Tenho um formulário que começou a apresentar erros:
Notice: Undefined index: Oferta_list_dt_oferta on line 563
Notice: Undefined variable: total on line 581

Não estou conseguindo identificar o que está ocorrendo.
está salvando e também somando e enviando a soma dos detalhes normalmente más apresentam o erros na tela após o salvamento.

 
  1. <?php
  2. /**
  3. * ReceitaForm Master/Detail
  4. * @author Alexandre M. Roberto
  5. */
  6. class ReceitaForm extends TPage
  7. {
  8. protected $form; // form
  9. protected $detail_list;
  10. // trait with saveFile, saveFiles, ...
  11. use Adianti\Base\AdiantiFileSaveTrait;
  12. /**
  13. * Page constructor
  14. */
  15. public function __construct()
  16. {
  17. parent::__construct();
  18. // creates the form
  19. $this->form = new BootstrapFormBuilder('form_Receita');
  20. $this->form->setFormTitle('Formulário de Receita da Paróquia/Comunidade');
  21. $this->form->setClientValidation(true);
  22. // master fields
  23. $id = new TEntry('id');
  24. $dt_receita = new TDate('dt_receita');
  25. $refmes = new TCombo('refmes');
  26. $refano = new TCombo('refano');
  27. $contribuicoes = new TEntry('contribuicoes');
  28. $ofertas = new TEntry('ofertas');
  29. $doacoes = new TEntry('doacoes');
  30. $promocoes = new TEntry('promocoes');
  31. $patrimonial = new TEntry('patrimonial');
  32. $outros = new TEntry('outros');
  33. $tot_receitas = new TEntry('tot_receitas');
  34. $dizimo = new TEntry('dizimo');
  35. $parcelado = new TEntry('parcelado');
  36. $parcelado->style = "background-color: #DFE54A";
  37. $ofertas_a_repassar = new TEntry('ofertas_a_repassar');
  38. $comprovantes = new TMultiFile('comprovantes');
  39. $comprovantes->setAllowedExtensions( ['gif', 'png', 'jpg', 'jpeg', 'pdf'] );
  40. $comprovantes->enableFileHandling();
  41. $comprovantes->enableImageGallery();
  42. $comprovantes->enablePopover('Preview', '<img style="max-width:300px" src="download.php?file={file_name}">');
  43. $dep_dizimo = new TDate('dep_dizimo');
  44. $dep_ofertas_a_repassar = new TDate('dep_ofertas_a_repassar');
  45. $observacoes = new TText('observacoes');
  46. $dt_receita->setMask('dd/mm/yyyy');
  47. $dt_receita->setDatabaseMask('yyyy-mm-dd');
  48. $dt_receita->setValue( date('Y-m-d') );
  49. $contribuicoes->setNumericMask(2, ',', '.', true);
  50. $ofertas->setNumericMask(2, ',', '.', true);
  51. $doacoes->setNumericMask(2, ',', '.', true);
  52. $promocoes->setNumericMask(2, ',', '.', true);
  53. $patrimonial->setNumericMask(2, ',', '.', true);
  54. $outros->setNumericMask(2, ',', '.', true);
  55. $tot_receitas->setNumericMask(2, ',', '.', true);
  56. $dizimo->setNumericMask(2, ',', '.', true);
  57. $ofertas_a_repassar->setNumericMask(2, ',', '.', true);
  58. $parcelado->setNumericMask(2, ',', '.', true);
  59. $current = (int) date('Y');
  60. $refmes->addItems( ['01' => 'Janeiro',
  61. '02' => 'Fevereiro',
  62. '03' => 'Março',
  63. '04' => 'Abril',
  64. '05' => 'Maio',
  65. '06' => 'Junho',
  66. '07' => 'Julho',
  67. '08' => 'Agosto',
  68. '09' => 'Setembro',
  69. '10' => 'Outubro',
  70. '11' => 'Novembro',
  71. '12' => 'Dezembro'] );
  72. $refano->addItems( [ ($current -5) => ($current -5), ($current -4) => ($current -4), ($current -3) => ($current -3), ($current -2) => ($current -2), ($current -1) => ($current -1), $current => $current ] );
  73. $id->setSize('100%');
  74. $dt_receita->setSize('100%');
  75. $refmes->setSize('100%');
  76. $refano->setSize('100%');
  77. $contribuicoes->setSize('100%');
  78. $ofertas->setSize('100%');
  79. $doacoes->setSize('100%');
  80. $promocoes->setSize('100%');
  81. $patrimonial->setSize('100%');
  82. $outros->setSize('100%');
  83. $tot_receitas->setSize('100%');
  84. $tot_receitas->setEditable(FALSE);
  85. $dizimo->setSize('100%');
  86. $parcelado->setSize('100%');
  87. $parcelado->style = ("background-color: #ffff99; text-align: right;");
  88. $dizimo->setEditable(FALSE);
  89. $ofertas_a_repassar->setSize('100%');
  90. $ofertas_a_repassar->setEditable(FALSE);
  91. $contribuicoes->setValue(0);
  92. $ofertas->setValue(0);
  93. $doacoes->setValue(0);
  94. $promocoes->setValue(0);
  95. $patrimonial->setValue(0);
  96. $outros->setValue(0);
  97. $parcelado->setValue(0);
  98. $comprovantes->setSize('100%');
  99. $dep_dizimo->setSize('100%');
  100. $dep_dizimo->setMask('dd/mm/yyyy');
  101. $dep_dizimo->setDatabaseMask('yyyy-mm-dd');
  102. $dep_ofertas_a_repassar->setMask('dd/mm/yyyy');
  103. $dep_ofertas_a_repassar->setDatabaseMask('yyyy-mm-dd');
  104. $dep_ofertas_a_repassar->setSize('100%');
  105. $observacoes->setSize('100%');
  106. // detail fields
  107. $detail_uniqid = new THidden('detail_uniqid');
  108. $detail_id = new THidden('detail_id');
  109. $detail_dt_oferta = new TDate('detail_dt_oferta');
  110. $detail_dt_oferta->setMask('dd/mm/yyyy');
  111. $detail_dt_oferta->setDatabaseMask('yyyy-mm-dd');
  112. $detail_plano_id = new TDBCombo('detail_plano_id', 'sinodo', 'Plano', 'id', '{favorecido} ({oferta_tipo->nome})');
  113. $detail_plano_id->setEditable(FALSE);
  114. $detail_plano_id->setSize('100%');
  115. $detail_valor = new TNumeric('detail_valor', 2, ',', '.', true);
  116. $refmes->addValidation('Mês', new TRequiredValidator);
  117. $refano->addValidation('Ano', new TRequiredValidator);
  118. $detail_deposito = new TDate('detail_deposito');
  119. $detail_deposito->setMask('dd/mm/yyyy');
  120. $detail_deposito->setDatabaseMask('yyyy-mm-dd');
  121. // exit action
  122. $detail_dt_oferta->setExitAction(new TAction([$this,'onExitDate']));
  123. if (!empty($id))
  124. {
  125. $id->setEditable(FALSE);
  126. }
  127. // master fields
  128. $row = $this->form->addFields( [ new TLabel('Id'), $id ],
  129. [ new TLabel('Data'), $dt_receita ],
  130. [ new TLabel('Mês'), $refmes ],
  131. [ new TLabel('Ano'), $refano ] );
  132. $row->layout = ['col-sm-3', 'col-sm-3', 'col-sm-3', 'col-sm-3' ];
  133. $row = $this->form->addFields( [ new TLabel('Contribuições'), $contribuicoes ],
  134. [ new TLabel('Ofertas'), $ofertas ],
  135. [ new TLabel('Doações'), $doacoes ],
  136. [ new TLabel('Promoções'), $promocoes ]);
  137. $row->layout = ['col-sm-3', 'col-sm-3', 'col-sm-3', 'col-sm-3' ];
  138. $row = $this->form->addFields( [ new TLabel('Renda Patrimonial'), $patrimonial ],
  139. [ new TLabel('Outras Receitas'), $outros ],
  140. [ new TLabel('Total Receitas'), $tot_receitas ],
  141. [ new TLabel('Dizimo (10%)'), $dizimo ]);
  142. $row->layout = ['col-sm-3', 'col-sm-3','col-sm-3', 'col-sm-3' ];
  143. $row = $this->form->addFields( [ new TLabel('Data do Depósito Dízimo (10%)'), $dep_dizimo ],
  144. [ new TLabel('<b>Dízimo em atrazo / parcelado</b>'), $parcelado ] );
  145. $row->layout = ['col-sm-3', 'col-sm-3' ];
  146. $label4 = new TLabel('Comprovantes', '#5A73DB', 12, '');
  147. $label4->style='text-align:left;border-bottom:1px solid #c0c0c0;width:100%; padding-top: 25px;';
  148. $this->form->addContent( [$label4] );
  149. $row = $this->form->addFields( [ $comprovantes ]);
  150. $row->layout = ['col-sm-12' ];
  151. $contribuicoes->setExitAction(new TAction(array($this, 'onUpdateTotal')));
  152. $ofertas->setExitAction(new TAction(array($this, 'onUpdateTotal')));
  153. $doacoes->setExitAction(new TAction(array($this, 'onUpdateTotal')));
  154. $patrimonial->setExitAction(new TAction(array($this, 'onUpdateTotal')));
  155. $promocoes->setExitAction(new TAction(array($this, 'onUpdateTotal')));
  156. $outros->setExitAction(new TAction(array($this, 'onUpdateTotal')));
  157. $parcelado->setExitAction(new TAction(array($this, 'onUpdateTotal')));
  158. // detail fields
  159. $label4 = new TLabel('Ofertas a Repassar', '#5A73DB', 12, '');
  160. $label4->style='text-align:left;border-bottom:1px solid #c0c0c0;width:100%; padding-top: 25px;';
  161. $this->form->addContent( [$label4] );
  162. $this->form->addFields( [$detail_uniqid] );
  163. $this->form->addFields( [$detail_id] );
  164. $row = $this->form->addFields( [ new TLabel('Data Oferta'), $detail_dt_oferta ],
  165. [ new TLabel('Favorecido'), $detail_plano_id ],
  166. [ new TLabel('Data Depósito'), $detail_deposito ],
  167. [ new TLabel('Valor'), $detail_valor ]);
  168. $row->layout = ['col-sm-2', 'col-sm-6', 'col-sm-2', 'col-sm-2'];
  169. $add = TButton::create('add', [$this, 'onDetailAdd'], _t('Register'), 'fa:plus-circle green');
  170. $add->getAction()->setParameter('static','1');
  171. $this->form->addFields( [], [$add] );
  172. $this->detail_list = new BootstrapDatagridWrapper(new TDataGrid);
  173. $this->detail_list->setId('Oferta_list');
  174. $this->detail_list->setHeight(150);
  175. $this->detail_list->makeScrollable();
  176. $this->detail_list->generateHiddenFields();
  177. $this->detail_list->style = "min-width: 700px; width:100%;margin-bottom: 10px";
  178. // items
  179. $col_uniq = new TDataGridColumn( 'uniqid', 'Uniqid', 'center', '10%');
  180. $col_id = new TDataGridColumn( 'id', 'ID', 'center', '10%');
  181. $col_dt_oferta = new TDataGridColumn( 'dt_oferta', 'Data', 'center', '20%');
  182. $col_plano_id = new TDataGridColumn( 'plano_id', 'Favorecido', 'left', '40%');
  183. $col_deposito = new TDataGridColumn( 'deposito', 'Depósito', 'center', '10%');
  184. $col_valor = new TDataGridColumn( 'valor', 'Valor', 'right', '20%');
  185. $this->detail_list->addColumn( $col_uniq );
  186. $this->detail_list->addColumn( $col_id );
  187. $this->detail_list->addColumn( $col_dt_oferta );
  188. $this->detail_list->addColumn( $col_plano_id );
  189. $this->detail_list->addColumn( $col_deposito );
  190. $this->detail_list->addColumn( $col_valor );
  191. $col_id->setVisibility(false);
  192. $col_uniq->setVisibility(false);
  193. $col_dt_oferta->setTransformer( function($value, $object, $row) {
  194. if ($value)
  195. {
  196. try
  197. {
  198. $date = new DateTime($value);
  199. return $date->format('d/m/Y');
  200. }
  201. catch (Exception $e)
  202. {
  203. return $value;
  204. }
  205. }
  206. return $value;
  207. });
  208. $col_plano_id->setTransformer(function($value) {
  209. TTransaction::open('sinodo');
  210. $plano = new Plano($value);
  211. $favorecido = $plano->favorecido;
  212. $oferta_tipo = $plano->oferta_tipo->nome;
  213. TTransaction::close();
  214. return $favorecido . ' (' . $oferta_tipo . ')';
  215. });
  216. $format_value = function($value) {
  217. if (is_numeric($value)) {
  218. return 'R$ '.number_format($value, 2, ',', '.');
  219. }
  220. return $value;
  221. };
  222. $col_valor->setTransformer( $format_value );
  223. $col_valor->enableTotal('sum', 'R$', 2, ',', '.');
  224. // define the transformer method over image
  225. $col_deposito->setTransformer( function($value, $object, $row) {
  226. if ($value)
  227. {
  228. try
  229. {
  230. $date = new DateTime($value);
  231. return $date->format('d/m/Y');
  232. }
  233. catch (Exception $e)
  234. {
  235. return $value;
  236. }
  237. }
  238. return $value;
  239. });
  240. // detail actions
  241. $action1 = new TDataGridAction([$this, 'onDetailEdit'] );
  242. $action1->setFields( ['uniqid', '*'] );
  243. $action2 = new TDataGridAction([$this, 'onDetailDelete']);
  244. $action2->setField('uniqid');
  245. // add the actions to the datagrid
  246. $this->detail_list->addAction($action1, _t('Edit'), 'fa:edit blue');
  247. $this->detail_list->addAction($action2, _t('Delete'), 'fa:trash-alt red');
  248. $panel = new TPanelGroup;
  249. $panel->add($this->detail_list);
  250. $panel->getBody()->style = 'overflow-x:auto';
  251. $this->form->addContent( [$panel] );
  252. $label4 = new TLabel('Obervações', '#5A73DB', 12, '');
  253. $label4->style='text-align:left;border-bottom:1px solid #c0c0c0;width:100%; padding-top: 25px;';
  254. $this->form->addContent( [$label4] );
  255. $row = $this->form->addFields( [ new TLabel(''), $observacoes ] );
  256. $row->layout = ['col-sm-12' ];
  257. $this->detail_list->createModel();
  258. $this->form->addAction( 'Save', new TAction([$this, 'onSave'], ['static'=>'1']), 'fa:save green');
  259. $this->form->addAction( 'Clear', new TAction([$this, 'onClear']), 'fa:eraser red');
  260. $this->form->addActionLink(_t('Back'),new TAction(array('ReceitaList','onReload')),'far:arrow-alt-circle-left blue');
  261. // create the page container
  262. $container = new TVBox;
  263. $container->style = 'width: 100%';
  264. // $container->add(new TXMLBreadCrumb('menu.xml', __CLASS__));
  265. $container->add($this->form);
  266. parent::add($container);
  267. }
  268. public function formatDate($date, $object)
  269. {
  270. $dt = new DateTime($date);
  271. return $dt->format('d/m/Y');
  272. }
  273. public static function onExitDate($params)
  274. {
  275. if( !empty($params['detail_dt_oferta']) )
  276. {
  277. try
  278. {
  279. TTransaction::open('sinodo');
  280. $criteria = new TCriteria;
  281. $dt_oferta = TDate::date2us( $params['detail_dt_oferta']);
  282. $criteria->add( new TFilter( 'dt_oferta', '=' , $dt_oferta ));
  283. $criteria->add( new TFilter( 'oferta_tipo_id', '!=', '3' ));
  284. $repository = new TRepository('Plano');
  285. $planos = $repository->load( $criteria );
  286. if ($planos)
  287. {
  288. foreach ($planos as $plano)
  289. {
  290. TForm::sendData('form_Receita', (object) ['detail_plano_id' => $plano->id ]);
  291. }
  292. }
  293. else
  294. {
  295. new TMessage('info', 'Verifique se existe oferta a repassar nesta data e tente novamente!');
  296. }
  297. }
  298. catch (Exception $e)
  299. {
  300. new TMessage('error', $e->getMessage());
  301. TTransaction::rollback();
  302. }
  303. }
  304. }
  305. /**
  306. * Clear form
  307. * @param $param URL parameters
  308. */
  309. public function onClear($param)
  310. {
  311. $this->form->clear(TRUE);
  312. }
  313. /**
  314. * Add detail item
  315. * @param $param URL parameters
  316. */
  317. public function onDetailAdd( $param )
  318. {
  319. try
  320. {
  321. $this->form->validate();
  322. $data = $this->form->getData();
  323. // validation sample
  324. if (empty($data->detail_deposito))
  325. {
  326. throw new Exception('Informe a data do depósito!');
  327. }
  328. $uniqid = !empty($data->detail_uniqid) ? $data->detail_uniqid : uniqid();
  329. $grid_data = [];
  330. $grid_data['uniqid'] = $uniqid;
  331. $grid_data['id'] = $data->detail_id;
  332. $grid_data['dt_oferta'] = $data->detail_dt_oferta;
  333. $grid_data['plano_id'] = $data->detail_plano_id;
  334. $grid_data['deposito'] = $data->detail_deposito;
  335. $grid_data['valor'] = $data->detail_valor;
  336. // insert row dynamically
  337. $row = $this->detail_list->addItem( (object) $grid_data );
  338. $row->id = $uniqid;
  339. TDataGrid::replaceRowById('Oferta_list', $uniqid, $row);
  340. $data = new stdClass;
  341. // clear detail form fields
  342. $data->detail_uniqid = '';
  343. $data->detail_id = '';
  344. $data->detail_dt_oferta = '';
  345. $data->detail_plano_id = '';
  346. $data->detail_deposito = '';
  347. $data->detail_valor = '';
  348. // send data, do not fire change/exit events
  349. TForm::sendData( 'form_Receita', $data, false, false );
  350. }
  351. catch (Exception $e)
  352. {
  353. $this->form->setData( $this->form->getData());
  354. new TMessage('error', $e->getMessage());
  355. }
  356. }
  357. /**
  358. * Edit detail item
  359. * @param $param URL parameters
  360. */
  361. public static function onDetailEdit( $param )
  362. {
  363. $data = new stdClass;
  364. $data->detail_uniqid = $param['uniqid'];
  365. $data->detail_id = $param['id'];
  366. $data->detail_dt_oferta = TDate::date2br($param['dt_oferta']);
  367. $data->detail_plano_id = $param['plano_id'];
  368. $data->detail_deposito = TDate::date2br($param['deposito']);
  369. $data->detail_valor = number_format($param['valor'], 2, ',','.');
  370. // send data, do not fire change/exit events
  371. TForm::sendData( 'form_Receita', $data, false, false );
  372. }
  373. /**
  374. * Delete detail item
  375. * @param $param URL parameters
  376. */
  377. public static function onDetailDelete( $param )
  378. {
  379. // clear detail form fields
  380. $data = new stdClass;
  381. $data->detail_uniqid = '';
  382. $data->detail_id = '';
  383. $data->detail_dt_oferta = '';
  384. $data->detail_plano_id = '';
  385. $data->detail_deposito = '';
  386. $data->detail_valor = '';
  387. // send data, do not fire change/exit events
  388. TForm::sendData( 'form_Receita', $data, false, false );
  389. // remove row
  390. TDataGrid::removeRowById('Oferta_list', $param['uniqid']);
  391. }
  392. /**
  393. * Load Master/Detail data from database to form
  394. */
  395. public function onEdit($param)
  396. {
  397. try
  398. {
  399. TTransaction::open('sinodo');
  400. if (isset($param['key']))
  401. {
  402. $key = $param['key'];
  403. $object = new Receita($key);
  404. $object->comprovantes = ReceitaImagem::where('receita_id', '=', $param['key'])->getIndexedArray('imagem');
  405. $items = Oferta::where('receita_id', '=', $key)->load();
  406. foreach( $items as $item )
  407. {
  408. $item->uniqid = uniqid();
  409. $row = $this->detail_list->addItem( $item );
  410. $row->id = $item->uniqid;
  411. }
  412. $this->form->setData($object);
  413. TTransaction::close();
  414. }
  415. else
  416. {
  417. $this->form->clear(TRUE);
  418. }
  419. }
  420. catch (Exception $e) // in case of exception
  421. {
  422. new TMessage('error', $e->getMessage());
  423. TTransaction::rollback();
  424. }
  425. }
  426. /**
  427. * Update the total based on the sale price, amount
  428. */
  429. public static function onUpdateTotal($param)
  430. {
  431. $contribuicoes = (double) str_replace(['.', ','], ['', '.'], $param['contribuicoes']);
  432. $ofertas = (double) str_replace(['.', ','], ['', '.'], $param['ofertas']);
  433. $doacoes = (double) str_replace(['.', ','], ['', '.'], $param['doacoes']);
  434. $patrimonial = (double) str_replace(['.', ','], ['', '.'], $param['patrimonial']);
  435. $promocoes = (double) str_replace(['.', ','], ['', '.'], $param['promocoes']);
  436. $outros = (double) str_replace(['.', ','], ['', '.'], $param['outros']);
  437. $obj = new StdClass;
  438. $obj->tot_receitas = number_format(($contribuicoes + $ofertas + $doacoes + $patrimonial + $promocoes + $outros), 2, ',', '.');
  439. $obj->dizimo = number_format((($contribuicoes + $ofertas + $doacoes + $patrimonial + $promocoes + $outros) * 0.10), 2, ',', '.');
  440. TForm::sendData('form_Receita', $obj);
  441. }
  442. /**
  443. * Save the Master/Detail data from form to database
  444. */
  445. public function onSave($param)
  446. {
  447. try
  448. {
  449. // open a transaction with database
  450. TTransaction::open('sinodo');
  451. $data = $this->form->getData();
  452. $this->form->validate();
  453. $master = new Receita;
  454. $master->fromArray( (array) $data);
  455. $master->contribuicoes = str_replace(['.', ','], ['', '.'], $param['contribuicoes']);
  456. $master->ofertas = str_replace(['.', ','], ['', '.'], $param['ofertas']);
  457. $master->doacoes = str_replace(['.', ','], ['', '.'], $param['doacoes']);
  458. $master->patrimonial = str_replace(['.', ','], ['', '.'], $param['patrimonial']);
  459. $master->promocoes = str_replace(['.', ','], ['', '.'], $param['promocoes']);
  460. $master->outros = str_replace(['.', ','], ['', '.'], $param['outros']);
  461. $master->tot_receitas = str_replace(['.', ','], ['', '.'], $param['tot_receitas']);
  462. $master->dizimo = str_replace(['.', ','], ['', '.'], $param['dizimo']);
  463. $master->parcelado = str_replace(['.', ','], ['', '.'], $param['parcelado']);
  464. $master->system_user_id = TSession::getValue('userid');
  465. $master->system_unit_id = TSession::getValue('userunitid');
  466. $master->mes = TDateTime::convertToMask($master->dep_dizimo, 'yyyy-mm-dd', 'mm');
  467. $master->ano = TDateTime::convertToMask($master->dep_dizimo, 'yyyy-mm-dd', 'yyyy');
  468. $master->dep_confirmado = 'N';
  469. $master->store();
  470. $this->saveFiles($master, $data, 'comprovantes', 'files/images', 'ReceitaImagem', 'imagem', 'receita_id');
  471. Oferta::where('receita_id', '=', $master->id)->delete();
  472. if( $param['Oferta_list_dt_oferta'] )
  473. {
  474. $total = 0;
  475. foreach( $param['Oferta_list_dt_oferta'] as $key => $item_id )
  476. {
  477. $detail = new Oferta;
  478. $detail->dt_oferta = $param['Oferta_list_dt_oferta'][$key];
  479. $detail->plano_id = $param['Oferta_list_plano_id'][$key];
  480. $detail->valor = $param['Oferta_list_valor'][$key];
  481. $detail->deposito = $param['Oferta_list_deposito'][$key];
  482. $detail->mes = TDateTime::convertToMask($detail->deposito, 'yyyy-mm-dd', 'mm');
  483. $detail->ano = TDateTime::convertToMask($detail->deposito, 'yyyy-mm-dd', 'yyyy');
  484. $detail->receita_id = $master->id;
  485. $detail->system_unit_id = (int)TSession::getValue('userunitid');
  486. $detail->store();
  487. $total += $detail->valor;
  488. }
  489. }
  490. $master->ofertas_a_repassar = $total;
  491. $master->total_deposito = $master->dizimo + $master->ofertas_a_repassar + $master->parcelado;
  492. $master->store(); // stores the object
  493. TForm::sendData('form_Receita', (object) ['id' => $master->id]);
  494. $this->form->setData($data); // fill form data
  495. TTransaction::close(); // close the transaction
  496. new TMessage('info', AdiantiCoreTranslator::translate('Record saved').'!' . '<br> O Sínodo agradece por Informar!');
  497. }
  498. catch (Exception $e) // in case of exception
  499. {
  500. if($e->getCode() ==23000){
  501. new TMessage('error', 'Erro: ' . 'Já existe receita informada para este mês/ano! <br> Verifique e tente novamente.');
  502. }else{
  503. new TMessage('error', $e->getMessage());
  504. $this->form->setData( $this->form->getData() ); // keep form data
  505. }
  506. TTransaction::rollback();
  507. }
  508. }
  509. }

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


MG

Você está inicializando a variável
$total
dentro do
if( $param['Oferta_list_dt_oferta'] )
.
Teste inicializar antes, pois se o
if
for falso, a linha a seguir onte vc exibe o $total não exibe ainda.
Veja se funciona?
AR

Olá Marcelo,

Obrigado pela Dica. o erro da variável $total foi resolvido com sua sugestão.

Más continua ainda o erro Notice: Undefined index: Oferta_list_dt_oferta na linha 563.

AR

Consegui resolver, fiz uma alteração na linha 563 para:

if( !empty($param['Oferta_list_dt_oferta'] ))

Resolveu aqui, muito obrigado
MG

Excelente! Bom trabalho.
RF

Obrigadão, salvou, consegui aqui também utilizando esse if.