27 require_once DOL_DOCUMENT_ROOT.
'/core/modules/societe/modules_societe.class.php';
38 public $name =
'Digitaria';
44 public $version =
'dolibarr';
50 public $prefixcustomeraccountancycode;
56 public $prefixsupplieraccountancycode;
58 public $position = 30;
67 if (!isset($conf->global->COMPANY_DIGITARIA_MASK_CUSTOMER) || trim($conf->global->COMPANY_DIGITARIA_MASK_CUSTOMER) ==
'') $conf->global->COMPANY_DIGITARIA_MASK_CUSTOMER =
'411';
68 if (!isset($conf->global->COMPANY_DIGITARIA_MASK_SUPPLIER) || trim($conf->global->COMPANY_DIGITARIA_MASK_SUPPLIER) ==
'') $conf->global->COMPANY_DIGITARIA_MASK_SUPPLIER =
'401';
69 $this->prefixcustomeraccountancycode = $conf->global->COMPANY_DIGITARIA_MASK_CUSTOMER;
70 $this->prefixsupplieraccountancycode = $conf->global->COMPANY_DIGITARIA_MASK_SUPPLIER;
72 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';
73 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';
74 $this->customeraccountancycodecharacternumber = $conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_CUSTOMER;
75 $this->supplieraccountancycodecharacternumber = $conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_SUPPLIER;
84 public function info($langs)
89 $texte =
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
90 $texte .=
'<input type="hidden" name="token" value="'.newToken().
'">';
91 $texte .=
'<input type="hidden" name="action" value="setModuleOptions">';
92 $texte .=
'<input type="hidden" name="param1" value="COMPANY_DIGITARIA_MASK_SUPPLIER">';
93 $texte .=
'<input type="hidden" name="param2" value="COMPANY_DIGITARIA_MASK_CUSTOMER">';
94 $texte .=
'<input type="hidden" name="param3" value="COMPANY_DIGITARIA_MASK_NBCHARACTER_SUPPLIER">';
95 $texte .=
'<input type="hidden" name="param4" value="COMPANY_DIGITARIA_MASK_NBCHARACTER_CUSTOMER">';
96 $texte .=
'<table class="nobordernopadding" width="100%">';
97 $s1 = $form->textwithpicto(
'<input type="text" class="flat" size="4" name="value1" value="'.$conf->global->COMPANY_DIGITARIA_MASK_SUPPLIER.
'">', $tooltip, 1, 1);
98 $s2 = $form->textwithpicto(
'<input type="text" class="flat" size="4" name="value2" value="'.$conf->global->COMPANY_DIGITARIA_MASK_CUSTOMER.
'">', $tooltip, 1, 1);
99 $s3 = $form->textwithpicto(
'<input type="text" class="flat" size="2" name="value3" value="'.$conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_SUPPLIER.
'">', $tooltip, 1, 1);
100 $s4 = $form->textwithpicto(
'<input type="text" class="flat" size="2" name="value4" value="'.$conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_CUSTOMER.
'">', $tooltip, 1, 1);
101 $texte .=
'<tr><td>';
103 $texte .= $langs->trans(
"ModuleCompanyCodeCustomer".$this->
name,
'{s2}',
'{s4}').
"<br>\n";
104 $texte .= $langs->trans(
"ModuleCompanyCodeSupplier".$this->
name,
'{s1}',
'{s3}').
"<br>\n";
105 $texte = str_replace(array(
'{s1}',
'{s2}',
'{s3}',
'{s4}'), array($s1, $s2, $s3, $s4), $texte);
108 if (!isset($conf->global->COMPANY_DIGITARIA_REMOVE_SPECIAL) || !empty($conf->global->$conf->global->COMPANY_DIGITARIA_REMOVE_SPECIAL)) $texte .= $langs->trans(
'RemoveSpecialChars').
' = '.
yn(1).
"<br>\n";
110 if (!empty($conf->global->COMPANY_DIGITARIA_CLEAN_REGEX)) $texte .= $langs->trans(
'COMPANY_DIGITARIA_CLEAN_REGEX').
' = '.$conf->global->COMPANY_DIGITARIA_CLEAN_REGEX.
"<br>\n";
112 if (!isset($conf->global->COMPANY_DIGITARIA_UNIQUE_CODE) || !empty($conf->global->COMPANY_DIGITARIA_UNIQUE_CODE)) $texte .= $langs->trans(
'COMPANY_DIGITARIA_UNIQUE_CODE').
' = '.
yn(1).
"<br>\n";
114 $texte .=
'<td class="right"><input type="submit" class="button" value="'.$langs->trans(
"Modify").
'" name="Button"></td>';
115 $texte .=
'</tr></table>';
131 global $conf, $mysoc;
133 $s = $langs->trans(
"ThirdPartyName").
": ".$mysoc->name;
136 if (!isset($conf->global->COMPANY_DIGITARIA_REMOVE_SPECIAL)) $thirdpartylabelexample = preg_replace(
'/([^a-z0-9])/i',
'', $mysoc->name);
138 $s .= $this->prefixcustomeraccountancycode.strtoupper(substr($thirdpartylabelexample, 0, $this->customeraccountancycodecharacternumber));
140 $s .= $this->prefixsupplieraccountancycode.strtoupper(substr($thirdpartylabelexample, 0, $this->supplieraccountancycodecharacternumber));
153 public function get_code($db, $societe, $type =
'')
162 if (is_object($societe))
164 dol_syslog(
"mod_codecompta_digitaria::get_code search code for type=".$type.
" & company=".(!empty($societe->name) ? $societe->name :
''));
166 if ($type ==
'supplier') {
167 $codetouse = $societe->name;
168 $prefix = $this->prefixsupplieraccountancycode;
169 $width = $this->supplieraccountancycodecharacternumber;
170 } elseif ($type ==
'customer')
172 $codetouse = $societe->name;
173 $prefix = $this->prefixcustomeraccountancycode;
174 $width = $this->customeraccountancycodecharacternumber;
176 $this->error =
'Bad value for parameter type';
181 if (!isset($conf->global->COMPANY_DIGITARIA_REMOVE_SPECIAL) || !empty($conf->global->COMPANY_DIGITARIA_REMOVE_SPECIAL)) $codetouse = preg_replace(
'/([^a-z0-9])/i',
'', $codetouse);
183 if (!empty($conf->global->COMPANY_DIGITARIA_CLEAN_REGEX))
185 $codetouse = preg_replace(
'/'.$conf->global->COMPANY_DIGITARIA_CLEAN_REGEX.
'/',
'\1\2\3', $codetouse);
188 $this->
code = $prefix.strtoupper(substr($codetouse, 0, $width));
189 dol_syslog(
"mod_codecompta_digitaria::get_code search code proposed=".$this->
code);
192 if (!isset($conf->global->COMPANY_DIGITARIA_UNIQUE_CODE) || !empty($conf->global->COMPANY_DIGITARIA_UNIQUE_CODE))
196 while ($disponibility <> 0 && $i < 100) {
197 $widthsupplier = $this->supplieraccountancycodecharacternumber;
198 $widthcustomer = $this->customeraccountancycodecharacternumber;
203 if ($i >= 10 && $i <= 99) {
207 if ($type ==
'supplier') {
208 $this->
code = $prefix.strtoupper(substr($codetouse, 0, $widthsupplier - $a)).$i;
209 } elseif ($type ==
'customer') {
210 $this->
code = $prefix.strtoupper(substr($codetouse, 0, $widthcustomer - $a)).$i;
221 if ($disponibility == 0) {
238 if ($type ==
'supplier')
240 $typethirdparty =
'code_compta_fournisseur';
241 } elseif ($type ==
'customer')
243 $typethirdparty =
'code_compta';
245 $this->error =
'Bad value for parameter type';
249 $sql =
"SELECT ".$typethirdparty.
" FROM ".MAIN_DB_PREFIX.
"societe";
250 $sql .=
" WHERE ".$typethirdparty.
" = '".$db->escape($code).
"'";
252 $resql = $db->query($sql);
255 if ($db->num_rows(
$resql) == 0)
257 dol_syslog(
"mod_codecompta_digitaria::checkIfAccountancyCodeIsAlreadyUsed '".$code.
"' available");
260 dol_syslog(
"mod_codecompta_digitaria::checkIfAccountancyCodeIsAlreadyUsed '".$code.
"' not available");
264 $this->error = $db->error().
" sql=".$sql;
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
if(!empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'] country if(!empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'] typent code
$conf db name
Only used if Module[ID]Name translation string is not found.
Parent class for third parties accountancy code generators.
getExample($langs, $objsoc=0, $type=-1)
Return an example of result returned by getNextValue.
__construct()
Constructor.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
get_code($db, $societe, $type= '')
Set accountancy account code for a third party into this->code.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
checkIfAccountancyCodeIsAlreadyUsed($db, $code, $type= '')
Check accountancy account code for a third party into this->code.
Class to manage accountancy code of thirdparties with Digitaria rules.
info($langs)
Return description of module.