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 More option for elephant numbering rule #30273

Merged
merged 4 commits into from
Jul 21, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 34 additions & 1 deletion htdocs/core/modules/societe/mod_codeclient_elephant.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
* Copyright (C) 2011 Juanjo Menent <[email protected]>
* Copyright (C) 2013-2018 Philippe Grand <[email protected]>
* Copyright (C) 2020-2024 Frédéric France <[email protected]>
* Copyright (C) 2024 MDW <[email protected]>
* Copyright (C) 2024 MDW <[email protected]>
* Copyright (C) 2024 Eric Seigne <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -93,6 +94,8 @@ public function info($langs)
$texte .= '<input type="hidden" name="action" value="setModuleOptions">';
$texte .= '<input type="hidden" name="param1" value="COMPANY_ELEPHANT_MASK_CUSTOMER">';
$texte .= '<input type="hidden" name="param2" value="COMPANY_ELEPHANT_MASK_SUPPLIER">';
$texte .= '<input type="hidden" name="param3" value="COMPANY_ELEPHANT_DATE_START">';
$texte .= '<input type="hidden" name="param4" value="COMPANY_ELEPHANT_DATE_START_ENABLE">';
$texte .= '<table class="nobordernopadding" width="100%">';

$tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("ThirdParty"), $langs->transnoentities("ThirdParty"));
Expand All @@ -114,6 +117,33 @@ public function info($langs)
$texte .= '<td class="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="value2" value="'.getDolGlobalString('COMPANY_ELEPHANT_MASK_SUPPLIER').'"'.$disabled.'>', $tooltip, 1, 1).'</td>';
$texte .= '</tr>';

// Date of switch to that numbering model
$datedb = getDolGlobalString('COMPANY_ELEPHANT_DATE_START');
// After save, default dolibarr store data like displayed : 20/05/2024 and we need a timestamp -> override data
if (!empty($datedb)) {
if (!is_numeric($datedb) && GETPOSTISSET('value3')) {
if (GETPOST('value4') == 1) {
$dateinput = GETPOSTDATE('value3');
$res = dolibarr_set_const($this->db, 'COMPANY_ELEPHANT_DATE_START', $dateinput, 'chaine', 0, '', $conf->entity);
} else {
$res = dolibarr_set_const($this->db, 'COMPANY_ELEPHANT_DATE_START', '', 'chaine', 0, '', $conf->entity);
}
} else {
$dateinput = $datedb;
}
}
if (empty($dateinput)) {
$dateinput = dol_now();
}
$texte .= '<tr><td>'.$langs->trans("DateStartThatModel").' ('.$langs->trans("DateStartThatModelHelp").'):</td>';
$texte .= '<td class="" style="flex-direction: row;display: flex;">';
$texte .= '<input type="checkbox" onclick="let d=document.getElementById(\'elephantchoosedate\'); if(this.checked){d.style.cssText = \'display: block;\'}else{{d.style.cssText = \'display: none;\'}}" name="value4" value="1" style="float: left;"/>';
$texte .= '<div style="display: none;" id="elephantchoosedate" class="right">';
$texte .= $form->selectDate($dateinput, 'value3', 0, 0, 1, '', 1, 1, $disabled ? 1 : 0);
$texte .= '</div>';
$texte .= '</td>';
$texte .= '</tr>';

$texte .= '</table>';
$texte .= '</form>';

Expand Down Expand Up @@ -271,6 +301,9 @@ public function verif($db, &$code, $soc, $type)
$result = 0;
$code = strtoupper(trim($code));

if (getDolGlobalString('COMPANY_ELEPHANT_DATE_START_ENABLE') == 1 && $soc->date_creation < getDolGlobalString('COMPANY_ELEPHANT_DATE_START')) {
return -5;
}
if (empty($code) && $this->code_null && !getDolGlobalString('MAIN_COMPANY_CODE_ALWAYS_REQUIRED')) {
$result = 0;
} elseif (empty($code) && (!$this->code_null || getDolGlobalString('MAIN_COMPANY_CODE_ALWAYS_REQUIRED'))) {
Expand Down
2 changes: 2 additions & 0 deletions htdocs/langs/en_US/admin.lang
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,8 @@ GenericMaskCodes4b=<u>Example on third party created on 2023-01-31:</u><br>
GenericMaskCodes4c=<u>Example on product created on 2023-01-31:</u><br>
GenericMaskCodes5=<b>ABC{yy}{mm}-{000000}</b> will give <b>ABC2301-000099</b><br><b>{0000+100@1}-ZZZ/{dd}/XXX</b> will give <b>0199-ZZZ/31/XXX</b><br><b>IN{yy}{mm}-{0000}-{t}</b> will give <b>IN2301-0099-A</b> if the type of company is 'Responsable Inscripto' with code for type that is 'A_RI'
GenericNumRefModelDesc=Returns a customizable number according to a defined mask.
DateStartThatModel=Do not check customer numbers created before
DateStartThatModelHelp=You can disable elephant number check for customers created before a date (used for migration from an other erp for example). Let that field empty to check all customers numbers.
ServerAvailableOnIPOrPort=Server is available at address <b>%s</b> on port <b>%s</b>
ServerNotAvailableOnIPOrPort=Server is not available at address <b>%s</b> on port <b>%s</b>
DoTestServerAvailability=Test server connectivity
Expand Down