';
@@ -93,7 +95,11 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode
*/
function getExample($langs,$objsoc=0,$type=-1)
{
- return $this->prefixsupplieraccountancycode.'SUPPCODE'." \n".$this->prefixcustomeraccountancycode.'CUSTCODE';
+ $s='';
+ $s.=$this->prefixcustomeraccountancycode.'CUSTCODE';
+ $s.=" \n";
+ $s.=$this->prefixsupplieraccountancycode.'SUPPCODE';
+ return $s;
}
@@ -107,24 +113,43 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode
*/
function get_code($db, $societe, $type='')
{
+ global $conf;
+
$i = 0;
$this->db = $db;
dol_syslog("mod_codecompta_aquarium::get_code search code for type=".$type." company=".(! empty($societe->name)?$societe->name:''));
// Regle gestion compte compta
- $codetouse='';
if ($type == 'customer')
{
- $codetouse = $this->prefixcustomeraccountancycode;
- $codetouse.= (! empty($societe->code_client)?$societe->code_client:'CUSTCODE');
+ $codetouse=(! empty($societe->code_client)?$societe->code_client:'CUSTCODE');
+ $prefix = $this->prefixcustomeraccountancycode;
}
else if ($type == 'supplier')
{
- $codetouse = $this->prefixsupplieraccountancycode;
- $codetouse.= (! empty($societe->code_fournisseur)?$societe->code_fournisseur:'SUPPCODE');
+ $codetouse=(! empty($societe->code_fournisseur)?$societe->code_fournisseur:'SUPPCODE');
+ $prefix = $this->prefixsupplieraccountancycode;
}
- $codetouse=strtoupper(preg_replace('/([^a-z0-9])/i','',$codetouse));
+ else
+ {
+ $this->error = 'Bad value for parameter type';
+ return -1;
+ }
+
+ //$conf->global->COMPANY_AQUARIUM_CLEAN_REGEX='^..(..)..';
+
+ // Remove special char if COMPANY_AQUARIUM_REMOVE_SPECIAL is set to 1 or not set (default)
+ if (! isset($conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL) || ! empty($conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL)) $codetouse=preg_replace('/([^a-z0-9])/i','',$codetouse);
+ // Remove special alpha if COMPANY_AQUARIUM_REMOVE_ALPHA is set to 1
+ if (! empty($conf->global->COMPANY_AQUARIUM_REMOVE_ALPHA)) $codetouse=preg_replace('/([a-z])/i','',$codetouse);
+ // Apply a regex replacement pattern if COMPANY_AQUARIUM_REMOVE_ALPHA is set to 1
+ 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);
+ }
+
+ $codetouse=$prefix.strtoupper($codetouse);
$is_dispo = $this->verif($db, $codetouse, $societe, $type);
if (! $is_dispo)
diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang
index f2c1f0e8f96..5544991959d 100644
--- a/htdocs/langs/en_US/admin.lang
+++ b/htdocs/langs/en_US/admin.lang
@@ -446,7 +446,8 @@ DisplayCompanyInfo=Display company address
DisplayCompanyManagers=Display manager names
DisplayCompanyInfoAndManagers=Display company address and manager names
EnableAndSetupModuleCron=If you want to have this recurring invoice beeing generated automatically, module *%s* must be enabled and correctly setup. Otherwise, generation of invoices must be done manually from this template with button *Create*. Note that even if you enabled automatic generation, you can still safely launch manual generation. Duplicates generation for same period are not possible.
-ModuleCompanyCodeAquarium=Return an accounting code built by: %s followed by third party supplier code for a supplier accounting code, %s followed by third party customer code for a customer accounting code.
+ModuleCompanyCodeCustomerAquarium=%s followed by third party customer code for a customer accounting code
+ModuleCompanyCodeSupplierAquarium=%s followed by third party supplier code for a supplier accounting code
ModuleCompanyCodePanicum=Return an empty accounting code.
ModuleCompanyCodeDigitaria=Accounting code depends on third party code. The code is composed of the character "C" in the first position followed by the first 5 characters of the third party code.
Use3StepsApproval=By default, Purchase Orders need to be created and approved by 2 different users (one step/user to create and one step/user to approve. Note that if user has both permission to create and approve, one step/user will be enough). You can ask with this option to introduce a third step/user approval, if amount is higher than a dedicated value (so 3 steps will be necessary: 1=validation, 2=first approval and 3=second approval if amount is enough). Set this to empty if one approval (2 steps) is enough, set it to a very low value (0.1) if a second approval (3 steps) is always required.