Last active
October 24, 2023 11:04
-
-
Save cupertinobr/79340ae780be4b24f07f5ca877e39918 to your computer and use it in GitHub Desktop.
Saldo calculado por coluna em DatilForm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
- Cria a coluna "Saldo" no DetailForm | |
- Nas prorpiedades do DetailForm criar envento onUpdateList | |
*/ | |
public static function onUpdateList($param = null) | |
{ | |
try | |
{ | |
$saldo = 0; | |
if( ! empty($param['list_data'])) | |
{ | |
foreach($param['list_data'] as $index => $data) | |
{ | |
if ($data['operacao'] == 'C') | |
{ | |
$saldo += $data['pontos']; | |
} elseif ($data['operacao'] == 'D') { | |
$saldo -= $data['pontos']; | |
} | |
//Atualiza a colna vis JS, usado o ID da tag <table> | |
TScript::create("$('#id_da_table_do_seu_datilform_list tbody tr:eq({$index}) td:eq(6)').html('{$saldo}')"); | |
} | |
} | |
} | |
catch (Exception $e) | |
{ | |
new TMessage('error', $e->getMessage()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment