Skip to content
Snippets Groups Projects
Commit 3e93468d authored by Andie Hunt's avatar Andie Hunt
Browse files

financial#139 prep: move CRM_Contribute_Form_Task_Status::getDetails to...

financial#139 prep: move CRM_Contribute_Form_Task_Status::getDetails to CRM_Contribute_Form_Task_Status::PDF because it'll be the only place it's used anymore
parent a9e97cdf
No related branches found
No related tags found
No related merge requests found
......@@ -253,7 +253,7 @@ AND {$this->_componentClause}";
$pdfElements['contribIDs'] = implode(',', $contribIds);
$pdfElements['details'] = CRM_Contribute_Form_Task_Status::getDetails($pdfElements['contribIDs']);
$pdfElements['details'] = self::getDetails($pdfElements['contribIDs']);
$pdfElements['baseIPN'] = new CRM_Core_Payment_BaseIPN();
......@@ -295,4 +295,47 @@ AND {$this->_componentClause}";
return $pdfElements;
}
/**
* @param string $contributionIDs
*
* @return array
*/
private static function getDetails($contributionIDs) {
if (empty($contributionIDs)) {
return [];
}
$query = "
SELECT c.id as contribution_id,
c.contact_id as contact_id ,
mp.membership_id as membership_id ,
pp.participant_id as participant_id ,
p.event_id as event_id
FROM civicrm_contribution c
LEFT JOIN civicrm_membership_payment mp ON mp.contribution_id = c.id
LEFT JOIN civicrm_participant_payment pp ON pp.contribution_id = c.id
LEFT JOIN civicrm_participant p ON pp.participant_id = p.id
WHERE c.id IN ( $contributionIDs )";
$rows = [];
$dao = CRM_Core_DAO::executeQuery($query);
while ($dao->fetch()) {
$rows[$dao->contribution_id]['component'] = $dao->participant_id ? 'event' : 'contribute';
$rows[$dao->contribution_id]['contact'] = $dao->contact_id;
if ($dao->membership_id) {
if (!array_key_exists('membership', $rows[$dao->contribution_id])) {
$rows[$dao->contribution_id]['membership'] = [];
}
$rows[$dao->contribution_id]['membership'][] = $dao->membership_id;
}
if ($dao->participant_id) {
$rows[$dao->contribution_id]['participant'] = $dao->participant_id;
}
if ($dao->event_id) {
$rows[$dao->contribution_id]['event'] = $dao->event_id;
}
}
return $rows;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment