Merge remote-tracking branch 'upstream/4.3' into 4.3-master-2013-05-21-13-15-18
[civicrm-core.git] / CRM / Event / Form / Participant.php
index e9555ef4be17ba8da5947a79f5e8c4ad8d843e90..6fe4d260de3215ebe4796c8c2e2a58232ea2c3c4 100644 (file)
@@ -233,6 +233,18 @@ class CRM_Event_Form_Participant extends CRM_Contact_Form_Task {
       $this->_paymentId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment',
         $this->_id, 'id', 'participant_id'
       );
+      // CRM-12615 - Get payment information from the primary registration
+      if ((!$this->_paymentId) && ($this->_action == CRM_Core_Action::UPDATE)) {
+        $registered_by_id = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant',
+          $this->_id, 'registered_by_id', 'id'
+        );
+        if ($registered_by_id) {
+          $this->_paymentId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment',
+            $registered_by_id, 'id', 'participant_id'
+          );
+          $this->assign('registeredByParticipantId', $registered_by_id);
+        }
+      }
     }
 
     // get the option value for custom data type