}
CRM_Activity_BAO_Activity::create($activityParams);
}
+
+ function getPaymentInfo($id, $component, $getTrxnInfo = FALSE) {
+ if ($component == 'event') {
+ $entity = 'participant';
+ $contributionId = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_ParticipantPayment', $id, 'contribution_id', 'participant_id');
+ }
+ $total = CRM_Core_BAO_FinancialTrxn::getBalanceTrxnAmt($contributionId);
+ $baseTrxnId = $total['trxn_id'];
+ $total = $total['total_amount'];
+ $paymentBalance = CRM_Core_BAO_FinancialTrxn::getPartialPaymentWithType($id, $entity, FALSE);
+
+ $info['total'] = $total;
+ $info['paid'] = $total - $paymentBalance;
+ $info['balance'] = $paymentBalance;
+ $info['id'] = $id;
+ $info['component'] = $component;
+
+ if ($getTrxnInfo) {
+ $sql = "
+SELECT ft.total_amount, con.financial_type_id, ft.payment_instrument_id, ft.trxn_date, ft.trxn_id, ft.status_id
+FROM civicrm_contribution con
+ LEFT JOIN civicrm_entity_financial_trxn eft ON (eft.entity_id = con.id AND eft.entity_table = 'civicrm_contribution')
+ LEFT JOIN civicrm_financial_trxn ft ON ft.id = eft.financial_trxn_id
+WHERE ft.id != {$baseTrxnId} AND con.id = {$contributionId}
+";
+ $resultDAO = CRM_Core_DAO::executeQuery($sql);
+
+ $rows = array();
+ while($resultDAO->fetch()) {
+ $paymentInstrument = CRM_Contribute_PseudoConstant::paymentInstrument();
+ $statuses = CRM_Contribute_PseudoConstant::contributionStatus();
+ $financialTypes = CRM_Contribute_PseudoConstant::financialType();
+ $rows[] = array(
+ 'total_amount' => $resultDAO->total_amount,
+ 'financial_type' => $financialTypes[$resultDAO->financial_type_id],
+ 'payment_instrument' => $paymentInstrument[$resultDAO->payment_instrument_id],
+ 'receive_date' => $resultDAO->trxn_date,
+ 'trxn_id' => $resultDAO->trxn_id,
+ 'status' => $statuses[$resultDAO->status_id],
+ );
+ }
+ $info['transaction'] = $rows;
+ }
+ return $info;
+ }
}
\ No newline at end of file
}
$statusMsg = ts('The payment record has been processed.');
- if (CRM_Utils_Array::value('is_email_receipt', $this->_$submittedValues) && $sendReceipt) {
+ if (CRM_Utils_Array::value('is_email_receipt', $submittedValues) && $sendReceipt) {
$statusMsg .= ' ' . ts('A receipt has been emailed to the contributor.');
}
CRM_Core_Session::setStatus($statusMsg, ts('Saved'), 'success');
<page_callback>CRM_Financial_Form_Export</page_callback>
<weight>610</weight>
</item>
-</menu>
+ <item>
+ <path>civicrm/payment/view</path>
+ <title>View Payment</title>
+ <page_callback>CRM_Contribute_Page_PaymentInfo</page_callback>
+ <path_arguments>action=view</path_arguments>
+ <access_arguments>access CiviContribute</access_arguments>
+ <page_type>1</page_type>
+ <component>CiviContribute</component>
+ </item>
+</menu>
\ No newline at end of file
return $trxn;
}
- static function getBalanceTrxnAmt($contributionId, $contributionFinancialTypeId) {
+ static function getBalanceTrxnAmt($contributionId, $contributionFinancialTypeId = NULL) {
+ if (!$contributionFinancialTypeId) {
+ $contributionFinancialTypeId = CRM_Core_DAO::getFieldValue('CRM_Contribute_BAO_Contribution', $contributionId, 'financial_type_id');
+ }
$relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Accounts Receivable Account is' "));
$toFinancialAccount = CRM_Contribute_PseudoConstant::financialAccountType($contributionFinancialTypeId, $relationTypeId);
$q = "SELECT ft.id, ft.total_amount FROM civicrm_financial_trxn ft INNER JOIN civicrm_entity_financial_trxn eft ON (eft.financial_trxn_id = ft.id AND eft.entity_table = 'civicrm_contribution') WHERE eft.entity_id = %1 AND ft.to_financial_account_id = %2";
* return @array : payment type => amount
* payment type : 'amount_owed' or 'refund_due'
*/
- static function getPartialPaymentWithType($entityId, $entityName = 'pariticpant') {
+ static function getPartialPaymentWithType($entityId, $entityName = 'pariticpant', $returnType = TRUE) {
$value = NULL;
if (empty($entityName)) {
return $value;
";
$ftTotalAmt = CRM_Core_DAO::singleValueQuery($sqlFtTotalAmt);
- $paymentVal = $lineItemTotal - $ftTotalAmt;
- if ($paymentVal < 0) {
- $value['refund_due'] = $paymentVal;
- }
- elseif ($paymentVal > 0) {
- $value['amount_owed'] = $paymentVal;
+ $value = $paymentVal = $lineItemTotal - $ftTotalAmt;
+ if ($returnType) {
+ $value = array();
+ if ($paymentVal < 0) {
+ $value['refund_due'] = $paymentVal;
+ }
+ elseif ($paymentVal > 0) {
+ $value['amount_owed'] = $paymentVal;
+ }
}
}
}
else {
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
}
+ $participantStatuses = CRM_Event_PseudoConstant::participantStatus();
if ($this->_id) {
+ $this->assign('participantId', $this->_id);
+ $feePaymentBlock = FALSE;
+ $statusId = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_Participant', $this->_id, 'status_id', 'id');
+
+ if (in_array($participantStatuses[$statusId], array('Partially paid', 'Pending refund'))) {
+ $feePaymentBlock = TRUE;
+ }
+ $this->assign('feePaymentBlock', $feePaymentBlock);
$this->_paymentId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment',
$this->_id, 'id', 'participant_id'
);
$this->assign('eventNameCustomDataTypeID', $this->_eventNameCustomDataTypeID);
$this->assign('eventTypeCustomDataTypeID', $this->_eventTypeCustomDataTypeID);
- $partiallyPaidStatusId = CRM_Event_PseudoConstant::participantStatus();
- $partiallyPaidStatusId = array_search('Partially paid', $partiallyPaidStatusId);
+ $partiallyPaidStatusId = array_search('Partially paid', $participantStatuses);
$this->assign('partiallyPaidStatusId', $partiallyPaidStatusId);
if ($this->_mode) {
* @access public
*/
public function buildQuickForm() {
+ if ($this->_action == CRM_Core_Action::UPDATE) {
+ CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js');
+ }
if ($this->_showFeeBlock) {
return CRM_Event_Form_EventFees::buildQuickForm($this);
}
</script>
{/literal}
{/if}
+ {if $participantId and $feePaymentBlock}
+ {include file="CRM/Contribute/Page/PaymentInfo.tpl" show='event-payment'}
+ {/if}
{include file="CRM/Event/Form/EventFees.tpl"}
-
-{elseif $cdType }
+{elseif $cdType}
{include file="CRM/Custom/Form/CustomData.tpl"}
{else}
{if $participantMode == 'test' }
<span class="description">{ts}Source for this registration (if applicable).{/ts}</span></td>
</tr>
</table>
-
+ {if $participantId and $feePaymentBlock}
+ <table class='form-layout'>
+ <tr>
+ <td class='label'>{ts}Fees{/ts}</td>
+ {* this is where the payment info is shown using CRM/Contribute/Page/PaymentInfo.tpl tpl*}
+ <td id='payment-info'></td>
+ </tr>
+ </table>
+ {/if}
{* Fee block (EventFees.tpl) is injected here when an event is selected. *}
<div id="feeBlock"></div>
<fieldset>