39 for ($i = $len - 1; $i >= 0; $i--) {
41 if ($i % 2 == $parity) {
48 return $sum % 10 == 0;
62 $siren = trim($siren);
63 $siren = preg_replace(
'/(\s)/',
'', $siren);
65 if (!is_numeric($siren) ||
dol_strlen($siren) != 9) {
83 $siret = trim($siret);
84 $siret = preg_replace(
'/(\s)/',
'', $siret);
86 if (!is_numeric($siret) ||
dol_strlen($siret) != 14) {
92 } elseif ((substr($siret, 0, 9) ==
"356000000") && (array_sum(str_split($siret)) % 5 == 0)) {
116 $str = preg_replace(
'/(\s)/',
'', $str);
118 if (preg_match(
'/(^[0-9]{9}$)/', $str)) {
137 $str = preg_replace(
'/(\s)/',
'', $str);
139 if (preg_match(
'/(^[0-9]{15}$)/', $str)) {
159 $str = preg_replace(
'/(\s)/',
'', $str);
161 if (preg_match(
'/(^[0-1]{1}[0-9]{3}\.[0-9]{3}\.[0-9]{3}$)/', $str)) {
182 $str = preg_replace(
'/(\s)/',
'', $str);
183 $str = strtoupper($str);
186 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}$)/', $str)) {
191 for ($i = 0; $i < 9; $i++) {
192 $num[$i] = substr($str, $i, 1);
194 '@phan-var-force array<int<0,8>,string> $num';
197 if (preg_match(
'/(^[0-9]{8}[A-Z]{1}$)/', $str)) {
198 if ($num[8] == substr(
'TRWAGMYFPDXBNJZSQVHLCKE', (
int) substr($str, 0, 8) % 23, 1)) {
206 $sum = (int) $num[2] + (
int) $num[4] + (int) $num[6];
207 for ($i = 1; $i < 8; $i += 2) {
208 $sum += intval(substr((
string) (2 * (
int) $num[$i]), 0, 1)) + intval(substr((
string) (2 * (
int) $num[$i]), 1, 1));
210 $n = 10 - (int) substr((
string) $sum, strlen((
string) $sum) - 1, 1);
213 if (preg_match(
'/^[KLM]{1}/', $str)) {
214 if ($num[8] == chr(64 + $n) || $num[8] == substr(
'TRWAGMYFPDXBNJZSQVHLCKE', (
int) substr($str, 1, 8) % 23, 1)) {
222 if (preg_match(
'/^[ABCDEFGHJNPQRSUVW]{1}/', $str)) {
223 if ($num[8] == chr(64 + $n) || $num[8] == substr((
string) $n, strlen((
string) $n) - 1, 1)) {
231 if (preg_match(
'/^[T]{1}/', $str)) {
232 if ($num[8] == preg_match(
'/^[T]{1}[A-Z0-9]{8}$/', $str)) {
240 if (preg_match(
'/^[XYZ]{1}/', $str)) {
241 if ($num[8] == substr(
'TRWAGMYFPDXBNJZSQVHLCKE', (
int) substr(str_replace(array(
'X',
'Y',
'Z'), array(
'0',
'1',
'2'), $str), 0, 8) % 23, 1)) {
270 if ($thirdparty->country_code ==
'FR') {
271 if ($idprof == 1 && !
isValidSiren($thirdparty->idprof1, $lenghtonly)) {
276 if ($idprof == 2 && !
isValidSiret($thirdparty->idprof2, $lenghtonly)) {
282 if ($idprof == 1 && $thirdparty->country_code ==
'ES') {
287 if ($idprof == 1 && $thirdparty->country_code ==
'PT' && !
isValidTinForPT($thirdparty->idprof1)) {
292 if ($idprof == 1 && $thirdparty->country_code ==
'DZ' && !
isValidTinForDZ($thirdparty->idprof1)) {
297 if ($idprof == 1 && $thirdparty->country_code ==
'BE' && !
isValidTinForBE($thirdparty->idprof1)) {
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
isValidSiren($siren, $lengthonly=0)
Check the syntax validity of a SIREN.
isValidLuhn($str)
Check if a string passes the Luhn algorithm test.
isValidTinForPT($str)
Check the syntax validity of a Portuguese (PT) Tax Identification Number (TIN).
isValidTinForES($str)
Check the syntax validity of a Spanish (ES) Tax Identification Number (TIN), where:
isValidProfIds($idprof, $thirdparty, $lenghtonly=0)
Check the validity of a professional identifier according to the properties (country) of the company ...
isValidTinForBE($str)
Check the syntax validity of a Belgium (BE) Tax Identification Number (TIN).
isValidSiret($siret, $lengthonly=0)
Check the syntax validity of a SIRET.
isValidTinForDZ($str)
Check the syntax validity of an Algerian (DZ) Tax Identification Number (TIN).