Debug the new import tool

This commit is contained in:
Laurent Destailleur 2022-06-09 18:10:07 +02:00
parent dbaae5b1e3
commit ea0589cbc3
2 changed files with 16 additions and 15 deletions

View File

@ -492,9 +492,9 @@ if ($step == 2 && $datatoimport) {
print '<td style="text-align:center">'; print '<td style="text-align:center">';
print '<a href="'.DOL_URL_ROOT.'/imports/emptyexample.php?format='.$key.$param.'" target="_blank" rel="noopener noreferrer">'; print '<a href="'.DOL_URL_ROOT.'/imports/emptyexample.php?format='.$key.$param.'" target="_blank" rel="noopener noreferrer">';
print img_picto('', 'download', 'class="paddingright opacitymedium"'); print img_picto('', 'download', 'class="paddingright opacitymedium"');
print $langs->trans("DownloadEmptyExample"); print $langs->trans("DownloadEmptyExampleShort");
print '</a>'; print '</a>';
print $form->textwithpicto('', $langs->trans("StarAreMandatory")); print $form->textwithpicto('', $langs->trans("DownloadEmptyExample").'.<br>'.$langs->trans("StarAreMandatory"));
print '</td>'; print '</td>';
// Action button // Action button
print '<td style="text-align:right">'; print '<td style="text-align:right">';
@ -583,9 +583,9 @@ if ($step == 3 && $datatoimport) {
print '</td><td style="text-align:right" class="nowrap">'; print '</td><td style="text-align:right" class="nowrap">';
print '<a href="'.DOL_URL_ROOT.'/imports/emptyexample.php?format='.$format.$param.'" target="_blank" rel="noopener noreferrer">'; print '<a href="'.DOL_URL_ROOT.'/imports/emptyexample.php?format='.$format.$param.'" target="_blank" rel="noopener noreferrer">';
print img_picto('', 'download', 'class="paddingright opacitymedium"'); print img_picto('', 'download', 'class="paddingright opacitymedium"');
print $langs->trans("DownloadEmptyExample"); print $langs->trans("DownloadEmptyExampleShort");
print '</a>'; print '</a>';
print $form->textwithpicto('', $langs->trans("StarAreMandatory")); print $form->textwithpicto('', $langs->trans("DownloadEmptyExample").'.<br>'.$langs->trans("StarAreMandatory"));
print '</td></tr>'; print '</td></tr>';
print '</table>'; print '</table>';
@ -600,9 +600,9 @@ if ($step == 3 && $datatoimport) {
} }
print '<br>'; print '<br><br>';
print '<form name="userfile" action="'.$_SERVER["PHP_SELF"].'" enctype="multipart/form-data" METHOD="POST">'; print '<form name="userfile" action="'.$_SERVER["PHP_SELF"].'" enctype="multipart/form-data" method="POST">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="max_file_size" value="'.$conf->maxfilesize.'">'; print '<input type="hidden" name="max_file_size" value="'.$conf->maxfilesize.'">';
@ -984,10 +984,10 @@ if ($step == 4 && $datatoimport) {
print '<input type="hidden" value="'.$datatoimport.'" name="datatoimport">'; print '<input type="hidden" value="'.$datatoimport.'" name="datatoimport">';
print '<input type="hidden" value="'.$filetoimport.'" name="filetoimport">'; print '<input type="hidden" value="'.$filetoimport.'" name="filetoimport">';
print $langs->trans("Separator").' : '; print $langs->trans("Separator").' : ';
print '<input type="text" size="1" name="separator" value="'.dol_escape_htmltag($separator).'"/>'; print '<input type="text" class="width25 center" name="separator" value="'.dol_escape_htmltag($separator).'"/>';
print '&nbsp;&nbsp;&nbsp;&nbsp;'.$langs->trans("Enclosure").' : '; print '&nbsp;&nbsp;&nbsp;&nbsp;'.$langs->trans("Enclosure").' : ';
print '<input type="text" size="1" name="enclosure" value="'.dol_escape_htmltag($enclosure).'"/> '; print '<input type="text" class="width25 center" name="enclosure" value="'.dol_escape_htmltag($enclosure).'"/> ';
print '<input name="update" type="submit" value="'.$langs->trans('Update').'" class="button small" />'; print '<input name="update" type="submit" value="'.$langs->trans('Update').'" class="button smallpaddingimp" />';
print '</form>'; print '</form>';
print '</td></tr>'; print '</td></tr>';
} }
@ -1014,7 +1014,7 @@ if ($step == 4 && $datatoimport) {
// List of source fields // List of source fields
print '<!-- List of source fields -->'."\n"; print '<!-- List of source fields -->'."\n";
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'; print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="select_model">'; print '<input type="hidden" name="action" value="select_model">';
print '<input type="hidden" name="step" value="4">'; print '<input type="hidden" name="step" value="4">';
@ -1448,7 +1448,7 @@ if ($step == 4 && $datatoimport) {
print '</tr>'; print '</tr>';
$nameofimportprofile = str_replace(' ', '-', $langs->trans("ImportProfile").' '.$titleofmodule.' '.dol_print_date(dol_now('gmt'), 'dayxcard')); $nameofimportprofile = str_replace(' ', '-', $langs->trans("ImportProfile").' '.$titleofmodule.' '.dol_print_date(dol_now('gmt'), 'dayxcard'));
if (is_object($objimport)) { if (is_object($objimport) && !empty($objimport->model_name)) {
$nameofimportprofile = $objimport->model_name; $nameofimportprofile = $objimport->model_name;
} }
@ -1459,7 +1459,7 @@ if ($step == 4 && $datatoimport) {
print $form->selectarray('visibility', $arrayvisibility, 'private'); print $form->selectarray('visibility', $arrayvisibility, 'private');
print '</td>'; print '</td>';
print '<td class="right">'; print '<td class="right">';
print '<input type="submit" class="button small reposition" value="'.$langs->trans("SaveImportProfile").'">'; print '<input type="submit" class="button smallpaddingimp reposition" value="'.$langs->trans("SaveImportProfile").'">';
print '</td></tr>'; print '</td></tr>';
// List of existing import profils // List of existing import profils
@ -1489,7 +1489,7 @@ if ($step == 4 && $datatoimport) {
print $langs->trans("Everybody"); print $langs->trans("Everybody");
} else { } else {
$tmpuser->fetch($obj->fk_user); $tmpuser->fetch($obj->fk_user);
print $tmpuser->getNomUrl(1); print $tmpuser->getNomUrl(-1);
} }
print '</td>'; print '</td>';
print '<td class="right">'; print '<td class="right">';
@ -1778,9 +1778,9 @@ if ($step == 5 && $datatoimport) {
} }
//print $code.'-'.$label; //print $code.'-'.$label;
$alias = preg_replace('/(\..*)$/i', '', $label); $alias = preg_replace('/(\..*)$/i', '', $label);
$listfields[$i] = $langs->trans("Column").' '.num2Alpha($code - 1).' -> '.$label; $listfields[$i] = '<span class="nowrap">'.$langs->trans("Column").' '.num2Alpha($code - 1).' -> '.$label.'</span>';
} }
print count($listfields) ? (join(', &nbsp;', $listfields)) : $langs->trans("Error"); print count($listfields) ? (join(', ', $listfields)) : $langs->trans("Error");
print '</td></tr>'; print '</td></tr>';
print '</table>'; print '</table>';

View File

@ -54,6 +54,7 @@ TypeOfLineServiceOrProduct=Type of line (0=product, 1=service)
FileWithDataToImport=File with data to import FileWithDataToImport=File with data to import
FileToImport=Source file to import FileToImport=Source file to import
FileMustHaveOneOfFollowingFormat=File to import must have one of following formats FileMustHaveOneOfFollowingFormat=File to import must have one of following formats
DownloadEmptyExampleShort=Download a sample file
DownloadEmptyExample=Download a template file with examples and information on fields you can import DownloadEmptyExample=Download a template file with examples and information on fields you can import
StarAreMandatory=Into the template file, all fields with a * are mandatory fields StarAreMandatory=Into the template file, all fields with a * are mandatory fields
ChooseFormatOfFileToImport=Choose the file format to use as import file format by clicking on the %s icon to select it... ChooseFormatOfFileToImport=Choose the file format to use as import file format by clicking on the %s icon to select it...