Situation:
I have a table LOTTI and a related table LOTTI_LINES
In LOTTI I have fields:
ID_LOTTO
INITIAL_QUANTITY (manual filled)
FINAL_QUANTITY (auto calculate)
In LOTTI_LINES I have fields:
ID_LOTTO
TRASH_QUANTITY (manual filled)
Now I would like to auto fill FINAL_QUANTITY like yhis:
INITIAL_QUANTITY - (SUM OF ALL RELATED TRASH_QUANTITY)...
Is it possible to do it?
I have already put some calculation on before_update and before_insert section of HOOK file to calculate some % between FIANL_QUANTITY and INITIAL_QUANTITY to know the final %...and works fine.
Thanks.
Auto Double-Calculate
Re: Auto Double-Calculate
You'd need to use the after_insert hook of the "hooks/LOTTI_LINES.php" file ... You should add code to execute an SQL statement for updating the FINAL_QUANTITY field of the LOTTI table ... something like this:
You need of course to calculate the value of $final_quantity and specify the value of $id_lotti before the above code line.
Code: Select all
sql("update LOTTI set FINAL_QUANTITY=$final_quantity where ID_LOTTI=$id_lotti", $eo);

- DataTalk is an innovative AppGini plugin based on ChatGPT that allows you to interact with your AppGini database using natural language questions, without writing any SQL. Check the demo video
- Check our other plugins and get a generous discount of up to 30% when buying 2 or more plugins.
- Need personalized consulting on your specific app and customizations? Book an online call with me here.