dolibarr 24.0.0-beta
profid.lib.php File Reference

Set of functions for professional identifiers. More...

Go to the source code of this file.

Functions

 isValidLuhn ($str)
 Check if a string passes the Luhn algorithm test.
 
 isValidSiren ($siren, $lengthonly=0)
 Check the syntax validity of a SIREN.
 
 isValidSiret ($siret, $lengthonly=0)
 Check the syntax validity of a SIRET.
 
 isValidTinForPT ($str)
 Check the syntax validity of a Portuguese (PT) Tax Identification Number (TIN).
 
 isValidTinForDZ ($str)
 Check the syntax validity of an Algerian (DZ) Tax Identification Number (TIN).
 
 isValidTinForBE ($str)
 Check the syntax validity of a Belgium (BE) 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 (siren, siret, ...)
 

Detailed Description

Set of functions for professional identifiers.

Definition in file profid.lib.php.

Function Documentation

◆ isValidLuhn()

isValidLuhn ( $str)

Check if a string passes the Luhn algorithm test.

Parameters
string | int$strstring to check
Returns
bool True if the string passes the Luhn algorithm check, False otherwise
Since
Dolibarr V20

Definition at line 33 of file profid.lib.php.

References dol_strlen(), and string.

Referenced by isValidSiren(), and isValidSiret().

◆ isValidProfIds()

isValidProfIds ( $idprof,
$thirdparty,
$lenghtonly = 0 )

Check the validity of a professional identifier according to the properties (country) of the company (siren, siret, ...)

Parameters
int$idprof1,2,3,4 (Example: 1=siren, 2=siret, 3=naf, 4=rcs/rm)
Societe$thirdpartyObject societe
int$lenghtonlyMake surface test only (length, ...)
Returns
int Return integer <=0 if KO, >0 if OK

Definition at line 261 of file profid.lib.php.

References getDolGlobalString(), isValidSiren(), isValidSiret(), isValidTinForBE(), isValidTinForDZ(), isValidTinForES(), and isValidTinForPT().

Referenced by Societe\id_prof_check().

◆ isValidSiren()

isValidSiren ( $siren,
$lengthonly = 0 )

Check the syntax validity of a SIREN.

Parameters
string$sirenSIREN to check
int$lengthonlyMake surface test only (length, ...)
Returns
boolean True if valid, False otherwise
Since
Dolibarr V20

Definition at line 60 of file profid.lib.php.

References dol_strlen(), and isValidLuhn().

Referenced by isValidProfIds().

◆ isValidSiret()

isValidSiret ( $siret,
$lengthonly = 0 )

Check the syntax validity of a SIRET.

Parameters
string$siretSIRET to check
int$lengthonlyMake surface test only (length, ...)
Returns
boolean True if valid, False otherwise
Since
Dolibarr V20

Specific case of "La Poste" businesses (SIRET such as "356 000 000 XXXXX"), for which the rule becomes: the sum of the 14 digits must be a multiple of 5. See https://fr.wikipedia.org/wiki/SIRET for details.

Definition at line 81 of file profid.lib.php.

References dol_strlen(), and isValidLuhn().

Referenced by isValidProfIds().

◆ isValidTinForBE()

isValidTinForBE ( $str)

Check the syntax validity of a Belgium (BE) Tax Identification Number (TIN).

(NN = Numéro National)

Parameters
string$strNN to check
Returns
boolean True if valid, False otherwise
Since
Dolibarr V20

Definition at line 155 of file profid.lib.php.

Referenced by isValidProfIds().

◆ isValidTinForDZ()

isValidTinForDZ ( $str)

Check the syntax validity of an Algerian (DZ) Tax Identification Number (TIN).

(NIF = Numéro d'Identification Fiscale)

Parameters
string$strTIN to check
Returns
boolean True if valid, False otherwise
Since
Dolibarr V20

Definition at line 134 of file profid.lib.php.

Referenced by isValidProfIds().

◆ isValidTinForES()

isValidTinForES ( $str)

Check the syntax validity of a Spanish (ES) Tax Identification Number (TIN), where:

  • NIF = Número de Identificación Fiscal (used for residents only before 2008. Used for both residents and companies since 2008.)
  • CIF = Código de Identificación Fiscal (used for companies only before 2008. Replaced by NIF since 2008.)
  • NIE = Número de Identidad de Extranjero
Parameters
string$strTIN to check
Returns
int<-4,3> 1 if NIF ok, 2 if CIF ok, 3 if NIE ok, -1 if NIF bad, -2 if CIF bad, -3 if NIE bad, -4 if unexpected bad
Since
Dolibarr V20

Definition at line 179 of file profid.lib.php.

Referenced by isValidProfIds().

◆ isValidTinForPT()

isValidTinForPT ( $str)

Check the syntax validity of a Portuguese (PT) Tax Identification Number (TIN).

(NIF = Número de Identificação Fiscal)

Parameters
string$strNIF to check
Returns
boolean True if valid, False otherwise
Since
Dolibarr V20

Definition at line 113 of file profid.lib.php.

Referenced by isValidProfIds().