29require_once DOL_DOCUMENT_ROOT.
'/core/modules/societe/modules_societe.class.php';
40 public $name =
'Digitaria';
46 public $version =
'dolibarr';
51 public $prefixcustomeraccountancycode;
56 public $prefixsupplieraccountancycode;
61 public $position = 30;
70 public $customeraccountancycodecharacternumber;
74 public $supplieraccountancycodecharacternumber;
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) {
296 if ($type ==
'supplier') {
298 $typethirdparty =
'accountancy_code_supplier';
300 $typethirdparty =
'code_compta_fournisseur';
302 } elseif ($type ==
'customer') {
304 $typethirdparty =
'accountancy_code_customer';
306 $typethirdparty =
'code_compta';
309 $this->error =
'Bad value for parameter type';
314 $sql =
"SELECT " . $db->sanitize($typethirdparty) .
" FROM " . MAIN_DB_PREFIX .
"societe_perentity";
315 $sql .=
" WHERE " . $db->sanitize($typethirdparty) .
" = '" . $db->escape($code) .
"'";
317 $sql =
"SELECT " . $db->sanitize($typethirdparty) .
" FROM " . MAIN_DB_PREFIX .
"societe";
318 $sql .=
" WHERE " . $db->sanitize($typethirdparty) .
" = '" . $db->escape($code) .
"'";
320 $sql .=
" AND entity IN (".getEntity(
'societe').
")";
322 $resql = $db->query($sql);
324 if ($db->num_rows($resql) == 0) {
325 dol_syslog(
"mod_codecompta_digitaria::checkIfAccountancyCodeIsAlreadyUsed '".$code.
"' available");
328 dol_syslog(
"mod_codecompta_digitaria::checkIfAccountancyCodeIsAlreadyUsed '".$code.
"' not available");
332 $this->error = $db->error().
" sql=".$sql;
Parent class for third parties accountancy code generators.
Class to manage translations.
Class to manage accountancy code of thirdparties with Digitaria rules.
getExample($langs=null, $objsoc='', $type=-1)
Return an example of result returned by getNextValue.
get_code($db, $societe, $type='')
Set accountancy account code for a third party into this->code.
info($langs)
Return description of module.
__construct()
Constructor.
checkIfAccountancyCodeIsAlreadyUsed($db, $code, $type='')
Check accountancy account code for a third party into this->code.
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
$conf db name
Only used if Module[ID]Name translation string is not found.