From d4c0653fd0a283f79586395e7159c27b3f4ea0de Mon Sep 17 00:00:00 2001 From: eileen Date: Wed, 25 Nov 2015 13:02:15 +1300 Subject: [PATCH] CRM-17620 expose payment data for contributions in the UI --- CRM/Contribute/BAO/Contribution.php | 6 +++ CRM/Contribute/Form/AdditionalPayment.php | 10 ++++ CRM/Contribute/Selector/Search.php | 9 +++- .../CRM/Contribute/Form/AdditionalPayment.tpl | 17 ++++-- templates/CRM/Contribute/Form/Selector.tpl | 14 ++++- templates/CRM/common/expandRow.tpl | 54 +++++++++++++++++++ 6 files changed, 103 insertions(+), 7 deletions(-) create mode 100644 templates/CRM/common/expandRow.tpl diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index 8af434153b..5bb109b267 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -3745,6 +3745,12 @@ WHERE eft.financial_trxn_id IN ({$trxnId}, {$baseTrxnId['financialTrxnId']}) } } } + else { + $contributionId = $id; + $entity = 'contribution'; + $entityTable = 'civicrm_contribution'; + } + $total = CRM_Core_BAO_FinancialTrxn::getBalanceTrxnAmt($contributionId); $baseTrxnId = !empty($total['trxn_id']) ? $total['trxn_id'] : NULL; $isBalance = NULL; diff --git a/CRM/Contribute/Form/AdditionalPayment.php b/CRM/Contribute/Form/AdditionalPayment.php index 641d560d51..2e02e3701f 100644 --- a/CRM/Contribute/Form/AdditionalPayment.php +++ b/CRM/Contribute/Form/AdditionalPayment.php @@ -81,6 +81,7 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE); $this->assign('component', $this->_component); $this->assign('id', $this->_id); + $this->assign('suppressPaymentFormButtons', $this->isBeingCalledFromSelectorContext()); if ($this->_view == 'transaction' && ($this->_action & CRM_Core_Action::BROWSE)) { $paymentInfo = CRM_Contribute_BAO_Contribution::getPaymentInfo($this->_id, $this->_component, TRUE); @@ -143,6 +144,15 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract $this->setPageTitle($this->_refund ? ts('Refund') : ts('Payment')); } + /** + * Is this function being called from a datatable selector. + * + * If so we don't want to show the buttons. + */ + protected function isBeingCalledFromSelectorContext() { + return CRM_Utils_Request::retrieve('selector', 'Positive'); + } + /** * This virtual function is used to set the default values of * various form elements diff --git a/CRM/Contribute/Selector/Search.php b/CRM/Contribute/Selector/Search.php index ee9f1fa49e..f8eae6298f 100644 --- a/CRM/Contribute/Selector/Search.php +++ b/CRM/Contribute/Selector/Search.php @@ -524,6 +524,7 @@ class CRM_Contribute_Selector_Search extends CRM_Core_Selector_Base implements C ), ) ); + $pre = array(); if (!$this->_single) { $pre = array( array('desc' => ts('Contact Type')), @@ -533,8 +534,14 @@ class CRM_Contribute_Selector_Search extends CRM_Core_Selector_Base implements C 'direction' => CRM_Utils_Sort::DONTCARE, ), ); - self::$_columnHeaders = array_merge($pre, self::$_columnHeaders); } + $pre[] = array( + array( + 'desc' => '', + array(), + ), + ); + self::$_columnHeaders = array_merge($pre, self::$_columnHeaders); if ($this->_includeSoftCredits) { self::$_columnHeaders = array_merge( self::$_columnHeaders, diff --git a/templates/CRM/Contribute/Form/AdditionalPayment.tpl b/templates/CRM/Contribute/Form/AdditionalPayment.tpl index 7d360525be..2619a88aa9 100644 --- a/templates/CRM/Contribute/Form/AdditionalPayment.tpl +++ b/templates/CRM/Contribute/Form/AdditionalPayment.tpl @@ -51,12 +51,19 @@ {else} {assign var='entity' value=$component} {/if} - {ts 1=$entity}No additional payments found for this %1 record{/ts} + {if $suppressPaymentFormButtons} + {ts 1=$entity}No payments found for this %1 record{/ts} + {else} + {* Am unsure where this appears so unsure if above text could apply *} + {ts 1=$entity}No Additional payments found for this %1 record{/ts} + {/if} {/if} -
- {include file="CRM/common/formButtons.tpl"} -
-{elseif $formType} + {if !$suppressPaymentFormButtons} +
+ {include file="CRM/common/formButtons.tpl"} +
+ {/if} + {elseif $formType} {include file="CRM/Contribute/Form/AdditionalInfo/$formType.tpl"} {else} diff --git a/templates/CRM/Contribute/Form/Selector.tpl b/templates/CRM/Contribute/Form/Selector.tpl index 22cd85f17b..f7dddb6c18 100644 --- a/templates/CRM/Contribute/Form/Selector.tpl +++ b/templates/CRM/Contribute/Form/Selector.tpl @@ -49,17 +49,24 @@ +

+ {ts}Click arrow to view payment details.{/ts} +

{counter start=0 skip=1 print=false} {foreach from=$rows item=row} - + {if !$single } {if $context eq 'Search' } {assign var=cbName value=$row.checkbox} {$form.$cbName.html} {/if} + {$row.contact_type} {$row.sort_name} {/if} + {assign var="targetRowID" value="paymentDetails"|cat:$row.contribution_id} + {include file='CRM/common/expandRow.tpl' rowEntityID=$row.contribution_id rowEntity='contribution' targetRowID=$targetRowID baseUrl='payment'} {if $row.contribution_soft_credit_amount}   {else} @@ -89,9 +96,14 @@ {/if} {$row.action|replace:'xx':$row.contribution_id} + + +   + {/foreach} {/strip} {include file="CRM/common/pager.tpl" location="bottom"} + diff --git a/templates/CRM/common/expandRow.tpl b/templates/CRM/common/expandRow.tpl new file mode 100644 index 0000000000..e352bfc4de --- /dev/null +++ b/templates/CRM/common/expandRow.tpl @@ -0,0 +1,54 @@ + + + + {ts}open section{/ts} + + + + {ts}open section{/ts} + + + + + {literal} + +{/literal} -- 2.25.1