[+] Project : B2B Features

This commit is contained in:
jBreux
2011-12-22 15:30:21 +00:00
parent 171d7c61cb
commit 4eb9edf698
18 changed files with 984 additions and 19 deletions
+31
View File
@@ -934,5 +934,36 @@ class ValidateCore
return false;
return true;
}
/**
* Validate SIRET Code
* @static
* @param $siret SIRET Code
* @return boolean Return true if is valid
*/
public static function isSiret($siret)
{
if (Tools::strlen($siret) != 14)
return false;
$sum = 0;
for($i=0; $i != 14; $i++) {
$tmp = ((($i + 1) % 2) + 1) * intval($siret[$i]);
if ($tmp >= 10)
$tmp -= 9;
$sum += $tmp;
}
return ($sum % 10 === 0);
}
/**
* Validate APE Code
* @static
* @param $ape APE Code
* @return boolean Return true if is valid
*/
public static function isApe($ape)
{
return (bool)preg_match('/^[0-9]{3,4}[a-zA-Z]{1}$/s', $ape);
}
}