fix mod barcode product

This commit is contained in:
Frédéric France 2024-03-12 18:49:29 +01:00
parent 0e209ea702
commit fc732b1be5
4 changed files with 28 additions and 38 deletions

View file

@ -109,10 +109,10 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode
* Return an example of result returned by getNextValue
*
* @param Translate $langs Object langs
* @param Product $objproduct Object product
* @param ?Product $objproduct Object product
* @return string Return string example
*/
public function getExample($langs, $objproduct = 0)
public function getExample($langs, $objproduct = null)
{
$examplebarcode = $this->getNextValue($objproduct, '');
if (!$examplebarcode) {
@ -155,18 +155,19 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode
return $out;
}
/**
* Return next value
*
* @param CommonObject $objproduct Object product
* @param string $type Type of barcode (EAN, ISBN, ...)
* @return string Value if OK, '' if module not configured, <0 if KO
* @param ?CommonObject $objproduct Object product (not used)
* @param string $type Type of barcode (EAN, ISBN, ...)
* @return string Value if OK, '' if module not configured, <0 if KO
*/
public function getNextValue($objproduct, $type = '')
public function getNextValue($objproduct = null, $type = '')
{
global $db, $conf;
global $db;
if (!$objproduct instanceof Product) {
if (is_object($objproduct) && !$objproduct instanceof Product) {
dol_syslog(get_class($this)."::getNextValue used on incompatible".get_class($objproduct), LOG_ERR);
return -1;
}
@ -178,13 +179,8 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode
$type = getDolGlobalString('PRODUIT_DEFAULT_BARCODE_TYPE');
} //get barcode type configuration for products if $type not set
// TODO
// Get Mask value
$mask = '';
if (getDolGlobalString('BARCODE_STANDARD_PRODUCT_MASK')) {
$mask = getDolGlobalString('BARCODE_STANDARD_PRODUCT_MASK');
}
$mask = getDolGlobalString('BARCODE_STANDARD_PRODUCT_MASK');
if (empty($mask)) {
$this->error = 'NotConfigured';
@ -216,7 +212,8 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode
}
}
//End barcode with key
return $numFinal;
return $numFinal;
}

View file

@ -72,10 +72,11 @@ class mod_barcode_thirdparty_standard extends ModeleNumRefBarCode
}
/** Return description of module
/**
* Return description of module
*
* @param Translate $langs Object langs
* @return string Description of module
* @param Translate $langs Object langs
* @return string Description of module
*/
public function info($langs)
{
@ -120,10 +121,10 @@ class mod_barcode_thirdparty_standard extends ModeleNumRefBarCode
* Return an example of result returned by getNextValue
*
* @param Translate $langs Object langs
* @param Societe $objthirdparty Object third-party
* @param ?Societe $objthirdparty Object third-party
* @return string Return string example
*/
public function getExample($langs, $objthirdparty = 0)
public function getExample($langs, $objthirdparty = null)
{
$examplebarcode = $this->getNextValue($objthirdparty, '');
if (!$examplebarcode) {
@ -169,13 +170,13 @@ class mod_barcode_thirdparty_standard extends ModeleNumRefBarCode
/**
* Return next value
*
* @param CommonObject $objthirdparty Object third-party
* @param ?CommonObject $objthirdparty Object third-party
* @param string $type Type of barcode (EAN, ISBN, ...)
* @return string Value if OK, '' if module not configured, <0 if KO
*/
public function getNextValue($objthirdparty, $type = '')
public function getNextValue($objthirdparty = null, $type = '')
{
global $db, $conf;
global $db;
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/barcode.lib.php'; // to be able to call function barcode_gen_ean_sum($ean)
@ -184,13 +185,8 @@ class mod_barcode_thirdparty_standard extends ModeleNumRefBarCode
$type = getDolGlobalString('GENBARCODE_BARCODETYPE_THIRDPARTY');
} //get barcode type configuration for companies if $type not set
// TODO
// Get Mask value
$mask = '';
if (getDolGlobalString('BARCODE_STANDARD_THIRDPARTY_MASK')) {
$mask = getDolGlobalString('BARCODE_STANDARD_THIRDPARTY_MASK');
}
$mask = getDolGlobalString('BARCODE_STANDARD_THIRDPARTY_MASK');
if (empty($mask)) {
$this->error = 'NotConfigured';
@ -222,6 +218,7 @@ class mod_barcode_thirdparty_standard extends ModeleNumRefBarCode
}
}
//End barcode with key
return $numFinal;
}
@ -242,10 +239,6 @@ class mod_barcode_thirdparty_standard extends ModeleNumRefBarCode
*/
public function verif($db, &$code, $thirdparty, $thirdparty_type, $type)
{
global $conf;
//var_dump($code.' '.$thirdparty->ref.' '.$thirdparty_type);exit;
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$result = 0;
@ -273,6 +266,7 @@ class mod_barcode_thirdparty_standard extends ModeleNumRefBarCode
}
dol_syslog(get_class($this)."::verif type=".$thirdparty_type." result=".$result);
return $result;
}

View file

@ -62,11 +62,11 @@ abstract class ModeleNumRefBarCode extends CommonNumRefGenerator
/**
* Return next value available
*
* @param CommonObject $objcommon Object Product, Thirdparty
* @param string $type Type of barcode (EAN, ISBN, ...)
* @return string Value
* @param ?CommonObject $objcommon Object Product, Thirdparty
* @param string $type Type of barcode (EAN, ISBN, ...)
* @return string Value
*/
public function getNextValue($objcommon, $type = '')
public function getNextValue($objcommon = null, $type = '')
{
global $langs;
return $langs->trans("Function_getNextValue_InModuleNotWorking");

View file

@ -54,7 +54,6 @@ parameters:
- '#(\$force_dolibarr_lib|\$dolibarr_main_db).*in empty\(\) is never defined.#'
- '#Sprain\\SwissQrBill\\#'
- '#Constructor of class .* has an unused parameter #'
- '#Default value of the parameter#'
internalErrorsCountLimit: 50
cache:
nodesByFileCountMax: 512