Skip to content

Commit

Permalink
Rework on the relative and absolute dates
Browse files Browse the repository at this point in the history
  • Loading branch information
VangelisP committed Oct 24, 2019
1 parent f73c243 commit c4f0bf3
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions CRM/Contact/Form/Search/Custom/ContributionAggregate.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,20 +226,29 @@ public function where($includeContactIDs = FALSE) {
);
}

foreach (CRM_Contact_BAO_Query::convertFormValues($dateParams) as $values) {
list($name, $op, $value) = $values;
if (strstr($name, '_low')) {
if (strlen($value) == 10) {
$value .= ' 00:00:00';
}
$clauses[] = "contrib.receive_date >= '{$value}'";
if ($dateParams['receive_date_relative']) {
list($relativeFrom, $relativeTo) = CRM_Utils_Date::getFromTo($dateParams['receive_date_relative'], $dateParams['receive_date_low'], $dateParams['receive_date_high']);
}
else {
if (strlen($dateParams['receive_date_low']) == 10) {
$relativeFrom = $dateParams['receive_date_low'] . ' 00:00:00';
}
else {
if (strlen($value) == 10) {
$value .= ' 23:59:59';
}
$clauses[] = "contrib.receive_date <= '{$value}'";
$relativeFrom = $dateParams['receive_date_low'];
}
if (strlen($dateParams['receive_date_high']) == 10) {
$relativeTo = $dateParams['receive_date_high'] . ' 23:59:59';
}
else {
$relativeTo = $dateParams['receive_date_high'];
}
}

if ($relativeFrom) {
$clauses[] = "contrib.receive_date >= '{$relativeFrom}'";
}
if ($relativeTo) {
$clauses[] = "contrib.receive_date <= '{$relativeTo}'";
}

if ($includeContactIDs) {
Expand Down

0 comments on commit c4f0bf3

Please sign in to comment.