NEW Add hidden option COMPANY_AQUARIUM_CLEAN_REGEX to clean generated

accounting account.
This commit is contained in:
Laurent Destailleur 2018-04-20 01:10:57 +02:00
parent 4ce313d864
commit 7baf0eddbc
2 changed files with 35 additions and 9 deletions

View File

@ -74,7 +74,9 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode
$texte.= '<table class="nobordernopadding" width="100%">';
$s1= $form->textwithpicto('<input type="text" class="flat" size="4" name="value1" value="'.$conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER.'">',$tooltip,1,1);
$s2= $form->textwithpicto('<input type="text" class="flat" size="4" name="value2" value="'.$conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER.'">',$tooltip,1,1);
$texte.= '<tr><td>'.$langs->trans("ModuleCompanyCode".$this->name,$s1,$s2)."<br>\n";
$texte.= '<tr><td>';
$texte.=$langs->trans("ModuleCompanyCodeCustomer".$this->name,$s2)."<br>\n";
$texte.=$langs->trans("ModuleCompanyCodeSupplier".$this->name,$s1)."<br>\n";
$texte.= '</td>';
$texte.= '<td align="left">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
$texte.= '</tr></table>';
@ -93,7 +95,11 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode
*/
function getExample($langs,$objsoc=0,$type=-1)
{
return $this->prefixsupplieraccountancycode.'SUPPCODE'."<br>\n".$this->prefixcustomeraccountancycode.'CUSTCODE';
$s='';
$s.=$this->prefixcustomeraccountancycode.'CUSTCODE';
$s.="<br>\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)

View File

@ -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:<br>%s followed by third party supplier code for a supplier accounting code,<br>%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).<br>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.