--- /tmp/dsg/dolibarr/htdocs/core/modules/societe/github_19.0.3_mod_codeclient_elephant.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/societe/client_mod_codeclient_elephant.php @@ -7 +6,0 @@ - * Copyright (C) 2020 Frédéric France @@ -43,24 +42,12 @@ - /** - * @var int Code modifiable - */ - public $code_modifiable; - - /** - * @var int Code modifiable si il est invalide - */ - public $code_modifiable_invalide; - - /** - * @var int Code modifiables si il est null - */ - public $code_modifiable_null; - - /** - * @var int Code facultatif - */ - public $code_null; - - /** - * Dolibarr version of the loaded document - * @var string - */ + public $code_modifiable; // Code modifiable + + public $code_modifiable_invalide; // Code modifiable si il est invalide + + public $code_modifiable_null; // Code modifiables si il est null + + public $code_null; // Code facultatif + + /** + * Dolibarr version of the loaded document + * @var string + */ @@ -74,14 +61,5 @@ - /** - * @var string search string - */ - public $searchcode; - - /** - * @var int Nombre de chiffres du compteur - */ - public $numbitcounter; - - /** - * @var int thirdparty prefix is required when using {pre} - */ - public $prefixIsRequired; + public $searchcode; // String de recherche + + public $numbitcounter; // Nombre de chiffres du compteur + + public $prefixIsRequired; // Le champ prefix du tiers doit etre renseigne quand on utilise {pre} @@ -105 +83 @@ - * Return description of module + * Return description of module @@ -122 +99,0 @@ - $texte .= ''; @@ -136,3 +113,3 @@ - $texte .= ''.$form->textwithpicto('', $tooltip, 1, 1).''; - - $texte .= '  '; + $texte .= ''.$form->textwithpicto('', $tooltip, 1, 1).''; + + $texte .= '  '; @@ -144 +121 @@ - $texte .= ''.$form->textwithpicto('', $tooltip, 1, 1).''; + $texte .= ''.$form->textwithpicto('', $tooltip, 1, 1).''; @@ -164,15 +141,2 @@ - $error = 0; - $examplecust = ''; - $examplesup = ''; - $errmsg = array( - "ErrorBadMask", - "ErrorCantUseRazIfNoYearInMask", - "ErrorCantUseRazInStartedYearIfNoYearMonthInMask", - "ErrorCounterMustHaveMoreThan3Digits", - "ErrorBadMaskBadRazMonth", - "ErrorCantUseRazWithYearOnOneDigit", - ); - - $cssforerror = (getDolGlobalString('SOCIETE_CODECLIENT_ADDON') == 'mod_codeclient_elephant' ? 'error' : 'opacitymedium'); - - if ($type != 1) { + if ($type == 0 || $type == -1) + { @@ -180,12 +144,22 @@ - if (!$examplecust && ($cssforerror == 'error' || $this->error != 'NotConfigured')) { - $langs->load("errors"); - $examplecust = ''.$langs->trans('ErrorBadMask').''; - $error = 1; - } - if (in_array($examplecust, $errmsg)) { - $langs->load("errors"); - $examplecust = ''.$langs->trans($examplecust).''; - $error = 1; - } - } - if ($type != 0) { + if (!$examplecust) + { + $examplecust = $langs->trans('NotConfigured'); + } + if ($examplecust == "ErrorBadMask") + { + $langs->load("errors"); + $examplecust = $langs->trans($examplecust); + } + if ($examplecust == "ErrorCantUseRazIfNoYearInMask") + { + $langs->load("errors"); + $examplecust = $langs->trans($examplecust); + } + if ($examplecust == "ErrorCantUseRazInStartedYearIfNoYearMonthInMask") + { + $langs->load("errors"); + $examplecust = $langs->trans($examplecust); + } + } + if ($type == 1 || $type == -1) + { @@ -193,19 +167,24 @@ - if (!$examplesup && ($cssforerror == 'error' || $this->error != 'NotConfigured')) { - $langs->load("errors"); - $examplesup = ''.$langs->trans('ErrorBadMask').''; - $error = 1; - } - if (in_array($examplesup, $errmsg)) { - $langs->load("errors"); - $examplesup = ''.$langs->trans($examplesup).''; - $error = 1; - } - } - - if ($type == 0) { - return $examplecust; - } elseif ($type == 1) { - return $examplesup; - } else { - return $examplecust.'
'.$examplesup; - } + if (!$examplesup) + { + $examplesup = $langs->trans('NotConfigured'); + } + if ($examplesup == "ErrorBadMask") + { + $langs->load("errors"); + $examplesup = $langs->trans($examplesup); + } + if ($examplesup == "ErrorCantUseRazIfNoYearInMask") + { + $langs->load("errors"); + $examplesup = $langs->trans($examplesup); + } + if ($examplesup == "ErrorCantUseRazInStartedYearIfNoYearMonthInMask") + { + $langs->load("errors"); + $examplesup = $langs->trans($examplesup); + } + } + + if ($type == 0) return $examplecust; + if ($type == 1) return $examplesup; + return $examplecust.'
'.$examplesup; @@ -229,7 +208,4 @@ - if ($type == 0) { - $mask = !getDolGlobalString('COMPANY_ELEPHANT_MASK_CUSTOMER') ? '' : $conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER; - } - if ($type == 1) { - $mask = !getDolGlobalString('COMPANY_ELEPHANT_MASK_SUPPLIER') ? '' : $conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER; - } - if (!$mask) { + if ($type == 0) $mask = $conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER; + if ($type == 1) $mask = $conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER; + if (!$mask) + { @@ -240,3 +216,3 @@ - $field = ''; - $where = ''; - if ($type == 0) { + $field = ''; $where = ''; + if ($type == 0) + { @@ -245 +221,3 @@ - } elseif ($type == 1) { + } + elseif ($type == 1) + { @@ -248,3 +226,2 @@ - } else { - return -1; - } + } + else return -1; @@ -260 +237 @@ - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -268 +245 @@ - // phpcs:enable + // phpcs:enable @@ -272,3 +249 @@ - if (preg_match('/\{pre\}/i', $mask)) { - return 1; - } + if (preg_match('/\{pre\}/i', $mask)) return 1; @@ -277,3 +252 @@ - if (preg_match('/\{pre\}/i', $mask)) { - return 1; - } + if (preg_match('/\{pre\}/i', $mask)) return 1; @@ -297,2 +270 @@ - * -5 NotConfigured - Setup empty so any value may be ok or not - * -6 Other (see this->error) + * -5 Other (see this->error) @@ -309 +281,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)) + { @@ -311 +284,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))) + { @@ -313 +288,3 @@ - } else { + } + else + { @@ -316,7 +293,4 @@ - if ($type == 0) { - $mask = !getDolGlobalString('COMPANY_ELEPHANT_MASK_CUSTOMER') ? '' : $conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER; - } - if ($type == 1) { - $mask = !getDolGlobalString('COMPANY_ELEPHANT_MASK_SUPPLIER') ? '' : $conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER; - } - if (!$mask) { + if ($type == 0) $mask = empty($conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER) ? '' : $conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER; + if ($type == 1) $mask = empty($conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER) ? '' : $conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER; + if (!$mask) + { @@ -325,0 +300 @@ + @@ -327 +302,2 @@ - if (is_string($result)) { + if (is_string($result)) + { @@ -329,6 +305 @@ - return -6; - } else { - $is_dispo = $this->verif_dispo($db, $code, $soc, $type); - if ($is_dispo != 0) { - $result = -3; - } + return -5; @@ -343 +314 @@ - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -355 +326 @@ - // phpcs:enable + // phpcs:enable @@ -357,9 +328,3 @@ - if ($type == 1) { - $sql .= " WHERE code_fournisseur = '".$db->escape($code)."'"; - } else { - $sql .= " WHERE code_client = '".$db->escape($code)."'"; - } - if ($soc->id > 0) { - $sql .= " AND rowid <> ".$soc->id; - } - $sql .= " AND entity IN (".getEntity('societe').")"; + if ($type == 1) $sql .= " WHERE code_fournisseur = '".$code."'"; + else $sql .= " WHERE code_client = '".$code."'"; + if ($soc->id > 0) $sql .= " AND rowid <> ".$soc->id; @@ -368,2 +333,4 @@ - if ($resql) { - if ($db->num_rows($resql) == 0) { + if ($resql) + { + if ($db->num_rows($resql) == 0) + { @@ -371 +338,3 @@ - } else { + } + else + { @@ -374 +343,3 @@ - } else { + } + else + { --- /tmp/dsg/dolibarr/htdocs/core/modules/societe/github_19.0.3_mod_codeclient_leopard.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/societe/client_mod_codeclient_leopard.php @@ -55,3 +55,3 @@ - * Dolibarr version of the loaded document - * @var string - */ + * Dolibarr version of the loaded document + * @var string + */ @@ -80 +80 @@ - * Return description of module + * Return description of module @@ -91,12 +90,0 @@ - /** - * Return an example of result returned by getNextValue - * - * @param Translate $langs Object langs - * @param societe $objsoc Object thirdparty - * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) - * @return string Return string example - */ - public function getExample($langs, $objsoc = 0, $type = -1) - { - return ''; - } @@ -138 +126,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)) + { @@ -140 +129,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/societe/github_19.0.3_mod_codeclient_monkey.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/societe/client_mod_codeclient_monkey.php @@ -49,3 +49,3 @@ - * Dolibarr version of the loaded document - * @var string - */ + * Dolibarr version of the loaded document + * @var string + */ @@ -70,0 +71,3 @@ + $this->nom = "Monkey"; + $this->name = "Monkey"; + $this->version = "dolibarr"; @@ -81 +84 @@ - * Return description of module + * Return description of module @@ -118 +121 @@ - $prefix = ''; + $prefix = ''; @@ -121 +124 @@ - $prefix = $this->prefixcustomer; + $prefix = $this->prefixcustomer; @@ -124 +127 @@ - $prefix = $this->prefixsupplier; + $prefix = $this->prefixsupplier; @@ -125,0 +129,21 @@ + return -1; + } + + // First, we get the max value (reponse immediate car champ indexe) + $posindice = strlen($prefix) + 6; + $sql = "SELECT MAX(CAST(SUBSTRING(".$field." FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL + $sql .= " FROM ".MAIN_DB_PREFIX."societe"; + $sql .= " WHERE ".$field." LIKE '".$prefix."____-%'"; + $sql .= " AND entity IN (".getEntity('societe').")"; + + dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); + + $resql = $db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + if ($obj) $max = intval($obj->max); + else $max = 0; + } + else + { @@ -129,21 +152,0 @@ - // First, we get the max value (reponse immediate car champ indexe) - $posindice = strlen($prefix) + 6; - $sql = "SELECT MAX(CAST(SUBSTRING(".$field." FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL - $sql .= " FROM ".MAIN_DB_PREFIX."societe"; - $sql .= " WHERE ".$field." LIKE '".$db->escape($prefix)."____-%'"; - $sql .= " AND entity IN (".getEntity('societe').")"; - - dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); - - $resql = $db->query($sql); - if ($resql) { - $obj = $db->fetch_object($resql); - if ($obj) { - $max = intval($obj->max); - } else { - $max = 0; - } - } else { - return -1; - } - @@ -151,7 +154,4 @@ - $yymm = dol_print_date($date, "%y%m", 'tzuserrel'); - - if ($max >= (pow(10, 5) - 1)) { - $num = $max + 1; // If counter > 99999, we do not format on 5 chars, we take number as it is - } else { - $num = sprintf("%05s", $max + 1); - } + $yymm = strftime("%y%m", $date); + + if ($max >= (pow(10, 5) - 1)) $num = $max + 1; // If counter > 99999, we do not format on 5 chars, we take number as it is + else $num = sprintf("%05s", $max + 1); @@ -184 +184,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)) + { @@ -186 +187,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))) + { @@ -188,2 +191,5 @@ - } else { - if ($this->verif_syntax($code) >= 0) { + } + else + { + if ($this->verif_syntax($code) >= 0) + { @@ -191 +197,2 @@ - if ($is_dispo != 0) { + if ($is_dispo <> 0) + { @@ -193 +200,3 @@ - } else { + } + else + { @@ -196,2 +205,5 @@ - } else { - if (dol_strlen($code) == 0) { + } + else + { + if (dol_strlen($code) == 0) + { @@ -199 +211,3 @@ - } else { + } + else + { @@ -210 +224 @@ - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -222 +236 @@ - // phpcs:enable + // phpcs:enable @@ -226,5 +240,2 @@ - if ($type == 1) { - $sql .= " WHERE code_fournisseur = '".$db->escape($code)."'"; - } else { - $sql .= " WHERE code_client = '".$db->escape($code)."'"; - } + if ($type == 1) $sql .= " WHERE code_fournisseur = '".$code."'"; + else $sql .= " WHERE code_client = '".$code."'"; @@ -232,3 +243 @@ - if ($soc->id > 0) { - $sql .= " AND rowid <> ".$soc->id; - } + if ($soc->id > 0) $sql .= " AND rowid <> ".$soc->id; @@ -238,2 +247,4 @@ - if ($resql) { - if ($db->num_rows($resql) == 0) { + if ($resql) + { + if ($db->num_rows($resql) == 0) + { @@ -241 +252,3 @@ - } else { + } + else + { @@ -244 +257,3 @@ - } else { + } + else + { @@ -250 +265 @@ - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -259 +274 @@ - // phpcs:enable + // phpcs:enable @@ -262 +277,2 @@ - if (dol_strlen($code) < 11) { + if (dol_strlen($code) < 11) + { @@ -264 +280,3 @@ - } else { + } + else + { --- /tmp/dsg/dolibarr/htdocs/core/modules/societe/github_19.0.3_mod_codecompta_aquarium.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/societe/client_mod_codecompta_aquarium.php @@ -40,8 +40,3 @@ - * @var string - */ - public $code; - - /** - * Dolibarr version of the loaded document - * @var string - */ + * Dolibarr version of the loaded document + * @var string + */ @@ -62,15 +57,5 @@ - global $conf; - if (!isset($conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER) || trim($conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER) == '') { - $conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER = '411'; - } - if (!isset($conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER) || trim($conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER) == '') { - $conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER = '401'; - } - - if (getDolGlobalString('COMPANY_AQUARIUM_NO_PREFIX')) { - $this->prefixcustomeraccountancycode = ''; - $this->prefixsupplieraccountancycode = ''; - } else { - $this->prefixcustomeraccountancycode = $conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER; - $this->prefixsupplieraccountancycode = $conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER; - } + global $conf; + if (!isset($conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER) || trim($conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER) == '') $conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER = '411'; + if (!isset($conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER) || trim($conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER) == '') $conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER = '401'; + $this->prefixcustomeraccountancycode = $conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER; + $this->prefixsupplieraccountancycode = $conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER; @@ -88,2 +73,2 @@ - global $conf; - global $form; + global $conf; + global $form; @@ -93 +78 @@ - $tooltip = ''; + $tooltip = ''; @@ -96 +80,0 @@ - $texte .= ''; @@ -101,2 +85,2 @@ - $s1 = $form->textwithpicto('', $tooltip, 1, 1); - $s2 = $form->textwithpicto('', $tooltip, 1, 1); + $s1 = $form->textwithpicto('', $tooltip, 1, 1); + $s2 = $form->textwithpicto('', $tooltip, 1, 1); @@ -104,4 +88,2 @@ - // trans remove html entities - $texte .= $langs->trans("ModuleCompanyCodeCustomer".$this->name, '{s2}')."
\n"; - $texte .= $langs->trans("ModuleCompanyCodeSupplier".$this->name, '{s1}')."
\n"; - $texte = str_replace(array('{s1}', '{s2}'), array($s1, $s2), $texte); + $texte .= $langs->trans("ModuleCompanyCodeCustomer".$this->name, $s2)."
\n"; + $texte .= $langs->trans("ModuleCompanyCodeSupplier".$this->name, $s1)."
\n"; @@ -109,11 +91,3 @@ - if (!isset($conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL) || !empty($conf->global->$conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL)) { - $texte .= $langs->trans('RemoveSpecialChars').' = '.yn(1)."
\n"; - } - //if (!empty($conf->global->COMPANY_AQUARIUM_REMOVE_ALPHA)) $texte.=$langs->trans('COMPANY_AQUARIUM_REMOVE_ALPHA').' = '.yn($conf->global->COMPANY_AQUARIUM_REMOVE_ALPHA)."
\n"; - if (getDolGlobalString('COMPANY_AQUARIUM_CLEAN_REGEX')) { - $texte .= $langs->trans('COMPANY_AQUARIUM_CLEAN_REGEX').' = ' . getDolGlobalString('COMPANY_AQUARIUM_CLEAN_REGEX')."
\n"; - } - - if (getDolGlobalString('COMPANY_AQUARIUM_NO_PREFIX')) { - $texte .= $langs->trans('COMPANY_AQUARIUM_NO_PREFIX').' = ' . getDolGlobalString('COMPANY_AQUARIUM_NO_PREFIX')."
\n"; - } + if (!isset($conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL) || !empty($conf->global->$conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL)) $texte .= $langs->trans('RemoveSpecialChars').' = '.yn(1)."
\n"; + //if (! empty($conf->global->COMPANY_AQUARIUM_REMOVE_ALPHA)) $texte.=$langs->trans('COMPANY_AQUARIUM_REMOVE_ALPHA').' = '.yn($conf->global->COMPANY_AQUARIUM_REMOVE_ALPHA)."
\n"; + if (!empty($conf->global->COMPANY_AQUARIUM_CLEAN_REGEX)) $texte .= $langs->trans('COMPANY_AQUARIUM_CLEAN_REGEX').' = '.$conf->global->COMPANY_AQUARIUM_CLEAN_REGEX."
\n"; @@ -121,3 +95,3 @@ - $texte .= ''; - $texte .= ''; - $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; @@ -140,7 +114,7 @@ - $s .= "
\n"; - $s .= $this->prefixsupplieraccountancycode.'SUPPCODE'; - return $s; - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + $s .= "
\n"; + $s .= $this->prefixsupplieraccountancycode.'SUPPCODE'; + return $s; + } + + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -157 +131 @@ - // phpcs:enable + // phpcs:enable @@ -166 +140,2 @@ - if ($type == 'customer') { + if ($type == 'customer') + { @@ -169 +144,3 @@ - } elseif ($type == 'supplier') { + } + elseif ($type == 'supplier') + { @@ -172 +149,3 @@ - } else { + } + else + { @@ -180,3 +159 @@ - if (!isset($conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL) || getDolGlobalString('COMPANY_AQUARIUM_REMOVE_SPECIAL')) { - $codetouse = preg_replace('/([^a-z0-9])/i', '', $codetouse); - } + if (!isset($conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL) || !empty($conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL)) $codetouse = preg_replace('/([^a-z0-9])/i', '', $codetouse); @@ -184,3 +161 @@ - if (getDolGlobalString('COMPANY_AQUARIUM_REMOVE_ALPHA')) { - $codetouse = preg_replace('/([a-z])/i', '', $codetouse); - } + if (!empty($conf->global->COMPANY_AQUARIUM_REMOVE_ALPHA)) $codetouse = preg_replace('/([a-z])/i', '', $codetouse); @@ -188,2 +163,3 @@ - if (getDolGlobalString('COMPANY_AQUARIUM_CLEAN_REGEX')) { // Example: $conf->global->COMPANY_AQUARIUM_CLEAN_REGEX='^..(..)..'; - $codetouse = preg_replace('/' . getDolGlobalString('COMPANY_AQUARIUM_CLEAN_REGEX').'/', '\1\2\3', $codetouse); + if (!empty($conf->global->COMPANY_AQUARIUM_CLEAN_REGEX)) // Example: $conf->global->COMPANY_AQUARIUM_CLEAN_REGEX='^..(..)..'; + { + $codetouse = preg_replace('/'.$conf->global->COMPANY_AQUARIUM_CLEAN_REGEX.'/', '\1\2\3', $codetouse); @@ -195 +171,2 @@ - if (!$is_dispo) { + if (!$is_dispo) + { @@ -197 +174,3 @@ - } else { + } + else + { @@ -218,5 +197,2 @@ - if ($type == 'customer') { - $sql .= "code_compta"; - } elseif ($type == 'supplier') { - $sql .= "code_compta_fournisseur"; - } + if ($type == 'customer') $sql .= "code_compta"; + elseif ($type == 'supplier') $sql .= "code_compta_fournisseur"; @@ -225,5 +201,2 @@ - if ($type == 'customer') { - $sql .= "code_compta"; - } elseif ($type == 'supplier') { - $sql .= "code_compta_fournisseur"; - } + if ($type == 'customer') $sql .= "code_compta"; + elseif ($type == 'supplier') $sql .= "code_compta_fournisseur"; @@ -231,3 +204 @@ - if (!empty($societe->id)) { - $sql .= " AND rowid <> ".$societe->id; - } + if (!empty($societe->id)) $sql .= " AND rowid <> ".$societe->id; @@ -236,2 +207,4 @@ - if ($resql) { - if ($db->num_rows($resql) == 0) { + if ($resql) + { + if ($db->num_rows($resql) == 0) + { @@ -240 +213,3 @@ - } else { + } + else + { @@ -244 +219,3 @@ - } else { + } + else + { --- /tmp/dsg/dolibarr/htdocs/core/modules/societe/github_19.0.3_mod_codecompta_digitaria.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/societe/client_mod_codecompta_digitaria.php @@ -35,31 +35,24 @@ - /** - * @var string model name - */ - public $name = 'Digitaria'; - - /** - * Dolibarr version of the loaded document - * @var string - */ - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' - - /** - * Prefix customer accountancy code - * @var string - */ - public $prefixcustomeraccountancycode; - - /** - * Prefix supplier accountancy code - * @var string - */ - public $prefixsupplieraccountancycode; - - public $position = 30; - - /** - * @var string - */ - public $code; - public $customeraccountancycodecharacternumber; - public $supplieraccountancycodecharacternumber; + /** + * @var string model name + */ + public $name = 'Digitaria'; + + /** + * Dolibarr version of the loaded document + * @var string + */ + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' + + /** + * Prefix customer accountancy code + * @var string + */ + public $prefixcustomeraccountancycode; + + /** + * Prefix supplier accountancy code + * @var string + */ + public $prefixsupplieraccountancycode; + + public $position = 30; @@ -73,18 +66,10 @@ - global $conf, $langs; - if (!isset($conf->global->COMPANY_DIGITARIA_MASK_CUSTOMER) || trim($conf->global->COMPANY_DIGITARIA_MASK_CUSTOMER) == '') { - $conf->global->COMPANY_DIGITARIA_MASK_CUSTOMER = '411'; - } - if (!isset($conf->global->COMPANY_DIGITARIA_MASK_SUPPLIER) || trim($conf->global->COMPANY_DIGITARIA_MASK_SUPPLIER) == '') { - $conf->global->COMPANY_DIGITARIA_MASK_SUPPLIER = '401'; - } - $this->prefixcustomeraccountancycode = $conf->global->COMPANY_DIGITARIA_MASK_CUSTOMER; - $this->prefixsupplieraccountancycode = $conf->global->COMPANY_DIGITARIA_MASK_SUPPLIER; - - if (!isset($conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_CUSTOMER) || trim($conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_CUSTOMER) == '') { - $conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_CUSTOMER = '5'; - } - if (!isset($conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_SUPPLIER) || trim($conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_SUPPLIER) == '') { - $conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_SUPPLIER = '5'; - } - $this->customeraccountancycodecharacternumber = $conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_CUSTOMER; - $this->supplieraccountancycodecharacternumber = $conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_SUPPLIER; + global $conf, $langs; + if (!isset($conf->global->COMPANY_DIGITARIA_MASK_CUSTOMER) || trim($conf->global->COMPANY_DIGITARIA_MASK_CUSTOMER) == '') $conf->global->COMPANY_DIGITARIA_MASK_CUSTOMER = '411'; + if (!isset($conf->global->COMPANY_DIGITARIA_MASK_SUPPLIER) || trim($conf->global->COMPANY_DIGITARIA_MASK_SUPPLIER) == '') $conf->global->COMPANY_DIGITARIA_MASK_SUPPLIER = '401'; + $this->prefixcustomeraccountancycode = $conf->global->COMPANY_DIGITARIA_MASK_CUSTOMER; + $this->prefixsupplieraccountancycode = $conf->global->COMPANY_DIGITARIA_MASK_SUPPLIER; + + if (!isset($conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_CUSTOMER) || trim($conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_CUSTOMER) == '') $conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_CUSTOMER = '5'; + if (!isset($conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_SUPPLIER) || trim($conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_SUPPLIER) == '') $conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_SUPPLIER = '5'; + $this->customeraccountancycodecharacternumber = $conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_CUSTOMER; + $this->supplieraccountancycodecharacternumber = $conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_SUPPLIER; @@ -101,57 +86,31 @@ - global $conf, $form; - - $tooltip = ''; - $texte = '
'; - $texte .= ''; - $texte .= ''; - $texte .= ''; - $texte .= ''; - $texte .= ''; - $texte .= ''; - $texte .= ''; - $texte .= ''; - $texte .= ''; - $s1 = $form->textwithpicto('', $tooltip, 1, 1); - $s2 = $form->textwithpicto('', $tooltip, 1, 1); - $s3 = $form->textwithpicto('', $tooltip, 1, 1); - $s4 = $form->textwithpicto('', $tooltip, 1, 1); - $texte .= ''; - $texte .= ''; - $texte .= ''; - - $texte .= '
'; - // trans remove html entities - $texte .= $langs->trans("ModuleCompanyCodeCustomer".$this->name, '{s2}', '{s4}')."
\n"; - $texte .= $langs->trans("ModuleCompanyCodeSupplier".$this->name, '{s1}', '{s3}')."
\n"; - $texte = str_replace(array('{s1}', '{s2}', '{s3}', '{s4}'), array($s1, $s2, $s3, $s4), $texte); - $texte .= "
\n"; - // Remove special char if COMPANY_DIGITARIA_REMOVE_SPECIAL is set to 1 or not set (default) - if (!isset($conf->global->COMPANY_DIGITARIA_REMOVE_SPECIAL) || !empty($conf->global->$conf->global->COMPANY_DIGITARIA_REMOVE_SPECIAL)) { - $texte .= $langs->trans('RemoveSpecialChars').' = '.yn(1)."
\n"; - } - // Apply a regex replacement pattern on code if COMPANY_DIGITARIA_CLEAN_REGEX is set. Value must be a regex with parenthesis. The part into parenthesis is kept, the rest removed. - if (getDolGlobalString('COMPANY_DIGITARIA_CLEAN_REGEX')) { - $texte .= $langs->trans('COMPANY_DIGITARIA_CLEAN_REGEX').' = ' . getDolGlobalString('COMPANY_DIGITARIA_CLEAN_REGEX')."
\n"; - } - // Unique index on code if COMPANY_DIGITARIA_UNIQUE_CODE is set to 1 or not set (default) - if (!isset($conf->global->COMPANY_DIGITARIA_UNIQUE_CODE) || getDolGlobalString('COMPANY_DIGITARIA_UNIQUE_CODE')) { - $texte .= $langs->trans('COMPANY_DIGITARIA_UNIQUE_CODE').' = '.yn(1)."
\n"; - } - $texte .= '
'; - $texte .= "
\n"; - - $texthelp = $langs->trans("RemoveSpecialWordsHelp"); - $texttitle = $langs->trans("RemoveSpecialWords"); - - $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); - $texte .= "
\n"; - $texte .= ''; - $texte .= '
'; - - $texte .= '
'; - - return $texte; + global $conf, $form; + + $tooltip = ''; + $texte = '
'; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $s1 = $form->textwithpicto('', $tooltip, 1, 1); + $s2 = $form->textwithpicto('', $tooltip, 1, 1); + $s3 = $form->textwithpicto('', $tooltip, 1, 1); + $s4 = $form->textwithpicto('', $tooltip, 1, 1); + $texte .= ''; + $texte .= ''; + $texte .= '
'; + $texte .= $langs->trans("ModuleCompanyCodeCustomer".$this->name, $s2, $s4)."
\n"; + $texte .= $langs->trans("ModuleCompanyCodeSupplier".$this->name, $s1, $s3)."
\n"; + $texte .= "
\n"; + // Remove special char if COMPANY_DIGITARIA_REMOVE_SPECIAL is set to 1 or not set (default) + if (!isset($conf->global->COMPANY_DIGITARIA_REMOVE_SPECIAL) || !empty($conf->global->$conf->global->COMPANY_DIGITARIA_REMOVE_SPECIAL)) $texte .= $langs->trans('RemoveSpecialChars').' = '.yn(1)."
\n"; + // Apply a regex replacement pattern on code if COMPANY_DIGITARIA_CLEAN_REGEX is set. Value must be a regex with parenthesis. The part into parenthesis is kept, the rest removed. + if (!empty($conf->global->COMPANY_DIGITARIA_CLEAN_REGEX)) $texte .= $langs->trans('COMPANY_DIGITARIA_CLEAN_REGEX').' = '.$conf->global->COMPANY_DIGITARIA_CLEAN_REGEX."
\n"; + // Unique index on code if COMPANY_DIGITARIA_UNIQUE_CODE is set to 1 or not set (default) + if (!isset($conf->global->COMPANY_DIGITARIA_UNIQUE_CODE) || !empty($conf->global->COMPANY_DIGITARIA_UNIQUE_CODE)) $texte .= $langs->trans('COMPANY_DIGITARIA_UNIQUE_CODE').' = '.yn(1)."
\n"; + $texte .= '
'; + $texte .= '
'; + + return $texte; @@ -170,17 +129,15 @@ - global $conf, $mysoc; - - $s = $langs->trans("ThirdPartyName").": ".$mysoc->name; - $s .= "
\n"; - - if (!isset($conf->global->COMPANY_DIGITARIA_REMOVE_SPECIAL)) { - $thirdpartylabelexample = preg_replace('/([^a-z0-9])/i', '', $mysoc->name); - } - $s .= "
\n"; - $s .= $this->prefixcustomeraccountancycode.strtoupper(substr($thirdpartylabelexample, 0, $this->customeraccountancycodecharacternumber)); - $s .= "
\n"; - $s .= $this->prefixsupplieraccountancycode.strtoupper(substr($thirdpartylabelexample, 0, $this->supplieraccountancycodecharacternumber)); - return $s; - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** + global $conf, $mysoc; + + $s = $langs->trans("ThirdPartyName").": ".$mysoc->name; + $s .= "
\n"; + + if (!isset($conf->global->COMPANY_DIGITARIA_REMOVE_SPECIAL)) $thirdpartylabelexample = preg_replace('/([^a-z0-9])/i', '', $mysoc->name); + $s .= "
\n"; + $s .= $this->prefixcustomeraccountancycode.strtoupper(substr($thirdpartylabelexample, 0, $this->customeraccountancycodecharacternumber)); + $s .= "
\n"; + $s .= $this->prefixsupplieraccountancycode.strtoupper(substr($thirdpartylabelexample, 0, $this->supplieraccountancycodecharacternumber)); + return $s; + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** @@ -196,9 +153,8 @@ - // phpcs:enable - global $conf; - $i = 0; - $this->code = ''; - - $disponibility = 0; - - if (is_object($societe)) { - dol_syslog("mod_codecompta_digitaria::get_code search code for type=".$type." & company=".(!empty($societe->name) ? $societe->name : '')); + // phpcs:enable + global $conf; + $i = 0; + $this->code = ''; + + if (is_object($societe)) + { + dol_syslog("mod_codecompta_digitaria::get_code search code for type=".$type." & company=".(!empty($societe->name) ? $societe->name : '')); @@ -207,10 +163,3 @@ - $codetouse = $societe->name; - $prefix = $this->prefixsupplieraccountancycode; - $width = $this->supplieraccountancycodecharacternumber; - } elseif ($type == 'customer') { - $codetouse = $societe->name; - $prefix = $this->prefixcustomeraccountancycode; - $width = $this->customeraccountancycodecharacternumber; - } else { - $this->error = 'Bad value for parameter type'; - return -1; + $codetouse = $societe->name; + $prefix = $this->prefixsupplieraccountancycode; + $width = $this->supplieraccountancycodecharacternumber; @@ -218,48 +167,51 @@ - - // Clean declared words - if (getDolGlobalString('COMPANY_DIGITARIA_CLEAN_WORDS')) { - $cleanWords = explode(";", getDolGlobalString('COMPANY_DIGITARIA_CLEAN_WORDS')); - $codetouse = str_replace($cleanWords, "", $codetouse); - } - // Remove special char if COMPANY_DIGITARIA_REMOVE_SPECIAL is set to 1 or not set (default) - if (!isset($conf->global->COMPANY_DIGITARIA_REMOVE_SPECIAL) || getDolGlobalString('COMPANY_DIGITARIA_REMOVE_SPECIAL')) { - $codetouse = preg_replace('/([^a-z0-9])/i', '', $codetouse); - } - // Apply a regex replacement pattern on code if COMPANY_DIGITARIA_CLEAN_REGEX is set. Value must be a regex with parenthesis. The part into parenthesis is kept, the rest removed. - if (getDolGlobalString('COMPANY_DIGITARIA_CLEAN_REGEX')) { // Example: $conf->global->COMPANY_DIGITARIA_CLEAN_REGEX='^..(..)..'; - $codetouse = preg_replace('/' . getDolGlobalString('COMPANY_DIGITARIA_CLEAN_REGEX').'/', '\1\2\3', $codetouse); - } - - $this->code = $prefix.strtoupper(substr($codetouse, 0, $width)); - dol_syslog("mod_codecompta_digitaria::get_code search code proposed=".$this->code, LOG_DEBUG); - - // Unique index on code if COMPANY_DIGITARIA_UNIQUE_CODE is set to 1 or not set (default) - if (!isset($conf->global->COMPANY_DIGITARIA_UNIQUE_CODE) || getDolGlobalString('COMPANY_DIGITARIA_UNIQUE_CODE')) { - $disponibility = $this->checkIfAccountancyCodeIsAlreadyUsed($db, $this->code, $type); - - while ($disponibility != 0 && $i < 1000) { - $widthsupplier = $this->supplieraccountancycodecharacternumber; - $widthcustomer = $this->customeraccountancycodecharacternumber; - - if ($i <= 9) { - $a = 1; - } - if ($i >= 10 && $i <= 99) { - $a = 2; - } - if ($i >= 100 && $i <= 999) { - $a = 3; - } - - if ($type == 'supplier') { - $this->code = $prefix.strtoupper(substr($codetouse, 0, $widthsupplier - $a)).$i; - } elseif ($type == 'customer') { - $this->code = $prefix.strtoupper(substr($codetouse, 0, $widthcustomer - $a)).$i; - } - $disponibility = $this->checkIfAccountancyCodeIsAlreadyUsed($db, $this->code, $type); - - $i++; - } - } else { - $disponibility == 0; - } + elseif ($type == 'customer') + { + $codetouse = $societe->name; + $prefix = $this->prefixcustomeraccountancycode; + $width = $this->customeraccountancycodecharacternumber; + } + else + { + $this->error = 'Bad value for parameter type'; + return -1; + } + + // Remove special char if COMPANY_DIGITARIA_REMOVE_SPECIAL is set to 1 or not set (default) + if (!isset($conf->global->COMPANY_DIGITARIA_REMOVE_SPECIAL) || !empty($conf->global->COMPANY_DIGITARIA_REMOVE_SPECIAL)) $codetouse = preg_replace('/([^a-z0-9])/i', '', $codetouse); + // Apply a regex replacement pattern on code if COMPANY_DIGITARIA_CLEAN_REGEX is set. Value must be a regex with parenthesis. The part into parenthesis is kept, the rest removed. + if (!empty($conf->global->COMPANY_DIGITARIA_CLEAN_REGEX)) // Example: $conf->global->COMPANY_DIGITARIA_CLEAN_REGEX='^..(..)..'; + { + $codetouse = preg_replace('/'.$conf->global->COMPANY_DIGITARIA_CLEAN_REGEX.'/', '\1\2\3', $codetouse); + } + + $this->code = $prefix.strtoupper(substr($codetouse, 0, $width)); + dol_syslog("mod_codecompta_digitaria::get_code search code proposed=".$this->code); + + // Unique index on code if COMPANY_DIGITARIA_UNIQUE_CODE is set to 1 or not set (default) + if (!isset($conf->global->COMPANY_DIGITARIA_UNIQUE_CODE) || !empty($conf->global->COMPANY_DIGITARIA_UNIQUE_CODE)) + { + $disponibility = $this->checkIfAccountancyCodeIsAlreadyUsed($db, $this->code, $type); + + while ($disponibility <> 0 && $i < 100) { + $widthsupplier = $this->supplieraccountancycodecharacternumber; + $widthcustomer = $this->customeraccountancycodecharacternumber; + + if ($i <= 9) { + $a = 1; + } + if ($i >= 10 && $i <= 99) { + $a = 2; + } + + if ($type == 'supplier') { + $this->code = $prefix.strtoupper(substr($codetouse, 0, $widthsupplier - $a)).$i; + } elseif ($type == 'customer') { + $this->code = $prefix.strtoupper(substr($codetouse, 0, $widthcustomer - $a)).$i; + } + $disponibility = $this->checkIfAccountancyCodeIsAlreadyUsed($db, $this->code, $type); + + $i++; + } + } else { + $disponibility == 0; + } @@ -268,59 +220,57 @@ - if ($disponibility == 0) { - return 0; // return ok - } else { - return -1; // return ko - } - } - - /** - * Check accountancy account code for a third party into this->code - * - * @param DoliDB $db Database handler - * @param string $code Code of third party - * @param int $type 'customer' or 'supplier' - * @return int >=0 if OK, <0 if KO - */ - public function checkIfAccountancyCodeIsAlreadyUsed($db, $code, $type = '') - { - global $conf; - - if ($type == 'supplier') { - if (getDolGlobalString('MAIN_COMPANY_PERENTITY_SHARED')) { - $typethirdparty = 'accountancy_code_supplier'; - } else { - $typethirdparty = 'code_compta_fournisseur'; - } - } elseif ($type == 'customer') { - if (getDolGlobalString('MAIN_COMPANY_PERENTITY_SHARED')) { - $typethirdparty = 'accountancy_code_customer'; - } else { - $typethirdparty = 'code_compta'; - } - } else { - $this->error = 'Bad value for parameter type'; - return -1; - } - - if (getDolGlobalString('MAIN_COMPANY_PERENTITY_SHARED')) { - $sql = "SELECT " . $typethirdparty . " FROM " . MAIN_DB_PREFIX . "societe_perentity"; - $sql .= " WHERE " . $typethirdparty . " = '" . $db->escape($code) . "'"; - } else { - $sql = "SELECT " . $typethirdparty . " FROM " . MAIN_DB_PREFIX . "societe"; - $sql .= " WHERE " . $typethirdparty . " = '" . $db->escape($code) . "'"; - } - $sql .= " AND entity IN (".getEntity('societe').")"; - - $resql = $db->query($sql); - if ($resql) { - if ($db->num_rows($resql) == 0) { - dol_syslog("mod_codecompta_digitaria::checkIfAccountancyCodeIsAlreadyUsed '".$code."' available"); - return 0; // Available - } else { - dol_syslog("mod_codecompta_digitaria::checkIfAccountancyCodeIsAlreadyUsed '".$code."' not available"); - return -1; // Not available - } - } else { - $this->error = $db->error()." sql=".$sql; - return -2; // Error - } - } + if ($disponibility == 0) + { + return 0; // return ok + } + else + { + return -1; // return ko + } + } + + /** + * Check accountancy account code for a third party into this->code + * + * @param DoliDB $db Database handler + * @param string $code Code of third party + * @param int $type 'customer' or 'supplier' + * @return int >=0 if OK, <0 if KO + */ + public function checkIfAccountancyCodeIsAlreadyUsed($db, $code, $type = '') + { + if ($type == 'supplier') + { + $typethirdparty = 'code_compta_fournisseur'; + } + elseif ($type == 'customer') + { + $typethirdparty = 'code_compta'; + } + else + { + $this->error = 'Bad value for parameter type'; + return -1; + } + + $sql = "SELECT ".$typethirdparty." FROM ".MAIN_DB_PREFIX."societe"; + $sql .= " WHERE ".$typethirdparty." = '".$code."'"; + + $resql = $db->query($sql); + if ($resql) + { + if ($db->num_rows($resql) == 0) + { + dol_syslog("mod_codecompta_digitaria::checkIfAccountancyCodeIsAlreadyUsed '".$code."' available"); + return 0; // Available + } + else + { + dol_syslog("mod_codecompta_digitaria::checkIfAccountancyCodeIsAlreadyUsed '".$code."' not available"); + return -1; // Not available + } + } + else + { + $this->error = $db->error()." sql=".$sql; + return -2; // Error + } + } --- /tmp/dsg/dolibarr/htdocs/core/modules/societe/github_19.0.3_mod_codecompta_panicum.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/societe/client_mod_codecompta_panicum.php @@ -39,8 +39,3 @@ - * @var string - */ - public $code; - - /** - * Dolibarr version of the loaded document - * @var string - */ + * Dolibarr version of the loaded document + * @var string + */ @@ -84 +79 @@ - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -95 +90 @@ - // phpcs:enable + // phpcs:enable @@ -99,5 +94,2 @@ - if ($type == 'supplier') { - $this->code = (($societe->code_compta_fournisseur != "") ? $societe->code_compta_fournisseur : ''); - } else { - $this->code = (($societe->code_compta != "") ? $societe->code_compta : ''); - } + if ($type == 'supplier') $this->code = (($societe->code_compta_fournisseur != "") ? $societe->code_compta_fournisseur : ''); + else $this->code = (($societe->code_compta != "") ? $societe->code_compta : ''); --- /tmp/dsg/dolibarr/htdocs/core/modules/societe/github_19.0.3_modules_societe.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/societe/client_modules_societe.class.php @@ -28 +27,0 @@ -require_once DOL_DOCUMENT_ROOT.'/core/class/commonnumrefgenerator.class.php'; @@ -32 +31,2 @@ - * Parent class for third parties models of doc generators + * \class ModeleThirdPartyDoc + * \brief Parent class for third parties models of doc generators @@ -35,0 +36,5 @@ + /** + * @var string Error code (or message) + */ + public $error = ''; + @@ -40 +45 @@ - * @param DoliDB $dbs Database handler + * @param DoliDB $db Database handler @@ -44 +49 @@ - public static function liste_modeles($dbs, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) @@ -46,0 +52,2 @@ + global $conf; + @@ -48 +55 @@ - $list = array(); + $liste = array(); @@ -51,3 +58,3 @@ - $list = getListOfModels($dbs, $type, $maxfilenamelength); - - return $list; + $liste = getListOfModels($db, $type, $maxfilenamelength); + + return $liste; @@ -58,3 +65,4 @@ - * Parent class for third parties code generators - */ -abstract class ModeleThirdPartyCode extends CommonNumRefGenerator + * \class ModeleThirdPartyCode + * \brief Parent class for third parties code generators + */ +abstract class ModeleThirdPartyCode @@ -63,16 +71,47 @@ - * @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"); + } + + /** Return name of module + * + * @param Translate $langs Object langs + * @return string Nom du module + */ + public function getNom($langs) + { + return $this->name; + } + + + /** Return an example of numbering + * + * @param Translate $langs Object langs + * @return string Example + */ + public function getExample($langs) + { + $langs->load("bills"); + 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; + } @@ -92,0 +132,18 @@ + + /** + * 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"); + } + @@ -97 +154 @@ - * @param DoliDB $dbs Database handler + * @param DoliDB $db Database handler @@ -99,3 +156,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) @@ -104 +161 @@ - $list = array(); + $liste = array(); @@ -107,3 +164,4 @@ - $resql = $dbs->query($sql); - if ($resql) { - $num = $dbs->num_rows($resql); + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); @@ -111,3 +169,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]; @@ -116 +175,3 @@ - } else { + } + else + { @@ -119 +180 @@ - return $list; + return $liste; @@ -134,8 +195 @@ - $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"); @@ -144,12 +198,5 @@ - if ($type == -1) { - $s .= $langs->trans("Name").': '.$this->getNom($langs).'
'; - } elseif ($type == -1) { - $s .= $langs->trans("Version").': '.$this->getVersion().'
'; - } elseif ($type == 0) { - $s .= $langs->trans("CustomerCodeDesc").'
'; - } elseif ($type == 1) { - $s .= $langs->trans("SupplierCodeDesc").'
'; - } - if ($type != -1) { - $s .= $langs->trans("ValidityControledByModule").': '.$this->getNom($langs).'
'; - } + if ($type == -1) $s .= $langs->trans("Name").': '.$this->getNom($langs).'
'; + if ($type == -1) $s .= $langs->trans("Version").': '.$this->getVersion().'
'; + if ($type == 0) $s .= $langs->trans("CustomerCodeDesc").'
'; + if ($type == 1) $s .= $langs->trans("SupplierCodeDesc").'
'; + if ($type != -1) $s .= $langs->trans("ValidityControledByModule").': '.$this->getNom($langs).'
'; @@ -158,3 +205,6 @@ - if ($type == 0) { - $s .= $langs->trans("RequiredIfCustomer").': '.$strikestart; - $s .= yn(!$this->code_null, 1, 2).$strikeend; + if ($type == 0) + { + $s .= $langs->trans("RequiredIfCustomer").': '; + 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")).')'; @@ -162,3 +212,7 @@ - } elseif ($type == 1) { - $s .= $langs->trans("RequiredIfSupplier").': '.$strikestart; - $s .= yn(!$this->code_null, 1, 2).$strikeend; + } + if ($type == 1) + { + $s .= $langs->trans("RequiredIfSupplier").': '; + 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")).')'; @@ -166,3 +220,7 @@ - } elseif ($type == -1) { - $s .= $langs->trans("Required").': '.$strikestart; - $s .= yn(!$this->code_null, 1, 2).$strikeend; + } + if ($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")).')'; @@ -177 +235,2 @@ - if ($type == 0 || $type == -1) { + if ($type == 0 || $type == -1) + { @@ -179,3 +238 @@ - if (empty($nextval)) { - $nextval = $langs->trans("Undefined"); - } + if (empty($nextval)) $nextval = $langs->trans("Undefined"); @@ -184 +241,2 @@ - if ($type == 1 || $type == -1) { + if ($type == 1 || $type == -1) + { @@ -186,3 +244 @@ - if (empty($nextval)) { - $nextval = $langs->trans("Undefined"); - } + if (empty($nextval)) $nextval = $langs->trans("Undefined"); @@ -211 +267 @@ -abstract class ModeleAccountancyCode extends CommonNumRefGenerator +abstract class ModeleAccountancyCode @@ -214,3 +270,58 @@ - * @var string - */ - public $code; + * @var string Error code (or message) + */ + public $error = ''; + + + /** + * Return description of module + * + * @param Translate $langs Object langs + * @return string Description of module + */ + public function info($langs) + { + $langs->load("bills"); + return $langs->trans("NoDescription"); + } + + /** + * Return an example of result returned by getNextValue + * + * @param Translate $langs Object langs + * @param societe $objsoc Object thirdparty + * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) + * @return string Example + */ + public function getExample($langs, $objsoc = 0, $type = -1) + { + $langs->load("bills"); + 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; + } + + /** + * 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"); + } @@ -228 +339 @@ - global $db; + global $conf, $db; @@ -233,4 +344,2 @@ - if ($type == -1) { - $s .= $langs->trans("Name").': '.$this->name.'
'; - $s .= $langs->trans("Version").': '.$this->getVersion().'
'; - } + if ($type == -1) $s .= $langs->trans("Name").': '.$this->name.'
'; + if ($type == -1) $s .= $langs->trans("Version").': '.$this->getVersion().'
'; @@ -240 +349,2 @@ - if ($type == 0 || $type == -1) { + if ($type == 0 || $type == -1) + { @@ -243,3 +353 @@ - if (empty($nextval)) { - $nextval = $langs->trans("Undefined"); - } + if (empty($nextval)) $nextval = $langs->trans("Undefined"); @@ -248 +356,2 @@ - if ($type == 1 || $type == -1) { + if ($type == 1 || $type == -1) + { @@ -251,3 +360 @@ - if (empty($nextval)) { - $nextval = $langs->trans("Undefined"); - } + if (empty($nextval)) $nextval = $langs->trans("Undefined"); @@ -275,0 +383,23 @@ + + +/** + * Create a document onto disk according to template module. + * + * @param DoliDB $db Database handler + * @param Facture $object Object invoice + * @param string $message Message (not used, deprecated) + * @param string $modele Force template to use ('' to not force) + * @param Translate $outputlangs objet lang a utiliser pour traduction + * @param int $hidedetails Hide details of lines + * @param int $hidedesc Hide description + * @param int $hideref Hide ref + * @return int <0 if KO, >0 if OK + * @deprecated Use the new function generateDocument of Objects class + * @see Societe::generateDocument() + */ +function thirdparty_doc_create(DoliDB $db, Societe $object, $message, $modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0) +{ + dol_syslog(__METHOD__." is deprecated", LOG_WARNING); + + return $object->generateDocument($modele, $outputlangs, $hidedetails, $hidedesc, $hideref); +}