Skip to content
Snippets Groups Projects
Commit 1683609d authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

FIX Check of EAN13 barcode when mask was set to use 13 digits instead of

12
parent 1ded08ab
No related branches found
No related tags found
No related merge requests found
......@@ -227,7 +227,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode
* Return if a code is used (by other element)
*
* @param DoliDB $db Handler acces base
* @param string $code Code a verifier
* @param string $code Code to check
* @param Product $product Objet product
* @return int 0 if available, <0 if KO
*/
......@@ -277,12 +277,20 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode
return '';
}
dol_syslog(get_class($this).'::verif_syntax codefortest='.$codefortest." typefortest=".$typefortest);
$newcodefortest=$codefortest;
// Special case, if mask is on 12 digits instead of 13, we remove last char into code to test
if (in_array($typefortest,array('EAN13','ISBN'))) // We remove the CRC char not included into mask
{
$newcodefortest=substr($newcodefortest,0,12);
if (preg_match('/\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}/i',$mask,$reg))
{
if (strlen($reg[1]) == 12) $newcodefortest=substr($newcodefortest,0,12);
dol_syslog(get_class($this).'::verif_syntax newcodefortest='.$newcodefortest);
}
}
$result=check_value($mask,$newcodefortest);
return $result;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment