Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ayduns
ukgiftaid
Commits
32d58fc2
Commit
32d58fc2
authored
Mar 24, 2021
by
mattwire
Browse files
Revert "Fix #25: consider addresses from declarations in the next 4 years"
This reverts commit
36bfe35e
.
parent
13e7a222
Changes
1
Hide whitespace changes
Inline
Side-by-side
CRM/Civigiftaid/Declaration.php
View file @
32d58fc2
...
...
@@ -656,59 +656,6 @@ class CRM_Civigiftaid_Declaration {
$aAddress
[
'postcode'
]
=
self
::
getPostCode
(
$oDao
->
postcode
);
}
// To avoid conflicts, we only check for declarations in the
// next 4 years if we didn't find an active declaration in the
// date of the contribution
if
(
is_null
(
$aAddress
[
'address'
]))
{
$aAddress
=
self
::
getDonorAddressIn4YearsDeclaration
(
$contactID
,
$contributionReceiveDate
);
}
return
$aAddress
;
}
/**
* Get an donor address from a declaration made in the 4 years after the
* contribution with a eligibility of type:
*
* > "Yes, and for donations made in the past 4 years"
*
* @param int $contactID
* @param string $contributionReceiveDate
*
* @return mixed
*/
private
static
function
getDonorAddressIn4YearsDeclaration
(
$contactID
,
$contributionReceiveDate
)
{
$contributionReceiveDate
=
date
(
'Ymd'
,
strtotime
(
$contributionReceiveDate
))
.
'235959'
;
$aAddress
=
[];
$sSql
=
"
SELECT
address AS address,
post_code AS postcode
FROM civicrm_value_gift_aid_declaration
WHERE
entity_id = %1 AND
start_date <= %2 AND (
end_date IS NULL OR
DATE_ADD( end_date, INTERVAL 4 YEAR ) >= %2
) AND
eligible_for_gift_aid = 3
ORDER BY start_date ASC
LIMIT 1
"
;
$aParams
=
[
1
=>
[
$contactID
,
'Integer'
],
2
=>
[
$contributionReceiveDate
,
'Timestamp'
]
];
$oDao
=
CRM_Core_DAO
::
executeQuery
(
$sSql
,
$aParams
);
if
(
$oDao
->
fetch
())
{
$aAddress
[
'address'
]
=
$oDao
->
address
;
$aAddress
[
'house'
]
=
substr
(
explode
(
','
,
$oDao
->
address
)[
0
]
??
''
,
0
,
40
);
$aAddress
[
'postcode'
]
=
self
::
getPostCode
(
$oDao
->
postcode
);
}
return
$aAddress
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment