|
@@ -876,9 +876,9 @@ if ($step == 4 && $datatoimport) {
|
|
|
$isrequired = preg_match('/\*$/', $label);
|
|
|
if (!empty($isrequired)) {
|
|
|
$newlabel = substr($label, 0, -1);
|
|
|
- $fieldstarget_tmp[$key] = array("label"=>$newlabel,"required"=>true);
|
|
|
+ $fieldstarget_tmp[$key] = array("label"=>$newlabel, "required"=>true);
|
|
|
} else {
|
|
|
- $fieldstarget_tmp[$key] = array("label"=>$label,"required"=>false);
|
|
|
+ $fieldstarget_tmp[$key] = array("label"=>$label, "required"=>false);
|
|
|
}
|
|
|
if (!empty($array_match_database_to_file[$key])) {
|
|
|
$fieldstarget_tmp[$key]["imported"] = true;
|
|
@@ -1089,9 +1089,14 @@ if ($step == 4 && $datatoimport) {
|
|
|
$optionsall = array();
|
|
|
foreach ($fieldstarget as $code => $line) {
|
|
|
//var_dump($line);
|
|
|
- $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.
|
|
|
+
|
|
|
+ $tmparray = explode('|', $line["label"]); // If label of field is several translation keys separated with |
|
|
|
+ $labeltoshow = '';
|
|
|
+ foreach ($tmparray as $tmpkey => $tmpval) {
|
|
|
+ $labeltoshow .= ($labeltoshow ? ' '.$langs->trans('or').' ' : '').$langs->transnoentities($tmpval);
|
|
|
+ }
|
|
|
+ $optionsall[$code] = array('labelkey'=>$line['label'], 'labelkeyarray'=>$tmparray, 'label'=>$labeltoshow, 'required'=>(empty($line["required"]) ? 0 : 1), 'position'=>!empty($line['position']) ? $line['position'] : 0);
|
|
|
+ // TODO Get type from a new array into module descriptor.
|
|
|
//$picto = 'email';
|
|
|
$picto = '';
|
|
|
if ($picto) {
|
|
@@ -1129,9 +1134,6 @@ if ($step == 4 && $datatoimport) {
|
|
|
print '<tr style="height:'.$height.'" class="trimport oddevenimport">';
|
|
|
$entity = (!empty($objimport->array_import_entities[0][$code]) ? $objimport->array_import_entities[0][$code] : $objimport->array_import_icon[0]);
|
|
|
|
|
|
- $tablealias = preg_replace('/(\..*)$/i', '', $code);
|
|
|
- $tablename = !empty($objimport->array_import_tables[0][$tablealias]) ? $objimport->array_import_tables[0][$tablealias] : "";
|
|
|
-
|
|
|
$entityicon = !empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity; // $entityicon must string name of picto of the field like 'project', 'company', 'contact', 'modulename', ...
|
|
|
$entitylang = $entitytolang[$entity] ? $entitytolang[$entity] : $objimport->array_import_label[0]; // $entitylang must be a translation key to describe object the field is related to, like 'Company', 'Contact', 'MyModyle', ...
|
|
|
|
|
@@ -1161,6 +1163,48 @@ if ($step == 4 && $datatoimport) {
|
|
|
$label .= $tmpval['label'];
|
|
|
$label .= $tmpval['required'] ? '*</strong>' : '';
|
|
|
|
|
|
+ $tablealias = preg_replace('/(\..*)$/i', '', $tmpcode);
|
|
|
+ $tablename = !empty($objimport->array_import_tables[0][$tablealias]) ? $objimport->array_import_tables[0][$tablealias] : "";
|
|
|
+
|
|
|
+ $htmltext = '';
|
|
|
+
|
|
|
+ $filecolumn = ($i + 1);
|
|
|
+ // Source field info
|
|
|
+ if (empty($objimport->array_import_convertvalue[0][$tmpcode])) { // If source file does not need convertion
|
|
|
+ $filecolumntoshow = num2Alpha($i);
|
|
|
+ } else {
|
|
|
+ if ($objimport->array_import_convertvalue[0][$tmpcode]['rule'] == 'fetchidfromref') {
|
|
|
+ $htmltext .= $langs->trans("DataComeFromIdFoundFromRef", $filecolumn, $langs->transnoentitiesnoconv($entitylang)).'<br>';
|
|
|
+ }
|
|
|
+ if ($objimport->array_import_convertvalue[0][$tmpcode]['rule'] == 'fetchidfromcodeid') {
|
|
|
+ $htmltext .= $langs->trans("DataComeFromIdFoundFromCodeId", $filecolumn, $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$code]['dict'])).'<br>';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // Source required
|
|
|
+ $example = !empty($objimport->array_import_examplevalues[0][$tmpcode])?$objimport->array_import_examplevalues[0][$tmpcode]:"";
|
|
|
+ // Example
|
|
|
+ if (empty($objimport->array_import_convertvalue[0][$tmpcode])) { // If source file does not need convertion
|
|
|
+ if ($example) {
|
|
|
+ $htmltext .= $langs->trans("SourceExample").': <b>'.str_replace('"', '', $example).'</b><br>';
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if ($objimport->array_import_convertvalue[0][$tmpcode]['rule'] == 'fetchidfromref') {
|
|
|
+ $htmltext .= $langs->trans("SourceExample").': <b>'.$langs->transnoentitiesnoconv("ExampleAnyRefFoundIntoElement", $entitylang).($example ? ' ('.$langs->transnoentitiesnoconv("Example").': '.$example.')' : '').'</b><br>';
|
|
|
+ } elseif ($objimport->array_import_convertvalue[0][$tmpcode]['rule'] == 'fetchidfromcodeid') {
|
|
|
+ $htmltext .= $langs->trans("SourceExample").': <b>'.$langs->trans("ExampleAnyCodeOrIdFoundIntoDictionary", $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$code]['dict'])).($example ? ' ('.$langs->transnoentitiesnoconv("Example").': '.$example.')' : '').'</b><br>';
|
|
|
+ } elseif ($example) {
|
|
|
+ $htmltext .= $langs->trans("SourceExample").': <b>'.str_replace('"', '', $example).'</b><br>';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // Format control rule
|
|
|
+ if (!empty($objimport->array_import_regex[0][$tmpcode])) {
|
|
|
+ $htmltext .= $langs->trans("FormatControlRule").': <b>'.str_replace('"', '', $objimport->array_import_regex[0][$tmpcode]).'</b><br>';
|
|
|
+ }
|
|
|
+
|
|
|
+ $htmltext .= $langs->trans("Table")."->".$langs->trans("Field").': <b>'.$tablename."->".preg_replace('/^.*\./', '', $tmpcode)."</b>";
|
|
|
+
|
|
|
+ $labelhtml = $label.' '.$form->textwithpicto('', $htmltext, 1, 'help', '', 1);
|
|
|
+
|
|
|
$selectforline .= '<option value="'.$tmpcode.'"';
|
|
|
if ($modetoautofillmapping == 'orderoftargets') {
|
|
|
// The mode where we fill the preselected value of combo one by one in order of available targets fields in the declaration in descriptor file.
|
|
@@ -1169,8 +1213,9 @@ if ($step == 4 && $datatoimport) {
|
|
|
}
|
|
|
} elseif ($modetoautofillmapping == 'guess') {
|
|
|
// The mode where we try to guess which value to preselect from the name in first column of source file.
|
|
|
+ // $line['example1'] is the label of the column found on first line
|
|
|
$regs = array();
|
|
|
- if (preg_match('/^(.+)\((.+)\)$/', $line['example1'], $regs)) {
|
|
|
+ if (preg_match('/^(.+)\((.+\..+)\)$/', $line['example1'], $regs)) { // If text is "Label (x.abc)"
|
|
|
$tmpstring1 = $regs[1];
|
|
|
$tmpstring2 = $regs[2];
|
|
|
} else {
|
|
@@ -1181,18 +1226,23 @@ if ($step == 4 && $datatoimport) {
|
|
|
$tmpstring2 = strtolower(str_replace('*', '', trim($tmpstring2)));
|
|
|
|
|
|
// $tmpstring1 and $tmpstring2 are string from input file.
|
|
|
- //var_dump($tmpstring1.' '.$tmpstring2.' '.$tmpval['label'].' '.$tmpval['labelkey']);
|
|
|
- if ($tmpstring1 && ($tmpstring1 == $tmpcode || $tmpstring1 == strtolower($tmpval['label'])
|
|
|
- || $tmpstring1 == strtolower(dol_string_unaccent($tmpval['label'])) || $tmpstring1 == strtolower($tmpval['labelkey']))) {
|
|
|
- if (empty($codeselectedarray[$code])) {
|
|
|
- $selectforline .= ' selected';
|
|
|
- $codeselectedarray[$code] = 1;
|
|
|
- }
|
|
|
- } elseif ($tmpstring2 && ($tmpstring2 == $tmpcode || $tmpstring2 == strtolower($tmpval['label'])
|
|
|
- || $tmpstring2 == strtolower(dol_string_unaccent($tmpval['label'])) || $tmpstring2 == strtolower($tmpval['labelkey']))) {
|
|
|
- if (empty($codeselectedarray[$code])) {
|
|
|
- $selectforline .= ' selected';
|
|
|
- $codeselectedarray[$code] = 1;
|
|
|
+ foreach ($tmpval['labelkeyarray'] as $tmpval2) {
|
|
|
+ $labeltarget = $langs->transnoentities($tmpval2);
|
|
|
+ //var_dump($tmpstring1.' - '.$tmpstring2.' - '.$tmpval['labelkey'].' - '.$tmpval['label'].' - '.$tmpval2.' - '.$labeltarget);
|
|
|
+ if ($tmpstring1 && ($tmpstring1 == $tmpcode || $tmpstring1 == strtolower($labeltarget)
|
|
|
+ || $tmpstring1 == strtolower(dol_string_unaccent($labeltarget)) || $tmpstring1 == strtolower($tmpval2))) {
|
|
|
+ if (empty($codeselectedarray[$code])) {
|
|
|
+ $selectforline .= ' selected';
|
|
|
+ $codeselectedarray[$code] = 1;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ } elseif ($tmpstring2 && ($tmpstring2 == $tmpcode || $tmpstring2 == strtolower($labeltarget)
|
|
|
+ || $tmpstring2 == strtolower(dol_string_unaccent($labeltarget)) || $tmpstring2 == strtolower($tmpval2))) {
|
|
|
+ if (empty($codeselectedarray[$code])) {
|
|
|
+ $selectforline .= ' selected';
|
|
|
+ $codeselectedarray[$code] = 1;
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
} elseif ($modetoautofillmapping == 'session' && !empty($_SESSION['dol_array_match_file_to_database_select'])) {
|
|
@@ -1203,7 +1253,7 @@ if ($step == 4 && $datatoimport) {
|
|
|
}
|
|
|
$selectforline .= ' data-debug="'.$tmpcode.'-'.$code.'-'.$j.'-'.(!empty($tmpselectioninsession[($i+1)]) ? $tmpselectioninsession[($i+1)] : "").'"';
|
|
|
}
|
|
|
- $selectforline .= ' data-html="'.dol_escape_htmltag($label).'"';
|
|
|
+ $selectforline .= ' data-html="'.dol_escape_htmltag($labelhtml).'"';
|
|
|
$selectforline .= '>';
|
|
|
$selectforline .= $label;
|
|
|
$selectforline .= '</options>';
|
|
@@ -1216,62 +1266,17 @@ if ($step == 4 && $datatoimport) {
|
|
|
|
|
|
print '</td>';
|
|
|
|
|
|
+ // Tooltip at end of line
|
|
|
print '<td class="nowraponall" style="font-weight:normal; text-align:right">';
|
|
|
- $filecolumn = ($i + 1);
|
|
|
+
|
|
|
// Source field info
|
|
|
$htmltext = '<b><u>'.$langs->trans("FieldSource").'</u></b><br>';
|
|
|
- if ($filecolumn > count($fieldssource)) {
|
|
|
- $htmltext .= $langs->trans("DataComeFromNoWhere").'<br>';
|
|
|
- } else {
|
|
|
- if (empty($objimport->array_import_convertvalue[0][$code])) { // If source file does not need convertion
|
|
|
- $filecolumntoshow = num2Alpha($i);
|
|
|
- $htmltext .= $langs->trans("DataComeFromFileFieldNb", $filecolumntoshow).'<br>';
|
|
|
- } else {
|
|
|
- if ($objimport->array_import_convertvalue[0][$code]['rule'] == 'fetchidfromref') {
|
|
|
- $htmltext .= $langs->trans("DataComeFromIdFoundFromRef", $filecolumn, $langs->transnoentitiesnoconv($entitylang)).'<br>';
|
|
|
- }
|
|
|
- if ($objimport->array_import_convertvalue[0][$code]['rule'] == 'fetchidfromcodeid') {
|
|
|
- $htmltext .= $langs->trans("DataComeFromIdFoundFromCodeId", $filecolumn, $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$code]['dict'])).'<br>';
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- // Source required
|
|
|
- $example = !empty($objimport->array_import_examplevalues[0][$code])?$objimport->array_import_examplevalues[0][$code]:"";
|
|
|
- // Example
|
|
|
- if (empty($objimport->array_import_convertvalue[0][$code])) { // If source file does not need convertion
|
|
|
- if ($example) {
|
|
|
- $htmltext .= $langs->trans("SourceExample").': <b>'.$example.'</b><br>';
|
|
|
- }
|
|
|
- } else {
|
|
|
- if ($objimport->array_import_convertvalue[0][$code]['rule'] == 'fetchidfromref') {
|
|
|
- $htmltext .= $langs->trans("SourceExample").': <b>'.$langs->transnoentitiesnoconv("ExampleAnyRefFoundIntoElement", $entitylang).($example ? ' ('.$langs->transnoentitiesnoconv("Example").': '.$example.')' : '').'</b><br>';
|
|
|
- } elseif ($objimport->array_import_convertvalue[0][$code]['rule'] == 'fetchidfromcodeid') {
|
|
|
- $htmltext .= $langs->trans("SourceExample").': <b>'.$langs->trans("ExampleAnyCodeOrIdFoundIntoDictionary", $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$code]['dict'])).($example ? ' ('.$langs->transnoentitiesnoconv("Example").': '.$example.')' : '').'</b><br>';
|
|
|
- } elseif ($example) {
|
|
|
- $htmltext .= $langs->trans("SourceExample").': <b>'.$example.'</b><br>';
|
|
|
- }
|
|
|
- }
|
|
|
- // Format control rule
|
|
|
- if (!empty($objimport->array_import_regex[0][$code])) {
|
|
|
- $htmltext .= $langs->trans("FormatControlRule").': <b>'.$objimport->array_import_regex[0][$code].'</b><br>';
|
|
|
- }
|
|
|
- $htmltext .= '<br>';
|
|
|
- // Target field info
|
|
|
- $htmltext .= '<b><u>'.$langs->trans("FieldTarget").'</u></b><br>';
|
|
|
- //$htmltext .= $langs->trans("SourceRequired").': <b>'.yn($line["label"]).'</b><br>';
|
|
|
- if (empty($objimport->array_import_convertvalue[0][$code])) { // If source file does not need convertion
|
|
|
- $htmltext .= $langs->trans("DataIsInsertedInto").'<br>';
|
|
|
- } else {
|
|
|
- if ($objimport->array_import_convertvalue[0][$code]['rule'] == 'fetchidfromref') {
|
|
|
- $htmltext .= $langs->trans("DataIDSourceIsInsertedInto").'<br>';
|
|
|
- }
|
|
|
- if ($objimport->array_import_convertvalue[0][$code]['rule'] == 'fetchidfromcodeid') {
|
|
|
- $htmltext .= $langs->trans("DataCodeIDSourceIsInsertedInto").'<br>';
|
|
|
- }
|
|
|
- }
|
|
|
- $htmltext .= $langs->trans("FieldTitle").": <b>".$langs->trans($fieldstarget[$arraykeysfieldtarget[$code-1]]["label"])."</b><br>";
|
|
|
- $htmltext .= $langs->trans("Table")." -> ".$langs->trans("Field").': <b>'.$tablename." -> ".preg_replace('/^.*\./', '', $code)."</b><br>";
|
|
|
- print $form->textwithpicto($more, $htmltext);
|
|
|
+ $filecolumntoshow = num2Alpha($i);
|
|
|
+ $htmltext .= $langs->trans("DataComeFromFileFieldNb", $filecolumntoshow).'<br>';
|
|
|
+
|
|
|
+ print $form->textwithpicto('', $htmltext);
|
|
|
+
|
|
|
+ print '</td>';
|
|
|
print '</tr>';
|
|
|
$i++;
|
|
|
}
|
|
@@ -1926,9 +1931,9 @@ if ($step == 5 && $datatoimport) {
|
|
|
print $langs->trans("TooMuchErrors", (count($arrayoferrors) - $nboferrors))."<br>";
|
|
|
break;
|
|
|
}
|
|
|
- print '* '.$langs->trans("Line").' '.$key.'<br>';
|
|
|
+ print '* '.$langs->trans("Line").' '.dol_escape_htmltag($key).'<br>';
|
|
|
foreach ($val as $i => $err) {
|
|
|
- print ' > '.$err['lib'].'<br>';
|
|
|
+ print ' > '.dol_escape_htmltag($err['lib']).'<br>';
|
|
|
}
|
|
|
}
|
|
|
print '</td></tr></table>';
|
|
@@ -1946,9 +1951,9 @@ if ($step == 5 && $datatoimport) {
|
|
|
print $langs->trans("TooMuchWarnings", (count($arrayofwarnings) - $nbofwarnings))."<br>";
|
|
|
break;
|
|
|
}
|
|
|
- print ' * '.$langs->trans("Line").' '.$key.'<br>';
|
|
|
+ print ' * '.$langs->trans("Line").' '.dol_escape_htmltag($key).'<br>';
|
|
|
foreach ($val as $i => $err) {
|
|
|
- print ' > '.$err['lib'].'<br>';
|
|
|
+ print ' > '.dol_escape_htmltag($err['lib']).'<br>';
|
|
|
}
|
|
|
}
|
|
|
print '</td></tr></table>';
|