diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index 52784558b45..38a540ca042 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -167,6 +167,7 @@ if (empty($array_match_file_to_database)) { } } + /* * Actions */ @@ -742,8 +743,8 @@ if ($step == 3 && $datatoimport) { if ($step == 4 && $datatoimport) { //var_dump($_SESSION["dol_array_match_file_to_database_select"]); $serialized_array_match_file_to_database = isset($_SESSION["dol_array_match_file_to_database_select"]) ? $_SESSION["dol_array_match_file_to_database_select"] : ''; - $array_match_file_to_database = array(); $fieldsarray = explode(',', $serialized_array_match_file_to_database); + $array_match_file_to_database = array(); // Same than $fieldsarray but with mapped value only (col1 => 's.fielda', col2 => 's.fieldb'...) foreach ($fieldsarray as $elem) { $tabelem = explode('=', $elem, 2); $key = $tabelem[0]; @@ -752,6 +753,11 @@ if ($step == 4 && $datatoimport) { $array_match_file_to_database[$key] = $val; } } + + //var_dump($serialized_array_match_file_to_database); + //var_dump($fieldsarray); + //var_dump($array_match_file_to_database); + $model = $format; $list = $objmodelimport->liste_modeles($db); @@ -853,20 +859,15 @@ if ($step == 4 && $datatoimport) { } // We found the key of targets that is at position pos $array_match_file_to_database[$pos] = $key; - if ($serialized_array_match_file_to_database) { - $serialized_array_match_file_to_database .= ','; - } - $serialized_array_match_file_to_database .= ($pos.'='.$key); break; } } $pos++; } - // Save the match array in session. We now will use the array in session. - $_SESSION["dol_array_match_file_to_database_select"] = $serialized_array_match_file_to_database; } $array_match_database_to_file = array_flip($array_match_file_to_database); - + //var_dump($array_match_database_to_file); + //var_dump($_SESSION["dol_array_match_file_to_database_select"]); $fieldstarget_tmp = array(); $arraykeysfieldtarget = array_keys($fieldstarget); @@ -1088,8 +1089,8 @@ if ($step == 4 && $datatoimport) { $optionsall = array(); foreach ($fieldstarget as $code => $line) { //var_dump($line); - $labeltoshow = $langs->trans($line["label"]); - $optionsall[$code] = array('label'=>$labeltoshow, 'required'=>(empty($line["required"]) ? 0 : 1), 'position'=>!empty($line['position']) ? $line['position'] : 0); + $labeltoshow = $langs->transnoentities($line["label"]); + $optionsall[$code] = array('labelkey'=>$line['label'], 'label'=>$labeltoshow, 'required'=>(empty($line["required"]) ? 0 : 1), 'position'=>!empty($line['position']) ? $line['position'] : 0); // TODO Get type from an new array into module descriptor. //$picto = 'email'; $picto = ''; @@ -1106,13 +1107,19 @@ if ($step == 4 && $datatoimport) { //var_dump($fieldstarget); //var_dump($optionsall); //exit; - /* - var_dump($_SESSION['dol_array_match_file_to_database']); - var_dump($_SESSION['dol_array_match_file_to_database_select']); - var_dump($optionsall); - var_dump($fieldssource); - var_dump($fieldstarget); - */ + + //var_dump($_SESSION['dol_array_match_file_to_database']); + //var_dump($_SESSION['dol_array_match_file_to_database_select']); + //exit; + //var_dump($optionsall); + //var_dump($fieldssource); + //var_dump($fieldstarget); + + $modetoautofillmapping = 'session'; // Use setup in session + if ($initialloadofstep4) { + $modetoautofillmapping = 'guess'; + } + //var_dump($modetoautofillmapping); print '
| => | '; print ''; - $modetoautofillmapping = 'session'; // Use setup in session - if ($initialloadofstep4) { - $modetoautofillmapping = 'guess'; - } //var_dump($_SESSION['dol_array_match_file_to_database_select']); - //var_dump($modetoautofillmapping); //var_dump($_SESSION['dol_array_match_file_to_database']); - //var_dump($modetoautofillmapping); - print ' | "; + $selectforline .= ''; + $selectforline .= ajax_combobox('selectorderimport_'.($i+1)); + + print $selectforline; + + print ''; print '';
$filecolumn = ($i + 1);
@@ -1317,18 +1325,21 @@ if ($step == 4 && $datatoimport) {
print ' console.log("Remove the disabled flag everywhere");'."\n";
print ' $("select.targetselectchange").not($( this )).find(\'option\').prop("disabled", false);'."\n"; // Enable all options
print ' arrayofselectedvalues = [];'."\n";
+
print ' $("select.targetselectchange").each(function(){'."\n";
print ' id = $(this).attr(\'id\')'."\n";
print ' value = $(this).val()'."\n";
- //print ' console.log("a selected value has been found for component "+id+" = "+value);'."\n";
+ print ' console.log("a selected value has been found for component "+id+" = "+value);'."\n";
print ' arrayofselectedvalues.push(value);'."\n";
print ' });'."\n";
- print ' console.log("List of all selected values");'."\n";
+
+ print ' console.log("List of all selected values arrayofselectedvalues");'."\n";
print ' console.log(arrayofselectedvalues);'."\n";
print ' console.log("Set the option to disabled for every entry that is currently selected somewhere else (so into arrayofselectedvalues)");'."\n";
- print ' $.each( arrayofselectedvalues, function( key, value ) {'."\n"; // Loop on each selected value
+
+ print ' $.each(arrayofselectedvalues, function(key, value) {'."\n"; // Loop on each selected value
print ' if (value != -1) {'."\n";
- //print ' console.log("Process key="+key+" value="+value+" to disable.");'."\n";
+ print ' console.log("Process key="+key+" value="+value+" to disable.");'."\n";
print ' $("select.targetselectchange").find(\'option[value="\'+value+\'"]:not(:selected)\').prop("disabled", true);'."\n"; // Set to disabled except if currently selected
print ' }'."\n";
print ' });'."\n";
@@ -1338,12 +1349,13 @@ if ($step == 4 && $datatoimport) {
print 'function saveSelection() {'."\n";
//print ' console.log(arrayofselectedvalues);'."\n";
print ' arrayselectedfields = [];'."\n";
- print ' arrayselectedfields.push("0");'."\n";
+ print ' arrayselectedfields.push(0);'."\n";
+
print ' $.each( arrayofselectedvalues, function( key, value ) {'."\n";
print ' if (value != -1) {'."\n";
- print ' arrayselectedfields.push(value);'."\n";
+ print ' arrayselectedfields.push(value);'."\n";
print ' } else {'."\n";
- print ' arrayselectedfields.push(0);'."\n";
+ print ' arrayselectedfields.push(0);'."\n";
print ' }'."\n";
print ' });'."\n";
@@ -1353,12 +1365,14 @@ if ($step == 4 && $datatoimport) {
print " url: '".dol_escape_js($_SERVER["PHP_SELF"])."?action=saveselectorder&token=".newToken()."',\n";
print " data: 'selectorder='+arrayselectedfields.toString(),\n";
print " success: function(){\n";
- print " console.log('Select order saved');\n";
+ print " console.log('The selected fields have been saved into '+arrayselectedfields.toString());\n";
print " },\n";
print ' });'."\n";
// Now we loop on all target fields that are mandatory to show if they are not mapped yet.
+ print ' console.log("arrayselectedfields");';
print ' console.log(arrayselectedfields);';
+ print ' console.log("arrayoftargetmandatoryfields");';
print ' console.log(arrayoftargetmandatoryfields);';
print " listtoshow = '';";
print " nbelement = arrayoftargetmandatoryfields.length
@@ -1886,16 +1900,17 @@ if ($step == 5 && $datatoimport) {
// Show OK
if (!count($arrayoferrors) && !count($arrayofwarnings)) {
- print ' '.img_picto($langs->trans("OK"), 'tick').' '.$langs->trans("NoError").' '; - print ' ';
+ print ' '; + print ' ';
+ print ' ';
print ''.$langs->trans("ResultOfSimulationNoError").' ';
print $langs->trans("NbInsert", empty($obj->nbinsert) ? 0 : $obj->nbinsert).''; print $langs->trans("NbUpdate", empty($obj->nbupdate) ? 0 : $obj->nbupdate).' '; print ' '; } else { print ' '; - print ' ';
- print $langs->trans("NbOfLinesOK", $nbok).' '; + print ' ';
+ print $langs->trans("NbOfLinesOK", $nbok).'... ';
print ''; print ' '; } @@ -2281,10 +2296,10 @@ if ($step == 6 && $datatoimport) { // Show result print ' '; - print ' ';
+ print ' ';
print $langs->trans("NbOfLinesImported", $nbok).' ';
print ''; print $langs->trans("NbInsert", empty($obj->nbinsert) ? 0 : $obj->nbinsert).' '; - print $langs->trans("NbUpdate", empty($obj->nbupdate) ? 0 : $obj->nbupdate).' '; + print $langs->trans("NbUpdate", empty($obj->nbupdate) ? 0 : $obj->nbupdate).' '; print ' ';
print $langs->trans("FileWasImported", $importid).' '; diff --git a/htdocs/langs/en_US/exports.lang b/htdocs/langs/en_US/exports.lang index f06acd49f41..c4c629c9a87 100644 --- a/htdocs/langs/en_US/exports.lang +++ b/htdocs/langs/en_US/exports.lang @@ -141,4 +141,5 @@ WarningFirstImportedLine=The first line(s) will not be imported with the current NotUsedFields=Fields of database not used SelectImportFieldsSource = Choose the source file fields you want to import and their target field in database by choosing the fields in each select boxes, or select a predefined import profile: MandatoryTargetFieldsNotMapped=Some mandatory target fields are not mapped -AllTargetMandatoryFieldsAreMapped=All target fields that need a mandatory value are mapped \ No newline at end of file +AllTargetMandatoryFieldsAreMapped=All target fields that need a mandatory value are mapped +ResultOfSimulationNoError=Result of simulation: No error \ No newline at end of file |