diff --git a/htdocs/core/modules/societe/mod_codeclient_elephant.php b/htdocs/core/modules/societe/mod_codeclient_elephant.php index f83458dc55825..c9d4e01d5733e 100644 --- a/htdocs/core/modules/societe/mod_codeclient_elephant.php +++ b/htdocs/core/modules/societe/mod_codeclient_elephant.php @@ -5,7 +5,8 @@ * Copyright (C) 2011 Juanjo Menent * Copyright (C) 2013-2018 Philippe Grand * Copyright (C) 2020-2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024 MDW + * Copyright (C) 2024 Eric Seigne * * 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 @@ -93,6 +94,8 @@ public function info($langs) $texte .= ''; $texte .= ''; $texte .= ''; + $texte .= ''; + $texte .= ''; $texte .= ''; $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("ThirdParty"), $langs->transnoentities("ThirdParty")); @@ -114,6 +117,33 @@ public function info($langs) $texte .= ''; $texte .= ''; + // 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 .= ''; + $texte .= ''; + $texte .= ''; + $texte .= '
'.$form->textwithpicto('', $tooltip, 1, 1).'
'.$langs->trans("DateStartThatModel").' ('.$langs->trans("DateStartThatModelHelp").'):'; + $texte .= ''; + $texte .= ''; + $texte .= '
'; $texte .= ''; @@ -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'))) { diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index ac5c3f815cb7c..d94e0b7494a9a 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -372,6 +372,8 @@ GenericMaskCodes4b=Example on third party created on 2023-01-31:
GenericMaskCodes4c=Example on product created on 2023-01-31:
GenericMaskCodes5=ABC{yy}{mm}-{000000} will give ABC2301-000099
{0000+100@1}-ZZZ/{dd}/XXX will give 0199-ZZZ/31/XXX
IN{yy}{mm}-{0000}-{t} will give IN2301-0099-A 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 %s on port %s ServerNotAvailableOnIPOrPort=Server is not available at address %s on port %s DoTestServerAvailability=Test server connectivity