Skip to content

Commit

Permalink
changes to append balance_due column using civicrm_searchColumns hook
Browse files Browse the repository at this point in the history
  • Loading branch information
monishdeb committed May 3, 2017
1 parent 0f4a79f commit f7e47d8
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 20 deletions.
28 changes: 12 additions & 16 deletions CRM/Contribute/Selector/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -402,13 +402,6 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) {
}
}

$row['balance_due'] = CRM_Core_BAO_FinancialTrxn::getPartialPaymentWithType(
$result->contribution_id,
'contribution',
FALSE,
$result->total_amount
);

//carry campaign on selectors.
// @todo - I can't find any evidence that 'carrying' the campaign on selectors actually
// results in it being displayed anywhere so why do we do this???
Expand Down Expand Up @@ -518,9 +511,6 @@ public function &getColumnHeaders($action = NULL, $output = NULL) {
'sort' => 'total_amount',
'direction' => CRM_Utils_Sort::DONTCARE,
),
array(
'name' => ts('Balance Due'),
),
);
if ($this->_includeSoftCredits) {
self::$_columnHeaders
Expand Down Expand Up @@ -564,6 +554,11 @@ public function &getColumnHeaders($action = NULL, $output = NULL) {
'sort' => 'contribution_status',
'direction' => CRM_Utils_Sort::DONTCARE,
),
array(
'name' => ts('Premium'),
'sort' => 'product_name',
'direction' => CRM_Utils_Sort::DONTCARE,
),
)
);
if (!$this->_single) {
Expand Down Expand Up @@ -593,12 +588,13 @@ public function &getColumnHeaders($action = NULL, $output = NULL) {
)
);
}
self::$_columnHeaders
= array_merge(
self::$_columnHeaders, array(
array('desc' => ts('Actions')),
)
);
self::$_columnHeaders = array_merge(self::$_columnHeaders,
array(
'actions' => array(
'desc' => ts('Actions'),
),
)
);
CRM_Core_Smarty::singleton()->assign('softCreditColumns', $this->_includeSoftCredits);
return self::$_columnHeaders;
}
Expand Down
21 changes: 17 additions & 4 deletions templates/CRM/Contribute/Form/Selector.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,17 @@
{if !$single and $context eq 'Search' }
<th scope="col" title="Select Rows">{$form.toggleSelect.html}</th>
{/if}
{foreach from=$columnHeaders item=header}
{if $columnHeaders.hookHeaders}
{assign var='hookHeaders' value=$columnHeaders.hookHeaders}
{/if}
{foreach from=$columnHeaders key=index item=header}
<th scope="col">
{* Append user-defined header before action column *}
{if $index === 'actions' and $hookHeaders}
{foreach from=$hookHeaders item=hookHeader}
{$hookHeader.name}
{/foreach}
{/if}
{if $header.sort}
{assign var='key' value=$header.sort}
{$sort->_response.$key.link}
Expand Down Expand Up @@ -67,9 +76,6 @@
{if $row.amount_level }<br/>({$row.amount_level}){/if}
{if $row.contribution_recur_id}<br/>{ts}(Recurring){/ts}{/if}
</td>
<td class="crm-contribution-balance_due bold">
{$row.balance_due|crmMoney:$row.currency}
</td>
{if $softCreditColumns}
<td class="right bold crm-contribution-soft_credit_amount">
<span class="nowrap">{$row.contribution_soft_credit_amount|crmMoney:$row.currency}</span>
Expand All @@ -93,12 +99,19 @@
{$row.cancel_date|crmDate}
{/if}
</td>
<td class="crm-contribution-product_name">{$row.product_name}</td>
{if $softCreditColumns}
<td class="crm-contribution-soft_credit_name">
<a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=`$row.contribution_soft_credit_contact_id`"}">{$row.contribution_soft_credit_name}</a>
</td>
<td class="crm-contribution-soft_credit_type">{$row.contribution_soft_credit_type}</td>
{/if}
{* Append user-defined row before action column *}
{if $hookHeaders}
{foreach from=$hookHeaders key=rowName item=header}
<td class="crm-{$rowName}">{$row.$rowName}</td>
{/foreach}
{/if}
<td>{$row.action|replace:'xx':$row.contribution_id}</td>
</tr>
{/foreach}
Expand Down

0 comments on commit f7e47d8

Please sign in to comment.