From 2f5a251ac3c54da2f5f971455e7230723facc865 Mon Sep 17 00:00:00 2001 From: eileen Date: Sat, 15 Feb 2020 15:45:13 +1300 Subject: [PATCH] [REF] Fix static call to non-static function. This non-static function was being called statically. On grepping I found it is only called from this one place so I moved it to the form --- CRM/Event/BAO/Participant.php | 76 -------------------------------- CRM/Event/Form/Participant.php | 80 ++++++++++++++++++++++++++++++++-- 2 files changed, 77 insertions(+), 79 deletions(-) diff --git a/CRM/Event/BAO/Participant.php b/CRM/Event/BAO/Participant.php index bb64e18477..78e03b3c40 100644 --- a/CRM/Event/BAO/Participant.php +++ b/CRM/Event/BAO/Participant.php @@ -1043,82 +1043,6 @@ WHERE cpf.price_set_id = %1 AND cpfv.label LIKE %2"; return CRM_Core_DAO::singleValueQuery($query, $params); } - /** - * Get the event fee info for given participant ids - * either from line item table / participant table. - * - * @param array $participantIds - * Participant ids. - * @param bool $hasLineItems - * Do fetch from line items. - * - * @return array - */ - public function getFeeDetails($participantIds, $hasLineItems = FALSE) { - $feeDetails = []; - if (!is_array($participantIds) || empty($participantIds)) { - return $feeDetails; - } - - $select = ' -SELECT participant.id as id, - participant.fee_level as fee_level, - participant.fee_amount as fee_amount'; - $from = 'FROM civicrm_participant participant'; - if ($hasLineItems) { - $select .= ' , -lineItem.id as lineId, -lineItem.label as label, -lineItem.qty as qty, -lineItem.unit_price as unit_price, -lineItem.line_total as line_total, -field.label as field_title, -field.html_type as html_type, -field.id as price_field_id, -value.id as price_field_value_id, -value.description as description, -IF( value.count, value.count, 0 ) as participant_count'; - $from .= " -INNER JOIN civicrm_line_item lineItem ON ( lineItem.entity_table = 'civicrm_participant' - AND lineItem.entity_id = participant.id ) -INNER JOIN civicrm_price_field field ON ( field.id = lineItem.price_field_id ) -INNER JOIN civicrm_price_field_value value ON ( value.id = lineItem.price_field_value_id ) -"; - } - $where = 'WHERE participant.id IN ( ' . implode(', ', $participantIds) . ' )'; - $query = "$select $from $where"; - - $feeInfo = CRM_Core_DAO::executeQuery($query); - $feeProperties = ['fee_level', 'fee_amount']; - $lineProperties = [ - 'lineId', - 'label', - 'qty', - 'unit_price', - 'line_total', - 'field_title', - 'html_type', - 'price_field_id', - 'participant_count', - 'price_field_value_id', - 'description', - ]; - while ($feeInfo->fetch()) { - if ($hasLineItems) { - foreach ($lineProperties as $property) { - $feeDetails[$feeInfo->id][$feeInfo->lineId][$property] = $feeInfo->$property; - } - } - else { - foreach ($feeProperties as $property) { - $feeDetails[$feeInfo->id][$property] = $feeInfo->$property; - } - } - } - - return $feeDetails; - } - /** * Retrieve additional participants display-names and URL to view their participant records. * (excludes cancelled participants automatically) diff --git a/CRM/Event/Form/Participant.php b/CRM/Event/Form/Participant.php index 94402038c0..1c30a29c13 100644 --- a/CRM/Event/Form/Participant.php +++ b/CRM/Event/Form/Participant.php @@ -1885,9 +1885,7 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment if (CRM_Event_BAO_Participant::isPrimaryParticipant($this->_id)) { $additionalIds = CRM_Event_BAO_Participant::getAdditionalParticipantIds($this->_id); $hasLineItems = CRM_Utils_Array::value('priceSetId', $params, FALSE); - $additionalParticipantDetails = CRM_Event_BAO_Participant::getFeeDetails($additionalIds, - $hasLineItems - ); + $additionalParticipantDetails = $this->getFeeDetails($additionalIds, $hasLineItems); } } else { @@ -2274,4 +2272,80 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment } } + /** + * Get the event fee info for given participant ids + * either from line item table / participant table. + * + * @param array $participantIds + * Participant ids. + * @param bool $hasLineItems + * Do fetch from line items. + * + * @return array + */ + public function getFeeDetails($participantIds, $hasLineItems = FALSE) { + $feeDetails = []; + if (!is_array($participantIds) || empty($participantIds)) { + return $feeDetails; + } + + $select = ' +SELECT participant.id as id, + participant.fee_level as fee_level, + participant.fee_amount as fee_amount'; + $from = 'FROM civicrm_participant participant'; + if ($hasLineItems) { + $select .= ' , +lineItem.id as lineId, +lineItem.label as label, +lineItem.qty as qty, +lineItem.unit_price as unit_price, +lineItem.line_total as line_total, +field.label as field_title, +field.html_type as html_type, +field.id as price_field_id, +value.id as price_field_value_id, +value.description as description, +IF( value.count, value.count, 0 ) as participant_count'; + $from .= " +INNER JOIN civicrm_line_item lineItem ON ( lineItem.entity_table = 'civicrm_participant' + AND lineItem.entity_id = participant.id ) +INNER JOIN civicrm_price_field field ON ( field.id = lineItem.price_field_id ) +INNER JOIN civicrm_price_field_value value ON ( value.id = lineItem.price_field_value_id ) +"; + } + $where = 'WHERE participant.id IN ( ' . implode(', ', $participantIds) . ' )'; + $query = "$select $from $where"; + + $feeInfo = CRM_Core_DAO::executeQuery($query); + $feeProperties = ['fee_level', 'fee_amount']; + $lineProperties = [ + 'lineId', + 'label', + 'qty', + 'unit_price', + 'line_total', + 'field_title', + 'html_type', + 'price_field_id', + 'participant_count', + 'price_field_value_id', + 'description', + ]; + while ($feeInfo->fetch()) { + if ($hasLineItems) { + foreach ($lineProperties as $property) { + $feeDetails[$feeInfo->id][$feeInfo->lineId][$property] = $feeInfo->$property; + } + } + else { + foreach ($feeProperties as $property) { + $feeDetails[$feeInfo->id][$property] = $feeInfo->$property; + } + } + } + + return $feeDetails; + } + } -- 2.25.1