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

@@ -30,6 +30,7 @@
*/
require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/commonnumrefgenerator.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // required for use by classes that inherit
require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
@@ -83,98 +84,7 @@ abstract class ModelePDFCommandes extends CommonDocGenerator
/**
* Parent class to manage numbering of Sale Orders
*/
abstract class ModeleNumRefCommandes
abstract class ModeleNumRefCommandes extends CommonNumRefGenerator
{
/**
* @var string Version
*/
public $version = '';
/**
* @var string Error code (or message)
*/
public $error = '';
/**
* Return if a module can be used or not
*
* @return boolean true if module can be used
*/
public function isEnabled()
{
return true;
}
/**
* Returns the default description of the numbering pattern
*
* @return string Descriptive text
*/
public function info()
{
global $langs;
$langs->load("orders");
return $langs->trans("NoDescription");
}
/**
* Renvoie un exemple de numerotation
*
* @return string Example
*/
public function getExample()
{
global $langs;
$langs->load("orders");
return $langs->trans("NoExample");
}
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
public function canBeActivated()
{
return true;
}
/**
* Returns next assigned value
*
* @param Societe $objsoc Object thirdparty
* @param Object $object Object we need next value for
* @return string Valeur
*/
public function getNextValue($objsoc, $object)
{
global $langs;
return $langs->trans("NotAvailable");
}
/**
* Returns version of numbering module
*
* @return string Valeur
*/
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");
}
// No overload code
}