83 if (!isset($conf->global->COMPANY_DIGITARIA_MASK_CUSTOMER) || trim($conf->global->COMPANY_DIGITARIA_MASK_CUSTOMER) ==
'') {
84 $conf->global->COMPANY_DIGITARIA_MASK_CUSTOMER =
'411';
86 if (!isset($conf->global->COMPANY_DIGITARIA_MASK_SUPPLIER) || trim($conf->global->COMPANY_DIGITARIA_MASK_SUPPLIER) ==
'') {
87 $conf->global->COMPANY_DIGITARIA_MASK_SUPPLIER =
'401';
89 $this->prefixcustomeraccountancycode =
getDolGlobalString(
'COMPANY_DIGITARIA_MASK_CUSTOMER');
90 $this->prefixsupplieraccountancycode =
getDolGlobalString(
'COMPANY_DIGITARIA_MASK_SUPPLIER');
92 if (!isset($conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_CUSTOMER) || trim($conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_CUSTOMER) ==
'') {
93 $conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_CUSTOMER =
'5';
95 if (!isset($conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_SUPPLIER) || trim($conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_SUPPLIER) ==
'') {
96 $conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_SUPPLIER =
'5';
98 $this->customeraccountancycodecharacternumber =
getDolGlobalString(
'COMPANY_DIGITARIA_MASK_NBCHARACTER_CUSTOMER');
99 $this->supplieraccountancycodecharacternumber =
getDolGlobalString(
'COMPANY_DIGITARIA_MASK_NBCHARACTER_SUPPLIER');
113 $texte =
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
114 $texte .=
'<input type="hidden" name="token" value="'.newToken().
'">';
115 $texte .=
'<input type="hidden" name="page_y" value="">';
116 $texte .=
'<input type="hidden" name="action" value="setModuleOptions">';
117 $texte .=
'<input type="hidden" name="param1" value="COMPANY_DIGITARIA_MASK_SUPPLIER">';
118 $texte .=
'<input type="hidden" name="param2" value="COMPANY_DIGITARIA_MASK_CUSTOMER">';
119 $texte .=
'<input type="hidden" name="param3" value="COMPANY_DIGITARIA_MASK_NBCHARACTER_SUPPLIER">';
120 $texte .=
'<input type="hidden" name="param4" value="COMPANY_DIGITARIA_MASK_NBCHARACTER_CUSTOMER">';
121 $texte .=
'<input type="hidden" name="param5" value="COMPANY_DIGITARIA_CLEAN_WORDS">';
122 $texte .=
'<table class="nobordernopadding centpercent">';
123 $s1 = $form->textwithpicto(
'<input type="text" class="flat" size="4" name="value1" value="' .
getDolGlobalString(
'COMPANY_DIGITARIA_MASK_SUPPLIER').
'">', $tooltip, 1,
'help',
'valignmiddle', 0, 3, $this->
name);
124 $s2 = $form->textwithpicto(
'<input type="text" class="flat" size="4" name="value2" value="' .
getDolGlobalString(
'COMPANY_DIGITARIA_MASK_CUSTOMER').
'">', $tooltip, 1,
'help',
'valignmiddle', 0, 3, $this->
name);
125 $s3 = $form->textwithpicto(
'<input type="text" class="flat" size="2" name="value3" value="' .
getDolGlobalString(
'COMPANY_DIGITARIA_MASK_NBCHARACTER_SUPPLIER').
'">', $tooltip, 1,
'help',
'valignmiddle', 0, 3, $this->
name);
126 $s4 = $form->textwithpicto(
'<input type="text" class="flat" size="2" name="value4" value="' .
getDolGlobalString(
'COMPANY_DIGITARIA_MASK_NBCHARACTER_CUSTOMER').
'">', $tooltip, 1,
'help',
'valignmiddle', 0, 3, $this->
name);
127 $texte .=
'<tr><td>';
129 $texte .= $langs->trans(
"ModuleCompanyCodeCustomer".$this->
name,
'{s2}',
'{s4}').
"<br>\n";
130 $texte .= $langs->trans(
"ModuleCompanyCodeSupplier".$this->
name,
'{s1}',
'{s3}').
"<br>\n";
131 $texte = str_replace(array(
'{s1}',
'{s2}',
'{s3}',
'{s4}'), array($s1, $s2, $s3, $s4), $texte);
134 if (!isset($conf->global->COMPANY_DIGITARIA_REMOVE_SPECIAL) ||
getDolGlobalString(
'COMPANY_DIGITARIA_REMOVE_SPECIAL')) {
135 $texte .= $langs->trans(
'RemoveSpecialChars').
' = '.
yn(1).
"<br>\n";
139 $texte .= $langs->trans(
'COMPANY_DIGITARIA_CLEAN_REGEX').
' = ' .
getDolGlobalString(
'COMPANY_DIGITARIA_CLEAN_REGEX').
"<br>\n";
143 $texte .= $langs->trans(
'DuplicateForbidden').
' = '.
yn(0).
"<br>\n";
146 $texte .=
'<td class="right"><input type="submit" class="button button-edit reposition smallpaddingimp" name="modify" value="'.$langs->trans(
"Modify").
'"></td>';
149 $texte .=
'<tr><td>';
152 $texthelp = $langs->trans(
"RemoveSpecialWordsHelp");
153 $texttitle = $langs->trans(
"RemoveSpecialWords");
155 $texte .= $form->textwithpicto($texttitle, $texthelp, 1,
'help',
'', 1);
157 $texte .=
'<textarea class="flat textareafordir" spellcheck="false" cols="60" name="value5">';
159 $texte .= $conf->global->COMPANY_DIGITARIA_CLEAN_WORDS;
161 $texte .=
'</textarea>';
162 $texte .=
'</tr></table>';
177 public function getExample($langs =
null, $objsoc =
'', $type = -1)
181 $langs = $GLOBALS[
'langs'];
182 '@phan-var-force Translate $langs';
185 $s = $langs->trans(
"ThirdPartyName").
": ".
$mysoc->name;
188 if (!isset($conf->global->COMPANY_DIGITARIA_REMOVE_SPECIAL)) {
189 $thirdpartylabelexample = (string) preg_replace(
'/([^a-z0-9])/i',
'',
$mysoc->name);
191 $thirdpartylabelexample =
'';
194 $s .= $this->prefixcustomeraccountancycode.strtoupper(substr($thirdpartylabelexample, 0, (
int) $this->customeraccountancycodecharacternumber));
196 $s .= $this->prefixsupplieraccountancycode.strtoupper(substr($thirdpartylabelexample, 0, (
int) $this->supplieraccountancycodecharacternumber));
209 public function get_code($db, $societe, $type =
'')
218 if (is_object($societe)) {
219 dol_syslog(
"mod_codecompta_digitaria::get_code search code for type=".$type.
" & company=".(!empty($societe->name) ? $societe->name :
''));
221 if ($type ==
'supplier') {
222 $codetouse = (string) $societe->name;
223 $prefix = $this->prefixsupplieraccountancycode;
224 $width = $this->supplieraccountancycodecharacternumber;
225 } elseif ($type ==
'customer') {
226 $codetouse = (string) $societe->name;
227 $prefix = $this->prefixcustomeraccountancycode;
228 $width = $this->customeraccountancycodecharacternumber;
230 $this->error =
'Bad value for parameter type';
237 $codetouse = str_replace($cleanWords,
"", $codetouse);
240 if (!isset($conf->global->COMPANY_DIGITARIA_REMOVE_SPECIAL) ||
getDolGlobalString(
'COMPANY_DIGITARIA_REMOVE_SPECIAL')) {
241 $codetouse = (string) preg_replace(
'/([^a-z0-9])/i',
'', $codetouse);
245 $codetouse = (string) preg_replace(
'/' .
getDolGlobalString(
'COMPANY_DIGITARIA_CLEAN_REGEX').
'/',
'\1\2\3', $codetouse);
248 $this->code = $prefix.strtoupper(substr($codetouse, 0, (
int) $width));
249 dol_syslog(
"mod_codecompta_digitaria::get_code search code proposed=".$this->code, LOG_DEBUG);
255 while ($disponibility != 0 && $i < 1000) {
256 $widthsupplier = $this->supplieraccountancycodecharacternumber;
257 $widthcustomer = $this->customeraccountancycodecharacternumber;
261 } elseif ($i <= 99) {
267 if ($type ==
'supplier') {
268 $this->code = $prefix.strtoupper(substr($codetouse, 0, (
int) $widthsupplier - $a)).$i;
269 } elseif ($type ==
'customer') {
270 $this->code = $prefix.strtoupper(substr($codetouse, 0, (
int) $widthcustomer - $a)).$i;
279 if ($disponibility == 0) {