-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
eldy
merged 4 commits into
Dolibarr:develop
from
rycks:develop_new_codeclient_elephant_option
Jul 21, 2024
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -93,6 +94,8 @@ | |
$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")); | ||
|
@@ -114,6 +117,33 @@ | |
$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); | ||
Check warning on line 142 in htdocs/core/modules/societe/mod_codeclient_elephant.php
|
||
$texte .= '</div>'; | ||
$texte .= '</td>'; | ||
$texte .= '</tr>'; | ||
|
||
$texte .= '</table>'; | ||
$texte .= '</form>'; | ||
|
||
|
@@ -271,6 +301,9 @@ | |
$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'))) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it better like this :
$selectdisabled = ((!empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity) ? 1 : 0);
$texte .= $form->selectDate($dateinput, 'value3', 0, 0, 1, '', 1, 1, $selectdisabled);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@frederic34 ... i really can't see that your code could do the same thing as mine ?
my objective is:
that is an elegant way to handle situation where people want to "remove" data: with classic input field if the field is empty on POST dolibarr do not "delete" / "set to empty" value (i think, that was the situation last time i check)...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$disabled returns a string but selectDate wait for an int
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably want to do
$disabled ? 1 : 0