--- /tmp/dsg/dolibarr/htdocs/core/modules/product/github_mod_codeproduct_elephant.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/product/client_mod_codeproduct_elephant.php @@ -55,9 +55,9 @@ public $code_null; // Code facultatif /** - * Dolibarr version of the loaded document - * @var string - */ + * Dolibarr version of the loaded document + * @var string + */ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' /** @@ -86,14 +86,14 @@ } - /** - * 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) + { global $conf, $mc; global $form; @@ -131,7 +131,7 @@ $texte .= ''; return $texte; - } + } /** @@ -142,7 +142,7 @@ * @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) + public function getExample($langs, $objproduct = 0, $type = -1) { if ($type == 0 || $type == -1) { @@ -207,11 +207,13 @@ { $field = 'ref'; //$where = ' AND client in (1,2)'; - } elseif ($type == 1) + } + elseif ($type == 1) { $field = 'ref'; //$where = ' AND fournisseur = 1'; - } else return -1; + } + else return -1; $now = dol_now(); @@ -226,7 +228,7 @@ } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Check if mask/numbering use prefix * @@ -234,7 +236,7 @@ */ public function verif_prefixIsUsed() { - // phpcs:enable + // phpcs:enable global $conf; $mask = $conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT; @@ -273,10 +275,13 @@ if (empty($code) && $this->code_null && empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) { $result = 0; - } elseif (empty($code) && (!$this->code_null || !empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED))) + } + elseif (empty($code) && (!$this->code_null || !empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED))) { $result = -2; - } else { + } + else + { // Get Mask value $mask = ''; if ($type == 0) $mask = empty($conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT) ? '' : $conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT; @@ -300,7 +305,7 @@ } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi si un code est pris ou non (par autre tiers) * @@ -311,9 +316,9 @@ */ public function verif_dispo($db, $code, $product) { - // phpcs:enable + // phpcs:enable $sql = "SELECT ref FROM ".MAIN_DB_PREFIX."product"; - $sql .= " WHERE ref = '".$db->escape($code)."'"; + $sql .= " WHERE ref = '".$code."'"; if ($product->id > 0) $sql .= " AND rowid <> ".$product->id; $resql = $db->query($sql); @@ -322,10 +327,14 @@ if ($db->num_rows($resql) == 0) { return 0; - } else { + } + else + { return -1; } - } else { + } + else + { return -2; } } --- /tmp/dsg/dolibarr/htdocs/core/modules/product/github_mod_codeproduct_leopard.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/product/client_mod_codeproduct_leopard.php @@ -60,9 +60,9 @@ public $code_null; // Code facultatif /** - * Dolibarr version of the loaded document - * @var string - */ + * Dolibarr version of the loaded document + * @var string + */ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' /** @@ -85,7 +85,7 @@ /** - * Return description of module + * Return description of module * * @param Translate $langs Object langs * @return string Description of module @@ -134,7 +134,8 @@ if (empty($code) && $this->code_null && empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) { $result = 0; - } elseif (empty($code) && (!$this->code_null || !empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED))) + } + elseif (empty($code) && (!$this->code_null || !empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED))) { $result = -2; } --- /tmp/dsg/dolibarr/htdocs/core/modules/product/github_modules_product.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/product/client_modules_product.class.php @@ -137,18 +137,10 @@ 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; - } + 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"); } @@ -167,15 +159,19 @@ $sql = ""; $resql = $db->query($sql); - if ($resql) { + if ($resql) + { $num = $db->num_rows($resql); $i = 0; - while ($i < $num) { + while ($i < $num) + { $row = $db->fetch_row($resql); $liste[$row[0]] = $row[1]; $i++; } - } else { + } + else + { return -1; } return $liste; @@ -194,37 +190,39 @@ global $conf; $langs->load("admin"); - $strikestart = ''; - $strikeend = ''; - if (!empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && !empty($this->code_null)) { - $strikestart = ''; - $strikeend = ' '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')'; - } + $s = ''; if ($type == -1) { $s .= $langs->trans("Name").': '.$this->getNom($langs).'
'; $s .= $langs->trans("Version").': '.$this->getVersion().'
'; - } 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).'
'; $s .= '
'; $s .= ''.$langs->trans("ThisIsModuleRules").':
'; - 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")).')'; $s .= '
'; - } 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")).')'; $s .= '
'; - } 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")).')'; $s .= '
'; } $s .= $langs->trans("CanBeModifiedIfOk").': '; @@ -233,18 +231,16 @@ $s .= $langs->trans("CanBeModifiedIfKo").': '.yn($this->code_modifiable_invalide, 1, 2).'
'; $s .= $langs->trans("AutomaticCode").': '.yn($this->code_auto, 1, 2).'
'; $s .= '
'; - if ($type == 0 || $type == -1) { + if ($type == 0 || $type == -1) + { $nextval = $this->getNextValue($product, 0); - if (empty($nextval)) { - $nextval = $langs->trans("Undefined"); - } + if (empty($nextval)) $nextval = $langs->trans("Undefined"); $s .= $langs->trans("NextValue").($type == -1 ? ' ('.$langs->trans("Product").')' : '').': '.$nextval.'
'; } - if ($type == 1 || $type == -1) { + if ($type == 1 || $type == -1) + { $nextval = $this->getNextValue($product, 1); - if (empty($nextval)) { - $nextval = $langs->trans("Undefined"); - } + if (empty($nextval)) $nextval = $langs->trans("Undefined"); $s .= $langs->trans("NextValue").($type == -1 ? ' ('.$langs->trans("Service").')' : '').': '.$nextval.''; } return $s;