-
-
Notifications
You must be signed in to change notification settings - Fork 825
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Export code cleanup - Use getComponentPaymentFields from processorClass #13082
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
0e32ed6
Use getComponentPaymentFields from processorClass
eileenmcnaughton 05ad310
Refactor out getPaymentHeaders function
eileenmcnaughton 63b17b8
Move wrangling payment header outside main row iteration
eileenmcnaughton 0b94b40
Always create temp table at the start.
eileenmcnaughton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -235,8 +235,6 @@ public static function exportComponents( | |
$imProviders = CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id'); | ||
self::$relationshipTypes = $processor->getRelationshipTypes(); | ||
|
||
$queryMode = $processor->getQueryMode(); | ||
|
||
if ($fields) { | ||
foreach ($fields as $key => $value) { | ||
$fieldName = CRM_Utils_Array::value(1, $value); | ||
|
@@ -432,29 +430,19 @@ public static function exportComponents( | |
|
||
$paymentDetails = array(); | ||
if ($processor->isExportPaymentFields()) { | ||
|
||
// get payment related in for event and members | ||
$paymentDetails = CRM_Contribute_BAO_Contribution::getContributionDetails($exportMode, $ids); | ||
//get all payment headers. | ||
// If we haven't selected specific payment fields, load in all the | ||
// payment headers. | ||
if (!$processor->isExportSpecifiedPaymentFields()) { | ||
$paymentHeaders = self::componentPaymentFields(); | ||
if (!empty($paymentDetails)) { | ||
$addPaymentHeader = TRUE; | ||
} | ||
} | ||
// If we have selected specific payment fields, leave the payment headers | ||
// as an empty array; the headers for each selected field will be added | ||
// elsewhere. | ||
else { | ||
$paymentHeaders = array(); | ||
} | ||
$nullContributionDetails = array_fill_keys(array_keys($paymentHeaders), NULL); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. calculated when it is used |
||
} | ||
|
||
$componentDetails = array(); | ||
$setHeader = TRUE; | ||
|
||
$rowCount = self::EXPORT_ROW_COUNT; | ||
$offset = 0; | ||
|
@@ -468,7 +456,19 @@ public static function exportComponents( | |
|
||
list($outputColumns, $headerRows, $sqlColumns, $metadata) = self::getExportStructureArrays($returnProperties, $processor); | ||
|
||
// add payment headers if required | ||
if ($addPaymentHeader && $processor->isExportPaymentFields()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. moved to being before the row-by-row loop |
||
// @todo rather than do this for every single row do it before the loop starts. | ||
// where other header definitions take place. | ||
$headerRows = array_merge($headerRows, $processor->getPaymentHeaders()); | ||
foreach (array_keys($processor->getPaymentHeaders()) as $paymentHdr) { | ||
self::sqlColumnDefn($processor, $sqlColumns, $paymentHdr); | ||
} | ||
} | ||
|
||
$exportTempTable = self::createTempTable($sqlColumns); | ||
$limitReached = FALSE; | ||
|
||
while (!$limitReached) { | ||
$limitQuery = "{$queryString} LIMIT {$offset}, {$rowCount}"; | ||
$iterationDAO = CRM_Core_DAO::executeQuery($limitQuery); | ||
|
@@ -532,28 +532,12 @@ public static function exportComponents( | |
} | ||
} | ||
|
||
// add payment headers if required | ||
if ($addPaymentHeader && $processor->isExportPaymentFields()) { | ||
// @todo rather than do this for every single row do it before the loop starts. | ||
// where other header definitions take place. | ||
$headerRows = array_merge($headerRows, $paymentHeaders); | ||
foreach (array_keys($paymentHeaders) as $paymentHdr) { | ||
self::sqlColumnDefn($processor, $sqlColumns, $paymentHdr); | ||
} | ||
} | ||
|
||
if ($setHeader) { | ||
$exportTempTable = self::createTempTable($sqlColumns); | ||
} | ||
|
||
//build header only once | ||
$setHeader = FALSE; | ||
|
||
// If specific payment fields have been selected for export, payment | ||
// data will already be in $row. Otherwise, add payment related | ||
// information, if appropriate. | ||
if ($addPaymentHeader) { | ||
if (!$processor->isExportSpecifiedPaymentFields()) { | ||
$nullContributionDetails = array_fill_keys(array_keys($processor->getPaymentHeaders()), NULL); | ||
if ($processor->isExportPaymentFields()) { | ||
$paymentData = CRM_Utils_Array::value($row[$paymentTableId], $paymentDetails); | ||
if (!is_array($paymentData) || empty($paymentData)) { | ||
|
@@ -1304,6 +1288,11 @@ public static function postalMailingFormat($exportTempTable, &$headerRows, &$sql | |
|
||
/** | ||
* Build componentPayment fields. | ||
* | ||
* This is no longer used by export but BAO_Mapping still calls it & we | ||
* should find a generic way to handle this or move this to that class. | ||
* | ||
* @deprecated | ||
*/ | ||
public static function componentPaymentFields() { | ||
static $componentPaymentFields; | ||
|
@@ -1345,8 +1334,8 @@ public static function setHeaderRows($field, $headerRows, $processor) { | |
// @todo - set this correctly in the xml rather than here. | ||
$headerRows[] = ts('IM Service Provider'); | ||
} | ||
elseif ($processor->isExportPaymentFields() && array_key_exists($field, self::componentPaymentFields())) { | ||
$headerRows[] = CRM_Utils_Array::value($field, self::componentPaymentFields()); | ||
elseif ($processor->isExportPaymentFields() && array_key_exists($field, $processor->getcomponentPaymentFields())) { | ||
$headerRows[] = CRM_Utils_Array::value($field, $processor->getcomponentPaymentFields()); | ||
} | ||
else { | ||
$headerRows[] = $field; | ||
|
@@ -1807,7 +1796,7 @@ protected static function getTransformedFieldValue($field, $iterationDAO, $field | |
} | ||
} | ||
} | ||
elseif ($processor->isExportSpecifiedPaymentFields() && array_key_exists($field, self::componentPaymentFields())) { | ||
elseif ($processor->isExportSpecifiedPaymentFields() && array_key_exists($field, $processor->getcomponentPaymentFields())) { | ||
$paymentTableId = $processor->getPaymentTableID(); | ||
$paymentData = CRM_Utils_Array::value($iterationDAO->$paymentTableId, $paymentDetails); | ||
$payFieldMapper = array( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replaced by $processor->getPaymentHeaders(