Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NEW Accountancy - Model Digitaria - Add a way to clean some words when you generate thirdparty accounting account FPC22 #22772

Merged
merged 2 commits into from Nov 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 25 additions & 2 deletions htdocs/core/modules/societe/mod_codecompta_digitaria.php
Expand Up @@ -102,7 +102,8 @@ public function info($langs)
$texte .= '<input type="hidden" name="param2" value="COMPANY_DIGITARIA_MASK_CUSTOMER">';
$texte .= '<input type="hidden" name="param3" value="COMPANY_DIGITARIA_MASK_NBCHARACTER_SUPPLIER">';
$texte .= '<input type="hidden" name="param4" value="COMPANY_DIGITARIA_MASK_NBCHARACTER_CUSTOMER">';
$texte .= '<table class="nobordernopadding" width="100%">';
$texte .= '<input type="hidden" name="param5" value="COMPANY_DIGITARIA_CLEAN_WORDS">';
$texte .= '<table class="nobordernopadding centpercent">';
$s1 = $form->textwithpicto('<input type="text" class="flat" size="4" name="value1" value="'.$conf->global->COMPANY_DIGITARIA_MASK_SUPPLIER.'">', $tooltip, 1, 1);
$s2 = $form->textwithpicto('<input type="text" class="flat" size="4" name="value2" value="'.$conf->global->COMPANY_DIGITARIA_MASK_CUSTOMER.'">', $tooltip, 1, 1);
$s3 = $form->textwithpicto('<input type="text" class="flat" size="2" name="value3" value="'.$conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_SUPPLIER.'">', $tooltip, 1, 1);
Expand All @@ -127,7 +128,23 @@ public function info($langs)
}
$texte .= '</td>';
$texte .= '<td class="right"><input type="submit" class="button button-edit reposition" name="modify" value="'.$langs->trans("Modify").'"></td>';
$texte .= '</tr>';

$texte .= '<tr><td>';
$texte .= "<br>\n";

$texthelp = $langs->trans("RemoveSpecialWordsHelp");
$texttitle = $langs->trans("RemoveSpecialWords");

$texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
$texte .= "<br>\n";
$texte .= '<textarea class="flat" cols="60" name="value5">';
if (!empty($conf->global->COMPANY_DIGITARIA_CLEAN_WORDS)) {
$texte .= $conf->global->COMPANY_DIGITARIA_CLEAN_WORDS;
}
$texte .= '</textarea>';
$texte .= '</tr></table>';

$texte .= '</form>';

return $texte;
Expand Down Expand Up @@ -192,6 +209,11 @@ public function get_code($db, $societe, $type = '')
return -1;
}

// Clean declared words
if (!empty($conf->global->COMPANY_DIGITARIA_CLEAN_WORDS)) {
$cleanWords = explode(";", $conf->global->COMPANY_DIGITARIA_CLEAN_WORDS);
$codetouse = str_replace($cleanWords, "", $codetouse);
}
// Remove special char if COMPANY_DIGITARIA_REMOVE_SPECIAL is set to 1 or not set (default)
if (!isset($conf->global->COMPANY_DIGITARIA_REMOVE_SPECIAL) || !empty($conf->global->COMPANY_DIGITARIA_REMOVE_SPECIAL)) {
$codetouse = preg_replace('/([^a-z0-9])/i', '', $codetouse);
Expand All @@ -202,7 +224,7 @@ public function get_code($db, $societe, $type = '')
}

$this->code = $prefix.strtoupper(substr($codetouse, 0, $width));
dol_syslog("mod_codecompta_digitaria::get_code search code proposed=".$this->code);
dol_syslog("mod_codecompta_digitaria::get_code search code proposed=".$this->code, LOG_DEBUG);

// Unique index on code if COMPANY_DIGITARIA_UNIQUE_CODE is set to 1 or not set (default)
if (!isset($conf->global->COMPANY_DIGITARIA_UNIQUE_CODE) || !empty($conf->global->COMPANY_DIGITARIA_UNIQUE_CODE)) {
Expand Down Expand Up @@ -279,6 +301,7 @@ public function checkIfAccountancyCodeIsAlreadyUsed($db, $code, $type = '')
$sql = "SELECT " . $typethirdparty . " FROM " . MAIN_DB_PREFIX . "societe";
$sql .= " WHERE " . $typethirdparty . " = '" . $db->escape($code) . "'";
}
$sql .= " AND entity IN (".getEntity('societe').")";

$resql = $db->query($sql);
if ($resql) {
Expand Down
4 changes: 3 additions & 1 deletion htdocs/langs/en_US/admin.lang
Expand Up @@ -2059,6 +2059,8 @@ RemoveSpecialChars=Remove special characters
COMPANY_AQUARIUM_CLEAN_REGEX=Regex filter to clean value (COMPANY_AQUARIUM_CLEAN_REGEX)
COMPANY_DIGITARIA_CLEAN_REGEX=Regex filter to clean value (COMPANY_DIGITARIA_CLEAN_REGEX)
COMPANY_DIGITARIA_UNIQUE_CODE=Duplicate not allowed
RemoveSpecialWords=Clean certain words when generating sub-accounts for customers or suppliers
RemoveSpecialWordsHelp=Specify the words to be cleaned before calculating the customer or supplier account. Use a ";" between each word
GDPRContact=Data Protection Officer (DPO, Data Privacy or GDPR contact)
GDPRContactDesc=If you store personal data in your Information System, you can name the contact who is responsible for the General Data Protection Regulation here
HelpOnTooltip=Help text to show on tooltip
Expand Down Expand Up @@ -2335,4 +2337,4 @@ LimitsAndMitigation=Access limits and mitigation
DesktopsOnly=Desktops only
DesktopsAndSmartphones=Desktops et smartphones
AllowOnlineSign=Allow online signing
AllowExternalDownload=Allow external download (without login, using a shared link)
AllowExternalDownload=Allow external download (without login, using a shared link)