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>';
169 public function getExample($langs =
null, $objsoc =
'', $type = -1)
171 global $conf, $mysoc;
173 $langs = $GLOBALS[
'langs'];
174 '@phan-var-force Translate $langs';
177 $s = $langs->trans(
"ThirdPartyName").
": ".$mysoc->name;
180 if (!isset($conf->global->COMPANY_DIGITARIA_REMOVE_SPECIAL)) {
181 $thirdpartylabelexample = preg_replace(
'/([^a-z0-9])/i',
'', $mysoc->name);
184 $s .= $this->prefixcustomeraccountancycode.strtoupper(substr($thirdpartylabelexample, 0, (
int) $this->customeraccountancycodecharacternumber));
186 $s .= $this->prefixsupplieraccountancycode.strtoupper(substr($thirdpartylabelexample, 0, (
int) $this->supplieraccountancycodecharacternumber));
199 public function get_code($db, $societe, $type =
'')
208 if (is_object($societe)) {
209 dol_syslog(
"mod_codecompta_digitaria::get_code search code for type=".$type.
" & company=".(!empty($societe->name) ? $societe->name :
''));
211 if ($type ==
'supplier') {
212 $codetouse = $societe->name;
213 $prefix = $this->prefixsupplieraccountancycode;
214 $width = $this->supplieraccountancycodecharacternumber;
215 } elseif ($type ==
'customer') {
216 $codetouse = $societe->name;
217 $prefix = $this->prefixcustomeraccountancycode;
218 $width = $this->customeraccountancycodecharacternumber;
220 $this->error =
'Bad value for parameter type';
227 $codetouse = str_replace($cleanWords,
"", $codetouse);
230 if (!isset($conf->global->COMPANY_DIGITARIA_REMOVE_SPECIAL) ||
getDolGlobalString(
'COMPANY_DIGITARIA_REMOVE_SPECIAL')) {
231 $codetouse = preg_replace(
'/([^a-z0-9])/i',
'', $codetouse);
235 $codetouse = preg_replace(
'/' .
getDolGlobalString(
'COMPANY_DIGITARIA_CLEAN_REGEX').
'/',
'\1\2\3', $codetouse);
238 $this->code = $prefix.strtoupper(substr($codetouse, 0, (
int) $width));
239 dol_syslog(
"mod_codecompta_digitaria::get_code search code proposed=".$this->code, LOG_DEBUG);
245 while ($disponibility != 0 && $i < 1000) {
246 $widthsupplier = $this->supplieraccountancycodecharacternumber;
247 $widthcustomer = $this->customeraccountancycodecharacternumber;
252 if ($i >= 10 && $i <= 99) {
255 if ($i >= 100 && $i <= 999) {
259 if ($type ==
'supplier') {
260 $this->code = $prefix.strtoupper(substr($codetouse, 0, (
int) $widthsupplier - $a)).$i;
261 } elseif ($type ==
'customer') {
262 $this->code = $prefix.strtoupper(substr($codetouse, 0, (
int) $widthcustomer - $a)).$i;
271 if ($disponibility == 0) {