[+] Project : B2B Features

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@11619 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
jBreux
2011-12-22 15:30:21 +00:00
parent 96df495dd6
commit e3a5d7fe37
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);
}
}