Updating the calc element

I tried all the options, but nothing happened, maybe someone knows how to update after clicking on a certain element, the calc element of the form
PHP:
$firstday2 = '{sbrh2_datebase___id}';
$dbb = JFactory::getDbo();
$query='SELECT SUM(zp_day) FROM sbrh2_tabel_pers_log WHERE id = ANY(SELECT max(id) FROM sbrh2_tabel_pers_log WHERE familia = '.$firstday2.' GROUP BY date) AND familia = '.$firstday2.'';
$dbb->setQuery($query);
$datavalue = $dbb->loadResult();
$dbb_shtraf = JFactory::getDbo();
$query='SELECT SUM(shtraf) FROM sbrh2_motivacia WHERE id = ANY(SELECT max(id) FROM sbrh2_motivacia WHERE familia = '.$firstday2.' GROUP BY date_time) AND familia = '.$firstday2.'';
$dbb_shtraf->setQuery($query);
$shtraf_value = $dbb_shtraf->loadResult();
$dbb_premia = JFactory::getDbo();
$query='SELECT SUM(premia) FROM sbrh2_motivacia WHERE id = ANY(SELECT max(id) FROM sbrh2_motivacia WHERE familia = '.$firstday2.' GROUP BY date_time) AND familia = '.$firstday2.'';
$dbb_premia->setQuery($query);
$premia_value = $dbb_premia->loadResult();
$dbb_beznal = JFactory::getDbo();
$query='SELECT SUM(value) FROM sbrh2_extradition_log WHERE id = ANY(SELECT max(id) FROM sbrh2_extradition_log WHERE familia = '.$firstday2.' AND value_accrued = "beznal" GROUP BY data_create) AND value_accrued = "beznal" AND familia = '.$firstday2.'';
$dbb_beznal->setQuery($query);
$beznal_value = $dbb_beznal->loadResult();
$dbb_nal = JFactory::getDbo();
$query='SELECT SUM(value) FROM sbrh2_extradition_log WHERE id = ANY(SELECT max(id) FROM sbrh2_extradition_log WHERE familia = '.$firstday2.' AND value_accrued = "nal" GROUP BY data_create) AND value_accrued = "nal" AND familia = '.$firstday2.'';
$dbb_nal->setQuery($query);
$nal_value = $dbb_nal->loadResult();
$datavalues = $datavalue + $premia_value - $shtraf_value - ($nal_value + $beznal_value);
return number_format((float)$datavalues, 2, '.', '');
 
I understood that you want a calc element's value to change by means of JS when interacting with a (j)date element in the form -- "live" and in "real-time", so to speak.

Well, if that's the PHP in your calc element (haven't looked through all lines but trust the code works for you), then its returned value will be saved in the DB on form submission, if the calc element is set to do so (and I bet it is, because why else would you let it go through all those queries).
So, then it's obviously pointless to change anything in the calc element in the form with JS, because its PHP rules and will be executed anyway on save, practically "overriding" whatever happens in the form.

So, seems you'll want to approach this in a completely different way... either set/change the calc (or any other) element's value live in the form by means of JS depending on another element like date or so (no calc PHP, and the user then eventually seeing those changes in the form), or have the calc element watching the (j)date element and be updated with Ajax, or do your calcs in the element or in a PHP form on submit (the user then only seeing the result after submission in list or details).
 
I understood that you want a calc element's value to change by means of JS when interacting with a (j)date element in the form -- "live" and in "real-time", so to speak.

Well, if that's the PHP in your calc element (haven't looked through all lines but trust the code works for you), then its returned value will be saved in the DB on form submission, if the calc element is set to do so (and I bet it is, because why else would you let it go through all those queries).
So, then it's obviously pointless to change anything in the calc element in the form with JS, because its PHP rules and will be executed anyway on save, practically "overriding" whatever happens in the form.

So, seems you'll want to approach this in a completely different way... either set/change the calc (or any other) element's value live in the form by means of JS depending on another element like date or so (no calc PHP, and the user then eventually seeing those changes in the form), or have the calc element watching the (j)date element and be updated with Ajax, or do your calcs in the element or in a PHP form on submit (the user then only seeing the result after submission in list or details).
I have implemented inlineedit using non-standard fabrik tools, and using ajax, and the calculations shown above output information that has already been calculated and filtered, so I can't get the element updated with the means provided by fabrik, so I thought that using js, you can force the calc element to reboot, or force it to recalculate. Make something like
PHP:
Fabrik.get Block(list Ref).updateRows();


I tried to monitor changes in the element, but without results. I apologize for my English, I use google translator.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top