75 if (!isset($conf->global->COMPANY_DIGITARIA_MASK_CUSTOMER) || trim($conf->global->COMPANY_DIGITARIA_MASK_CUSTOMER) ==
'') {
76 $conf->global->COMPANY_DIGITARIA_MASK_CUSTOMER =
'411';
78 if (!isset($conf->global->COMPANY_DIGITARIA_MASK_SUPPLIER) || trim($conf->global->COMPANY_DIGITARIA_MASK_SUPPLIER) ==
'') {
79 $conf->global->COMPANY_DIGITARIA_MASK_SUPPLIER =
'401';
81 $this->prefixcustomeraccountancycode =
getDolGlobalString(
'COMPANY_DIGITARIA_MASK_CUSTOMER');
82 $this->prefixsupplieraccountancycode =
getDolGlobalString(
'COMPANY_DIGITARIA_MASK_SUPPLIER');
84 if (!isset($conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_CUSTOMER) || trim($conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_CUSTOMER) ==
'') {
85 $conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_CUSTOMER =
'5';
87 if (!isset($conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_SUPPLIER) || trim($conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_SUPPLIER) ==
'') {
88 $conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_SUPPLIER =
'5';
90 $this->customeraccountancycodecharacternumber =
getDolGlobalString(
'COMPANY_DIGITARIA_MASK_NBCHARACTER_CUSTOMER');
91 $this->supplieraccountancycodecharacternumber =
getDolGlobalString(
'COMPANY_DIGITARIA_MASK_NBCHARACTER_SUPPLIER');
105 $texte =
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
106 $texte .=
'<input type="hidden" name="token" value="'.newToken().
'">';
107 $texte .=
'<input type="hidden" name="page_y" value="">';
108 $texte .=
'<input type="hidden" name="action" value="setModuleOptions">';
109 $texte .=
'<input type="hidden" name="param1" value="COMPANY_DIGITARIA_MASK_SUPPLIER">';
110 $texte .=
'<input type="hidden" name="param2" value="COMPANY_DIGITARIA_MASK_CUSTOMER">';
111 $texte .=
'<input type="hidden" name="param3" value="COMPANY_DIGITARIA_MASK_NBCHARACTER_SUPPLIER">';
112 $texte .=
'<input type="hidden" name="param4" value="COMPANY_DIGITARIA_MASK_NBCHARACTER_CUSTOMER">';
113 $texte .=
'<input type="hidden" name="param5" value="COMPANY_DIGITARIA_CLEAN_WORDS">';
114 $texte .=
'<table class="nobordernopadding centpercent">';
115 $s1 = $form->textwithpicto(
'<input type="text" class="flat" size="4" name="value1" value="' .
getDolGlobalString(
'COMPANY_DIGITARIA_MASK_SUPPLIER').
'">', $tooltip, 1, 1);
116 $s2 = $form->textwithpicto(
'<input type="text" class="flat" size="4" name="value2" value="' .
getDolGlobalString(
'COMPANY_DIGITARIA_MASK_CUSTOMER').
'">', $tooltip, 1, 1);
117 $s3 = $form->textwithpicto(
'<input type="text" class="flat" size="2" name="value3" value="' .
getDolGlobalString(
'COMPANY_DIGITARIA_MASK_NBCHARACTER_SUPPLIER').
'">', $tooltip, 1, 1);
118 $s4 = $form->textwithpicto(
'<input type="text" class="flat" size="2" name="value4" value="' .
getDolGlobalString(
'COMPANY_DIGITARIA_MASK_NBCHARACTER_CUSTOMER').
'">', $tooltip, 1, 1);
119 $texte .=
'<tr><td>';
121 $texte .= $langs->trans(
"ModuleCompanyCodeCustomer".$this->
name,
'{s2}',
'{s4}').
"<br>\n";
122 $texte .= $langs->trans(
"ModuleCompanyCodeSupplier".$this->
name,
'{s1}',
'{s3}').
"<br>\n";
123 $texte = str_replace(array(
'{s1}',
'{s2}',
'{s3}',
'{s4}'), array($s1, $s2, $s3, $s4), $texte);
126 if (!isset($conf->global->COMPANY_DIGITARIA_REMOVE_SPECIAL) || !empty($conf->global->COMPANY_DIGITARIA_REMOVE_SPECIAL)) {
127 $texte .= $langs->trans(
'RemoveSpecialChars').
' = '.
yn(1).
"<br>\n";
131 $texte .= $langs->trans(
'COMPANY_DIGITARIA_CLEAN_REGEX').
' = ' .
getDolGlobalString(
'COMPANY_DIGITARIA_CLEAN_REGEX').
"<br>\n";
135 $texte .= $langs->trans(
'DuplicateForbidden').
' = '.
yn(0).
"<br>\n";
138 $texte .=
'<td class="right"><input type="submit" class="button button-edit reposition smallpaddingimp" name="modify" value="'.$langs->trans(
"Modify").
'"></td>';
141 $texte .=
'<tr><td>';
144 $texthelp = $langs->trans(
"RemoveSpecialWordsHelp");
145 $texttitle = $langs->trans(
"RemoveSpecialWords");
147 $texte .= $form->textwithpicto($texttitle, $texthelp, 1,
'help',
'', 1);
149 $texte .=
'<textarea class="flat" cols="60" name="value5">';
151 $texte .= $conf->global->COMPANY_DIGITARIA_CLEAN_WORDS;
153 $texte .=
'</textarea>';
154 $texte .=
'</tr></table>';
171 global $conf, $mysoc;
173 $s = $langs->trans(
"ThirdPartyName").
": ".$mysoc->name;
176 if (!isset($conf->global->COMPANY_DIGITARIA_REMOVE_SPECIAL)) {
177 $thirdpartylabelexample = preg_replace(
'/([^a-z0-9])/i',
'', $mysoc->name);
180 $s .= $this->prefixcustomeraccountancycode.strtoupper(substr($thirdpartylabelexample, 0, (
int) $this->customeraccountancycodecharacternumber));
182 $s .= $this->prefixsupplieraccountancycode.strtoupper(substr($thirdpartylabelexample, 0, (
int) $this->supplieraccountancycodecharacternumber));
195 public function get_code($db, $societe, $type =
'')
204 if (is_object($societe)) {
205 dol_syslog(
"mod_codecompta_digitaria::get_code search code for type=".$type.
" & company=".(!empty($societe->name) ? $societe->name :
''));
207 if ($type ==
'supplier') {
208 $codetouse = $societe->name;
209 $prefix = $this->prefixsupplieraccountancycode;
210 $width = $this->supplieraccountancycodecharacternumber;
211 } elseif ($type ==
'customer') {
212 $codetouse = $societe->name;
213 $prefix = $this->prefixcustomeraccountancycode;
214 $width = $this->customeraccountancycodecharacternumber;
216 $this->error =
'Bad value for parameter type';
223 $codetouse = str_replace($cleanWords,
"", $codetouse);
226 if (!isset($conf->global->COMPANY_DIGITARIA_REMOVE_SPECIAL) ||
getDolGlobalString(
'COMPANY_DIGITARIA_REMOVE_SPECIAL')) {
227 $codetouse = preg_replace(
'/([^a-z0-9])/i',
'', $codetouse);
231 $codetouse = preg_replace(
'/' .
getDolGlobalString(
'COMPANY_DIGITARIA_CLEAN_REGEX').
'/',
'\1\2\3', $codetouse);
234 $this->code = $prefix.strtoupper(substr($codetouse, 0, (
int) $width));
235 dol_syslog(
"mod_codecompta_digitaria::get_code search code proposed=".$this->code, LOG_DEBUG);
241 while ($disponibility != 0 && $i < 1000) {
242 $widthsupplier = $this->supplieraccountancycodecharacternumber;
243 $widthcustomer = $this->customeraccountancycodecharacternumber;
248 if ($i >= 10 && $i <= 99) {
251 if ($i >= 100 && $i <= 999) {
255 if ($type ==
'supplier') {
256 $this->code = $prefix.strtoupper(substr($codetouse, 0, $widthsupplier - $a)).$i;
257 } elseif ($type ==
'customer') {
258 $this->code = $prefix.strtoupper(substr($codetouse, 0, $widthcustomer - $a)).$i;
267 if ($disponibility == 0) {