This gets rid of the crazy code on the preview screen - relying on getMappingFieldFromMapperInput
to compile the titles and
}
$this->set('columnNames', $this->_columnNames);
- $this->set('websites', $parserParameters['mapperWebsiteType']);
- $this->set('locations', $locations);
- $this->set('phones', $parserParameters['mapperPhoneType']);
- $this->set('ims', $parserParameters['mapperImProvider']);
- $this->set('related', $parserParameters['mapperRelated']);
- $this->set('relatedContactType', $parserParameters['relatedContactType']);
- $this->set('relatedContactDetails', $parserParameters['relatedContactDetails']);
- $this->set('relatedContactLocType', $parserParameters['relatedContactLocType']);
- $this->set('relatedContactPhoneType', $parserParameters['relatedContactPhoneType']);
- $this->set('relatedContactImProvider', $parserParameters['relatedContactImProvider']);
- $this->set('relatedContactWebsiteType', $parserParameters['relatedContactWebsiteType']);
- $this->set('mapper', $mapper);
// store mapping Id to display it in the preview page
$this->set('loadMappingId', CRM_Utils_Array::value('mappingId', $params));
}
$properties = array(
- 'mapper',
- 'locations',
- 'phones',
- 'ims',
'columnCount',
'totalRowCount',
'validRowCount',
'downloadErrorRecordsUrl',
'downloadConflictRecordsUrl',
'downloadMismatchRecordsUrl',
- 'related',
- 'relatedContactDetails',
- 'relatedContactLocType',
- 'relatedContactPhoneType',
- 'relatedContactImProvider',
- 'websites',
- 'relatedContactWebsiteType',
);
+ $this->assign('mapper', $this->getMappedFieldLabels());
+
foreach ($properties as $property) {
$this->assign($property, $this->get($property));
}
$importJob->isComplete();
}
+ /**
+ * Get the mapped fields as an array of labels.
+ *
+ * e.g
+ * ['First Name', 'Employee Of - First Name', 'Home - Street Address']
+ *
+ * @return array
+ * @throws \API_Exception
+ * @throws \CRM_Core_Exception
+ */
+ protected function getMappedFieldLabels(): array {
+ $mapper = [];
+ $parser = new CRM_Contact_Import_Parser_Contact();
+ $parser->setUserJobID($this->getUserJobID());
+ foreach ($this->getSubmittedValue('mapper') as $columnNumber => $mappedField) {
+ $mapper[$columnNumber] = $parser->getMappedFieldLabel($parser->getMappingFieldFromMapperInput($mappedField, 0, $columnNumber));
+ }
+ return $mapper;
+ }
+
}
{* Display mapper <select> field for 'Map Fields', and mapper value for 'Preview' *}
<td class="form-item even-row{if $wizard.currentStepName == 'Preview'} labels{/if}">
{if $wizard.currentStepName == 'Preview'}
- {if $relatedContactDetails && $relatedContactDetails[$i] != ''}
- {$mapper[$i]} - {$relatedContactDetails[$i]}
- {if $relatedContactLocType && $relatedContactLocType[$i] != ''} - {$relatedContactLocType[$i]}{/if}
- {if $relatedContactPhoneType && $relatedContactPhoneType[$i] != ''} - {$relatedContactPhoneType[$i]}{/if}
- {* append IM Service Provider type for related contact *}
- {if $relatedContactImProvider && $relatedContactImProvider[$i] != ''} - {$relatedContactImProvider[$i]}{/if}
- {* append website type *}
- {if $relatedContactWebsiteType && $relatedContactWebsiteType[$i] != ''} - {$relatedContactWebsiteType[$i]}{/if}
- {else}
- {if $locations[$i]}{$locations[$i]} - {/if}
- {if $phones[$i]}{$phones[$i]} - {/if}
- {* append IM Service provider type for contact *}
- {if $ims[$i]}{$ims[$i]} - {/if}
- {* append website type *}
- {if $websites[$i]}{$websites[$i]} - {/if}
- {$mapper[$i]}
- {/if}
+ {$mapperField}
{else}
{$mapperField.html|smarty:nodefaults}
{/if}