Skip to content

Commit

Permalink
CRM-16189, Added add payment link on contribution search
Browse files Browse the repository at this point in the history
----------------------------------------
* CRM-16189: Improve support for Accrual Method bookkeeping
  https://issues.civicrm.org/jira/browse/CRM-16189
  • Loading branch information
pradpnayak committed Aug 11, 2016
1 parent 9af7026 commit 451ce63
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
26 changes: 24 additions & 2 deletions CRM/Contribute/Selector/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class CRM_Contribute_Selector_Search extends CRM_Core_Selector_Base implements C
'contribution_soft_credit_contact_id',
'contribution_soft_credit_amount',
'contribution_soft_credit_type',
'participant_contribution_id',
);

/**
Expand Down Expand Up @@ -183,11 +184,12 @@ public function __construct(

// type of selector
$this->_action = $action;

$returnProperties = CRM_Contribute_BAO_Query::selectorReturnProperties();
$returnProperties['participant_contribution_id'] = 1;
$this->_includeSoftCredits = CRM_Contribute_BAO_Query::isSoftCreditOptionEnabled($this->_queryParams);
$this->_query = new CRM_Contact_BAO_Query(
$this->_queryParams,
CRM_Contribute_BAO_Query::selectorReturnProperties(),
$returnProperties,
NULL, FALSE, FALSE,
CRM_Contact_BAO_Query::MODE_CONTRIBUTE
);
Expand Down Expand Up @@ -433,7 +435,27 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) {
'id' => $result->contribution_id,
'cid' => $result->contact_id,
'cxt' => $this->_context,
'pid' => $result->participant_id,
);
if (!empty($row['participant_contribution_id'])) {
if ($row['contribution_status_name'] == 'Partially paid') {
$links[CRM_Core_Action::ADD] = array(
'name' => ts('Record Payment'),
'url' => 'civicrm/payment',
'qs' => 'reset=1&id=%%pid%%&cid=%%cid%%&action=add&component=event',
'title' => ts('Record Payment'),
);
}

if ($row['contribution_status_name'] == 'Pending refund') {
$links[CRM_Core_Action::ADD] = array(
'name' => ts('Record Refund'),
'url' => 'civicrm/payment',
'qs' => 'reset=1&id=%%pid%%&cid=%%cid%%&action=add&component=event',
'title' => ts('Record Refund'),
);
}
}

$row['action'] = CRM_Core_Action::formLink(
$links,
Expand Down
11 changes: 11 additions & 0 deletions CRM/Event/BAO/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ public static function select(&$query) {
$query->_element['participant_fee_amount'] = 1;
}

if (!empty($query->_returnProperties['participant_contribution_id'])) {
$query->_select['participant_contribution_id'] = "civicrm_participant_payment.participant_id as participant_contribution_id";
$query->_element['participant_contribution_id'] = 1;
$query->_tables['civicrm_contribution_participant_payment'] = 1;
$query->_whereTables['civicrm_contribution_participant_payment'] = 1;
}

//add fee currency
if (!empty($query->_returnProperties['participant_fee_currency'])) {
$query->_select['participant_fee_currency'] = "civicrm_participant.fee_currency as participant_fee_currency";
Expand Down Expand Up @@ -479,6 +486,10 @@ public static function from($name, $mode, $side) {
$from = " LEFT JOIN civicrm_participant ON civicrm_participant.contact_id = contact_a.id ";
break;

case 'civicrm_contribution_participant_payment':
$from = " $side JOIN civicrm_participant_payment ON civicrm_contribution.id = civicrm_participant_payment.contribution_id ";
break;

case 'civicrm_event':
//CRM-17121
$from = " LEFT JOIN civicrm_event ON civicrm_participant.event_id = civicrm_event.id ";
Expand Down

0 comments on commit 451ce63

Please sign in to comment.