Fix import key not visible

This commit is contained in:
Laurent Destailleur 2026-02-28 15:34:30 +01:00
parent 58909659f0
commit 302dcd4aa0
3 changed files with 40 additions and 43 deletions

View file

@ -997,7 +997,7 @@ class ModeleImports
* @param string $importid Import key
* @param string[] $updatekeys Array of keys used to update first before insert
* @param int $recordpositionbase 0 when $arrayrecord starts at 0, 1 when starts at 1
* @return int Return integer <0 if KO, >0 if OK
* @return int Return integer <0 if KO, >0 if OK
*/
protected function commonImportInsert($arrayrecord, $array_match_file_to_database, $objimport, $maxfields, $importid, $updatekeys, $recordpositionbase = 0)
{

View file

@ -179,7 +179,6 @@ $objmodelimport = new ModeleImports();
$form = new Form($db);
$htmlother = new FormOther($db);
$formfile = new FormFile($db);
// Init $array_match_file_to_database from _SESSION
if (empty($array_match_file_to_database)) {
@ -1649,25 +1648,25 @@ if ($step == 4 && $datatoimport) {
print $langs->trans("ImportFromToLine");
print '</td><td>';
if ($action == 'launchsimu') {
print '<input type="number" class="maxwidth50 right" name="excludefirstlinebis" disabled="disabled" value="'.$excludefirstline.'">';
print '<input type="number" class="maxwidth50 right valignmiddle" name="excludefirstlinebis" disabled="disabled" value="'.$excludefirstline.'">';
print '<input type="hidden" name="excludefirstline" value="'.$excludefirstline.'">';
} else {
print '<input type="number" class="maxwidth50 right" name="excludefirstline" value="'.$excludefirstline.'">';
print '<input type="number" class="maxwidth50 right valignmiddle" name="excludefirstline" value="'.$excludefirstline.'">';
print $form->textwithpicto("", $langs->trans("SetThisValueTo2ToExcludeFirstLine"));
}
print ' - ';
if ($action == 'launchsimu') {
print '<input type="text" class="maxwidth50" name="endatlinenbbis" disabled="disabled" value="'.$endatlinenb.'">';
print '<input type="text" class="maxwidth50 valignmiddle" name="endatlinenbbis" disabled="disabled" value="'.$endatlinenb.'">';
print '<input type="hidden" name="endatlinenb" value="'.$endatlinenb.'">';
} else {
print '<input type="text" class="maxwidth50" name="endatlinenb" value="'.$endatlinenb.'">';
print '<input type="text" class="maxwidth50 valignmiddle" name="endatlinenb" value="'.$endatlinenb.'">';
print $form->textwithpicto("", $langs->trans("KeepEmptyToGoToEndOfFile"));
}
if ($action == 'launchsimu') {
print ' &nbsp; <a href="'.$_SERVER["PHP_SELF"].'?step=4'.$param.'">'.$langs->trans("Modify").'</a>';
}
if ($excludefirstline == 2) {
print $form->textwithpicto("", $langs->trans("WarningFirstImportedLine", $excludefirstline), 1, 'warning', "warningexcludefirstline");
print $form->textwithpicto("", $langs->trans("WarningFirstImportedLine", $excludefirstline), 1, 'warning', "warningexcludefirstline valignmiddle");
print '<script>
$( document ).ready(function() {
$("input[name=\'excludefirstline\']").on("change",function(){
@ -1709,31 +1708,6 @@ if ($step == 4 && $datatoimport) {
echo '</pre>';*/
print '</td></tr>';
// Trigger mode
print '<tr><td>';
print $langs->trans("ImportTriggerModeLabel");
print '</td><td>';
$triggerModeChoices = array(
'strict_line' => $langs->trans("ImportTriggerModeStrictLine"),
'fast_bulk' => $langs->trans("ImportTriggerModeFastBulk"),
);
if ($action == 'launchsimu') {
print dol_escape_htmltag($triggerModeChoices[$importtriggermode] ?? $importtriggermode);
print '<input type="hidden" name="importtriggermode" value="'.dol_escape_htmltag($importtriggermode).'">';
print ' &nbsp; <a href="'.$_SERVER["PHP_SELF"].'?step=4'.$param.'">'.$langs->trans("Modify").'</a>';
} else {
print $form->selectarray('importtriggermode', $triggerModeChoices, $importtriggermode, 0);
}
print '<br><span class="opacitymedium">';
print $langs->trans("ImportTriggerModeHint");
print '</span>';
if ($importtriggermode === 'fast_bulk') {
print '<br><span class="warning">';
print $langs->trans("ImportTriggerModeFastBulkWarning");
print '</span>';
}
print '</td></tr>';
print '</table>';
print '</div>';
@ -1809,6 +1783,28 @@ if ($step == 4 && $datatoimport) {
print count($listfields) ? (implode(', ', $listfields)) : $langs->trans("Error");
print '</td></tr>';
// Trigger mode
print '<tr><td>';
print $form->textwithpicto($langs->trans("ImportTriggerModeLabel"), $langs->trans("ImportTriggerModeHint"));
print '</td><td>';
$triggerModeChoices = array(
'strict_line' => $langs->trans("ImportTriggerModeStrictLine"),
'fast_bulk' => $langs->trans("ImportTriggerModeFastBulk"),
);
if ($action == 'launchsimu') {
print dol_escape_htmltag($triggerModeChoices[$importtriggermode] ?? $importtriggermode);
print '<input type="hidden" name="importtriggermode" value="'.dol_escape_htmltag($importtriggermode).'">';
print ' &nbsp; <a href="'.$_SERVER["PHP_SELF"].'?step=4'.$param.'">'.$langs->trans("Modify").'</a>';
} else {
print $form->selectarray('importtriggermode', $triggerModeChoices, $importtriggermode, 0);
}
if ($importtriggermode === 'fast_bulk') {
print '<br><span class="warning">';
print $langs->trans("ImportTriggerModeFastBulkWarning");
print '</span>';
}
print '</td></tr>';
print '</table>';
print '</div>';
@ -1833,7 +1829,8 @@ if ($step == 4 && $datatoimport) {
print '<div class="warning">';
print '<b>'.$langs->trans("ImportTriggerModeSimulationWarningTitle").'</b><br>';
print $langs->trans("ImportTriggerModeSimulationWarning");
print '</div><br>';
print '</div>';
// Launch import
$arrayoferrors = array();
$arrayofwarnings = array();
@ -1947,7 +1944,7 @@ if ($step == 4 && $datatoimport) {
// Show OK
if (!count($arrayoferrors) && !count($arrayofwarnings)) {
print '<br>';
//print '<br>';
print '<div class="info">';
print '<div class=""><b>'.$langs->trans("ResultOfSimulationNoError").'</b></div>';
print $langs->trans("NbInsertSim", empty($obj->nbinsert) ? 0 : $obj->nbinsert).'<br>';
@ -1955,7 +1952,7 @@ if ($step == 4 && $datatoimport) {
print '</div>';
print '<br>';
} else {
print '<br>';
//print '<br>';
print '<div class="warning">';
print $langs->trans("NbOfLinesOK", $nbok).'...<br>';
print '</div>';

View file

@ -79,7 +79,7 @@ FieldsTarget=Targeted fields
FieldTarget=Targeted field
FieldSource=Source field
NbOfSourceLines=Number of lines in source file
NowClickToTestTheImport=Check that the file format (field and string delimiters) of your file matches the options shown and that you have omitted the header line, or these will be flagged as errors in the following simulation.<br>Click on the "<b>%s</b>" button to run a check of the file structure/contents and simulate the import process.<br><b>No data will be changed in your database</b>.
NowClickToTestTheImport=Check that the file format (field and string delimiters) of your file matches the options shown and that you have omitted the header line, or these will be flagged as errors in the following simulation.<br>Click on the "<b>%s</b>" button to simulate the import process.<br><b>No data will be changed in your database</b>.
RunSimulateImportFile=Run Import Simulation
FieldNeedSource=This field requires data from the source file
SomeMandatoryFieldHaveNoSource=Some mandatory fields have no source from data file
@ -127,7 +127,7 @@ EndAtLineNb=End at line number
ImportFromToLine=Limit range (From - To). Eg. to omit header line(s).
SetThisValueTo2ToExcludeFirstLine=For example, set this value to 3 to exclude the 2 first lines.<br>If the header lines are NOT omitted, this will result in multiple errors in the Import Simulation.
KeepEmptyToGoToEndOfFile=Keep this field empty to process all lines to the end of the file.
SelectPrimaryColumnsForUpdateAttempt=Select column(s) to use as primary key for an UPDATE import
SelectPrimaryColumnsForUpdateAttempt=Select column(s) to use as primary key to check if the record already exists. If a record is already found with this key(s), an UPDATE will be performed instead of an INSERT.
UpdateNotYetSupportedForThisImport=Update is not supported for this type of import (only insert)
NoUpdateAttempt=No update attempt was performed, only insert
ImportDataset_user_1=Users (employees or not) and properties
@ -155,15 +155,15 @@ NumberOfLinesLimited=Number of lines limited
ErrorFileLinesReachEOF=File has %s lines. However we reach the end of file or an empty line at record %s. This may occurs when some records are split onto several lines and not correctly delimited by the "Char delimiter", or if there is line with no data on all fields.
ImportInProcess=Import of file %s is in process
ImportTriggerModeLabel=Import mode
ImportTriggerModeStrictLine=Secure mode (slower) - applies all automatic actions on each imported line
ImportTriggerModeFastBulk=Fast mode (faster) - does not apply automatic actions line by line
ImportTriggerModeHint=Choose Secure mode if you use modules or automatic business actions (notifications, synchronizations, linked updates, etc.).
ImportTriggerModeFastBulkWarning=Warning: in Fast mode, automatic actions are not executed for each line.
ImportTriggerModeStrictLine=Secured mode (slower) - applies all automatic actions on each imported line
ImportTriggerModeFastBulk=Fast mode (faster) - does not apply automatic actions on lines
ImportTriggerModeHint=Use the Secured mode to guarantee that automatic business actions (usually provided by some modules) are done (triggered controls, notifications, synchronizations, linked updates, etc.).<br>Use the fast mode if you understand what it means.
ImportTriggerModeFastBulkWarning=Warning: in Fast mode, automatic actions (triggered controls, notifications, synchronizations) are not executed.
ImportTriggerModeSimulationWarningTitle=Simulation mode
ImportTriggerModeSimulationWarning=Simulation never executes automatic import actions.
ImportTriggerModeSimulationInfo=Simulation: no automatic action is executed (this is expected).
ImportTriggerModeSummaryFast=Fast mode (faster)
ImportTriggerModeSummaryFast=Fast mode (dangerous but faster)
ImportTriggerModeSummaryStrict=Secure mode (automatic actions on each line)
ImportTriggerModeSummaryHint=Fast mode is recommended for high volumes. Secure mode is recommended when automatic business rules are required.
ImportTriggerModeSummaryHint=Fast mode is not recommended. Use it only for high volumes if secure mode is too slow and if you are sure that you can ignore triggered business event.
ImportTriggerModeFastBulkFinalWarningTitle=Fast mode
ImportTriggerModeFastBulkFinalWarning=During this import, automatic actions will not be executed line by line.