--- /tmp/dsg/dolibarr/htdocs/core/modules/product/github_19.0.3_mod_codeproduct_elephant.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/product/client_mod_codeproduct_elephant.php
@@ -32 +32,2 @@
- * Class to manage product code with elephant rule
+ * \class mod_codeproduct_elephant
+ * \brief Class to manage product code with elephant rule
@@ -57,3 +58,3 @@
- * Dolibarr version of the loaded document
- * @var string
- */
+ * Dolibarr version of the loaded document
+ * @var string
+ */
@@ -88,8 +89,8 @@
- /**
- * Return description of module
- *
- * @param Translate $langs Object langs
- * @return string Description of module
- */
- public function info($langs)
- {
+ /**
+ * Return description of module
+ *
+ * @param Translate $langs Object langs
+ * @return string Description of module
+ */
+ public function info($langs)
+ {
@@ -106 +106,0 @@
- $texte .= '';
@@ -119,3 +119,3 @@
- $texte .= '
'.$form->textwithpicto('', $tooltip, 1, 1).' | ';
-
- $texte .= ' | ';
+ $texte .= ''.$form->textwithpicto('', $tooltip, 1, 1).' | ';
+
+ $texte .= ' | ';
@@ -127 +127 @@
- $texte .= ''.$form->textwithpicto('', $tooltip, 1, 1).' | ';
+ $texte .= ''.$form->textwithpicto('', $tooltip, 1, 1).' | ';
@@ -134 +134 @@
- }
+ }
@@ -141 +141 @@
- * @param Product $objproduct Object product
+ * @param product $objproduct Object product
@@ -145,5 +145,4 @@
- public function getExample($langs, $objproduct = 0, $type = -1)
- {
- $exampleproduct = $exampleservice = '';
-
- if ($type == 0 || $type == -1) {
+ public function getExample($langs, $objproduct = 0, $type = -1)
+ {
+ if ($type == 0 || $type == -1)
+ {
@@ -151 +150,2 @@
- if (!$exampleproduct) {
+ if (!$exampleproduct)
+ {
@@ -154 +154,2 @@
- if ($exampleproduct == "ErrorBadMask") {
+ if ($exampleproduct == "ErrorBadMask")
+ {
@@ -159 +160,2 @@
- if ($type == 1 || $type == -1) {
+ if ($type == 1 || $type == -1)
+ {
@@ -161 +163,2 @@
- if (!$exampleservice) {
+ if (!$exampleservice)
+ {
@@ -164 +167,2 @@
- if ($exampleservice == "ErrorBadMask") {
+ if ($exampleservice == "ErrorBadMask")
+ {
@@ -170,6 +174,2 @@
- if ($type == 0) {
- return $exampleproduct;
- }
- if ($type == 1) {
- return $exampleservice;
- }
+ if ($type == 0) return $exampleproduct;
+ if ($type == 1) return $exampleservice;
@@ -194 +194 @@
- if ($type == 0 && getDolGlobalString('PRODUCT_ELEPHANT_MASK_PRODUCT')) {
+ if ($type == 0 && !empty($conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT))
@@ -196 +196 @@
- } elseif ($type == 1 && getDolGlobalString('PRODUCT_ELEPHANT_MASK_SERVICE')) {
+ elseif ($type == 1 && !empty($conf->global->PRODUCT_ELEPHANT_MASK_SERVICE))
@@ -198,3 +198,3 @@
- }
-
- if (empty($mask)) {
+
+ if (empty($mask))
+ {
@@ -205,3 +205,3 @@
- $field = '';
- $where = '';
- if ($type == 0) {
+ $field = ''; $where = '';
+ if ($type == 0)
+ {
@@ -210 +210,3 @@
- } elseif ($type == 1) {
+ }
+ elseif ($type == 1)
+ {
@@ -213,3 +215,2 @@
- } else {
- return -1;
- }
+ }
+ else return -1;
@@ -219 +220,2 @@
- if (getDolGlobalString('PRODUCT_ELEPHANT_ADD_WHERE')) {
+ if (!empty($conf->global->PRODUCT_ELEPHANT_ADD_WHERE))
+ {
@@ -229 +231 @@
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
@@ -237 +239 @@
- // phpcs:enable
+ // phpcs:enable
@@ -241,3 +243 @@
- if (preg_match('/\{pre\}/i', $mask)) {
- return 1;
- }
+ if (preg_match('/\{pre\}/i', $mask)) return 1;
@@ -246,3 +246 @@
- if (preg_match('/\{pre\}/i', $mask)) {
- return 1;
- }
+ if (preg_match('/\{pre\}/i', $mask)) return 1;
@@ -277 +275,2 @@
- if (empty($code) && $this->code_null && !getDolGlobalString('MAIN_COMPANY_CODE_ALWAYS_REQUIRED')) {
+ if (empty($code) && $this->code_null && empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED))
+ {
@@ -279 +278,3 @@
- } elseif (empty($code) && (!$this->code_null || getDolGlobalString('MAIN_COMPANY_CODE_ALWAYS_REQUIRED'))) {
+ }
+ elseif (empty($code) && (!$this->code_null || !empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)))
+ {
@@ -281 +282,3 @@
- } else {
+ }
+ else
+ {
@@ -284,7 +287,4 @@
- if ($type == 0) {
- $mask = !getDolGlobalString('PRODUCT_ELEPHANT_MASK_PRODUCT') ? '' : $conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT;
- }
- if ($type == 1) {
- $mask = !getDolGlobalString('PRODUCT_ELEPHANT_MASK_SERVICE') ? '' : $conf->global->PRODUCT_ELEPHANT_MASK_SERVICE;
- }
- if (!$mask) {
+ if ($type == 0) $mask = empty($conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT) ? '' : $conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT;
+ if ($type == 1) $mask = empty($conf->global->PRODUCT_ELEPHANT_MASK_SERVICE) ? '' : $conf->global->PRODUCT_ELEPHANT_MASK_SERVICE;
+ if (!$mask)
+ {
@@ -296 +296,2 @@
- if (is_string($result)) {
+ if (is_string($result))
+ {
@@ -307 +308 @@
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
@@ -318 +319 @@
- // phpcs:enable
+ // phpcs:enable
@@ -320,4 +321,2 @@
- $sql .= " WHERE ref = '".$db->escape($code)."'";
- if ($product->id > 0) {
- $sql .= " AND rowid <> ".$product->id;
- }
+ $sql .= " WHERE ref = '".$code."'";
+ if ($product->id > 0) $sql .= " AND rowid <> ".$product->id;
@@ -326,2 +325,4 @@
- if ($resql) {
- if ($db->num_rows($resql) == 0) {
+ if ($resql)
+ {
+ if ($db->num_rows($resql) == 0)
+ {
@@ -329 +330,3 @@
- } else {
+ }
+ else
+ {
@@ -332 +335,3 @@
- } else {
+ }
+ else
+ {
--- /tmp/dsg/dolibarr/htdocs/core/modules/product/github_19.0.3_mod_codeproduct_leopard.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/product/client_mod_codeproduct_leopard.php
@@ -36 +36,2 @@
- * Please note this module is used by default if no module has been defined in the configuration
+ * Attention ce module est utilise par defaut si aucun module n'a
+ * ete definit dans la configuration
@@ -38 +39 @@
- * Its operation must therefore remain as open as possible
+ * Le fonctionnement de celui-ci doit donc rester le plus ouvert possible
@@ -62,3 +63,3 @@
- * Dolibarr version of the loaded document
- * @var string
- */
+ * Dolibarr version of the loaded document
+ * @var string
+ */
@@ -87 +88 @@
- * Return description of module
+ * Return description of module
@@ -98,12 +98,0 @@
- /**
- * Return an example of result returned by getNextValue
- *
- * @param Translate $langs Object langs
- * @param Product $objproduct Object product
- * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect)
- * @return string Return string example
- */
- public function getExample($langs, $objproduct = 0, $type = -1)
- {
- return '';
- }
@@ -114 +103 @@
- * @param Product $objproduct Object product
+ * @param product $objproduct Object product
@@ -119,0 +109 @@
+ global $langs;
@@ -144 +134,2 @@
- if (empty($code) && $this->code_null && !getDolGlobalString('MAIN_COMPANY_CODE_ALWAYS_REQUIRED')) {
+ if (empty($code) && $this->code_null && empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED))
+ {
@@ -146 +137,3 @@
- } elseif (empty($code) && (!$this->code_null || getDolGlobalString('MAIN_COMPANY_CODE_ALWAYS_REQUIRED'))) {
+ }
+ elseif (empty($code) && (!$this->code_null || !empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)))
+ {
--- /tmp/dsg/dolibarr/htdocs/core/modules/product/github_19.0.3_modules_product.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/product/client_modules_product.class.php
@@ -29,3 +29 @@
-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.'/core/class/commondocgenerator.class.php';
@@ -37,0 +36,6 @@
+ /**
+ * @var string Error code (or message)
+ */
+ public $error = '';
+
+
@@ -42 +46 @@
- * @param DoliDB $dbs Database handler
+ * @param DoliDB $db Database handler
@@ -46 +50 @@
- public static function liste_modeles($dbs, $maxfilenamelength = 0)
+ public static function liste_modeles($db, $maxfilenamelength = 0)
@@ -48,0 +53,2 @@
+ global $conf;
+
@@ -50 +56 @@
- $list = array();
+ $liste = array();
@@ -53,2 +59,2 @@
- $list = getListOfModels($dbs, $type, $maxfilenamelength);
- return $list;
+ $liste = getListOfModels($db, $type, $maxfilenamelength);
+ return $liste;
@@ -61 +67 @@
-abstract class ModeleProductCode extends CommonNumRefGenerator
+abstract class ModeleProductCode
@@ -64,16 +70,46 @@
- * @var int Automatic numbering
- */
- public $code_auto;
-
- /**
- * @var string Editable code
- */
- public $code_modifiable;
-
- public $code_modifiable_invalide; // Modified code if it is invalid
-
- /**
- * @var int Code facultatif
- */
- public $code_null;
-
+ * @var string Error code (or message)
+ */
+ public $error = '';
+
+ /** Renvoi la description par defaut du modele de numerotation
+ *
+ * @param Translate $langs Object langs
+ * @return string Texte descripif
+ */
+ public function info($langs)
+ {
+ $langs->load("bills");
+ return $langs->trans("NoDescription");
+ }
+
+ /** Renvoi nom module
+ *
+ * @param Translate $langs Object langs
+ * @return string Nom du module
+ */
+ public function getNom($langs)
+ {
+ return empty($this->name) ? $this->nom : $this->name;
+ }
+
+
+ /** Return an example of numbering
+ *
+ * @param Translate $langs Object langs
+ * @return string Example
+ */
+ public function getExample($langs)
+ {
+ 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;
+ }
@@ -93,0 +130,17 @@
+
+ /** 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");
+ }
+
@@ -98 +151 @@
- * @param DoliDB $dbs Database handler
+ * @param DoliDB $db Database handler
@@ -100,3 +153,3 @@
- * @return array|int List of numbers
- */
- public static function liste_modeles($dbs, $maxfilenamelength = 0)
+ * @return array List of numbers
+ */
+ public static function liste_modeles($db, $maxfilenamelength = 0)
@@ -105 +158 @@
- $list = array();
+ $liste = array();
@@ -108,3 +161,4 @@
- $resql = $dbs->query($sql);
- if ($resql) {
- $num = $dbs->num_rows($resql);
+ $resql = $db->query($sql);
+ if ($resql)
+ {
+ $num = $db->num_rows($resql);
@@ -112,3 +166,4 @@
- while ($i < $num) {
- $row = $dbs->fetch_row($resql);
- $list[$row[0]] = $row[1];
+ while ($i < $num)
+ {
+ $row = $db->fetch_row($resql);
+ $liste[$row[0]] = $row[1];
@@ -117 +172,3 @@
- } else {
+ }
+ else
+ {
@@ -120 +177 @@
- return $list;
+ return $liste;
@@ -135,8 +192,2 @@
- $langs->loadLangs(array("admin", "companies"));
-
- $strikestart = '';
- $strikeend = '';
- if (getDolGlobalString('MAIN_COMPANY_CODE_ALWAYS_REQUIRED') && !empty($this->code_null)) {
- $strikestart = '';
- $strikeend = ' '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
- }
+ $langs->load("admin");
+
@@ -147,8 +198,4 @@
- } elseif ($type == 0) {
- $s .= $langs->trans("ProductCodeDesc").'
';
- } elseif ($type == 1) {
- $s .= $langs->trans("ServiceCodeDesc").'
';
- }
- if ($type != -1) {
- $s .= $langs->trans("ValidityControledByModule").': '.$this->getNom($langs).'
';
- }
+ }
+ if ($type == 0) $s .= $langs->trans("ProductCodeDesc").'
';
+ if ($type == 1) $s .= $langs->trans("ServiceCodeDesc").'
';
+ if ($type != -1) $s .= $langs->trans("ValidityControledByModule").': '.$this->getNom($langs).'
';
@@ -157,3 +204,6 @@
- if ($type == 0) {
- $s .= $langs->trans("RequiredIfProduct").': '.$strikestart;
- $s .= yn(!$this->code_null, 1, 2).$strikeend;
+ if ($type == 0)
+ {
+ $s .= $langs->trans("RequiredIfProduct").': ';
+ if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '';
+ $s .= yn(!$this->code_null, 1, 2);
+ if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= ' '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
@@ -161,3 +211,7 @@
- } elseif ($type == 1) {
- $s .= $langs->trans("RequiredIfService").': '.$strikestart;
- $s .= yn(!$this->code_null, 1, 2).$strikeend;
+ }
+ elseif ($type == 1)
+ {
+ $s .= $langs->trans("RequiredIfService").': ';
+ if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '';
+ $s .= yn(!$this->code_null, 1, 2);
+ if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= ' '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
@@ -165,3 +219,7 @@
- } elseif ($type == -1) {
- $s .= $langs->trans("Required").': '.$strikestart;
- $s .= yn(!$this->code_null, 1, 2).$strikeend;
+ }
+ elseif ($type == -1)
+ {
+ $s .= $langs->trans("Required").': ';
+ if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= '';
+ $s .= yn(!$this->code_null, 1, 2);
+ if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) $s .= ' '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
@@ -176 +234,2 @@
- if ($type == 0 || $type == -1) {
+ if ($type == 0 || $type == -1)
+ {
@@ -178,3 +237 @@
- if (empty($nextval)) {
- $nextval = $langs->trans("Undefined");
- }
+ if (empty($nextval)) $nextval = $langs->trans("Undefined");
@@ -183 +240,2 @@
- if ($type == 1 || $type == -1) {
+ if ($type == 1 || $type == -1)
+ {
@@ -185,3 +243 @@
- if (empty($nextval)) {
- $nextval = $langs->trans("Undefined");
- }
+ if (empty($nextval)) $nextval = $langs->trans("Undefined");