diff --git a/CRM/Export/BAO/Export.php b/CRM/Export/BAO/Export.php index ddf2190eed18..f8b0dc44112c 100644 --- a/CRM/Export/BAO/Export.php +++ b/CRM/Export/BAO/Export.php @@ -1243,7 +1243,7 @@ public static function getExportStructureArrays($returnProperties, $processor) { foreach ($returnProperties as $key => $value) { if (($key != 'location' || !is_array($value)) && !$processor->isRelationshipTypeKey($key)) { $outputColumns[$key] = $value; - $processor->addOutputSpecification($key, $processor->getHeaderForRow($key)); + $processor->addOutputSpecification($key); self::sqlColumnDefn($processor, $sqlColumns, $key); } elseif ($processor->isRelationshipTypeKey($key)) { @@ -1254,7 +1254,7 @@ public static function getExportStructureArrays($returnProperties, $processor) { if (isset($queryFields[$relationField]['title'])) { if (!$processor->isHouseholdMergeRelationshipTypeKey($field)) { // Do not add to header row if we are only generating for merge reasons. - $processor->addOutputSpecification($relationField, $processor->getHeaderForRow($relationField), $key); + $processor->addOutputSpecification($relationField, $key); } self::sqlColumnDefn($processor, $sqlColumns, $field . '-' . $relationField); } @@ -1274,7 +1274,7 @@ public static function getExportStructureArrays($returnProperties, $processor) { $hdr .= "-" . CRM_Core_PseudoConstant::getLabel('CRM_Core_BAO_IM', 'provider_id', $type[1]); } } - $processor->addOutputSpecification($field, $hdr, $key); + $processor->addOutputSpecification($field, $key, $ltype, CRM_Utils_Array::value(1, $type)); self::sqlColumnDefn($processor, $sqlColumns, $field . '-' . $hdr); } } @@ -1304,7 +1304,7 @@ public static function getExportStructureArrays($returnProperties, $processor) { $metadata[$daoFieldName]['pseudoconstant']['var'] = 'imProviders'; } self::sqlColumnDefn($processor, $sqlColumns, $outputFieldName); - $processor->addOutputSpecification($outputFieldName, $processor->getHeaderForRow($outputFieldName)); + $processor->addOutputSpecification($outputFieldName, NULL, $locationType, CRM_Utils_Array::value(1, $type)); self::sqlColumnDefn($processor, $sqlColumns, $outputFieldName); if ($actualDBFieldName == 'country' || $actualDBFieldName == 'world_region') { $metadata[$daoFieldName] = array('context' => 'country'); diff --git a/CRM/Export/BAO/ExportProcessor.php b/CRM/Export/BAO/ExportProcessor.php index c87b8dc99a01..72f99b32a74e 100644 --- a/CRM/Export/BAO/ExportProcessor.php +++ b/CRM/Export/BAO/ExportProcessor.php @@ -443,16 +443,33 @@ public function runQuery($params, $order, $returnProperties) { /** * Add a row to the specification for how to output data. + * * @param string $key - * @param string $label * @param string $relationshipType + * @param string $locationType + * @param int $entityTypeID phone_type_id or provider_id for phone or im fields. */ - public function addOutputSpecification($key, $label, $relationshipType = NULL) { - $labelPrefix = ''; + public function addOutputSpecification($key, $relationshipType = NULL, $locationType = NULL, $entityTypeID = NULL) { + $label = $this->getHeaderForRow($key); + $labelPrefix = $fieldPrefix = []; if ($relationshipType) { - $labelPrefix = $this->getRelationshipTypes()[$relationshipType] . '-'; + $labelPrefix[] = $this->getRelationshipTypes()[$relationshipType]; + $fieldPrefix[] = $relationshipType; + } + if ($locationType) { + $labelPrefix[] = $fieldPrefix[] = $locationType; + } + if ($entityTypeID) { + if ($key === 'phone') { + $labelPrefix[] = $fieldPrefix[] = CRM_Core_PseudoConstant::getLabel('CRM_Core_BAO_Phone', 'phone_type_id', $entityTypeID); + } + if ($key === 'im') { + $labelPrefix[] = $fieldPrefix[] = CRM_Core_PseudoConstant::getLabel('CRM_Core_BAO_IM', 'provider_id', $entityTypeID); + } } - $this->outputSpecification[$key]['header'] = $labelPrefix . $label; + $index = ($fieldPrefix ? (implode('-', $fieldPrefix) . '-') : '') . $key; + $this->outputSpecification[$index]['header'] = ($labelPrefix ? (implode('-', $labelPrefix) . '-') : '') . $label; + } /**