diff --git a/CRM/Import/DataSource/CSV.php b/CRM/Import/DataSource/CSV.php index 79e68a0d7ff2..f084d65c7397 100644 --- a/CRM/Import/DataSource/CSV.php +++ b/CRM/Import/DataSource/CSV.php @@ -74,7 +74,7 @@ public function buildQuickForm(&$form) { * @throws \CRM_Core_Exception */ public function initialize(): void { - $result = self::_CsvToTable( + $result = $this->csvToTable( $this->getSubmittedValue('uploadFile')['name'], $this->getSubmittedValue('skipColumnHeader'), $this->getSubmittedValue('fieldSeparator') ?? ',' @@ -83,7 +83,7 @@ public function initialize(): void { $this->updateUserJobMetadata('DataSource', [ 'table_name' => $result['import_table_name'], - 'column_headers' => $this->getSubmittedValue('skipColumnHeader') ? $result['column_headers'] : [], + 'column_headers' => $result['column_headers'], 'number_of_columns' => $result['number_of_columns'], ]); } @@ -102,7 +102,7 @@ public function initialize(): void { * name of the created table * @throws \CRM_Core_Exception */ - private static function _CsvToTable( + private function csvToTable( $file, $headers = FALSE, $fieldSeparator = ',' @@ -124,7 +124,7 @@ private static function _CsvToTable( } $firstrow = fgetcsv($fd, 0, $fieldSeparator); - + $result['column_headers'] = array_fill(0, count($firstrow), ''); // create the column names from the CSV header or as col_0, col_1, etc. if ($headers) { //need to get original headers. diff --git a/CRM/Import/Form/Preview.php b/CRM/Import/Form/Preview.php index 24aa09977ce7..92959b83577d 100644 --- a/CRM/Import/Form/Preview.php +++ b/CRM/Import/Form/Preview.php @@ -113,6 +113,7 @@ protected function assignPreviewVariables(): void { } $this->assign('savedMappingName', $mappingId ? $mapDAO->name : NULL); $this->assign('skipColumnHeader', $this->getSubmittedValue('skipColumnHeader')); + $this->assign('showColumnNames', $this->getSubmittedValue('skipColumnHeader')); // rowDisplayCount is deprecated - it used to be used with {section} but we have nearly gotten rid of it. $this->assign('rowDisplayCount', $this->getSubmittedValue('skipColumnHeader') ? 3 : 2); } diff --git a/CRM/Import/Forms.php b/CRM/Import/Forms.php index 0b37ea76b221..f07a203297e3 100644 --- a/CRM/Import/Forms.php +++ b/CRM/Import/Forms.php @@ -597,6 +597,7 @@ protected function assignMapFieldVariables(): void { $this->_columnNames = $this->getColumnHeaders(); $this->_dataValues = array_values($this->getDataRows([], 2)); $this->assign('columnNames', $this->getColumnHeaders()); + $this->assign('showColumnNames', $this->getSubmittedValue('skipColumnHeader')); $this->assign('highlightedFields', $this->getHighlightedFields()); $this->assign('columnCount', $this->_columnCount); $this->assign('dataValues', $this->_dataValues); diff --git a/templates/CRM/Import/Form/MapTableCommon.tpl b/templates/CRM/Import/Form/MapTableCommon.tpl index 83fa1fcc8e48..8be853aa87fc 100644 --- a/templates/CRM/Import/Form/MapTableCommon.tpl +++ b/templates/CRM/Import/Form/MapTableCommon.tpl @@ -10,7 +10,7 @@ {* Header row - has column for column names if they have been supplied *}
{ts}Review the values shown below from the first 2 rows of your import file and select the matching CiviCRM database fields from the drop-down lists in the right-hand column. Select '- do not import -' for any columns in the import file that you want ignored.{/ts}
-{ts}If you think you may be importing additional data from the same data source, check 'Save this field mapping' at the bottom of the page before continuing. The saved mapping can then be easily reused the next time data is imported.{/ts}
-