Fix var not defined

This commit is contained in:
Laurent Destailleur 2019-07-20 16:00:16 +02:00
parent 6594b361b1
commit 73b5302905

View File

@ -3024,7 +3024,7 @@ class Societe extends CommonObject
for ($index = 0; $index < 9; $index ++)
{
$number = (int) $siren[$index];
$number = (int) $chaine[$index];
if (($index % 2) != 0) { if (($number *= 2) > 9) $number -= 9; }
$sum += $number;
}
@ -3066,13 +3066,16 @@ class Societe extends CommonObject
$string=preg_replace('/(\s)/', '', $string);
$string = strtoupper($string);
for ($i = 0; $i < 9; $i ++)
$num[$i] = substr($string, $i, 1);
//Check format
if (!preg_match('/((^[A-Z]{1}[0-9]{7}[A-Z0-9]{1}$|^[T]{1}[A-Z0-9]{8}$)|^[0-9]{8}[A-Z]{1}$)/', $string))
return 0;
$num = array();
for ($i = 0; $i < 9; $i ++)
{
$num[$i] = substr($string, $i, 1);
}
//Check NIF
if (preg_match('/(^[0-9]{8}[A-Z]{1}$)/', $string))
if ($num[8] == substr('TRWAGMYFPDXBNJZSQVHLCKE', substr($string, 0, 8) % 23, 1))