This topic is locked
[SOLVED]

Help regarding php runner 10.91 and php 8

3/4/2024 6:14:02 AM
PHPRunner General questions
A
Andrew S author

I have a project which I originally created several years ago and is currently running using php runner 9.8 and php 5.

I have been forced to upgrade to php runner 10.91 which I have done. My hosting company is no longer supporting legacy php versions.

I have created a test environment with php 8 and rebuilt the whole project. However, I have a piece of events code which is throwing up Uncaught Type error.

This code works fine php5 but not php8 (I am not a programmer so unsure of code I need to correct so would be very grateful if anyone can assist). All $values are field type Text in phprunner. They are stored as int in database.

($values['InvoiceLabourTax']=($values['InvoiceLabour']*$values['LabourTAXRate']));
($values['InvoiceAmount']=($values['InvoiceTotal']-$values['InvoiceLabourTax']));

Thanks in advance

admin 3/4/2024

The code itself looks fine to me. Maybe it doesn't work with some specific values that are not numbers? How do you know that the issue is with this specific code?

A
Andrew S author 3/4/2024

All the values are being treated as text and php8.2 no longer supports calculations this way. I am currently in the process of going through all values and converting to ints and storing in tmp variables to carry out calculations and it appears to be working so far. Just have one variable left which I am currently trying to debug. I know it is this code because I only have calculations on this page in the whole project.

A
Andrew S author 3/4/2024

This is the code which works fine php runner 9.8 php version 5

if ($_SESSION['tmpRetention']=="Y") {
$tmpsubtotal1 = ($values['InvoiceLabour']+$values['InvoiceMaterials']);
$tmpRetentionAmount = $tmpsubtotal1*$values['RetentionRate'];
($values['InvoiceSubTotal'] = $tmpsubtotal1-$tmpRetentionAmount);
($values['RetentionAmount']=$tmpRetentionAmount);
}
Else
{
($values['InvoiceSubTotal'] = ($values['InvoiceLabour']+$values['InvoiceMaterials']));

}

($values['InvoiceSubTotal'] = ($values['InvoiceLabour']+$values['InvoiceMaterials']));
($values['InvoiceVAT']=($values['InvoiceSubTotal']*$values['VATRate']));
($values['InvoiceTotal']=($values['InvoiceSubTotal']+$values['InvoiceVAT']));

// Added 28th February 2021 - VAT changes

if ($_SESSION['tmpVATReversal']=="Y") {
($values['VATReversalAmount']=$values['InvoiceVAT']);
($values['InvoiceTotal']=($values['InvoiceSubTotal']));
($values['InvoiceVAT']=0.00);
}

($values['InvoiceLabourTax']=($values['InvoiceLabour']*$values['LabourTAXRate']));
($values['InvoiceAmount']=($values['InvoiceTotal']-$values['InvoiceLabourTax']));
($values['InvoiceNo']=$values['workorderID']);
($values['Invoiced']="Yes");
($values['InvoicePaid']="No");

if ($values["InvoiceDate"]=="" || $values["InvoiceDate"]==NULL)
{

$values["InvoiceDate"]=now();

}
//Added 4th May 2013 - if status not changed to Invoice this will change it if Invoiced = Yes
if ($values['Invoiced']="Yes")
{
$values['statusID']=7;
}

// Place event code here.
// Use "Add Action" button to add code snippets.

return true;

A
Andrew S author 3/5/2024

I setup temp variables for all values that required adding / subtracting / multiplying and settype to Interger. All now works.