NEW Factorize a lot of code for numbering modules

This commit is contained in:
Laurent Destailleur
2023-08-09 14:50:28 +02:00
parent 7bbaf37ffe
commit db2a70b86a
40 changed files with 147 additions and 3648 deletions

View File

@@ -22,6 +22,7 @@
* \brief File with parent classes for barcode document modules and numbering modules
*/
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/commonnumrefgenerator.class.php';
/**
@@ -50,50 +51,8 @@ abstract class ModeleBarCode
/**
* Parent class for barcode numbering models
*/
abstract class ModeleNumRefBarCode
abstract class ModeleNumRefBarCode extends CommonNumRefGenerator
{
/**
* @var string Version
*/
public $version = '';
/**
* @var string Error code (or message)
*/
public $error = '';
/** Return default description of numbering model
*
* @param Translate $langs Object langs
* @return string Descriptive text
*/
public function info($langs)
{
$langs->load("bills");
return $langs->trans("NoDescription");
}
/** Return model name
*
* @param Translate $langs Object langs
* @return string Model name
*/
public function getNom($langs)
{
return empty($this->name) ? get_class($this) : $this->name;
}
/** Return a numbering example
*
* @param Translate $langs Object langs
* @return string Example
*/
public function getExample($langs)
{
$langs->load("bills");
return $langs->trans("NoExample");
}
/**
* Return next value available
*
@@ -107,30 +66,6 @@ abstract class ModeleNumRefBarCode
return $langs->trans("Function_getNextValue_InModuleNotWorking");
}
/** Return version of module
*
* @return string Version
*/
public function getVersion()
{
global $langs;
$langs->load("admin");
if ($this->version == 'development') {
return $langs->trans("VersionDevelopment");
}
if ($this->version == 'experimental') {
return $langs->trans("VersionExperimental");
}
if ($this->version == 'dolibarr') {
return DOL_VERSION;
}
if ($this->version) {
return $this->version;
}
return $langs->trans("NotAvailable");
}
/**
* Return description of module parameters
*