automatic calculation instead of after update/insert code
Posted: 2023-10-12 16:26
Hi everyone, I have a problem: I have a code that works well if inserted in the after update/insert section hook page.
However, on this page the values are updated only when I update the fields.
Can anyone help me convert the code so I can use it directly in automatic calculations?
However, on this page the values are updated only when I update the fields.
Can anyone help me convert the code so I can use it directly in automatic calculations?
Code: Select all
$tb = sqlValue("SELECT `Tot_blocchi` FROM `Acquisto_peso` WHERE `id`=" . $data['Totfat']);
$sum = sqlValue("SELECT SUM(`Lordo`) FROM `Movimenti_acquisto_peso` WHERE `Totfat`=" . $data['Totfat']);
$rr = $sum - $tb ;
sql("UPDATE `Movimenti_acquisto_peso` SET `Differenza`='" . $rr . "' WHERE `id`=" . $data['selectedID'], $eo);