Commit 93abe1d0 authored by mattwire's avatar mattwire
Browse files

Merge branch '3.4.2' into 'master'

3.4.2

Closes #4

See merge request extensions/ukgiftaid!11
parents 12f2be04 1a7d806b
......@@ -107,8 +107,6 @@ class CRM_Civigiftaid_Upgrader extends CRM_Civigiftaid_Upgrader_Base {
'weight' => 2,
]
)['id'];
}
/**
* Ensure we have the custom fields defined for declaration
......
......@@ -9,6 +9,8 @@
+--------------------------------------------------------------------+
*/
use CRM_Civigiftaid_ExtensionUtil as E;
/**
* Class CRM_Civigiftaid_Utils_Contribution
*/
......@@ -517,6 +519,9 @@ class CRM_Civigiftaid_Utils_Contribution {
$contributionDetails[$dao->id]['batch'] = $dao->title;
$contributionDetails[$dao->id]['batch_id'] = $dao->batch_id;
$contributionDetails[$dao->id]['line_items_count'] = 0;
CRM_Utils_System::url('civicrm/contact/view/contribution', 'reset=1&&action=view&id=255&cid=202');
$contributionDetails[$dao->id]['actions'] = self::getActionLinks($dao->contact_id, $dao->id);
}
if (count($contributionDetails)) {
......@@ -525,6 +530,11 @@ class CRM_Civigiftaid_Utils_Contribution {
return $contributionDetails;
}
private static function getActionLinks($contactID, $contributionID) {
$viewURL = CRM_Utils_System::url('civicrm/contact/view/contribution', "reset=1&&action=view&id={$contributionID}&cid={$contactID}");
return "<a href='{$viewURL}' class='crm-popup'>" . E::ts('View') . "</a>";
}
/**
* This gets a count of all lineitems for a contribution for display on the "Add to Batch" list.
*
......@@ -675,22 +685,17 @@ class CRM_Civigiftaid_Utils_Contribution {
return FALSE;
}
// If contribution is marked as not eligible for gift-aid it is not eligible..
if (!(bool) $contribution[CRM_Civigiftaid_Utils::getCustomByName('Eligible_for_Gift_Aid', 'Gift_Aid')]) {
// Contribution marked as not eligible
return FALSE;
}
$eligibleAmount = $contribution[CRM_Civigiftaid_Utils::getCustomByName('Amount', 'Gift_Aid')];
if (!empty($eligibleAmount) && ($eligibleAmount == 0)) {
// Contribution has 0 eligible amount.
return FALSE;
}
// @todo fix this code it does nothing.
$isEligible = $contribution[CRM_Civigiftaid_Utils::getCustomByName('Eligible_for_Gift_Aid', 'Gift_Aid')];
if (!empty($isEligible) && ($isEligible == 0)) {
// Contribution marked as not eligible
return FALSE;
};
// If it is not set ('') it's not the same as DECLARATION_IS_NO
// This does nothing; $contributionEligible is not defined anywhere. @todo
if (!empty($contributionEligible) && ($contributionEligible == CRM_Civigiftaid_Declaration::DECLARATION_IS_NO)) {
return FALSE;
}
foreach ($declarations as $declaration) {
if ($declaration['eligible_for_gift_aid'] == CRM_Civigiftaid_Declaration::DECLARATION_IS_PAST_4_YEARS) {
......
## Release 3.4.2
* Fix [#4](https://lab.civicrm.org/extensions/ukgiftaid/-/issues/4) - Individual donation marked as "NO" from backend, gets included in batch.
* Remove unused lineitems display from add/remove to batch.
* Add 'View' action to contributions on add/remove batch list.
## Release 3.4.1
* Add GiftAid.Updatedeclarations API
......
......@@ -18,8 +18,8 @@
<author>MJW Consulting, Rich Lott (Artful Robot) Erawat Chamanont, Jamie Novick, Guanhuan Chen, Robin Mitra</author>
<email>mjw@mjwconsult.co.uk, https://artfulrobot.uk, jamie@compucorp.co.uk, guanhuan@compucorp.co.uk</email>
</maintainer>
<releaseDate>2020-07-08</releaseDate>
<version>3.4.1</version>
<releaseDate>2020-07-09</releaseDate>
<version>3.4.2</version>
<develStage>stable</develStage>
<compatibility>
<ver>5.24</ver>
......
......@@ -98,28 +98,10 @@
border-width: 0;
}
#crm-container .gift-aid .contribution > td:first-child::before {
content: "";
width: 10px;
height: 10px;
margin-right: 5px;
display: inline-block;
background: url("/sites/all/modules/civicrm/i/icons/jquery-ui-3E3E3E.png") no-repeat -68px -20px;
}
#crm-container .gift-aid .contribution.collapsed > td:first-child::before {
background-position: -37px -20px;
}
#crm-container .gift-aid .contribution a:hover {
text-decoration: underline;
}
#crm-container .gift-aid .line-items-container > td {
padding: 0;
border: none;
}
#crm-container .gift-aid .line-items {
width: 98%;
padding: 0;
......
......@@ -23,7 +23,6 @@ CRM.$(function($) {
setup: function () {
this.configure();
this.init();
this.createBindings();
},
/**
* Set variables and other configurations to be used in the later stages
......@@ -34,11 +33,6 @@ CRM.$(function($) {
* Initialise
*/
init: function () {
},
/**
* Create bindings
*/
createBindings: function () {
}
};
......@@ -59,21 +53,5 @@ CRM.$(function($) {
this.lineItems.toggle();
};
BatchOperations.createBindings = function () {
this.contributions.on('click', function () {
var contribution = cj(this);
var contributionId = contribution.data('contribution-id');
var financialItems = cj('#line-items-' + contributionId);
contribution.toggleClass('collapsed');
if (contribution.hasClass('collapsed')) {
financialItems.fadeOut(100);
} else {
financialItems.fadeIn(100);
}
});
};
BatchOperations.setup();
});
\ No newline at end of file
});
......@@ -3,178 +3,169 @@
*}
<div id="gift-aid-add" class="crm-block crm-form-block crm-export-form-block gift-aid">
<h2>{ts}Add To Gift Aid{/ts}</h2>
<h2>{ts}Add To Gift Aid{/ts}</h2>
<div class="help">
<p>{ts}Use this form to submit Gift Aid contributions. Note that this action is irreversible, i.e. you cannot take contributions out of a batch once they have been added.{/ts}</p>
<p><strong>Possible reasons for contributions not valid for gift aid:</strong></p>
<ol>
<li>Contribution status is not 'Completed'</li>
<li>Related Contact does not have a valid gift aid declaration</li>
<li>Related Contact's gift aid declaration does not cover the contribution date</li>
</ol>
</div>
<div class="help">
<p>{ts}Use this form to submit Gift Aid contributions. Note that this action is irreversible, i.e. you cannot take contributions out of a batch once they have been added.{/ts}</p>
<p><strong>Possible reasons for contributions not valid for gift aid:</strong></p>
<ol>
<li>Contribution status is not 'Completed'</li>
<li>Related Contact does not have a valid gift aid declaration</li>
<li>Related Contact's gift aid declaration does not cover the contribution date</li>
</ol>
</div>
<table class="form-layout">
<tr>
<td>
<table class="form-layout">
<tr>
<td class="label">{$form.title.label}</td>
<td>{$form.title.html}</td>
<tr>
<tr>
<td class="label">{$form.description.label}</td>
<td>{$form.description.html}</td>
</tr>
</table>
</td>
</tr>
</table>
<table class="form-layout">
<tr>
<td>
<table class="form-layout">
<tr>
<td class="label">{$form.title.label}</td>
<td>{$form.title.html}</td>
<tr>
<tr>
<td class="label">{$form.description.label}</td>
<td>{$form.description.html}</td>
</tr>
</table>
</td>
</tr>
</table>
<div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl"}</div>
<div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl"}</div>
<div class="clear"></div>
<div class="clear"></div>
<h3>{ts}Summary{/ts}</h3>
<h3>{ts}Summary{/ts}</h3>
<p>Number of contributions that were selected: {$selectedContributions}</p>
<p>Number of contributions that were selected: {$selectedContributions}</p>
{if $totalAddedContributions}
<div class="crm-accordion-wrapper crm-accordion_title-accordion crm-accordion-closed">
<div class="crm-accordion-header">
Number of contributions that will be added to this batch: {$totalAddedContributions}
</div>
<!-- /.crm-accordion-header -->
<div class="crm-accordion-body">
<table class="selector">
<thead>
<tr>
<th>{ts}Name{/ts}</th>
<th>{ts}Gift Aidable Amount{/ts}</th>
<th>{ts}Total Amount{/ts}</th>
<th>{ts}No of items{/ts}</th>
<th>{ts}Type{/ts}</th>
<th>{ts}Source{/ts}</th>
<th>{ts}Received{/ts}</th>
</tr>
</thead>
{foreach from=$contributionsAddedRows item=row}
<tr class="contribution" data-contribution-id="{$row.contribution_id}">
<td>
<a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=`$row.contact_id`"}">{$row.display_name}</a>
</td>
<td>{$row.gift_aidable_amount|crmMoney:$row.currency}</td>
<td>{$row.total_amount|crmMoney:$row.currency}</td>
<td>{$row.line_items_count}</td>
<td>{$row.financial_account}</td>
<td>{$row.source}</td>
<td>{$row.receive_date}</td>
</tr>
<tr class="line-items-container">
<td colspan="7">
{include file="CRM/Civigiftaid/Form/Task/LineItems.tpl" contributionId=$row.contribution_id}
</td>
</tr>
{/foreach}
</table>
</div>
<!-- /.crm-accordion-body -->
</div>
<!-- /.crm-accordion-wrapper -->
{else}
{include file="CRM/Civigiftaid/Form/Task/EmptyAccordion.tpl" content="Number of contributions that will be added to this batch: $totalAddedContributions"}
{/if}
{if $alreadyAddedContributions}
<div class="crm-accordion-wrapper crm-accordion_title-accordion crm-accordion-closed">
<div class="crm-accordion-header">
Number of contributions already in a batch (will not be added to batch): {$alreadyAddedContributions}
</div>
<!-- /.crm-accordion-header -->
<div class="crm-accordion-body">
<table class="selector">
<thead>
<tr>
<th>{ts}Name{/ts}</th>
<th>{ts}Gift Aidable Amount{/ts}</th>
<th>{ts}Total Amount{/ts}</th>
<th>{ts}No of items{/ts}</th>
<th>{ts}Type{/ts}</th>
<th>{ts}Source{/ts}</th>
<th>{ts}Received{/ts}</th>
<th>{ts}Batch{/ts}</th>
</tr>
</thead>
{foreach from=$contributionsAlreadyAddedRows item=row}
<tr class="contribution" data-contribution-id="{$row.contribution_id}">
<td>
<a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=`$row.contact_id`"}">{$row.display_name}</a>
</td>
<td>{$row.gift_aidable_amount|crmMoney:$row.currency}</td>
<td>{$row.total_amount|crmMoney:$row.currency}</td>
<td>{$row.line_items_count}</td>
<td>{$row.financial_account}</td>
<td>{$row.source}</td>
<td>{$row.receive_date}</td>
<td>{$row.batch}</td>
</tr>
<tr class="line-items-container">
<td colspan="8">
{include file="CRM/Civigiftaid/Form/Task/LineItems.tpl" contributionId=$row.contribution_id}
</td>
</tr>
{/foreach}
</table>
</div>
<!-- /.crm-accordion-body -->
</div>
<!-- /.crm-accordion-wrapper -->
{else}
{include file="CRM/Civigiftaid/Form/Task/EmptyAccordion.tpl" content="Number of contributions already in a batch: $alreadyAddedContributions"}
{/if}
{if $notValidContributions}
<div class="crm-accordion-wrapper crm-accordion_title-accordion crm-accordion-closed">
<div class="crm-accordion-header">
Number of contributions not valid for gift aid (will not be added to batch): {$notValidContributions}
</div>
<!-- /.crm-accordion-header -->
<div class="crm-accordion-body">
<table class="selector">
<thead>
<tr>
<th>{ts}Name{/ts}</th>
<th>{ts}Gift Aidable Amount{/ts}</th>
<th>{ts}Total Amount{/ts}</th>
<th>{ts}No of items{/ts}</th>
<th>{ts}Type{/ts}</th>
<th>{ts}Source{/ts}</th>
<th>{ts}Received{/ts}</th>
</tr>
</thead>
{foreach from=$contributionsNotValid item=row}
<tr class="contribution" data-contribution-id="{$row.contribution_id}">
<td>
<a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=`$row.contact_id`"}">{$row.display_name}</a>
</td>
<td>{$row.gift_aidable_amount|crmMoney:$row.currency}</td>
<td>{$row.total_amount|crmMoney:$row.currency}</td>
<td>{$row.line_items_count}</td>
<td>{$row.financial_account}</td>
<td>{$row.source}</td>
<td>{$row.receive_date}</td>
</tr>
<tr class="line-items-container">
<td colspan="7">
{include file="CRM/Civigiftaid/Form/Task/LineItems.tpl" contributionId=$row.contribution_id}
</td>
</tr>
{/foreach}
</table>
</div>
<!-- /.crm-accordion-body -->
</div>
<!-- /.crm-accordion-wrapper -->
{else}
{include file="CRM/Civigiftaid/Form/Task/EmptyAccordion.tpl" content="Number of contributions not valid for gift aid: $notValidContributions"}
{/if}
{if $totalAddedContributions}
<div class="crm-accordion-wrapper crm-accordion_title-accordion crm-accordion-closed">
<div class="crm-accordion-header">
Number of contributions that will be added to this batch: {$totalAddedContributions}
</div>
<!-- /.crm-accordion-header -->
<div class="crm-accordion-body">
<table class="selector">
<thead>
<tr>
<th>{ts}Name{/ts}</th>
<th>{ts}Gift Aidable Amount{/ts}</th>
<th>{ts}Total Amount{/ts}</th>
<th>{ts}No of items{/ts}</th>
<th>{ts}Type{/ts}</th>
<th>{ts}Source{/ts}</th>
<th>{ts}Received{/ts}</th>
<th>{ts}Actions{/ts}</th>
</tr>
</thead>
{foreach from=$contributionsAddedRows item=row}
<tr class="contribution" data-contribution-id="{$row.contribution_id}">
<td>
<a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=`$row.contact_id`"}">{$row.display_name}</a>
</td>
<td>{$row.gift_aidable_amount|crmMoney:$row.currency}</td>
<td>{$row.total_amount|crmMoney:$row.currency}</td>
<td>{$row.line_items_count}</td>
<td>{$row.financial_account}</td>
<td>{$row.source}</td>
<td>{$row.receive_date}</td>
<td>{$row.actions}</td>
</tr>
{/foreach}
</table>
</div>
<!-- /.crm-accordion-body -->
</div>
<!-- /.crm-accordion-wrapper -->
{else}
{include file="CRM/Civigiftaid/Form/Task/EmptyAccordion.tpl" content="Number of contributions that will be added to this batch: $totalAddedContributions"}
{/if}
{if $alreadyAddedContributions}
<div class="crm-accordion-wrapper crm-accordion_title-accordion crm-accordion-closed">
<div class="crm-accordion-header">
Number of contributions already in a batch (will not be added to batch): {$alreadyAddedContributions}
</div>
<!-- /.crm-accordion-header -->
<div class="crm-accordion-body">
<table class="selector">
<thead>
<tr>
<th>{ts}Name{/ts}</th>
<th>{ts}Gift Aidable Amount{/ts}</th>
<th>{ts}Total Amount{/ts}</th>
<th>{ts}No of items{/ts}</th>
<th>{ts}Type{/ts}</th>
<th>{ts}Source{/ts}</th>
<th>{ts}Received{/ts}</th>
<th>{ts}Batch{/ts}</th>
<th>{ts}Actions{/ts}</th>
</tr>
</thead>
{foreach from=$contributionsAlreadyAddedRows item=row}
<tr class="contribution" data-contribution-id="{$row.contribution_id}">
<td>
<a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=`$row.contact_id`"}">{$row.display_name}</a>
</td>
<td>{$row.gift_aidable_amount|crmMoney:$row.currency}</td>
<td>{$row.total_amount|crmMoney:$row.currency}</td>
<td>{$row.line_items_count}</td>
<td>{$row.financial_account}</td>
<td>{$row.source}</td>
<td>{$row.receive_date}</td>
<td>{$row.batch}</td>
<td>{$row.actions}</td>
</tr>
{/foreach}
</table>
</div>
<!-- /.crm-accordion-body -->
</div>
<!-- /.crm-accordion-wrapper -->
{else}
{include file="CRM/Civigiftaid/Form/Task/EmptyAccordion.tpl" content="Number of contributions already in a batch: $alreadyAddedContributions"}
{/if}
{if $notValidContributions}
<div class="crm-accordion-wrapper crm-accordion_title-accordion crm-accordion-closed">
<div class="crm-accordion-header">
Number of contributions not valid for gift aid (will not be added to batch): {$notValidContributions}
</div>
<!-- /.crm-accordion-header -->
<div class="crm-accordion-body">
<table class="selector">
<thead>
<tr>
<th>{ts}Name{/ts}</th>
<th>{ts}Gift Aidable Amount{/ts}</th>
<th>{ts}Total Amount{/ts}</th>
<th>{ts}No of items{/ts}</th>
<th>{ts}Type{/ts}</th>
<th>{ts}Source{/ts}</th>
<th>{ts}Received{/ts}</th>
<th>{ts}Actions{/ts}</th>
</tr>
</thead>
{foreach from=$contributionsNotValid item=row}
<tr class="contribution" data-contribution-id="{$row.contribution_id}">
<td>
<a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=`$row.contact_id`"}">{$row.display_name}</a>
</td>
<td>{$row.gift_aidable_amount|crmMoney:$row.currency}</td>
<td>{$row.total_amount|crmMoney:$row.currency}</td>
<td>{$row.line_items_count}</td>
<td>{$row.financial_account}</td>
<td>{$row.source}</td>
<td>{$row.receive_date}</td>
<td>{$row.actions}</td>
</tr>
{/foreach}
</table>
</div>
<!-- /.crm-accordion-body -->
</div>
<!-- /.crm-accordion-wrapper -->
{else}
{include file="CRM/Civigiftaid/Form/Task/EmptyAccordion.tpl" content="Number of contributions not valid for gift aid: $notValidContributions"}
{/if}
</div>
{*
* https://civicrm.org/license
*}
{if $row.line_items}
<table class="line-items" id="line-items-{$contributionId}">
<tr>
<th>Item</th>
<th>Quantity</th>
<th>Type</th>
<th>Description</th>
<th>Total Amount</th>
</tr>
{assign var="count" value=0}
{foreach from=$row.line_items item=item}
<tr {if $count % 2 !== 0 }class="odd"{/if}>
<td>{$item.item}</td>
<td>{$item.qty}</td>
<td>{$item.financial_type}</td>
<td>{$item.description}</td>
<td>{$item.amount}</td>
</tr>
{assign var="count" value=$count+1}
{/foreach}
</table>
{else}
<div class="line-items" id="line-items-{$contributionId}">
<p>No gift aidable line items found for the contribution.</p>
</div>
{/if}
\ No newline at end of file
......@@ -3,156 +3,147 @@
*}
<div id="gift-aid-remove" class="crm-block crm-form-block crm-export-form-block gift-aid">
<h2>{ts}Remove contribution from Gift Aid batch{/ts}</h2>
<h2>{ts}Remove contribution from Gift Aid batch{/ts}</h2>
<div class="help">
<p>{ts}Use this form to remove Gift Aid contributions from the batch. You can remove multiple contributions from different batches. All gift aid field values including the amount of gift aid will be removed from the contribution record. If you are using the online gift aid submission module and the batch has been submitted, the form below will state the contibution has been submitted and you cannot remove this from the batch.{/ts}</p>
</div>
<div class="help">
<p>{ts}Use this form to remove Gift Aid contributions from the batch. You can remove multiple contributions from different batches. All gift aid field values including the amount of gift aid will be removed from the contribution record. If you are using the online gift aid submission module and the batch has been submitted, the form below will state the contibution has been submitted and you cannot remove this from the batch.{/ts}</p>
</div>
<h3>{ts}Summary{/ts}</h3>
<h3>{ts}Summary{/ts}</h3>
<p>Number of selected contributions: {$selectedContributions}</p>
<p>Number of selected contributions: {$selectedContributions}</p>
{if $totalToRemoveContributions}
<div class="crm-accordion-wrapper crm-accordion_title-accordion crm-accordion-closed">
<div class="crm-accordion-header">
Number of contributions that will be removed from batch: {$totalToRemoveContributions}
</div>
<!-- /.crm-accordion-header -->
<div class="crm-accordion-body">
<table class="selector">
<thead>
<tr>
<th>{ts}Name{/ts}</th>
<th>{ts}Gift Aidable Amount{/ts}</th>
<th>{ts}Total Amount{/ts}</th>
<th>{ts}No of items{/ts}</th>
<th>{ts}Type{/ts}</th>
<th>{ts}Source{/ts}</th>
<th>{ts}Recieved{/ts}</th>
<th>{ts}Batch name{/ts}</th>
</tr>
</thead>
{foreach from=$contributionsToRemoveRows item=row}
<tr class="contribution" data-contribution-id="{$row.contribution_id}">
<td>
<a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=`$row.contact_id`"}">{$row.display_name}</a>
</td>
<td>{$row.gift_aidable_amount}</td>
<td>{$row.total_amount}</td>
<td>{$row.line_items|@count}</td>
<td>{$row.financial_account}</td>
<td>{$row.source}</td>
<td>{$row.receive_date}</td>
<td>{$row.batch}</td>
</tr>
<tr class="line-items-container">
<td colspan="8">
{include file="CRM/Civigiftaid/Form/Task/LineItems.tpl" contributionId=$row.contribution_id}
</td>
</tr>
{/foreach}
</table>
</div>