Fix return code
This commit is contained in:
parent
77a0762fc1
commit
2cb190fc5c
@ -1163,7 +1163,7 @@ function get_string_between($string, $start, $end){
|
|||||||
*
|
*
|
||||||
* @param string $mask Mask to use
|
* @param string $mask Mask to use
|
||||||
* @param string $value Value
|
* @param string $value Value
|
||||||
* @return int <0 if KO, 0 if OK
|
* @return int|string <0 or error string if KO, 0 if OK
|
||||||
*/
|
*/
|
||||||
function check_value($mask,$value)
|
function check_value($mask,$value)
|
||||||
{
|
{
|
||||||
@ -1249,6 +1249,7 @@ function check_value($mask,$value)
|
|||||||
if (dol_strlen($value) != $len) $result=-1;
|
if (dol_strlen($value) != $len) $result=-1;
|
||||||
|
|
||||||
// Define $maskLike
|
// Define $maskLike
|
||||||
|
/* seems not used
|
||||||
$maskLike = dol_string_nospecial($mask);
|
$maskLike = dol_string_nospecial($mask);
|
||||||
$maskLike = str_replace("%","_",$maskLike);
|
$maskLike = str_replace("%","_",$maskLike);
|
||||||
// Replace protected special codes with matching number of _ as wild card caracter
|
// Replace protected special codes with matching number of _ as wild card caracter
|
||||||
@ -1259,7 +1260,7 @@ function check_value($mask,$value)
|
|||||||
$maskLike = str_replace(dol_string_nospecial('{dd}'),'__',$maskLike);
|
$maskLike = str_replace(dol_string_nospecial('{dd}'),'__',$maskLike);
|
||||||
$maskLike = str_replace(dol_string_nospecial('{'.$masktri.'}'),str_pad("",dol_strlen($maskcounter),"_"),$maskLike);
|
$maskLike = str_replace(dol_string_nospecial('{'.$masktri.'}'),str_pad("",dol_strlen($maskcounter),"_"),$maskLike);
|
||||||
if ($maskrefclient) $maskLike = str_replace(dol_string_nospecial('{'.$maskrefclient.'}'),str_pad("",strlen($maskrefclient),"_"),$maskLike);
|
if ($maskrefclient) $maskLike = str_replace(dol_string_nospecial('{'.$maskrefclient.'}'),str_pad("",strlen($maskrefclient),"_"),$maskLike);
|
||||||
|
*/
|
||||||
|
|
||||||
dol_syslog("functions2::check_value result=".$result,LOG_DEBUG);
|
dol_syslog("functions2::check_value result=".$result,LOG_DEBUG);
|
||||||
return $result;
|
return $result;
|
||||||
|
|||||||
@ -267,14 +267,14 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode
|
|||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
$res = 0;
|
$result = 0;
|
||||||
|
|
||||||
// Get Mask value
|
// Get Mask value
|
||||||
$mask = empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)?'':$conf->global->BARCODE_STANDARD_PRODUCT_MASK;
|
$mask = empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)?'':$conf->global->BARCODE_STANDARD_PRODUCT_MASK;
|
||||||
if (! $mask)
|
if (! $mask)
|
||||||
{
|
{
|
||||||
$this->error='NotConfigured';
|
$this->error='NotConfigured';
|
||||||
return '';
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
dol_syslog(get_class($this).'::verif_syntax codefortest='.$codefortest." typefortest=".$typefortest);
|
dol_syslog(get_class($this).'::verif_syntax codefortest='.$codefortest." typefortest=".$typefortest);
|
||||||
@ -292,6 +292,11 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode
|
|||||||
}
|
}
|
||||||
|
|
||||||
$result=check_value($mask,$newcodefortest);
|
$result=check_value($mask,$newcodefortest);
|
||||||
|
if (is_string($result))
|
||||||
|
{
|
||||||
|
$this->error = $result;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -229,6 +229,7 @@ class mod_codeproduct_elephant extends ModeleProductCode
|
|||||||
* -2 ErrorCustomerCodeRequired
|
* -2 ErrorCustomerCodeRequired
|
||||||
* -3 ErrorCustomerCodeAlreadyUsed
|
* -3 ErrorCustomerCodeAlreadyUsed
|
||||||
* -4 ErrorPrefixRequired
|
* -4 ErrorPrefixRequired
|
||||||
|
* -5 Other (see this->error)
|
||||||
*/
|
*/
|
||||||
function verif($db, &$code, $product, $type)
|
function verif($db, &$code, $product, $type)
|
||||||
{
|
{
|
||||||
@ -256,10 +257,15 @@ class mod_codeproduct_elephant extends ModeleProductCode
|
|||||||
if (! $mask)
|
if (! $mask)
|
||||||
{
|
{
|
||||||
$this->error='NotConfigured';
|
$this->error='NotConfigured';
|
||||||
return '';
|
return -5;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result=check_value($mask,$code);
|
$result=check_value($mask,$code);
|
||||||
|
if (is_string($result))
|
||||||
|
{
|
||||||
|
$this->error = $result;
|
||||||
|
return -5;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dol_syslog("mod_codeclient_elephant::verif type=".$type." result=".$result);
|
dol_syslog("mod_codeclient_elephant::verif type=".$type." result=".$result);
|
||||||
|
|||||||
@ -247,6 +247,7 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode
|
|||||||
* -2 ErrorCustomerCodeRequired
|
* -2 ErrorCustomerCodeRequired
|
||||||
* -3 ErrorCustomerCodeAlreadyUsed
|
* -3 ErrorCustomerCodeAlreadyUsed
|
||||||
* -4 ErrorPrefixRequired
|
* -4 ErrorPrefixRequired
|
||||||
|
* -5 Other (see this->error)
|
||||||
*/
|
*/
|
||||||
function verif($db, &$code, $soc, $type)
|
function verif($db, &$code, $soc, $type)
|
||||||
{
|
{
|
||||||
@ -274,10 +275,15 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode
|
|||||||
if (! $mask)
|
if (! $mask)
|
||||||
{
|
{
|
||||||
$this->error='NotConfigured';
|
$this->error='NotConfigured';
|
||||||
return '';
|
return -5;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result=check_value($mask,$code);
|
$result=check_value($mask,$code);
|
||||||
|
if (is_string($result))
|
||||||
|
{
|
||||||
|
$this->error = $result;
|
||||||
|
return -5;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dol_syslog("mod_codeclient_elephant::verif type=".$type." result=".$result);
|
dol_syslog("mod_codeclient_elephant::verif type=".$type." result=".$result);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user