26 require_once DOL_DOCUMENT_ROOT.
'/core/modules/societe/modules_societe.class.php';
37 public $name =
'Aquarium';
43 public $version =
'dolibarr';
45 public $prefixcustomeraccountancycode;
47 public $prefixsupplieraccountancycode;
49 public $position = 20;
58 if (!isset($conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER) || trim($conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER) ==
'') {
59 $conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER =
'411';
61 if (!isset($conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER) || trim($conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER) ==
'') {
62 $conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER =
'401';
64 $this->prefixcustomeraccountancycode = $conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER;
65 $this->prefixsupplieraccountancycode = $conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER;
75 public function info($langs)
80 $langs->load(
"companies");
83 $texte =
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
84 $texte .=
'<input type="hidden" name="token" value="'.newToken().
'">';
85 $texte .=
'<input type="hidden" name="page_y" value="">';
86 $texte .=
'<input type="hidden" name="action" value="setModuleOptions">';
87 $texte .=
'<input type="hidden" name="param1" value="COMPANY_AQUARIUM_MASK_SUPPLIER">';
88 $texte .=
'<input type="hidden" name="param2" value="COMPANY_AQUARIUM_MASK_CUSTOMER">';
89 $texte .=
'<table class="nobordernopadding" width="100%">';
90 $s1 =
$form->textwithpicto(
'<input type="text" class="flat" size="4" name="value1" value="'.$conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER.
'">', $tooltip, 1, 1);
91 $s2 =
$form->textwithpicto(
'<input type="text" class="flat" size="4" name="value2" value="'.$conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER.
'">', $tooltip, 1, 1);
94 $texte .= $langs->trans(
"ModuleCompanyCodeCustomer".$this->
name,
'{s2}').
"<br>\n";
95 $texte .= $langs->trans(
"ModuleCompanyCodeSupplier".$this->
name,
'{s1}').
"<br>\n";
96 $texte = str_replace(array(
'{s1}',
'{s2}'), array($s1, $s2), $texte);
98 if (!isset($conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL) || !empty($conf->global->$conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL)) {
99 $texte .= $langs->trans(
'RemoveSpecialChars').
' = '.
yn(1).
"<br>\n";
102 if (!empty($conf->global->COMPANY_AQUARIUM_CLEAN_REGEX)) {
103 $texte .= $langs->trans(
'COMPANY_AQUARIUM_CLEAN_REGEX').
' = '.$conf->global->COMPANY_AQUARIUM_CLEAN_REGEX.
"<br>\n";
106 $texte .=
'<td class="right"><input type="submit" class="button button-edit reposition" name="modify" value="'.$langs->trans(
"Modify").
'"></td>';
107 $texte .=
'</tr></table>';
124 $s .= $this->prefixcustomeraccountancycode.
'CUSTCODE';
126 $s .= $this->prefixsupplieraccountancycode.
'SUPPCODE';
140 public function get_code($db, $societe, $type =
'')
148 dol_syslog(
"mod_codecompta_aquarium::get_code search code for type=".$type.
" company=".(!empty($societe->name) ? $societe->name :
''));
151 if ($type ==
'customer') {
152 $codetouse = (!empty($societe->code_client) ? $societe->code_client :
'CUSTCODE');
153 $prefix = $this->prefixcustomeraccountancycode;
154 } elseif ($type ==
'supplier') {
155 $codetouse = (!empty($societe->code_fournisseur) ? $societe->code_fournisseur :
'SUPPCODE');
156 $prefix = $this->prefixsupplieraccountancycode;
158 $this->error =
'Bad value for parameter type';
165 if (!isset($conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL) || !empty($conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL)) {
166 $codetouse = preg_replace(
'/([^a-z0-9])/i',
'', $codetouse);
169 if (!empty($conf->global->COMPANY_AQUARIUM_REMOVE_ALPHA)) {
170 $codetouse = preg_replace(
'/([a-z])/i',
'', $codetouse);
173 if (!empty($conf->global->COMPANY_AQUARIUM_CLEAN_REGEX)) {
174 $codetouse = preg_replace(
'/'.$conf->global->COMPANY_AQUARIUM_CLEAN_REGEX.
'/',
'\1\2\3', $codetouse);
177 $codetouse = $prefix.strtoupper($codetouse);
179 $is_dispo = $this->
verif($db, $codetouse, $societe, $type);
181 $this->
code = $codetouse;
184 $this->
code = $codetouse;
186 dol_syslog(
"mod_codecompta_aquarium::get_code found code=".$this->
code);
200 public function verif($db, $code, $societe, $type)
203 if ($type ==
'customer') {
204 $sql .=
"code_compta";
205 } elseif ($type ==
'supplier') {
206 $sql .=
"code_compta_fournisseur";
208 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe";
210 if ($type ==
'customer') {
211 $sql .=
"code_compta";
212 } elseif ($type ==
'supplier') {
213 $sql .=
"code_compta_fournisseur";
215 $sql .=
" = '".$db->escape($code).
"'";
216 if (!empty($societe->id)) {
217 $sql .=
" AND rowid <> ".$societe->id;
220 $resql = $db->query($sql);
222 if ($db->num_rows(
$resql) == 0) {
223 dol_syslog(
"mod_codecompta_aquarium::verif code '".$code.
"' available");
226 dol_syslog(
"mod_codecompta_aquarium::verif code '".$code.
"' not available");
230 $this->error = $db->error().
" sql=".$sql;
Parent class for third parties accountancy code generators.
Class to manage accountancy code of thirdparties with Aquarium rules.
info($langs)
Return description of module.
verif($db, $code, $societe, $type)
Return if a code is available.
get_code($db, $societe, $type='')
Set accountancy account code for a third party into this->code.
getExample($langs, $objsoc=0, $type=-1)
Return an example of result returned by getNextValue.
__construct()
Constructor.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
$conf db name
Only used if Module[ID]Name translation string is not found.
$conf db
API class for accounts.
print *****$script_file(".$version.") pid code
! Closing after partial payment: discount_vat, badcustomer or badsupplier, bankcharge,...