* @param $eventID
* @param $participantRoles
* @param $receiptText
- * @param $isPaidEvent
*
* @return void
*/
- protected function assignEventDetailsToTpl($eventID, $participantRoles, $receiptText, $isPaidEvent) {
+ protected function assignEventDetailsToTpl($eventID, $participantRoles, $receiptText) {
//use of the message template below requires variables in different format
$events = [];
$returnProperties = ['event_type_id', 'fee_label', 'start_date', 'end_date', 'is_show_location', 'title'];
else {
$event['participant_role'] = $role[$participantRoles] ?? NULL;
}
- $event['is_monetary'] = $isPaidEvent;
+ $event['is_monetary'] = $this->_isPaidEvent;
if ($receiptText) {
$event['confirm_email_text'] = $receiptText;
return $this->_id ?: NULL;
}
- /**
- * Get the contribution ID associated with the participant record.
- *
- *
- * @api This function will not change in a minor release and is supported for
- * use outside of core. This annotation / external support for properties
- * is only given where there is specific test cover.
- *
- * @return int|null
- * @throws \CRM_Core_Exception
- */
- public function getContributionID(): ?int {
- if (!isset($this->contributionID)) {
- $this->contributionID = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment',
- $this->getParticipantID(), 'contribution_id', 'participant_id'
- );
- }
- return $this->contributionID;
- }
-
/**
* Get the value for the revenue recognition date field.
*
$sent = [];
$notSent = [];
$this->assign('module', 'Event Registration');
- $this->assignEventDetailsToTpl($params['event_id'], CRM_Utils_Array::value('role_id', $params), CRM_Utils_Array::value('receipt_text', $params), $this->_isPaidEvent);
-
+ $this->assignEventDetailsToTpl($params['event_id'], CRM_Utils_Array::value('role_id', $params), CRM_Utils_Array::value('receipt_text', $params));
+ // @todo - this is no longer in core templates as of 5.63
+ // we should remove once we have done a 'push upgrade' on addresses - ie advised
+ // people to upgrade their templates in an upgrade message, as
+ // opposed to just updating unmodified templates.
+ $this->assign('isPrimary', (int) $this->_isPaidEvent);
if ($this->_isPaidEvent) {
$paymentInstrument = CRM_Contribute_PseudoConstant::paymentInstrument();
if (!$this->_mode) {
}
$this->assign('totalAmount', $params['total_amount'] ?? $total_amount);
- $this->assign('isPrimary', 1);
$this->assign('checkNumber', CRM_Utils_Array::value('check_number', $params));
}
if ($this->_mode) {
$valuesForForm = CRM_Contribute_Form_AbstractEditPayment::formatCreditCardDetails($params);
$this->assignVariables($valuesForForm, ['credit_card_exp_date', 'credit_card_type', 'credit_card_number']);
$this->assign('is_pay_later', 0);
- $this->assign('isPrimary', 1);
}
$this->assign('register_date', $params['register_date']);
$this->assign('contactID', $contactID);
$this->assign('participantID', $participants[$num]->id);
+ $contributionID = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment',
+ $participants[$num]->id, 'contribution_id', 'participant_id'
+ );
$this->_id = $participants[$num]->id;
if ($this->_isPaidEvent) {
'modelProps' => [
'participantID' => $this->_id,
'eventID' => $params['event_id'],
- 'contributionID' => $this->getContributionID(),
+ 'contributionID' => $contributionID,
],
];
$taxAmt = $template->get_template_vars('dataArray');
if (Civi::settings()->get('invoice_is_email_pdf')) {
$sendTemplateParams['isEmailPdf'] = TRUE;
- $sendTemplateParams['contributionId'] = $this->getContributionID();
+ $sendTemplateParams['contributionId'] = $contributionID;
}
[$mailSent, $subject, $message, $html] = CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams);
if ($mailSent) {
protected $_toDoNotEmail = NULL;
- protected $_contributionId = NULL;
+ protected $contributionID;
protected $fromEmailId = NULL;
$this->_eventId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $this->_participantId, 'event_id');
$this->_fromEmails = CRM_Event_BAO_Event::getFromEmailIds($this->_eventId);
- $this->_contributionId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $this->_participantId, 'contribution_id', 'participant_id');
- if (!$this->_contributionId) {
- if ($primaryParticipantId = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_Participant', $this->_participantId, 'registered_by_id')) {
- $this->_contributionId = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_ParticipantPayment', $primaryParticipantId, 'contribution_id', 'participant_id');
- }
- }
-
- if ($this->_contributionId) {
+ if ($this->getContributionID()) {
$this->_isPaidEvent = TRUE;
}
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, TRUE);
$this->assign('paymentInfo', $paymentInfo);
$this->assign('feePaid', $this->_paidAmount);
- $ids = CRM_Event_BAO_Participant::getParticipantIds($this->_contributionId);
+ $ids = CRM_Event_BAO_Participant::getParticipantIds($this->getContributionID());
if (count($ids) > 1) {
- $total = CRM_Price_BAO_LineItem::getLineTotal($this->_contributionId);
+ $total = CRM_Price_BAO_LineItem::getLineTotal($this->getContributionID());
$this->assign('totalLineTotal', $total);
$this->assign('lineItemTotal', $total);
}
}
}
+ /**
+ * Get the contribution ID.
+ *
+ * @api This function will not change in a minor release and is supported for
+ * use outside of core. This annotation / external support for properties
+ * is only given where there is specific test cover.
+ *
+ * @noinspection PhpUnhandledExceptionInspection
+ */
+ public function getContributionID(): ?int {
+ if ($this->contributionID === NULL) {
+ $this->contributionID = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $this->_participantId, 'contribution_id', 'participant_id') ?: FALSE;
+
+ if (!$this->contributionID) {
+ $primaryParticipantID = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_Participant', $this->_participantId, 'registered_by_id');
+ if ($primaryParticipantID) {
+ $this->contributionID = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_ParticipantPayment', $primaryParticipantID, 'contribution_id', 'participant_id') ?: FALSE;
+ }
+ }
+ }
+ return $this->contributionID ?: NULL;
+ }
+
/**
* Set default values for the form.
*
$feeBlock = $this->_values['fee'];
$lineItems = $this->_values['line_items'];
- CRM_Price_BAO_LineItem::changeFeeSelections($params, $this->_participantId, 'participant', $this->_contributionId, $feeBlock, $lineItems);
- $this->contributionAmt = CRM_Core_DAO::getFieldValue('CRM_Contribute_BAO_Contribution', $this->_contributionId, 'total_amount');
+ CRM_Price_BAO_LineItem::changeFeeSelections($params, $this->_participantId, 'participant', $this->getContributionID(), $feeBlock, $lineItems);
+ $this->contributionAmt = CRM_Core_DAO::getFieldValue('CRM_Contribute_BAO_Contribution', $this->getContributionID(), 'total_amount');
// email sending
if (!empty($params['send_receipt'])) {
$fetchParticipantVals = ['id' => $this->_participantId];
}
$this->assign('totalAmount', $this->contributionAmt);
-
- $this->assign('isPrimary', 1);
$this->assign('checkNumber', CRM_Utils_Array::value('check_number', $params));
}
-
+ // @todo isPrimary no longer used from 5.63 in core templates, remove
+ // once users have been 'pushed' to update their templates (via
+ // upgrade message - which we don't always do whenever we change
+ // a minor variable.
+ $this->assign('isPrimary', $this->_isPaidEvent);
$this->assign('register_date', $params['register_date']);
// Retrieve the name and email of the contact - this will be the TO for receipt email
'modelProps' => [
'participantID' => $this->_participantId,
'eventID' => $params['event_id'],
+ 'contributionID' => $this->getContributionID(),
],
];
{/if}
{if !empty($isOnWaitlist)}
- <p>{ts}You have been added to the WAIT LIST for this event.{/ts}</p>
- {if !empty($isPrimary)}
- <p>{ts}If space becomes available you will receive an email with a link to a web page where you can complete your registration.{/ts}</p>
- {/if}
+ <p>{ts}You have been added to the WAIT LIST for this event.{/ts}</p>
+ <p>{ts}If space becomes available you will receive an email with a link to a web page where you can complete your registration.{/ts}</p>
{elseif !empty($isRequireApproval)}
- <p>{ts}Your registration has been submitted.{/ts}</p>
- {if !empty($isPrimary)}
+ <p>{ts}Your registration has been submitted.{/ts}</p>
<p>{ts}Once your registration has been reviewed, you will receive an email with a link to a web page where you can complete the registration process.{/ts}</p>
- {/if}
{elseif $is_pay_later}
<p>{$pay_later_receipt}</p> {* FIXME: this might be text rather than HTML *}
{/if}
{/if}
- {if !empty($event.is_monetary)}
+ {if {event.is_monetary|boolean}}
<tr>
<th {$headerStyle}>
{if !empty($lineItem)}
{foreach from=$lineItem item=value key=priceset}
{if $value neq 'skip'}
- {if !empty($isPrimary)}
{if $lineItem|@count GT 1} {* Header for multi participant registration cases. *}
<tr>
<td colspan="2" {$labelStyle}>
</td>
</tr>
{/if}
- {/if}
+
<tr>
<td colspan="2" {$valueStyle}>
<table>
</td>
</tr>
{/if}
- {if !empty($isPrimary)}
+ {if {event.is_monetary|boolean}}
{if {contribution.balance_amount|boolean}}
<tr>
<td {$labelStyle}>{ts}Total Paid{/ts}</td>
{ts}You have been added to the WAIT LIST for this event.{/ts}
-{if !empty($isPrimary)}
{ts}If space becomes available you will receive an email with a link to a web page where you can complete your registration.{/ts}
-{/if}
==========================================================={if !empty($pricesetFieldsCount) }===================={/if}
{elseif !empty($isRequireApproval)}
{ts}Your registration has been submitted.{/ts}
-{if !empty($isPrimary)}
{ts}Once your registration has been reviewed, you will receive an email with a link to a web page where you can complete the registration process.{/ts}
-{/if}
==========================================================={if !empty($pricesetFieldsCount) }===================={/if}
{elseif $is_pay_later}
{if !empty($lineItem)}{foreach from=$lineItem item=value key=priceset}
{if $value neq 'skip'}
-{if !empty($isPrimary)}
+{if {event.is_monetary|boolean}}
{if $lineItem|@count GT 1} {* Header for multi participant registration cases. *}
{ts 1=$priceset+1}Participant %1{/ts}
{/if}
{if $totalTaxAmount}
{ts}Total Tax Amount{/ts}: {$totalTaxAmount|crmMoney:$currency}
{/if}
-{if !empty($isPrimary)}
+{if {event.is_monetary|boolean}}
{if {contribution.balance_amount|boolean}}{ts}Total Paid{/ts}: {if {contribution.paid_amount|boolean}}{contribution.paid_amount}{/if} {if !empty($hookDiscount.message)}({$hookDiscount.message}){/if}
{ts}Balance{/ts}: {contribution.balance_amount}